Imported Upstream version 2.5.2p1
[debian/amanda] / common-src / util.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1999 University of Maryland at College Park
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Authors: the Amanda Development Team.  Its members are listed in a
24  * file named AUTHORS, in the root directory of this distribution.
25  */
26 /*
27  * $Id: util.h,v 1.17 2006/07/26 15:17:36 martinea Exp $
28  */
29 #ifndef UTIL_H
30 #define UTIL_H
31
32 #include "amanda.h"
33 #include "sl.h"
34
35 #define BIGINT  INT_MAX
36
37 #define BSTRNCMP(a,b)  strncmp(a, b, strlen(b))
38
39 /* internal types and variables */
40
41
42 ssize_t fullread(int, void *, size_t);
43 ssize_t fullwrite(int, const void *, size_t);
44
45 int     connect_portrange(struct sockaddr_storage *, in_port_t, in_port_t, char *,
46                           struct sockaddr_storage *, int);
47 int     bind_portrange(int, struct sockaddr_storage *, in_port_t, in_port_t,
48                        char *);
49
50 char *  construct_datestamp(time_t *t);
51 char *  construct_timestamp(time_t *t);
52
53 /*@only@*//*@null@*/char *quote_string(const char *str);
54 /*@only@*//*@null@*/char *unquote_string(const char *str);
55 int     needs_quotes(const char * str);
56
57 char *  sanitize_string(const char *str);
58 char *  strquotedstr(void);
59 ssize_t hexdump(const char *buffer, size_t bytes);
60 void    dump_sockaddr(struct sockaddr_storage * sa);
61 char *  str_sockaddr(struct sockaddr_storage *sa);
62 /* Compare two sockaddr_storage objects, optionally comparing
63  * only the address (and thus ignoring port, flow info, etc.).
64  * @returns: -1, 0, or 1 for <, ==, >, respectively
65  */
66 int     cmp_sockaddr(struct sockaddr_storage *ss1,
67                      struct sockaddr_storage *ss2,
68              int addr_only);
69 int     copy_file(char *dst, char *src, char **errmsg);
70
71 /*
72  *   validate_email return 0 if the following characters are present
73  *   * ( ) < > [ ] , ; : ! $ \ / "
74  *   else returns 1
75  */
76 int validate_mailto(const char *mailto);
77
78 char *taperalgo2str(int taperalgo);
79
80 #endif  /* UTIL_H */