xref: /titanic_44/usr/src/cmd/lp/lib/requests/anyrequests.c (revision 2b4a78020b9c38d1b95e2f3fefa6d6e4be382d1f)
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"	/* SVr4.0 1.6	*/
27 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
28 
29 #include "sys/types.h"
30 
31 #include "lp.h"
32 
33 /**
34  ** anyrequests() - SEE IF ANY REQUESTS ARE ``QUEUED''
35  **/
36 
37 int
38 #if	defined(__STDC__)
39 anyrequests (
40 	void
41 )
42 #else
43 anyrequests ()
44 #endif
45 {
46 	long			lastdir		= -1;
47 
48 	char *			name;
49 
50 
51 	/*
52 	 * This routine walks through the requests (secure)
53 	 * directory looking for files, descending one level
54 	 * into each sub-directory, if any. Finding at least
55 	 * one file means that a request is queued.
56 	 */
57 	while ((name = next_dir(Lp_Requests, &lastdir))) {
58 
59 		long			lastfile	= -1;
60 
61 		char *			subdir;
62 
63 
64 		if (!(subdir = makepath(Lp_Requests, name, (char *)0)))
65 			return (1);	/* err on safe side */
66 
67 		if (next_file(subdir, &lastfile)) {
68 			Free (subdir);
69 			return (1);
70 		}
71 
72 		Free (subdir);
73 	}
74 	return (0);
75 }
76