pkg: store size, installed size and installed time info in blob buffer
[oweals/opkg-lede.git] / libopkg / xregex.c
1 /* xregex.c - regex functions with error messages
2
3    Carl D. Worth
4
5    Copyright (C) 2001 University of Southern California
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2, or (at your option)
10    any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 */
17
18 #include "xregex.h"
19 #include "libbb/libbb.h"
20
21 static void print_regcomp_err(const regex_t * preg, int err);
22
23 int xregcomp(regex_t * preg, const char *regex, int cflags)
24 {
25         int err;
26         err = regcomp(preg, regex, cflags);
27         if (err) {
28                 print_regcomp_err(preg, err);
29         }
30
31         return err;
32 }
33
34 static void print_regcomp_err(const regex_t * preg, int err)
35 {
36         unsigned int size;
37         char *error;
38
39         size = regerror(err, preg, 0, 0);
40         error = xcalloc(1, size);
41         regerror(err, preg, error, size);
42
43         opkg_msg(ERROR, "Internal error compiling regex: %s.", error);
44
45         free(error);
46 }