]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
logindefs: fix coding style
authorSami Kerola <kerolasa@iki.fi>
Sun, 13 Nov 2011 18:34:46 +0000 (19:34 +0100)
committerSami Kerola <sami.kerola@tomtom.com>
Tue, 29 Nov 2011 16:58:00 +0000 (17:58 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/logindefs.c

index 27017c4597c328358f37ba40c94d7d82c726c007..fe590e990df85e51efe0746823a61a54c2e88d16 100644 (file)
  *    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.  */
@@ -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 <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;
        }
@@ -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;
 }