[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.46

1.46    ! joris       1: /*     $OpenBSD: cvs.h,v 1.45 2005/03/06 21:09:00 joris 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
                     29:
                     30: #include <sys/param.h>
1.8       jfb        31: #include <stdio.h>
1.9       jfb        32: #include <dirent.h>
                     33:
1.1       jfb        34: #include "rcs.h"
1.19      jfb        35: #include "file.h"
1.1       jfb        36:
1.19      jfb        37: #define CVS_VERSION_MAJOR 0
                     38: #define CVS_VERSION_MINOR 2
                     39: #define CVS_VERSION       "OpenCVS 0.2"
1.1       jfb        40:
                     41:
                     42: #define CVS_HIST_CACHE     128
                     43: #define CVS_HIST_NBFLD     6
                     44:
                     45:
                     46: #define CVS_CKSUM_LEN      33     /* length of a CVS checksum string */
                     47:
                     48:
                     49: /* operations */
1.19      jfb        50: #define CVS_OP_UNKNOWN      0
1.1       jfb        51: #define CVS_OP_ADD          1
1.43      jfb        52: #define CVS_OP_ADMIN        2
                     53: #define CVS_OP_ANNOTATE     3
                     54: #define CVS_OP_CHECKOUT     4
                     55: #define CVS_OP_COMMIT       5
                     56: #define CVS_OP_DIFF         6
                     57: #define CVS_OP_EDIT         7
                     58: #define CVS_OP_EDITORS      8
                     59: #define CVS_OP_EXPORT       9
                     60: #define CVS_OP_HISTORY     10
                     61: #define CVS_OP_IMPORT      11
                     62: #define CVS_OP_INIT        12
                     63: #define CVS_OP_LOG         13
                     64: #define CVS_OP_RANNOTATE   14
                     65: #define CVS_OP_RDIFF       15
                     66: #define CVS_OP_RELEASE     16
                     67: #define CVS_OP_REMOVE      17
                     68: #define CVS_OP_RLOG        18
                     69: #define CVS_OP_RTAG        19
                     70: #define CVS_OP_SERVER      20
                     71: #define CVS_OP_STATUS      21
                     72: #define CVS_OP_TAG         22
                     73: #define CVS_OP_UNEDIT      23
                     74: #define CVS_OP_UPDATE      24
                     75: #define CVS_OP_VERSION     25
                     76: #define CVS_OP_WATCH       26
                     77: #define CVS_OP_WATCHERS    27
1.1       jfb        78:
1.19      jfb        79: #define CVS_OP_ANY         64     /* all operations */
1.1       jfb        80:
                     81:
                     82: /* methods */
                     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
1.34      jfb        95: #define CVS_CMD_MAXARG      128
1.1       jfb        96:
                     97:
                     98: /* defaults */
1.21      jfb        99: #define CVS_SERVER_DEFAULT  "cvs"
1.1       jfb       100: #define CVS_RSH_DEFAULT     "ssh"
                    101: #define CVS_EDITOR_DEFAULT  "vi"
                    102:
                    103:
                    104: /* server-side paths */
                    105: #define CVS_PATH_ROOT         "CVSROOT"
                    106: #define CVS_PATH_COMMITINFO   CVS_PATH_ROOT "/commitinfo"
                    107: #define CVS_PATH_CONFIG       CVS_PATH_ROOT "/config"
                    108: #define CVS_PATH_CVSIGNORE    CVS_PATH_ROOT "/cvsignore"
                    109: #define CVS_PATH_CVSWRAPPERS  CVS_PATH_ROOT "/cvswrappers"
                    110: #define CVS_PATH_EDITINFO     CVS_PATH_ROOT "/editinfo"
                    111: #define CVS_PATH_HISTORY      CVS_PATH_ROOT "/history"
                    112: #define CVS_PATH_LOGINFO      CVS_PATH_ROOT "/loginfo"
                    113: #define CVS_PATH_MODULES      CVS_PATH_ROOT "/modules"
                    114: #define CVS_PATH_NOTIFY       CVS_PATH_ROOT "/notify"
                    115: #define CVS_PATH_RCSINFO      CVS_PATH_ROOT "/rcsinfo"
                    116: #define CVS_PATH_TAGINFO      CVS_PATH_ROOT "/taginfo"
                    117: #define CVS_PATH_VERIFYMSG    CVS_PATH_ROOT "/verifymsg"
                    118:
                    119:
                    120: /* client-side paths */
                    121: #define CVS_PATH_RC             ".cvsrc"
                    122: #define CVS_PATH_CVSDIR         "CVS"
                    123: #define CVS_PATH_ENTRIES        CVS_PATH_CVSDIR "/Entries"
                    124: #define CVS_PATH_STATICENTRIES  CVS_PATH_CVSDIR "/Entries.Static"
                    125: #define CVS_PATH_LOGENTRIES     CVS_PATH_CVSDIR "/Entries.Log"
                    126: #define CVS_PATH_ROOTSPEC       CVS_PATH_CVSDIR "/Root"
1.10      jfb       127: #define CVS_PATH_REPOSITORY     CVS_PATH_CVSDIR "/Repository"
1.1       jfb       128:
1.46    ! joris     129: struct cvs_cmd_info {
        !           130:        /* parses the options for the command */
        !           131:        int (*cmd_options)(char *, int, char **, int *);
        !           132:
        !           133:        /* send command specific flags (CVS_METHOD_REMOTE only) */
        !           134:        int (*cmd_sendflags)(struct cvsroot *);
        !           135:
        !           136:        /* callback to be used for cvs_file_examine() */
        !           137:        int (*cmd_examine)(CVSFILE *, void *);
        !           138:
        !           139:        /* called after everything is done */
        !           140:        int (*cmd_cleanup)(void);
        !           141:
        !           142:        /* helper function, gets called after cvs_file_get()
        !           143:         * to do command specific operations if needed.
        !           144:         */
        !           145:        int (*cmd_helper)(void);
        !           146:
        !           147:        /* flags for cvs_file_get() */
        !           148:        int file_flags;
        !           149:
        !           150:        /* number of request */
        !           151:        int cmd_req;
        !           152:
        !           153:        /* info on the command (see flags below) */
        !           154:        int cmd_flags;
        !           155: };
        !           156:
        !           157: /* flags for cmd_flags */
        !           158: #define CVS_CMD_ALLOWSPEC      0x01
        !           159: #define CVS_CMD_NEEDLOG                0x02
        !           160: #define CVS_CMD_SENDARGS1      0x04
        !           161: #define CVS_CMD_SENDARGS2      0x08
        !           162: #define CVS_CMD_SENDDIR                0x10
        !           163:
        !           164: struct cvs_cmd {
        !           165:        int cmd_op;
        !           166:        char cmd_name[CVS_CMD_MAXNAMELEN];
        !           167:        char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
        !           168:        int (*cmd_hdlr)(int, char **);
        !           169:        char *cmd_synopsis;
        !           170:        char *cmd_opts;
        !           171:        char cmd_descr[CVS_CMD_MAXDESCRLEN];
        !           172:        char *cmd_defargs;
        !           173:        struct cvs_cmd_info *cmd_info;
        !           174: };
1.1       jfb       175:
1.7       jfb       176: struct cvs_file;
                    177: struct cvs_dir;
1.19      jfb       178: struct cvs_flist;
1.7       jfb       179:
1.41      jfb       180: struct cvs_var {
                    181:        char   *cv_name;
                    182:        char   *cv_val;
                    183:        TAILQ_ENTRY(cvs_var) cv_link;
                    184: };
                    185:
                    186:
                    187:
1.1       jfb       188: struct cvs_op {
1.19      jfb       189:        u_int             co_op;
                    190:        uid_t             co_uid;    /* user performing the operation */
                    191:        char             *co_tag;    /* tag or branch, NULL if HEAD */
                    192:        char             *co_msg;    /* message string (on commit or add) */
                    193:        struct cvs_flist  co_files;
1.1       jfb       194: };
                    195:
                    196:
1.36      jfb       197: #define CVS_ROOT_CONNECTED    0x01
                    198:
1.1       jfb       199: struct cvsroot {
1.11      jfb       200:        char   *cr_str;
1.1       jfb       201:        u_int   cr_method;
                    202:        char   *cr_buf;
                    203:        char   *cr_user;
                    204:        char   *cr_pass;
                    205:        char   *cr_host;
                    206:        char   *cr_dir;
                    207:        u_int   cr_port;
1.11      jfb       208:        u_int   cr_ref;
                    209:
                    210:        /* connection data */
1.36      jfb       211:        u_int   cr_flags;
1.11      jfb       212:        FILE   *cr_srvin;
                    213:        FILE   *cr_srvout;
1.21      jfb       214:        FILE   *cr_srverr;
1.29      jfb       215:        char   *cr_version;     /* version of remote server */
                    216:        u_char  cr_vrmask[16];  /* mask of valid requests supported by server */
1.1       jfb       217: };
1.20      jfb       218:
1.29      jfb       219: #define CVS_SETVR(rt, rq)  ((rt)->cr_vrmask[(rq) / 8] |=  (1 << ((rq) % 8)))
                    220: #define CVS_GETVR(rt, rq)  ((rt)->cr_vrmask[(rq) / 8] &   (1 << ((rq) % 8)))
                    221: #define CVS_CLRVR(rt, rq)  ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
1.20      jfb       222: #define CVS_RSTVR(rt)      memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
1.1       jfb       223:
                    224:
                    225: #define CVS_HIST_ADDED    'A'
                    226: #define CVS_HIST_EXPORT   'E'
                    227: #define CVS_HIST_RELEASE  'F'
                    228: #define CVS_HIST_MODIFIED 'M'
                    229: #define CVS_HIST_CHECKOUT 'O'
                    230: #define CVS_HIST_COMMIT   'R'
                    231: #define CVS_HIST_TAG      'T'
                    232:
                    233:
1.28      jfb       234: #define CVS_DATE_DUMMY  "dummy timestamp"
                    235: #define CVS_DATE_DMSEC  (time_t)-1
1.27      jfb       236:
1.1       jfb       237: #define CVS_ENT_NONE    0
                    238: #define CVS_ENT_FILE    1
                    239: #define CVS_ENT_DIR     2
1.27      jfb       240:
1.44      jfb       241: #define CVS_ENT_REG      0
                    242: #define CVS_ENT_ADDED    1
                    243: #define CVS_ENT_REMOVED  2
                    244:
1.1       jfb       245:
1.17      jfb       246: #define CVS_ENTF_SYNC   0x01    /* contents of disk and memory match */
                    247: #define CVS_ENTF_WR     0x02    /* file is opened for writing too */
                    248:
1.1       jfb       249:
                    250: struct cvs_ent {
1.44      jfb       251:        char      *ce_buf;
                    252:        u_int16_t  ce_type;
                    253:        u_int16_t  ce_status;
                    254:        char      *ce_name;
                    255:        RCSNUM    *ce_rev;
                    256:        time_t     ce_mtime;
                    257:        char      *ce_opts;
                    258:        char      *ce_tag;
1.4       jfb       259:        TAILQ_ENTRY(cvs_ent) ce_list;
1.1       jfb       260: };
                    261:
                    262: typedef struct cvs_entries {
                    263:        char    *cef_path;
1.3       jfb       264:        FILE    *cef_file;
1.17      jfb       265:        u_int    cef_flags;
1.1       jfb       266:
1.4       jfb       267:        TAILQ_HEAD(, cvs_ent) cef_ent;
                    268:        struct cvs_ent       *cef_cur;
1.1       jfb       269: } CVSENTRIES;
                    270:
                    271:
                    272: struct cvs_hent {
                    273:        char    ch_event;
                    274:        time_t  ch_date;
                    275:        uid_t   ch_uid;
                    276:        char   *ch_user;
                    277:        char   *ch_curdir;
                    278:        char   *ch_repo;
                    279:        RCSNUM *ch_rev;
                    280:        char   *ch_arg;
                    281: };
                    282:
                    283:
                    284: typedef struct cvs_histfile {
                    285:        int     chf_fd;
                    286:        char   *chf_buf;       /* read buffer */
                    287:        size_t  chf_blen;      /* buffer size */
                    288:        size_t  chf_bused;     /* bytes used in buffer */
                    289:
                    290:        off_t   chf_off;       /* next read */
                    291:        u_int   chf_sindex;    /* history entry index of first in array */
                    292:        u_int   chf_cindex;    /* current index (for getnext()) */
                    293:        u_int   chf_nbhent;    /* number of valid entries in the array */
                    294:
                    295:        struct cvs_hent chf_hent[CVS_HIST_CACHE];
                    296:
                    297: } CVSHIST;
                    298:
                    299:
1.15      jfb       300: #ifdef CVS
1.42      jfb       301:
1.22      jfb       302: extern char *cvs_command;
1.18      jfb       303: extern char *cvs_editor;
1.30      krapht    304: extern char *cvs_msg;
1.42      jfb       305: extern char *cvs_rsh;
1.22      jfb       306:
1.42      jfb       307: extern int  verbosity;
                    308: extern int  cvs_trace;
                    309: extern int  cvs_nolog;
                    310: extern int  cvs_compress;
                    311: extern int  cvs_cmdop;
                    312: extern int  cvs_nocase;
                    313: extern int  cvs_readonly;
1.22      jfb       314:
1.23      jfb       315: extern CVSFILE *cvs_files;
                    316:
1.15      jfb       317: #endif
                    318:
1.1       jfb       319:
                    320: /* client command handlers */
1.46    ! joris     321: int  cvs_startcmd (struct cvs_cmd *, int, char **);
1.1       jfb       322: int  cvs_add      (int, char **);
1.45      joris     323: int  cvs_admin    (int, char **);
1.38      jfb       324: int  cvs_annotate (int, char **);
1.9       jfb       325: int  cvs_checkout (int, char **);
1.1       jfb       326: int  cvs_commit   (int, char **);
                    327: int  cvs_diff     (int, char **);
                    328: int  cvs_getlog   (int, char **);
                    329: int  cvs_history  (int, char **);
1.30      krapht    330: int  cvs_import   (int, char **);
1.1       jfb       331: int  cvs_init     (int, char **);
1.40      xsa       332: int  cvs_remove   (int, char **);
1.1       jfb       333: int  cvs_server   (int, char **);
1.15      jfb       334: int  cvs_status   (int, char **);
1.39      jfb       335: int  cvs_tag      (int, char **);
1.1       jfb       336: int  cvs_update   (int, char **);
                    337: int  cvs_version  (int, char **);
1.41      jfb       338:
                    339:
                    340: int         cvs_var_set   (const char *, const char *);
                    341: int         cvs_var_unset (const char *);
                    342: const char* cvs_var_get   (const char *);
1.1       jfb       343:
                    344:
                    345: /* from root.c */
                    346: struct cvsroot*  cvsroot_parse (const char *);
                    347: void             cvsroot_free  (struct cvsroot *);
                    348: struct cvsroot*  cvsroot_get   (const char *);
1.2       jfb       349:
                    350:
1.1       jfb       351: /* Entries API */
1.3       jfb       352: CVSENTRIES*      cvs_ent_open   (const char *, int);
1.1       jfb       353: struct cvs_ent*  cvs_ent_get    (CVSENTRIES *, const char *);
                    354: struct cvs_ent*  cvs_ent_next   (CVSENTRIES *);
                    355: int              cvs_ent_add    (CVSENTRIES *, struct cvs_ent *);
1.5       jfb       356: int              cvs_ent_addln  (CVSENTRIES *, const char *);
1.1       jfb       357: int              cvs_ent_remove (CVSENTRIES *, const char *);
1.17      jfb       358: int              cvs_ent_write  (CVSENTRIES *);
1.1       jfb       359: struct cvs_ent*  cvs_ent_parse  (const char *);
                    360: void             cvs_ent_close  (CVSENTRIES *);
1.8       jfb       361: void             cvs_ent_free   (struct cvs_ent *);
                    362: struct cvs_ent*  cvs_ent_getent (const char *);
1.1       jfb       363:
                    364: /* history API */
                    365: CVSHIST*         cvs_hist_open    (const char *);
                    366: void             cvs_hist_close   (CVSHIST *);
                    367: int              cvs_hist_parse   (CVSHIST *);
                    368: struct cvs_hent* cvs_hist_getnext (CVSHIST *);
                    369: int              cvs_hist_append  (CVSHIST *, struct cvs_hent *);
                    370:
1.31      jfb       371: /* from logmsg.c */
                    372: char*  cvs_logmsg_open (const char *);
1.37      jfb       373: char*  cvs_logmsg_get  (const char *, struct cvs_flist *, struct cvs_flist *, struct cvs_flist *);
1.31      jfb       374: int    cvs_logmsg_send (struct cvsroot *, const char *);
1.1       jfb       375:
                    376: /* from util.c */
1.28      jfb       377: #define CVS_DATE_CTIME  0
                    378: #define CVS_DATE_RFC822 1
                    379:
1.1       jfb       380: int    cvs_readrepo   (const char *, char *, size_t);
1.28      jfb       381: time_t cvs_datesec    (const char *, int, int);
1.1       jfb       382: int    cvs_modetostr  (mode_t, char *, size_t);
                    383: int    cvs_strtomode  (const char *, mode_t *);
1.26      jfb       384: int    cvs_splitpath  (const char *, char *, size_t, char **);
1.32      jfb       385: int    cvs_mkadmin    (CVSFILE *, mode_t);
1.1       jfb       386: int    cvs_cksum      (const char *, char *, size_t);
                    387: int    cvs_exec       (int, char **, int []);
1.6       jfb       388: int    cvs_getargv    (const char *, char **, int);
1.34      jfb       389: char** cvs_makeargv   (const char *, int *);
1.6       jfb       390: void   cvs_freeargv   (char **, int);
1.1       jfb       391:
                    392:
                    393: #endif /* CVS_H */