diff options
Diffstat (limited to 'lib/libpies.h')
-rw-r--r-- | lib/libpies.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/libpies.h b/lib/libpies.h new file mode 100644 index 0000000..4733c63 --- /dev/null +++ b/lib/libpies.h @@ -0,0 +1,70 @@ +/* This file is part of Pies. + Copyright (C) 2009 Sergey Poznyakoff + + This program 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. + + This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <unistd.h> +#include <stdlib.h> +#include <gettext.h> +#include <mailutils/types.h> +#include <mailutils/cfg.h> + + +#define _(String) gettext(String) +#define N_(String) String + + +#if defined HAVE_SYSCONF && defined _SC_OPEN_MAX +# define getmaxfd() sysconf(_SC_OPEN_MAX) +#elif defined (HAVE_GETDTABLESIZE) +# define getmaxfd() getdtablesize() +#else +# define getmaxfd() 256 +#endif + + + +void *xmalloc (size_t size); +void *xzalloc (size_t size); +void *xcalloc (size_t count, size_t size); +char *xstrdup (const char *str); + + +struct mf_privs +{ + char *user; + int allgroups; + mu_list_t groups; +}; + +int switch_to_privs (uid_t uid, gid_t gid, mu_list_t retain_groups); +int get_user_groups (mu_list_t *pgrouplist, const char *user); + +void mf_priv_setup (struct mf_privs *); +void mf_epriv_setup (struct mf_privs *); + + +char **config_array_to_argv (mu_config_value_t *val, mu_debug_t debug); +char *config_array_to_string (mu_config_value_t *val, mu_debug_t debug); + +int config_cb_timeout (struct timeval *pt, mu_debug_t debug, + mu_config_value_t *val); + + +void mf_proctitle_init (int argc, char *argv[], char *env[]); +void mf_proctitle_format (const char *fmt, ...); + + +size_t longtostr (long i, char *buf, size_t size); +size_t ulongtostr (unsigned long i, char *buf, size_t size); |