Annotation of src/usr.bin/cvs/file.h, Revision 1.14
1.14 ! joris 1: /* $OpenBSD: file.h,v 1.13 2004/12/15 07:03:04 jfb Exp $ */
1.1 jfb 2: /*
3: * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
1.11 tedu 4: * All rights reserved.
1.1 jfb 5: *
1.11 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.11 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.11 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.11 tedu 24: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1 jfb 25: */
26:
27: #ifndef FILE_H
28: #define FILE_H
29:
30: #include <sys/param.h>
1.3 jfb 31:
1.1 jfb 32: #include <dirent.h>
1.9 jfb 33: #include <search.h>
1.1 jfb 34:
35: struct cvs_file;
36: struct cvs_dir;
1.5 jfb 37: struct cvs_entries;
1.1 jfb 38:
39:
1.9 jfb 40: #define CVS_FILE_MAXDEPTH 32
41: #define CVS_FILE_NBUCKETS 256
42:
43:
1.6 jfb 44: #define CF_STAT 0x01 /* obsolete */
1.3 jfb 45: #define CF_IGNORE 0x02 /* apply regular ignore rules */
46: #define CF_RECURSE 0x04 /* recurse on directory operations */
47: #define CF_SORT 0x08 /* all files are sorted alphabetically */
48: #define CF_KNOWN 0x10 /* only recurse in directories known to CVS */
49: #define CF_CREATE 0x20 /* create if file does not exist */
50: #define CF_MKADMIN 0x40 /* create administrative files if they're missing */
1.8 jfb 51: #define CF_NOSYMS 0x80 /* ignore symbolic links */
1.1 jfb 52:
53:
54: /*
55: * The cvs_file structure is used to represent any file or directory within
56: * the CVS tree's hierarchy. The <cf_path> field is a path relative to the
57: * directory in which the cvs command was executed. The <cf_parent> field
58: * points back to the parent node in the directory tree structure (it is
59: * NULL if the directory is at the wd of the command).
60: *
61: * The <cf_cvstat> field gives the file's status with regards to the CVS
62: * repository. The file can be in any one of the CVS_FST_* states.
63: * If the file's type is DT_DIR, then the <cf_ddat> pointer will point to
64: * a cvs_dir structure containing data specific to the directory (such as
65: * the contents of the directory's CVS/Entries, CVS/Root, etc.).
66: */
67: #define CVS_FST_UNKNOWN 0
68: #define CVS_FST_UPTODATE 1
69: #define CVS_FST_MODIFIED 2
70: #define CVS_FST_ADDED 3
71: #define CVS_FST_REMOVED 4
72: #define CVS_FST_CONFLICT 5
73: #define CVS_FST_PATCHED 6
1.12 jfb 74: #define CVS_FST_LOST 7
1.1 jfb 75:
1.11 tedu 76:
1.9 jfb 77: struct cvs_fname {
78: char *cf_name;
79: u_int cf_ref;
80: SLIST_ENTRY(cvs_fname) cf_list;
81: };
82:
1.1 jfb 83:
84: TAILQ_HEAD(cvs_flist, cvs_file);
85:
86:
87: typedef struct cvs_file {
1.9 jfb 88: struct cvs_file *cf_parent; /* parent directory (NULL if none) */
89: struct cvs_fname *cf_name;
90: mode_t cf_mode;
91: time_t cf_mtime;
92: u_int16_t cf_cvstat; /* cvs status of the file */
93: u_int16_t cf_type; /* uses values from dirent.h */
94: struct cvs_dir *cf_ddat; /* only for directories */
1.1 jfb 95:
96: TAILQ_ENTRY(cvs_file) cf_list;
97: } CVSFILE;
98:
1.9 jfb 99: #define CVS_FILE_NAME(cf) (cf->cf_name->cf_name)
1.1 jfb 100:
1.8 jfb 101:
102: #define CVS_DIRF_STATIC 0x01
103: #define CVS_DIRF_STICKY 0x02
1.14 ! joris 104: #define CVS_DIRF_BASE 0x04
1.8 jfb 105:
1.1 jfb 106: struct cvs_dir {
1.5 jfb 107: struct cvsroot *cd_root;
108: char *cd_repo;
109: struct cvs_entries *cd_ent;
110: struct cvs_flist cd_files;
1.9 jfb 111: u_int16_t cd_nfiles;
112: u_int16_t cd_flags;
1.1 jfb 113: };
114:
1.2 jfb 115:
1.13 jfb 116: #define CVS_DIR_ROOT(f) ((((f)->cf_type == DT_DIR) && \
117: ((f)->cf_ddat->cd_root != NULL)) ? (f)->cf_ddat->cd_root : \
118: (((f)->cf_parent == NULL) ? NULL : (f)->cf_parent->cf_ddat->cd_root))
1.2 jfb 119:
1.3 jfb 120: #define CVS_DIR_ENTRIES(f) (((f)->cf_type == DT_DIR) ? \
121: (f)->cf_ddat->cd_ent : (((f)->cf_parent == NULL) ? \
122: NULL : (f)->cf_parent->cf_ddat->cd_ent))
123:
124: #define CVS_DIR_REPO(f) (((f)->cf_type == DT_DIR) ? \
125: (f)->cf_ddat->cd_repo : (((f)->cf_parent == NULL) ? \
126: NULL : (f)->cf_parent->cf_ddat->cd_repo))
1.2 jfb 127:
1.1 jfb 128: int cvs_file_init (void);
129: int cvs_file_ignore (const char *);
130: int cvs_file_chkign (const char *);
131: CVSFILE* cvs_file_get (const char *, int);
132: CVSFILE* cvs_file_getspec (char **, int, int);
1.9 jfb 133: CVSFILE* cvs_file_create (CVSFILE *, const char *, u_int, mode_t);
1.10 jfb 134: CVSFILE* cvs_file_copy (CVSFILE *);
1.2 jfb 135: CVSFILE* cvs_file_find (CVSFILE *, const char *);
1.7 jfb 136: int cvs_file_attach (CVSFILE *, CVSFILE *);
1.9 jfb 137: char* cvs_file_getpath (CVSFILE *, char *, size_t);
1.2 jfb 138: int cvs_file_examine (CVSFILE *, int (*)(CVSFILE *, void *), void *);
1.9 jfb 139: void cvs_file_free (CVSFILE *);
1.1 jfb 140:
141:
142: #endif /* FILE_H */