aboutsummaryrefslogtreecommitdiff
path: root/src/defs.h
blob: 1f7c7f3ca64bf1a089bac76c7478ca25eae4edd5 (plain)
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
/* This file is part of Ping903
   Copyright (C) 2020 Sergey Poznyakoff
  
   Ping903 is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.
  
   Ping903 is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
  
   You should have received a copy of the GNU General Public License
   along with Ping903.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdarg.h>

#ifndef DEFAULT_ADDRESS
# define DEFAULT_ADDRESS "127.0.0.1"
#endif
#ifndef DEFAULT_SERVICE
# define DEFAULT_SERVICE "8080"
#endif
#ifndef SYSCONFDIR
# define SYSCONFDIR "/etc"
#endif
#ifndef LOCALSTATEDIR
# define LOCALSTATEDIR "/var/lib"
#endif
#ifndef PACKAGESTATEDIR
# define PACKAGESTATEDIR LOCALSTATEDIR "/" PACKAGE
#endif
#define DEFAULT_CONFIG_FILE SYSCONFDIR "/" PACKAGE ".conf"
#define LOCAL_IP_LIST_FILE PACKAGESTATEDIR "/ip-list"
#define CRED_FILE_NAME ".ping903.cred"

#define COPYLEFT "\
Copyright (C) 2020 Sergey Poznyakoff\n\
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
This is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n\
\n"

void emalloc_die(void);
void *emalloc(size_t s);
void *ecalloc(size_t n, size_t s);
char *estrdup(char const *s);
void *e2nrealloc(void *p, size_t *pn, size_t s);

extern char *progname;

#define ATTR_PRINTFLIKE(fmt,narg)				\
	__attribute__ ((__format__ (__printf__, fmt, narg)))

void vlogger(int prio, char const *fmt, va_list ap);
void fatal(char const *fmt, ...) ATTR_PRINTFLIKE(1,2);
void error(char const *fmt, ...) ATTR_PRINTFLIKE(1,2);
void info(char const *fmt, ...) ATTR_PRINTFLIKE(1,2);
void syslog_enable(void);
void set_progname(char const *arg);
int set_log_facility(char const *arg);

enum {
	STRSPLIT_OK,
	STRSPLIT_NOMEM,
	STRSPLIT_ERR
};

int strsplit(char const *str, int max, int *ret_ac, char ***ret_av,
	     char **endp);
void argcv_free(int ac, char **av);

Return to:

Send suggestions and report system problems to the System administrator.