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 5*0a44ef6dSjacobs * Common Development and Distribution License (the "License"). 6*0a44ef6dSjacobs * 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 /* 23*0a44ef6dSjacobs * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*0a44ef6dSjacobs /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*0a44ef6dSjacobs /* All Rights Reserved */ 29*0a44ef6dSjacobs 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include "stdio.h" 357c478bd9Sstevel@tonic-gate #include "string.h" 367c478bd9Sstevel@tonic-gate #include "errno.h" 377c478bd9Sstevel@tonic-gate #include "sys/types.h" 387c478bd9Sstevel@tonic-gate #include "stdlib.h" 39*0a44ef6dSjacobs #include <syslog.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #include "lp.h" 427c478bd9Sstevel@tonic-gate #include "printers.h" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate extern struct { 457c478bd9Sstevel@tonic-gate char *v; 467c478bd9Sstevel@tonic-gate short len, 477c478bd9Sstevel@tonic-gate okremote; 487c478bd9Sstevel@tonic-gate } prtrheadings[]; 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /** 517c478bd9Sstevel@tonic-gate ** getprinter() - EXTRACT PRINTER STRUCTURE FROM DISK FILE 527c478bd9Sstevel@tonic-gate **/ 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate PRINTER * 557c478bd9Sstevel@tonic-gate getprinter(char *name) 567c478bd9Sstevel@tonic-gate { 577c478bd9Sstevel@tonic-gate static long lastdir = -1; 587c478bd9Sstevel@tonic-gate 59*0a44ef6dSjacobs PRINTER *prp; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate char buf[BUFSIZ]; 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate short daisy; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate int fld; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate int fd; 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate FALERT *pa; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate register char * p; 727c478bd9Sstevel@tonic-gate register char ** pp; 737c478bd9Sstevel@tonic-gate register char *** ppp; 747c478bd9Sstevel@tonic-gate register char * path; 757c478bd9Sstevel@tonic-gate int isNameAll; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate if (!name || !*name) { 807c478bd9Sstevel@tonic-gate errno = EINVAL; 817c478bd9Sstevel@tonic-gate return (0); 827c478bd9Sstevel@tonic-gate } 837c478bd9Sstevel@tonic-gate 84*0a44ef6dSjacobs syslog(LOG_DEBUG, "getprinter(%s)", name ? name : ""); 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * Getting ``all''? If so, jump into the directory 877c478bd9Sstevel@tonic-gate * wherever we left off. 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate isNameAll = STREQU(NAME_ALL, name); 907c478bd9Sstevel@tonic-gate for (; ; ) { 917c478bd9Sstevel@tonic-gate /* fix for bug 1117241 927c478bd9Sstevel@tonic-gate * occasionally when a printer is removed, a printer directory 937c478bd9Sstevel@tonic-gate * is left behind, but the CONFIGFILE is removed. In this 947c478bd9Sstevel@tonic-gate * case this directory terminates the search for additional 957c478bd9Sstevel@tonic-gate * printers as we have been returning 0 in this case. 967c478bd9Sstevel@tonic-gate * Now, we loop back and try the next directory until 977c478bd9Sstevel@tonic-gate * we have no more directories or we find a directory with 987c478bd9Sstevel@tonic-gate * a CONFIGFILE 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate if (isNameAll) { 1017c478bd9Sstevel@tonic-gate if (!(name = next_dir(Lp_A_Printers, &lastdir))) 1027c478bd9Sstevel@tonic-gate return (0); 1037c478bd9Sstevel@tonic-gate } else 1047c478bd9Sstevel@tonic-gate lastdir = -1; 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * Get the printer configuration information. 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate path = getprinterfile(name, CONFIGFILE); 1117c478bd9Sstevel@tonic-gate if (!path) { 1127c478bd9Sstevel@tonic-gate if (isNameAll) 1137c478bd9Sstevel@tonic-gate Free(name); 1147c478bd9Sstevel@tonic-gate return (0); 1157c478bd9Sstevel@tonic-gate } 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate if ((fd = open_locked(path, "r", 0)) < 0) { 1187c478bd9Sstevel@tonic-gate Free(path); /* 1197c478bd9Sstevel@tonic-gate * go around to loop again for 1207c478bd9Sstevel@tonic-gate * NAME_ALL case 1217c478bd9Sstevel@tonic-gate */ 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate if (!isNameAll) /* fix for bug 1117241 */ 1247c478bd9Sstevel@tonic-gate return(0); 1257c478bd9Sstevel@tonic-gate else 1267c478bd9Sstevel@tonic-gate Free(name); 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate else 1297c478bd9Sstevel@tonic-gate break; 1307c478bd9Sstevel@tonic-gate } 1317c478bd9Sstevel@tonic-gate Free (path); 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate /* 1347c478bd9Sstevel@tonic-gate * Initialize the entire structure, to ensure no random 1357c478bd9Sstevel@tonic-gate * values get in it. However, make sure some values won't 1367c478bd9Sstevel@tonic-gate * be null or empty. Do the latter here as opposed to 1377c478bd9Sstevel@tonic-gate * after reading the file, because sometimes the file 1387c478bd9Sstevel@tonic-gate * contains an empty header to FORCE a null/empty value. 1397c478bd9Sstevel@tonic-gate */ 140*0a44ef6dSjacobs prp = calloc(sizeof (*prp), 1); 141*0a44ef6dSjacobs prp->name = Strdup(name); 1427c478bd9Sstevel@tonic-gate if (isNameAll) 1437c478bd9Sstevel@tonic-gate Free(name); 144*0a44ef6dSjacobs prp->printer_types = getlist(NAME_UNKNOWN, LP_WS, LP_SEP); 145*0a44ef6dSjacobs prp->input_types = getlist(NAME_SIMPLE, LP_WS, LP_SEP); 1467c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES) 147*0a44ef6dSjacobs prp->modules = getlist(NAME_DEFAULT, LP_WS, LP_SEP); 1487c478bd9Sstevel@tonic-gate #endif 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate /* 1517c478bd9Sstevel@tonic-gate * Read the file. 1527c478bd9Sstevel@tonic-gate */ 1537c478bd9Sstevel@tonic-gate errno = 0; 1547c478bd9Sstevel@tonic-gate while (fdgets(buf, BUFSIZ, fd) != NULL) { 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate buf[strlen(buf) - 1] = 0; 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate for (fld = 0; fld < PR_MAX; fld++) 1597c478bd9Sstevel@tonic-gate if ( 1607c478bd9Sstevel@tonic-gate prtrheadings[fld].v 1617c478bd9Sstevel@tonic-gate && prtrheadings[fld].len 1627c478bd9Sstevel@tonic-gate && STRNEQU( 1637c478bd9Sstevel@tonic-gate buf, 1647c478bd9Sstevel@tonic-gate prtrheadings[fld].v, 1657c478bd9Sstevel@tonic-gate prtrheadings[fld].len 1667c478bd9Sstevel@tonic-gate ) 1677c478bd9Sstevel@tonic-gate ) { 1687c478bd9Sstevel@tonic-gate p = buf + prtrheadings[fld].len; 1697c478bd9Sstevel@tonic-gate while (*p && *p == ' ') 1707c478bd9Sstevel@tonic-gate p++; 1717c478bd9Sstevel@tonic-gate break; 1727c478bd9Sstevel@tonic-gate } 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate /* 1757c478bd9Sstevel@tonic-gate * To allow future extensions to not impact applications 1767c478bd9Sstevel@tonic-gate * using old versions of this routine, ignore strange 1777c478bd9Sstevel@tonic-gate * fields. 1787c478bd9Sstevel@tonic-gate */ 1797c478bd9Sstevel@tonic-gate if (fld >= PR_MAX) 1807c478bd9Sstevel@tonic-gate continue; 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate switch (fld) { 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate case PR_BAN: 1857c478bd9Sstevel@tonic-gate if ((pp = getlist(p, LP_WS, ":"))) { 1867c478bd9Sstevel@tonic-gate if (pp[0] != NULL) { 1877c478bd9Sstevel@tonic-gate if (strcmp(pp[0], NAME_OPTIONAL) == 0) 188*0a44ef6dSjacobs prp->banner = BAN_OPTIONAL; 1897c478bd9Sstevel@tonic-gate else if (strcmp(pp[0], NAME_OFF) == 0) 190*0a44ef6dSjacobs prp->banner = BAN_NEVER; 1917c478bd9Sstevel@tonic-gate else if (strcmp(pp[0], NAME_ON) == 0) 192*0a44ef6dSjacobs prp->banner = BAN_ALWAYS; 1937c478bd9Sstevel@tonic-gate else /* default to the LP default */ 194*0a44ef6dSjacobs prp->banner = BAN_ALWAYS; 1957c478bd9Sstevel@tonic-gate } 1967c478bd9Sstevel@tonic-gate if (pp[1] && CS_STREQU(pp[1], NAME_ALWAYS)) 197*0a44ef6dSjacobs prp->banner |= BAN_ALWAYS; 1987c478bd9Sstevel@tonic-gate freelist (pp); 1997c478bd9Sstevel@tonic-gate } 2007c478bd9Sstevel@tonic-gate break; 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate case PR_LOGIN: 203*0a44ef6dSjacobs prp->login = LOG_IN; 2047c478bd9Sstevel@tonic-gate break; 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate case PR_CPI: 207*0a44ef6dSjacobs prp->cpi = getcpi(p); 2087c478bd9Sstevel@tonic-gate break; 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate case PR_LPI: 211*0a44ef6dSjacobs prp->lpi = getsdn(p); 2127c478bd9Sstevel@tonic-gate break; 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate case PR_LEN: 215*0a44ef6dSjacobs prp->plen = getsdn(p); 2167c478bd9Sstevel@tonic-gate break; 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate case PR_WIDTH: 219*0a44ef6dSjacobs prp->pwid = getsdn(p); 2207c478bd9Sstevel@tonic-gate break; 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate case PR_CS: 223*0a44ef6dSjacobs ppp = &(prp->char_sets); 2247c478bd9Sstevel@tonic-gate goto CharStarStar; 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate case PR_ITYPES: 227*0a44ef6dSjacobs ppp = &(prp->input_types); 2287c478bd9Sstevel@tonic-gate CharStarStar: if (*ppp) 2297c478bd9Sstevel@tonic-gate freelist (*ppp); 2307c478bd9Sstevel@tonic-gate *ppp = getlist(p, LP_WS, LP_SEP); 2317c478bd9Sstevel@tonic-gate break; 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate case PR_DEV: 234*0a44ef6dSjacobs pp = &(prp->device); 2357c478bd9Sstevel@tonic-gate goto CharStar; 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate case PR_DIAL: 238*0a44ef6dSjacobs pp = &(prp->dial_info); 2397c478bd9Sstevel@tonic-gate goto CharStar; 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate case PR_RECOV: 242*0a44ef6dSjacobs pp = &(prp->fault_rec); 2437c478bd9Sstevel@tonic-gate goto CharStar; 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate case PR_INTFC: 246*0a44ef6dSjacobs pp = &(prp->interface); 2477c478bd9Sstevel@tonic-gate goto CharStar; 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate case PR_PTYPE: 250*0a44ef6dSjacobs ppp = &(prp->printer_types); 2517c478bd9Sstevel@tonic-gate goto CharStarStar; 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate case PR_REMOTE: 254*0a44ef6dSjacobs pp = &(prp->remote); 2557c478bd9Sstevel@tonic-gate goto CharStar; 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate case PR_SPEED: 258*0a44ef6dSjacobs pp = &(prp->speed); 2597c478bd9Sstevel@tonic-gate goto CharStar; 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate case PR_STTY: 262*0a44ef6dSjacobs pp = &(prp->stty); 2637c478bd9Sstevel@tonic-gate CharStar: if (*pp) 2647c478bd9Sstevel@tonic-gate Free (*pp); 2657c478bd9Sstevel@tonic-gate *pp = Strdup(p); 2667c478bd9Sstevel@tonic-gate break; 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES) 2697c478bd9Sstevel@tonic-gate case PR_MODULES: 270*0a44ef6dSjacobs ppp = &(prp->modules); 2717c478bd9Sstevel@tonic-gate goto CharStarStar; 2727c478bd9Sstevel@tonic-gate #endif 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate case PR_OPTIONS: 275*0a44ef6dSjacobs ppp = &(prp->options); 2767c478bd9Sstevel@tonic-gate goto CharStarStar; 2777c478bd9Sstevel@tonic-gate break; 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate case PR_PPD: 2807c478bd9Sstevel@tonic-gate { 281*0a44ef6dSjacobs pp = &(prp->ppd); 2827c478bd9Sstevel@tonic-gate goto CharStar; 2837c478bd9Sstevel@tonic-gate } 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate } 2877c478bd9Sstevel@tonic-gate if (errno != 0) { 2887c478bd9Sstevel@tonic-gate int save_errno = errno; 2897c478bd9Sstevel@tonic-gate 290*0a44ef6dSjacobs freeprinter (prp); 2917c478bd9Sstevel@tonic-gate close(fd); 2927c478bd9Sstevel@tonic-gate errno = save_errno; 2937c478bd9Sstevel@tonic-gate return (0); 2947c478bd9Sstevel@tonic-gate } 2957c478bd9Sstevel@tonic-gate close(fd); 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate /* 2987c478bd9Sstevel@tonic-gate * Get the printer description (if it exists). 2997c478bd9Sstevel@tonic-gate */ 300*0a44ef6dSjacobs if (!(path = getprinterfile(prp->name, COMMENTFILE))) 3017c478bd9Sstevel@tonic-gate return (0); 302*0a44ef6dSjacobs if (!(prp->description = loadstring(path)) && errno != ENOENT) { 3037c478bd9Sstevel@tonic-gate Free (path); 304*0a44ef6dSjacobs freeprinter (prp); 3057c478bd9Sstevel@tonic-gate return (0); 3067c478bd9Sstevel@tonic-gate } 3077c478bd9Sstevel@tonic-gate Free (path); 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate /* 3107c478bd9Sstevel@tonic-gate * Get the information for the alert. Don't fail if we can't 3117c478bd9Sstevel@tonic-gate * read it because of access permission UNLESS we're "root" 3127c478bd9Sstevel@tonic-gate * or "lp" 3137c478bd9Sstevel@tonic-gate */ 314*0a44ef6dSjacobs if (!(pa = getalert(Lp_A_Printers, prp->name))) { 3157c478bd9Sstevel@tonic-gate if ( 3167c478bd9Sstevel@tonic-gate errno != ENOENT 3177c478bd9Sstevel@tonic-gate && ( 3187c478bd9Sstevel@tonic-gate errno != EACCES 3197c478bd9Sstevel@tonic-gate || !getpid() /* we be root */ 3207c478bd9Sstevel@tonic-gate || STREQU(getname(), LPUSER) /* we be lp */ 3217c478bd9Sstevel@tonic-gate ) 3227c478bd9Sstevel@tonic-gate ) { 323*0a44ef6dSjacobs freeprinter (prp); 3247c478bd9Sstevel@tonic-gate return (0); 3257c478bd9Sstevel@tonic-gate } 3267c478bd9Sstevel@tonic-gate } else 327*0a44ef6dSjacobs prp->fault_alert = *pa; 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate /* 3307c478bd9Sstevel@tonic-gate * Now go through the structure and see if we have 3317c478bd9Sstevel@tonic-gate * anything strange. 3327c478bd9Sstevel@tonic-gate */ 333*0a44ef6dSjacobs if (!okprinter(prp->name, prp, 0)) { 334*0a44ef6dSjacobs freeprinter (prp); 3357c478bd9Sstevel@tonic-gate errno = EBADF; 3367c478bd9Sstevel@tonic-gate return (0); 3377c478bd9Sstevel@tonic-gate } 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate /* 3407c478bd9Sstevel@tonic-gate * Just in case somebody tried to pull a fast one 3417c478bd9Sstevel@tonic-gate * by giving a printer type header by itself.... 3427c478bd9Sstevel@tonic-gate */ 343*0a44ef6dSjacobs if (!prp->printer_types) 344*0a44ef6dSjacobs prp->printer_types = getlist(NAME_UNKNOWN, LP_WS, LP_SEP); 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate /* 3477c478bd9Sstevel@tonic-gate * If there are more than one printer type, then we can't 3487c478bd9Sstevel@tonic-gate * have any input types, except perhaps ``simple''. 3497c478bd9Sstevel@tonic-gate */ 3507c478bd9Sstevel@tonic-gate if ( 351*0a44ef6dSjacobs lenlist(prp->printer_types) > 1 352*0a44ef6dSjacobs && prp->input_types 3537c478bd9Sstevel@tonic-gate && ( 354*0a44ef6dSjacobs lenlist(prp->input_types) > 1 355*0a44ef6dSjacobs || !STREQU(NAME_SIMPLE, *prp->input_types) 3567c478bd9Sstevel@tonic-gate ) 3577c478bd9Sstevel@tonic-gate ) { 358*0a44ef6dSjacobs freeprinter (prp); 3597c478bd9Sstevel@tonic-gate badprinter = BAD_ITYPES; 3607c478bd9Sstevel@tonic-gate errno = EBADF; 3617c478bd9Sstevel@tonic-gate return (0); 3627c478bd9Sstevel@tonic-gate } 3637c478bd9Sstevel@tonic-gate 3647c478bd9Sstevel@tonic-gate /* 3657c478bd9Sstevel@tonic-gate * If there are more than one printer types, none can 3667c478bd9Sstevel@tonic-gate * be ``unknown''. 3677c478bd9Sstevel@tonic-gate */ 3687c478bd9Sstevel@tonic-gate if ( 369*0a44ef6dSjacobs lenlist(prp->printer_types) > 1 370*0a44ef6dSjacobs && searchlist(NAME_UNKNOWN, prp->printer_types) 3717c478bd9Sstevel@tonic-gate ) { 372*0a44ef6dSjacobs freeprinter (prp); 3737c478bd9Sstevel@tonic-gate badprinter = BAD_PTYPES; 3747c478bd9Sstevel@tonic-gate errno = EBADF; 3757c478bd9Sstevel@tonic-gate return (0); 3767c478bd9Sstevel@tonic-gate } 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate /* 3797c478bd9Sstevel@tonic-gate * All the printer types had better agree on whether the 3807c478bd9Sstevel@tonic-gate * printer takes print wheels! 3817c478bd9Sstevel@tonic-gate */ 382*0a44ef6dSjacobs prp->daisy = -1; 383*0a44ef6dSjacobs for (pp = prp->printer_types; *pp; pp++) { 3847c478bd9Sstevel@tonic-gate tidbit (*pp, "daisy", &daisy); 3857c478bd9Sstevel@tonic-gate if (daisy == -1) 3867c478bd9Sstevel@tonic-gate daisy = 0; 387*0a44ef6dSjacobs if (prp->daisy == -1) 388*0a44ef6dSjacobs prp->daisy = daisy; 389*0a44ef6dSjacobs else if (prp->daisy != daisy) { 390*0a44ef6dSjacobs freeprinter (prp); 3917c478bd9Sstevel@tonic-gate badprinter = BAD_DAISY; 3927c478bd9Sstevel@tonic-gate errno = EBADF; 3937c478bd9Sstevel@tonic-gate return (0); 3947c478bd9Sstevel@tonic-gate } 3957c478bd9Sstevel@tonic-gate } 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate /* 3987c478bd9Sstevel@tonic-gate * Help out those who are still using the obsolete 3997c478bd9Sstevel@tonic-gate * "printer_type" member. 4007c478bd9Sstevel@tonic-gate */ 401*0a44ef6dSjacobs prp->printer_type = Strdup(*prp->printer_types); 4027c478bd9Sstevel@tonic-gate 403*0a44ef6dSjacobs return (prp); 4047c478bd9Sstevel@tonic-gate } 405