summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
78d1128)
make fgetline calls work (was messing up on continuation lines)
SCCS-vsn: lib/libc/gen/getcap.c 5.14
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getcap.c 5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)getcap.c 5.14 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#define RECOK (char)0
#define TCERR (char)1
#define RECOK (char)0
#define TCERR (char)1
static size_t topreclen; /* toprec length */
static char *toprec; /* Additional record specified by cgetset() */
static size_t topreclen; /* toprec length */
static char *toprec; /* Additional record specified by cgetset() */
- key.size = strlen(name) + 1;
+ key.size = strlen(name);
+ for (;;) {
+ /* Get the reference. */
+ switch(capdbp->get(capdbp, &key, &data, 0)) {
+ case -1:
+ return (-2);
+ case 1:
+ return (-1);
+ }
- /*
- * Get the reference.
- */
- if ((st = capdbp->get(capdbp, &key, &data, 0)) < 0)
- return(-2);
- if (st == 1)
- return(-1);
-
- if ((buf = malloc(data.size - 1)) == NULL)
- return(-2);
-
- strcpy(buf, (char *)(data.data));
-
- key.data = buf;
- key.size = data.size;
+ if (((char *)data.data)[0] != SHADOW)
+ break;
- /*
- * Get the record.
- */
- if (capdbp->get(capdbp, &key, &data, 0) < 0) {
- free(buf);
- return(-2);
+ key.data = data.data + 1;
+ key.size = data.size - 1;
*bp = &((char *)(data.data))[1];
*bp = &((char *)(data.data))[1];
if (((char *)(data.data))[0] == TCERR)
if (((char *)(data.data))[0] == TCERR)
(void)cgetclose();
return (-1);
} else {
(void)cgetclose();
return (-1);
} else {
- dbp++;
- if (*dbp == NULL) {
(void)cgetclose();
return (0);
(void)cgetclose();
return (0);
- } else if ((pfp = fopen(*dbp, "r")) ==
- NULL) {
+ } else if ((pfp =
+ fopen(*dbp, "r")) == NULL) {
(void)cgetclose();
return (-1);
} else
(void)cgetclose();
return (-1);
} else
}
} else
line[len - 1] = '\0';
}
} else
line[len - 1] = '\0';
- if (isspace(*line) || *line == ':' || *line == '#'
- || len == 0 || slash) {
- if (len > 0 && line[len - 1] == '\\')
+ if (len == 1) {
+ slash = 0;
+ continue;
+ }
+ if (isspace(*line) ||
+ *line == ':' || *line == '#' || slash) {
+ if (line[len - 2] == '\\')
slash = 1;
else
slash = 0;
continue;
}
slash = 1;
else
slash = 0;
continue;
}
- if (len > 0 && line[len - 1] == '\\')
+ if (line[len - 2] == '\\')
slash = 1;
else
slash = 0;
slash = 1;
else
slash = 0;