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

1.32    ! joris       1: /*     $OpenBSD: file.h,v 1.31 2005/12/03 02:19:17 joris 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:
1.16      jfb        35: #include "rcs.h"
                     36:
1.1       jfb        37: struct cvs_file;
1.5       jfb        38: struct cvs_entries;
1.1       jfb        39:
1.26      xsa        40: #define CF_STAT                0x01    /* obsolete */
                     41: #define CF_IGNORE      0x02    /* apply regular ignore rules */
                     42: #define CF_RECURSE     0x04    /* recurse on directory operations */
                     43: #define CF_SORT                0x08    /* all files are sorted alphabetically */
                     44: #define CF_KNOWN       0x10    /* only recurse in directories known to CVS */
                     45: #define CF_CREATE      0x20    /* create if file does not exist */
1.32    ! joris      46: #define CF_NOSYMS      0x40    /* ignore symbolic links */
        !            47: #define CF_NOFILES     0x80    /* don't load any files inside a directory */
        !            48: #define CF_REPO                0x100   /* we are loading a repository with ,v files */
1.1       jfb        49:
                     50: /*
                     51:  * The cvs_file structure is used to represent any file or directory within
                     52:  * the CVS tree's hierarchy.  The <cf_path> field is a path relative to the
                     53:  * directory in which the cvs command was executed.  The <cf_parent> field
                     54:  * points back to the parent node in the directory tree structure (it is
                     55:  * NULL if the directory is at the wd of the command).
                     56:  *
                     57:  * The <cf_cvstat> field gives the file's status with regards to the CVS
                     58:  * repository.  The file can be in any one of the CVS_FST_* states.
                     59:  */
1.26      xsa        60: #define CVS_FST_UNKNOWN                0       /* Unknown */
                     61: #define CVS_FST_UPTODATE       1       /* Up-to-date */
                     62: #define CVS_FST_MODIFIED       2       /* Locally Modified */
                     63: #define CVS_FST_ADDED          3       /* Locally Added */
                     64: #define CVS_FST_REMOVED                4       /* Locally Removed */
                     65: #define CVS_FST_CONFLICT       5       /* Unresolved Conflict */
                     66: #define CVS_FST_PATCHED                6
                     67: #define CVS_FST_LOST           7       /* Needs Checkout */
1.1       jfb        68:
1.16      jfb        69: SIMPLEQ_HEAD(cvs_flist, cvs_file);
1.1       jfb        70:
                     71: typedef struct cvs_file {
1.26      xsa        72:        struct cvs_file *cf_parent;     /* parent directory (NULL if none) */
1.25      joris      73:
                     74:        /*
                     75:         * cf_name contains the basename of the fullpath
                     76:         * cf_dir contains the parent directory the file or dir is in.
                     77:         * if cf_dir is NULL the file is in the parent directory.
                     78:         */
1.29      niallo     79:        char            *cf_name;
                     80:        char            *cf_dir;
1.25      joris      81:
1.28      joris      82:        /* pointer to the parent directory's entry file */
                     83:        void            *cf_entry;
                     84:
1.26      xsa        85:        mode_t           cf_mode;
                     86:        u_int8_t         cf_cvstat;     /* cvs status of the file */
                     87:        u_int8_t         cf_type;       /* uses values from dirent.h */
                     88:        u_int16_t        cf_flags;
1.16      jfb        89:
                     90:        union {
                     91:                struct {
1.26      xsa        92:                        RCSNUM  *cd_lrev;       /* local revision */
                     93:                        time_t   cd_etime;      /* time in Entries file */
                     94:                        time_t   cd_mtime;
                     95:                        char    *cd_tag;
                     96:                        char    *cd_opts;
1.16      jfb        97:                } cf_reg;
                     98:                struct {
1.26      xsa        99:                        char                    *cd_repo;
                    100:                        struct cvsroot          *cd_root;
                    101:                        struct cvs_flist        cd_files;
1.16      jfb       102:                } cf_dir;
                    103:        } cf_td;
1.1       jfb       104:
1.26      xsa       105:        SIMPLEQ_ENTRY(cvs_file) cf_list;
1.1       jfb       106: } CVSFILE;
                    107:
1.16      jfb       108: /* only valid for regular files */
1.26      xsa       109: #define cf_etime       cf_td.cf_reg.cd_etime
                    110: #define cf_mtime       cf_td.cf_reg.cd_mtime
                    111: #define cf_lrev                cf_td.cf_reg.cd_lrev
                    112: #define cf_tag         cf_td.cf_reg.cd_tag
                    113: #define cf_opts                cf_td.cf_reg.cd_opts
1.16      jfb       114:
                    115: /* only valid for directories */
1.26      xsa       116: #define cf_files       cf_td.cf_dir.cd_files
                    117: #define cf_repo                cf_td.cf_dir.cd_repo
                    118: #define cf_root                cf_td.cf_dir.cd_root
1.8       jfb       119:
1.26      xsa       120: #define CVS_DIRF_STATIC                0x01
                    121: #define CVS_DIRF_STICKY                0x02
                    122: #define CVS_DIRF_BASE          0x04
1.27      joris     123: #define CVS_FILE_ONDISK                0x08
1.8       jfb       124:
1.13      jfb       125: #define CVS_DIR_ROOT(f)  ((((f)->cf_type == DT_DIR) && \
1.16      jfb       126:        ((f)->cf_root != NULL)) ? (f)->cf_root : \
                    127:        (((f)->cf_parent == NULL) ? NULL : (f)->cf_parent->cf_root))
1.3       jfb       128:
                    129: #define CVS_DIR_REPO(f)  (((f)->cf_type == DT_DIR) ? \
1.16      jfb       130:        (f)->cf_repo : (((f)->cf_parent == NULL) ? \
                    131:        NULL : (f)->cf_parent->cf_repo))
1.2       jfb       132:
1.26      xsa       133: int     cvs_file_init(void);
                    134: int     cvs_file_ignore(const char *);
                    135: int     cvs_file_chkign(const char *);
                    136: int     cvs_file_get(const char *, int, int (*)(CVSFILE *, void *),
                    137:            void *, struct cvs_flist *);
                    138: int     cvs_file_getspec(char **, int, int, int (*)(CVSFILE *, void *),
                    139:            void *, struct cvs_flist *);
                    140: CVSFILE        *cvs_file_loadinfo(char *, int, int (*)(CVSFILE *, void *), void *,
                    141:            int);
                    142:
                    143: CVSFILE        *cvs_file_create(CVSFILE *, const char *, u_int, mode_t);
                    144: CVSFILE        *cvs_file_copy(CVSFILE *);
                    145: int     cvs_file_attach(CVSFILE *, CVSFILE *);
                    146:
                    147: int     cvs_file_init(void);
                    148: int     cvs_file_ignore(const char *);
                    149: int     cvs_file_chkign(const char *);
                    150: CVSFILE        *cvs_file_load(const char *, int);
                    151: CVSFILE        *cvs_file_find(CVSFILE *, const char *);
                    152: char   *cvs_file_getpath(CVSFILE *, char *, size_t);
                    153: void    cvs_file_free(CVSFILE *);
                    154: int     cvs_file_prune(char *);
1.1       jfb       155:
1.26      xsa       156: #endif /* FILE_H */