From 3f9c237dcb96ac324a2eef822aabbed02fb63a03 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 13 Nov 2011 19:34:46 +0100 Subject: [PATCH] logindefs: fix coding style Signed-off-by: Sami Kerola --- login-utils/logindefs.c | 42 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/login-utils/logindefs.c b/login-utils/logindefs.c index 27017c4597..fe590e990d 100644 --- a/login-utils/logindefs.c +++ b/login-utils/logindefs.c @@ -19,20 +19,20 @@ * products derived from this software without their specific prior * written permission. */ -#include +#include #include +#include +#include #include #include #include -#include -#include #include #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. */ @@ -76,7 +76,6 @@ static void store(const char *name, const char *value, const char *path) list = new; } - static void load_defaults(const char *filename) { FILE *f; @@ -91,7 +90,7 @@ static void load_defaults(const char *filename) 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) @@ -103,16 +102,16 @@ static void load_defaults(const char *filename) } 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'; @@ -121,14 +120,16 @@ static void load_defaults(const char *filename) 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); @@ -170,7 +171,7 @@ static const char *search_config(const char *name) 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; } @@ -189,7 +190,7 @@ long getlogindefs_num(const char *name, long 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; } @@ -210,7 +211,6 @@ const char *getlogindefs_str(const char *name, const char *dflt) return ptr->value; } - #ifdef TEST_PROGRAM int main(int argc, char *argv[]) { @@ -218,15 +218,16 @@ int main(int argc, char *argv[]) if (argc <= 1) errx(EXIT_FAILURE, "usage: %s " - "[ ]", argv[0]); + "[ ]", 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; } @@ -239,7 +240,8 @@ int main(int argc, char *argv[]) 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; } -- 2.39.2