ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSAdmin/common.h
Revision: 583
Committed: 2005-11-21T12:56:05-08:00 (19 years, 7 months ago) by douglas
Content type: text/x-c
File size: 1435 byte(s)
Log Message:
Refactorx0r!

File Contents

# Content
1 // Douglas Thrift
2 //
3 // CCS Computer Science
4 //
5 // Common Functions
6
7 #ifndef _common_h_
8 #define _common_h_
9
10 #ifndef __FreeBSD__
11 #define _BSD_SOURCE
12 #define _POSIX_SOURCE
13 #define _GNU_SOURCE
14 #endif
15
16 #include <pwd.h>
17 #include <regex.h>
18 #include <setjmp.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <sys/param.h>
23 #include <sys/stat.h>
24 #include <sys/wait.h>
25 #include <unistd.h>
26
27 #ifndef _PASSWORD_LEN
28 #define _PASSWORD_LEN BUFSIZ
29 #endif
30
31 #ifndef MAXLOGNAME
32 #define MAXLOGNAME 17
33 #endif
34
35 typedef struct
36 {
37 const char *name;
38 char *freebsd, *linux, *darwin, *solaris;
39 }
40 Shells;
41
42 typedef enum { sh, csh, tcsh, bash, ksh, zsh, _3sh, custom } Shell;
43
44 extern Shells shells[];
45
46 int check(int value, jmp_buf environment);
47 int regcheck(int value, const regex_t *regex, jmp_buf environment);
48 char *fcheck(char *value, FILE *stream, jmp_buf environment);
49 void authenticate(const char *program, jmp_buf environment);
50 void getpassword(char password[_PASSWORD_LEN], jmp_buf environment);
51 void putpassword(char password[_PASSWORD_LEN], char *name, jmp_buf environment);
52 void get(const char *prompt, regex_t *regex, char **string, jmp_buf environment);
53 void setshells(Shells *shells, jmp_buf environment);
54
55 #ifndef __FreeBSD__
56 size_t strlcpy(char *dst, const char *src, size_t size);
57 size_t strlcat(char *dst, const char *src, size_t size);
58 char *fgetln(FILE * restrict stream, size_t * restrict len);
59 #endif
60
61 #endif//_common_h_