1#ifndef _UTIL_H_
2#define _UTIL_H_
3
4#include "netcompat.h"
5#include <sys/cdefs.h>
6#include <sys/types.h>
7#include <inttypes.h>
8#include <stdio.h>
9#include <stdarg.h>
10#include <sys/stat.h>
11#include <grp.h>
12#include <pwd.h>
13
14#ifndef FPARSELN_UNESCESC
15#define FPARSELN_UNESCESC 0x01
16#define FPARSELN_UNESCCONT 0x02
17#define FPARSELN_UNESCCOMM 0x04
18#define FPARSELN_UNESCREST 0x08
19#define FPARSELN_UNESCALL 0x0f
20#endif
21
22__BEGIN_DECLS
23
24char *flags_to_string(unsigned long, const char *);
25int string_to_flags(char **, unsigned long *, unsigned long *);
26
27void (*esetfunc(void (*)(int, const char *, ...)))(int, const char *, ...);
28size_t estrlcpy(char *, const char *, size_t);
29size_t estrlcat(char *, const char *, size_t);
30char *estrdup(const char *);
31char *estrndup(const char *, size_t);
32intmax_t estrtoi(const char *, int, intmax_t, intmax_t);
33uintmax_t estrtou(const char *, int, uintmax_t, uintmax_t);
34void *ecalloc(size_t, size_t);
35void *emalloc(size_t);
36void *erealloc(void *, size_t);
37void ereallocarr(void *, size_t, size_t);
38FILE *efopen(const char *, const char *);
39int easprintf(char ** __restrict, const char * __restrict, ...)
40 __printflike(2, 3);
41int evasprintf(char ** __restrict, const char * __restrict, va_list)
42 __printflike(2, 0);
43
44char *fgetln(FILE *, size_t *);
45char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
46mode_t getmode(const void *, mode_t);
47void *setmode(const char *);
48long long strsuftoll(const char *, const char *, long long, long long);
49uintmax_t strtou(const char * __restrict, char ** __restrict, int,
50 uintmax_t, uintmax_t, int *);
51
52const char *getprogname(void);
53void setprogname(const char *);
54
55const char *user_from_uid(uid_t, int);
56const char *group_from_gid(gid_t, int);
57int uid_from_user(const char *, uid_t *);
58int gid_from_group(const char *, gid_t *);
59int pwcache_userdb(int (*)(int), void (*)(void),
60 struct passwd *(*)(const char *), struct passwd *(*)(uid_t));
61int pwcache_groupdb(int (*)(int), void (*)(void),
62 struct group *(*)(const char *), struct group *(*)(gid_t));
63int setpassent(int);
64int setgroupent(int);
65
66__END_DECLS
67
68#endif