diff options
author | Sami Kerola | 2011-11-13 19:32:10 +0100 |
---|---|---|
committer | Sami Kerola | 2011-11-29 17:58:00 +0100 |
commit | 43b53f57c180bfe0c25d9fc1a1597d720bd1e44d (patch) | |
tree | 6398959c588316baf1f5e4c9228aeed362cfe4ca /login-utils/islocal.c | |
parent | chsh: fix coding style (diff) | |
download | kernel-qcow2-util-linux-43b53f57c180bfe0c25d9fc1a1597d720bd1e44d.tar.gz kernel-qcow2-util-linux-43b53f57c180bfe0c25d9fc1a1597d720bd1e44d.tar.xz kernel-qcow2-util-linux-43b53f57c180bfe0c25d9fc1a1597d720bd1e44d.zip |
islocal: fix coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/islocal.c')
-rw-r--r-- | login-utils/islocal.c | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/login-utils/islocal.c b/login-utils/islocal.c index e0a3d7694..91dda0d29 100644 --- a/login-utils/islocal.c +++ b/login-utils/islocal.c @@ -1,42 +1,40 @@ -/* - islocal.c - returns true if user is registered in the local - /etc/passwd file. Written by Alvaro Martinez Echevarria, - alvaro@enano.etsit.upm.es, to allow peaceful coexistence with yp. Nov 94. - - Hacked a bit by poe@daimi.aau.dk - See also ftp://ftp.daimi.aau.dk/pub/linux/poe/admutil* - - Hacked by Peter Breitenlohner, peb@mppmu.mpg.de, - to distinguish user names where one is a prefix of the other, - and to use "pathnames.h". Oct 5, 96. - - 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> - - added Native Language Support - - 2008-04-06 James Youngman, jay@gnu.org - - Completely rewritten to remove assumption that /etc/passwd - lines are < 1024 characters long. Also added unit tests. - -*/ +/* + * islocal.c - returns true if user is registered in the local + * /etc/passwd file. Written by Alvaro Martinez Echevarria, + * alvaro@enano.etsit.upm.es, to allow peaceful coexistence with yp. Nov 94. + * + * Hacked a bit by poe@daimi.aau.dk + * See also ftp://ftp.daimi.aau.dk/pub/linux/poe/admutil* + * + * Hacked by Peter Breitenlohner, peb@mppmu.mpg.de, + * to distinguish user names where one is a prefix of the other, + * and to use "pathnames.h". Oct 5, 96. + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> + * - added Native Language Support + * + * 2008-04-06 James Youngman, jay@gnu.org + * - Completely rewritten to remove assumption that /etc/passwd + * lines are < 1024 characters long. Also added unit tests. + */ +#include <stddef.h> #include <stdio.h> #include <stdlib.h> -#include <stddef.h> +#include "islocal.h" #include "nls.h" #include "pathnames.h" -#include "islocal.h" -static int -is_local_in_file(const char *user, const char *filename) +static int is_local_in_file(const char *user, const char *filename) { int local = 0; size_t match; int chin, skip; FILE *f; - if (NULL == (f=fopen(filename, "r"))) - return -1; + if (NULL == (f = fopen(filename, "r"))) + return -1; match = 0u; skip = 0; @@ -51,20 +49,22 @@ is_local_in_file(const char *user, const char *filename) } else { if (':' == chin) { if (0 == user[match]) { - local = 1; /* Success. */ - /* next line has no test coverage, but it is - * just an optimisation anyway. */ + /* Success. */ + local = 1; + /* next line has no test coverage, + * but it is just an optimisation + * anyway. */ break; } else { - /* we read a whole username, but it is - * the wrong user. Skip to the next - * line. */ + /* we read a whole username, but it + * is the wrong user. Skip to the + * next line. */ skip = 1; } } else if ('\n' == chin) { - /* This line contains no colon; it's malformed. - * No skip since we are already at the start of - * the next line. */ + /* This line contains no colon; it's + * malformed. No skip since we are already + * at the start of the next line. */ match = 0u; } else if (chin != user[match]) { /* username does not match. */ @@ -78,8 +78,7 @@ is_local_in_file(const char *user, const char *filename) return local; } -int -is_local(const char *user) +int is_local(const char *user) { int rv; if ((rv = is_local_in_file(user, _PATH_PASSWD)) < 0) { @@ -93,11 +92,11 @@ is_local(const char *user) } #ifdef TEST_PROGRAM -int -main (int argc, char *argv[]) +int main(int argc, char *argv[]) { if (argc <= 2) { - fprintf(stderr, "usage: %s <passwdfile> <username> [...]\n", argv[0]); + fprintf(stderr, "usage: %s <passwdfile> <username> [...]\n", + argv[0]); return 1; } else { int i; |