X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common.h;h=fb70b7562dc04831330ff74dd4c47f721d0e6a6d;hb=8a872b1a9ec12dd44292603137c41f1b29b9f756;hp=75825eb2dc5f3df27a24b1a9c709b22de5c6e7d3;hpb=2472ae9bd2a2a22a278ffe586fd381e70c881e8d;p=apps%2Fpfixtools.git diff --git a/common.h b/common.h index 75825eb..fb70b75 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,23 +33,29 @@ * 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 +#include "mem.h" + #define UNIXERR(fun) \ syslog(LOG_ERR, "%s:%d:%s: %s: %m", \ __FILE__, __LINE__, __func__, fun) @@ -60,16 +66,24 @@ typedef void (*exitcall_t)(void); #define __init __attribute__((__used__,__section__(".mad.init"))) #define __exit __attribute__((__used__,__section__(".mad.exit"))) -#define module_init(fn) static initcall_t __init_##fn __init = fn; -#define module_exit(fn) static exitcall_t __exit_##fn __exit = fn; +#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 cleanexit; extern sig_atomic_t sigint; extern sig_atomic_t sighup; void common_sighandler(int sig); -void common_initialize(void); -void common_shutdown(void); + +int tcp_bind(const struct sockaddr *addr, socklen_t len); +int tcp_listen(const struct sockaddr *addr, socklen_t len); +int tcp_listen_nonblock(const struct sockaddr *addr, socklen_t len); +int accept_nonblock(int fd); +int xwrite(int fd, const char *s, size_t l); + +int daemon_detach(void); +int drop_privileges(const char *user, const char *group); + +int pidfile_open(const char *name); +int pidfile_refresh(void); #endif