1 /*
2     OW -- One-Wire filesystem
3     version 0.4 7/2/2003
4 
5      Written 2003 Paul H Alfille
6         Fuse code based on "fusexmp" {GPL} by Miklos Szeredi, mszeredi@inf.bme.hu
7         Serial code based on "xt" {GPL} by David Querbach, www.realtime.bc.ca
8         in turn based on "miniterm" by Sven Goldt, goldt@math.tu.berlin.de
9     GPL license
10     This program is free software; you can redistribute it and/or
11     modify it under the terms of the GNU General Public License
12     as published by the Free Software Foundation; either version 2
13     of the License, or (at your option) any later version.
14 
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     GNU General Public License for more details.
19 
20     Other portions based on Dallas Semiconductor Public Domain Kit,
21     ---------------------------------------------------------------------------
22     Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
23         Permission is hereby granted, free of charge, to any person obtaining a
24         copy of this software and associated documentation files (the "Software"),
25         to deal in the Software without restriction, including without limitation
26         the rights to use, copy, modify, merge, publish, distribute, sublicense,
27         and/or sell copies of the Software, and to permit persons to whom the
28         Software is furnished to do so, subject to the following conditions:
29         The above copyright notice and this permission notice shall be included
30         in all copies or substantial portions of the Software.
31     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
32     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33     MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
34     IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
35     OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
36     ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
37     OTHER DEALINGS IN THE SOFTWARE.
38         Except as contained in this notice, the name of Dallas Semiconductor
39         shall not be used except as stated in the Dallas Semiconductor
40         Branding Policy.
41     ---------------------------------------------------------------------------
42     Implementation:
43     25-05-2003 iButtonLink device
44 */
45 
46 /* Can stand alone -- separated out of ow.h for clarity */
47 
48 #ifndef OW_GLOBAL_H				/* tedious wrapper */
49 #define OW_GLOBAL_H
50 
51 #include "ow_temperature.h"
52 #include "ow_pressure.h"
53 
54 // some improbably sub-absolute-zero number
55 #define GLOBAL_UNTOUCHED_TEMP_LIMIT	(-999.)
56 
57 #define DEFAULT_USB_SCAN_INTERVAL 10 /* seconds */
58 #define DEFAULT_ENET_SCAN_INTERVAL 60 /* seconds */
59 #define DEFAULT_MASTERHUB_SCAN_INTERVAL 60 /* seconds */
60 
61 enum zero_support { zero_unknown, zero_none, zero_bonjour, zero_avahi, } ;
62 
63 enum enum_program_type {
64 	program_type_filesystem, program_type_server, program_type_httpd, program_type_ftpd, program_type_external,
65 	program_type_tcl, program_type_swig, program_type_clibrary,
66 	program_option_sensor, program_option_property,
67 };
68 
69 /* Daemon status
70  * can be running as foreground or background
71  * this is for a state machine implementation
72  * sd is systemd which is foreground
73  * sd cannot be changed
74  * want_bg is default state
75  * goes to bg if proper program type and can daemonize
76  * */
77 enum enum_daemon_status {
78 	e_daemon_want_bg, e_daemon_bg, e_daemon_sd, e_daemon_sd_done, e_daemon_fg, e_daemon_unknown,
79 } ;
80 
81 /* Globals information (for local control) */
82 struct global {
83 	int announce_off;			// use zeroconf?
84 	ASCII *announce_name;
85 	enum temp_type temp_scale;
86 	enum pressure_type pressure_scale ;
87 	enum deviceformat format ;
88 	enum enum_program_type program_type;
89 	enum enum_daemon_status daemon_status ;
90 	int allow_external ; // allow this program to call external programs for read/write -- dangerous
91 	int allow_other ;
92 	struct antiloop Token;
93 	int uncached ; // all requests are from /uncached directory
94 	int unaliased ; // all requests are from /unaliased (no alias substitution on results)
95 	int error_level;
96 	int error_level_restore;
97 	int error_print;
98 	int fatal_debug;
99 	ASCII *fatal_debug_file;
100 	int readonly;
101 	int max_clients;			// for ftp
102 	size_t cache_size;			// max cache size (or 0 for no max) ;
103 	int one_device;				// Single device, use faster ROM comands
104 	/* Special parameter to trigger William Robison <ibutton@n952.dyndns.ws> timings */
105 	int altUSB;
106 	int usb_flextime;
107 	int serial_flextime;
108 	int serial_reverse; // reverse polarity ?
109 	int serial_hardflow ; // hardware flow control
110 	/* timeouts -- order must match ow_opt.c values for correct indexing */
111 	int timeout_volatile;
112 	int timeout_stable;
113 	int timeout_directory;
114 	int timeout_presence;
115 	int timeout_serial; // serial read and write use the same timeout currently
116 	int timeout_usb;
117 	int timeout_network;
118 	int timeout_server;
119 	int timeout_ftp;
120 	int timeout_ha7;
121 	int timeout_w1;
122 	int timeout_persistent_low;
123 	int timeout_persistent_high;
124 	int clients_persistent_low;
125 	int clients_persistent_high;
126 	int pingcrazy;
127 	int no_dirall;
128 	int no_get;
129 	int no_persistence;
130 	int eightbit_serial;
131 	int trim;
132 	enum zero_support zero ;
133 	int i2c_APU ;
134 	int i2c_PPM ;
135 	int baud ;
136 	int traffic ; // show bus traffic
137 	int locks ; // show mutexes
138 	_FLOAT templow ;
139 	_FLOAT temphigh ;
140 #if OW_USB
141 	libusb_context * luc ;
142 #endif /* OW_USB */
143 	int argc;
144 	char ** argv ;
145 	enum e_inet_type inet_type ;
146 	enum { exit_early, exit_normal, exit_exec, } exitmode ; // is this an execpe on config file change?
147 	int restart_seconds ; // time after close before execve
148 };
149 extern struct global Globals;
150 
151 // generic value for ignorable function returns
152 extern int ignore_result ;
153 
154 void SetLocalControlFlags( void ) ;
155 
156 
157 #endif							/* OW_GLOBAL_H */
158