ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSAdmin/common.h
Revision: 807
Committed: 2006-06-29T07:39:29-07:00 (18 years, 11 months ago) by douglas
Content type: text/x-c
File size: 1846 byte(s)
Log Message:
Yarg!

File Contents

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