Annotation of src/usr.bin/cvs/rcs.h, Revision 1.1
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 RCS_H
! 28: #define RCS_H
! 29:
! 30: #include <sys/types.h>
! 31: #include <sys/queue.h>
! 32:
! 33: #include <time.h>
! 34:
! 35: #include "buf.h"
! 36:
! 37: #define RCS_DIFF_MAXARG 32
! 38: #define RCS_DIFF_DIV \
! 39: "==================================================================="
! 40:
! 41: #define RCS_FILE_EXT ",v"
! 42:
! 43: #define RCS_HEAD_INIT "1.1"
! 44:
! 45:
! 46: /* open modes */
! 47: #define RCS_MODE_READ 0x01
! 48: #define RCS_MODE_WRITE 0x02
! 49: #define RCS_MODE_RDWR (RCS_MODE_READ|RCS_MODE_WRITE)
! 50:
! 51:
! 52: /* file flags */
! 53: #define RCS_RF_PARSED 0x01 /* file has been parsed */
! 54: #define RCS_RF_SYNCED 0x02 /* in-memory copy is in sync with disk copy */
! 55: #define RCS_RF_SLOCK 0x04 /* strict lock */
! 56:
! 57: /* delta flags */
! 58: #define RCS_RD_DEAD 0x01 /* dead */
! 59:
! 60:
! 61: typedef struct rcs_num {
! 62: u_int rn_len;
! 63: u_int16_t *rn_id;
! 64: } RCSNUM;
! 65:
! 66:
! 67:
! 68: struct rcs_sym {
! 69: char *rs_name;
! 70: RCSNUM *rs_num;
! 71: TAILQ_ENTRY(rcs_sym) rs_list;
! 72: };
! 73:
! 74: struct rcs_lock {
! 75: RCSNUM *rl_num;
! 76:
! 77: TAILQ_ENTRY(rcs_lock) rl_list;
! 78: };
! 79:
! 80:
! 81: struct rcs_branch {
! 82: RCSNUM *rb_num;
! 83: TAILQ_ENTRY(rcs_branch) rb_list;
! 84: };
! 85:
! 86: struct rcs_dlist {
! 87: struct rcs_delta *tqh_first;
! 88: struct rcs_delta **tqh_last;
! 89: };
! 90:
! 91: struct rcs_delta {
! 92: RCSNUM *rd_num;
! 93: RCSNUM *rd_next;
! 94: u_int rd_flags;
! 95: struct tm rd_date;
! 96: char *rd_author;
! 97: char *rd_state;
! 98: char *rd_log;
! 99: char *rd_text;
! 100:
! 101: struct rcs_dlist rd_snodes;
! 102:
! 103: TAILQ_HEAD(, rcs_branch) rd_branches;
! 104: TAILQ_ENTRY(rcs_delta) rd_list;
! 105: };
! 106:
! 107:
! 108:
! 109: typedef struct rcs_file {
! 110: char *rf_path;
! 111: u_int rf_ref;
! 112: u_int rf_mode;
! 113: u_int rf_flags;
! 114:
! 115: RCSNUM *rf_head;
! 116: RCSNUM *rf_branch;
! 117: char *rf_comment;
! 118: char *rf_expand;
! 119: char *rf_desc;
! 120:
! 121: struct rcs_dlist rf_delta;
! 122: TAILQ_HEAD(rcs_slist, rcs_sym) rf_symbols;
! 123: TAILQ_HEAD(rcs_llist, rcs_lock) rf_locks;
! 124:
! 125: void *rf_pdata;
! 126: } RCSFILE;
! 127:
! 128:
! 129:
! 130:
! 131: RCSFILE* rcs_open (const char *, u_int);
! 132: void rcs_close (RCSFILE *);
! 133: int rcs_parse (RCSFILE *);
! 134: int rcs_write (RCSFILE *);
! 135: int rcs_addsym (RCSFILE *, const char *, RCSNUM *);
! 136: int rcs_rmsym (RCSFILE *, const char *);
! 137: BUF* rcs_getrev (RCSFILE *, RCSNUM *);
! 138: RCSNUM* rcs_getrevbydate (RCSFILE *, struct tm *);
! 139:
! 140: BUF* rcs_patch (const char *, const char *);
! 141: size_t rcs_stresc (int, const char *, char *, size_t *);
! 142:
! 143: RCSNUM* rcsnum_alloc (void);
! 144: void rcsnum_free (RCSNUM *);
! 145: int rcsnum_aton (const char *, char **, RCSNUM *);
! 146: char* rcsnum_tostr (const RCSNUM *, char *, size_t);
! 147: int rcsnum_cpy (const RCSNUM *, RCSNUM *, u_int);
! 148: int rcsnum_cmp (const RCSNUM *, const RCSNUM *, u_int);
! 149:
! 150:
! 151: #endif /* RCS_H */