File: dcc_defs.h

package info (click to toggle)
dcc 1.2.74-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,552 kB
  • ctags: 4,041
  • sloc: ansic: 41,034; perl: 2,310; sh: 2,186; makefile: 224
file content (645 lines) | stat: -rw-r--r-- 19,485 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
/* Distributed Checksum Clearinghouse
 *
 * common definitions internal to client libraries and servers
 *
 * Copyright (c) 2005 by Rhyolite Software
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE
 * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 *
 * Rhyolite Software DCC 1.2.74-1.204 $Revision$
 */

#ifndef DCC_DEFS_H
#define DCC_DEFS_H

#define RHYOLITE_VERSION "1.2.74"
#define DCC_VERSION RHYOLITE_VERSION

#include "dcc_config.h"

/* work on WIN32 and any reasonable UNIX platform */
#ifdef UNIX
#include <stdarg.h>
#include <stdio.h>			/* for FreeBSD */
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
#undef EX_OK				/* IRIX defines EX_OK in unistd.h */
#include <sysexits.h>
#include <limits.h>			/* for FreeBSD */
#include <netdb.h>
#include <netinet/in.h>
#include <sys/param.h>			/* for FreeBSD */
#include <sys/socket.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#else /* !UNIX or DCC_WIN32 */
#define STRICT
#define WIN32_LEAN_AND_MEAN
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <winerror.h>
#include <limits.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <io.h>
#include "sendmail-sysexits.h"

typedef unsigned int	u_int32_t;
typedef signed int	int32_t;
typedef unsigned short	u_int16_t;
#endif /* !UNIX or DCC_WIN32 */

/* use kludge file if asked */
#ifdef NEED_KLUDGE_H
#include "kludge.h"
#endif

#ifdef NEED_STRINGS_H
#include <strings.h>
#endif

#if !defined(DCC_HAVE_U_INT32_T)
#define u_int32_t uint32_t
#define u_int16_t uint16_t
#endif
#if !defined(DCC_HAVE_U_INT64_T)
#define u_int64_t uint64_t
#endif

#ifdef HAVE_GCC_ATTRIBUTES
#define UATTRIB __attribute__((unused))
#define PATTRIB(f,l) __attribute__((format (printf,f,l)))
#define NRATTRIB __attribute((__noreturn__))
#else
#define UATTRIB
#define PATTRIB(f,l)
#define NRATTRIB
#endif

#ifndef HAVE_GCC_INLINE
#define inline
#endif

typedef char DCC_PASSWD[32];

typedef char DCC_EMSG[120];

/* deal with ancient UNIX */
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif

#ifdef UNIX
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
#endif
#ifdef HAVE_OLD_MSYNC
#define MSYNC(addr,len,flags) msync((void *)(addr),(len))
#else
#define MSYNC(addr,len,flags) msync((void *)(addr),(len),(flags))
#endif

#ifndef FD_CLOEXEC
#define FD_CLOEXEC 1
#endif

#ifndef HAVE_DAEMON
#define daemon dcc_daemon
extern int daemon(int, int);
#endif

typedef int SOCKET;
typedef int HANDLE;
#define INVALID_HANDLE_VALUE (-1)
#define INVALID_SOCKET (-1)
#define SOCKET_ERROR (-1)
#define WSAAPI
#define closesocket close
#define ERROR_STR() ERROR_STR1(errno)
#define ERROR_STR1(e) strerror(e)
#define DCC_CONNECT_ERRORS() (errno == ECONNREFUSED		    \
			      || errno == EHOSTUNREACH		    \
			      || errno == EHOSTDOWN		    \
			      || errno == ENETDOWN		    \
			      || errno == ENETUNREACH)
#define DCC_SELECT_NERROR() (errno == EINTR || errno == EAGAIN)
/* EWOULDBLOCK and EAGAIN differ on HP-UX */
#define DCC_BLOCK_ERROR() (errno == EWOULDBLOCK || errno == EAGAIN)

typedef char DCC_PATH[PATH_MAX+1];

#else /* !UNIX or DCC_WIN32 */
extern void win32_init(void);

#undef errno
#define errno WSAGetLastError()
#define h_errno WSAGetLastError()
#define ERROR_STR() ERROR_STR1(errno)
#define ERROR_STR1(e) ws_strerror(e)
const char *ws_strerror(int);
#define DCC_CONNECT_ERRORS() ((errno) == WSAECONNREFUSED	\
			      || (errno) == WSAEHOSTUNREACH	\
			      || (errno) == WSAEHOSTDOWN	\
			      || (errno) == WSAENETDOWN	\
			      || (errno) == WSAENETUNREACH)
#define DCC_SELECT_NERROR() (errno == WSAEINTR)
#define DCC_BLOCK_ERROR() (errno == WSAEWOULDBLOCK || errno == WSAEINTR)
#define EADDRINUSE	WSAEADDRINUSE

typedef char DCC_PATH[MAX_PATH+1];

#define MAXHOSTNAMELEN   256

/* Win95 lacks snprintf() */
#define snprintf dcc_snprintf
extern int dcc_snprintf(char *, int, const char *, ...);
#define vsnprintf dcc_vsnprintf
extern int dcc_vsnprintf(char *, int, const char *, va_list);

extern char *optarg;
extern int optind, opterr, optopt;
extern int getopt(int, char * const [], const char *);

#define strcasecmp stricmp
#define strncasecmp strnicmp
extern int getpid(void);
#define usleep(usec) Sleep((usec)/1000)

#define LOG_ERR	    0
#define LOG_MAIL    0
#define LOG_NOTICE  0
#define LOG_PID	    0
extern void openlog(const char *, int, int);
extern void syslog(int, const char *, ...);

struct timezone {
    int     tz_minuteswest;		/* minutes west of Greenwich */
    int     tz_dsttime;			/* type of dst correction */
};
extern int gettimeofday(struct timeval *, struct timezone *);

/* FlushViewOfFile() on Win98 sometimes returns 0 with GetLastError()==0 */
#define MSYNC(addr,len,flags) (FlushViewOfFile(addr,0), 0)

#define R_OK	04
#define W_OK	02
#ifndef S_ISDIR
#define S_ISDIR(mode) (mode & _S_IFDIR)
#endif

extern u_char win32_lock(HANDLE, DWORD);
extern u_char win32_unlock(HANDLE);

extern void win32_unmap(HANDLE *, void *, const char *);
extern void *win32_map(DCC_EMSG, HANDLE *, const char *, int, int);
#endif /* !UNIX or DCC_WIN32 */


/* AIX is missing some prototypes or has them #ifdef'ed with strange switches */
#ifdef _AIX41
#include <sys/select.h>
typedef unsigned long long int uint64_t;
typedef unsigned int uint32_t;
typedef int int32_t;
typedef unsigned short uint16_t;

extern void openlog(const char *, int, int);
extern int snprintf(char *, int, const char *, ...);
extern int vsnprintf(char *, int, const char *, const char *, ...);
extern int seteuid(uid_t);
extern int flock(int, int);
#define	AF_LOCAL AF_UNIX
#endif /* _AIX41 */


/* 4.4BSD sockets */
#ifdef DCC_HAVE_SA_LEN
#define DCC_SU_LEN(s) ((s)->sa.sa_len)
#else
#define DCC_SU_LEN(s) (((s)->sa.sa_family == AF_INET)	\
		       ? sizeof((s)->ipv4) : sizeof((s)->ipv6))
#endif
#ifdef DCC_HAVE_SOCKLEN_T
#define DCC_SOCKLEN_T socklen_t
#else
#define DCC_SOCKLEN_T int
#endif
#if !defined(DCC_HAVE_AF_LOCAL) && !defined(AF_LOCAL)
#define AF_LOCAL AF_UNIX
#endif

/* these are needed even when IPV6 is available to handle old map file
 * formats in dcc_clnt.h */
struct dcc_in6_addr {
    u_int32_t dcc_s6_addr32[4];
};
struct dcc_sockaddr_in6 {
    u_char	sin6_len;
    u_char	sin6_family;
    u_int16_t	sin6_port;
    u_int32_t	sin6_flowinfo;
    struct dcc_in6_addr sin6_addr;
};
/* define in6_addr here after u_int32_t has been seen in sys/types.h */
#ifdef NO_IPV6
#undef in6_addr
#define in6_addr dcc_in6_addr		/* defend against lurking definitions */
#undef s6_addr32
#define s6_addr32 dcc_s6_addr32
#define sockaddr_in6 dcc_sockaddr_in6	/* defend against lurking definitions */
#endif /* NO_IPV6 */


#include "dcc_proto.h"


/* see if an address is in a CIDR block */
#define DCC_IN_BLOCK(a,b,m) ((((a).s6_addr32[3] & (m).s6_addr32[3])	\
			      == (b).s6_addr32[3])			\
			     && (((a).s6_addr32[2] & (m).s6_addr32[2])	\
				 == (b).s6_addr32[2])			\
			     && (((a).s6_addr32[1] & (m).s6_addr32[1])	\
				 == (b).s6_addr32[1])			\
			     && (((a).s6_addr32[0] & (m).s6_addr32[0])	\
				 == (b).s6_addr32[0]))


/* puzzle out something for s6_addr32 */
#if !defined(s6_addr32) && defined(CONF_S6_ADDR32)
#define s6_addr32 CONF_S6_ADDR32
#endif

#ifdef NO_AF_INET6
#define AF_INET6 24
#endif

#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif

#define MAXPORTNAMELEN	64

#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif

#define DCC_SU_SA_EQ(a,b) ((a)->sa.sa_family == (b)->sa.sa_family	\
			   && (((a)->sa.sa_family == AF_INET)		\
			       ? ((a)->ipv4.sin_addr.s_addr		\
				  == (b)->ipv4.sin_addr.s_addr)		\
			       : !memcmp(&(a)->ipv6.sin6_addr,		\
					 &(b)->ipv6.sin6_addr,		\
					 sizeof((a)->ipv6.sin6_addr))))

#define DCC_SU_PORT(su) ((su)->sa.sa_family == AF_INET			\
			 ? &(su)->ipv4.sin_port				\
			 : &(su)->ipv6.sin6_port)

#define DCC_IN6_ADDR_V4MAPPED(ap) ((ap)->s6_addr32[0] == 0		\
				   && (ap)->s6_addr32[1] == 0		\
				   && (ap)->s6_addr32[2] == ntohl(0x0000ffff))

#define DCC_IN6_ADDR_V4COMPAT(ap) ((ap)->s6_addr32[0] == 0		\
				   && (ap)->s6_addr32[1] == 0		\
				   && (ap)->s6_addr32[2] == 0		\
				   && (ap)->s6_addr32[3] == 0		\
				   && (ap)->s6_addr32[3] == ntohl(1))



/* printf patterns for 64-bit values */
#ifdef HAVE_64BIT_LONG
#define L_HPAT	    "%#lx"
#define L_H8PAT	    "%8lx"
#define L_DPAT	    "%ld"
#define L_D9PAT	    "%9ld"
#else
#define L_HPAT	    "%#llx"
#define L_H8PAT	    "%8llx"
#define L_DPAT	    "%lld"
#define L_D9PAT	    "%9lld"
#endif

/* printf pattern for size_t and off_t */
#ifdef HAVE_BIG_FILES
#define OFF_HPAT    L_DPAT
#define OFF_DPAT    L_DPAT
#else
#define OFF_HPAT    "%#lx"
#define OFF_DPAT    "%ld"
#endif

#define DIM(_a)	    ((int)(sizeof(_a) / sizeof((_a)[0])))
#define LAST(_a)    (&(_a)[DIM(_a)-1])
/* abbreviation to silence common compiler warnings */
#define ISZ(_s)	    ((int)sizeof(_s))

#ifdef HAVE_STRLCPY
#define STRLIMCPY(d,lim,s) strlcpy(d,s,lim)
#else
#define STRLIMCPY(d,lim,s) ((d)[(lim)-1] = '\0', strncpy(d,s,(lim)-1))
#endif
#define BUFCPY(d,s) STRLIMCPY(d,sizeof(d),s)

#define STRZ(_s)    ((int)sizeof(_s)-1)
#define CSTRCMP(b,_s) strncasecmp(b, _s, STRZ(_s))


#ifndef HAVE___PROGNAME
#define __progname dcc_progname
#endif

#undef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#undef min
#define min(a,b) ((a) < (b) ? (a) : (b))

/* Is it time or has the local clock been changed?
 *	Is the clock after the target date or earlier than the original date? */
#define DCC_IS_TIME(now,tgt,lim) ((now) >= (tgt) || (now)+(lim) < (tgt))


#define DCC_WHITESPACE " \t\n\r"

/* ctype() is now a slow mess that does not give constant results on all
 * systems */
#define DCC_IS_WHITE(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c)== '\n')
#define DCC_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define DCC_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
#define DCC_TO_LOWER(c) (DCC_IS_UPPER(c) ? ((c) + ('a'-'A')) : (c))
#define DCC_TO_UPPER(c) (DCC_IS_LOWER(c) ? ((c) - ('a'-'A')) : (c))

typedef union {
    struct sockaddr sa;
    struct sockaddr_in ipv4;
    struct sockaddr_in6 ipv6;
} DCC_SOCKU;

#ifdef HAVE_RSENDTO
extern int Rconnect(int, const struct sockaddr *, socklen_t);
extern ssize_t Rsend(int, const void *, size_t, int);
extern ssize_t Rsendto(int, const void *, size_t, int,
		       const struct sockaddr *, size_t);
extern ssize_t Rrecv(int, void *, size_t, int);
extern ssize_t Rrecvfrom(int, void *, size_t, int,
			 struct sockaddr *, socklen_t *);
extern struct hostent *Rgethostbyname(const char *);
#else
#define Rconnect    connect
#define Rsend	    send
#define Rsendto	    sendto
#define Rrecv	    recv
#define Rrecvfrom   recvfrom
#define Rgethostbyname gethostbyname
#endif

/* ensure that missing parts of the BIND resolver library turns it all
 * off, even on Windows systems.
 * Some RedHat systems have res_init() but not res_query() */
#if !defined(HAVE_RESOLV_H) || !defined(HAVE_ARPA_NAMESER_H)
#undef HAVE_RESOLV_H
#undef HAVE_ARPA_NAMESER_H
#undef HAVE__RES
#undef HAVE_RES_INIT
#endif
#if !defined(HAVE_RES_QUERY) || !defined(HAVE_DN_EXPAND)
#undef MX_DNSBL
#endif
#if !defined(HAVE__RES) || !defined(HAVE_RES_INIT) || !defined(HAVE_HSTRERROR)
#undef HAVE__RES
#undef HAVE_RES_INIT
#undef MX_DNSBL
#endif

/* use very old fashioned gethostbyname() if we are not doing any IPv6 */
#ifdef NO_IPV6
#undef HAVE_GETIPNODEBYNAME
#undef HAVE_GETADDRINFO
#endif

/* prefer old fashioned getipnodebyname() for IPv6 resolution */
#if !defined(HAVE_GETIPNODEBYNAME) || !defined(HAVE_FREEHOSTENT)
#undef HAVE_GETIPNODEBYNAME
#undef HAVE_GETIPNODEBYADDR
#undef HAVE_FREEHOSTENT
#endif
#ifdef HAVE_GETIPNODEBYNAME
#define USE_GETIPNODEBYNAME
#undef USE_GETADDRINFO
#endif

#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_FREEADDRINFO) || !defined(HAVE_GAI_STRERROR)
#undef HAVE_GETADDRINFO
#undef HAVE_GETNAMEINFO
#undef HAVE_GAI_STRERROR
#undef HAVE_FREEADDRINFO
#endif
/* Linux does not have getipnodebyname() */
#if defined(HAVE_GETADDRINFO) && !defined(HAVE_GETIPNODEBYNAME)
#define USE_GETADDRINFO
#endif

#ifdef USE_GETADDRINFO
#define DCC_HSTRERROR(e) gai_strerror(e)
#else
#ifdef HAVE_HSTRERROR
#define DCC_HSTRERROR(e) hstrerror(e)
#else
#define DCC_HSTRERROR dcc_hstrerror
#endif
#endif


#ifndef HAVE_POLL
#undef USE_POLL
#endif

/* Some systems including Linux with gcc 3.4.2 on AMD 64 processes
 *	do not allow two uses of a va_list but require va_copy()
 * Other systems do not have any notion of va_copy() */
#ifdef USE_VA_COPY
#define COPY_DCC_ARGS2() va_list DCC_ARGS2; va_copy(DCC_ARGS2, args)
#define END_DCC_ARGS2() va_end(DCC_ARGS2)
#else
#define COPY_DCC_ARGS2()
#define DCC_ARGS2 args
#define END_DCC_ARGS2()
#endif

extern int dcc_ex_code;			/* not thread safe */
extern void dcc_pemsg(int, DCC_EMSG, const char *, ...) PATTRIB(3,4);
extern void dcc_vpemsg(int, DCC_EMSG, const char *, va_list);

#define DCC_MAX_HDR_LINE    78		/* by RFC 2822 */
#define DCC_MAX_XHDR_LEN    240		/* largest possible X-DCC header */
typedef struct {
    u_int	start_len;		/* length of start up to ':' */
    u_int	used;			/* bytes of buffer used */
    int		col;			/* current column */
    char	buf[DCC_MAX_XHDR_LEN];
} DCC_HEADER_BUF;

#define DCC_MAP_NM_DEF	    "map"

extern void dcc_sign(const char *, int, void *, u_int);
extern u_char dcc_ck_signature(const char *, int, const void *, u_int);

extern DCC_PATH dcc_homedir;
extern DCC_PATH dcc_path_buf;
#define DCC_NM2PATH(nm) dcc_fnm2path(dcc_path_buf, nm)
extern const char *dcc_fnm2path(DCC_PATH, const char *);
extern u_char dcc_cdhome(DCC_EMSG, const char *);

u_char dcc_get_priv_home(const char *);
extern void dcc_rel_priv(void);
extern void dcc_init_priv(void);
extern u_char dcc_ck_private(DCC_EMSG, struct stat *, const char *, int);
extern int dcc_lock_open(DCC_EMSG, const char *, int, u_char, int, u_char *);
# define DCC_LOCK_OPEN_WAIT	0	/* wait to get lock */
# define DCC_LOCK_OPEN_NOWAIT	1
# define DCC_LOCK_OPEN_EXT	2	/* already locked */
extern u_char dcc_unlock_fd(DCC_EMSG, int, int, const char *, const char *);
extern u_char dcc_shlock_fd(DCC_EMSG, int, int, const char *, const char *);
extern u_char dcc_exlock_fd(DCC_EMSG, int, int, const char *, const char *);
#define DCC_LOCK_ALL_FILE   (-1)
extern void dcc_mmap_utime(const char *, u_char);

extern char dcc_have_logdir;
extern DCC_PATH dcc_logdir;
#define DCC_MKSTEMP_LEN 6		/* characters added by dcc_mkstemp() */
extern int dcc_mkstemp(DCC_EMSG, char *, int,
		       const char *, const char *, u_char, int, int);
#define	DCC_TMP_LOG_PAT "/tmp."
#define	DCC_FIN_LOG_PAT "/msg."
extern int dcc_logdir_ck(DCC_EMSG, const char *, int *);
extern u_char dcc_log_init(DCC_EMSG, const char *);
extern int dcc_log_open(DCC_EMSG, char *, int);
extern u_char dcc_log_keep(DCC_EMSG, char *, int);
#define DCC_LOG_DATE_PAT "VERSION: 3\nDATE: %s"
#define DCC_LOG_DATE_FMT "%x %X %Z"
#define DCC_LOG_MSG_SEP "\n### end of message body ########################\n"
#define DCC_LOG_TRN_MSG0 "### log truncated ######################"
#define DCC_LOG_TRN_MSG "\n"DCC_LOG_TRN_MSG0"\n"
#define DCC_LOG_TRN_MSG_CR "\r\n"DCC_LOG_TRN_MSG0"\r\n"



extern const struct tm *dcc_localtime(time_t, struct tm *);
#ifndef HAVE_LOCALTIME_R
extern void dcc_localtime_lock(void);
extern void dcc_localtime_unlock(void);
#endif

extern int dcc_get_secs(char *, char **, int, int, int);
#define DCC_MAX_SECS 0x7fffffff
extern u_int dcc_get_port(DCC_EMSG, const char *, u_int, const char *, int);
#define DCC_GET_PORT_INVALID    0x10000
extern u_char dcc_host_locked;
#define MAX_DCC_HOSTADDRS 20
extern DCC_SOCKU dcc_hostaddrs[MAX_DCC_HOSTADDRS];
extern DCC_SOCKU *dcc_hostaddrs_end;
extern void dcc_host_lock(void);
extern void dcc_host_unlock(void);
extern u_char dcc_get_host(const char *, u_char, int *);
extern u_char dcc_get_host_SOCKS(const char *, u_char, int *);
extern const char *dcc_hstrerror(int);
extern DCC_SOCKU *dcc_mk_su(DCC_SOCKU *, int, const void *, u_short);
extern u_char dcc_str2ip(DCC_SOCKU *, const char *);
extern void dcc_bits2mask(struct in6_addr *, int);
extern int dcc_str2cidr(DCC_EMSG, struct in6_addr *, struct in6_addr *,
			const char *, const char *, int);
extern u_char dcc_udp_bind(DCC_EMSG, SOCKET *, const DCC_SOCKU *, int *);
extern DCC_CLNT_ID dcc_get_id(DCC_EMSG, const char *, const char *, int);
extern const char *dcc_get_srvr_id(DCC_EMSG, DCC_SRVR_ID *,
				   const char *, const char *,
				   const char *, int);
extern const char *dcc_parse_word(DCC_EMSG, char *, int,
				  const char *, const char *,
				  const char *, int);
extern u_char dcc_ck_word_comma(char **, const char *);
extern const char *fnm_lineno(const char *, int);

extern void dcc_ipv4toipv6(struct in6_addr *, const struct in_addr);
extern u_char dcc_ipv6toipv4(struct in_addr *, const struct in6_addr *);

extern const char *dcc_su2str(const DCC_SOCKU *);
extern const char *dcc_su2str_opt(const DCC_SOCKU *, u_int16_t, char);
extern void dcc_su2name(char *, int, const DCC_SOCKU *);
#if !defined(HAVE_INET_NTOP) || defined(NO_IPV6)
#define DCC_INET_NTOP dcc_inet_ntop
extern const char *DCC_INET_NTOP(int, const void *, char *, size_t);
#else
#define DCC_INET_NTOP inet_ntop
#endif

extern u_char dcc_no_syslog;
extern int dcc_error_priority, dcc_trace_priority;
extern u_char dcc_parse_log_opt(const char *);
extern void dcc_syslog_init(u_char, const char *, const char *);
extern DCC_PATH dcc_progname;
extern void dcc_vfatal_msg(const char *, va_list);
extern void dcc_verror_msg(const char *, va_list);
extern void dcc_error_msg(const char *, ...) PATTRIB(1,2);
extern void dcc_vtrace_msg(const char *, va_list);
extern void dcc_trace_msg(const char *, ...) PATTRIB(1,2);
#ifndef HAVE_VSYSLOG
#define vsyslog dcc_vsyslog
extern void vsyslog(int, const char *, va_list);
#endif

extern void NRATTRIB dcc_logbad(int, const char *, ...) PATTRIB(2,3);

extern char *dcc_ck2str(char *, u_int, DCC_CK_TYPES, const DCC_SUM);
#define DCC_CK2STR_LEN (sizeof(DCC_SUM)*2+sizeof(DCC_SUM)/4+1)
extern const char *dcc_ck2str_err(DCC_CK_TYPES, const DCC_SUM);
extern char *dcc_cnt2str(char *, u_int, DCC_TGTS, u_char);
extern char *dcc_type2str(char *, u_int, DCC_CK_TYPES, const char *, u_char);
extern const char *dcc_type2str_err(DCC_CK_TYPES, const char *, u_char);
extern DCC_CK_TYPES dcc_str2type(const char *);
extern DCC_TGTS dcc_str2cnt(const char *);

extern const char *dcc_op2str(DCC_OPS, DCC_AOPS, u_int32_t);
extern const char *dcc_req_op2str(const DCC_ADMN_REQ *);
extern const char *dcc_hdr_op2str(const DCC_HDR *);


#endif /* DCC_DEFS_H */