logindefs: fix coding style

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2011-11-13 19:34:46 +01:00 committed by Sami Kerola
parent 43b53f57c1
commit 3f9c237dcb
1 changed files with 23 additions and 21 deletions

View File

@ -19,20 +19,20 @@
* 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 "nls.h"
#include "xalloc.h"
#include "pathnames.h"
#include "logindefs.h"
#include "nls.h"
#include "pathnames.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;
@ -107,12 +106,12 @@ static void load_defaults(const char *filename)
/* 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 == '"'))
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;
}
@ -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[])
{
@ -226,7 +226,8 @@ int main(int argc, char *argv[])
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;
}