X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common.h;h=e70c9a7b8fc02f4ed3313faaf21b58f9d3f1211d;hb=e79fdf45f5b9b14a452c9fe067e827d6a7d5e87d;hp=6a885d9d01ea5d947341372326a0bcf114c4d991;hpb=b8b6ac5a6d545a000077eed217c221c7eeda2a84;p=apps%2Fpfixtools.git diff --git a/common.h b/common.h index 6a885d9..e70c9a7 100644 --- a/common.h +++ b/common.h @@ -1,5 +1,5 @@ /******************************************************************************/ -/* postlicyd: a postfix policy daemon with a lot of features */ +/* pfixtools: a collection of postfix related tools */ /* ~~~~~~~~~ */ /* ________________________________________________________________________ */ /* */ @@ -33,24 +33,52 @@ * Copyright © 2007 Pierre Habouzit */ -#ifndef POSTLICYD_H -#define POSTLICYD_H +#ifndef PFIXTOOLS_COMMON_H +#define PFIXTOOLS_COMMON_H #include +#include #include -#include +#include +#include #include #include -#include #include +#include #include #include #include +#include #include +#include #include +#include "mem.h" + #define UNIXERR(fun) \ syslog(LOG_ERR, "%s:%d:%s: %s: %m", \ __FILE__, __LINE__, __func__, fun) +typedef int (*initcall_t)(void); +typedef void (*exitcall_t)(void); + +#define __init __attribute__((__used__,__section__(".mad.init"))) +#define __exit __attribute__((__used__,__section__(".mad.exit"))) + +#define module_init(fn) static __init initcall_t __init_##fn = fn; +#define module_exit(fn) static __exit exitcall_t __exit_##fn = fn; + +/* common.c */ +extern sig_atomic_t sigint; +extern sig_atomic_t sighup; + +void common_sighandler(int sig); + +/* daemon.c */ +int tcp_listen_nonblock(const struct sockaddr *addr, socklen_t len); +int accept_nonblock(int fd); + +int daemon_detach(void); +int drop_privileges(const char *user, const char *group); + #endif