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

1.105   ! joris       1: /*     $OpenBSD: cvs.h,v 1.104 2006/05/27 03:30:30 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
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.1       jfb       102:
1.70      xsa       103: /* extensions */
                    104: #define CVS_DESCR_FILE_EXT     ",t"
1.1       jfb       105:
                    106: /* server-side paths */
1.74      xsa       107: #define CVS_PATH_ROOT          "CVSROOT"
                    108: #define CVS_PATH_EMPTYDIR      CVS_PATH_ROOT "/Emptydir"
                    109: #define CVS_PATH_COMMITINFO    CVS_PATH_ROOT "/commitinfo"
                    110: #define CVS_PATH_CONFIG                CVS_PATH_ROOT "/config"
                    111: #define CVS_PATH_CVSIGNORE     CVS_PATH_ROOT "/cvsignore"
                    112: #define CVS_PATH_CVSWRAPPERS   CVS_PATH_ROOT "/cvswrappers"
                    113: #define CVS_PATH_EDITINFO      CVS_PATH_ROOT "/editinfo"
                    114: #define CVS_PATH_HISTORY       CVS_PATH_ROOT "/history"
                    115: #define CVS_PATH_LOGINFO       CVS_PATH_ROOT "/loginfo"
                    116: #define CVS_PATH_MODULES       CVS_PATH_ROOT "/modules"
1.101     xsa       117: #define CVS_PATH_NOTIFY_R      CVS_PATH_ROOT "/notify"
1.74      xsa       118: #define CVS_PATH_RCSINFO       CVS_PATH_ROOT "/rcsinfo"
                    119: #define CVS_PATH_TAGINFO       CVS_PATH_ROOT "/taginfo"
                    120: #define CVS_PATH_VERIFYMSG     CVS_PATH_ROOT "/verifymsg"
1.1       jfb       121:
                    122: /* client-side paths */
1.74      xsa       123: #define CVS_PATH_RC            ".cvsrc"
                    124: #define CVS_PATH_CVSDIR                "CVS"
1.100     xsa       125: #define CVS_PATH_BASEDIR       CVS_PATH_CVSDIR "/Base"
                    126: #define CVS_PATH_BASEREV       CVS_PATH_CVSDIR "/Baserev"
                    127: #define CVS_PATH_BASEREVTMP    CVS_PATH_CVSDIR "/Baserev.tmp"
                    128: #define CVS_PATH_CHECKINPROG   CVS_PATH_CVSDIR "/Checkin.prog"
1.74      xsa       129: #define CVS_PATH_ENTRIES       CVS_PATH_CVSDIR "/Entries"
                    130: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
                    131: #define CVS_PATH_LOGENTRIES    CVS_PATH_CVSDIR "/Entries.Log"
1.89      joris     132: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.100     xsa       133: #define CVS_PATH_NOTIFY                CVS_PATH_CVSDIR "/Notify"
                    134: #define CVS_PATH_NOTIFYTMP     CVS_PATH_CVSDIR "/Notify.tmp"
1.74      xsa       135: #define CVS_PATH_ROOTSPEC      CVS_PATH_CVSDIR "/Root"
                    136: #define CVS_PATH_REPOSITORY    CVS_PATH_CVSDIR "/Repository"
1.81      xsa       137: #define CVS_PATH_TAG           CVS_PATH_CVSDIR "/Tag"
1.100     xsa       138: #define CVS_PATH_TEMPLATE      CVS_PATH_CVSDIR "/Template"
                    139: #define CVS_PATH_UPDATEPROG    CVS_PATH_CVSDIR "/Update.prog"
1.1       jfb       140:
1.46      joris     141: struct cvs_cmd {
1.103     joris     142:        u_int    cmd_op;
                    143:        u_int    cmd_req;
1.86      reyk      144:        char     cmd_name[CVS_CMD_MAXNAMELEN];
                    145:        char     cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
                    146:        char     cmd_descr[CVS_CMD_MAXDESCRLEN];
                    147:        char    *cmd_synopsis;
                    148:        char    *cmd_opts;
                    149:        char    *cmd_defargs;
1.58      jfb       150:
1.104     joris     151:        int     (*cmd)(int, char **);
                    152: };
                    153:
                    154: struct cvsroot;
1.58      jfb       155:
1.104     joris     156: struct cvs_recursion {
                    157:        void    (*enterdir)(struct cvs_file *);
                    158:        void    (*leavedir)(struct cvs_file *);
                    159:        void    (*local)(struct cvs_file *);
                    160:        void    (*remote)(struct cvs_file *, struct cvsroot *);
1.46      joris     161: };
1.1       jfb       162:
1.41      jfb       163: struct cvs_var {
                    164:        char   *cv_name;
                    165:        char   *cv_val;
                    166:        TAILQ_ENTRY(cvs_var) cv_link;
                    167: };
                    168:
1.74      xsa       169: #define CVS_ROOT_CONNECTED     0x01
1.36      jfb       170:
1.1       jfb       171: struct cvsroot {
1.11      jfb       172:        char   *cr_str;
1.1       jfb       173:        u_int   cr_method;
                    174:        char   *cr_buf;
                    175:        char   *cr_user;
                    176:        char   *cr_pass;
                    177:        char   *cr_host;
                    178:        char   *cr_dir;
                    179:        u_int   cr_port;
1.11      jfb       180:        u_int   cr_ref;
                    181:
                    182:        /* connection data */
1.36      jfb       183:        u_int   cr_flags;
1.11      jfb       184:        FILE   *cr_srvin;
                    185:        FILE   *cr_srvout;
1.21      jfb       186:        FILE   *cr_srverr;
1.29      jfb       187:        char   *cr_version;     /* version of remote server */
                    188:        u_char  cr_vrmask[16];  /* mask of valid requests supported by server */
1.78      joris     189:
                    190:        TAILQ_ENTRY(cvsroot) root_cache;
1.1       jfb       191: };
1.20      jfb       192:
1.74      xsa       193: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |=  (1 << ((rq) % 8)))
                    194: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &   (1 << ((rq) % 8)))
                    195: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
                    196: #define CVS_RSTVR(rt)  memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
                    197:
                    198: #define CVS_HIST_ADDED         'A'
                    199: #define CVS_HIST_EXPORT                'E'
                    200: #define CVS_HIST_RELEASE       'F'
                    201: #define CVS_HIST_MODIFIED      'M'
                    202: #define CVS_HIST_CHECKOUT      'O'
                    203: #define CVS_HIST_COMMIT                'R'
                    204: #define CVS_HIST_TAG           'T'
                    205:
                    206: #define CVS_DATE_DUMMY "dummy timestamp"
                    207: #define CVS_DATE_DMSEC (time_t)-1
                    208:
                    209: #define CVS_ENT_NONE   0
                    210: #define CVS_ENT_FILE   1
                    211: #define CVS_ENT_DIR    2
                    212:
                    213: #define CVS_ENT_REG            0
                    214: #define CVS_ENT_ADDED          1
                    215: #define CVS_ENT_REMOVED                2
                    216: #define CVS_ENT_UPTODATE       3
1.80      xsa       217:
                    218: #define CVS_ENT_MAXLINELEN     1024
1.1       jfb       219:
1.104     joris     220: #define ENT_NOSYNC     0
                    221: #define ENT_SYNC       1
1.17      jfb       222:
1.85      joris     223: #define STRIP_SLASH(p)                                 \
                    224:        do {                                            \
                    225:                size_t _slen;                           \
                    226:                _slen = strlen(p);                      \
                    227:                while ((_slen > 0) && (p[_slen - 1] == '/'))    \
                    228:                        p[--_slen] = '\0';              \
                    229:        } while (0)
1.104     joris     230:
1.1       jfb       231: struct cvs_ent {
1.104     joris     232:        char            *ce_buf;
                    233:        char            *ce_name;
                    234:        char            *ce_opts;
                    235:        char            *ce_tag;
                    236:        char            *ce_conflict;
                    237:        time_t           ce_mtime;
                    238:        u_int16_t        ce_type;
                    239:        u_int16_t        ce_status;
                    240:        RCSNUM          *ce_rev;
                    241: };
                    242:
                    243: struct cvs_ent_line {
                    244:        char    *buf;
                    245:        TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1       jfb       246: };
                    247:
                    248: typedef struct cvs_entries {
1.74      xsa       249:        char    *cef_path;
1.89      joris     250:        char    *cef_bpath;
1.104     joris     251:        char    *cef_lpath;
1.1       jfb       252:
1.104     joris     253:        TAILQ_HEAD(, cvs_ent_line)       cef_ent;
1.1       jfb       254: } CVSENTRIES;
                    255:
1.104     joris     256: extern struct cvs_wklhead temp_files;
                    257: extern volatile sig_atomic_t sig_received;
                    258: extern volatile sig_atomic_t cvs_quit;
                    259: extern struct cvsroot *current_cvsroot;
1.64      joris     260: extern char *cvs_repo_base;
1.22      jfb       261: extern char *cvs_command;
1.18      jfb       262: extern char *cvs_editor;
1.76      xsa       263: extern char *cvs_homedir;
1.30      krapht    264: extern char *cvs_msg;
1.42      jfb       265: extern char *cvs_rsh;
1.77      xsa       266: extern char *cvs_tmpdir;
1.22      jfb       267:
1.42      jfb       268: extern int  verbosity;
                    269: extern int  cvs_trace;
                    270: extern int  cvs_nolog;
                    271: extern int  cvs_compress;
                    272: extern int  cvs_cmdop;
                    273: extern int  cvs_nocase;
1.57      xsa       274: extern int  cvs_noexec;
1.42      jfb       275: extern int  cvs_readonly;
1.72      joris     276: extern int  cvs_error;
1.15      jfb       277:
1.58      jfb       278: extern struct cvs_cmd *cvs_cdt[];
1.1       jfb       279:
1.58      jfb       280: extern struct cvs_cmd cvs_cmd_add;
                    281: extern struct cvs_cmd cvs_cmd_admin;
                    282: extern struct cvs_cmd cvs_cmd_annotate;
                    283: extern struct cvs_cmd cvs_cmd_checkout;
                    284: extern struct cvs_cmd cvs_cmd_commit;
                    285: extern struct cvs_cmd cvs_cmd_diff;
                    286: extern struct cvs_cmd cvs_cmd_edit;
                    287: extern struct cvs_cmd cvs_cmd_editors;
                    288: extern struct cvs_cmd cvs_cmd_export;
                    289: extern struct cvs_cmd cvs_cmd_history;
                    290: extern struct cvs_cmd cvs_cmd_import;
                    291: extern struct cvs_cmd cvs_cmd_init;
                    292: extern struct cvs_cmd cvs_cmd_log;
                    293: extern struct cvs_cmd cvs_cmd_login;
                    294: extern struct cvs_cmd cvs_cmd_logout;
                    295: extern struct cvs_cmd cvs_cmd_rdiff;
                    296: extern struct cvs_cmd cvs_cmd_release;
                    297: extern struct cvs_cmd cvs_cmd_remove;
                    298: extern struct cvs_cmd cvs_cmd_rlog;
                    299: extern struct cvs_cmd cvs_cmd_rtag;
                    300: extern struct cvs_cmd cvs_cmd_status;
                    301: extern struct cvs_cmd cvs_cmd_tag;
                    302: extern struct cvs_cmd cvs_cmd_update;
                    303: extern struct cvs_cmd cvs_cmd_version;
                    304: extern struct cvs_cmd cvs_cmd_server;
                    305: extern struct cvs_cmd cvs_cmd_unedit;
                    306: extern struct cvs_cmd cvs_cmd_watch;
                    307: extern struct cvs_cmd cvs_cmd_watchers;
                    308:
1.104     joris     309: /* cmd.c */
1.74      xsa       310: struct cvs_cmd *cvs_findcmd(const char *);
                    311: struct cvs_cmd *cvs_findcmdbyreq(int);
                    312:
1.104     joris     313: /* cvs.c */
1.74      xsa       314: int             cvs_var_set(const char *, const char *);
                    315: int             cvs_var_unset(const char *);
                    316: const char     *cvs_var_get(const char *);
1.104     joris     317: void            cvs_cleanup(void);
1.1       jfb       318:
1.104     joris     319: /* date.y */
                    320: time_t          cvs_date_parse(const char *);
                    321:
                    322: /* entries.c */
                    323: struct cvs_ent *cvs_ent_parse(const char *);
                    324: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
                    325: CVSENTRIES     *cvs_ent_open(const char *);
                    326: void           cvs_ent_add(CVSENTRIES *, const char *);
                    327: void           cvs_ent_remove(CVSENTRIES *, const char *);
                    328: void           cvs_ent_close(CVSENTRIES *, int);
                    329: void           cvs_ent_free(struct cvs_ent *);
                    330: int            cvs_ent_exists(CVSENTRIES *, const char *);
1.1       jfb       331:
1.69      xsa       332: /* root.c */
1.74      xsa       333: struct cvsroot *cvsroot_parse(const char *);
1.104     joris     334: struct cvsroot *cvsroot_get(const char *);
1.83      joris     335: void            cvsroot_remove(struct cvsroot *);
1.87      joris     336:
1.104     joris     337: /* misc stuff */
                    338: void   cvs_update_local(struct cvs_file *);
                    339: void   cvs_update_enterdir(struct cvs_file *);
1.105   ! joris     340: void   cvs_update_leavedir(struct cvs_file *);
1.104     joris     341: int    cvs_checkout_file(struct cvs_file *, RCSNUM *, int);
1.1       jfb       342:
1.91      joris     343: #endif