xref: /illumos-gate/usr/src/cmd/lp/cmd/lpadmin/default.c (revision 7c478bd9)
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.5	*/
27 
28 #include "stdio.h"
29 #include "errno.h"
30 #include "sys/types.h"
31 
32 #include "lp.h"
33 #include "printers.h"
34 
35 #define	WHO_AM_I	I_AM_LPADMIN
36 #include "oam.h"
37 
38 #include "lpadmin.h"
39 
40 
41 /**
42  ** getdflt() - RETURN DEFAULT DESTINATION
43  **/
44 
getdflt()45 char			*getdflt ()
46 {
47 	char			*name;
48 
49 	if ((name = getdefault()))
50 		return (name);
51 	else
52 		return ("");
53 }
54 
55 /**
56  ** newdflt() - ESTABLISH NEW DEFAULT DESTINATION
57  **/
58 
newdflt(name)59 void			newdflt (name)
60 	char			*name;
61 {
62 	BEGIN_CRITICAL
63 		if (name && *name && !STREQU(name, NAME_NONE)) {
64 			if (putdefault(name) == -1) {
65 				LP_ERRMSG1 (ERROR, E_ADM_WRDEFAULT, PERROR);
66 				done (1);
67 			}
68 
69 		} else {
70 			if (deldefault() == -1) {
71 				LP_ERRMSG1 (ERROR, E_ADM_WRDEFAULT, PERROR);
72 				done (1);
73 			}
74 
75 		}
76 	END_CRITICAL
77 
78 	return;
79 }
80