diff options
author | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-06-04 18:47:09 +0000 |
---|---|---|
committer | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-06-04 18:47:09 +0000 |
commit | c46806bf74c2618daa398cb7c3e4b1c47509a105 (patch) | |
tree | 0b429074ffc365e7eba2391cf00d7f4eecf372ab /mdk-stage1/dietlibc/libcruft | |
parent | 7b14ca284d598e7748f6f7a831389525c84890ba (diff) | |
download | drakx-c46806bf74c2618daa398cb7c3e4b1c47509a105.tar drakx-c46806bf74c2618daa398cb7c3e4b1c47509a105.tar.gz drakx-c46806bf74c2618daa398cb7c3e4b1c47509a105.tar.bz2 drakx-c46806bf74c2618daa398cb7c3e4b1c47509a105.tar.xz drakx-c46806bf74c2618daa398cb7c3e4b1c47509a105.zip |
even more removals
Diffstat (limited to 'mdk-stage1/dietlibc/libcruft')
-rw-r--r-- | mdk-stage1/dietlibc/libcruft/entlib.c | 153 | ||||
-rw-r--r-- | mdk-stage1/dietlibc/libcruft/entlib.h | 44 | ||||
-rw-r--r-- | mdk-stage1/dietlibc/libcruft/grent.c | 54 | ||||
-rw-r--r-- | mdk-stage1/dietlibc/libcruft/pwent.c | 43 | ||||
-rw-r--r-- | mdk-stage1/dietlibc/libcruft/spent.c | 45 |
5 files changed, 0 insertions, 339 deletions
diff --git a/mdk-stage1/dietlibc/libcruft/entlib.c b/mdk-stage1/dietlibc/libcruft/entlib.c deleted file mode 100644 index f88b3f057..000000000 --- a/mdk-stage1/dietlibc/libcruft/entlib.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * dietlibc/lib/entlib.c - Generic delimited-line parsing library - * - * Copyright 2001 Jeff Garzik <jgarzik@mandrakesoft.com> - * - * This is a brand new implementation, based on the interface - * described in man-pages-1.34-1mdk man pages package. - */ - - -#include "entlib.h" /* this is our only include */ - - -/* - * __ent_start - * - * Allocates and zeroes the module's state structure, - * and open a handle to /etc/passwd. - * - * Returns -1 on failure and sets errno, or zero for success. - */ - -int __ent_start(const char *pathname, struct __ent_state **st_ref) -{ - struct __ent_state *st; - - if (*st_ref) - return 0; - - st = calloc(1, sizeof(*st)); - if (!st) { - errno = ENOMEM; - return -1; - } - - st->fd = open(pathname, O_RDONLY); - if (st->fd == -1) { - /* errno should have been set by open(2) */ - free(st); - st = NULL; - return -1; - } - - *st_ref = st; - return 0; -} - - -/* - * __ent_get_line - * - * Eliminates a previous line from the buffer, if any. - * Then reads in a new line from /etc/passwd, if necessary. - * - * Returns -1 on failure, or zero for success. - */ - -int __ent_get_line(struct __ent_state *st) -{ - int rc; - - /* overwrite previous line, by shifting the rest - * of the rest to the front of the buffer - */ - if (st->bufptr) { - unsigned int slop = st->buflen - st->bufptr; - memmove(st->ent_buf, &st->ent_buf[st->bufptr], slop); - st->bufptr = 0; - st->buflen = slop; - st->ent_buf[st->buflen] = 0; /* null terminate */ - } - - if (st->buflen == __ENT_BUFSIZ || strchr(st->ent_buf, '\n')) - return 0; - - rc = read(st->fd, &st->ent_buf[st->buflen], __ENT_BUFSIZ - st->buflen); - if (rc < 0) - return -1; - - st->buflen += rc; - if (st->buflen == 0) - return -1; - - return 0; -} - - -/* - * __ent_split - * - * Splits a string into parts based on a delimiter. - * Stops processing when \n is reached also. - * - * Returns -1 on failure, or zero on success. - */ - -int __ent_split(struct __ent_state *st, char **parts, - int n_parts, int delimiter, int require_exact) -{ - char *s = &st->ent_buf[st->bufptr]; - int idx = 0; - - /* empty list */ - if (!*s) { - if (!require_exact) - return 0; - return -1; - } - - /* scan through string, sticking string pointers - * into parts[] as delimiters are found - */ - parts[idx++] = s; - while (*s) { - st->bufptr++; - if (*s == '\n') { - *s = 0; /* null terminate */ - break; - } - if (*s == delimiter) { - *s = 0; /* null terminate */ - /* boundary error: too many delimiters */ - if (idx == n_parts) - return -1; - s++; - parts[idx++] = s; - } else { - s++; - } - } - - if (!require_exact) - return 0; - return (n_parts == idx) ? 0 : -1; -} - - -void __ent_set(struct __ent_state *st) -{ - if (!st) - return; - st->buflen = st->bufptr = 0; - lseek(st->fd, 0, SEEK_SET); -} - - -void __ent_end(struct __ent_state *st) -{ - if (!st) - return; - close(st->fd); - free(st); -} diff --git a/mdk-stage1/dietlibc/libcruft/entlib.h b/mdk-stage1/dietlibc/libcruft/entlib.h deleted file mode 100644 index 2659d542e..000000000 --- a/mdk-stage1/dietlibc/libcruft/entlib.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * dietlibc/lib/entlib.h - Generic delimited-line parsing library header - * - * Copyright 2001 Jeff Garzik <jgarzik@mandrakesoft.com> - * - * This is a brand new implementation, based on the interface - * described in man-pages-1.34-1mdk man pages package. - */ - -#ifndef __ENTLIB_H -#define __ENTLIB_H - -#include <sys/types.h> /* for open(2), lseek(2) */ -#include <sys/stat.h> /* for open(2) */ -#include <fcntl.h> /* for open(2) */ -#include <unistd.h> /* for close(2), lseek(2) */ -#include <stdlib.h> /* for calloc(3), free(3) */ -#include <errno.h> /* for errno */ -#include <string.h> /* for memmove(3) */ -#include <stdlib.h> /* for atoi(3) */ -#include <paths.h> /* for the file locations */ - -#include <pwd.h> /* for struct passwd */ -#include <grp.h> /* for struct group */ -#include <shadow.h> /* for struct spwd */ - -/* should be a multiple of 64 to create decent alignment */ -#define __ENT_BUFSIZ (64 * 2) -#define __ENT_RAW_BUFSIZ (__ENT_BUFSIZ + 2) /* some overlap required */ - -struct __ent_state { - char ent_buf[__ENT_RAW_BUFSIZ]; /* raw file data buffer */ - unsigned int buflen; /* amount of valid data in ent_buf */ - unsigned int bufptr; /* next valid position in ent_buf */ - int fd; /* /etc/passwd file descriptor */ -}; - -extern int __ent_start(const char *pathname, struct __ent_state **st_ref); -extern int __ent_get_line(struct __ent_state *st); -extern int __ent_split(struct __ent_state *st, char **parts, int n_parts, int delimiter, int require_exact); -extern void __ent_set(struct __ent_state *st); -extern void __ent_end(struct __ent_state *st); - -#endif /* __ENTLIB_H */ diff --git a/mdk-stage1/dietlibc/libcruft/grent.c b/mdk-stage1/dietlibc/libcruft/grent.c deleted file mode 100644 index 0357657de..000000000 --- a/mdk-stage1/dietlibc/libcruft/grent.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * dietlibc/lib/grent.c - getgrent(3)/setgrent(3)/endgrent(3) implementation - * - * Copyright 2001 Jeff Garzik <jgarzik@mandrakesoft.com> - * - * This is a brand new implementation, based on the interface - * described in man-pages-1.34-1mdk man pages package. - */ - - -#include "entlib.h" /* this is our only include */ - -#define MAX_GROUP_MEMBERS 16 /* matches Linux kernel task struct */ - -static struct __ent_state *st = NULL; /* state held across calls */ -static char *gr_mem[MAX_GROUP_MEMBERS+1]; -static struct group gr; - -struct group *getgrent(void) -{ - char *parts[4], *grouplist; - unsigned int bufptr; - - if (__ent_start(_PATH_GROUP, &st)) - return NULL; - if (__ent_get_line(st)) - goto err_out; - if (__ent_split(st, parts, 4, ':', 1) < 0) - goto err_out; - - gr.gr_name = parts[0]; - gr.gr_passwd = parts[1]; - gr.gr_gid = (gid_t) atoi(parts[2]); - grouplist = parts[3]; - - memset(&gr_mem, 0, sizeof(gr_mem)); - gr.gr_mem = gr_mem; - - /* rewind bufptr to beginning of group list */ - bufptr = st->bufptr; - st->bufptr = (int) (grouplist - st->ent_buf); - - __ent_split(st, gr_mem, MAX_GROUP_MEMBERS, ',', 0); - st->bufptr = bufptr; - - return &gr; - -err_out: - st->buflen = st->bufptr = 0; /* invalidate file data buffer */ - return NULL; -} - -void setgrent(void) { __ent_set(st); } -void endgrent(void) { __ent_end(st); st=NULL; } diff --git a/mdk-stage1/dietlibc/libcruft/pwent.c b/mdk-stage1/dietlibc/libcruft/pwent.c deleted file mode 100644 index 30a8a0957..000000000 --- a/mdk-stage1/dietlibc/libcruft/pwent.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * dietlibc/lib/pwent.c - getpwent(3)/setpwent(3)/endpwent(3) implementation - * - * Copyright 2001 Jeff Garzik <jgarzik@mandrakesoft.com> - * - * This is a brand new implementation, based on the interface - * described in man-pages-1.34-1mdk man pages package. - */ - - -#include "entlib.h" /* this is our only include */ - -static struct __ent_state *st = NULL; /* state held across calls */ -static struct passwd pw; - -struct passwd *getpwent(void) -{ - char *parts[7]; - - if (__ent_start(_PATH_PASSWD, &st)) - return NULL; - if (__ent_get_line(st)) - goto err_out; - if (__ent_split(st, parts, 7, ':', 1) < 0) - goto err_out; - - pw.pw_name = parts[0]; - pw.pw_passwd = parts[1]; - pw.pw_uid = (uid_t) atoi(parts[2]); - pw.pw_gid = (gid_t) atoi(parts[3]); - pw.pw_gecos = parts[4]; - pw.pw_dir = parts[5]; - pw.pw_shell = parts[6]; - - return &pw; - -err_out: - st->buflen = st->bufptr = 0; /* invalidate file data buffer */ - return NULL; -} - -void setpwent(void) { __ent_set(st); } -void endpwent(void) { __ent_end(st); st=NULL; } diff --git a/mdk-stage1/dietlibc/libcruft/spent.c b/mdk-stage1/dietlibc/libcruft/spent.c deleted file mode 100644 index e4beb81e4..000000000 --- a/mdk-stage1/dietlibc/libcruft/spent.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * dietlibc/lib/spent.c - getspent(3)/setspent(3)/endspent(3) implementation - * - * Copyright 2001 Jeff Garzik <jgarzik@mandrakesoft.com> - * - * This is a brand new implementation, based on the interface - * described in man-pages-1.34-1mdk man pages package. - */ - - -#include "entlib.h" /* this is our only include */ - -static struct __ent_state *st = NULL; /* state held across calls */ -static struct spwd sp; - -struct spwd *getspent(void) -{ - char *parts[9]; - - if (__ent_start(_PATH_SHADOW, &st)) - return NULL; - if (__ent_get_line(st)) - goto err_out; - if (__ent_split(st, parts, 9, ':', 1) < 0) - goto err_out; - - sp.sp_namp = parts[0]; - sp.sp_pwdp = parts[1]; - sp.sp_lstchg = atoi(parts[2]); /* XXX: atol */ - sp.sp_min = atoi(parts[3]); - sp.sp_max = atoi(parts[4]); - sp.sp_warn = atoi(parts[5]); - sp.sp_inact = atoi(parts[6]); - sp.sp_expire = atoi(parts[7]); - sp.sp_flag = atoi(parts[8]); - - return &sp; - -err_out: - st->buflen = st->bufptr = 0; /* invalidate file data buffer */ - return NULL; -} - -void setspent(void) { __ent_set(st); } -void endspent(void) { __ent_end(st); st=NULL; } |