1 /*****************************************************************************\
4 *****************************************************************************
5 * Copyright (C) 2002-2005 The Regents of the University of California.
6 * Produced at the Lawrence Livermore National Laboratory.
7 * Written by Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>.
11 * This file is part of nvramtool, a utility for reading/writing coreboot
12 * parameters and displaying information from the coreboot table.
13 * For details, see http://coreboot.org/nvramtool.
15 * Please also read the file DISCLAIMER which is included in this software
18 * This program is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License (as published by the
20 * Free Software Foundation) version 2, dated June 1991.
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
25 * conditions of the GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
30 \*****************************************************************************/
36 /****************************************************************************
39 * Compile a bunch of regular expressions.
40 ****************************************************************************/
41 void compile_reg_exprs (int cflags, int num_exprs,
42 /* const char *expr1, regex_t *reg1, */ ...)
43 { static const size_t ERROR_BUF_SIZE = 256;
44 char error_msg[ERROR_BUF_SIZE];
50 va_start(ap, num_exprs);
52 for (i = 0; i < num_exprs; i++)
53 { expr = va_arg(ap, const char *);
54 reg = va_arg(ap, regex_t *);
56 if ((result = regcomp(reg, expr, cflags)) != 0)
57 { regerror(result, reg, error_msg, ERROR_BUF_SIZE);
58 fprintf(stderr, "%s: %s\n", prog_name, error_msg);
66 /****************************************************************************
69 * Destroy a bunch of previously compiled regular expressions.
70 ****************************************************************************/
71 void free_reg_exprs (int num_exprs, /* regex_t *reg1, */ ...)
75 va_start(ap, num_exprs);
77 for (i = 0; i < num_exprs; i++)
78 regfree(va_arg(ap, regex_t *));