ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccs/admin/common.h
Revision: 438
Committed: 2009-06-07T02:39:17-07:00 (16 years, 1 month ago) by douglas
Content type: text/x-c
File size: 1987 byte(s)
Log Message:
Some cleanup and MySQL crap.

File Contents

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

Properties

Name Value
svn:keywords Id