7 |
|
#ifndef _common_h_ |
8 |
|
#define _common_h_ |
9 |
|
|
10 |
+ |
#if !defined(__FreeBSD__) && !defined(__sun__) && !defined(__APPLE__) |
11 |
+ |
#define _BSD_SOURCE |
12 |
+ |
#define _POSIX_SOURCE |
13 |
+ |
#define _GNU_SOURCE |
14 |
+ |
#elif defined(__sun__) |
15 |
+ |
#define __EXTENSIONS__ |
16 |
+ |
#endif |
17 |
+ |
|
18 |
|
#include <pwd.h> |
19 |
|
#include <regex.h> |
20 |
|
#include <setjmp.h> |
26 |
|
#include <sys/wait.h> |
27 |
|
#include <unistd.h> |
28 |
|
|
29 |
+ |
#ifndef _PASSWORD_LEN |
30 |
+ |
#define _PASSWORD_LEN BUFSIZ |
31 |
+ |
#endif |
32 |
+ |
|
33 |
+ |
#ifndef MAXLOGNAME |
34 |
+ |
#define MAXLOGNAME 17 |
35 |
+ |
#endif |
36 |
+ |
|
37 |
+ |
typedef struct |
38 |
+ |
{ |
39 |
+ |
const char *name; |
40 |
+ |
char *freebsd, *linux, *darwin, *solaris; |
41 |
+ |
} |
42 |
+ |
Shells; |
43 |
+ |
|
44 |
+ |
typedef enum { sh, csh, tcsh, bash, ksh, zsh, _3sh, custom } Shell; |
45 |
+ |
|
46 |
+ |
extern Shells shells[]; |
47 |
+ |
|
48 |
|
int check(int value, jmp_buf environment); |
49 |
|
int regcheck(int value, const regex_t *regex, jmp_buf environment); |
50 |
|
char *fcheck(char *value, FILE *stream, jmp_buf environment); |
51 |
|
void authenticate(const char *program, jmp_buf environment); |
52 |
|
void getpassword(char password[_PASSWORD_LEN], jmp_buf environment); |
53 |
|
void putpassword(char password[_PASSWORD_LEN], char *name, jmp_buf environment); |
54 |
+ |
void get(const char *prompt, regex_t *regex, char **string, jmp_buf environment); |
55 |
+ |
void setshells(Shells *shells, jmp_buf environment); |
56 |
+ |
|
57 |
+ |
#if !defined(__FreeBSD__) && !defined(__sun__) && !defined(__APPLE__) |
58 |
+ |
size_t strlcpy(char *dst, const char *src, size_t size); |
59 |
+ |
size_t strlcat(char *dst, const char *src, size_t size); |
60 |
+ |
char *fgetln(FILE * restrict stream, size_t * restrict len); |
61 |
+ |
#elif defined(__sun__) |
62 |
+ |
char *fgetln(FILE * restrict stream, size_t * restrict len); |
63 |
+ |
int setenv(const char *name, const char *value, int overwrite); |
64 |
+ |
#endif |
65 |
|
|
66 |
|
#endif//_common_h_ |