Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/libpwdgrp/pwd_grp_internal.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/libpwdgrp/pwd_grp_internal.c
r821 r1770 1 /* vi: set sw=4 ts=4: */ 1 2 /* Copyright (C) 2003 Manuel Novoa III 2 3 * … … 18 19 */ 19 20 20 #include <features.h>21 #include <stdio.h>22 #include <stdlib.h>23 #include <stdint.h>24 #include <string.h>25 #include <stddef.h>26 #include <errno.h>27 #include <assert.h>28 #include <ctype.h>29 30 #include "pwd_.h"31 #include "grp_.h"32 #include "shadow_.h"33 #include "libbb.h"34 35 #ifndef _PATH_SHADOW36 #define _PATH_SHADOW "/etc/shadow"37 #endif38 #ifndef _PATH_PASSWD39 #define _PATH_PASSWD "/etc/passwd"40 #endif41 #ifndef _PATH_GROUP42 #define _PATH_GROUP "/etc/group"43 #endif44 45 /**********************************************************************/46 /* Sizes for statically allocated buffers. */47 48 /* If you change these values, also change _SC_GETPW_R_SIZE_MAX and49 * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */50 #define PWD_BUFFER_SIZE 25651 #define GRP_BUFFER_SIZE 25652 53 /**********************************************************************/54 /* Prototypes for internal functions. */55 56 extern int __parsepwent(void *pw, char *line);57 extern int __parsegrent(void *gr, char *line);58 extern int __parsespent(void *sp, char *line);59 60 extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,61 char *__restrict line_buff, size_t buflen, FILE *f);62 63 64 21 #ifndef GETXXKEY_R_FUNC 65 22 #error GETXXKEY_R_FUNC is not defined! 66 23 #endif 67 /**********************************************************************/68 #ifdef GETXXKEY_R_FUNC69 24 70 int GETXXKEY_R_FUNC( DO_GETXXKEY_R_KEYTYPE key,71 72 73 25 int GETXXKEY_R_FUNC(GETXXKEY_R_KEYTYPE key, 26 GETXXKEY_R_ENTTYPE *__restrict resultbuf, 27 char *__restrict buffer, size_t buflen, 28 GETXXKEY_R_ENTTYPE **__restrict result) 74 29 { 75 30 FILE *stream; … … 78 33 *result = NULL; 79 34 80 if (!(stream = fopen(DO_GETXXKEY_R_PATHNAME, "r"))) { 81 rv = errno; 82 } else { 83 do { 84 if (!(rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf, 85 buffer, buflen, stream)) 86 ) { 87 if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */ 88 *result = resultbuf; 89 break; 90 } 91 } else { 92 if (rv == ENOENT) { /* end-of-file encountered. */ 93 rv = 0; 94 } 35 stream = fopen(GETXXKEY_R_PATHNAME, "r"); 36 if (!stream) 37 return errno; 38 while (1) { 39 rv = bb__pgsreader(GETXXKEY_R_PARSER, resultbuf, buffer, buflen, stream); 40 if (!rv) { 41 if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */ 42 *result = resultbuf; 95 43 break; 96 44 } 97 } while (1); 98 fclose(stream); 45 } else { 46 if (rv == ENOENT) { /* end-of-file encountered. */ 47 rv = 0; 48 } 49 break; 50 } 99 51 } 52 fclose(stream); 100 53 101 54 return rv; 102 55 } 103 56 104 #endif105 /**********************************************************************/106 57 #undef GETXXKEY_R_FUNC 107 58 #undef GETXXKEY_R_PARSER 108 59 #undef GETXXKEY_R_ENTTYPE 109 60 #undef GETXXKEY_R_TEST 110 #undef DO_GETXXKEY_R_KEYTYPE 111 #undef DO_GETXXKEY_R_PATHNAME 112 61 #undef GETXXKEY_R_KEYTYPE 62 #undef GETXXKEY_R_PATHNAME
Note:
See TracChangeset
for help on using the changeset viewer.