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 <openssl/md5.h>
33 #include <sys/types.h>
35 /* If we're not compiling in a C99 environment, define the C99 types. */
36 #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
41 #define uint32_t u_int32_t
46 #define uint16_t u_int16_t
51 #define uint8_t u_int8_t
57 /* This is a GCC-specific keyword but some other compilers (namely icc)
58 understand it, and the code won't work if we can't disable padding
61 #define __packed __attribute__((__packed__))
63 /* We explicitely don't define this with icc because it defines __GNUC__
64 but doesn't support it. */
66 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
67 (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC__MINOR__ >= 7)
68 #define __printflike(fmtarg, firstvararg) \
69 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
71 #define __printflike(fmtarg, firstvararg)
75 #define STATUS_SUCCESS 0
76 #define STATUS_FAILURE 1
77 #define STATUS_TRANSIENTFAILURE 2
78 #define STATUS_INTERRUPTED 3
83 /* Thread parameters. */
85 struct config *config;
92 /* Minimum size for MD5_File() and MD5_End() buffers. */
93 #define MD5_DIGEST_SIZE 33
95 #define min(a, b) ((a) > (b) ? (b) : (a))
96 #define max(a, b) ((a) < (b) ? (b) : (a))
102 int asciitoint(const char *, int *, int);
103 int lprintf(int, const char *, ...) __printflike(2, 3);
104 int MD5_File(char *, char *);
105 void MD5_End(char *, MD5_CTX *);
106 int rcsdatetotm(const char *, struct tm *);
107 time_t rcsdatetotime(const char *);
108 int pathcmp(const char *, const char *);
109 size_t commonpathlength(const char *, size_t, const char *, size_t);
110 const char *pathlast(const char *);
111 int isrcs(const char *, size_t *);
112 char *checkoutpath(const char *, const char *);
113 char *cvspath(const char *, const char *, int);
114 char *atticpath(const char *, const char *);
115 char *path_prefix(char *);
116 char *path_first(char *);
117 int mkdirhier(char *, mode_t);
118 char *tempname(const char *);
119 void *xmalloc(size_t);
120 void *xrealloc(void *, size_t);
121 char *xstrdup(const char *);
122 int xasprintf(char **, const char *, ...) __printflike(2, 3);
123 int rcsnum_cmp(char *, char *);
124 int rcsrev_istrunk(char *);
125 char *rcsrev_prefix(char *);
127 struct pattlist *pattlist_new(void);
128 void pattlist_add(struct pattlist *, const char *);
129 char *pattlist_get(struct pattlist *, size_t);
130 size_t pattlist_size(struct pattlist *);
131 void pattlist_free(struct pattlist *);
133 struct backoff_timer *bt_new(time_t, time_t, float, float);
134 time_t bt_get(struct backoff_timer *);
135 void bt_pause(struct backoff_timer *);
136 void bt_free(struct backoff_timer *);
138 #endif /* !_MISC_H_ */