[BACK]Return to getinfo.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cap_mkdb

Diff for /src/usr.bin/cap_mkdb/Attic/getinfo.c between version 1.16 and 1.17

version 1.16, 2009/11/11 23:49:01 version 1.17, 2011/07/04 21:34:54
Line 32 
Line 32 
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <ctype.h>  #include <ctype.h>
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <limits.h>  #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
Line 135 
Line 135 
         int myfd, eof, foundit;          int myfd, eof, foundit;
         char *record, *s;          char *record, *s;
         int tc_not_resolved;          int tc_not_resolved;
   
         /*          /*
          * Return with ``loop detected'' error if we've recursed more than           * Return with ``loop detected'' error if we've recursed more than
          * MAX_RECURSION times.           * MAX_RECURSION times.
Line 204 
Line 204 
                         for (;;) {                          for (;;) {
                                 if (bp >= b_end) {                                  if (bp >= b_end) {
                                         int n;                                          int n;
   
                                         n = read(fd, buf, sizeof(buf));                                          n = read(fd, buf, sizeof(buf));
                                         if (n <= 0) {                                          if (n <= 0) {
                                                 if (myfd)                                                  if (myfd)
Line 221 
Line 221 
                                         b_end = buf+n;                                          b_end = buf+n;
                                         bp = buf;                                          bp = buf;
                                 }                                  }
   
                                 c = *bp++;                                  c = *bp++;
                                 if (c == '\n') {                                  if (c == '\n') {
                                         if (bp >= b_end) {                                          if (bp >= b_end) {
Line 252 
Line 252 
                                         *rp++ = c;                                          *rp++ = c;
   
                                 /*                                  /*
                                  * Enforce loop invariant: if no room                                   * Enforce loop invariant: if no room
                                  * left in record buffer, try to get                                   * left in record buffer, try to get
                                  * some more.                                   * some more.
                                  */                                   */
Line 277 
Line 277 
                         }                          }
                         /* loop invariant lets us do this */                          /* loop invariant lets us do this */
                         *rp++ = '\0';                          *rp++ = '\0';
   
                         /*                          /*
                          * Toss blank lines and comments.                           * Toss blank lines and comments.
                          */                           */
                         if (*record == '\0' || *record == '#')                          if (*record == '\0' || *record == '#')
                                 continue;                                  continue;
   
                         /*                          /*
                          * See if this is the record we want ...                           * See if this is the record we want ...
                          */                           */
Line 361 
Line 361 
                                         tc_not_resolved = 1;                                          tc_not_resolved = 1;
                                 /* couldn't resolve tc */                                  /* couldn't resolve tc */
                                 if (iret == -1) {                                  if (iret == -1) {
                                         *(s - 1) = ',';                                          *(s - 1) = ',';
                                         scan = s - 1;                                          scan = s - 1;
                                         tc_not_resolved = 1;                                          tc_not_resolved = 1;
                                         continue;                                          continue;
   
                                 }                                  }
                         }                          }
                         /* not interested in name field of tc'ed record */                          /* not interested in name field of tc'ed record */
Line 426 
Line 426 
                          */                           */
                         scan = s-1;                          scan = s-1;
                 }                  }
   
         }          }
         /*          /*
          * Close file (if we opened it), give back any extra memory, and           * Close file (if we opened it), give back any extra memory, and
Line 436 
Line 436 
                 (void)close(fd);                  (void)close(fd);
         *len = rp - record - 1; /* don't count NUL */          *len = rp - record - 1; /* don't count NUL */
         if (r_end > rp) {          if (r_end > rp) {
                 if ((s =                  if ((s =
                      realloc(record, (size_t)(rp - record))) == NULL) {                       realloc(record, (size_t)(rp - record))) == NULL) {
                         free(record);                          free(record);
                         errno = ENOMEM;                          errno = ENOMEM;
Line 444 
Line 444 
                 } else                  } else
                         record = s;                          record = s;
         }          }
   
         *cap = record;          *cap = record;
         if (tc_not_resolved)          if (tc_not_resolved)
                 return (1);                  return (1);
         return (0);          return (0);
 }  }
   
 /*  /*
  * Igetmatch will return 0 if name is one of the names of the capability   * Igetmatch will return 0 if name is one of the names of the capability
Line 510 
Line 510 
 }  }
   
 /*  /*
  * Igetnext() gets either the first or next entry in the logical database   * Igetnext() gets either the first or next entry in the logical database
  * specified by db_array.  It returns 0 upon completion of the database, 1   * specified by db_array.  It returns 0 upon completion of the database, 1
  * upon returning an entry with more remaining, and -1 if an error occurs.   * upon returning an entry with more remaining, and -1 if an error occurs.
  */   */
Line 567 
Line 567 
                 else                  else
                         slash = 0;                          slash = 0;
   
                 /*                  /*
                  * Line points to a name line.                   * Line points to a name line.
                  */                   */
                 done = 0;                  done = 0;

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17