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

1.1       jfb         1: /*     $OpenBSD$       */
                      2: /*
                      3:  * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  *
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. The name of the author may not be used to endorse or promote products
                     13:  *    derived from this software without specific prior written permission.
                     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
                     24:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     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"
                     35:
                     36: #define CVS_VERSION    "OpenCVS 0.1"
                     37:
                     38:
                     39: #define CVS_HIST_CACHE     128
                     40: #define CVS_HIST_NBFLD     6
                     41:
                     42:
                     43: #define CVS_REQ_TIMEOUT    300
                     44:
                     45:
                     46:
                     47: #define CVS_CKSUM_LEN      33     /* length of a CVS checksum string */
                     48:
                     49:
                     50: /* operations */
1.8       jfb        51: #define CVS_OP_ANY          0     /* all operations */
1.1       jfb        52: #define CVS_OP_ADD          1
                     53: #define CVS_OP_ANNOTATE     2
                     54: #define CVS_OP_COMMIT       3
                     55: #define CVS_OP_DIFF         4
                     56: #define CVS_OP_TAG          5
                     57: #define CVS_OP_UPDATE       6
                     58:
                     59:
                     60:
                     61:
                     62: /* methods */
                     63: #define CVS_METHOD_NONE       0
                     64: #define CVS_METHOD_LOCAL      1    /* local access */
                     65: #define CVS_METHOD_SERVER     2    /* tunnel through CVS_RSH */
                     66: #define CVS_METHOD_PSERVER    3    /* cvs pserver */
                     67: #define CVS_METHOD_KSERVER    4    /* kerberos */
                     68: #define CVS_METHOD_GSERVER    5    /* gssapi server */
                     69: #define CVS_METHOD_EXT        6
                     70: #define CVS_METHOD_FORK       7    /* local but fork */
                     71:
                     72: /* client/server protocol requests */
                     73: #define CVS_REQ_NONE          0
                     74: #define CVS_REQ_ROOT          1
                     75: #define CVS_REQ_VALIDREQ      2
                     76: #define CVS_REQ_VALIDRESP     3
                     77: #define CVS_REQ_DIRECTORY     4
                     78: #define CVS_REQ_MAXDOTDOT     5
                     79: #define CVS_REQ_STATICDIR     6
                     80: #define CVS_REQ_STICKY        7
                     81: #define CVS_REQ_ENTRY         8
                     82: #define CVS_REQ_ENTRYEXTRA    9
                     83: #define CVS_REQ_CHECKINTIME  10
                     84: #define CVS_REQ_MODIFIED     11
                     85: #define CVS_REQ_ISMODIFIED   12
                     86: #define CVS_REQ_UNCHANGED    13
                     87: #define CVS_REQ_USEUNCHANGED 14
                     88: #define CVS_REQ_NOTIFY       15
                     89: #define CVS_REQ_NOTIFYUSER   16
                     90: #define CVS_REQ_QUESTIONABLE 17
                     91: #define CVS_REQ_CASE         18
                     92: #define CVS_REQ_UTF8         19
                     93: #define CVS_REQ_ARGUMENT     20
                     94: #define CVS_REQ_ARGUMENTX    21
                     95: #define CVS_REQ_GLOBALOPT    22
                     96: #define CVS_REQ_GZIPSTREAM   23
                     97: #define CVS_REQ_KERBENCRYPT  24
                     98: #define CVS_REQ_GSSENCRYPT   25
                     99: #define CVS_REQ_PROTOENCRYPT 26
                    100: #define CVS_REQ_GSSAUTH      27
                    101: #define CVS_REQ_PROTOAUTH    28
                    102: #define CVS_REQ_READCVSRC2   29
                    103: #define CVS_REQ_READWRAP     30
                    104: #define CVS_REQ_ERRIFREADER  31
                    105: #define CVS_REQ_VALIDRCSOPT  32
                    106: #define CVS_REQ_READIGNORE   33
                    107: #define CVS_REQ_SET          34
                    108: #define CVS_REQ_XPANDMOD     35
                    109: #define CVS_REQ_CI           36
                    110: #define CVS_REQ_CHOWN        37
                    111: #define CVS_REQ_SETOWN       38
                    112: #define CVS_REQ_SETPERM      39
                    113: #define CVS_REQ_CHACL        40
                    114: #define CVS_REQ_LISTPERM     41
                    115: #define CVS_REQ_LISTACL      42
                    116: #define CVS_REQ_SETPASS      43
                    117: #define CVS_REQ_PASSWD       44
                    118: #define CVS_REQ_DIFF         45
                    119: #define CVS_REQ_STATUS       46
                    120: #define CVS_REQ_LS           47
                    121: #define CVS_REQ_TAG          48
                    122: #define CVS_REQ_IMPORT       49
                    123: #define CVS_REQ_ADMIN        50
                    124: #define CVS_REQ_HISTORY      51
                    125: #define CVS_REQ_WATCHERS     52
                    126: #define CVS_REQ_EDITORS      53
                    127: #define CVS_REQ_ANNOTATE     54
                    128: #define CVS_REQ_LOG          55
                    129: #define CVS_REQ_CO           56
                    130: #define CVS_REQ_EXPORT       57
                    131: #define CVS_REQ_RANNOTATE    58
                    132: #define CVS_REQ_INIT         59
                    133: #define CVS_REQ_UPDATE       60
                    134: #define CVS_REQ_ADD          62
                    135: #define CVS_REQ_REMOVE       63
                    136: #define CVS_REQ_NOOP         64
                    137: #define CVS_REQ_RTAG         65
                    138: #define CVS_REQ_RELEASE      66
                    139: #define CVS_REQ_RLOG         67
                    140: #define CVS_REQ_RDIFF        68
                    141: #define CVS_REQ_VERSION      69
                    142:
                    143: #define CVS_REQ_MAX          69
                    144:
                    145:
                    146: /* responses */
                    147: #define CVS_RESP_OK           1
                    148: #define CVS_RESP_ERROR        2
                    149: #define CVS_RESP_VALIDREQ     3
                    150: #define CVS_RESP_CHECKEDIN    4
                    151: #define CVS_RESP_NEWENTRY     5
                    152: #define CVS_RESP_CKSUM        6
                    153: #define CVS_RESP_COPYFILE     7
                    154: #define CVS_RESP_UPDATED      8
                    155: #define CVS_RESP_CREATED      9
                    156: #define CVS_RESP_UPDEXIST    10
                    157: #define CVS_RESP_MERGED      11
                    158: #define CVS_RESP_PATCHED     12
                    159: #define CVS_RESP_RCSDIFF     13
                    160: #define CVS_RESP_MODE        14
                    161: #define CVS_RESP_MODTIME     15
                    162: #define CVS_RESP_REMOVED     16
                    163: #define CVS_RESP_RMENTRY     17
                    164: #define CVS_RESP_SETSTATDIR  18
                    165: #define CVS_RESP_CLRSTATDIR  19
                    166: #define CVS_RESP_SETSTICKY   20
                    167: #define CVS_RESP_CLRSTICKY   21
                    168: #define CVS_RESP_TEMPLATE    22
                    169: #define CVS_RESP_SETCIPROG   23
                    170: #define CVS_RESP_SETUPDPROG  24
                    171: #define CVS_RESP_NOTIFIED    25
                    172: #define CVS_RESP_MODXPAND    26
                    173: #define CVS_RESP_WRAPRCSOPT  27
                    174: #define CVS_RESP_M           28
                    175: #define CVS_RESP_MBINARY     29
                    176: #define CVS_RESP_E           30
                    177: #define CVS_RESP_F           31
                    178: #define CVS_RESP_MT          32
                    179:
                    180:
                    181:
                    182:
                    183: #define CVS_CMD_MAXNAMELEN   16
                    184: #define CVS_CMD_MAXALIAS      2
                    185: #define CVS_CMD_MAXDESCRLEN  64
                    186:
                    187:
                    188: /* defaults */
                    189: #define CVS_RSH_DEFAULT     "ssh"
                    190: #define CVS_EDITOR_DEFAULT  "vi"
                    191:
                    192:
                    193: /* server-side paths */
                    194: #define CVS_PATH_ROOT         "CVSROOT"
                    195: #define CVS_PATH_COMMITINFO   CVS_PATH_ROOT "/commitinfo"
                    196: #define CVS_PATH_CONFIG       CVS_PATH_ROOT "/config"
                    197: #define CVS_PATH_CVSIGNORE    CVS_PATH_ROOT "/cvsignore"
                    198: #define CVS_PATH_CVSWRAPPERS  CVS_PATH_ROOT "/cvswrappers"
                    199: #define CVS_PATH_EDITINFO     CVS_PATH_ROOT "/editinfo"
                    200: #define CVS_PATH_HISTORY      CVS_PATH_ROOT "/history"
                    201: #define CVS_PATH_LOGINFO      CVS_PATH_ROOT "/loginfo"
                    202: #define CVS_PATH_MODULES      CVS_PATH_ROOT "/modules"
                    203: #define CVS_PATH_NOTIFY       CVS_PATH_ROOT "/notify"
                    204: #define CVS_PATH_RCSINFO      CVS_PATH_ROOT "/rcsinfo"
                    205: #define CVS_PATH_TAGINFO      CVS_PATH_ROOT "/taginfo"
                    206: #define CVS_PATH_VERIFYMSG    CVS_PATH_ROOT "/verifymsg"
                    207:
                    208:
                    209: /* client-side paths */
                    210: #define CVS_PATH_RC             ".cvsrc"
                    211: #define CVS_PATH_CVSDIR         "CVS"
                    212: #define CVS_PATH_ENTRIES        CVS_PATH_CVSDIR "/Entries"
                    213: #define CVS_PATH_STATICENTRIES  CVS_PATH_CVSDIR "/Entries.Static"
                    214: #define CVS_PATH_LOGENTRIES     CVS_PATH_CVSDIR "/Entries.Log"
                    215: #define CVS_PATH_ROOTSPEC       CVS_PATH_CVSDIR "/Root"
1.10      jfb       216: #define CVS_PATH_REPOSITORY     CVS_PATH_CVSDIR "/Repository"
1.1       jfb       217:
                    218:
1.7       jfb       219: struct cvs_file;
                    220: struct cvs_dir;
                    221:
                    222:
1.1       jfb       223: struct cvs_op {
                    224:        u_int  co_op;
                    225:        uid_t  co_uid;    /* user performing the operation */
                    226:        char  *co_path;   /* target path of the operation */
                    227:        char  *co_tag;    /* tag or branch, NULL if HEAD */
                    228: };
                    229:
                    230:
                    231:
                    232: struct cvsroot {
1.11      jfb       233:        char   *cr_str;
1.1       jfb       234:        u_int   cr_method;
                    235:        char   *cr_buf;
                    236:        char   *cr_user;
                    237:        char   *cr_pass;
                    238:        char   *cr_host;
                    239:        char   *cr_dir;
                    240:        u_int   cr_port;
1.11      jfb       241:        u_int   cr_ref;
                    242:
                    243:        /* connection data */
                    244:        FILE   *cr_srvin;
                    245:        FILE   *cr_srvout;
1.1       jfb       246: };
                    247:
                    248:
1.7       jfb       249: #define CF_STAT     0x01    /* allocate space for file stats */
                    250: #define CF_IGNORE   0x02    /* apply regular ignore rules */
                    251: #define CF_RECURSE  0x04    /* recurse on directory operations */
                    252: #define CF_SORT     0x08    /* all files are sorted alphabetically */
1.8       jfb       253: #define CF_KNOWN    0x10    /* only recurse in directories known to CVS */
1.10      jfb       254: #define CF_CREATE   0x20    /* create if file does not exist */
1.7       jfb       255:
                    256:
                    257: /*
                    258:  * The cvs_file structure is used to represent any file or directory within
                    259:  * the CVS tree's hierarchy.  The <cf_path> field is a path relative to the
                    260:  * directory in which the cvs command was executed.  The <cf_parent> field
                    261:  * points back to the parent node in the directory tree structure (it is
                    262:  * NULL if the directory is at the wd of the command).
                    263:  *
1.8       jfb       264:  * The <cf_cvstat> field gives the file's status with regards to the CVS
                    265:  * repository.  The file can be in any one of the CVS_FST_* states.
1.7       jfb       266:  * If the file's type is DT_DIR, then the <cf_ddat> pointer will point to
                    267:  * a cvs_dir structure containing data specific to the directory (such as
                    268:  * the contents of the directory's CVS/Entries, CVS/Root, etc.).
                    269:  */
                    270:
1.8       jfb       271: #define CVS_FST_UNKNOWN   0
                    272: #define CVS_FST_UPTODATE  1
                    273: #define CVS_FST_MODIFIED  2
                    274: #define CVS_FST_ADDED     3
                    275: #define CVS_FST_REMOVED   4
                    276: #define CVS_FST_CONFLICT  5
1.12      jfb       277: #define CVS_FST_PATCHED   6
1.8       jfb       278:
1.13      jfb       279:
1.14      jfb       280: TAILQ_HEAD(cvs_flist, cvs_file);
1.13      jfb       281:
                    282:
1.9       jfb       283: typedef struct cvs_file {
1.7       jfb       284:        char            *cf_path;
                    285:        struct cvs_file *cf_parent;  /* parent directory (NULL if none) */
                    286:        char            *cf_name;
1.8       jfb       287:        u_int16_t        cf_cvstat;  /* cvs status of the file */
                    288:        u_int16_t        cf_type;    /* uses values from dirent.h */
                    289:        struct stat     *cf_stat;    /* only available with CF_STAT flag */
                    290:        struct cvs_dir  *cf_ddat;    /* only for directories */
1.7       jfb       291:
1.13      jfb       292:        TAILQ_ENTRY(cvs_file)  cf_list;
1.9       jfb       293: } CVSFILE;
1.7       jfb       294:
                    295:
                    296: struct cvs_dir {
1.13      jfb       297:        struct cvsroot  *cd_root;
                    298:        char            *cd_repo;
                    299:        struct cvs_flist cd_files;
1.7       jfb       300: };
                    301:
1.1       jfb       302: #define CVS_HIST_ADDED    'A'
                    303: #define CVS_HIST_EXPORT   'E'
                    304: #define CVS_HIST_RELEASE  'F'
                    305: #define CVS_HIST_MODIFIED 'M'
                    306: #define CVS_HIST_CHECKOUT 'O'
                    307: #define CVS_HIST_COMMIT   'R'
                    308: #define CVS_HIST_TAG      'T'
                    309:
                    310:
                    311: #define CVS_ENT_NONE    0
                    312: #define CVS_ENT_FILE    1
                    313: #define CVS_ENT_DIR     2
                    314:
                    315:
                    316: struct cvs_ent {
                    317:        char    *ce_line;
                    318:        char    *ce_buf;
                    319:        u_int    ce_type;
                    320:        char    *ce_name;
                    321:        RCSNUM  *ce_rev;
                    322:        char    *ce_timestamp;
                    323:        char    *ce_opts;
                    324:        char    *ce_tag;
1.4       jfb       325:        TAILQ_ENTRY(cvs_ent) ce_list;
1.1       jfb       326: };
                    327:
                    328: typedef struct cvs_entries {
                    329:        char    *cef_path;
1.3       jfb       330:        FILE    *cef_file;
1.1       jfb       331:
1.4       jfb       332:        TAILQ_HEAD(, cvs_ent) cef_ent;
                    333:        struct cvs_ent       *cef_cur;
1.1       jfb       334: } CVSENTRIES;
                    335:
                    336:
                    337:
                    338: struct cvs_hent {
                    339:        char    ch_event;
                    340:        time_t  ch_date;
                    341:        uid_t   ch_uid;
                    342:        char   *ch_user;
                    343:        char   *ch_curdir;
                    344:        char   *ch_repo;
                    345:        RCSNUM *ch_rev;
                    346:        char   *ch_arg;
                    347: };
                    348:
                    349:
                    350: typedef struct cvs_histfile {
                    351:        int     chf_fd;
                    352:        char   *chf_buf;       /* read buffer */
                    353:        size_t  chf_blen;      /* buffer size */
                    354:        size_t  chf_bused;     /* bytes used in buffer */
                    355:
                    356:        off_t   chf_off;       /* next read */
                    357:        u_int   chf_sindex;    /* history entry index of first in array */
                    358:        u_int   chf_cindex;    /* current index (for getnext()) */
                    359:        u_int   chf_nbhent;    /* number of valid entries in the array */
                    360:
                    361:        struct cvs_hent chf_hent[CVS_HIST_CACHE];
                    362:
                    363: } CVSHIST;
                    364:
                    365:
1.15    ! jfb       366: #ifdef CVS
        !           367: extern struct cvsroot *cvs_root;
        !           368: #endif
        !           369:
        !           370:
        !           371:
1.1       jfb       372:
                    373: /* client command handlers */
                    374: int  cvs_add      (int, char **);
1.9       jfb       375: int  cvs_checkout (int, char **);
1.1       jfb       376: int  cvs_commit   (int, char **);
                    377: int  cvs_diff     (int, char **);
                    378: int  cvs_getlog   (int, char **);
                    379: int  cvs_history  (int, char **);
                    380: int  cvs_init     (int, char **);
                    381: int  cvs_server   (int, char **);
1.15    ! jfb       382: int  cvs_status   (int, char **);
1.1       jfb       383: int  cvs_update   (int, char **);
                    384: int  cvs_version  (int, char **);
                    385:
                    386:
                    387: /* proto.c */
                    388: int         cvs_req_handle     (char *);
                    389: const char* cvs_req_getbyid    (int);
                    390: int         cvs_req_getbyname  (const char *);
                    391: char*       cvs_req_getvalid   (void);
                    392:
1.2       jfb       393:
1.1       jfb       394: int         cvs_resp_handle    (char *);
                    395: const char* cvs_resp_getbyid   (int);
                    396: int         cvs_resp_getbyname (const char *);
                    397: char*       cvs_resp_getvalid  (void);
                    398:
                    399: int         cvs_sendfile       (const char *);
                    400: int         cvs_recvfile       (const char *);
                    401:
                    402:
                    403: /* from client.c */
1.11      jfb       404: int     cvs_client_connect     (struct cvsroot *);
                    405: void    cvs_client_disconnect  (struct cvsroot *);
1.1       jfb       406: int     cvs_client_sendreq     (u_int, const char *, int);
                    407: int     cvs_client_sendarg     (const char *, int);
                    408: int     cvs_client_sendln      (const char *);
                    409: int     cvs_client_sendraw     (const void *, size_t);
                    410: ssize_t cvs_client_recvraw     (void *, size_t);
                    411: int     cvs_client_getln       (char *, size_t);
                    412: int     cvs_client_senddir     (const char *);
                    413:
                    414:
                    415: /* from root.c */
                    416: struct cvsroot*  cvsroot_parse (const char *);
                    417: void             cvsroot_free  (struct cvsroot *);
                    418: struct cvsroot*  cvsroot_get   (const char *);
1.2       jfb       419:
                    420:
1.7       jfb       421: /* from file.c */
1.9       jfb       422: int      cvs_file_init    (void);
                    423: int      cvs_file_ignore  (const char *);
                    424: int      cvs_file_chkign  (const char *);
1.10      jfb       425: CVSFILE* cvs_file_create  (const char *, u_int, mode_t);
1.9       jfb       426: CVSFILE* cvs_file_get     (const char *, int);
1.12      jfb       427: CVSFILE* cvs_file_getspec (char **, int, int);
1.9       jfb       428: void     cvs_file_free    (struct cvs_file *);
                    429: int      cvs_file_examine (CVSFILE *, int (*)(CVSFILE *, void *), void *);
1.1       jfb       430:
                    431:
                    432: /* Entries API */
1.3       jfb       433: CVSENTRIES*      cvs_ent_open   (const char *, int);
1.1       jfb       434: struct cvs_ent*  cvs_ent_get    (CVSENTRIES *, const char *);
                    435: struct cvs_ent*  cvs_ent_next   (CVSENTRIES *);
                    436: int              cvs_ent_add    (CVSENTRIES *, struct cvs_ent *);
1.5       jfb       437: int              cvs_ent_addln  (CVSENTRIES *, const char *);
1.1       jfb       438: int              cvs_ent_remove (CVSENTRIES *, const char *);
                    439: struct cvs_ent*  cvs_ent_parse  (const char *);
                    440: void             cvs_ent_close  (CVSENTRIES *);
1.8       jfb       441: void             cvs_ent_free   (struct cvs_ent *);
                    442: struct cvs_ent*  cvs_ent_getent (const char *);
1.1       jfb       443:
                    444: /* history API */
                    445: CVSHIST*         cvs_hist_open    (const char *);
                    446: void             cvs_hist_close   (CVSHIST *);
                    447: int              cvs_hist_parse   (CVSHIST *);
                    448: struct cvs_hent* cvs_hist_getnext (CVSHIST *);
                    449: int              cvs_hist_append  (CVSHIST *, struct cvs_hent *);
                    450:
                    451:
                    452: /* from util.c */
                    453: int    cvs_readrepo   (const char *, char *, size_t);
                    454: int    cvs_splitpath  (const char *, char *, size_t, char *, size_t);
                    455: int    cvs_modetostr  (mode_t, char *, size_t);
                    456: int    cvs_strtomode  (const char *, mode_t *);
1.10      jfb       457: int    cvs_mkadmin    (struct cvs_file *, mode_t);
1.1       jfb       458: int    cvs_cksum      (const char *, char *, size_t);
                    459: int    cvs_exec       (int, char **, int []);
1.6       jfb       460: int    cvs_getargv    (const char *, char **, int);
                    461: void   cvs_freeargv   (char **, int);
1.1       jfb       462:
                    463:
                    464: #endif /* CVS_H */