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 __FILECMP_H__
31 #define	__FILECMP_H__
32 
33 struct collection;
34 struct cvsync_attr;
35 struct cvsync_file;
36 struct hash_args;
37 struct mux;
38 
39 #define	FILECMP_START		0x80
40 #define	FILECMP_END		0x81
41 
42 #define	FILECMP_ADD		0x00
43 #define	FILECMP_REMOVE		0x01
44 #define	FILECMP_SETATTR		0x02
45 #define	FILECMP_UPDATE		0x03
46 #define	FILECMP_RCS_ATTIC	0x04
47 
48 /* UPDATE */
49 #define	FILECMP_UPDATE_END	0x81
50 
51 #define	FILECMP_UPDATE_GENERIC	0x00
52 #define	FILECMP_UPDATE_RCS	0x01
53 #define	FILECMP_UPDATE_RDIFF	0x02
54 
55 #define	FILECMP_UPDATE_RCS_HEAD		0x00
56 #define	FILECMP_UPDATE_RCS_BRANCH	0x01
57 #define	FILECMP_UPDATE_RCS_ACCESS	0x02
58 #define	FILECMP_UPDATE_RCS_SYMBOLS	0x03
59 #define	FILECMP_UPDATE_RCS_LOCKS	0x04
60 #define	FILECMP_UPDATE_RCS_COMMENT	0x05
61 #define	FILECMP_UPDATE_RCS_EXPAND	0x06
62 #define	FILECMP_UPDATE_RCS_DELTA	0x07
63 #define	FILECMP_UPDATE_RCS_DESC		0x08
64 #define	FILECMP_UPDATE_RCS_DELTATEXT	0x09
65 
66 struct filecmp_args {
67 	struct mux		*fca_mux;
68 	const char		*fca_hostinfo;
69 	struct collection	*fca_collections_list, *fca_collections;
70 	struct collection	*fca_collection;
71 	uint32_t		fca_proto;
72 	pthread_t		fca_thread;
73 	void			*fca_status;
74 
75 	char			fca_name[CVSYNC_NAME_MAX + 1];
76 	char			fca_release[CVSYNC_NAME_MAX + 1];
77 
78 	char			fca_path[PATH_MAX + CVSYNC_NAME_MAX + 1];
79 	char			*fca_rpath;
80 	size_t			fca_pathmax, fca_pathlen, fca_rpathlen;
81 	size_t			fca_namemax;
82 
83 	uint8_t			fca_tag, fca_cmd[CVSYNC_MAXCMDLEN];
84 	uint8_t			fca_rvcmd[CVSYNC_MAXCMDLEN];
85 	size_t			fca_cmdmax;
86 	struct cvsync_attr	fca_attr;
87 	uint16_t		fca_umask;
88 
89 	void			*fca_hash_ctx;
90 	const struct hash_args	*fca_hash_ops;
91 	uint8_t			fca_hash[HASH_MAXLEN];
92 };
93 
94 struct filecmp_args *filecmp_init(struct mux *, struct collection *,
95 				  struct collection *, const char *, uint32_t,
96 				  int);
97 void filecmp_destroy(struct filecmp_args *);
98 void *filecmp(void *);
99 bool filecmp_start(struct filecmp_args *, const char *, const char *);
100 bool filecmp_end(struct filecmp_args *);
101 int filecmp_access(struct filecmp_args *, struct cvsync_attr *);
102 
103 bool filecmp_list(struct filecmp_args *);
104 bool filecmp_rcs(struct filecmp_args *);
105 
106 bool filecmp_generic_update(struct filecmp_args *, struct cvsync_file *);
107 bool filecmp_rdiff_update(struct filecmp_args *, struct cvsync_file *);
108 bool filecmp_rdiff_ignore(struct filecmp_args *);
109 bool filecmp_rdiff_ischanged(struct filecmp_args *, struct cvsync_file *);
110 
111 #endif /* __FILECMP_H__ */
112