BSD 3 development
[unix-history] / usr / src / cmd / uucp / gnamef.c
CommitLineData
6685ccc5
BJ
1#include "uucp.h"
2#include <sys/types.h>
3#include <sys/dir.h>
4
5
6/*******
7 * gnamef(p, filename) get next file name from directory
8 * FILE *p;
9 * char *filename;
10 *
11 * return codes:
12 * 0 - end of directory read
13 * 1 - returned name
14 */
15
16
17gnamef(p, filename)
18FILE *p;
19char *filename;
20{
21 static struct direct dentry;
22 int i;
23 char *s;
24
25 while (1) {
26 if (fread(&dentry, sizeof(dentry), 1, p) != 1)
27 return(0);
28 if (dentry.d_ino != 0)
29 break;
30 }
31
32 for (i = 0, s = dentry.d_name; i < DIRSIZ; i++)
33 if ((filename[i] = *s++) == '\0')
34 break;
35 filename[DIRSIZ] = '\0';
36 return(1);
37}
38