1 /* $OpenBSD: file.h,v 1.53 2009/03/26 22:54:37 joris Exp $ */ 2 /* 3 * Copyright (c) 2006 Joris Vink <joris@openbsd.org> 4 * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. The name of the author may not be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 18 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 19 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef FILE_H 29 #define FILE_H 30 31 #include <sys/queue.h> 32 #include <sys/tree.h> 33 34 #include <dirent.h> 35 #include <stdio.h> 36 37 #include "rcs.h" 38 39 struct cvs_file { 40 char *file_name; 41 char *file_wd; 42 char *file_path; 43 char *file_rpath; 44 45 int fd; 46 int repo_fd; 47 int file_type; 48 int file_status; 49 int file_flags; 50 int in_attic; 51 52 RCSNUM *file_rcsrev; 53 RCSFILE *file_rcs; 54 struct cvs_ent *file_ent; 55 }; 56 57 #define FILE_UNKNOWN 0 58 #define FILE_ADDED 1 59 #define FILE_REMOVED 2 60 #define FILE_MODIFIED 3 61 #define FILE_UPTODATE 4 62 #define FILE_LOST 5 63 #define FILE_CHECKOUT 6 64 #define FILE_MERGE 7 65 #define FILE_PATCH 8 66 #define FILE_REMOVE_ENTRY 9 67 #define FILE_CONFLICT 10 68 #define FILE_UNLINK 11 69 70 #define DIR_CREATE 12 71 72 #define FILE_SKIP 100 73 74 #define FILE_HAS_TAG 0x01 75 #define FILE_USER_SUPPLIED 0x02 76 #define FILE_INSIDE_ATTIC 0x04 77 #define FILE_ON_DISK 0x08 78 79 struct cvs_filelist { 80 RB_ENTRY(cvs_filelist) flist; 81 char *file_path; 82 int flags; 83 int type; 84 }; 85 86 RB_HEAD(cvs_flisthead, cvs_filelist); 87 RB_PROTOTYPE(cvs_flisthead, cvs_filelist, flist, cvs_filelist_cmp); 88 89 struct cvs_recursion; 90 91 #define CVS_DIR 1 92 #define CVS_FILE 2 93 94 TAILQ_HEAD(cvs_flist, cvs_file); 95 96 struct cvs_ignpat { 97 char ip_pat[MAXNAMLEN]; 98 int ip_flags; 99 TAILQ_ENTRY(cvs_ignpat) ip_list; 100 }; 101 102 TAILQ_HEAD(ignore_head, cvs_ignpat); 103 104 void cvs_file_init(void); 105 void cvs_file_ignore(const char *, struct ignore_head *); 106 void cvs_file_classify(struct cvs_file *, const char *); 107 void cvs_file_free(struct cvs_file *); 108 void cvs_file_run(int, char **, struct cvs_recursion *); 109 void cvs_file_walklist(struct cvs_flisthead *, struct cvs_recursion *); 110 void cvs_file_walkdir(struct cvs_file *, struct cvs_recursion *); 111 void cvs_file_freelist(struct cvs_flisthead *); 112 struct cvs_filelist *cvs_file_get(char *, int, struct cvs_flisthead *, int); 113 114 int cvs_filelist_cmp(struct cvs_filelist *, struct cvs_filelist *); 115 int cvs_file_chkign(const char *); 116 int cvs_file_cmpname(const char *, const char *); 117 int cvs_file_cmp(const char *, const char *); 118 int cvs_file_copy(const char *, const char *); 119 120 struct cvs_file *cvs_file_get_cf(const char *, const char *, const char *, 121 int, int, int); 122 123 #endif /* FILE_H */ 124