8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / bnu / gnamef.c
blob6fe75cae2f84fa87fd32dc7930eb31a371e42412
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #ident "%Z%%M% %I% %E% SMI" /* from SVR4 bnu:gnamef.c 2.6 */
28 #include "uucp.h"
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
39 int
40 gnamef(p, filename)
41 register char *filename;
42 DIR *p;
44 struct dirent dentry;
45 register struct dirent *dp = &dentry;
47 for (;;) {
48 if ((dp = readdir(p)) == NULL)
49 return(FALSE);
50 if (dp->d_ino != 0 && dp->d_name[0] != '.')
51 break;
54 (void) strncpy(filename, dp->d_name, MAXBASENAME);
55 filename[MAXBASENAME] = '\0';
56 return(TRUE);
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
68 int
69 gdirf(p, filename, dir)
70 register char *filename;
71 DIR *p;
72 char *dir;
74 char statname[MAXNAMESIZE];
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;
85 return(TRUE);