ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSAdmin/common.h
Revision: 584
Committed: 2005-11-22T18:14:57-08:00 (19 years, 7 months ago) by douglas
Content type: text/x-c
File size: 1683 byte(s)
Log Message:
Solaris worky!

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 #if !defined(__FreeBSD__) && !defined(__sun__)
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>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/param.h>
25 #include <sys/stat.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__)
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_