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

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_CKSUM_LEN      33     /* length of a CVS checksum string */
                     44:
                     45:
                     46: /* operations */
1.8       jfb        47: #define CVS_OP_ANY          0     /* all operations */
1.1       jfb        48: #define CVS_OP_ADD          1
                     49: #define CVS_OP_ANNOTATE     2
1.16    ! jfb        50: #define CVS_OP_CHECKOUT     3
        !            51: #define CVS_OP_COMMIT       4
        !            52: #define CVS_OP_DIFF         5
        !            53: #define CVS_OP_HISTORY      6
        !            54: #define CVS_OP_IMPORT       7
        !            55: #define CVS_OP_INIT         8
        !            56: #define CVS_OP_LOG          9
        !            57: #define CVS_OP_REMOVE      10
        !            58: #define CVS_OP_SERVER      11
        !            59: #define CVS_OP_STATUS      12
        !            60: #define CVS_OP_TAG         13
        !            61: #define CVS_OP_UPDATE      14
        !            62: #define CVS_OP_VERSION     15
1.1       jfb        63:
                     64:
                     65:
                     66:
                     67: /* methods */
                     68: #define CVS_METHOD_NONE       0
                     69: #define CVS_METHOD_LOCAL      1    /* local access */
                     70: #define CVS_METHOD_SERVER     2    /* tunnel through CVS_RSH */
                     71: #define CVS_METHOD_PSERVER    3    /* cvs pserver */
                     72: #define CVS_METHOD_KSERVER    4    /* kerberos */
                     73: #define CVS_METHOD_GSERVER    5    /* gssapi server */
                     74: #define CVS_METHOD_EXT        6
                     75: #define CVS_METHOD_FORK       7    /* local but fork */
                     76:
                     77: #define CVS_CMD_MAXNAMELEN   16
                     78: #define CVS_CMD_MAXALIAS      2
                     79: #define CVS_CMD_MAXDESCRLEN  64
                     80:
                     81:
                     82: /* defaults */
                     83: #define CVS_RSH_DEFAULT     "ssh"
                     84: #define CVS_EDITOR_DEFAULT  "vi"
                     85:
                     86:
                     87: /* server-side paths */
                     88: #define CVS_PATH_ROOT         "CVSROOT"
                     89: #define CVS_PATH_COMMITINFO   CVS_PATH_ROOT "/commitinfo"
                     90: #define CVS_PATH_CONFIG       CVS_PATH_ROOT "/config"
                     91: #define CVS_PATH_CVSIGNORE    CVS_PATH_ROOT "/cvsignore"
                     92: #define CVS_PATH_CVSWRAPPERS  CVS_PATH_ROOT "/cvswrappers"
                     93: #define CVS_PATH_EDITINFO     CVS_PATH_ROOT "/editinfo"
                     94: #define CVS_PATH_HISTORY      CVS_PATH_ROOT "/history"
                     95: #define CVS_PATH_LOGINFO      CVS_PATH_ROOT "/loginfo"
                     96: #define CVS_PATH_MODULES      CVS_PATH_ROOT "/modules"
                     97: #define CVS_PATH_NOTIFY       CVS_PATH_ROOT "/notify"
                     98: #define CVS_PATH_RCSINFO      CVS_PATH_ROOT "/rcsinfo"
                     99: #define CVS_PATH_TAGINFO      CVS_PATH_ROOT "/taginfo"
                    100: #define CVS_PATH_VERIFYMSG    CVS_PATH_ROOT "/verifymsg"
                    101:
                    102:
                    103: /* client-side paths */
                    104: #define CVS_PATH_RC             ".cvsrc"
                    105: #define CVS_PATH_CVSDIR         "CVS"
                    106: #define CVS_PATH_ENTRIES        CVS_PATH_CVSDIR "/Entries"
                    107: #define CVS_PATH_STATICENTRIES  CVS_PATH_CVSDIR "/Entries.Static"
                    108: #define CVS_PATH_LOGENTRIES     CVS_PATH_CVSDIR "/Entries.Log"
                    109: #define CVS_PATH_ROOTSPEC       CVS_PATH_CVSDIR "/Root"
1.10      jfb       110: #define CVS_PATH_REPOSITORY     CVS_PATH_CVSDIR "/Repository"
1.1       jfb       111:
                    112:
1.7       jfb       113: struct cvs_file;
                    114: struct cvs_dir;
                    115:
                    116:
1.1       jfb       117: struct cvs_op {
                    118:        u_int  co_op;
                    119:        uid_t  co_uid;    /* user performing the operation */
                    120:        char  *co_path;   /* target path of the operation */
                    121:        char  *co_tag;    /* tag or branch, NULL if HEAD */
                    122: };
                    123:
                    124:
                    125:
                    126: struct cvsroot {
1.11      jfb       127:        char   *cr_str;
1.1       jfb       128:        u_int   cr_method;
                    129:        char   *cr_buf;
                    130:        char   *cr_user;
                    131:        char   *cr_pass;
                    132:        char   *cr_host;
                    133:        char   *cr_dir;
                    134:        u_int   cr_port;
1.11      jfb       135:        u_int   cr_ref;
                    136:
                    137:        /* connection data */
                    138:        FILE   *cr_srvin;
                    139:        FILE   *cr_srvout;
1.1       jfb       140: };
                    141:
                    142:
1.7       jfb       143: #define CF_STAT     0x01    /* allocate space for file stats */
                    144: #define CF_IGNORE   0x02    /* apply regular ignore rules */
                    145: #define CF_RECURSE  0x04    /* recurse on directory operations */
                    146: #define CF_SORT     0x08    /* all files are sorted alphabetically */
1.8       jfb       147: #define CF_KNOWN    0x10    /* only recurse in directories known to CVS */
1.10      jfb       148: #define CF_CREATE   0x20    /* create if file does not exist */
1.7       jfb       149:
                    150:
                    151: /*
                    152:  * The cvs_file structure is used to represent any file or directory within
                    153:  * the CVS tree's hierarchy.  The <cf_path> field is a path relative to the
                    154:  * directory in which the cvs command was executed.  The <cf_parent> field
                    155:  * points back to the parent node in the directory tree structure (it is
                    156:  * NULL if the directory is at the wd of the command).
                    157:  *
1.8       jfb       158:  * The <cf_cvstat> field gives the file's status with regards to the CVS
                    159:  * repository.  The file can be in any one of the CVS_FST_* states.
1.7       jfb       160:  * If the file's type is DT_DIR, then the <cf_ddat> pointer will point to
                    161:  * a cvs_dir structure containing data specific to the directory (such as
                    162:  * the contents of the directory's CVS/Entries, CVS/Root, etc.).
                    163:  */
                    164:
1.8       jfb       165: #define CVS_FST_UNKNOWN   0
                    166: #define CVS_FST_UPTODATE  1
                    167: #define CVS_FST_MODIFIED  2
                    168: #define CVS_FST_ADDED     3
                    169: #define CVS_FST_REMOVED   4
                    170: #define CVS_FST_CONFLICT  5
1.12      jfb       171: #define CVS_FST_PATCHED   6
1.8       jfb       172:
1.13      jfb       173:
1.14      jfb       174: TAILQ_HEAD(cvs_flist, cvs_file);
1.13      jfb       175:
                    176:
1.9       jfb       177: typedef struct cvs_file {
1.7       jfb       178:        char            *cf_path;
                    179:        struct cvs_file *cf_parent;  /* parent directory (NULL if none) */
                    180:        char            *cf_name;
1.8       jfb       181:        u_int16_t        cf_cvstat;  /* cvs status of the file */
                    182:        u_int16_t        cf_type;    /* uses values from dirent.h */
                    183:        struct stat     *cf_stat;    /* only available with CF_STAT flag */
                    184:        struct cvs_dir  *cf_ddat;    /* only for directories */
1.7       jfb       185:
1.13      jfb       186:        TAILQ_ENTRY(cvs_file)  cf_list;
1.9       jfb       187: } CVSFILE;
1.7       jfb       188:
                    189:
                    190: struct cvs_dir {
1.13      jfb       191:        struct cvsroot  *cd_root;
                    192:        char            *cd_repo;
                    193:        struct cvs_flist cd_files;
1.7       jfb       194: };
                    195:
1.1       jfb       196: #define CVS_HIST_ADDED    'A'
                    197: #define CVS_HIST_EXPORT   'E'
                    198: #define CVS_HIST_RELEASE  'F'
                    199: #define CVS_HIST_MODIFIED 'M'
                    200: #define CVS_HIST_CHECKOUT 'O'
                    201: #define CVS_HIST_COMMIT   'R'
                    202: #define CVS_HIST_TAG      'T'
                    203:
                    204:
                    205: #define CVS_ENT_NONE    0
                    206: #define CVS_ENT_FILE    1
                    207: #define CVS_ENT_DIR     2
                    208:
                    209:
                    210: struct cvs_ent {
                    211:        char    *ce_line;
                    212:        char    *ce_buf;
                    213:        u_int    ce_type;
                    214:        char    *ce_name;
                    215:        RCSNUM  *ce_rev;
                    216:        char    *ce_timestamp;
                    217:        char    *ce_opts;
                    218:        char    *ce_tag;
1.4       jfb       219:        TAILQ_ENTRY(cvs_ent) ce_list;
1.1       jfb       220: };
                    221:
                    222: typedef struct cvs_entries {
                    223:        char    *cef_path;
1.3       jfb       224:        FILE    *cef_file;
1.1       jfb       225:
1.4       jfb       226:        TAILQ_HEAD(, cvs_ent) cef_ent;
                    227:        struct cvs_ent       *cef_cur;
1.1       jfb       228: } CVSENTRIES;
                    229:
                    230:
                    231:
                    232: struct cvs_hent {
                    233:        char    ch_event;
                    234:        time_t  ch_date;
                    235:        uid_t   ch_uid;
                    236:        char   *ch_user;
                    237:        char   *ch_curdir;
                    238:        char   *ch_repo;
                    239:        RCSNUM *ch_rev;
                    240:        char   *ch_arg;
                    241: };
                    242:
                    243:
                    244: typedef struct cvs_histfile {
                    245:        int     chf_fd;
                    246:        char   *chf_buf;       /* read buffer */
                    247:        size_t  chf_blen;      /* buffer size */
                    248:        size_t  chf_bused;     /* bytes used in buffer */
                    249:
                    250:        off_t   chf_off;       /* next read */
                    251:        u_int   chf_sindex;    /* history entry index of first in array */
                    252:        u_int   chf_cindex;    /* current index (for getnext()) */
                    253:        u_int   chf_nbhent;    /* number of valid entries in the array */
                    254:
                    255:        struct cvs_hent chf_hent[CVS_HIST_CACHE];
                    256:
                    257: } CVSHIST;
                    258:
                    259:
1.15      jfb       260: #ifdef CVS
                    261: extern struct cvsroot *cvs_root;
                    262: #endif
                    263:
                    264:
                    265:
1.1       jfb       266:
                    267: /* client command handlers */
                    268: int  cvs_add      (int, char **);
1.9       jfb       269: int  cvs_checkout (int, char **);
1.1       jfb       270: int  cvs_commit   (int, char **);
                    271: int  cvs_diff     (int, char **);
                    272: int  cvs_getlog   (int, char **);
                    273: int  cvs_history  (int, char **);
                    274: int  cvs_init     (int, char **);
                    275: int  cvs_server   (int, char **);
1.15      jfb       276: int  cvs_status   (int, char **);
1.1       jfb       277: int  cvs_update   (int, char **);
                    278: int  cvs_version  (int, char **);
                    279:
                    280:
                    281: /* from client.c */
1.11      jfb       282: int     cvs_client_connect     (struct cvsroot *);
                    283: void    cvs_client_disconnect  (struct cvsroot *);
1.1       jfb       284: int     cvs_client_sendreq     (u_int, const char *, int);
                    285: int     cvs_client_sendarg     (const char *, int);
                    286: int     cvs_client_sendln      (const char *);
                    287: int     cvs_client_sendraw     (const void *, size_t);
                    288: ssize_t cvs_client_recvraw     (void *, size_t);
                    289: int     cvs_client_getln       (char *, size_t);
                    290: int     cvs_client_senddir     (const char *);
                    291:
                    292:
                    293: /* from root.c */
                    294: struct cvsroot*  cvsroot_parse (const char *);
                    295: void             cvsroot_free  (struct cvsroot *);
                    296: struct cvsroot*  cvsroot_get   (const char *);
1.2       jfb       297:
                    298:
1.7       jfb       299: /* from file.c */
1.9       jfb       300: int      cvs_file_init    (void);
                    301: int      cvs_file_ignore  (const char *);
                    302: int      cvs_file_chkign  (const char *);
1.10      jfb       303: CVSFILE* cvs_file_create  (const char *, u_int, mode_t);
1.9       jfb       304: CVSFILE* cvs_file_get     (const char *, int);
1.12      jfb       305: CVSFILE* cvs_file_getspec (char **, int, int);
1.9       jfb       306: void     cvs_file_free    (struct cvs_file *);
                    307: int      cvs_file_examine (CVSFILE *, int (*)(CVSFILE *, void *), void *);
1.1       jfb       308:
                    309:
                    310: /* Entries API */
1.3       jfb       311: CVSENTRIES*      cvs_ent_open   (const char *, int);
1.1       jfb       312: struct cvs_ent*  cvs_ent_get    (CVSENTRIES *, const char *);
                    313: struct cvs_ent*  cvs_ent_next   (CVSENTRIES *);
                    314: int              cvs_ent_add    (CVSENTRIES *, struct cvs_ent *);
1.5       jfb       315: int              cvs_ent_addln  (CVSENTRIES *, const char *);
1.1       jfb       316: int              cvs_ent_remove (CVSENTRIES *, const char *);
                    317: struct cvs_ent*  cvs_ent_parse  (const char *);
                    318: void             cvs_ent_close  (CVSENTRIES *);
1.8       jfb       319: void             cvs_ent_free   (struct cvs_ent *);
                    320: struct cvs_ent*  cvs_ent_getent (const char *);
1.1       jfb       321:
                    322: /* history API */
                    323: CVSHIST*         cvs_hist_open    (const char *);
                    324: void             cvs_hist_close   (CVSHIST *);
                    325: int              cvs_hist_parse   (CVSHIST *);
                    326: struct cvs_hent* cvs_hist_getnext (CVSHIST *);
                    327: int              cvs_hist_append  (CVSHIST *, struct cvs_hent *);
                    328:
                    329:
                    330: /* from util.c */
                    331: int    cvs_readrepo   (const char *, char *, size_t);
                    332: int    cvs_splitpath  (const char *, char *, size_t, char *, size_t);
                    333: int    cvs_modetostr  (mode_t, char *, size_t);
                    334: int    cvs_strtomode  (const char *, mode_t *);
1.10      jfb       335: int    cvs_mkadmin    (struct cvs_file *, mode_t);
1.1       jfb       336: int    cvs_cksum      (const char *, char *, size_t);
                    337: int    cvs_exec       (int, char **, int []);
1.6       jfb       338: int    cvs_getargv    (const char *, char **, int);
                    339: void   cvs_freeargv   (char **, int);
1.1       jfb       340:
                    341:
                    342: #endif /* CVS_H */