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) 1995 Sun Microsystems, Inc. All Rights Reserved 24*7c478bd9Sstevel@tonic-gate * 25*7c478bd9Sstevel@tonic-gate * module: 26*7c478bd9Sstevel@tonic-gate * ignore.c 27*7c478bd9Sstevel@tonic-gate * 28*7c478bd9Sstevel@tonic-gate * purpose: 29*7c478bd9Sstevel@tonic-gate * routines to manage the ignore lists and test names against them, 30*7c478bd9Sstevel@tonic-gate * 31*7c478bd9Sstevel@tonic-gate * contents: 32*7c478bd9Sstevel@tonic-gate * ignore_check ... is a particular file covered by an ignore rule 33*7c478bd9Sstevel@tonic-gate * ignore_file .... add a specific file name to be ignored 34*7c478bd9Sstevel@tonic-gate * ignore_expr .... add a regular expression for files to be ignored 35*7c478bd9Sstevel@tonic-gate * ignore_pgm ..... add a rule to run a program to generate a list 36*7c478bd9Sstevel@tonic-gate * ignore_reset ... flush the internal optimization data structures 37*7c478bd9Sstevel@tonic-gate * 38*7c478bd9Sstevel@tonic-gate * static 39*7c478bd9Sstevel@tonic-gate * ign_hash ... maintain a hash table of ignored names 40*7c478bd9Sstevel@tonic-gate * cheap_check. build up a table of safe suffixes 41*7c478bd9Sstevel@tonic-gate * 42*7c478bd9Sstevel@tonic-gate * notes: 43*7c478bd9Sstevel@tonic-gate * a much simpler implementation could have been provided, but 44*7c478bd9Sstevel@tonic-gate * this test (every file tested against every rule) has the 45*7c478bd9Sstevel@tonic-gate * potential to be EXTREMELY expensive. This module implements 46*7c478bd9Sstevel@tonic-gate * an engine that attempts to optimize the process of determining 47*7c478bd9Sstevel@tonic-gate * that a file has not been ignored. 48*7c478bd9Sstevel@tonic-gate * 49*7c478bd9Sstevel@tonic-gate * the usage scenario is 50*7c478bd9Sstevel@tonic-gate * per base 51*7c478bd9Sstevel@tonic-gate * call ignore_{file,expr,pgm} for each ignore rule 52*7c478bd9Sstevel@tonic-gate * call ignore_check for every file under the base 53*7c478bd9Sstevel@tonic-gate * call ignore_reset when you are done 54*7c478bd9Sstevel@tonic-gate */ 55*7c478bd9Sstevel@tonic-gate #ident "%W% %E% SMI" 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate #include <stdio.h> 58*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 59*7c478bd9Sstevel@tonic-gate #include <string.h> 60*7c478bd9Sstevel@tonic-gate #include <libgen.h> 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate #include "filesync.h" 63*7c478bd9Sstevel@tonic-gate #include "messages.h" 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate /* 66*7c478bd9Sstevel@tonic-gate * routines: 67*7c478bd9Sstevel@tonic-gate */ 68*7c478bd9Sstevel@tonic-gate static struct list *ign_hash(const char *, int); 69*7c478bd9Sstevel@tonic-gate static void cheap_check(const char *); 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* 72*7c478bd9Sstevel@tonic-gate * globals 73*7c478bd9Sstevel@tonic-gate */ 74*7c478bd9Sstevel@tonic-gate struct list { 75*7c478bd9Sstevel@tonic-gate char *l_value; /* the actual string */ 76*7c478bd9Sstevel@tonic-gate struct list *l_next; /* pointer to next element */ 77*7c478bd9Sstevel@tonic-gate }; 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate static struct list *expr_list; /* list of regular expressions */ 80*7c478bd9Sstevel@tonic-gate static struct list *file_list[ HASH_SIZE ]; /* hash table of literal names */ 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate static char cheap_last[256]; /* cheap test: last char */ 83*7c478bd9Sstevel@tonic-gate static char cheap_penu[256]; /* cheap test: penultimate char */ 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate /* 86*7c478bd9Sstevel@tonic-gate * routine: 87*7c478bd9Sstevel@tonic-gate * ignore_check 88*7c478bd9Sstevel@tonic-gate * 89*7c478bd9Sstevel@tonic-gate * purpose: 90*7c478bd9Sstevel@tonic-gate * determine whether or not a particular name matches an ignore pattern. 91*7c478bd9Sstevel@tonic-gate * 92*7c478bd9Sstevel@tonic-gate * parameters: 93*7c478bd9Sstevel@tonic-gate * file name 94*7c478bd9Sstevel@tonic-gate * 95*7c478bd9Sstevel@tonic-gate * returns: 96*7c478bd9Sstevel@tonic-gate * true/false 97*7c478bd9Sstevel@tonic-gate * 98*7c478bd9Sstevel@tonic-gate * note: 99*7c478bd9Sstevel@tonic-gate * becuse this routine is called on every single file in 100*7c478bd9Sstevel@tonic-gate * every single sub-directory, it is critical that we make 101*7c478bd9Sstevel@tonic-gate * it fail quickly for most files. The purpose of the cheap_last 102*7c478bd9Sstevel@tonic-gate * and cheap_penu arrays is to quickly determine there is no chance 103*7c478bd9Sstevel@tonic-gate * that a name will match any expression. Most expressions have 104*7c478bd9Sstevel@tonic-gate * wildcards near the front and constant suffixes, so our cheap 105*7c478bd9Sstevel@tonic-gate * test is to look at the last two bytes. 106*7c478bd9Sstevel@tonic-gate */ 107*7c478bd9Sstevel@tonic-gate bool_t 108*7c478bd9Sstevel@tonic-gate ignore_check(const char *name) 109*7c478bd9Sstevel@tonic-gate { struct list *lp; 110*7c478bd9Sstevel@tonic-gate const char *s; 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /* 113*7c478bd9Sstevel@tonic-gate * start with the cheap test 114*7c478bd9Sstevel@tonic-gate */ 115*7c478bd9Sstevel@tonic-gate for (s = name; *s; s++); 116*7c478bd9Sstevel@tonic-gate if (cheap_last[ (unsigned char) s[-1] ] == 0 || 117*7c478bd9Sstevel@tonic-gate cheap_penu[ (unsigned char) s[-2] ] == 0) 118*7c478bd9Sstevel@tonic-gate return (FALSE); 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* check the literal names in the hash table */ 121*7c478bd9Sstevel@tonic-gate if (ign_hash(name, 0)) { 122*7c478bd9Sstevel@tonic-gate if (opt_debug & DBG_IGNORE) 123*7c478bd9Sstevel@tonic-gate fprintf(stderr, "IGNO: match %s\n", name); 124*7c478bd9Sstevel@tonic-gate return (TRUE); 125*7c478bd9Sstevel@tonic-gate } 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate /* check all the regular expressions */ 128*7c478bd9Sstevel@tonic-gate for (lp = expr_list; lp; lp = lp->l_next) { 129*7c478bd9Sstevel@tonic-gate if (gmatch(name, lp->l_value) == 0) 130*7c478bd9Sstevel@tonic-gate continue; 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate if (opt_debug & DBG_IGNORE) 133*7c478bd9Sstevel@tonic-gate fprintf(stderr, "IGNO: regex %s : %s\n", 134*7c478bd9Sstevel@tonic-gate lp->l_value, name); 135*7c478bd9Sstevel@tonic-gate return (TRUE); 136*7c478bd9Sstevel@tonic-gate } 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate return (FALSE); 139*7c478bd9Sstevel@tonic-gate } 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate /* 142*7c478bd9Sstevel@tonic-gate * routine: 143*7c478bd9Sstevel@tonic-gate * ignore_file 144*7c478bd9Sstevel@tonic-gate * 145*7c478bd9Sstevel@tonic-gate * purpose: 146*7c478bd9Sstevel@tonic-gate * to add a specific file to an ignore list 147*7c478bd9Sstevel@tonic-gate * 148*7c478bd9Sstevel@tonic-gate * parameters: 149*7c478bd9Sstevel@tonic-gate * command to run 150*7c478bd9Sstevel@tonic-gate */ 151*7c478bd9Sstevel@tonic-gate void 152*7c478bd9Sstevel@tonic-gate ignore_file(const char *name) 153*7c478bd9Sstevel@tonic-gate { 154*7c478bd9Sstevel@tonic-gate cheap_check(name); 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate (void) ign_hash(name, 1); 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate if (opt_debug & DBG_IGNORE) 159*7c478bd9Sstevel@tonic-gate fprintf(stderr, "IGNO: add file %s\n", name); 160*7c478bd9Sstevel@tonic-gate } 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate /* 163*7c478bd9Sstevel@tonic-gate * routine: 164*7c478bd9Sstevel@tonic-gate * ignore_expr 165*7c478bd9Sstevel@tonic-gate * 166*7c478bd9Sstevel@tonic-gate * purpose: 167*7c478bd9Sstevel@tonic-gate * to add a regular expression to an ignore list 168*7c478bd9Sstevel@tonic-gate * 169*7c478bd9Sstevel@tonic-gate * parameters: 170*7c478bd9Sstevel@tonic-gate * command to run 171*7c478bd9Sstevel@tonic-gate */ 172*7c478bd9Sstevel@tonic-gate void 173*7c478bd9Sstevel@tonic-gate ignore_expr(const char *expr) 174*7c478bd9Sstevel@tonic-gate { struct list *lp; 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate cheap_check(expr); 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate /* allocate a new node and stick it on the front of the list */ 179*7c478bd9Sstevel@tonic-gate lp = malloc(sizeof (*lp)); 180*7c478bd9Sstevel@tonic-gate if (lp == 0) 181*7c478bd9Sstevel@tonic-gate nomem("ignore list"); 182*7c478bd9Sstevel@tonic-gate lp->l_value = strdup(expr); 183*7c478bd9Sstevel@tonic-gate lp->l_next = expr_list; 184*7c478bd9Sstevel@tonic-gate expr_list = lp; 185*7c478bd9Sstevel@tonic-gate 186*7c478bd9Sstevel@tonic-gate if (opt_debug & DBG_IGNORE) 187*7c478bd9Sstevel@tonic-gate fprintf(stderr, "IGNO: add expr %s\n", expr); 188*7c478bd9Sstevel@tonic-gate } 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate /* 191*7c478bd9Sstevel@tonic-gate * routine: 192*7c478bd9Sstevel@tonic-gate * ignore_pgm 193*7c478bd9Sstevel@tonic-gate * 194*7c478bd9Sstevel@tonic-gate * purpose: 195*7c478bd9Sstevel@tonic-gate * to run a program and gather up the ignore list it produces 196*7c478bd9Sstevel@tonic-gate * 197*7c478bd9Sstevel@tonic-gate * parameters: 198*7c478bd9Sstevel@tonic-gate * command to run 199*7c478bd9Sstevel@tonic-gate */ 200*7c478bd9Sstevel@tonic-gate void 201*7c478bd9Sstevel@tonic-gate ignore_pgm(const char *cmd) 202*7c478bd9Sstevel@tonic-gate { char *s; 203*7c478bd9Sstevel@tonic-gate FILE *fp; 204*7c478bd9Sstevel@tonic-gate char inbuf[ MAX_LINE ]; 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate if (opt_debug & DBG_IGNORE) 207*7c478bd9Sstevel@tonic-gate fprintf(stderr, "IGNO: add pgm %s\n", cmd); 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate /* run the command and collect its ouput */ 210*7c478bd9Sstevel@tonic-gate fp = popen(cmd, "r"); 211*7c478bd9Sstevel@tonic-gate if (fp == NULL) { 212*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext(ERR_badrun), cmd); 213*7c478bd9Sstevel@tonic-gate return; 214*7c478bd9Sstevel@tonic-gate } 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate /* 217*7c478bd9Sstevel@tonic-gate * read each line, strip off the newline and add it to the list 218*7c478bd9Sstevel@tonic-gate */ 219*7c478bd9Sstevel@tonic-gate while (fgets(inbuf, sizeof (inbuf), fp) != 0) { 220*7c478bd9Sstevel@tonic-gate /* strip off any trailing newline */ 221*7c478bd9Sstevel@tonic-gate for (s = inbuf; *s && *s != '\n'; s++); 222*7c478bd9Sstevel@tonic-gate *s = 0; 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate /* skip any leading white space */ 225*7c478bd9Sstevel@tonic-gate for (s = inbuf; *s == ' ' || *s == '\t'; s++); 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate /* add this file to the list */ 228*7c478bd9Sstevel@tonic-gate if (*s) { 229*7c478bd9Sstevel@tonic-gate cheap_check(s); 230*7c478bd9Sstevel@tonic-gate (void) ign_hash(s, 1); 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate if (opt_debug & DBG_IGNORE) 233*7c478bd9Sstevel@tonic-gate fprintf(stderr, "IGNO: ... %s\n", s); 234*7c478bd9Sstevel@tonic-gate } 235*7c478bd9Sstevel@tonic-gate } 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate pclose(fp); 238*7c478bd9Sstevel@tonic-gate } 239*7c478bd9Sstevel@tonic-gate 240*7c478bd9Sstevel@tonic-gate /* 241*7c478bd9Sstevel@tonic-gate * routine: 242*7c478bd9Sstevel@tonic-gate * ign_hash 243*7c478bd9Sstevel@tonic-gate * 244*7c478bd9Sstevel@tonic-gate * purpose: 245*7c478bd9Sstevel@tonic-gate * to find an entry in the hash list 246*7c478bd9Sstevel@tonic-gate * 247*7c478bd9Sstevel@tonic-gate * parameters: 248*7c478bd9Sstevel@tonic-gate * name 249*7c478bd9Sstevel@tonic-gate * allocate flag 250*7c478bd9Sstevel@tonic-gate * 251*7c478bd9Sstevel@tonic-gate * returns: 252*7c478bd9Sstevel@tonic-gate * pointer to new list entry or 0 253*7c478bd9Sstevel@tonic-gate */ 254*7c478bd9Sstevel@tonic-gate static struct list * 255*7c478bd9Sstevel@tonic-gate ign_hash(const char *name, int alloc) 256*7c478bd9Sstevel@tonic-gate { const unsigned char *s; 257*7c478bd9Sstevel@tonic-gate int i; 258*7c478bd9Sstevel@tonic-gate struct list *lp; 259*7c478bd9Sstevel@tonic-gate struct list **pp; 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate /* perform the hash and find the chain */ 262*7c478bd9Sstevel@tonic-gate for (s = (const unsigned char *) name, i = 0; *s; s++) 263*7c478bd9Sstevel@tonic-gate i += *s; 264*7c478bd9Sstevel@tonic-gate pp = &file_list[i % HASH_SIZE ]; 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate /* search for the specified entry */ 267*7c478bd9Sstevel@tonic-gate for (lp = *pp; lp; lp = *pp) { 268*7c478bd9Sstevel@tonic-gate if (strcmp(name, lp->l_value) == 0) 269*7c478bd9Sstevel@tonic-gate return (lp); 270*7c478bd9Sstevel@tonic-gate pp = &(lp->l_next); 271*7c478bd9Sstevel@tonic-gate } 272*7c478bd9Sstevel@tonic-gate 273*7c478bd9Sstevel@tonic-gate /* if caller said alloc, buy a new node and chain it in */ 274*7c478bd9Sstevel@tonic-gate if (alloc) { 275*7c478bd9Sstevel@tonic-gate lp = malloc(sizeof (*lp)); 276*7c478bd9Sstevel@tonic-gate if (lp == 0) 277*7c478bd9Sstevel@tonic-gate nomem("ignore list"); 278*7c478bd9Sstevel@tonic-gate lp->l_value = strdup(name); 279*7c478bd9Sstevel@tonic-gate lp->l_next = 0; 280*7c478bd9Sstevel@tonic-gate *pp = lp; 281*7c478bd9Sstevel@tonic-gate } 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate return (lp); 284*7c478bd9Sstevel@tonic-gate } 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate /* 287*7c478bd9Sstevel@tonic-gate * routine: 288*7c478bd9Sstevel@tonic-gate * cheap_check 289*7c478bd9Sstevel@tonic-gate * 290*7c478bd9Sstevel@tonic-gate * purpose: 291*7c478bd9Sstevel@tonic-gate * to update the cheap-check arrays for an ignore expression 292*7c478bd9Sstevel@tonic-gate * 293*7c478bd9Sstevel@tonic-gate * parameters: 294*7c478bd9Sstevel@tonic-gate * name/expression 295*7c478bd9Sstevel@tonic-gate */ 296*7c478bd9Sstevel@tonic-gate static void 297*7c478bd9Sstevel@tonic-gate cheap_check(const char *name) 298*7c478bd9Sstevel@tonic-gate { const char *s; 299*7c478bd9Sstevel@tonic-gate unsigned char c; 300*7c478bd9Sstevel@tonic-gate int i; 301*7c478bd9Sstevel@tonic-gate 302*7c478bd9Sstevel@tonic-gate for (s = name; *s; s++); 303*7c478bd9Sstevel@tonic-gate s--; 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate /* if expr ends in a wild card, we are undone */ 306*7c478bd9Sstevel@tonic-gate c = *s; 307*7c478bd9Sstevel@tonic-gate if (c == '*' || c == '?' || c == ']' || c == '}') { 308*7c478bd9Sstevel@tonic-gate for (i = 0; i < 256; i++) { 309*7c478bd9Sstevel@tonic-gate cheap_last[i] = 1; 310*7c478bd9Sstevel@tonic-gate cheap_penu[i] = 1; 311*7c478bd9Sstevel@tonic-gate } 312*7c478bd9Sstevel@tonic-gate return; 313*7c478bd9Sstevel@tonic-gate } else 314*7c478bd9Sstevel@tonic-gate cheap_last[c] = 1; 315*7c478bd9Sstevel@tonic-gate 316*7c478bd9Sstevel@tonic-gate if (s <= name) 317*7c478bd9Sstevel@tonic-gate return; 318*7c478bd9Sstevel@tonic-gate 319*7c478bd9Sstevel@tonic-gate /* check the next to last character too */ 320*7c478bd9Sstevel@tonic-gate c = s[-1]; 321*7c478bd9Sstevel@tonic-gate if (c == '*' || c == '?' || c == ']' || c == '}') { 322*7c478bd9Sstevel@tonic-gate for (i = 0; i < 256; i++) 323*7c478bd9Sstevel@tonic-gate cheap_penu[i] = 1; 324*7c478bd9Sstevel@tonic-gate } else 325*7c478bd9Sstevel@tonic-gate cheap_penu[c] = 1; 326*7c478bd9Sstevel@tonic-gate } 327*7c478bd9Sstevel@tonic-gate 328*7c478bd9Sstevel@tonic-gate /* 329*7c478bd9Sstevel@tonic-gate * routine: 330*7c478bd9Sstevel@tonic-gate * ignore_reset 331*7c478bd9Sstevel@tonic-gate * 332*7c478bd9Sstevel@tonic-gate * purpose: 333*7c478bd9Sstevel@tonic-gate * to free up all the ignore entries so we can start anew 334*7c478bd9Sstevel@tonic-gate */ 335*7c478bd9Sstevel@tonic-gate void 336*7c478bd9Sstevel@tonic-gate ignore_reset(void) 337*7c478bd9Sstevel@tonic-gate { int i; 338*7c478bd9Sstevel@tonic-gate struct list *np = 0; /* for LINT */ 339*7c478bd9Sstevel@tonic-gate struct list *lp; 340*7c478bd9Sstevel@tonic-gate 341*7c478bd9Sstevel@tonic-gate /* clear the cheap check arrays */ 342*7c478bd9Sstevel@tonic-gate for (i = 0; i < 255; i++) { 343*7c478bd9Sstevel@tonic-gate cheap_last[i] = 0; 344*7c478bd9Sstevel@tonic-gate cheap_penu[i] = 0; 345*7c478bd9Sstevel@tonic-gate } 346*7c478bd9Sstevel@tonic-gate 347*7c478bd9Sstevel@tonic-gate /* free all of the literal hash chains */ 348*7c478bd9Sstevel@tonic-gate for (i = 0; i < HASH_SIZE; i++) { 349*7c478bd9Sstevel@tonic-gate for (lp = file_list[i]; lp; lp = np) { 350*7c478bd9Sstevel@tonic-gate np = lp->l_next; 351*7c478bd9Sstevel@tonic-gate free(lp->l_value); 352*7c478bd9Sstevel@tonic-gate free(lp); 353*7c478bd9Sstevel@tonic-gate } 354*7c478bd9Sstevel@tonic-gate file_list[i] = 0; 355*7c478bd9Sstevel@tonic-gate } 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate /* free all of the expressions on the chain */ 358*7c478bd9Sstevel@tonic-gate for (lp = expr_list; lp; lp = np) { 359*7c478bd9Sstevel@tonic-gate np = lp->l_next; 360*7c478bd9Sstevel@tonic-gate free(lp->l_value); 361*7c478bd9Sstevel@tonic-gate free(lp); 362*7c478bd9Sstevel@tonic-gate } 363*7c478bd9Sstevel@tonic-gate expr_list = 0; 364*7c478bd9Sstevel@tonic-gate } 365