File: main.h

package info (click to toggle)
nut 0.45.5-rel-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,984 kB
  • ctags: 2,146
  • sloc: ansic: 22,216; sh: 1,138; makefile: 405
file content (54 lines) | stat: -rw-r--r-- 1,703 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
#include "common.h"
#include "upscommon.h"
#include "upsconf.h"

/* public functions & variables from main.c */
extern const char *progname;
extern const char *device_name;
extern const char *device_path;
void help(void);
void usage(void);

/* functions & variables required in each driver */
/* extern const char *upsdrv_version; */
void upsdrv_initups(void);
void upsdrv_initinfo(void);
void upsdrv_updateinfo(void);
void upsdrv_shutdown(void);
void upsdrv_help(void);
void upsdrv_usage(void);
void upsdrv_banner(void);
void upsdrv_arg(int i, char *optarg);
extern const char *driver_arguments;

/* driver provides the maximum number of entities into the info[] array */
int upsdrv_infomax(void);

/* --- details for the variable/value sharing --- */

/* main calls this driver function - it needs to call addvar */
void upsdrv_makevartable(void);

/* retrieve the value of variable <var> if possible */
char *getval(const char *var);

/* see if <var> has been defined, even if no value has been given to it */
int testvar(const char *var);

/* extended variable table - used for -x defines/flags */
typedef struct {
	int	vartype;	/* VAR_* value, below			 */
	char	*var;		/* left side of =, or whole word if none */
	char	*val;		/* right side of = 			 */
	char	*desc;		/* 40 character description for -h text	 */
	int	found;		/* set once encountered, for testvar()	 */
	void	*next;
}	vartab_t;

/* flags to define types in the vartab */

#define VAR_FLAG	0x0001	/* argument is a flag (no value needed) */
#define VAR_VALUE	0x0002	/* argument requires a value setting	*/

/* callback from driver - create the table for future -x entries */
void addvar(int vartype, const char *name, const char *desc);