fgetpos (ent->stream, &pos);
p = fgets (buffer, buflen, ent->stream);
if (p == NULL)
- return NSS_STATUS_NOTFOUND;
+ {
+ if (feof (ent->stream))
+ return NSS_STATUS_NOTFOUND;
+ else
+ {
+ fsetpos (ent->stream, &pos);
+ __set_errno (ERANGE);
+ return NSS_STATUS_TRYAGAIN;
+ }
+ }
/* Terminate the line for any case. */
buffer[buflen - 1] = '\0';
return NSS_STATUS_NOTFOUND;
else
{
+ fsetpos (ent->stream, &pos);
__set_errno (ERANGE);
return NSS_STATUS_TRYAGAIN;
}
fgetpos (ent->stream, &pos);
p = fgets (buffer, buflen, ent->stream);
if (p == NULL)
- return NSS_STATUS_NOTFOUND;
-
+ {
+ if (feof (ent->stream))
+ return NSS_STATUS_NOTFOUND;
+ else
+ {
+ fsetpos (ent->stream, &pos);
+ __set_errno (ERANGE);
+ return NSS_STATUS_TRYAGAIN;
+ }
+ }
+
/* Terminate the line for any case. */
buffer[buflen - 1] = '\0';
if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */
return NSS_STATUS_NOTFOUND;
else
- return status;
+ {
+ if (status == NSS_STATUS_TRYAGAIN)
+ /* The parser ran out of space */
+ fsetpos (ent->stream, &pos);
+ return status;
+ }
}
}
return NSS_STATUS_SUCCESS;