Lines 869-884
Link Here
|
869 |
} |
869 |
} |
870 |
fresh = 1; |
870 |
fresh = 1; |
871 |
} |
871 |
} |
872 |
if (how == nss_lt_all) |
872 |
stayopen = (how == nss_lt_all) ? 1 : st->stayopen; |
873 |
stayopen = 1; |
|
|
874 |
else { |
875 |
if (!fresh) |
876 |
rewind(st->fp); |
877 |
stayopen = st->stayopen; |
878 |
} |
879 |
rv = NS_NOTFOUND; |
880 |
if (stayopen) |
873 |
if (stayopen) |
881 |
pos = ftello(st->fp); |
874 |
pos = ftello(st->fp); |
|
|
875 |
if (how != nss_lt_all && !fresh) |
876 |
rewind(st->fp); |
877 |
rv = NS_NOTFOUND; |
882 |
while ((line = fgetln(st->fp, &linesize)) != NULL) { |
878 |
while ((line = fgetln(st->fp, &linesize)) != NULL) { |
883 |
if (line[linesize-1] == '\n') |
879 |
if (line[linesize-1] == '\n') |
884 |
linesize--; |
880 |
linesize--; |
Lines 900-906
Link Here
|
900 |
&buffer[linesize + 1], bufsize - linesize - 1, errnop); |
896 |
&buffer[linesize + 1], bufsize - linesize - 1, errnop); |
901 |
if (rv & NS_TERMINATE) |
897 |
if (rv & NS_TERMINATE) |
902 |
break; |
898 |
break; |
903 |
if (stayopen) |
899 |
if (how == nss_lt_all) |
904 |
pos = ftello(st->fp); |
900 |
pos = ftello(st->fp); |
905 |
} |
901 |
} |
906 |
if (st->fp != NULL && !stayopen) { |
902 |
if (st->fp != NULL && !stayopen) { |
Lines 907-912
Link Here
|
907 |
fclose(st->fp); |
903 |
fclose(st->fp); |
908 |
st->fp = NULL; |
904 |
st->fp = NULL; |
909 |
} |
905 |
} |
|
|
906 |
if (st->ftp != NULL && how != nss_lt_all) |
907 |
fseeko(st->fp, pos, SEEK_SET); |
910 |
if (rv == NS_SUCCESS && retval != NULL) |
908 |
if (rv == NS_SUCCESS && retval != NULL) |
911 |
*(struct group **)retval = grp; |
909 |
*(struct group **)retval = grp; |
912 |
else if (rv == NS_RETURN && *errnop == ERANGE && st->fp != NULL) |
910 |
else if (rv == NS_RETURN && *errnop == ERANGE && st->fp != NULL) |
Lines 1351-1363
Link Here
|
1351 |
} |
1349 |
} |
1352 |
fresh = 1; |
1350 |
fresh = 1; |
1353 |
} |
1351 |
} |
1354 |
if (how == nss_lt_all) |
1352 |
stayopen = (how == nss_lt_all) ? 1 : st->stayopen; |
1355 |
stayopen = 1; |
1353 |
if (stayopen) |
1356 |
else { |
1354 |
pos = ftello(st->fp); |
1357 |
if (!fresh) |
1355 |
if (how != nss_lt_all && !fresh) |
1358 |
rewind(st->fp); |
1356 |
rewind(st->fp); |
1359 |
stayopen = st->stayopen; |
|
|
1360 |
} |
1361 |
docompat: |
1357 |
docompat: |
1362 |
switch (st->compat) { |
1358 |
switch (st->compat) { |
1363 |
case COMPAT_MODE_ALL: |
1359 |
case COMPAT_MODE_ALL: |
Lines 1418-1425
Link Here
|
1418 |
break; |
1414 |
break; |
1419 |
} |
1415 |
} |
1420 |
rv = NS_NOTFOUND; |
1416 |
rv = NS_NOTFOUND; |
1421 |
if (stayopen) |
|
|
1422 |
pos = ftello(st->fp); |
1423 |
while ((line = fgetln(st->fp, &linesize)) != NULL) { |
1417 |
while ((line = fgetln(st->fp, &linesize)) != NULL) { |
1424 |
if (line[linesize-1] == '\n') |
1418 |
if (line[linesize-1] == '\n') |
1425 |
linesize--; |
1419 |
linesize--; |
Lines 1460-1466
Link Here
|
1460 |
&buffer[linesize + 1], bufsize - linesize - 1, errnop); |
1454 |
&buffer[linesize + 1], bufsize - linesize - 1, errnop); |
1461 |
if (rv & NS_TERMINATE) |
1455 |
if (rv & NS_TERMINATE) |
1462 |
break; |
1456 |
break; |
1463 |
if (stayopen) |
1457 |
if (how == nss_lt_all) |
1464 |
pos = ftello(st->fp); |
1458 |
pos = ftello(st->fp); |
1465 |
} |
1459 |
} |
1466 |
fin: |
1460 |
fin: |
Lines 1468-1473
Link Here
|
1468 |
fclose(st->fp); |
1462 |
fclose(st->fp); |
1469 |
st->fp = NULL; |
1463 |
st->fp = NULL; |
1470 |
} |
1464 |
} |
|
|
1465 |
if (st->fp != NULL && how != nss_lt_all) |
1466 |
fseeko(st->fp, pos, SEEK_SET); |
1471 |
if (rv == NS_SUCCESS && retval != NULL) |
1467 |
if (rv == NS_SUCCESS && retval != NULL) |
1472 |
*(struct group **)retval = grp; |
1468 |
*(struct group **)retval = grp; |
1473 |
else if (rv == NS_RETURN && *errnop == ERANGE && st->fp != NULL) |
1469 |
else if (rv == NS_RETURN && *errnop == ERANGE && st->fp != NULL) |