* products derived from this software without their specific prior
* written permission.
*/
-#include <errno.h>
+#include <assert.h>
#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <limits.h>
-#include <assert.h>
#include <sys/syslog.h>
#include "c.h"
+#include "logindefs.h"
#include "nls.h"
-#include "xalloc.h"
#include "pathnames.h"
-#include "logindefs.h"
+#include "xalloc.h"
struct item {
char *name; /* name of the option. */
list = new;
}
-
static void load_defaults(const char *filename)
{
FILE *f;
char *p, *name, *data = NULL;
if (*buf == '#' || *buf == '\n')
- continue; /* only comment or empty line */
+ continue; /* only comment or empty line */
p = strchr(buf, '#');
if (p)
}
if (!*buf)
- continue; /* empty line */
+ continue; /* empty line */
/* ignore space at begin of the line */
name = buf;
- while (*name && isspace((unsigned) *name))
+ while (*name && isspace((unsigned)*name))
name++;
/* go to the end of the name */
data = name;
- while (*data && !(isspace((unsigned) *data) || *data == '='))
+ while (*data && !(isspace((unsigned)*data) || *data == '='))
data++;
if (data > name && *data)
*data++ = '\0';
continue;
/* go to the begin of the value */
- while (*data && (isspace((unsigned) *data) || *data == '=' || *data == '"'))
- data++;
+ while (*data
+ && (isspace((unsigned)*data) || *data == '='
+ || *data == '"'))
+ data++;
/* remove space at the end of the value */
p = data + strlen(data);
if (p > data)
p--;
- while (p > data && (isspace((unsigned) *p) || *p == '"'))
+ while (p > data && (isspace((unsigned)*p) || *p == '"'))
*p-- = '\0';
store(name, data, filename);
int getlogindefs_bool(const char *name, int dflt)
{
- struct item *ptr= search(name);
+ struct item *ptr = search(name);
return ptr && ptr->value ? (strcasecmp(ptr->value, "yes") == 0) : dflt;
}
return retval;
syslog(LOG_NOTICE, _("%s: %s contains invalid numerical value: %s"),
- search_config(name), name, ptr->value);
+ search_config(name), name, ptr->value);
return dflt;
}
return ptr->value;
}
-
#ifdef TEST_PROGRAM
int main(int argc, char *argv[])
{
if (argc <= 1)
errx(EXIT_FAILURE, "usage: %s <filename> "
- "[<str|num|bool> <valname>]", argv[0]);
+ "[<str|num|bool> <valname>]", argv[0]);
load_defaults(argv[1]);
- if (argc != 4) { /* list all */
+ if (argc != 4) { /* list all */
struct item *ptr;
for (ptr = list; ptr; ptr = ptr->next)
- printf("%s: $%s: '%s'\n", ptr->path, ptr->name, ptr->value);
+ printf("%s: $%s: '%s'\n", ptr->path, ptr->name,
+ ptr->value);
return EXIT_SUCCESS;
}
else if (strcmp(type, "num") == 0)
printf("$%s: '%ld'\n", name, getlogindefs_num(name, 0));
else if (strcmp(type, "bool") == 0)
- printf("$%s: '%s'\n", name, getlogindefs_bool(name, 0) ? "Y" : "N");
+ printf("$%s: '%s'\n", name,
+ getlogindefs_bool(name, 0) ? "Y" : "N");
return EXIT_SUCCESS;
}