[BACK]Return to cvs.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/cvs.h, Revision 1.119

1.119   ! xsa         1: /*     $OpenBSD: cvs.h,v 1.118 2006/11/09 10:08:33 xsa Exp $   */
1.1       jfb         2: /*
                      3:  * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
1.35      tedu        4:  * All rights reserved.
1.1       jfb         5:  *
1.35      tedu        6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
1.1       jfb         9:  *
1.35      tedu       10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
1.1       jfb        12:  * 2. The name of the author may not be used to endorse or promote products
1.35      tedu       13:  *    derived from this software without specific prior written permission.
1.1       jfb        14:  *
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
                     16:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
                     17:  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
                     18:  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
                     19:  * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
                     20:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
                     21:  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
                     22:  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
                     23:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
1.35      tedu       24:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1       jfb        25:  */
                     26:
                     27: #ifndef CVS_H
                     28: #define CVS_H
1.9       jfb        29:
1.1       jfb        30: #include "rcs.h"
1.104     joris      31: #include "xmalloc.h"
                     32: #include "util.h"
1.19      jfb        33: #include "file.h"
1.104     joris      34: #include "repository.h"
                     35: #include "worklist.h"
1.1       jfb        36:
1.104     joris      37: #define CVS_VERSION_MINOR      "0"
                     38: #define CVS_VERSION_MAJOR      "1"
                     39: #define CVS_VERSION_PORT
                     40:
                     41: #define CVS_VERSION            \
                     42:        "OpenCVS version "      \
                     43:        CVS_VERSION_MAJOR "." CVS_VERSION_MINOR CVS_VERSION_PORT
1.1       jfb        44:
1.74      xsa        45: #define CVS_HIST_CACHE 128
                     46: #define CVS_HIST_NBFLD 6
1.1       jfb        47:
1.74      xsa        48: #define CVS_CKSUM_LEN  33      /* length of a CVS checksum string */
1.1       jfb        49:
                     50: /* operations */
1.74      xsa        51: #define CVS_OP_UNKNOWN         0
                     52: #define CVS_OP_ADD             1
                     53: #define CVS_OP_ADMIN           2
                     54: #define CVS_OP_ANNOTATE                3
                     55: #define CVS_OP_CHECKOUT                4
                     56: #define CVS_OP_COMMIT          5
                     57: #define CVS_OP_DIFF            6
                     58: #define CVS_OP_EDIT            7
                     59: #define CVS_OP_EDITORS         8
                     60: #define CVS_OP_EXPORT          9
                     61: #define CVS_OP_HISTORY         10
                     62: #define CVS_OP_IMPORT          11
                     63: #define CVS_OP_INIT            12
                     64: #define CVS_OP_LOG             13
                     65: #define CVS_OP_RANNOTATE       14
                     66: #define CVS_OP_RDIFF           15
                     67: #define CVS_OP_RELEASE         16
                     68: #define CVS_OP_REMOVE          17
                     69: #define CVS_OP_RLOG            18
                     70: #define CVS_OP_RTAG            19
                     71: #define CVS_OP_SERVER          20
                     72: #define CVS_OP_STATUS          21
                     73: #define CVS_OP_TAG             22
                     74: #define CVS_OP_UNEDIT          23
                     75: #define CVS_OP_UPDATE          24
                     76: #define CVS_OP_VERSION         25
                     77: #define CVS_OP_WATCH           26
                     78: #define CVS_OP_WATCHERS                27
1.1       jfb        79:
1.74      xsa        80: #define CVS_OP_ANY             64      /* all operations */
1.1       jfb        81:
                     82: /* methods */
1.74      xsa        83: #define CVS_METHOD_NONE                0
                     84: #define CVS_METHOD_LOCAL       1       /* local access */
                     85: #define CVS_METHOD_SERVER      2       /* tunnel through CVS_RSH */
                     86: #define CVS_METHOD_PSERVER     3       /* cvs pserver */
                     87: #define CVS_METHOD_KSERVER     4       /* kerberos */
                     88: #define CVS_METHOD_GSERVER     5       /* gssapi server */
                     89: #define CVS_METHOD_EXT         6
                     90: #define CVS_METHOD_FORK                7       /* local but fork */
                     91:
                     92: #define CVS_CMD_MAXNAMELEN     16
                     93: #define CVS_CMD_MAXALIAS       2
                     94: #define CVS_CMD_MAXDESCRLEN    64
                     95: #define CVS_CMD_MAXARG         128
1.1       jfb        96:
                     97: /* defaults */
1.74      xsa        98: #define CVS_SERVER_DEFAULT     "cvs"
                     99: #define CVS_RSH_DEFAULT                "ssh"
                    100: #define CVS_EDITOR_DEFAULT     "vi"
1.77      xsa       101: #define CVS_TMPDIR_DEFAULT     "/tmp"
1.107     joris     102: #define CVS_UMASK_DEFAULT      002
1.1       jfb       103:
1.70      xsa       104: /* extensions */
                    105: #define CVS_DESCR_FILE_EXT     ",t"
1.1       jfb       106:
                    107: /* server-side paths */
1.108     joris     108: #define CVS_PATH_DEVNULL       "/dev/null"
1.74      xsa       109: #define CVS_PATH_ROOT          "CVSROOT"
                    110: #define CVS_PATH_EMPTYDIR      CVS_PATH_ROOT "/Emptydir"
1.112     xsa       111: #define CVS_PATH_CHECKOUTLIST  CVS_PATH_ROOT "/checkoutlist"
1.74      xsa       112: #define CVS_PATH_COMMITINFO    CVS_PATH_ROOT "/commitinfo"
                    113: #define CVS_PATH_CONFIG                CVS_PATH_ROOT "/config"
                    114: #define CVS_PATH_CVSIGNORE     CVS_PATH_ROOT "/cvsignore"
                    115: #define CVS_PATH_CVSWRAPPERS   CVS_PATH_ROOT "/cvswrappers"
                    116: #define CVS_PATH_EDITINFO      CVS_PATH_ROOT "/editinfo"
                    117: #define CVS_PATH_HISTORY       CVS_PATH_ROOT "/history"
                    118: #define CVS_PATH_LOGINFO       CVS_PATH_ROOT "/loginfo"
                    119: #define CVS_PATH_MODULES       CVS_PATH_ROOT "/modules"
1.101     xsa       120: #define CVS_PATH_NOTIFY_R      CVS_PATH_ROOT "/notify"
1.74      xsa       121: #define CVS_PATH_RCSINFO       CVS_PATH_ROOT "/rcsinfo"
                    122: #define CVS_PATH_TAGINFO       CVS_PATH_ROOT "/taginfo"
1.112     xsa       123: #define CVS_PATH_VALTAGS       CVS_PATH_ROOT "/val-tags"
1.74      xsa       124: #define CVS_PATH_VERIFYMSG     CVS_PATH_ROOT "/verifymsg"
1.1       jfb       125:
                    126: /* client-side paths */
1.74      xsa       127: #define CVS_PATH_RC            ".cvsrc"
                    128: #define CVS_PATH_CVSDIR                "CVS"
1.100     xsa       129: #define CVS_PATH_BASEDIR       CVS_PATH_CVSDIR "/Base"
                    130: #define CVS_PATH_BASEREV       CVS_PATH_CVSDIR "/Baserev"
                    131: #define CVS_PATH_BASEREVTMP    CVS_PATH_CVSDIR "/Baserev.tmp"
                    132: #define CVS_PATH_CHECKINPROG   CVS_PATH_CVSDIR "/Checkin.prog"
1.74      xsa       133: #define CVS_PATH_ENTRIES       CVS_PATH_CVSDIR "/Entries"
                    134: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
                    135: #define CVS_PATH_LOGENTRIES    CVS_PATH_CVSDIR "/Entries.Log"
1.89      joris     136: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.100     xsa       137: #define CVS_PATH_NOTIFY                CVS_PATH_CVSDIR "/Notify"
                    138: #define CVS_PATH_NOTIFYTMP     CVS_PATH_CVSDIR "/Notify.tmp"
1.74      xsa       139: #define CVS_PATH_ROOTSPEC      CVS_PATH_CVSDIR "/Root"
                    140: #define CVS_PATH_REPOSITORY    CVS_PATH_CVSDIR "/Repository"
1.81      xsa       141: #define CVS_PATH_TAG           CVS_PATH_CVSDIR "/Tag"
1.100     xsa       142: #define CVS_PATH_TEMPLATE      CVS_PATH_CVSDIR "/Template"
                    143: #define CVS_PATH_UPDATEPROG    CVS_PATH_CVSDIR "/Update.prog"
1.110     joris     144: #define CVS_PATH_ATTIC         "Attic"
1.1       jfb       145:
1.46      joris     146: struct cvs_cmd {
1.103     joris     147:        u_int    cmd_op;
                    148:        u_int    cmd_req;
1.86      reyk      149:        char     cmd_name[CVS_CMD_MAXNAMELEN];
                    150:        char     cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
                    151:        char     cmd_descr[CVS_CMD_MAXDESCRLEN];
                    152:        char    *cmd_synopsis;
                    153:        char    *cmd_opts;
                    154:        char    *cmd_defargs;
1.58      jfb       155:
1.104     joris     156:        int     (*cmd)(int, char **);
                    157: };
                    158:
                    159: struct cvsroot;
1.58      jfb       160:
1.104     joris     161: struct cvs_recursion {
                    162:        void    (*enterdir)(struct cvs_file *);
                    163:        void    (*leavedir)(struct cvs_file *);
1.114     joris     164:        void    (*fileproc)(struct cvs_file *);
1.106     joris     165:        int     flags;
1.46      joris     166: };
1.106     joris     167:
                    168: #define CR_RECURSE_DIRS                0x01
                    169: #define CR_ATTIC               0x02
                    170: #define CR_REPO                        0x04
1.1       jfb       171:
1.41      jfb       172: struct cvs_var {
                    173:        char   *cv_name;
                    174:        char   *cv_val;
                    175:        TAILQ_ENTRY(cvs_var) cv_link;
                    176: };
                    177:
1.74      xsa       178: #define CVS_ROOT_CONNECTED     0x01
1.36      jfb       179:
1.1       jfb       180: struct cvsroot {
1.11      jfb       181:        char   *cr_str;
1.1       jfb       182:        u_int   cr_method;
                    183:        char   *cr_buf;
                    184:        char   *cr_user;
                    185:        char   *cr_pass;
                    186:        char   *cr_host;
                    187:        char   *cr_dir;
                    188:        u_int   cr_port;
1.11      jfb       189:        u_int   cr_ref;
                    190:
                    191:        /* connection data */
1.36      jfb       192:        u_int   cr_flags;
1.11      jfb       193:        FILE   *cr_srvin;
                    194:        FILE   *cr_srvout;
1.21      jfb       195:        FILE   *cr_srverr;
1.29      jfb       196:        char   *cr_version;     /* version of remote server */
                    197:        u_char  cr_vrmask[16];  /* mask of valid requests supported by server */
1.78      joris     198:
                    199:        TAILQ_ENTRY(cvsroot) root_cache;
1.1       jfb       200: };
1.20      jfb       201:
1.74      xsa       202: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |=  (1 << ((rq) % 8)))
                    203: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &   (1 << ((rq) % 8)))
                    204: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
                    205: #define CVS_RSTVR(rt)  memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
                    206:
                    207: #define CVS_HIST_ADDED         'A'
                    208: #define CVS_HIST_EXPORT                'E'
                    209: #define CVS_HIST_RELEASE       'F'
                    210: #define CVS_HIST_MODIFIED      'M'
                    211: #define CVS_HIST_CHECKOUT      'O'
                    212: #define CVS_HIST_COMMIT                'R'
                    213: #define CVS_HIST_TAG           'T'
                    214:
                    215: #define CVS_DATE_DUMMY "dummy timestamp"
                    216: #define CVS_DATE_DMSEC (time_t)-1
                    217:
                    218: #define CVS_ENT_NONE   0
                    219: #define CVS_ENT_FILE   1
                    220: #define CVS_ENT_DIR    2
                    221:
                    222: #define CVS_ENT_REG            0
                    223: #define CVS_ENT_ADDED          1
                    224: #define CVS_ENT_REMOVED                2
                    225: #define CVS_ENT_UPTODATE       3
1.80      xsa       226:
                    227: #define CVS_ENT_MAXLINELEN     1024
1.1       jfb       228:
1.104     joris     229: #define ENT_NOSYNC     0
                    230: #define ENT_SYNC       1
1.17      jfb       231:
1.85      joris     232: #define STRIP_SLASH(p)                                 \
                    233:        do {                                            \
                    234:                size_t _slen;                           \
                    235:                _slen = strlen(p);                      \
                    236:                while ((_slen > 0) && (p[_slen - 1] == '/'))    \
                    237:                        p[--_slen] = '\0';              \
                    238:        } while (0)
1.104     joris     239:
1.1       jfb       240: struct cvs_ent {
1.104     joris     241:        char            *ce_buf;
                    242:        char            *ce_name;
                    243:        char            *ce_opts;
                    244:        char            *ce_tag;
                    245:        char            *ce_conflict;
                    246:        time_t           ce_mtime;
                    247:        u_int16_t        ce_type;
                    248:        u_int16_t        ce_status;
                    249:        RCSNUM          *ce_rev;
                    250: };
                    251:
                    252: struct cvs_ent_line {
                    253:        char    *buf;
                    254:        TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1       jfb       255: };
                    256:
                    257: typedef struct cvs_entries {
1.74      xsa       258:        char    *cef_path;
1.89      joris     259:        char    *cef_bpath;
1.104     joris     260:        char    *cef_lpath;
1.1       jfb       261:
1.104     joris     262:        TAILQ_HEAD(, cvs_ent_line)       cef_ent;
1.1       jfb       263: } CVSENTRIES;
                    264:
1.104     joris     265: extern struct cvs_wklhead temp_files;
                    266: extern volatile sig_atomic_t sig_received;
                    267: extern volatile sig_atomic_t cvs_quit;
                    268: extern struct cvsroot *current_cvsroot;
1.107     joris     269: extern char *cvs_tagname;
1.22      jfb       270: extern char *cvs_command;
1.18      jfb       271: extern char *cvs_editor;
1.76      xsa       272: extern char *cvs_homedir;
1.30      krapht    273: extern char *cvs_msg;
1.42      jfb       274: extern char *cvs_rsh;
1.77      xsa       275: extern char *cvs_tmpdir;
1.110     joris     276: extern char *import_repository;
1.116     joris     277: extern char *cvs_server_path;
1.22      jfb       278:
1.107     joris     279: extern int  cvs_umask;
1.42      jfb       280: extern int  verbosity;
                    281: extern int  cvs_trace;
                    282: extern int  cvs_nolog;
                    283: extern int  cvs_compress;
                    284: extern int  cvs_cmdop;
                    285: extern int  cvs_nocase;
1.57      xsa       286: extern int  cvs_noexec;
1.42      jfb       287: extern int  cvs_readonly;
1.72      joris     288: extern int  cvs_error;
1.116     joris     289: extern int  cvs_server_active;
1.15      jfb       290:
1.58      jfb       291: extern struct cvs_cmd *cvs_cdt[];
1.1       jfb       292:
1.58      jfb       293: extern struct cvs_cmd cvs_cmd_add;
                    294: extern struct cvs_cmd cvs_cmd_admin;
                    295: extern struct cvs_cmd cvs_cmd_annotate;
                    296: extern struct cvs_cmd cvs_cmd_checkout;
                    297: extern struct cvs_cmd cvs_cmd_commit;
                    298: extern struct cvs_cmd cvs_cmd_diff;
                    299: extern struct cvs_cmd cvs_cmd_edit;
                    300: extern struct cvs_cmd cvs_cmd_editors;
                    301: extern struct cvs_cmd cvs_cmd_export;
                    302: extern struct cvs_cmd cvs_cmd_history;
                    303: extern struct cvs_cmd cvs_cmd_import;
                    304: extern struct cvs_cmd cvs_cmd_init;
                    305: extern struct cvs_cmd cvs_cmd_log;
                    306: extern struct cvs_cmd cvs_cmd_login;
                    307: extern struct cvs_cmd cvs_cmd_logout;
                    308: extern struct cvs_cmd cvs_cmd_rdiff;
                    309: extern struct cvs_cmd cvs_cmd_release;
                    310: extern struct cvs_cmd cvs_cmd_remove;
                    311: extern struct cvs_cmd cvs_cmd_rlog;
                    312: extern struct cvs_cmd cvs_cmd_rtag;
                    313: extern struct cvs_cmd cvs_cmd_status;
                    314: extern struct cvs_cmd cvs_cmd_tag;
                    315: extern struct cvs_cmd cvs_cmd_update;
                    316: extern struct cvs_cmd cvs_cmd_version;
                    317: extern struct cvs_cmd cvs_cmd_server;
                    318: extern struct cvs_cmd cvs_cmd_unedit;
                    319: extern struct cvs_cmd cvs_cmd_watch;
                    320: extern struct cvs_cmd cvs_cmd_watchers;
                    321:
1.104     joris     322: /* cmd.c */
1.74      xsa       323: struct cvs_cmd *cvs_findcmd(const char *);
                    324: struct cvs_cmd *cvs_findcmdbyreq(int);
                    325:
1.104     joris     326: /* cvs.c */
1.74      xsa       327: int             cvs_var_set(const char *, const char *);
                    328: int             cvs_var_unset(const char *);
                    329: const char     *cvs_var_get(const char *);
1.104     joris     330: void            cvs_cleanup(void);
1.1       jfb       331:
1.104     joris     332: /* date.y */
                    333: time_t          cvs_date_parse(const char *);
                    334:
                    335: /* entries.c */
                    336: struct cvs_ent *cvs_ent_parse(const char *);
                    337: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
                    338: CVSENTRIES     *cvs_ent_open(const char *);
                    339: void           cvs_ent_add(CVSENTRIES *, const char *);
                    340: void           cvs_ent_remove(CVSENTRIES *, const char *);
                    341: void           cvs_ent_close(CVSENTRIES *, int);
                    342: void           cvs_ent_free(struct cvs_ent *);
                    343: int            cvs_ent_exists(CVSENTRIES *, const char *);
1.113     xsa       344: void           cvs_parse_tagfile(char *, char **, char **, int *);
                    345: void           cvs_write_tagfile(char *, char *, char *, int);
1.1       jfb       346:
1.69      xsa       347: /* root.c */
1.74      xsa       348: struct cvsroot *cvsroot_parse(const char *);
1.104     joris     349: struct cvsroot *cvsroot_get(const char *);
1.83      joris     350: void            cvsroot_remove(struct cvsroot *);
1.87      joris     351:
1.104     joris     352: /* misc stuff */
                    353: void   cvs_update_local(struct cvs_file *);
                    354: void   cvs_update_enterdir(struct cvs_file *);
1.105     joris     355: void   cvs_update_leavedir(struct cvs_file *);
1.109     joris     356: void   cvs_checkout_file(struct cvs_file *, RCSNUM *, BUF *, int);
                    357: int    update_has_conflict_markers(struct cvs_file *);
                    358:
                    359: #define CO_MERGE       0x01
1.111     joris     360: #define CO_SETSTICKY   0x02
1.115     reyk      361: #define CO_DUMP                0x04
1.116     joris     362:
                    363: /* commands */
1.117     xsa       364: int    cvs_add(int, char **);
1.116     joris     365: int    cvs_commit(int, char **);
                    366: int    cvs_diff(int, char **);
1.118     xsa       367: int    cvs_getlog(int, char **);
1.119   ! xsa       368: int    cvs_init(int, char **);
1.117     xsa       369: int    cvs_remove(int, char **);
1.116     joris     370: int    cvs_status(int, char **);
1.118     xsa       371: int    cvs_tag(int, char **);
1.116     joris     372: int    cvs_update(int, char **);
1.1       jfb       373:
1.91      joris     374: #endif