17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
50a44ef6dSjacobs * Common Development and Distribution License (the "License").
60a44ef6dSjacobs * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate
227c478bd9Sstevel@tonic-gate /*
230a44ef6dSjacobs * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
270a44ef6dSjacobs /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
280a44ef6dSjacobs /* All Rights Reserved */
290a44ef6dSjacobs
307c478bd9Sstevel@tonic-gate /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate #include "stdio.h"
337c478bd9Sstevel@tonic-gate #include "string.h"
347c478bd9Sstevel@tonic-gate #include "errno.h"
357c478bd9Sstevel@tonic-gate #include "sys/types.h"
367c478bd9Sstevel@tonic-gate #include "stdlib.h"
370a44ef6dSjacobs #include <syslog.h>
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate #include "lp.h"
407c478bd9Sstevel@tonic-gate #include "printers.h"
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate extern struct {
437c478bd9Sstevel@tonic-gate char *v;
447c478bd9Sstevel@tonic-gate short len,
457c478bd9Sstevel@tonic-gate okremote;
467c478bd9Sstevel@tonic-gate } prtrheadings[];
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate /**
497c478bd9Sstevel@tonic-gate ** getprinter() - EXTRACT PRINTER STRUCTURE FROM DISK FILE
507c478bd9Sstevel@tonic-gate **/
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate PRINTER *
getprinter(char * name)537c478bd9Sstevel@tonic-gate getprinter(char *name)
547c478bd9Sstevel@tonic-gate {
557c478bd9Sstevel@tonic-gate static long lastdir = -1;
567c478bd9Sstevel@tonic-gate
570a44ef6dSjacobs PRINTER *prp;
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate char buf[BUFSIZ];
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate short daisy;
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate int fld;
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate int fd;
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate FALERT *pa;
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gate register char * p;
707c478bd9Sstevel@tonic-gate register char ** pp;
717c478bd9Sstevel@tonic-gate register char *** ppp;
727c478bd9Sstevel@tonic-gate register char * path;
737c478bd9Sstevel@tonic-gate int isNameAll;
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate if (!name || !*name) {
787c478bd9Sstevel@tonic-gate errno = EINVAL;
797c478bd9Sstevel@tonic-gate return (0);
807c478bd9Sstevel@tonic-gate }
817c478bd9Sstevel@tonic-gate
820a44ef6dSjacobs syslog(LOG_DEBUG, "getprinter(%s)", name ? name : "");
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate * Getting ``all''? If so, jump into the directory
857c478bd9Sstevel@tonic-gate * wherever we left off.
867c478bd9Sstevel@tonic-gate */
877c478bd9Sstevel@tonic-gate isNameAll = STREQU(NAME_ALL, name);
88*2a8bcb4eSToomas Soome for (; ; ) {
89*2a8bcb4eSToomas Soome /* fix for bug 1117241
907c478bd9Sstevel@tonic-gate * occasionally when a printer is removed, a printer directory
917c478bd9Sstevel@tonic-gate * is left behind, but the CONFIGFILE is removed. In this
927c478bd9Sstevel@tonic-gate * case this directory terminates the search for additional
937c478bd9Sstevel@tonic-gate * printers as we have been returning 0 in this case.
947c478bd9Sstevel@tonic-gate * Now, we loop back and try the next directory until
957c478bd9Sstevel@tonic-gate * we have no more directories or we find a directory with
96*2a8bcb4eSToomas Soome * a CONFIGFILE
977c478bd9Sstevel@tonic-gate */
987c478bd9Sstevel@tonic-gate if (isNameAll) {
997c478bd9Sstevel@tonic-gate if (!(name = next_dir(Lp_A_Printers, &lastdir)))
1007c478bd9Sstevel@tonic-gate return (0);
1017c478bd9Sstevel@tonic-gate } else
1027c478bd9Sstevel@tonic-gate lastdir = -1;
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate /*
1057c478bd9Sstevel@tonic-gate * Get the printer configuration information.
1067c478bd9Sstevel@tonic-gate */
1077c478bd9Sstevel@tonic-gate
1087c478bd9Sstevel@tonic-gate path = getprinterfile(name, CONFIGFILE);
1097c478bd9Sstevel@tonic-gate if (!path) {
1107c478bd9Sstevel@tonic-gate if (isNameAll)
1117c478bd9Sstevel@tonic-gate Free(name);
1127c478bd9Sstevel@tonic-gate return (0);
1137c478bd9Sstevel@tonic-gate }
1147c478bd9Sstevel@tonic-gate
1157c478bd9Sstevel@tonic-gate if ((fd = open_locked(path, "r", 0)) < 0) {
1167c478bd9Sstevel@tonic-gate Free(path); /*
1177c478bd9Sstevel@tonic-gate * go around to loop again for
1187c478bd9Sstevel@tonic-gate * NAME_ALL case
1197c478bd9Sstevel@tonic-gate */
1207c478bd9Sstevel@tonic-gate
1217c478bd9Sstevel@tonic-gate if (!isNameAll) /* fix for bug 1117241 */
1227c478bd9Sstevel@tonic-gate return(0);
1237c478bd9Sstevel@tonic-gate else
1247c478bd9Sstevel@tonic-gate Free(name);
1257c478bd9Sstevel@tonic-gate }
1267c478bd9Sstevel@tonic-gate else
1277c478bd9Sstevel@tonic-gate break;
1287c478bd9Sstevel@tonic-gate }
1297c478bd9Sstevel@tonic-gate Free (path);
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate /*
1327c478bd9Sstevel@tonic-gate * Initialize the entire structure, to ensure no random
1337c478bd9Sstevel@tonic-gate * values get in it. However, make sure some values won't
1347c478bd9Sstevel@tonic-gate * be null or empty. Do the latter here as opposed to
1357c478bd9Sstevel@tonic-gate * after reading the file, because sometimes the file
1367c478bd9Sstevel@tonic-gate * contains an empty header to FORCE a null/empty value.
1377c478bd9Sstevel@tonic-gate */
1380a44ef6dSjacobs prp = calloc(sizeof (*prp), 1);
1390a44ef6dSjacobs prp->name = Strdup(name);
1407c478bd9Sstevel@tonic-gate if (isNameAll)
1417c478bd9Sstevel@tonic-gate Free(name);
1420a44ef6dSjacobs prp->printer_types = getlist(NAME_UNKNOWN, LP_WS, LP_SEP);
1430a44ef6dSjacobs prp->input_types = getlist(NAME_SIMPLE, LP_WS, LP_SEP);
1447c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES)
1450a44ef6dSjacobs prp->modules = getlist(NAME_DEFAULT, LP_WS, LP_SEP);
1467c478bd9Sstevel@tonic-gate #endif
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate * Read the file.
1507c478bd9Sstevel@tonic-gate */
1517c478bd9Sstevel@tonic-gate errno = 0;
1527c478bd9Sstevel@tonic-gate while (fdgets(buf, BUFSIZ, fd) != NULL) {
1537c478bd9Sstevel@tonic-gate
1547c478bd9Sstevel@tonic-gate buf[strlen(buf) - 1] = 0;
1557c478bd9Sstevel@tonic-gate
1567c478bd9Sstevel@tonic-gate for (fld = 0; fld < PR_MAX; fld++)
1577c478bd9Sstevel@tonic-gate if (
1587c478bd9Sstevel@tonic-gate prtrheadings[fld].v
1597c478bd9Sstevel@tonic-gate && prtrheadings[fld].len
1607c478bd9Sstevel@tonic-gate && STRNEQU(
1617c478bd9Sstevel@tonic-gate buf,
1627c478bd9Sstevel@tonic-gate prtrheadings[fld].v,
1637c478bd9Sstevel@tonic-gate prtrheadings[fld].len
1647c478bd9Sstevel@tonic-gate )
1657c478bd9Sstevel@tonic-gate ) {
1667c478bd9Sstevel@tonic-gate p = buf + prtrheadings[fld].len;
1677c478bd9Sstevel@tonic-gate while (*p && *p == ' ')
1687c478bd9Sstevel@tonic-gate p++;
1697c478bd9Sstevel@tonic-gate break;
1707c478bd9Sstevel@tonic-gate }
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gate /*
1737c478bd9Sstevel@tonic-gate * To allow future extensions to not impact applications
1747c478bd9Sstevel@tonic-gate * using old versions of this routine, ignore strange
1757c478bd9Sstevel@tonic-gate * fields.
1767c478bd9Sstevel@tonic-gate */
177*2a8bcb4eSToomas Soome if (fld >= PR_MAX)
1787c478bd9Sstevel@tonic-gate continue;
1797c478bd9Sstevel@tonic-gate
1807c478bd9Sstevel@tonic-gate switch (fld) {
1817c478bd9Sstevel@tonic-gate
1827c478bd9Sstevel@tonic-gate case PR_BAN:
1837c478bd9Sstevel@tonic-gate if ((pp = getlist(p, LP_WS, ":"))) {
1847c478bd9Sstevel@tonic-gate if (pp[0] != NULL) {
1857c478bd9Sstevel@tonic-gate if (strcmp(pp[0], NAME_OPTIONAL) == 0)
1860a44ef6dSjacobs prp->banner = BAN_OPTIONAL;
1877c478bd9Sstevel@tonic-gate else if (strcmp(pp[0], NAME_OFF) == 0)
1880a44ef6dSjacobs prp->banner = BAN_NEVER;
1897c478bd9Sstevel@tonic-gate else if (strcmp(pp[0], NAME_ON) == 0)
1900a44ef6dSjacobs prp->banner = BAN_ALWAYS;
1917c478bd9Sstevel@tonic-gate else /* default to the LP default */
1920a44ef6dSjacobs prp->banner = BAN_ALWAYS;
1937c478bd9Sstevel@tonic-gate }
1947c478bd9Sstevel@tonic-gate if (pp[1] && CS_STREQU(pp[1], NAME_ALWAYS))
1950a44ef6dSjacobs prp->banner |= BAN_ALWAYS;
1967c478bd9Sstevel@tonic-gate freelist (pp);
1977c478bd9Sstevel@tonic-gate }
1987c478bd9Sstevel@tonic-gate break;
1997c478bd9Sstevel@tonic-gate
2007c478bd9Sstevel@tonic-gate case PR_LOGIN:
2010a44ef6dSjacobs prp->login = LOG_IN;
2027c478bd9Sstevel@tonic-gate break;
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gate case PR_CPI:
2050a44ef6dSjacobs prp->cpi = getcpi(p);
2067c478bd9Sstevel@tonic-gate break;
2077c478bd9Sstevel@tonic-gate
2087c478bd9Sstevel@tonic-gate case PR_LPI:
2090a44ef6dSjacobs prp->lpi = getsdn(p);
2107c478bd9Sstevel@tonic-gate break;
2117c478bd9Sstevel@tonic-gate
2127c478bd9Sstevel@tonic-gate case PR_LEN:
2130a44ef6dSjacobs prp->plen = getsdn(p);
2147c478bd9Sstevel@tonic-gate break;
2157c478bd9Sstevel@tonic-gate
2167c478bd9Sstevel@tonic-gate case PR_WIDTH:
2170a44ef6dSjacobs prp->pwid = getsdn(p);
2187c478bd9Sstevel@tonic-gate break;
2197c478bd9Sstevel@tonic-gate
2207c478bd9Sstevel@tonic-gate case PR_CS:
2210a44ef6dSjacobs ppp = &(prp->char_sets);
2227c478bd9Sstevel@tonic-gate goto CharStarStar;
2237c478bd9Sstevel@tonic-gate
2247c478bd9Sstevel@tonic-gate case PR_ITYPES:
2250a44ef6dSjacobs ppp = &(prp->input_types);
2267c478bd9Sstevel@tonic-gate CharStarStar: if (*ppp)
2277c478bd9Sstevel@tonic-gate freelist (*ppp);
2287c478bd9Sstevel@tonic-gate *ppp = getlist(p, LP_WS, LP_SEP);
2297c478bd9Sstevel@tonic-gate break;
2307c478bd9Sstevel@tonic-gate
2317c478bd9Sstevel@tonic-gate case PR_DEV:
2320a44ef6dSjacobs pp = &(prp->device);
2337c478bd9Sstevel@tonic-gate goto CharStar;
2347c478bd9Sstevel@tonic-gate
2357c478bd9Sstevel@tonic-gate case PR_DIAL:
2360a44ef6dSjacobs pp = &(prp->dial_info);
2377c478bd9Sstevel@tonic-gate goto CharStar;
2387c478bd9Sstevel@tonic-gate
2397c478bd9Sstevel@tonic-gate case PR_RECOV:
2400a44ef6dSjacobs pp = &(prp->fault_rec);
2417c478bd9Sstevel@tonic-gate goto CharStar;
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate case PR_INTFC:
2440a44ef6dSjacobs pp = &(prp->interface);
2457c478bd9Sstevel@tonic-gate goto CharStar;
2467c478bd9Sstevel@tonic-gate
2477c478bd9Sstevel@tonic-gate case PR_PTYPE:
2480a44ef6dSjacobs ppp = &(prp->printer_types);
2497c478bd9Sstevel@tonic-gate goto CharStarStar;
2507c478bd9Sstevel@tonic-gate
2517c478bd9Sstevel@tonic-gate case PR_REMOTE:
2520a44ef6dSjacobs pp = &(prp->remote);
2537c478bd9Sstevel@tonic-gate goto CharStar;
2547c478bd9Sstevel@tonic-gate
2557c478bd9Sstevel@tonic-gate case PR_SPEED:
2560a44ef6dSjacobs pp = &(prp->speed);
2577c478bd9Sstevel@tonic-gate goto CharStar;
2587c478bd9Sstevel@tonic-gate
2597c478bd9Sstevel@tonic-gate case PR_STTY:
2600a44ef6dSjacobs pp = &(prp->stty);
2617c478bd9Sstevel@tonic-gate CharStar: if (*pp)
2627c478bd9Sstevel@tonic-gate Free (*pp);
2637c478bd9Sstevel@tonic-gate *pp = Strdup(p);
2647c478bd9Sstevel@tonic-gate break;
2657c478bd9Sstevel@tonic-gate
2667c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES)
2677c478bd9Sstevel@tonic-gate case PR_MODULES:
2680a44ef6dSjacobs ppp = &(prp->modules);
2697c478bd9Sstevel@tonic-gate goto CharStarStar;
2707c478bd9Sstevel@tonic-gate #endif
2717c478bd9Sstevel@tonic-gate
2727c478bd9Sstevel@tonic-gate case PR_OPTIONS:
2730a44ef6dSjacobs ppp = &(prp->options);
2747c478bd9Sstevel@tonic-gate goto CharStarStar;
2757c478bd9Sstevel@tonic-gate break;
2767c478bd9Sstevel@tonic-gate
2777c478bd9Sstevel@tonic-gate case PR_PPD:
2787c478bd9Sstevel@tonic-gate {
2790a44ef6dSjacobs pp = &(prp->ppd);
2807c478bd9Sstevel@tonic-gate goto CharStar;
2817c478bd9Sstevel@tonic-gate }
2827c478bd9Sstevel@tonic-gate }
2837c478bd9Sstevel@tonic-gate
2847c478bd9Sstevel@tonic-gate }
2857c478bd9Sstevel@tonic-gate if (errno != 0) {
2867c478bd9Sstevel@tonic-gate int save_errno = errno;
2877c478bd9Sstevel@tonic-gate
2880a44ef6dSjacobs freeprinter (prp);
2897c478bd9Sstevel@tonic-gate close(fd);
2907c478bd9Sstevel@tonic-gate errno = save_errno;
2917c478bd9Sstevel@tonic-gate return (0);
2927c478bd9Sstevel@tonic-gate }
2937c478bd9Sstevel@tonic-gate close(fd);
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate /*
2967c478bd9Sstevel@tonic-gate * Get the printer description (if it exists).
2977c478bd9Sstevel@tonic-gate */
2980a44ef6dSjacobs if (!(path = getprinterfile(prp->name, COMMENTFILE)))
2997c478bd9Sstevel@tonic-gate return (0);
3000a44ef6dSjacobs if (!(prp->description = loadstring(path)) && errno != ENOENT) {
3017c478bd9Sstevel@tonic-gate Free (path);
3020a44ef6dSjacobs freeprinter (prp);
3037c478bd9Sstevel@tonic-gate return (0);
3047c478bd9Sstevel@tonic-gate }
3057c478bd9Sstevel@tonic-gate Free (path);
3067c478bd9Sstevel@tonic-gate
3077c478bd9Sstevel@tonic-gate /*
3087c478bd9Sstevel@tonic-gate * Get the information for the alert. Don't fail if we can't
3097c478bd9Sstevel@tonic-gate * read it because of access permission UNLESS we're "root"
3107c478bd9Sstevel@tonic-gate * or "lp"
3117c478bd9Sstevel@tonic-gate */
3120a44ef6dSjacobs if (!(pa = getalert(Lp_A_Printers, prp->name))) {
3137c478bd9Sstevel@tonic-gate if (
3147c478bd9Sstevel@tonic-gate errno != ENOENT
3157c478bd9Sstevel@tonic-gate && (
3167c478bd9Sstevel@tonic-gate errno != EACCES
3177c478bd9Sstevel@tonic-gate || !getpid() /* we be root */
3187c478bd9Sstevel@tonic-gate || STREQU(getname(), LPUSER) /* we be lp */
3197c478bd9Sstevel@tonic-gate )
3207c478bd9Sstevel@tonic-gate ) {
3210a44ef6dSjacobs freeprinter (prp);
3227c478bd9Sstevel@tonic-gate return (0);
3237c478bd9Sstevel@tonic-gate }
3247c478bd9Sstevel@tonic-gate } else
3250a44ef6dSjacobs prp->fault_alert = *pa;
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate /*
3287c478bd9Sstevel@tonic-gate * Now go through the structure and see if we have
3297c478bd9Sstevel@tonic-gate * anything strange.
3307c478bd9Sstevel@tonic-gate */
3310a44ef6dSjacobs if (!okprinter(prp->name, prp, 0)) {
3320a44ef6dSjacobs freeprinter (prp);
3337c478bd9Sstevel@tonic-gate errno = EBADF;
3347c478bd9Sstevel@tonic-gate return (0);
3357c478bd9Sstevel@tonic-gate }
3367c478bd9Sstevel@tonic-gate
3377c478bd9Sstevel@tonic-gate /*
3387c478bd9Sstevel@tonic-gate * Just in case somebody tried to pull a fast one
3397c478bd9Sstevel@tonic-gate * by giving a printer type header by itself....
3407c478bd9Sstevel@tonic-gate */
3410a44ef6dSjacobs if (!prp->printer_types)
3420a44ef6dSjacobs prp->printer_types = getlist(NAME_UNKNOWN, LP_WS, LP_SEP);
3437c478bd9Sstevel@tonic-gate
3447c478bd9Sstevel@tonic-gate /*
3457c478bd9Sstevel@tonic-gate * If there are more than one printer type, then we can't
3467c478bd9Sstevel@tonic-gate * have any input types, except perhaps ``simple''.
3477c478bd9Sstevel@tonic-gate */
3487c478bd9Sstevel@tonic-gate if (
3490a44ef6dSjacobs lenlist(prp->printer_types) > 1
3500a44ef6dSjacobs && prp->input_types
3517c478bd9Sstevel@tonic-gate && (
3520a44ef6dSjacobs lenlist(prp->input_types) > 1
3530a44ef6dSjacobs || !STREQU(NAME_SIMPLE, *prp->input_types)
3547c478bd9Sstevel@tonic-gate )
3557c478bd9Sstevel@tonic-gate ) {
3560a44ef6dSjacobs freeprinter (prp);
3577c478bd9Sstevel@tonic-gate badprinter = BAD_ITYPES;
3587c478bd9Sstevel@tonic-gate errno = EBADF;
3597c478bd9Sstevel@tonic-gate return (0);
3607c478bd9Sstevel@tonic-gate }
3617c478bd9Sstevel@tonic-gate
3627c478bd9Sstevel@tonic-gate /*
3637c478bd9Sstevel@tonic-gate * If there are more than one printer types, none can
3647c478bd9Sstevel@tonic-gate * be ``unknown''.
3657c478bd9Sstevel@tonic-gate */
3667c478bd9Sstevel@tonic-gate if (
3670a44ef6dSjacobs lenlist(prp->printer_types) > 1
3680a44ef6dSjacobs && searchlist(NAME_UNKNOWN, prp->printer_types)
3697c478bd9Sstevel@tonic-gate ) {
3700a44ef6dSjacobs freeprinter (prp);
3717c478bd9Sstevel@tonic-gate badprinter = BAD_PTYPES;
3727c478bd9Sstevel@tonic-gate errno = EBADF;
3737c478bd9Sstevel@tonic-gate return (0);
3747c478bd9Sstevel@tonic-gate }
3757c478bd9Sstevel@tonic-gate
3767c478bd9Sstevel@tonic-gate /*
3777c478bd9Sstevel@tonic-gate * All the printer types had better agree on whether the
3787c478bd9Sstevel@tonic-gate * printer takes print wheels!
3797c478bd9Sstevel@tonic-gate */
3800a44ef6dSjacobs prp->daisy = -1;
3810a44ef6dSjacobs for (pp = prp->printer_types; *pp; pp++) {
3827c478bd9Sstevel@tonic-gate tidbit (*pp, "daisy", &daisy);
3837c478bd9Sstevel@tonic-gate if (daisy == -1)
3847c478bd9Sstevel@tonic-gate daisy = 0;
3850a44ef6dSjacobs if (prp->daisy == -1)
3860a44ef6dSjacobs prp->daisy = daisy;
3870a44ef6dSjacobs else if (prp->daisy != daisy) {
3880a44ef6dSjacobs freeprinter (prp);
3897c478bd9Sstevel@tonic-gate badprinter = BAD_DAISY;
3907c478bd9Sstevel@tonic-gate errno = EBADF;
3917c478bd9Sstevel@tonic-gate return (0);
3927c478bd9Sstevel@tonic-gate }
3937c478bd9Sstevel@tonic-gate }
3947c478bd9Sstevel@tonic-gate
3957c478bd9Sstevel@tonic-gate /*
3967c478bd9Sstevel@tonic-gate * Help out those who are still using the obsolete
3977c478bd9Sstevel@tonic-gate * "printer_type" member.
3987c478bd9Sstevel@tonic-gate */
3990a44ef6dSjacobs prp->printer_type = Strdup(*prp->printer_types);
4007c478bd9Sstevel@tonic-gate
4010a44ef6dSjacobs return (prp);
4027c478bd9Sstevel@tonic-gate }
403