Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/libpwdgrp/pwd_grp_internal.c

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/*  Copyright (C) 2003     Manuel Novoa III
    23 *
     
    1819 */
    1920
    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_SHADOW
    36 #define _PATH_SHADOW    "/etc/shadow"
    37 #endif
    38 #ifndef _PATH_PASSWD
    39 #define _PATH_PASSWD    "/etc/passwd"
    40 #endif
    41 #ifndef _PATH_GROUP
    42 #define _PATH_GROUP "/etc/group"
    43 #endif
    44 
    45 /**********************************************************************/
    46 /* Sizes for statically allocated buffers. */
    47 
    48 /* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
    49  * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
    50 #define PWD_BUFFER_SIZE 256
    51 #define GRP_BUFFER_SIZE 256
    52 
    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 
    6421#ifndef GETXXKEY_R_FUNC
    6522#error GETXXKEY_R_FUNC is not defined!
    6623#endif
    67 /**********************************************************************/
    68 #ifdef GETXXKEY_R_FUNC
    6924
    70 int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
    71                     GETXXKEY_R_ENTTYPE *__restrict resultbuf,
    72                     char *__restrict buffer, size_t buflen,
    73                     GETXXKEY_R_ENTTYPE **__restrict result)
     25int 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)
    7429{
    7530    FILE *stream;
     
    7833    *result = NULL;
    7934
    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;
    9543                break;
    9644            }
    97         } while (1);
    98         fclose(stream);
     45        } else {
     46            if (rv == ENOENT) { /* end-of-file encountered. */
     47                rv = 0;
     48            }
     49            break;
     50        }
    9951    }
     52    fclose(stream);
    10053
    10154    return rv;
    10255}
    10356
    104 #endif
    105 /**********************************************************************/
    10657#undef GETXXKEY_R_FUNC
    10758#undef GETXXKEY_R_PARSER
    10859#undef GETXXKEY_R_ENTTYPE
    10960#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.