1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1994, by Sun Microsytems, Inc. 24*7c478bd9Sstevel@tonic-gate */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate /* 29*7c478bd9Sstevel@tonic-gate * Includes 30*7c478bd9Sstevel@tonic-gate */ 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* we need to define this to get strtok_r from string.h */ 33*7c478bd9Sstevel@tonic-gate /* SEEMS LIKE A BUG TO ME */ 34*7c478bd9Sstevel@tonic-gate #define _REENTRANT 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifndef DEBUG 37*7c478bd9Sstevel@tonic-gate #define NDEBUG 1 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #include <stdio.h> 41*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 42*7c478bd9Sstevel@tonic-gate #include <string.h> 43*7c478bd9Sstevel@tonic-gate #include <libintl.h> 44*7c478bd9Sstevel@tonic-gate #include <regexpr.h> 45*7c478bd9Sstevel@tonic-gate #include <assert.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 47*7c478bd9Sstevel@tonic-gate #include "spec.h" 48*7c478bd9Sstevel@tonic-gate #include "new.h" 49*7c478bd9Sstevel@tonic-gate #include "source.h" 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate static boolean_t spec_match(spec_t * spec_p, char *str); 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * Globals 56*7c478bd9Sstevel@tonic-gate */ 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate /* 61*7c478bd9Sstevel@tonic-gate * spec() - builds a spec 62*7c478bd9Sstevel@tonic-gate */ 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate spec_t * 65*7c478bd9Sstevel@tonic-gate spec(char *str_p, 66*7c478bd9Sstevel@tonic-gate spec_type_t type) 67*7c478bd9Sstevel@tonic-gate { 68*7c478bd9Sstevel@tonic-gate spec_t *new_p; 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate new_p = new(spec_t); 71*7c478bd9Sstevel@tonic-gate queue_init(&new_p->qn); 72*7c478bd9Sstevel@tonic-gate new_p->str = str_p; 73*7c478bd9Sstevel@tonic-gate new_p->type = type; 74*7c478bd9Sstevel@tonic-gate new_p->regexp_p = NULL; 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate if (type == SPEC_REGEXP) { 77*7c478bd9Sstevel@tonic-gate new_p->regexp_p = compile(str_p, NULL, NULL); 78*7c478bd9Sstevel@tonic-gate if (!new_p->regexp_p) { 79*7c478bd9Sstevel@tonic-gate semantic_err(gettext("invalid regular expression")); 80*7c478bd9Sstevel@tonic-gate free(new_p); 81*7c478bd9Sstevel@tonic-gate return (NULL); 82*7c478bd9Sstevel@tonic-gate } 83*7c478bd9Sstevel@tonic-gate } 84*7c478bd9Sstevel@tonic-gate return (new_p); 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate } /* end spec */ 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate /* 90*7c478bd9Sstevel@tonic-gate * spec_dup() - duplicates a spec, NOT A SPEC LIST! 91*7c478bd9Sstevel@tonic-gate */ 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate spec_t * 94*7c478bd9Sstevel@tonic-gate spec_dup(spec_t * spec_p) 95*7c478bd9Sstevel@tonic-gate { 96*7c478bd9Sstevel@tonic-gate spec_t *new_p; 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate new_p = spec(strdup(spec_p->str), spec_p->type); 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate return (new_p); 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate } /* end spec_dup */ 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate /* 106*7c478bd9Sstevel@tonic-gate * spec_destroy() - destroys a spec list 107*7c478bd9Sstevel@tonic-gate */ 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate void 110*7c478bd9Sstevel@tonic-gate spec_destroy(spec_t * list_p) 111*7c478bd9Sstevel@tonic-gate { 112*7c478bd9Sstevel@tonic-gate spec_t *spec_p; 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate while ((spec_p = (spec_t *) queue_next(&list_p->qn, &list_p->qn))) { 115*7c478bd9Sstevel@tonic-gate (void) queue_remove(&spec_p->qn); 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate if (spec_p->str) 118*7c478bd9Sstevel@tonic-gate free(spec_p->str); 119*7c478bd9Sstevel@tonic-gate if (spec_p->regexp_p) 120*7c478bd9Sstevel@tonic-gate free(spec_p->regexp_p); 121*7c478bd9Sstevel@tonic-gate free(spec_p); 122*7c478bd9Sstevel@tonic-gate } 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate if (list_p->str) 125*7c478bd9Sstevel@tonic-gate free(list_p->str); 126*7c478bd9Sstevel@tonic-gate if (list_p->regexp_p) 127*7c478bd9Sstevel@tonic-gate free(list_p->regexp_p); 128*7c478bd9Sstevel@tonic-gate free(list_p); 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate } /* end spec_destroy */ 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate /* 134*7c478bd9Sstevel@tonic-gate * spec_list() - append a spec_t to a list 135*7c478bd9Sstevel@tonic-gate */ 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate spec_t * 138*7c478bd9Sstevel@tonic-gate spec_list(spec_t * h, 139*7c478bd9Sstevel@tonic-gate spec_t * f) 140*7c478bd9Sstevel@tonic-gate { 141*7c478bd9Sstevel@tonic-gate /* queue append handles the NULL cases OK */ 142*7c478bd9Sstevel@tonic-gate return ((spec_t *) queue_append(&h->qn, &f->qn)); 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate } /* end spec_list */ 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate /* 148*7c478bd9Sstevel@tonic-gate * spec_print() - pretty prints a speclist 149*7c478bd9Sstevel@tonic-gate */ 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate void 152*7c478bd9Sstevel@tonic-gate spec_print(FILE * stream, 153*7c478bd9Sstevel@tonic-gate spec_t * list_p) 154*7c478bd9Sstevel@tonic-gate { 155*7c478bd9Sstevel@tonic-gate spec_t *spec_p = NULL; 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate while ((spec_p = (spec_t *) queue_next(&list_p->qn, &spec_p->qn))) { 158*7c478bd9Sstevel@tonic-gate switch (spec_p->type) { 159*7c478bd9Sstevel@tonic-gate case SPEC_EXACT: 160*7c478bd9Sstevel@tonic-gate (void) fprintf(stream, "'%s'", spec_p->str); 161*7c478bd9Sstevel@tonic-gate break; 162*7c478bd9Sstevel@tonic-gate case SPEC_REGEXP: 163*7c478bd9Sstevel@tonic-gate (void) fprintf(stream, "/%s/", spec_p->str); 164*7c478bd9Sstevel@tonic-gate break; 165*7c478bd9Sstevel@tonic-gate } 166*7c478bd9Sstevel@tonic-gate } 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate } /* end spec_print */ 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate /* 172*7c478bd9Sstevel@tonic-gate * spec_match() - called with a spec and a string, returns whether they 173*7c478bd9Sstevel@tonic-gate * match. 174*7c478bd9Sstevel@tonic-gate */ 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate static boolean_t 177*7c478bd9Sstevel@tonic-gate spec_match(spec_t * spec_p, 178*7c478bd9Sstevel@tonic-gate char *str) 179*7c478bd9Sstevel@tonic-gate { 180*7c478bd9Sstevel@tonic-gate if (!spec_p) 181*7c478bd9Sstevel@tonic-gate return (B_FALSE); 182*7c478bd9Sstevel@tonic-gate 183*7c478bd9Sstevel@tonic-gate switch (spec_p->type) { 184*7c478bd9Sstevel@tonic-gate case SPEC_EXACT: 185*7c478bd9Sstevel@tonic-gate return ((strcmp(spec_p->str, str) == 0)); 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate case SPEC_REGEXP: 188*7c478bd9Sstevel@tonic-gate return ((step(str, spec_p->regexp_p) != NULL)); 189*7c478bd9Sstevel@tonic-gate } 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate return (B_FALSE); 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate } /* end spec_match */ 194*7c478bd9Sstevel@tonic-gate 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate /* 197*7c478bd9Sstevel@tonic-gate * spec_attrtrav() - traverse an attribute list, calling the supplied 198*7c478bd9Sstevel@tonic-gate * function on each matching attribute. 199*7c478bd9Sstevel@tonic-gate */ 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate void 202*7c478bd9Sstevel@tonic-gate spec_attrtrav(spec_t * spec_p, 203*7c478bd9Sstevel@tonic-gate char *attrs, 204*7c478bd9Sstevel@tonic-gate spec_attr_fun_t fun, 205*7c478bd9Sstevel@tonic-gate void *calldatap) 206*7c478bd9Sstevel@tonic-gate { 207*7c478bd9Sstevel@tonic-gate char *lasts; 208*7c478bd9Sstevel@tonic-gate char *refptr = NULL; 209*7c478bd9Sstevel@tonic-gate char *escptr = NULL; 210*7c478bd9Sstevel@tonic-gate char *pair; 211*7c478bd9Sstevel@tonic-gate char *s; 212*7c478bd9Sstevel@tonic-gate boolean_t inquote = B_FALSE; 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate /* 215*7c478bd9Sstevel@tonic-gate * * STRATEGY - we make two copies of the attr string. In one * 216*7c478bd9Sstevel@tonic-gate * string we escape (translate) all relevant quoted characters to * a 217*7c478bd9Sstevel@tonic-gate * non-significant character. We use this string to feed to * strtok 218*7c478bd9Sstevel@tonic-gate * to do the parsing. * Once strtok has parsed the string, we use the 219*7c478bd9Sstevel@tonic-gate * same fragement * positions from the unescaped string to pass to 220*7c478bd9Sstevel@tonic-gate * the next level. 221*7c478bd9Sstevel@tonic-gate */ 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate /* make two copies of the string */ 224*7c478bd9Sstevel@tonic-gate refptr = strdup(attrs); 225*7c478bd9Sstevel@tonic-gate escptr = strdup(attrs); 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate /* escape any quoted ';'s in the escptr string */ 228*7c478bd9Sstevel@tonic-gate for (s = escptr; *s; s++) { 229*7c478bd9Sstevel@tonic-gate switch (*s) { 230*7c478bd9Sstevel@tonic-gate case ';': 231*7c478bd9Sstevel@tonic-gate if (inquote) 232*7c478bd9Sstevel@tonic-gate *s = '#'; 233*7c478bd9Sstevel@tonic-gate break; 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate case '\'': 236*7c478bd9Sstevel@tonic-gate inquote = (inquote) ? B_FALSE : B_TRUE; 237*7c478bd9Sstevel@tonic-gate break; 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate default: 240*7c478bd9Sstevel@tonic-gate /* nothing on purpose */ 241*7c478bd9Sstevel@tonic-gate break; 242*7c478bd9Sstevel@tonic-gate } 243*7c478bd9Sstevel@tonic-gate } 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate /* loop over each attribute section separated by ';' */ 246*7c478bd9Sstevel@tonic-gate for (pair = strtok_r(escptr, ";", &lasts); pair; 247*7c478bd9Sstevel@tonic-gate pair = strtok_r(NULL, ";", &lasts)) { 248*7c478bd9Sstevel@tonic-gate char *escattr; 249*7c478bd9Sstevel@tonic-gate char *escvals; 250*7c478bd9Sstevel@tonic-gate char *refattr; 251*7c478bd9Sstevel@tonic-gate char *refvals; 252*7c478bd9Sstevel@tonic-gate char emptystr[1]; 253*7c478bd9Sstevel@tonic-gate 254*7c478bd9Sstevel@tonic-gate escattr = strtok_r(pair, " \t", &escvals); 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate /* 257*7c478bd9Sstevel@tonic-gate * setup the ref pointers to the same locations as the esc 258*7c478bd9Sstevel@tonic-gate * ptrs 259*7c478bd9Sstevel@tonic-gate */ 260*7c478bd9Sstevel@tonic-gate /* 261*7c478bd9Sstevel@tonic-gate * null the reference string in the same spots as the esc 262*7c478bd9Sstevel@tonic-gate * string 263*7c478bd9Sstevel@tonic-gate */ 264*7c478bd9Sstevel@tonic-gate refattr = (refptr + (escattr - escptr)); 265*7c478bd9Sstevel@tonic-gate refattr[strlen(escattr)] = '\0'; 266*7c478bd9Sstevel@tonic-gate 267*7c478bd9Sstevel@tonic-gate if (escvals && *escvals) { 268*7c478bd9Sstevel@tonic-gate refvals = (refptr + (escvals - escptr)); 269*7c478bd9Sstevel@tonic-gate refvals[strlen(escvals)] = '\0'; 270*7c478bd9Sstevel@tonic-gate } else { 271*7c478bd9Sstevel@tonic-gate refvals = NULL; 272*7c478bd9Sstevel@tonic-gate emptystr[0] = '\0'; 273*7c478bd9Sstevel@tonic-gate } 274*7c478bd9Sstevel@tonic-gate 275*7c478bd9Sstevel@tonic-gate if (spec_match(spec_p, refattr)) { 276*7c478bd9Sstevel@tonic-gate if (refvals) 277*7c478bd9Sstevel@tonic-gate (*fun) (spec_p, refattr, refvals, calldatap); 278*7c478bd9Sstevel@tonic-gate else 279*7c478bd9Sstevel@tonic-gate (*fun) (spec_p, refattr, emptystr, calldatap); 280*7c478bd9Sstevel@tonic-gate } 281*7c478bd9Sstevel@tonic-gate } 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate alldone: 284*7c478bd9Sstevel@tonic-gate if (refptr) 285*7c478bd9Sstevel@tonic-gate free(refptr); 286*7c478bd9Sstevel@tonic-gate if (escptr) 287*7c478bd9Sstevel@tonic-gate free(escptr); 288*7c478bd9Sstevel@tonic-gate 289*7c478bd9Sstevel@tonic-gate } /* end spec_attrtrav */ 290*7c478bd9Sstevel@tonic-gate 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate /* 293*7c478bd9Sstevel@tonic-gate * spec_valtrav() - traverse an value list, calling the supplied function on 294*7c478bd9Sstevel@tonic-gate * each matching value. 295*7c478bd9Sstevel@tonic-gate */ 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate void 298*7c478bd9Sstevel@tonic-gate spec_valtrav(spec_t * spec_p, 299*7c478bd9Sstevel@tonic-gate char *valstr, 300*7c478bd9Sstevel@tonic-gate spec_val_fun_t fun, 301*7c478bd9Sstevel@tonic-gate void *calldatap) 302*7c478bd9Sstevel@tonic-gate { 303*7c478bd9Sstevel@tonic-gate char *s0; 304*7c478bd9Sstevel@tonic-gate char *s; 305*7c478bd9Sstevel@tonic-gate boolean_t intoken = B_FALSE; 306*7c478bd9Sstevel@tonic-gate boolean_t inquote = B_FALSE; 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate /* return immeadiatly on null pointers */ 309*7c478bd9Sstevel@tonic-gate if (!valstr) 310*7c478bd9Sstevel@tonic-gate return; 311*7c478bd9Sstevel@tonic-gate 312*7c478bd9Sstevel@tonic-gate /* special case, match once on empty string */ 313*7c478bd9Sstevel@tonic-gate if (!*valstr) { 314*7c478bd9Sstevel@tonic-gate if (spec_match(spec_p, valstr)) 315*7c478bd9Sstevel@tonic-gate (*fun) (spec_p, valstr, calldatap); 316*7c478bd9Sstevel@tonic-gate return; 317*7c478bd9Sstevel@tonic-gate } 318*7c478bd9Sstevel@tonic-gate for (s = s0 = valstr; ; s++) { 319*7c478bd9Sstevel@tonic-gate switch (*s) { 320*7c478bd9Sstevel@tonic-gate case NULL: 321*7c478bd9Sstevel@tonic-gate if (intoken) { 322*7c478bd9Sstevel@tonic-gate if (spec_match(spec_p, s0)) 323*7c478bd9Sstevel@tonic-gate (*fun) (spec_p, s0, calldatap); 324*7c478bd9Sstevel@tonic-gate } 325*7c478bd9Sstevel@tonic-gate return; /* ALL DONE */ 326*7c478bd9Sstevel@tonic-gate 327*7c478bd9Sstevel@tonic-gate case '\'': 328*7c478bd9Sstevel@tonic-gate if (inquote) { 329*7c478bd9Sstevel@tonic-gate /* end a quoted string */ 330*7c478bd9Sstevel@tonic-gate inquote = B_FALSE; 331*7c478bd9Sstevel@tonic-gate intoken = B_FALSE; 332*7c478bd9Sstevel@tonic-gate *s = '\0'; 333*7c478bd9Sstevel@tonic-gate if (spec_match(spec_p, s0)) 334*7c478bd9Sstevel@tonic-gate (*fun) (spec_p, s0, calldatap); 335*7c478bd9Sstevel@tonic-gate /* next string starts past the quote */ 336*7c478bd9Sstevel@tonic-gate s0 = s + 1; 337*7c478bd9Sstevel@tonic-gate } else { 338*7c478bd9Sstevel@tonic-gate /* start a quoted string */ 339*7c478bd9Sstevel@tonic-gate inquote = B_TRUE; 340*7c478bd9Sstevel@tonic-gate intoken = B_TRUE; 341*7c478bd9Sstevel@tonic-gate s0 = s + 1; /* point past the quote */ 342*7c478bd9Sstevel@tonic-gate } 343*7c478bd9Sstevel@tonic-gate break; 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate case ' ': 346*7c478bd9Sstevel@tonic-gate case '\t': 347*7c478bd9Sstevel@tonic-gate /* ignore whitespace in quoted strings */ 348*7c478bd9Sstevel@tonic-gate if (inquote) 349*7c478bd9Sstevel@tonic-gate break; 350*7c478bd9Sstevel@tonic-gate 351*7c478bd9Sstevel@tonic-gate if (intoken) { 352*7c478bd9Sstevel@tonic-gate /* whitespace ended this token */ 353*7c478bd9Sstevel@tonic-gate intoken = B_FALSE; 354*7c478bd9Sstevel@tonic-gate *s = '\0'; 355*7c478bd9Sstevel@tonic-gate if (spec_match(spec_p, s0)) 356*7c478bd9Sstevel@tonic-gate (*fun) (spec_p, s0, calldatap); 357*7c478bd9Sstevel@tonic-gate /* next string starts past the whitespace */ 358*7c478bd9Sstevel@tonic-gate s0 = s + 1; 359*7c478bd9Sstevel@tonic-gate } 360*7c478bd9Sstevel@tonic-gate break; 361*7c478bd9Sstevel@tonic-gate 362*7c478bd9Sstevel@tonic-gate default: 363*7c478bd9Sstevel@tonic-gate /* characters all OK inside quoted string */ 364*7c478bd9Sstevel@tonic-gate if (inquote) 365*7c478bd9Sstevel@tonic-gate break; 366*7c478bd9Sstevel@tonic-gate 367*7c478bd9Sstevel@tonic-gate if (!intoken) { 368*7c478bd9Sstevel@tonic-gate /* start of unquoted token */ 369*7c478bd9Sstevel@tonic-gate intoken = B_TRUE; 370*7c478bd9Sstevel@tonic-gate s0 = s; /* token starts here */ 371*7c478bd9Sstevel@tonic-gate } 372*7c478bd9Sstevel@tonic-gate break; 373*7c478bd9Sstevel@tonic-gate } 374*7c478bd9Sstevel@tonic-gate } 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate 377*7c478bd9Sstevel@tonic-gate #ifdef TOOSIMPLE 378*7c478bd9Sstevel@tonic-gate char *v; 379*7c478bd9Sstevel@tonic-gate char *ls; 380*7c478bd9Sstevel@tonic-gate 381*7c478bd9Sstevel@tonic-gate /* 382*7c478bd9Sstevel@tonic-gate * #### MISSING - need to handle quoted value strings * containing 383*7c478bd9Sstevel@tonic-gate * whitespace. 384*7c478bd9Sstevel@tonic-gate */ 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate for (v = strtok_r(valstr, " \t", &ls); v; 387*7c478bd9Sstevel@tonic-gate v = strtok_r(NULL, " \t", &ls)) { 388*7c478bd9Sstevel@tonic-gate if (spec_match(spec_p, v)) { 389*7c478bd9Sstevel@tonic-gate (*fun) (spec_p, v, calldatap); 390*7c478bd9Sstevel@tonic-gate } 391*7c478bd9Sstevel@tonic-gate } 392*7c478bd9Sstevel@tonic-gate #endif 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate } /* end spec_valtrav */ 395