#define TIMEOUT_ONERROR 3333 /* milliseconds */
static const char program_name[]= "xacpi-simple";
-static int debug, alarmlevel;
+static int debug=-1, alarmlevel;
/*---------- general utility stuff and declarations ----------*/
return val.addr;
}
+static int getresource_bool(const char *want, int def, int *cache) {
+ /* *cache should be initialised to -1 and will be set to !!value */
+
+ if (*cache >= 0) return *cache;
+ const char *str= getresource(want);
+ int result = def;
+ if (str && str[0]) {
+ char *ep;
+ long l= strtol(str,&ep,0);
+ if (!*ep) {
+ result = l > 0;
+ } else {
+ switch (str[0]) {
+ case 't': case 'T': case 'y': case 'Y': result= 1; break;
+ case 'f': case 'F': case 'n': case 'N': result= 0; break;
+ case '-': /* option name from XrmoptionIsArg */ result= 1; break;
+ }
+ }
+ }
+ return *cache= result;
+}
+
static void more_resources(const char *str, const char *why) {
XrmDatabase more;
if (argc>1) badusage();
- debug= !!getresource("debug");
+ getresource_bool("debug",0,&debug);
const char *alarmlevel_string= getresource("alarmLevel");
alarmlevel = alarmlevel_string ? atoi(alarmlevel_string) : 300;