[BACK]Return to file.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/file.h, Revision 1.7

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 FILE_H
                     28: #define FILE_H
                     29:
                     30: #include <sys/param.h>
1.3       jfb        31:
1.1       jfb        32: #include <dirent.h>
                     33:
                     34: struct cvs_file;
                     35: struct cvs_dir;
1.5       jfb        36: struct cvs_entries;
1.1       jfb        37:
                     38:
1.6       jfb        39: #define CF_STAT     0x01  /* obsolete */
1.3       jfb        40: #define CF_IGNORE   0x02  /* apply regular ignore rules */
                     41: #define CF_RECURSE  0x04  /* recurse on directory operations */
                     42: #define CF_SORT     0x08  /* all files are sorted alphabetically */
                     43: #define CF_KNOWN    0x10  /* only recurse in directories known to CVS */
                     44: #define CF_CREATE   0x20  /* create if file does not exist */
                     45: #define CF_MKADMIN  0x40  /* create administrative files if they're missing */
1.1       jfb        46:
                     47:
                     48: /*
                     49:  * The cvs_file structure is used to represent any file or directory within
                     50:  * the CVS tree's hierarchy.  The <cf_path> field is a path relative to the
                     51:  * directory in which the cvs command was executed.  The <cf_parent> field
                     52:  * points back to the parent node in the directory tree structure (it is
                     53:  * NULL if the directory is at the wd of the command).
                     54:  *
                     55:  * The <cf_cvstat> field gives the file's status with regards to the CVS
                     56:  * repository.  The file can be in any one of the CVS_FST_* states.
                     57:  * If the file's type is DT_DIR, then the <cf_ddat> pointer will point to
                     58:  * a cvs_dir structure containing data specific to the directory (such as
                     59:  * the contents of the directory's CVS/Entries, CVS/Root, etc.).
                     60:  */
                     61:
                     62: #define CVS_FST_UNKNOWN   0
                     63: #define CVS_FST_UPTODATE  1
                     64: #define CVS_FST_MODIFIED  2
                     65: #define CVS_FST_ADDED     3
                     66: #define CVS_FST_REMOVED   4
                     67: #define CVS_FST_CONFLICT  5
                     68: #define CVS_FST_PATCHED   6
                     69:
                     70:
                     71: TAILQ_HEAD(cvs_flist, cvs_file);
                     72:
                     73:
                     74: typedef struct cvs_file {
                     75:        char            *cf_path;
                     76:        struct cvs_file *cf_parent;  /* parent directory (NULL if none) */
                     77:        char            *cf_name;
1.7     ! jfb        78:        mode_t           cf_mode;
        !            79:        time_t           cf_mtime;
1.1       jfb        80:        u_int16_t        cf_cvstat;  /* cvs status of the file */
                     81:        u_int16_t        cf_type;    /* uses values from dirent.h */
                     82:        struct cvs_dir  *cf_ddat;    /* only for directories */
                     83:
                     84:        TAILQ_ENTRY(cvs_file)  cf_list;
                     85: } CVSFILE;
                     86:
                     87:
                     88: struct cvs_dir {
1.5       jfb        89:        struct cvsroot     *cd_root;
                     90:        char               *cd_repo;
                     91:        struct cvs_entries *cd_ent;
                     92:        struct cvs_flist    cd_files;
                     93:        u_int               cd_nfiles;
1.1       jfb        94: };
                     95:
1.2       jfb        96:
1.3       jfb        97: #define CVS_DIR_ROOT(f)  (((f)->cf_type == DT_DIR) ? \
1.2       jfb        98:        (f)->cf_ddat->cd_root : (((f)->cf_parent == NULL) ? \
                     99:        NULL : (f)->cf_parent->cf_ddat->cd_root))
                    100:
1.3       jfb       101: #define CVS_DIR_ENTRIES(f)  (((f)->cf_type == DT_DIR) ? \
                    102:        (f)->cf_ddat->cd_ent : (((f)->cf_parent == NULL) ? \
                    103:        NULL : (f)->cf_parent->cf_ddat->cd_ent))
                    104:
                    105: #define CVS_DIR_REPO(f)  (((f)->cf_type == DT_DIR) ? \
                    106:        (f)->cf_ddat->cd_repo : (((f)->cf_parent == NULL) ? \
                    107:        NULL : (f)->cf_parent->cf_ddat->cd_repo))
1.2       jfb       108:
1.1       jfb       109: int      cvs_file_init    (void);
                    110: int      cvs_file_ignore  (const char *);
                    111: int      cvs_file_chkign  (const char *);
                    112: CVSFILE* cvs_file_create  (const char *, u_int, mode_t);
                    113: CVSFILE* cvs_file_get     (const char *, int);
                    114: CVSFILE* cvs_file_getspec (char **, int, int);
1.2       jfb       115: CVSFILE* cvs_file_find    (CVSFILE *, const char *);
1.7     ! jfb       116: int      cvs_file_attach  (CVSFILE *, CVSFILE *);
1.2       jfb       117: int      cvs_file_examine (CVSFILE *, int (*)(CVSFILE *, void *), void *);
1.1       jfb       118: void     cvs_file_free    (struct cvs_file *);
                    119:
                    120:
                    121: #endif /* FILE_H */