2 * Copyright (c) 2003-2006, Maxime Henrion <mux@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/types.h>
35 #define MD5_DIGEST_LENGTH 16
36 #define MD5_Init MD5Init
37 #define MD5_Final MD5Final
38 #define MD5_Update MD5Update
40 #include <openssl/md5.h>
43 /* If we're not compiling in a C99 environment, define the C99 types. */
44 #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
49 #define uint32_t u_int32_t
54 #define uint16_t u_int16_t
59 #define uint8_t u_int8_t
65 /* This is a GCC-specific keyword but some other compilers (namely icc)
66 understand it, and the code won't work if we can't disable padding
69 #define __packed __attribute__((__packed__))
71 /* We explicitely don't define this with icc because it defines __GNUC__
72 but doesn't support it. */
74 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
75 (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC__MINOR__ >= 7)
76 #define __printflike(fmtarg, firstvararg) \
77 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
79 #define __printflike(fmtarg, firstvararg)
83 #define STATUS_SUCCESS 0
84 #define STATUS_FAILURE 1
85 #define STATUS_TRANSIENTFAILURE 2
86 #define STATUS_INTERRUPTED 3
91 /* Thread parameters. */
93 struct config *config;
100 /* Minimum size for MD5_File() and MD5_End() buffers. */
101 #define MD5_DIGEST_SIZE 33
103 #define min(a, b) ((a) > (b) ? (b) : (a))
104 #define max(a, b) ((a) < (b) ? (b) : (a))
106 struct backoff_timer;
110 int asciitoint(const char *, int *, int);
111 int lprintf(int, const char *, ...) __printflike(2, 3);
112 int MD5_File(char *, char *);
113 void MD5_End(char *, MD5_CTX *);
114 int rcsdatetotm(const char *, struct tm *);
115 time_t rcsdatetotime(const char *);
116 int pathcmp(const char *, const char *);
117 size_t commonpathlength(const char *, size_t, const char *, size_t);
118 const char *pathlast(const char *);
119 int isrcs(const char *, size_t *);
120 char *checkoutpath(const char *, const char *);
121 char *cvspath(const char *, const char *, int);
122 char *atticpath(const char *, const char *);
123 char *path_prefix(char *);
124 char *path_first(char *);
125 int mkdirhier(char *, mode_t);
126 char *tempname(const char *);
127 void *xmalloc(size_t);
128 void *xrealloc(void *, size_t);
129 char *xstrdup(const char *);
130 int xasprintf(char **, const char *, ...) __printflike(2, 3);
131 int rcsnum_cmp(char *, char *);
132 int rcsrev_istrunk(char *);
133 char *rcsrev_prefix(char *);
135 struct pattlist *pattlist_new(void);
136 void pattlist_add(struct pattlist *, const char *);
137 char *pattlist_get(struct pattlist *, size_t);
138 size_t pattlist_size(struct pattlist *);
139 void pattlist_free(struct pattlist *);
141 struct backoff_timer *bt_new(time_t, time_t, float, float);
142 time_t bt_get(struct backoff_timer *);
143 void bt_pause(struct backoff_timer *);
144 void bt_free(struct backoff_timer *);
146 #endif /* !_MISC_H_ */