/* Mail alias file parser in nss_files module.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
stream = fopen ("/etc/aliases", "r");
if (stream == NULL)
- status = NSS_STATUS_UNAVAIL;
+ status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
else
{
/* We have to make sure the file is `closed on exec'. */
/* Parsing the database file into `struct aliasent' data structures. */
static enum nss_status
get_next_alias (const char *match, struct aliasent *result,
- char *buffer, size_t buflen)
+ char *buffer, size_t buflen, int *errnop)
{
enum nss_status status = NSS_STATUS_NOTFOUND;
int ignore = 0;
/* Read the first line. It must contain the alias name and
possibly some alias names. */
- first_unused[room_left - 1] = '\0';
+ first_unused[room_left - 1] = '\xff';
line = fgets (first_unused, room_left, stream);
if (line == NULL)
/* Nothing to read. */
break;
- else if (first_unused[room_left - 1] != '\0')
+ else if (first_unused[room_left - 1] != '\xff')
{
/* The line is too long for our buffer. */
no_more_room:
- __set_errno (ERANGE);
+ *errnop = ERANGE;
status = NSS_STATUS_TRYAGAIN;
break;
}
looking for. If it does not match we simply ignore all
lines until the next line containing the start of a new
alias is found. */
- ignore = match != NULL && strcmp (result->alias_name, match) != 0;
+ ignore = (match != NULL
+ && __strcasecmp (result->alias_name, match) != 0);
while (! ignore)
{
{
while (! feof (listfile))
{
- first_unused[room_left - 1] = '\0';
+ first_unused[room_left - 1] = '\xff';
line = fgets (first_unused, room_left, listfile);
if (line == NULL)
break;
- if (first_unused[room_left - 1] != '\0')
+ if (first_unused[room_left - 1] != '\xff')
{
free (old_line);
goto no_more_room;
/* The just read character is a white space and so
can be ignored. */
- first_unused[room_left - 1] = '\0';
+ first_unused[room_left - 1] = '\xff';
line = fgets (first_unused, room_left, stream);
- if (first_unused[room_left - 1] != '\0')
+ if (first_unused[room_left - 1] != '\xff')
goto no_more_room;
cp = strpbrk (line, "#\n");
if (cp != NULL)
enum nss_status
-_nss_files_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen)
+_nss_files_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen,
+ int *errnop)
{
/* Return next entry in host file. */
enum nss_status status = NSS_STATUS_SUCCESS;
/* Read lines until we get a definite result. */
do
- status = get_next_alias (NULL, result, buffer, buflen);
+ status = get_next_alias (NULL, result, buffer, buflen, errnop);
while (status == NSS_STATUS_RETURN);
/* If we successfully read an entry remember this position. */
enum nss_status
_nss_files_getaliasbyname_r (const char *name, struct aliasent *result,
- char *buffer, size_t buflen)
+ char *buffer, size_t buflen, int *errnop)
{
/* Return next entry in host file. */
enum nss_status status = NSS_STATUS_SUCCESS;
/* Read lines until we get a definite result. */
do
- status = get_next_alias (name, result, buffer, buflen);
+ status = get_next_alias (name, result, buffer, buflen, errnop);
while (status == NSS_STATUS_RETURN);
}