summaryrefslogtreecommitdiff
path: root/libc/pwd_grp/getspnam.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-06-12 23:27:00 +0000
committerEric Andersen <andersen@codepoet.org>2002-06-12 23:27:00 +0000
commitc617db9065afa51100199d9ac4561feee4279291 (patch)
treee4a90725f73b9fb7ec9970ca495172181acfa873 /libc/pwd_grp/getspnam.c
parentfd6b9378be20243eaea7da1c2ddb3d68f123d28e (diff)
Silence warnings, clean things up.
-Erik
Diffstat (limited to 'libc/pwd_grp/getspnam.c')
-rw-r--r--libc/pwd_grp/getspnam.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/libc/pwd_grp/getspnam.c b/libc/pwd_grp/getspnam.c
index 3865a0dc5..d8a29a8a2 100644
--- a/libc/pwd_grp/getspnam.c
+++ b/libc/pwd_grp/getspnam.c
@@ -21,41 +21,39 @@
#include <string.h>
#include <errno.h>
#include <fcntl.h>
-#include <shadow.h>
-
-#define PWD_BUFFER_SIZE 256
+#include "config.h"
int getspnam_r (const char *name, struct spwd *spwd,
char *buff, size_t buflen, struct spwd **crap)
{
- int spwd_fd;
+ int spwd_fd;
- if (name == NULL) {
- __set_errno(EINVAL);
- return -1;
- }
+ if (name == NULL) {
+ __set_errno(EINVAL);
+ return -1;
+ }
- if ((spwd_fd = open(_PATH_SHADOW, O_RDONLY)) < 0)
- return -1;
+ if ((spwd_fd = open(_PATH_SHADOW, O_RDONLY)) < 0)
+ return -1;
- while (__getspent_r(spwd, buff, buflen, spwd_fd) != -1)
- if (!strcmp(spwd->sp_namp, name)) {
- close(spwd_fd);
- return 0;
- }
+ while (__getspent_r(spwd, buff, buflen, spwd_fd) != -1)
+ if (!strcmp(spwd->sp_namp, name)) {
+ close(spwd_fd);
+ return 0;
+ }
- close(spwd_fd);
- return -1;
+ close(spwd_fd);
+ return -1;
}
struct spwd *getspnam(const char *name)
{
- static char line_buff[PWD_BUFFER_SIZE];
- static struct spwd spwd;
+ static char line_buff[PWD_BUFFER_SIZE];
+ static struct spwd spwd;
- if (getspnam_r(name, &spwd, line_buff, PWD_BUFFER_SIZE, NULL) != -1) {
- return &spwd;
- }
- return NULL;
+ if (getspnam_r(name, &spwd, line_buff, sizeof(line_buff), NULL) != -1) {
+ return &spwd;
+ }
+ return NULL;
}