xref: /OK3568_Linux_fs/buildroot/package/mkpasswd/utils.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun #ifndef WHOIS_UTILS_H
2*4882a593Smuzhiyun #define WHOIS_UTILS_H
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun /* Convenience macros */
5*4882a593Smuzhiyun #define streq(a, b) (strcmp(a, b) == 0)
6*4882a593Smuzhiyun #define strcaseeq(a, b) (strcasecmp(a, b) == 0)
7*4882a593Smuzhiyun #define strneq(a, b, n) (strncmp(a, b, n) == 0)
8*4882a593Smuzhiyun #define strncaseeq(a, b, n) (strncasecmp(a, b, n) == 0)
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__)
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /* Portability macros */
13*4882a593Smuzhiyun #ifdef __GNUC__
14*4882a593Smuzhiyun # define NORETURN __attribute__((noreturn))
15*4882a593Smuzhiyun #else
16*4882a593Smuzhiyun # define NORETURN
17*4882a593Smuzhiyun #endif
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #ifndef AI_IDN
20*4882a593Smuzhiyun # define AI_IDN 0
21*4882a593Smuzhiyun #endif
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #ifndef AI_ADDRCONFIG
24*4882a593Smuzhiyun # define AI_ADDRCONFIG 0
25*4882a593Smuzhiyun #endif
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #ifdef HAVE_GETOPT_LONG
28*4882a593Smuzhiyun # define GETOPT_LONGISH(c, v, o, l, i) getopt_long(c, v, o, l, i)
29*4882a593Smuzhiyun #else
30*4882a593Smuzhiyun # define GETOPT_LONGISH(c, v, o, l, i) getopt(c, v, o)
31*4882a593Smuzhiyun #endif
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #ifdef ENABLE_NLS
34*4882a593Smuzhiyun # include <libintl.h>
35*4882a593Smuzhiyun # include <locale.h>
36*4882a593Smuzhiyun # define _(a) (gettext(a))
37*4882a593Smuzhiyun # ifdef gettext_noop
38*4882a593Smuzhiyun #  define N_(a) gettext_noop(a)
39*4882a593Smuzhiyun # else
40*4882a593Smuzhiyun #  define N_(a) (a)
41*4882a593Smuzhiyun # endif
42*4882a593Smuzhiyun #else
43*4882a593Smuzhiyun # define _(a) (a)
44*4882a593Smuzhiyun # define N_(a) (a)
45*4882a593Smuzhiyun # define ngettext(a, b, c) ((c==1) ? (a) : (b))
46*4882a593Smuzhiyun #endif
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun /* Prototypes */
50*4882a593Smuzhiyun void *do_nofail(void *ptr, const char *file, const int line);
51*4882a593Smuzhiyun char **merge_args(char *args, char *argv[], int *argc);
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun void err_quit(const char *fmt, ...) NORETURN;
54*4882a593Smuzhiyun void err_sys(const char *fmt, ...) NORETURN;
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun #endif
57