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
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
23f928ce67Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
27f928ce67Sceastha /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28f928ce67Sceastha /* All Rights Reserved */
29f928ce67Sceastha
307c478bd9Sstevel@tonic-gate #include "ctype.h"
317c478bd9Sstevel@tonic-gate #include "stdio.h"
327c478bd9Sstevel@tonic-gate #include "string.h"
337c478bd9Sstevel@tonic-gate #include "stdlib.h"
347c478bd9Sstevel@tonic-gate #include <libintl.h>
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate #include "lp.h"
377c478bd9Sstevel@tonic-gate #include "printers.h"
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate #define WHO_AM_I I_AM_LPADMIN
407c478bd9Sstevel@tonic-gate #include "oam.h"
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate #include "lpadmin.h"
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate #ifdef LP_USE_PAPI_ATTR
457c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES)
467c478bd9Sstevel@tonic-gate #define OPT_LIST "A:ac:d:D:e:f:F:H:hi:I:lm:Mn:o:p:Q:r:S:s:T:u:U:v:W:x:t:P:"
477c478bd9Sstevel@tonic-gate #else
487c478bd9Sstevel@tonic-gate #define OPT_LIST "A:ac:d:D:e:f:F:hi:I:lm:Mn:o:p:Q:r:S:s:T:u:U:v:W:x:t:P:"
497c478bd9Sstevel@tonic-gate #endif
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate #else
527c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES)
537c478bd9Sstevel@tonic-gate #define OPT_LIST "A:ac:d:D:e:f:F:H:hi:I:lm:Mo:p:Q:r:S:s:T:u:U:v:W:x:t:P:"
547c478bd9Sstevel@tonic-gate #else
557c478bd9Sstevel@tonic-gate #define OPT_LIST "A:ac:d:D:e:f:F:hi:I:lm:Mo:p:Q:r:S:s:T:u:U:v:W:x:t:P:"
567c478bd9Sstevel@tonic-gate #endif
577c478bd9Sstevel@tonic-gate #endif
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate #define MALLOC(pointer) \
607c478bd9Sstevel@tonic-gate if (!(pointer = strdup(optarg))) { \
617c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_MALLOC); \
627c478bd9Sstevel@tonic-gate done (1); \
637c478bd9Sstevel@tonic-gate } else
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate #define REALLOC(pointer) \
667c478bd9Sstevel@tonic-gate if (!(pointer = realloc(pointer, (unsigned) (strlen(pointer) + 1 + strlen(optarg) + 1)))) { \
677c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_MALLOC); \
687c478bd9Sstevel@tonic-gate done (1); \
697c478bd9Sstevel@tonic-gate } else if (strcat(pointer, " ")) \
707c478bd9Sstevel@tonic-gate (void)strcat (pointer, optarg); \
717c478bd9Sstevel@tonic-gate else
727c478bd9Sstevel@tonic-gate
737c478bd9Sstevel@tonic-gate extern char *optarg;
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate extern int optind,
767c478bd9Sstevel@tonic-gate opterr,
777c478bd9Sstevel@tonic-gate optopt;
787c478bd9Sstevel@tonic-gate
797c478bd9Sstevel@tonic-gate extern double strtod();
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate extern long strtol();
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gate int a = 0, /* alignment needed for mount */
847c478bd9Sstevel@tonic-gate banner = -1, /* allow/don't-allow nobanner */
857c478bd9Sstevel@tonic-gate #if defined(DIRECT_ACCESS)
867c478bd9Sstevel@tonic-gate C = 0, /* direct a.o.t. normal access */
877c478bd9Sstevel@tonic-gate #endif
887c478bd9Sstevel@tonic-gate filebreak = 0,
897c478bd9Sstevel@tonic-gate h = 0, /* hardwired terminal */
907c478bd9Sstevel@tonic-gate j = 0, /* do -F just for current job */
917c478bd9Sstevel@tonic-gate l = 0, /* login terminal */
927c478bd9Sstevel@tonic-gate M = 0, /* do mount */
937c478bd9Sstevel@tonic-gate t = 0, /* tray number*/
947c478bd9Sstevel@tonic-gate o = 0, /* some -o options given */
957c478bd9Sstevel@tonic-gate Q = -1, /* queue threshold for alert */
967c478bd9Sstevel@tonic-gate W = -1; /* alert interval */
977c478bd9Sstevel@tonic-gate
987c478bd9Sstevel@tonic-gate char *A = 0, /* alert type */
997c478bd9Sstevel@tonic-gate *c = 0, /* class name */
1007c478bd9Sstevel@tonic-gate *cpi = 0, /* string value of -o cpi= */
1017c478bd9Sstevel@tonic-gate *d = 0, /* default destination */
1027c478bd9Sstevel@tonic-gate *D = 0, /* description */
1037c478bd9Sstevel@tonic-gate *e = 0, /* copy existing interface */
1047c478bd9Sstevel@tonic-gate *f = 0, /* forms list - allow/deny */
1057c478bd9Sstevel@tonic-gate *P = 0, /* paper list */
1067c478bd9Sstevel@tonic-gate *F = 0, /* fault recovery */
1077c478bd9Sstevel@tonic-gate **H = 0, /* list of modules to push */
1087c478bd9Sstevel@tonic-gate *i = 0, /* interface pathname */
1097c478bd9Sstevel@tonic-gate **I = 0, /* content-type-list */
1107c478bd9Sstevel@tonic-gate *length = 0, /* string value of -o length= */
1117c478bd9Sstevel@tonic-gate *lpi = 0, /* string value of -o lpi= */
1127c478bd9Sstevel@tonic-gate *m = 0, /* model name */
1137c478bd9Sstevel@tonic-gate modifications[128], /* list of mods to make */
1147c478bd9Sstevel@tonic-gate #ifdef LP_USE_PAPI_ATTR
1157c478bd9Sstevel@tonic-gate *n_opt = NULL, /* PPD file name */
1167c478bd9Sstevel@tonic-gate #endif
1177c478bd9Sstevel@tonic-gate *p = 0, /* printer name */
1187c478bd9Sstevel@tonic-gate *r = 0, /* class to remove printer from */
1197c478bd9Sstevel@tonic-gate *s = 0, /* system printer is on */
1207c478bd9Sstevel@tonic-gate *stty_opt= 0, /* string value of -o stty= */
1217c478bd9Sstevel@tonic-gate **o_options = 0,/* undefined lpadmin -o options */
1227c478bd9Sstevel@tonic-gate **S = 0, /* -set/print-wheel list */
1237c478bd9Sstevel@tonic-gate **T = 0, /* terminfo names */
1247c478bd9Sstevel@tonic-gate *u = 0, /* user allow/deny list */
1257c478bd9Sstevel@tonic-gate *U = 0, /* dialer_info */
1267c478bd9Sstevel@tonic-gate *v = 0, /* device pathname */
1277c478bd9Sstevel@tonic-gate *width = 0, /* string value of -o width= */
1287c478bd9Sstevel@tonic-gate *x = 0; /* destination to be deleted */
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gate SCALED cpi_sdn = { 0, 0 },
1317c478bd9Sstevel@tonic-gate length_sdn = { 0, 0 },
1327c478bd9Sstevel@tonic-gate lpi_sdn = { 0, 0 },
1337c478bd9Sstevel@tonic-gate width_sdn = { 0, 0 };
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate static char *modp = modifications;
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gate static void oparse();
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate static char * empty_list[] = { 0 };
1407c478bd9Sstevel@tonic-gate
1417c478bd9Sstevel@tonic-gate /**
1427c478bd9Sstevel@tonic-gate ** options() - PARSE COMMAND LINE ARGUMENTS INTO OPTIONS
1437c478bd9Sstevel@tonic-gate **/
1447c478bd9Sstevel@tonic-gate
options(argc,argv)1457c478bd9Sstevel@tonic-gate void options (argc, argv)
1467c478bd9Sstevel@tonic-gate int argc;
1477c478bd9Sstevel@tonic-gate char *argv[];
1487c478bd9Sstevel@tonic-gate {
1497c478bd9Sstevel@tonic-gate int optsw,
1507c478bd9Sstevel@tonic-gate ac,
1517c478bd9Sstevel@tonic-gate Aflag = 0;
1527c478bd9Sstevel@tonic-gate
1537c478bd9Sstevel@tonic-gate char *cp,
1547c478bd9Sstevel@tonic-gate *rest,
1557c478bd9Sstevel@tonic-gate **av;
156268ffd3aSRichard Lowe char stroptsw[] = "-X";
1577c478bd9Sstevel@tonic-gate
1587c478bd9Sstevel@tonic-gate #if defined(__STDC__)
1597c478bd9Sstevel@tonic-gate typedef char * const * stupid; /* dumb-ass ANSI C */
1607c478bd9Sstevel@tonic-gate #else
1617c478bd9Sstevel@tonic-gate typedef char ** stupid;
1627c478bd9Sstevel@tonic-gate #endif
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate
1657c478bd9Sstevel@tonic-gate /*
1667c478bd9Sstevel@tonic-gate * Add a fake value to the end of the "argv" list, to
1677c478bd9Sstevel@tonic-gate * catch the case that a valued-option comes last.
1687c478bd9Sstevel@tonic-gate */
1697c478bd9Sstevel@tonic-gate av = malloc((argc + 2) * sizeof(char *));
1707c478bd9Sstevel@tonic-gate for (ac = 0; ac < argc; ac++)
1717c478bd9Sstevel@tonic-gate av[ac] = argv[ac];
1727c478bd9Sstevel@tonic-gate av[ac++] = "--";
1737c478bd9Sstevel@tonic-gate
1747c478bd9Sstevel@tonic-gate opterr = 0;
1757c478bd9Sstevel@tonic-gate while ((optsw = getopt(ac, (stupid)av, OPT_LIST)) != EOF) {
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate switch (optsw) {
1787c478bd9Sstevel@tonic-gate
1797c478bd9Sstevel@tonic-gate /*
1807c478bd9Sstevel@tonic-gate * These options MAY take a value. Check the value;
1817c478bd9Sstevel@tonic-gate * if it begins with a '-', assume it's really the next
1827c478bd9Sstevel@tonic-gate * option.
1837c478bd9Sstevel@tonic-gate */
1847c478bd9Sstevel@tonic-gate case 'd':
1857c478bd9Sstevel@tonic-gate case 'p': /* MR bl87-27863 */
1867c478bd9Sstevel@tonic-gate case 'I':
1877c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES)
1887c478bd9Sstevel@tonic-gate case 'H':
1897c478bd9Sstevel@tonic-gate #endif
1907c478bd9Sstevel@tonic-gate if (*optarg == '-') {
1917c478bd9Sstevel@tonic-gate /*
1927c478bd9Sstevel@tonic-gate * This will work if we were given
1937c478bd9Sstevel@tonic-gate *
1947c478bd9Sstevel@tonic-gate * -x -foo
1957c478bd9Sstevel@tonic-gate *
1967c478bd9Sstevel@tonic-gate * but would fail if we were given
1977c478bd9Sstevel@tonic-gate *
1987c478bd9Sstevel@tonic-gate * -x-foo
1997c478bd9Sstevel@tonic-gate */
2007c478bd9Sstevel@tonic-gate optind--;
2017c478bd9Sstevel@tonic-gate switch (optsw) {
2027c478bd9Sstevel@tonic-gate case 'd':
2037c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES)
2047c478bd9Sstevel@tonic-gate case 'H':
2057c478bd9Sstevel@tonic-gate #endif
2067c478bd9Sstevel@tonic-gate optarg = NAME_NONE;
2077c478bd9Sstevel@tonic-gate break;
2087c478bd9Sstevel@tonic-gate case 'p':
2097c478bd9Sstevel@tonic-gate optarg = NAME_ALL;
2107c478bd9Sstevel@tonic-gate break;
2117c478bd9Sstevel@tonic-gate case 'I':
2127c478bd9Sstevel@tonic-gate optarg = 0;
2137c478bd9Sstevel@tonic-gate break;
2147c478bd9Sstevel@tonic-gate }
2157c478bd9Sstevel@tonic-gate }
2167c478bd9Sstevel@tonic-gate break;
2177c478bd9Sstevel@tonic-gate
2187c478bd9Sstevel@tonic-gate /*
2197c478bd9Sstevel@tonic-gate * These options MUST have a value. Check the value;
2207c478bd9Sstevel@tonic-gate * if it begins with a dash or is null, complain.
2217c478bd9Sstevel@tonic-gate */
2227c478bd9Sstevel@tonic-gate case 'Q':
2237c478bd9Sstevel@tonic-gate case 'W':
2247c478bd9Sstevel@tonic-gate case 't':
2257c478bd9Sstevel@tonic-gate /*
2267c478bd9Sstevel@tonic-gate * These options take numeric values, which might
2277c478bd9Sstevel@tonic-gate * be negative. Negative values are handled later,
2287c478bd9Sstevel@tonic-gate * but here we just screen them.
2297c478bd9Sstevel@tonic-gate */
2307c478bd9Sstevel@tonic-gate (void)strtol(optarg, &rest, 10);
2317c478bd9Sstevel@tonic-gate if (!rest || !*rest)
2327c478bd9Sstevel@tonic-gate break;
2337c478bd9Sstevel@tonic-gate /*FALLTHROUGH*/
2347c478bd9Sstevel@tonic-gate case 'A':
2357c478bd9Sstevel@tonic-gate case 'c':
2367c478bd9Sstevel@tonic-gate case 'e':
2377c478bd9Sstevel@tonic-gate case 'f':
2387c478bd9Sstevel@tonic-gate case 'P':
2397c478bd9Sstevel@tonic-gate case 'F':
2407c478bd9Sstevel@tonic-gate case 'i':
2417c478bd9Sstevel@tonic-gate case 'm':
2427c478bd9Sstevel@tonic-gate #ifdef LP_USE_PAPI_ATTR
2437c478bd9Sstevel@tonic-gate case 'n':
2447c478bd9Sstevel@tonic-gate #endif
2457c478bd9Sstevel@tonic-gate case 'o':
2467c478bd9Sstevel@tonic-gate /* case 'p': */ /* MR bl87-27863 */
2477c478bd9Sstevel@tonic-gate case 'r':
2487c478bd9Sstevel@tonic-gate case 'S':
2497c478bd9Sstevel@tonic-gate case 's':
2507c478bd9Sstevel@tonic-gate case 'T':
2517c478bd9Sstevel@tonic-gate case 'u':
2527c478bd9Sstevel@tonic-gate case 'U':
2537c478bd9Sstevel@tonic-gate case 'v':
2547c478bd9Sstevel@tonic-gate case 'x':
2557c478bd9Sstevel@tonic-gate /*
2567c478bd9Sstevel@tonic-gate * These options also must have non-null args.
2577c478bd9Sstevel@tonic-gate */
2587c478bd9Sstevel@tonic-gate if (!*optarg) {
259f928ce67Sceastha stroptsw[1] = optsw;
260268ffd3aSRichard Lowe LP_ERRMSG1 (ERROR, E_LP_NULLARG, stroptsw);
2617c478bd9Sstevel@tonic-gate done (1);
2627c478bd9Sstevel@tonic-gate }
2637c478bd9Sstevel@tonic-gate if (*optarg == '-') {
264f928ce67Sceastha stroptsw[1] = optsw;
265268ffd3aSRichard Lowe LP_ERRMSG1 (ERROR, E_LP_OPTARG, stroptsw);
2667c478bd9Sstevel@tonic-gate done (1);
2677c478bd9Sstevel@tonic-gate }
2687c478bd9Sstevel@tonic-gate if (optsw == 'A')
2697c478bd9Sstevel@tonic-gate Aflag++;
2707c478bd9Sstevel@tonic-gate break;
2717c478bd9Sstevel@tonic-gate case 'D':
2727c478bd9Sstevel@tonic-gate /*
2737c478bd9Sstevel@tonic-gate * These options can have a null arg.
2747c478bd9Sstevel@tonic-gate */
2757c478bd9Sstevel@tonic-gate if (*optarg == '-') {
276f928ce67Sceastha stroptsw[1] = optsw;
277268ffd3aSRichard Lowe LP_ERRMSG1 (ERROR, E_LP_OPTARG, stroptsw);
2787c478bd9Sstevel@tonic-gate done (1);
2797c478bd9Sstevel@tonic-gate }
2807c478bd9Sstevel@tonic-gate break;
2817c478bd9Sstevel@tonic-gate }
282*55fea89dSDan Cross
2837c478bd9Sstevel@tonic-gate switch (optsw) {
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate case 'a': /* alignment pattern needed for mount */
2867c478bd9Sstevel@tonic-gate a = 1;
2877c478bd9Sstevel@tonic-gate break;
2887c478bd9Sstevel@tonic-gate
2897c478bd9Sstevel@tonic-gate case 'A': /* alert type */
2907c478bd9Sstevel@tonic-gate if (A)
2917c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'A');
2927c478bd9Sstevel@tonic-gate MALLOC(A);
2937c478bd9Sstevel@tonic-gate Aflag++;
2947c478bd9Sstevel@tonic-gate if (!STREQU(A, NAME_QUIET) && !STREQU(A, NAME_LIST))
2957c478bd9Sstevel@tonic-gate *modp++ = 'A';
2967c478bd9Sstevel@tonic-gate break;
2977c478bd9Sstevel@tonic-gate
2987c478bd9Sstevel@tonic-gate case 'c': /* class to insert printer p */
2997c478bd9Sstevel@tonic-gate if (c)
3007c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'c');
3017c478bd9Sstevel@tonic-gate MALLOC(c);
3027c478bd9Sstevel@tonic-gate break;
3037c478bd9Sstevel@tonic-gate
3047c478bd9Sstevel@tonic-gate #if defined(DIRECT_ACCESS)
305*55fea89dSDan Cross case 'C':
3067c478bd9Sstevel@tonic-gate C = 1;
3077c478bd9Sstevel@tonic-gate break;
3087c478bd9Sstevel@tonic-gate #endif
3097c478bd9Sstevel@tonic-gate
3107c478bd9Sstevel@tonic-gate case 'd': /* system default destination */
3117c478bd9Sstevel@tonic-gate if (d)
3127c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'd');
3137c478bd9Sstevel@tonic-gate MALLOC(d);
3147c478bd9Sstevel@tonic-gate break;
3157c478bd9Sstevel@tonic-gate
3167c478bd9Sstevel@tonic-gate case 'D': /* description */
3177c478bd9Sstevel@tonic-gate if (D)
3187c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'D');
3197c478bd9Sstevel@tonic-gate MALLOC(D);
3207c478bd9Sstevel@tonic-gate *modp++ = 'D';
3217c478bd9Sstevel@tonic-gate break;
3227c478bd9Sstevel@tonic-gate
3237c478bd9Sstevel@tonic-gate case 'e': /* existing printer interface */
3247c478bd9Sstevel@tonic-gate if (e)
3257c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'e');
3267c478bd9Sstevel@tonic-gate MALLOC(e);
3277c478bd9Sstevel@tonic-gate *modp++ = 'e';
3287c478bd9Sstevel@tonic-gate break;
3297c478bd9Sstevel@tonic-gate
3307c478bd9Sstevel@tonic-gate case 'f': /* set up forms allow/deny */
3317c478bd9Sstevel@tonic-gate if (f)
3327c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'f');
3337c478bd9Sstevel@tonic-gate MALLOC(f);
3347c478bd9Sstevel@tonic-gate break;
3357c478bd9Sstevel@tonic-gate
3367c478bd9Sstevel@tonic-gate case 'P': /* set up forms allow/deny */
3377c478bd9Sstevel@tonic-gate if (P)
3387c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'P');
3397c478bd9Sstevel@tonic-gate MALLOC(P);
3407c478bd9Sstevel@tonic-gate break;
3417c478bd9Sstevel@tonic-gate
3427c478bd9Sstevel@tonic-gate case 'F': /* fault recovery */
3437c478bd9Sstevel@tonic-gate if (F)
3447c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'F');
3457c478bd9Sstevel@tonic-gate MALLOC(F);
3467c478bd9Sstevel@tonic-gate *modp++ = 'F';
3477c478bd9Sstevel@tonic-gate break;
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate #if defined(CAN_DO_MODULES)
3507c478bd9Sstevel@tonic-gate case 'H':
3517c478bd9Sstevel@tonic-gate if (H)
3527c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'H');
3537c478bd9Sstevel@tonic-gate if (!optarg || !*optarg || STREQU(NAME_NONE, optarg))
3547c478bd9Sstevel@tonic-gate H = empty_list;
3557c478bd9Sstevel@tonic-gate if (!(H = getlist(optarg, LP_WS, LP_SEP))) {
3567c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_MALLOC);
3577c478bd9Sstevel@tonic-gate done(1);
3587c478bd9Sstevel@tonic-gate }
3597c478bd9Sstevel@tonic-gate *modp++ = 'H';
3607c478bd9Sstevel@tonic-gate break;
3617c478bd9Sstevel@tonic-gate #endif
362*55fea89dSDan Cross
3637c478bd9Sstevel@tonic-gate case 'h': /* hardwired terminal */
3647c478bd9Sstevel@tonic-gate h = 1;
3657c478bd9Sstevel@tonic-gate *modp++ = 'h';
3667c478bd9Sstevel@tonic-gate break;
3677c478bd9Sstevel@tonic-gate
3687c478bd9Sstevel@tonic-gate case 'i': /* interface pathname */
3697c478bd9Sstevel@tonic-gate if (i)
3707c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'i');
3717c478bd9Sstevel@tonic-gate MALLOC(i);
3727c478bd9Sstevel@tonic-gate *modp++ = 'i';
3737c478bd9Sstevel@tonic-gate break;
3747c478bd9Sstevel@tonic-gate
3757c478bd9Sstevel@tonic-gate case 'I': /* content-type-list */
3767c478bd9Sstevel@tonic-gate if (I)
3777c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'I');
3787c478bd9Sstevel@tonic-gate if (!optarg || !*optarg || STREQU(NAME_NONE, optarg))
3797c478bd9Sstevel@tonic-gate I = empty_list;
3807c478bd9Sstevel@tonic-gate else if (!(I = getlist(optarg, LP_WS, LP_SEP))) {
3817c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_MALLOC);
3827c478bd9Sstevel@tonic-gate done (1);
3837c478bd9Sstevel@tonic-gate }
3847c478bd9Sstevel@tonic-gate *modp++ = 'I';
3857c478bd9Sstevel@tonic-gate break;
3867c478bd9Sstevel@tonic-gate
3877c478bd9Sstevel@tonic-gate #if defined(J_OPTION)
3887c478bd9Sstevel@tonic-gate case 'j': /* fault recovery just for current job */
3897c478bd9Sstevel@tonic-gate j = 1;
3907c478bd9Sstevel@tonic-gate (void) printf (gettext("Sorry, the -j option is currently broken\n"));
3917c478bd9Sstevel@tonic-gate break;
3927c478bd9Sstevel@tonic-gate #endif
3937c478bd9Sstevel@tonic-gate
3947c478bd9Sstevel@tonic-gate case 'l': /* login terminal */
3957c478bd9Sstevel@tonic-gate l = 1;
3967c478bd9Sstevel@tonic-gate *modp++ = 'l';
3977c478bd9Sstevel@tonic-gate break;
3987c478bd9Sstevel@tonic-gate
3997c478bd9Sstevel@tonic-gate case 'm': /* model interface */
400*55fea89dSDan Cross if (m)
4017c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'm');
4027c478bd9Sstevel@tonic-gate MALLOC(m);
4037c478bd9Sstevel@tonic-gate *modp++ = 'm';
4047c478bd9Sstevel@tonic-gate break;
4057c478bd9Sstevel@tonic-gate
4067c478bd9Sstevel@tonic-gate #ifdef LP_USE_PAPI_ATTR
4077c478bd9Sstevel@tonic-gate case 'n': /* PPD file */
4087c478bd9Sstevel@tonic-gate if (n_opt)
4097c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'n');
4107c478bd9Sstevel@tonic-gate MALLOC(n_opt);
4117c478bd9Sstevel@tonic-gate *modp++ = 'n';
4127c478bd9Sstevel@tonic-gate break;
4137c478bd9Sstevel@tonic-gate #endif
4147c478bd9Sstevel@tonic-gate
4157c478bd9Sstevel@tonic-gate case 'M': /* a mount request */
4167c478bd9Sstevel@tonic-gate M = 1;
4177c478bd9Sstevel@tonic-gate break;
4187c478bd9Sstevel@tonic-gate
4197c478bd9Sstevel@tonic-gate case 'o': /* several different options */
4207c478bd9Sstevel@tonic-gate oparse (optarg);
4217c478bd9Sstevel@tonic-gate o = 1;
4227c478bd9Sstevel@tonic-gate break;
4237c478bd9Sstevel@tonic-gate
4247c478bd9Sstevel@tonic-gate case 'p': /* printer name */
425*55fea89dSDan Cross if (p)
4267c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'p');
4277c478bd9Sstevel@tonic-gate MALLOC(p);
4287c478bd9Sstevel@tonic-gate break;
4297c478bd9Sstevel@tonic-gate
4307c478bd9Sstevel@tonic-gate case 'Q':
4317c478bd9Sstevel@tonic-gate if (Q != -1)
4327c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'Q');
4337c478bd9Sstevel@tonic-gate if (STREQU(NAME_ANY, optarg))
4347c478bd9Sstevel@tonic-gate Q = 1;
4357c478bd9Sstevel@tonic-gate else {
4367c478bd9Sstevel@tonic-gate Q = strtol(optarg, &rest, 10);
4377c478bd9Sstevel@tonic-gate if (Q < 0) {
4387c478bd9Sstevel@tonic-gate LP_ERRMSG1 (ERROR, E_LP_NEGARG, 'Q');
4397c478bd9Sstevel@tonic-gate done (1);
4407c478bd9Sstevel@tonic-gate }
4417c478bd9Sstevel@tonic-gate if (rest && *rest) {
4427c478bd9Sstevel@tonic-gate LP_ERRMSG1 (ERROR, E_LP_GARBNMB, 'Q');
4437c478bd9Sstevel@tonic-gate done (1);
4447c478bd9Sstevel@tonic-gate }
4457c478bd9Sstevel@tonic-gate if (Q == 0) {
4467c478bd9Sstevel@tonic-gate LP_ERRMSG1 (ERROR, E_ADM_ZEROARG, 'Q');
4477c478bd9Sstevel@tonic-gate done (1);
4487c478bd9Sstevel@tonic-gate }
4497c478bd9Sstevel@tonic-gate }
4507c478bd9Sstevel@tonic-gate *modp++ = 'Q';
4517c478bd9Sstevel@tonic-gate break;
4527c478bd9Sstevel@tonic-gate
4537c478bd9Sstevel@tonic-gate case 'r': /* class to remove p from */
454*55fea89dSDan Cross if (r)
4557c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'r');
4567c478bd9Sstevel@tonic-gate MALLOC(r);
4577c478bd9Sstevel@tonic-gate break;
4587c478bd9Sstevel@tonic-gate
4597c478bd9Sstevel@tonic-gate case 'S': /* char_set/print-wheels */
460*55fea89dSDan Cross if (S)
4617c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'S');
4627c478bd9Sstevel@tonic-gate if (!(S = getlist(optarg, LP_WS, LP_SEP))) {
4637c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_MALLOC);
4647c478bd9Sstevel@tonic-gate done (1);
4657c478bd9Sstevel@tonic-gate }
4667c478bd9Sstevel@tonic-gate *modp++ = 'S';
4677c478bd9Sstevel@tonic-gate break;
4687c478bd9Sstevel@tonic-gate
4697c478bd9Sstevel@tonic-gate case 's':
4707c478bd9Sstevel@tonic-gate if (s)
4717c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 's');
4727c478bd9Sstevel@tonic-gate
4737c478bd9Sstevel@tonic-gate if ((cp = strchr(optarg, '!')))
4747c478bd9Sstevel@tonic-gate *cp = '\0';
4757c478bd9Sstevel@tonic-gate
4765c88ba20Swendyp if ((STREQU(optarg, NAME_NONE)) ||
4775c88ba20Swendyp (STREQU(optarg, "localhost")))
4785c88ba20Swendyp
4797c478bd9Sstevel@tonic-gate s = Local_System;
4807c478bd9Sstevel@tonic-gate else if (STREQU(optarg, Local_System)) {
4817c478bd9Sstevel@tonic-gate if (cp) {
4827c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_ADM_NAMEONLOCAL);
4837c478bd9Sstevel@tonic-gate done(1);
4847c478bd9Sstevel@tonic-gate } else
4857c478bd9Sstevel@tonic-gate s = Local_System;
4867c478bd9Sstevel@tonic-gate } else {
4877c478bd9Sstevel@tonic-gate if (cp)
4887c478bd9Sstevel@tonic-gate *cp = '!';
4897c478bd9Sstevel@tonic-gate
4907c478bd9Sstevel@tonic-gate MALLOC(s);
4917c478bd9Sstevel@tonic-gate }
4927c478bd9Sstevel@tonic-gate
4937c478bd9Sstevel@tonic-gate /* 's' already used for stty 'R' for remote? */
4947c478bd9Sstevel@tonic-gate *modp++ = 'R';
4957c478bd9Sstevel@tonic-gate break;
4967c478bd9Sstevel@tonic-gate
4977c478bd9Sstevel@tonic-gate case 't': /* tray number*/
4987c478bd9Sstevel@tonic-gate if (t != 0) LP_ERRMSG1 (WARNING, E_LP_2MANY, 't');
4997c478bd9Sstevel@tonic-gate t = strtol(optarg, &rest, 10);
5007c478bd9Sstevel@tonic-gate if (t <= 0) {
5017c478bd9Sstevel@tonic-gate LP_ERRMSG1 (ERROR, E_LP_NEGARG, 't');
5027c478bd9Sstevel@tonic-gate done (1);
5037c478bd9Sstevel@tonic-gate }
5047c478bd9Sstevel@tonic-gate if (rest && *rest) {
5057c478bd9Sstevel@tonic-gate LP_ERRMSG1 (ERROR, E_LP_GARBNMB, 't');
5067c478bd9Sstevel@tonic-gate done (1);
5077c478bd9Sstevel@tonic-gate }
5087c478bd9Sstevel@tonic-gate break;
5097c478bd9Sstevel@tonic-gate
5107c478bd9Sstevel@tonic-gate case 'T': /* terminfo names for p */
5117c478bd9Sstevel@tonic-gate if (T)
5127c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'T');
5137c478bd9Sstevel@tonic-gate if (!(T = getlist(optarg, LP_WS, LP_SEP))) {
5147c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_MALLOC);
5157c478bd9Sstevel@tonic-gate done (1);
5167c478bd9Sstevel@tonic-gate }
5177c478bd9Sstevel@tonic-gate *modp++ = 'T';
5187c478bd9Sstevel@tonic-gate break;
5197c478bd9Sstevel@tonic-gate
5207c478bd9Sstevel@tonic-gate case 'u': /* user allow/deny list */
5217c478bd9Sstevel@tonic-gate if (u)
5227c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'u');
5237c478bd9Sstevel@tonic-gate MALLOC(u);
5247c478bd9Sstevel@tonic-gate break;
5257c478bd9Sstevel@tonic-gate
5267c478bd9Sstevel@tonic-gate case 'U': /* dialer_info */
5277c478bd9Sstevel@tonic-gate if (U)
5287c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'U');
5297c478bd9Sstevel@tonic-gate MALLOC(U);
5307c478bd9Sstevel@tonic-gate *modp++ = 'U';
5317c478bd9Sstevel@tonic-gate break;
5327c478bd9Sstevel@tonic-gate
5337c478bd9Sstevel@tonic-gate case 'v': /* device pathname */
5347c478bd9Sstevel@tonic-gate if (v)
5357c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'v');
5367c478bd9Sstevel@tonic-gate MALLOC(v);
5377c478bd9Sstevel@tonic-gate *modp++ = 'v';
5387c478bd9Sstevel@tonic-gate break;
5397c478bd9Sstevel@tonic-gate
5407c478bd9Sstevel@tonic-gate case 'W': /* alert interval */
5417c478bd9Sstevel@tonic-gate if (W != -1)
5427c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'W');
5437c478bd9Sstevel@tonic-gate if (STREQU(NAME_ONCE, optarg))
5447c478bd9Sstevel@tonic-gate W = 0;
5457c478bd9Sstevel@tonic-gate else {
5467c478bd9Sstevel@tonic-gate W = strtol(optarg, &rest, 10);
5477c478bd9Sstevel@tonic-gate if (W < 0) {
5487c478bd9Sstevel@tonic-gate LP_ERRMSG1 (ERROR, E_LP_NEGARG, 'W');
5497c478bd9Sstevel@tonic-gate done (1);
5507c478bd9Sstevel@tonic-gate }
5517c478bd9Sstevel@tonic-gate if (rest && *rest) {
5527c478bd9Sstevel@tonic-gate LP_ERRMSG1 (ERROR, E_LP_GARBNMB, 'W');
5537c478bd9Sstevel@tonic-gate done (1);
5547c478bd9Sstevel@tonic-gate }
5557c478bd9Sstevel@tonic-gate }
5567c478bd9Sstevel@tonic-gate *modp++ = 'W';
5577c478bd9Sstevel@tonic-gate break;
5587c478bd9Sstevel@tonic-gate
5597c478bd9Sstevel@tonic-gate case 'x': /* destination to be deleted */
5607c478bd9Sstevel@tonic-gate if (x)
5617c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_2MANY, 'x');
5627c478bd9Sstevel@tonic-gate MALLOC(x);
5637c478bd9Sstevel@tonic-gate break;
5647c478bd9Sstevel@tonic-gate
5657c478bd9Sstevel@tonic-gate default:
5667c478bd9Sstevel@tonic-gate if (optopt == '?') {
5677c478bd9Sstevel@tonic-gate usage ();
5687c478bd9Sstevel@tonic-gate done (0);
5697c478bd9Sstevel@tonic-gate
5707c478bd9Sstevel@tonic-gate } else {
571f928ce67Sceastha stroptsw[1] = optsw;
572f928ce67Sceastha
5737c478bd9Sstevel@tonic-gate if (strchr(OPT_LIST, optopt))
574268ffd3aSRichard Lowe LP_ERRMSG1 (ERROR, E_LP_OPTARG,
575268ffd3aSRichard Lowe stroptsw);
5767c478bd9Sstevel@tonic-gate else
577268ffd3aSRichard Lowe LP_ERRMSG1 (ERROR, E_LP_OPTION,
578268ffd3aSRichard Lowe stroptsw);
5797c478bd9Sstevel@tonic-gate done (1);
5807c478bd9Sstevel@tonic-gate }
5817c478bd9Sstevel@tonic-gate }
5827c478bd9Sstevel@tonic-gate }
5837c478bd9Sstevel@tonic-gate
5847c478bd9Sstevel@tonic-gate if (optind < argc)
5857c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_LP_EXTRA, argv[optind]);
5867c478bd9Sstevel@tonic-gate
5877c478bd9Sstevel@tonic-gate if ((v) && (!Aflag)) {
5887c478bd9Sstevel@tonic-gate if (!(A = strdup("write"))) {
5897c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_MALLOC);
5907c478bd9Sstevel@tonic-gate done (1);
5917c478bd9Sstevel@tonic-gate }
5927c478bd9Sstevel@tonic-gate *modp++ = 'A';
5937c478bd9Sstevel@tonic-gate }
5947c478bd9Sstevel@tonic-gate
5957c478bd9Sstevel@tonic-gate return;
5967c478bd9Sstevel@tonic-gate }
5977c478bd9Sstevel@tonic-gate
5987c478bd9Sstevel@tonic-gate /**
5997c478bd9Sstevel@tonic-gate ** oparse() - PARSE -o OPTION
6007c478bd9Sstevel@tonic-gate **/
6017c478bd9Sstevel@tonic-gate
oparse(optarg)6027c478bd9Sstevel@tonic-gate static void oparse (optarg)
6037c478bd9Sstevel@tonic-gate char *optarg;
6047c478bd9Sstevel@tonic-gate {
6057c478bd9Sstevel@tonic-gate register char **list = dashos(optarg);
6067c478bd9Sstevel@tonic-gate
6077c478bd9Sstevel@tonic-gate
6087c478bd9Sstevel@tonic-gate if (!list)
6097c478bd9Sstevel@tonic-gate return;
6107c478bd9Sstevel@tonic-gate
6117c478bd9Sstevel@tonic-gate for ( ; (optarg = *list); list++)
6127c478bd9Sstevel@tonic-gate
6137c478bd9Sstevel@tonic-gate if (STREQU(optarg, "banner")) {
6147c478bd9Sstevel@tonic-gate if (banner != -1)
6157c478bd9Sstevel@tonic-gate LP_ERRMSG1 (
6167c478bd9Sstevel@tonic-gate WARNING,
6177c478bd9Sstevel@tonic-gate E_ADM_2MANY,
6187c478bd9Sstevel@tonic-gate "banner/nobanner"
6197c478bd9Sstevel@tonic-gate );
6207c478bd9Sstevel@tonic-gate banner = BAN_ALWAYS;
6217c478bd9Sstevel@tonic-gate *modp++ = 'b';
6227c478bd9Sstevel@tonic-gate
6237c478bd9Sstevel@tonic-gate } else if (STREQU(optarg, "nobanner")) {
6247c478bd9Sstevel@tonic-gate if (banner != -1)
6257c478bd9Sstevel@tonic-gate LP_ERRMSG1 (
6267c478bd9Sstevel@tonic-gate WARNING,
6277c478bd9Sstevel@tonic-gate E_ADM_2MANY,
6287c478bd9Sstevel@tonic-gate "banner/nobanner"
6297c478bd9Sstevel@tonic-gate );
6307c478bd9Sstevel@tonic-gate banner = BAN_OPTIONAL;
6317c478bd9Sstevel@tonic-gate *modp++ = 'b';
6327c478bd9Sstevel@tonic-gate
6337c478bd9Sstevel@tonic-gate /* handle banner=(always|optional|never) */
6347c478bd9Sstevel@tonic-gate } else if (STRNEQU(optarg, "banner=", 7)) {
6357c478bd9Sstevel@tonic-gate char *ptr;
6367c478bd9Sstevel@tonic-gate
6377c478bd9Sstevel@tonic-gate ptr = (optarg += 7);
6387c478bd9Sstevel@tonic-gate if (banner != -1)
6397c478bd9Sstevel@tonic-gate LP_ERRMSG1 ( WARNING, E_ADM_2MANY,
6407c478bd9Sstevel@tonic-gate "banner/nobanner/banner=(always|optional|never)"
6417c478bd9Sstevel@tonic-gate );
6427c478bd9Sstevel@tonic-gate
6437c478bd9Sstevel@tonic-gate /* like "banner", always print a banner */
6447c478bd9Sstevel@tonic-gate if (strcasecmp(ptr, "always") == 0)
6457c478bd9Sstevel@tonic-gate banner = BAN_ALWAYS;
6467c478bd9Sstevel@tonic-gate /* like "nobanner", print a banner unless requested */
6477c478bd9Sstevel@tonic-gate if (strcasecmp(ptr, "optional") == 0)
6487c478bd9Sstevel@tonic-gate banner = BAN_OPTIONAL;
6497c478bd9Sstevel@tonic-gate /* never print a banner */
6507c478bd9Sstevel@tonic-gate if (strcasecmp(ptr, "never") == 0)
6517c478bd9Sstevel@tonic-gate banner = BAN_NEVER;
6527c478bd9Sstevel@tonic-gate *modp++ = 'b';
653*55fea89dSDan Cross
6547c478bd9Sstevel@tonic-gate } else if (STRNEQU(optarg, "length=", 7)) {
6557c478bd9Sstevel@tonic-gate if (length)
6567c478bd9Sstevel@tonic-gate LP_ERRMSG1 (
6577c478bd9Sstevel@tonic-gate WARNING,
6587c478bd9Sstevel@tonic-gate E_ADM_2MANY,
6597c478bd9Sstevel@tonic-gate "length="
6607c478bd9Sstevel@tonic-gate );
6617c478bd9Sstevel@tonic-gate length = (optarg += 7);
6627c478bd9Sstevel@tonic-gate
6637c478bd9Sstevel@tonic-gate if (!*optarg) {
6647c478bd9Sstevel@tonic-gate length_sdn.val = 0;
6657c478bd9Sstevel@tonic-gate length_sdn.sc = 0;
6667c478bd9Sstevel@tonic-gate
6677c478bd9Sstevel@tonic-gate } else {
6687c478bd9Sstevel@tonic-gate length_sdn = _getsdn(optarg, &optarg, 0);
6697c478bd9Sstevel@tonic-gate if (errno == EINVAL) {
6707c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_BADSCALE);
6717c478bd9Sstevel@tonic-gate done (1);
6727c478bd9Sstevel@tonic-gate }
6737c478bd9Sstevel@tonic-gate }
6747c478bd9Sstevel@tonic-gate *modp++ = 'L';
6757c478bd9Sstevel@tonic-gate
6767c478bd9Sstevel@tonic-gate } else if (STRNEQU(optarg, "width=", 6)) {
6777c478bd9Sstevel@tonic-gate if (width)
6787c478bd9Sstevel@tonic-gate LP_ERRMSG1 (
6797c478bd9Sstevel@tonic-gate WARNING,
6807c478bd9Sstevel@tonic-gate E_ADM_2MANY,
6817c478bd9Sstevel@tonic-gate "width="
6827c478bd9Sstevel@tonic-gate );
6837c478bd9Sstevel@tonic-gate width = (optarg += 6);
6847c478bd9Sstevel@tonic-gate
6857c478bd9Sstevel@tonic-gate if (!*optarg) {
6867c478bd9Sstevel@tonic-gate width_sdn.val = 0;
6877c478bd9Sstevel@tonic-gate width_sdn.sc = 0;
6887c478bd9Sstevel@tonic-gate
6897c478bd9Sstevel@tonic-gate } else {
6907c478bd9Sstevel@tonic-gate width_sdn = _getsdn(optarg, &optarg, 0);
6917c478bd9Sstevel@tonic-gate if (errno == EINVAL) {
6927c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_BADSCALE);
6937c478bd9Sstevel@tonic-gate done (1);
6947c478bd9Sstevel@tonic-gate }
6957c478bd9Sstevel@tonic-gate }
6967c478bd9Sstevel@tonic-gate *modp++ = 'w';
6977c478bd9Sstevel@tonic-gate
6987c478bd9Sstevel@tonic-gate } else if (STRNEQU(optarg, "cpi=", 4)) {
6997c478bd9Sstevel@tonic-gate if (cpi)
7007c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_ADM_2MANY, "cpi=");
7017c478bd9Sstevel@tonic-gate
7027c478bd9Sstevel@tonic-gate cpi = (optarg += 4);
7037c478bd9Sstevel@tonic-gate
7047c478bd9Sstevel@tonic-gate if (!*optarg) {
7057c478bd9Sstevel@tonic-gate cpi_sdn.val = 0;
7067c478bd9Sstevel@tonic-gate cpi_sdn.sc = 0;
7077c478bd9Sstevel@tonic-gate
7087c478bd9Sstevel@tonic-gate } else {
7097c478bd9Sstevel@tonic-gate cpi_sdn = _getsdn(optarg, &optarg, 1);
7107c478bd9Sstevel@tonic-gate if (errno == EINVAL) {
7117c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_BADSCALE);
7127c478bd9Sstevel@tonic-gate done (1);
7137c478bd9Sstevel@tonic-gate }
7147c478bd9Sstevel@tonic-gate }
7157c478bd9Sstevel@tonic-gate *modp++ = 'c';
7167c478bd9Sstevel@tonic-gate
7177c478bd9Sstevel@tonic-gate } else if (STRNEQU(optarg, "lpi=", 4)) {
7187c478bd9Sstevel@tonic-gate if (lpi)
7197c478bd9Sstevel@tonic-gate LP_ERRMSG1 (WARNING, E_ADM_2MANY, "lpi=");
7207c478bd9Sstevel@tonic-gate lpi = (optarg += 4);
7217c478bd9Sstevel@tonic-gate
7227c478bd9Sstevel@tonic-gate if (!*optarg) {
7237c478bd9Sstevel@tonic-gate lpi_sdn.val = 0;
7247c478bd9Sstevel@tonic-gate lpi_sdn.sc = 0;
7257c478bd9Sstevel@tonic-gate
7267c478bd9Sstevel@tonic-gate } else {
7277c478bd9Sstevel@tonic-gate lpi_sdn = _getsdn(optarg, &optarg, 0);
7287c478bd9Sstevel@tonic-gate if (errno == EINVAL) {
7297c478bd9Sstevel@tonic-gate LP_ERRMSG (ERROR, E_LP_BADSCALE);
7307c478bd9Sstevel@tonic-gate done (1);
7317c478bd9Sstevel@tonic-gate }
7327c478bd9Sstevel@tonic-gate }
7337c478bd9Sstevel@tonic-gate *modp++ = 'M';
7347c478bd9Sstevel@tonic-gate
7357c478bd9Sstevel@tonic-gate } else if (STRNEQU(optarg, "stty=", 5)) {
7367c478bd9Sstevel@tonic-gate
7377c478bd9Sstevel@tonic-gate optarg += 5;
7387c478bd9Sstevel@tonic-gate if (!*optarg)
7397c478bd9Sstevel@tonic-gate stty_opt = 0;
7407c478bd9Sstevel@tonic-gate
7417c478bd9Sstevel@tonic-gate else {
7427c478bd9Sstevel@tonic-gate if (strchr(LP_QUOTES, *optarg)) {
7437c478bd9Sstevel@tonic-gate register int len
7447c478bd9Sstevel@tonic-gate = strlen(optarg);
7457c478bd9Sstevel@tonic-gate
7467c478bd9Sstevel@tonic-gate if (optarg[len - 1] == *optarg)
7477c478bd9Sstevel@tonic-gate optarg[len - 1] = 0;
7487c478bd9Sstevel@tonic-gate optarg++;
7497c478bd9Sstevel@tonic-gate }
7507c478bd9Sstevel@tonic-gate if (stty_opt)
7517c478bd9Sstevel@tonic-gate REALLOC (stty_opt);
7527c478bd9Sstevel@tonic-gate else
7537c478bd9Sstevel@tonic-gate MALLOC (stty_opt);
7547c478bd9Sstevel@tonic-gate }
7557c478bd9Sstevel@tonic-gate *modp++ = 's';
7567c478bd9Sstevel@tonic-gate
7577c478bd9Sstevel@tonic-gate } else if (STREQU(optarg, "filebreak")) {
7587c478bd9Sstevel@tonic-gate filebreak = 1;
7597c478bd9Sstevel@tonic-gate
7607c478bd9Sstevel@tonic-gate } else if (STREQU(optarg, "nofilebreak")) {
7617c478bd9Sstevel@tonic-gate filebreak = 0;
7627c478bd9Sstevel@tonic-gate
7637c478bd9Sstevel@tonic-gate /* added support for using -o to pass any key=value pair */
7647c478bd9Sstevel@tonic-gate } else if (*optarg) {
7657c478bd9Sstevel@tonic-gate
7667c478bd9Sstevel@tonic-gate if ((addlist(&o_options, optarg)) != 0) {
7677c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("System Error %d\n"), errno);
7687c478bd9Sstevel@tonic-gate }
7697c478bd9Sstevel@tonic-gate
7707c478bd9Sstevel@tonic-gate *modp++ = 'o';
7717c478bd9Sstevel@tonic-gate optarg++;
7727c478bd9Sstevel@tonic-gate }
7737c478bd9Sstevel@tonic-gate
7747c478bd9Sstevel@tonic-gate return;
7757c478bd9Sstevel@tonic-gate }
776