ENTNAME -- database name of the structure and functions (hostent, pwent).
STRUCTURE -- struct name, define only if not ENTNAME (passwd, group).
- DATAFILE -- string of the database file's name.
+ DATABASE -- string of the database file's name ("hosts", "passwd").
NEED_H_ERRNO - defined iff an arg `int *herrnop' is used.
- MIDLINE_COMMENTS - defined iff # before \n terminates a database line.
+
+ Also see files-parse.c.
*/
-#define ENTNAME_r CONCAT(ENTNAME,_r)
+#define ENTNAME_r CONCAT(ENTNAME,_r)
+
+#define DATAFILE "/etc/" DATABASE
#ifdef NEED_H_ERRNO
#define H_ERRNO_PROTO , int *herrnop
fclose (stream);
stream = NULL;
}
-
- /* Reset STAYOPEN flag. */
- keep_stream = 0;
}
internal_endent ();
+ /* Reset STAYOPEN flag. */
+ keep_stream = 0;
+
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS;
struct parser_data *data = (void *) buffer;
int linebuflen = buffer + buflen - data->linebuffer;
- /* Someone called internal_setent before calling us, so if the
- stream is not open now the file could not be opened. */
+ /* Be prepared that the set*ent function was not called before. */
if (stream == NULL)
{
- H_ERRNO_SET (NETDB_INTERNAL);
- return NSS_STATUS_UNAVAIL;
+ enum nss_status status;
+
+ status = internal_setent (0);
+ if (status != NSS_STATUS_SUCCESS)
+ return status;
}
- if (buflen < sizeof *data + 1)
+ if (buflen < (int) sizeof *data + 1)
{
errno = ERANGE;
- return NSS_STATUS_NOTFOUND;
+ return NSS_STATUS_TRYAGAIN;
}
do
return NSS_STATUS_NOTFOUND;
}
+ /* Terminate the line for any case. */
+ data->linebuffer[linebuflen - 1] = '\0';
+
/* Skip leading blanks. */
while (isspace (*p))
++p;
NAME is the name of the lookup; e.g. `hostbyname'.
+ KEYSIZE and KEYPATTERN are ignored here but used by ../nss_db/db-XXX.c.
+
PROTO describes the arguments for the lookup key;
e.g. `const char *hostname'.
BREAK_IF_MATCH is a block of code which compares `struct STRUCTURE *result'
to the lookup key arguments and does `break;' if they match. */
-#define DB_LOOKUP(name, break_if_match, proto...) \
+#define DB_LOOKUP(name, keysize, keypattern, break_if_match, proto...) \
enum nss_status \
_nss_files_get##name##_r (proto, \
struct STRUCTURE *result, \