1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
24
25
26 #ident "%Z%%M% %I% %E% SMI" /* from SVR4 bnu:gnamef.c 2.6 */
27
28 #include "uucp.h"
29
30 /*
31 * get next file name from directory
32 * p -> file description of directory file to read
33 * filename -> address of buffer to return filename in
34 * must be of size MAXBASENAME+1
35 * returns:
36 * FALSE -> end of directory read
37 * TRUE -> returned name
38 */
39 int
gnamef(p,filename)40 gnamef(p, filename)
41 register char *filename;
42 DIR *p;
43 {
44 struct dirent dentry;
45 register struct dirent *dp = &dentry;
46
47 for (;;) {
48 if ((dp = readdir(p)) == NULL)
49 return(FALSE);
50 if (dp->d_ino != 0 && dp->d_name[0] != '.')
51 break;
52 }
53
54 (void) strncpy(filename, dp->d_name, MAXBASENAME);
55 filename[MAXBASENAME] = '\0';
56 return(TRUE);
57 }
58
59 /*
60 * get next directory name from directory
61 * p -> file description of directory file to read
62 * filename -> address of buffer to return filename in
63 * must be of size MAXBASENAME+1
64 * returns:
65 * FALSE -> end of directory read
66 * TRUE -> returned dir
67 */
68 int
gdirf(p,filename,dir)69 gdirf(p, filename, dir)
70 register char *filename;
71 DIR *p;
72 char *dir;
73 {
74 char statname[MAXNAMESIZE];
75
76 for (;;) {
77 if(gnamef(p, filename) == FALSE)
78 return(FALSE);
79 (void) sprintf(statname, "%s/%s", dir, filename);
80 DEBUG(4, "stat %s\n", statname);
81 if (DIRECTORY(statname))
82 break;
83 }
84
85 return(TRUE);
86 }
87