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 __FILESCAN_H__
31 #define	__FILESCAN_H__
32 
33 struct collection;
34 struct cvsync_file;
35 struct hash_args;
36 struct mux;
37 struct refuse_args;
38 
39 #define	FILESCAN_START		0x80
40 #define	FILESCAN_END		0x81
41 
42 #define	FILESCAN_ADD		0x00
43 #define	FILESCAN_REMOVE		0x01
44 #define	FILESCAN_SETATTR	0x02
45 #define	FILESCAN_UPDATE		0x03
46 #define	FILESCAN_RCS_ATTIC	0x04
47 
48 struct filescan_args {
49 	struct mux		*fsa_mux;
50 	struct collection	*fsa_collections;
51 	struct refuse_args	*fsa_refuse;
52 	uint32_t		fsa_proto;
53 	pthread_t		fsa_thread;
54 	void			*fsa_status;
55 
56 	char			fsa_name[CVSYNC_NAME_MAX + 1];
57 	char			fsa_release[CVSYNC_NAME_MAX + 1];
58 
59 	char			fsa_path[PATH_MAX + CVSYNC_NAME_MAX + 1];
60 	char			*fsa_rpath;
61 	size_t			fsa_pathmax, fsa_pathlen, fsa_namemax;
62 
63 	uint8_t			fsa_tag, fsa_cmd[CVSYNC_MAXCMDLEN];
64 	size_t			fsa_cmdmax;
65 	struct cvsync_attr	fsa_attr;
66 	uint16_t		fsa_umask;
67 
68 	void			*fsa_hash_ctx;
69 	const struct hash_args	*fsa_hash_ops;
70 };
71 
72 struct filescan_args *filescan_init(struct mux *, struct collection *,
73 				    uint32_t, int);
74 void filescan_destroy(struct filescan_args *);
75 void *filescan(void *);
76 bool filescan_start(struct filescan_args *, const char *, const char *);
77 bool filescan_end(struct filescan_args *);
78 
79 bool filescan_rcs(struct filescan_args *);
80 
81 bool filescan_generic_update(struct filescan_args *, struct cvsync_file *);
82 bool filescan_rdiff_update(struct filescan_args *, struct cvsync_file *);
83 
84 #endif /* __FILESCAN_H__ */
85