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

1.142   ! joris       1: /*     $OpenBSD: cvs.h,v 1.141 2007/07/03 13:22:42 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.134     otto       30: #include <signal.h>
                     31:
                     32: #include "config.h"
                     33: #include "file.h"
                     34: #include "log.h"
                     35: #include "worklist.h"
                     36: #include "repository.h"
1.128     niallo     37: #include "util.h"
1.104     joris      38: #include "xmalloc.h"
1.1       jfb        39:
1.104     joris      40: #define CVS_VERSION_MINOR      "0"
                     41: #define CVS_VERSION_MAJOR      "1"
                     42: #define CVS_VERSION_PORT
                     43:
                     44: #define CVS_VERSION            \
                     45:        "OpenCVS version "      \
                     46:        CVS_VERSION_MAJOR "." CVS_VERSION_MINOR CVS_VERSION_PORT
1.1       jfb        47:
1.74      xsa        48: #define CVS_HIST_CACHE 128
                     49: #define CVS_HIST_NBFLD 6
1.1       jfb        50:
1.135     xsa        51: #define CVS_CKSUM_LEN  MD5_DIGEST_STRING_LENGTH
1.140     xsa        52:
                     53: #define CVS_REV_BUFSZ  32
                     54: #define CVS_TIME_BUFSZ 64
1.1       jfb        55:
                     56: /* operations */
1.74      xsa        57: #define CVS_OP_UNKNOWN         0
                     58: #define CVS_OP_ADD             1
                     59: #define CVS_OP_ADMIN           2
                     60: #define CVS_OP_ANNOTATE                3
                     61: #define CVS_OP_CHECKOUT                4
                     62: #define CVS_OP_COMMIT          5
                     63: #define CVS_OP_DIFF            6
                     64: #define CVS_OP_EDIT            7
                     65: #define CVS_OP_EDITORS         8
                     66: #define CVS_OP_EXPORT          9
                     67: #define CVS_OP_HISTORY         10
                     68: #define CVS_OP_IMPORT          11
                     69: #define CVS_OP_INIT            12
                     70: #define CVS_OP_LOG             13
                     71: #define CVS_OP_RANNOTATE       14
                     72: #define CVS_OP_RDIFF           15
                     73: #define CVS_OP_RELEASE         16
                     74: #define CVS_OP_REMOVE          17
                     75: #define CVS_OP_RLOG            18
                     76: #define CVS_OP_RTAG            19
                     77: #define CVS_OP_SERVER          20
                     78: #define CVS_OP_STATUS          21
                     79: #define CVS_OP_TAG             22
                     80: #define CVS_OP_UNEDIT          23
                     81: #define CVS_OP_UPDATE          24
                     82: #define CVS_OP_VERSION         25
                     83: #define CVS_OP_WATCH           26
                     84: #define CVS_OP_WATCHERS                27
1.1       jfb        85:
1.74      xsa        86: #define CVS_OP_ANY             64      /* all operations */
1.1       jfb        87:
                     88: /* methods */
1.74      xsa        89: #define CVS_METHOD_NONE                0
                     90: #define CVS_METHOD_LOCAL       1       /* local access */
                     91: #define CVS_METHOD_SERVER      2       /* tunnel through CVS_RSH */
                     92: #define CVS_METHOD_PSERVER     3       /* cvs pserver */
                     93: #define CVS_METHOD_KSERVER     4       /* kerberos */
                     94: #define CVS_METHOD_GSERVER     5       /* gssapi server */
                     95: #define CVS_METHOD_EXT         6
                     96: #define CVS_METHOD_FORK                7       /* local but fork */
                     97:
                     98: #define CVS_CMD_MAXNAMELEN     16
                     99: #define CVS_CMD_MAXALIAS       2
                    100: #define CVS_CMD_MAXDESCRLEN    64
                    101: #define CVS_CMD_MAXARG         128
1.1       jfb       102:
                    103: /* defaults */
1.74      xsa       104: #define CVS_SERVER_DEFAULT     "cvs"
                    105: #define CVS_RSH_DEFAULT                "ssh"
                    106: #define CVS_EDITOR_DEFAULT     "vi"
1.77      xsa       107: #define CVS_TMPDIR_DEFAULT     "/tmp"
1.107     joris     108: #define CVS_UMASK_DEFAULT      002
1.1       jfb       109:
1.70      xsa       110: /* extensions */
                    111: #define CVS_DESCR_FILE_EXT     ",t"
1.1       jfb       112:
                    113: /* server-side paths */
1.108     joris     114: #define CVS_PATH_DEVNULL       "/dev/null"
1.74      xsa       115: #define CVS_PATH_ROOT          "CVSROOT"
                    116: #define CVS_PATH_EMPTYDIR      CVS_PATH_ROOT "/Emptydir"
1.112     xsa       117: #define CVS_PATH_CHECKOUTLIST  CVS_PATH_ROOT "/checkoutlist"
1.74      xsa       118: #define CVS_PATH_COMMITINFO    CVS_PATH_ROOT "/commitinfo"
                    119: #define CVS_PATH_CONFIG                CVS_PATH_ROOT "/config"
                    120: #define CVS_PATH_CVSIGNORE     CVS_PATH_ROOT "/cvsignore"
                    121: #define CVS_PATH_CVSWRAPPERS   CVS_PATH_ROOT "/cvswrappers"
                    122: #define CVS_PATH_EDITINFO      CVS_PATH_ROOT "/editinfo"
                    123: #define CVS_PATH_HISTORY       CVS_PATH_ROOT "/history"
                    124: #define CVS_PATH_LOGINFO       CVS_PATH_ROOT "/loginfo"
                    125: #define CVS_PATH_MODULES       CVS_PATH_ROOT "/modules"
1.101     xsa       126: #define CVS_PATH_NOTIFY_R      CVS_PATH_ROOT "/notify"
1.74      xsa       127: #define CVS_PATH_RCSINFO       CVS_PATH_ROOT "/rcsinfo"
                    128: #define CVS_PATH_TAGINFO       CVS_PATH_ROOT "/taginfo"
1.112     xsa       129: #define CVS_PATH_VALTAGS       CVS_PATH_ROOT "/val-tags"
1.74      xsa       130: #define CVS_PATH_VERIFYMSG     CVS_PATH_ROOT "/verifymsg"
1.1       jfb       131:
                    132: /* client-side paths */
1.74      xsa       133: #define CVS_PATH_RC            ".cvsrc"
                    134: #define CVS_PATH_CVSDIR                "CVS"
1.100     xsa       135: #define CVS_PATH_BASEDIR       CVS_PATH_CVSDIR "/Base"
                    136: #define CVS_PATH_BASEREV       CVS_PATH_CVSDIR "/Baserev"
                    137: #define CVS_PATH_BASEREVTMP    CVS_PATH_CVSDIR "/Baserev.tmp"
                    138: #define CVS_PATH_CHECKINPROG   CVS_PATH_CVSDIR "/Checkin.prog"
1.74      xsa       139: #define CVS_PATH_ENTRIES       CVS_PATH_CVSDIR "/Entries"
                    140: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
                    141: #define CVS_PATH_LOGENTRIES    CVS_PATH_CVSDIR "/Entries.Log"
1.89      joris     142: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.100     xsa       143: #define CVS_PATH_NOTIFY                CVS_PATH_CVSDIR "/Notify"
                    144: #define CVS_PATH_NOTIFYTMP     CVS_PATH_CVSDIR "/Notify.tmp"
1.74      xsa       145: #define CVS_PATH_ROOTSPEC      CVS_PATH_CVSDIR "/Root"
                    146: #define CVS_PATH_REPOSITORY    CVS_PATH_CVSDIR "/Repository"
1.81      xsa       147: #define CVS_PATH_TAG           CVS_PATH_CVSDIR "/Tag"
1.100     xsa       148: #define CVS_PATH_TEMPLATE      CVS_PATH_CVSDIR "/Template"
                    149: #define CVS_PATH_UPDATEPROG    CVS_PATH_CVSDIR "/Update.prog"
1.110     joris     150: #define CVS_PATH_ATTIC         "Attic"
1.1       jfb       151:
1.136     joris     152: /* history stuff */
                    153: #define CVS_HISTORY_TAG                        0
                    154: #define CVS_HISTORY_CHECKOUT           1
                    155: #define CVS_HISTORY_EXPORT             2
                    156: #define CVS_HISTORY_RELEASE            3
                    157: #define CVS_HISTORY_UPDATE_REMOVE      4
                    158: #define CVS_HISTORY_UPDATE_CO          5
                    159: #define CVS_HISTORY_UPDATE_MERGED      6
                    160: #define CVS_HISTORY_UPDATE_MERGED_ERR  7
                    161: #define CVS_HISTORY_COMMIT_MODIFIED    8
                    162: #define CVS_HISTORY_COMMIT_ADDED       9
                    163: #define CVS_HISTORY_COMMIT_REMOVED     10
                    164:
                    165: void   cvs_history_add(int, struct cvs_file *, const char *);
                    166:
1.46      joris     167: struct cvs_cmd {
1.103     joris     168:        u_int    cmd_op;
                    169:        u_int    cmd_req;
1.86      reyk      170:        char     cmd_name[CVS_CMD_MAXNAMELEN];
                    171:        char     cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
                    172:        char     cmd_descr[CVS_CMD_MAXDESCRLEN];
                    173:        char    *cmd_synopsis;
                    174:        char    *cmd_opts;
                    175:        char    *cmd_defargs;
1.58      jfb       176:
1.104     joris     177:        int     (*cmd)(int, char **);
                    178: };
                    179:
                    180: struct cvsroot;
1.58      jfb       181:
1.104     joris     182: struct cvs_recursion {
                    183:        void    (*enterdir)(struct cvs_file *);
                    184:        void    (*leavedir)(struct cvs_file *);
1.114     joris     185:        void    (*fileproc)(struct cvs_file *);
1.106     joris     186:        int     flags;
1.46      joris     187: };
1.106     joris     188:
                    189: #define CR_RECURSE_DIRS                0x01
                    190: #define CR_ATTIC               0x02
                    191: #define CR_REPO                        0x04
1.1       jfb       192:
1.41      jfb       193: struct cvs_var {
                    194:        char   *cv_name;
                    195:        char   *cv_val;
                    196:        TAILQ_ENTRY(cvs_var) cv_link;
                    197: };
1.122     xsa       198:
                    199: TAILQ_HEAD(, cvs_var) cvs_variables;
1.41      jfb       200:
1.74      xsa       201: #define CVS_ROOT_CONNECTED     0x01
1.36      jfb       202:
1.1       jfb       203: struct cvsroot {
1.11      jfb       204:        char   *cr_str;
1.1       jfb       205:        u_int   cr_method;
                    206:        char   *cr_buf;
                    207:        char   *cr_user;
                    208:        char   *cr_pass;
                    209:        char   *cr_host;
                    210:        char   *cr_dir;
                    211:        u_int   cr_port;
1.11      jfb       212:
                    213:        /* connection data */
1.36      jfb       214:        u_int   cr_flags;
1.11      jfb       215:        FILE   *cr_srvin;
                    216:        FILE   *cr_srvout;
1.21      jfb       217:        FILE   *cr_srverr;
1.29      jfb       218:        char   *cr_version;     /* version of remote server */
                    219:        u_char  cr_vrmask[16];  /* mask of valid requests supported by server */
1.78      joris     220:
                    221:        TAILQ_ENTRY(cvsroot) root_cache;
1.1       jfb       222: };
1.20      jfb       223:
1.74      xsa       224: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |=  (1 << ((rq) % 8)))
                    225: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &   (1 << ((rq) % 8)))
                    226: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
                    227: #define CVS_RSTVR(rt)  memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
                    228:
                    229: #define CVS_HIST_ADDED         'A'
                    230: #define CVS_HIST_EXPORT                'E'
                    231: #define CVS_HIST_RELEASE       'F'
                    232: #define CVS_HIST_MODIFIED      'M'
                    233: #define CVS_HIST_CHECKOUT      'O'
                    234: #define CVS_HIST_COMMIT                'R'
                    235: #define CVS_HIST_TAG           'T'
                    236:
                    237: #define CVS_DATE_DUMMY "dummy timestamp"
                    238: #define CVS_DATE_DMSEC (time_t)-1
                    239:
                    240: #define CVS_ENT_NONE   0
                    241: #define CVS_ENT_FILE   1
                    242: #define CVS_ENT_DIR    2
                    243:
                    244: #define CVS_ENT_REG            0
                    245: #define CVS_ENT_ADDED          1
                    246: #define CVS_ENT_REMOVED                2
                    247: #define CVS_ENT_UPTODATE       3
1.80      xsa       248:
                    249: #define CVS_ENT_MAXLINELEN     1024
1.1       jfb       250:
1.104     joris     251: #define ENT_NOSYNC     0
                    252: #define ENT_SYNC       1
1.17      jfb       253:
1.85      joris     254: #define STRIP_SLASH(p)                                 \
                    255:        do {                                            \
                    256:                size_t _slen;                           \
                    257:                _slen = strlen(p);                      \
                    258:                while ((_slen > 0) && (p[_slen - 1] == '/'))    \
                    259:                        p[--_slen] = '\0';              \
                    260:        } while (0)
1.104     joris     261:
1.1       jfb       262: struct cvs_ent {
1.104     joris     263:        char            *ce_buf;
                    264:        char            *ce_name;
                    265:        char            *ce_opts;
                    266:        char            *ce_tag;
                    267:        char            *ce_conflict;
                    268:        time_t           ce_mtime;
                    269:        u_int16_t        ce_type;
                    270:        u_int16_t        ce_status;
                    271:        RCSNUM          *ce_rev;
                    272: };
                    273:
                    274: struct cvs_ent_line {
                    275:        char    *buf;
                    276:        TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1       jfb       277: };
                    278:
                    279: typedef struct cvs_entries {
1.74      xsa       280:        char    *cef_path;
1.89      joris     281:        char    *cef_bpath;
1.104     joris     282:        char    *cef_lpath;
1.1       jfb       283:
1.104     joris     284:        TAILQ_HEAD(, cvs_ent_line)       cef_ent;
1.1       jfb       285: } CVSENTRIES;
                    286:
1.104     joris     287: extern struct cvs_wklhead temp_files;
                    288: extern volatile sig_atomic_t sig_received;
                    289: extern volatile sig_atomic_t cvs_quit;
                    290: extern struct cvsroot *current_cvsroot;
1.107     joris     291: extern char *cvs_tagname;
1.22      jfb       292: extern char *cvs_command;
1.18      jfb       293: extern char *cvs_editor;
1.76      xsa       294: extern char *cvs_homedir;
1.30      krapht    295: extern char *cvs_msg;
1.42      jfb       296: extern char *cvs_rsh;
1.77      xsa       297: extern char *cvs_tmpdir;
1.110     joris     298: extern char *import_repository;
1.116     joris     299: extern char *cvs_server_path;
1.141     joris     300: extern char *cvs_specified_tag;
1.22      jfb       301:
1.107     joris     302: extern int  cvs_umask;
1.42      jfb       303: extern int  verbosity;
                    304: extern int  cvs_trace;
                    305: extern int  cvs_nolog;
                    306: extern int  cvs_compress;
                    307: extern int  cvs_cmdop;
                    308: extern int  cvs_nocase;
1.57      xsa       309: extern int  cvs_noexec;
1.42      jfb       310: extern int  cvs_readonly;
1.124     xsa       311: extern int  cvs_readonlyfs;
1.72      joris     312: extern int  cvs_error;
1.116     joris     313: extern int  cvs_server_active;
1.141     joris     314: extern int  reset_stickies;
1.15      jfb       315:
1.58      jfb       316: extern struct cvs_cmd *cvs_cdt[];
1.1       jfb       317:
1.58      jfb       318: extern struct cvs_cmd cvs_cmd_add;
                    319: extern struct cvs_cmd cvs_cmd_admin;
                    320: extern struct cvs_cmd cvs_cmd_annotate;
                    321: extern struct cvs_cmd cvs_cmd_checkout;
                    322: extern struct cvs_cmd cvs_cmd_commit;
                    323: extern struct cvs_cmd cvs_cmd_diff;
                    324: extern struct cvs_cmd cvs_cmd_edit;
                    325: extern struct cvs_cmd cvs_cmd_editors;
                    326: extern struct cvs_cmd cvs_cmd_export;
                    327: extern struct cvs_cmd cvs_cmd_history;
                    328: extern struct cvs_cmd cvs_cmd_import;
                    329: extern struct cvs_cmd cvs_cmd_init;
                    330: extern struct cvs_cmd cvs_cmd_log;
                    331: extern struct cvs_cmd cvs_cmd_rdiff;
                    332: extern struct cvs_cmd cvs_cmd_release;
                    333: extern struct cvs_cmd cvs_cmd_remove;
                    334: extern struct cvs_cmd cvs_cmd_rlog;
                    335: extern struct cvs_cmd cvs_cmd_rtag;
                    336: extern struct cvs_cmd cvs_cmd_status;
                    337: extern struct cvs_cmd cvs_cmd_tag;
                    338: extern struct cvs_cmd cvs_cmd_update;
                    339: extern struct cvs_cmd cvs_cmd_version;
                    340: extern struct cvs_cmd cvs_cmd_server;
                    341: extern struct cvs_cmd cvs_cmd_unedit;
                    342: extern struct cvs_cmd cvs_cmd_watch;
                    343: extern struct cvs_cmd cvs_cmd_watchers;
                    344:
1.104     joris     345: /* cmd.c */
1.74      xsa       346: struct cvs_cmd *cvs_findcmd(const char *);
1.133     otto      347: struct cvs_cmd *cvs_findcmdbyreq(u_int);
1.74      xsa       348:
1.104     joris     349: /* cvs.c */
1.74      xsa       350: int             cvs_var_set(const char *, const char *);
                    351: int             cvs_var_unset(const char *);
                    352: const char     *cvs_var_get(const char *);
1.104     joris     353: void            cvs_cleanup(void);
1.1       jfb       354:
1.104     joris     355: /* date.y */
                    356: time_t          cvs_date_parse(const char *);
                    357:
                    358: /* entries.c */
                    359: struct cvs_ent *cvs_ent_parse(const char *);
                    360: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
                    361: CVSENTRIES     *cvs_ent_open(const char *);
                    362: void           cvs_ent_add(CVSENTRIES *, const char *);
                    363: void           cvs_ent_remove(CVSENTRIES *, const char *);
                    364: void           cvs_ent_close(CVSENTRIES *, int);
                    365: void           cvs_ent_free(struct cvs_ent *);
                    366: int            cvs_ent_exists(CVSENTRIES *, const char *);
1.113     xsa       367: void           cvs_parse_tagfile(char *, char **, char **, int *);
1.133     otto      368: void           cvs_write_tagfile(const char *, char *, char *, int);
1.1       jfb       369:
1.69      xsa       370: /* root.c */
1.104     joris     371: struct cvsroot *cvsroot_get(const char *);
1.126     joris     372:
                    373: /* logmsg.c */
                    374: char * cvs_logmsg_read(const char *path);
                    375: char * cvs_logmsg_create(struct cvs_flisthead *, struct cvs_flisthead *,
                    376:        struct cvs_flisthead *);
1.87      joris     377:
1.104     joris     378: /* misc stuff */
                    379: void   cvs_update_local(struct cvs_file *);
                    380: void   cvs_update_enterdir(struct cvs_file *);
1.105     joris     381: void   cvs_update_leavedir(struct cvs_file *);
1.129     joris     382: void   cvs_checkout_file(struct cvs_file *, RCSNUM *, int);
1.109     joris     383: int    update_has_conflict_markers(struct cvs_file *);
                    384:
                    385: #define CO_MERGE       0x01
1.111     joris     386: #define CO_SETSTICKY   0x02
1.115     reyk      387: #define CO_DUMP                0x04
1.125     joris     388: #define CO_COMMIT      0x08
1.138     joris     389: #define CO_REMOVE      0x10
1.116     joris     390:
                    391: /* commands */
1.117     xsa       392: int    cvs_add(int, char **);
1.120     xsa       393: int    cvs_admin(int, char **);
1.123     xsa       394: int    cvs_annotate(int, char **);
1.131     xsa       395: int    cvs_checkout(int, char **);
1.116     joris     396: int    cvs_commit(int, char **);
                    397: int    cvs_diff(int, char **);
1.127     xsa       398: int    cvs_edit(int, char **);
                    399: int    cvs_editors(int, char **);
1.131     xsa       400: int    cvs_export(int, char **);
1.118     xsa       401: int    cvs_getlog(int, char **);
1.136     joris     402: int    cvs_history(int, char **);
1.132     xsa       403: int    cvs_import(int, char **);
1.119     xsa       404: int    cvs_init(int, char **);
1.137     xsa       405: int    cvs_release(int, char **);
1.117     xsa       406: int    cvs_remove(int, char **);
1.116     joris     407: int    cvs_status(int, char **);
1.118     xsa       408: int    cvs_tag(int, char **);
1.127     xsa       409: int    cvs_unedit(int, char **);
1.116     joris     410: int    cvs_update(int, char **);
1.121     xsa       411: int    cvs_version(int, char **);
1.127     xsa       412: int    cvs_watch(int, char **);
                    413: int    cvs_watchers(int, char **);
1.134     otto      414:
1.1       jfb       415:
1.91      joris     416: #endif