File: defs.h

package info (click to toggle)
op 1.32-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 716 kB
  • ctags: 360
  • sloc: ansic: 2,272; sh: 800; lex: 447; makefile: 68
file content (119 lines) | stat: -rw-r--r-- 3,041 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* +-------------------------------------------------------------------+ */
/* | Copyright 1991, David Koblas.                                     | */
/* |   Permission to use, copy, modify, and distribute this software   | */
/* |   and its documentation for any purpose and without fee is hereby | */
/* |   granted, provided that the above copyright notice appear in all | */
/* |   copies and that both that copyright notice and this permission  | */
/* |   notice appear in supporting documentation.  This software is    | */
/* |   provided "as is" without express or implied warranty.           | */
/* +-------------------------------------------------------------------+ */

#include <unistd.h>
#include <limits.h>
#include "config.h"

#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif

#if HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
# if HAVE_SYS_NDIR_H
#  include <sys/ndir.h>
# endif
# if HAVE_SYS_DIR_H
#  include <sys/dir.h>
# endif
# if HAVE_NDIR_H
#  include <ndir.h>
# endif
#endif

#include <sys/types.h>
#if HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif

#if STDC_HEADERS
# include <string.h>
#else
# if !HAVE_STRCHR
#  define strchr index
#  define strrchr rindex
# endif
char *strchr (), *strrchr ();
# if !HAVE_MEMCPY
#  define memcpy(d, s, n) bcopy ((s), (d), (n))
#  define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif

typedef struct cmd_s {
	char		*name;
	int		nargs, nopts;
	int		margs, mopts;
	char		**args, **opts;
	struct cmd_s	*next;
} cmd_t;

typedef struct var_s {
	char *name, *value;
	struct var_s *next;
} var_t;

typedef struct array_s {
	void **data;
	int size, capacity;
} array_t;

/* functions to manage a dynamically extensible array of pointers */
#define ARRAY_CHUNK	32
array_t *array_alloc();
void array_free(array_t *array);
array_t *array_free_contents(array_t *array);
void *array_push(array_t *array, void *object);
void *array_pop(array_t *array);
int array_extend(array_t *array, int capacity);

extern cmd_t	*First, *Build(), *BuildSingle();
extern var_t	*Variables;
extern unsigned	minimum_logging_level;

void fatal(int logit, const char *format, ...);
int logger(unsigned flags, const char *format, ...);
void strnprintf(char *out, int len, const char *format, ...);
void vstrnprintf(char *out, int len, const char *format, va_list ap);
char *strtolower(char *in);

int ReadFile(char *file);
int ReadDir(char *dir);
int CountArgs(cmd_t *cmd);
int atov(char *str, int type);

#define MAXSTRLEN	2048
#define OP_ACCESS	SYSCONFDIR "/op.conf"
#define OP_ACCESS_DIR	SYSCONFDIR "/op.d"

#define VAR_EXPAND_LEN	8192
#define	VAR_NAME_LEN	64	

#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX	255
#endif