Commit | Line | Data |
---|---|---|
73ac11f7 | 1 | #ifndef lint |
46b15d8a | 2 | static char sccsid[] = "@(#)gnamef.c 5.3 (Berkeley) %G%"; |
73ac11f7 SL |
3 | #endif |
4 | ||
5 | #include "uucp.h" | |
6 | #include <sys/types.h> | |
7 | #ifdef NDIR | |
8 | #include "ndir.h" | |
9 | #else | |
ed412ce0 | 10 | #include <sys/dir.h> |
73ac11f7 SL |
11 | #endif |
12 | ||
46b15d8a RC |
13 | /* |
14 | * get next file name from directory | |
73ac11f7 SL |
15 | * |
16 | * return codes: | |
17 | * 0 - end of directory read | |
18 | * 1 - returned name | |
19 | */ | |
20 | ||
21 | gnamef(dirp, filename) | |
22 | register DIR *dirp; | |
23 | register char *filename; | |
24 | { | |
25 | register struct direct *dentp; | |
26 | ||
46b15d8a RC |
27 | for (;;) { |
28 | if ((dentp = readdir(dirp)) == NULL) { | |
29 | return 0; | |
30 | } | |
73ac11f7 SL |
31 | if (dentp->d_ino != 0) |
32 | break; | |
33 | } | |
34 | ||
46b15d8a | 35 | /* Truncate filename. This may become a problem someday. */ |
73ac11f7 SL |
36 | strncpy(filename, dentp->d_name, NAMESIZE-1); |
37 | filename[NAMESIZE-1] = '\0'; | |
46b15d8a RC |
38 | DEBUG(99,"gnamef returns %s\n",filename); |
39 | return 1; | |
73ac11f7 | 40 | } |