1 /*- 2 * Copyright (c) 2000-2005 MAEKAWA Masahide <maekawa@cvsync.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the author nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30 #ifndef __SCANFILE_H__ 31 #define __SCANFILE_H__ 32 33 struct cvsync_file; 34 35 struct scanfile_attr { 36 size_t a_size; 37 uint8_t a_type; 38 void *a_name; 39 size_t a_namelen; 40 void *a_aux; 41 size_t a_auxlen; 42 }; 43 44 struct scanfile_args { 45 struct cvsync_file *sa_scanfile; 46 const char *sa_scanfile_name; 47 uint8_t *sa_start, *sa_end; 48 49 int sa_tmp; 50 char sa_tmp_name[PATH_MAX + CVSYNC_NAME_MAX + 1]; 51 mode_t sa_tmp_mode; 52 53 struct list *sa_dirlist; 54 struct scanfile_attr sa_attr; 55 56 bool sa_changed; 57 }; 58 59 struct scanfile_create_args { 60 const char *sca_name, *sca_prefix, *sca_release; 61 const char *sca_rprefix; 62 size_t sca_rprefixlen; 63 mode_t sca_mode; 64 struct mdirent_args *sca_mdirent_args; 65 mode_t sca_umask; 66 }; 67 68 void scanfile_init(struct scanfile_args *); 69 struct scanfile_args *scanfile_open(const char *); 70 void scanfile_close(struct scanfile_args *); 71 bool scanfile_read_attr(uint8_t *, const uint8_t *, struct scanfile_attr *); 72 bool scanfile_write_attr(struct scanfile_args *, struct scanfile_attr *); 73 74 bool scanfile_create_tmpfile(struct scanfile_args *, mode_t); 75 void scanfile_remove_tmpfile(struct scanfile_args *); 76 bool scanfile_rename(struct scanfile_args *); 77 78 bool scanfile_add(struct scanfile_args *, uint8_t, void *, size_t, void *, 79 size_t); 80 bool scanfile_remove(struct scanfile_args *, uint8_t, void *, size_t); 81 bool scanfile_replace(struct scanfile_args *, uint8_t, void *, size_t, void *, 82 size_t); 83 bool scanfile_update(struct scanfile_args *, uint8_t, void *, size_t, void *, 84 size_t); 85 86 bool scanfile_create(struct scanfile_create_args *); 87 bool scanfile_rcs(struct scanfile_create_args *); 88 89 #endif /* __SCANFILE_H__ */ 90