drivers/usbhid-ups.c: upsdrv_initups(): update comments about logical progression...
[networkupstools.git] / server / upsd.h
bloba6b96adce842fca303d88ae5bb072beba1ab5c69
1 /* upsd.h - support structures and other minor details
3 Copyright (C) 1999 Russell Kroll <rkroll@exploits.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * Much of the content from here was also useful to the
22 * drivers, so has been moved into include/shared-tables.h
23 * instead of being within the daemon specific include file
27 #ifndef UPSD_H_SEEN
28 #define UPSD_H_SEEN 1
30 #include "attribute.h"
32 #include "common.h"
34 #ifndef WIN32
35 #include <sys/socket.h>
36 #include <netinet/in.h>
37 #include <arpa/inet.h>
38 #endif
40 #include "timehead.h"
42 #include <sys/file.h>
43 #ifdef HAVE_POLL_H
44 # include <poll.h> /* nfds_t */
45 #else
46 typedef unsigned long int nfds_t;
47 #endif
49 #include "parseconf.h"
50 #include "nut_ctype.h"
51 #include "upstype.h"
53 #define NUT_NET_ANSWER_MAX SMALLBUF
55 #ifdef __cplusplus
56 /* *INDENT-OFF* */
57 extern "C" {
58 /* *INDENT-ON* */
59 #endif
61 /* prototypes from upsd.c */
63 upstype_t *get_ups_ptr(const char *upsname);
64 int ups_available(const upstype_t *ups, nut_ctype_t *client);
66 void listen_add(const char *addr, const char *port);
68 void kick_login_clients(const char *upsname);
69 int sendback(nut_ctype_t *client, const char *fmt, ...)
70 __attribute__ ((__format__ (__printf__, 2, 3)));
71 int send_err(nut_ctype_t *client, const char *errtype);
73 void server_load(void);
74 void server_free(void);
76 void check_perms(const char *fn);
78 /* return values for instcmd / setvar status tracking,
79 * mapped on drivers/upshandler.h, apart from STAT_PENDING (initial state) */
80 enum {
81 STAT_PENDING = -1, /* not yet completed */
82 STAT_HANDLED = 0, /* completed successfully (NUT_SUCCESS or "OK") */
83 STAT_UNKNOWN, /* unspecified error (NUT_ERR_UNKNOWN) */
84 STAT_INVALID, /* invalid command/setvar (NUT_ERR_INVALID_ARGUMENT) */
85 STAT_FAILED /* command/setvar failed (NUT_ERR_INSTCMD_FAILED / NUT_ERR_SET_FAILED) */
88 /* Commands and settings status tracking functions */
89 int tracking_add(const char *id);
90 int tracking_set(const char *id, const char *value);
91 int tracking_del(const char *id);
92 void tracking_free(void);
93 void tracking_cleanup(void);
94 char *tracking_get(const char *id);
95 int tracking_enable(void);
96 int tracking_disable(void);
97 int tracking_is_enabled(void);
99 /* declarations from upsd.c */
100 extern int maxage, tracking_delay, allow_no_device, allow_not_all_listeners;
101 extern nfds_t maxconn;
102 extern char *statepath, *datapath;
103 extern upstype_t *firstups;
104 extern nut_ctype_t *firstclient;
106 /* map commands onto signals */
107 #ifndef WIN32
108 #define SIGCMD_STOP SIGTERM
109 #define SIGCMD_RELOAD SIGHUP
110 #else
111 #define SIGCMD_STOP COMMAND_STOP
112 #define SIGCMD_RELOAD COMMAND_RELOAD
113 #endif
115 /* awkward way to make a string out of a numeric constant */
117 #define string_const_aux(x) #x
118 #define string_const(x) string_const_aux(x)
120 #ifdef SHUT_RDWR
121 #define shutdown_how SHUT_RDWR
122 #else
123 #define shutdown_how 2
124 #endif
126 /* UUID v4 generation function
127 * Note: 'dest' must be at least `UUID4_LEN` long */
128 int nut_uuid_v4(char *uuid_str);
130 #ifdef __cplusplus
131 /* *INDENT-OFF* */
133 /* *INDENT-ON* */
134 #endif
136 #endif /* UPSD_H_SEEN */