Wed, 23 Apr 2014 21:17:44 +0200
Config now reads sensors configuration
7 | 1 | #ifndef _MBSELIB_H |
2 | #define _MBSELIB_H | |
3 | ||
4 | #include "../config.h" | |
5 | ||
6 | #include <stdlib.h> | |
7 | #include <stdio.h> | |
8 | #include <string.h> | |
9 | #include <ctype.h> | |
10 | #include <sys/types.h> | |
8
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
11 | #include <syslog.h> |
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
12 | #include <unistd.h> |
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
13 | #include <errno.h> |
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
14 | #include <signal.h> |
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
15 | #include <getopt.h> |
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
16 | |
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
17 | #include <mosquitto.h> |
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
18 | |
7 | 19 | |
20 | #define TRUE 1 | |
21 | #define FALSE 0 | |
22 | ||
8
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
23 | #define MBSE_SS(x) (x)?(x):"(null)" |
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
24 | |
7 | 25 | /* rdconfig.c */ |
26 | typedef struct _key_list { | |
27 | char *key; | |
28 | int (*prc)(char **); | |
29 | char **dest; | |
30 | } key_list; | |
31 | ||
9
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
32 | typedef struct _w1_therm { |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
33 | struct _w1_therm *next; |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
34 | char *master; /* Master for this device */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
35 | int bus; /* Reserved for ds2482-800 */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
36 | char *name; /* Name of this device */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
37 | char *alias; /* Friendly name */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
38 | int present; /* 1=present, 0=absent */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
39 | int lastval; /* Last valid value */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
40 | } w1_therm; |
7 | 41 | |
42 | typedef struct _sys_config { | |
9
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
43 | char *name; /* Configuration name */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
44 | char *mosq_host; /* mosquitto server hostname */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
45 | int mosq_port; /* mosquitto server port */ |
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
46 | w1_therm *w1therms; /* 1-wire temp sensors */ |
7 | 47 | } sys_config; |
48 | ||
49 | ||
9
91218bc77abc
Config now reads sensors configuration
Michiel Broek <mbroek@mbse.eu>
parents:
8
diff
changeset
|
50 | |
7 | 51 | void killconfig(void); |
8
e584bc0177df
Server communication seems ok, can handle server shutdowns too.
Michiel Broek <mbroek@mbse.eu>
parents:
7
diff
changeset
|
52 | int rdconfig(void); |
7 | 53 | |
54 | ||
55 | /* xutil.c */ | |
56 | char *xmalloc(size_t); | |
57 | char *xstrcpy(char *); | |
58 | char *xstrcat(char *, char *); | |
59 | ||
60 | #endif | |
61 |