[BACK]Return to getcap.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / gen

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/gen/getcap.c between version 1.2 and 1.10

version 1.2, 1993/06/08 16:49:53 version 1.10, 1995/08/24 05:26:35
Line 1 
Line 1 
   /*      $NetBSD$        */
   
 /*-  /*-
  * Copyright (c) 1992 The Regents of the University of California.   * Copyright (c) 1992, 1993
  * All rights reserved.   *      The Regents of the University of California.  All rights reserved.
  *   *
  * This code is derived from software contributed to Berkeley by   * This code is derived from software contributed to Berkeley by
  * Casey Leedom of Lawrence Livermore National Laboratory.   * Casey Leedom of Lawrence Livermore National Laboratory.
Line 35 
Line 37 
  */   */
   
 #if defined(LIBC_SCCS) && !defined(lint)  #if defined(LIBC_SCCS) && !defined(lint)
 static char sccsid[] = "@(#)getcap.c    5.15 (Berkeley) 3/19/93";  #if 0
   static char sccsid[] = "@(#)getcap.c    8.3 (Berkeley) 3/25/94";
   #else
   static char rcsid[] = "$NetBSD$";
   #endif
 #endif /* LIBC_SCCS and not lint */  #endif /* LIBC_SCCS and not lint */
   
 #include <sys/types.h>  #include <sys/types.h>
Line 194  getent(cap, len, db_array, fd, name, dep
Line 200  getent(cap, len, db_array, fd, name, dep
         DB *capdbp;          DB *capdbp;
         DBT key, data;          DBT key, data;
         register char *r_end, *rp, **db_p;          register char *r_end, *rp, **db_p;
         int myfd, eof, foundit, retval;          int myfd, eof, foundit, retval, clen;
         char *record;          char *record, *cbuf;
         int tc_not_resolved;          int tc_not_resolved;
         char pbuf[_POSIX_PATH_MAX];          char pbuf[_POSIX_PATH_MAX];
   
Line 250  getent(cap, len, db_array, fd, name, dep
Line 256  getent(cap, len, db_array, fd, name, dep
                              != NULL) {                               != NULL) {
                                 free(record);                                  free(record);
                                 retval = cdbget(capdbp, &record, name);                                  retval = cdbget(capdbp, &record, name);
                                 if (capdbp->close(capdbp) < 0)                                  if (retval < 0) {
                                           /* no record available */
                                           (void)capdbp->close(capdbp);
                                           return (retval);
                                   }
                                   /* save the data; close frees it */
                                   clen = strlen(record);
                                   cbuf = malloc(clen + 1);
                                   memcpy(cbuf, record, clen + 1);
                                   if (capdbp->close(capdbp) < 0) {
                                           free(cbuf);
                                         return (-2);                                          return (-2);
                                 *len = strlen(record);                                  }
                                 *cap = malloc(*len + 1);                                  *len = clen;
                                 memmove(*cap, record, *len + 1);                                  *cap = cbuf;
                                 return (retval);                                  return (retval);
                         } else {                          } else {
                                 fd = open(*db_p, O_RDONLY, 0);                                  fd = open(*db_p, O_RDONLY, 0);
                                 if (fd < 0) {                                  if (fd < 0) {
                                         /* No error on unfound file. */                                          /* No error on unfound file. */
                                         if (errno == ENOENT)                                          continue;
                                                 continue;  
                                         free(record);  
                                         return (-2);  
                                 }                                  }
                                 myfd = 1;                                  myfd = 1;
                         }                          }
Line 657  cgetnext(bp, db_array)
Line 670  cgetnext(bp, db_array)
                         gottoprec = 1;                          gottoprec = 1;
                         line = toprec;                          line = toprec;
                 } else {                  } else {
                         line = fgetline(pfp, &len);                          line = fgetln(pfp, &len);
                         if (line == NULL && pfp) {                          if (line == NULL && pfp) {
                                 (void)fclose(pfp);                                  (void)fclose(pfp);
                                 if (ferror(pfp)) {                                  if (ferror(pfp)) {
Line 674  cgetnext(bp, db_array)
Line 687  cgetnext(bp, db_array)
                                         } else                                          } else
                                                 continue;                                                  continue;
                                 }                                  }
                         }                          } else
                         if (len == 0) {                                  line[len - 1] = '\0';
                           if (len == 1) {
                                 slash = 0;                                  slash = 0;
                                 continue;                                  continue;
                         }                          }
                         if (isspace(*line) ||                          if (isspace(*line) ||
                             *line == ':' || *line == '#' || slash) {                              *line == ':' || *line == '#' || slash) {
                                 if (line[len - 1] == '\\')                                  if (line[len - 2] == '\\')
                                         slash = 1;                                          slash = 1;
                                 else                                  else
                                         slash = 0;                                          slash = 0;
                                 continue;                                  continue;
                         }                          }
                         if (line[len - 1] == '\\')                          if (line[len - 2] == '\\')
                                 slash = 1;                                  slash = 1;
                         else                          else
                                 slash = 0;                                  slash = 0;
Line 715  cgetnext(bp, db_array)
Line 729  cgetnext(bp, db_array)
                                 *np = '\0';                                  *np = '\0';
                                 break;                                  break;
                         } else { /* name field extends beyond the line */                          } else { /* name field extends beyond the line */
                                 line = fgetline(pfp, &len);                                  line = fgetln(pfp, &len);
                                 if (line == NULL && pfp) {                                  if (line == NULL && pfp) {
                                         (void)fclose(pfp);                                          (void)fclose(pfp);
                                         if (ferror(pfp)) {                                          if (ferror(pfp)) {
                                                 (void)cgetclose();                                                  (void)cgetclose();
                                                 return (-1);                                                  return (-1);
                                         }                                          }
                                 }                                  } else
                                           line[len - 1] = '\0';
                         }                          }
                 }                  }
                 rp = buf;                  rp = buf;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.10

CVSweb <webmaster@jp.NetBSD.org>