aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2008-11-16 02:28:16 +0000
committerMike Frysinger <vapier@gentoo.org>2008-11-16 02:28:16 +0000
commitbd391f56049dbb8d9564793acd462f0f1fac69c3 (patch)
tree3949fdf2ba0b009ce63e79479373ad60ef91409a /libsbutil/src
parentlibsbutil: unify duplicate log debug functions (diff)
downloadsandbox-bd391f56049dbb8d9564793acd462f0f1fac69c3.tar.gz
sandbox-bd391f56049dbb8d9564793acd462f0f1fac69c3.tar.bz2
sandbox-bd391f56049dbb8d9564793acd462f0f1fac69c3.zip
libsbutil: drop some unused code
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil/src')
-rw-r--r--libsbutil/src/Makefile.am19
-rw-r--r--libsbutil/src/debug.c12
-rw-r--r--libsbutil/src/librcutil.map68
-rw-r--r--libsbutil/src/simple-regex.c851
-rw-r--r--libsbutil/src/string.c19
5 files changed, 0 insertions, 969 deletions
diff --git a/libsbutil/src/Makefile.am b/libsbutil/src/Makefile.am
deleted file mode 100644
index 086764b..0000000
--- a/libsbutil/src/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-AUTOMAKE_OPTIONS = foreign
-
-INCLUDES = \
- -I$(top_srcdir)/include \
- $(RCSCRIPTS_DEFINES)
-
-lib_LTLIBRARIES = librcutil.la
-
-librcutil_la_LDFLAGS = \
- -Wl,--version-script,$(srcdir)/librcutil.map
-librcutil_la_SOURCES = \
- debug.c \
- string.c \
- file.c \
- config.c \
- dynbuf.c \
- simple-regex.c
-
-EXTRA_DIST = librcutil.map
diff --git a/libsbutil/src/debug.c b/libsbutil/src/debug.c
index 1e2a28d..4e50a6e 100644
--- a/libsbutil/src/debug.c
+++ b/libsbutil/src/debug.c
@@ -11,7 +11,6 @@
#include "headers.h"
#include "rcscripts/rcutil.h"
-volatile static bool debug_enabled = true;
volatile static int debug_errno = 0;
static char log_domain_default[] = "rcscripts";
@@ -25,12 +24,6 @@ rc_log_domain (const char *new_domain)
}
void
-rc_debug_enabled (bool enabled)
-{
- debug_enabled = enabled;
-}
-
-void
rc_errno_set (int rc_errno)
{
if (rc_errno >= 0)
@@ -63,11 +56,6 @@ debug_message (const char *file, const char *func, int line,
char *format_str;
int length;
-#if !defined(RC_DEBUG)
- if (!debug_enabled)
- return;
-#endif
-
length = strlen (log_domain) + strlen ("(): ") + 1;
/* Do not use xmalloc() here, else we may have recursive issues */
format_str = malloc (length);
diff --git a/libsbutil/src/librcutil.map b/libsbutil/src/librcutil.map
deleted file mode 100644
index 3b45515..0000000
--- a/libsbutil/src/librcutil.map
+++ /dev/null
@@ -1,68 +0,0 @@
-RCUTIL_0.0.0 {
- global:
- # debug.c
- rc_log_domain;
- rc_debug_enabled;
- rc_errno_set;
- rc_errno_clear;
- rc_errno_get;
- rc_errno_is_set;
- debug_message;
- check_ptr;
- check_str;
- check_strv;
- check_fd;
- check_fp;
- __check_arg_ptr;
- __check_arg_str;
- __check_arg_strv;
- __check_arg_fd;
- __check_arg_fp;
- __xcalloc;
- __xmalloc;
- __xrealloc;
- __xstrndup;
-
- # config.c
- rc_get_cnf_entry;
- rc_get_list_file;
-
- # dynbuf.c
- rc_dynbuf_new;
- rc_dynbuf_new_mmap_file;
- rc_dynbuf_free;
- rc_dynbuf_write;
- rc_dynbuf_write_fd;
- rc_dynbuf_sprintf;
- rc_dynbuf_read;
- rc_dynbuf_read_fd;
- rc_dynbuf_read_line;
- rc_dynbuf_read_eof;
- rc_check_dynbuf;
- __rc_check_arg_dynbuf;
-
- # file.c
- rc_file_exists;
- rc_is_file;
- rc_is_link;
- rc_is_dir;
- rc_get_mtime;
- remove;
- rc_mktree;
- rc_rmtree;
- rc_ls_dir;
- rc_file_map;
- rc_file_unmap;
-
- # simple-regex.c
- match;
-
- # string.c
- rc_memrepchr;
- rc_strcatpaths;
- rc_strndup;
- rc_basename;
-
- local:
- *;
-};
diff --git a/libsbutil/src/simple-regex.c b/libsbutil/src/simple-regex.c
deleted file mode 100644
index 61eff6d..0000000
--- a/libsbutil/src/simple-regex.c
+++ /dev/null
@@ -1,851 +0,0 @@
-/*
- * simple_regex.c
- *
- * Simle regex library.
- *
- * Copyright 1999-2008 Gentoo Foundation
- * Copyright 2004-2007 Martin Schlemmer <azarah@nosferatu.za.org>
- * Licensed under the GPL-2
- */
-
-/*
- * Some notes:
- *
- * - This is a very simple regex library (read: return a match if some string
- * matches some regex). It is probably not POSIX (if there are a POSIX or
- * other standard) compatible.
- *
- * - I primarily wrote it to _not_ use glibc type regex functions, in case we
- * might want to use it in code that have to be linked agaist klibc, etc.
- *
- * - It really is not optimized in any way yet.
- *
- * - Supported operators are:
- *
- * '.', '?', '*', '+' - So called 'wildcards'
- * '[a-z]', '[^a-z]' - Basic 'lists'. Note that 'a-z' just specify that
- * it supports basic lists as well as sequences ..
- * The '^' is for an inverted list of course.
- * '^', '$' - The 'from start' and 'to end' operators. If these
- * are not used at the start ('^') or end ('$') of the
- * regex, they will be treated as normal characters
- * (this of course exclude the use of '^' in a 'list').
- *
- * - If an invalid argument was passed, the functions returns 0 with
- * 'regex_data->match == 0' (no error with no match) rather than -1. It may
- * not be consistant with other practices, but I personally do not feel it is
- * a critical error for these types of functions, and there are debugging you
- * can enable to verify that there are no such issues.
- *
- * - __somefunction() is usually a helper function for somefunction(). I guess
- * recursion might be an alternative, but I try to avoid it.
- *
- * - In general if we are matching a 'wildcard' ('*', '+' or '?'), a 'word'
- * (read: some part of the regex that do not contain a 'wildcard' or 'list')
- * will have a greater 'weight' than the 'wildcard'. This means that we
- * will only continue to evaluate the 'wildcard' until the following 'word'
- * (if any) matches. Currently this do not hold true for a 'list' not
- * followed by a 'wildcard' - I might fix this in future.
- *
- */
-
-#include "headers.h"
-#include "rcscripts/rcutil.h"
-
-/* Macro to check if a regex_data_t pointer is valid */
-#define CHECK_REGEX_DATA_P(_regex_data, _on_error) \
- do { \
- if ((NULL == _regex_data) \
- || (NULL == _regex_data->data) \
- /* We do not check for this, as it might still \
- * provide a match ('*' or '?' wildcard) */ \
- /* || (0 == strlen(_regex_data->data)) */ \
- || (NULL == _regex_data->regex) \
- || (0 == strlen(_regex_data->regex))) \
- { \
- rc_errno_set (EINVAL); \
- DBG_MSG ("Invalid argument passed!\n"); \
- goto _on_error; \
- } \
- } while (0)
-
-static size_t get_word (const char *regex, char **r_word);
-static int match_word (regex_data_t * regex_data);
-static size_t get_list_size (const char *regex);
-static size_t get_list (const char *regex, char **r_list);
-static int __match_list (regex_data_t * regex_data);
-static int match_list (regex_data_t * regex_data);
-static size_t get_wildcard (const char *regex, char *r_wildcard);
-static int __match_wildcard (regex_data_t * regex_data,
- int (*match_func) (regex_data_t * regex_data),
- const char *regex);
-static int match_wildcard (regex_data_t * regex_data);
-static int __match (regex_data_t * regex_data);
-
-/*
- * Return values for match_* functions
- *
- * 0 - There was no error. If there was a match, regex_data->match
- * - will be > 0 (this is the definitive check - if not true, the
- * - other values of the struct may be bogus), regex_data->count
- * - will be the amount of data that was matched (might be 0 for
- * - some wildcards), and regex_data->r_count will be > 0.
- *
- * -1 - An error occured. Check errno for more info.
- *
- */
-
-size_t
-get_word (const char *regex, char **r_word)
-{
- char *r_list;
- char *str_ptr;
- size_t count = 0;
- size_t tmp_count;
-
- if (!check_arg_str (regex))
- return 0;
-
- *r_word = xmalloc (strlen (regex) + 1);
- if (NULL == r_word)
- return 0;
-
- str_ptr = *r_word;
-
- while (strlen (regex) > 0)
- {
- switch (regex[0])
- {
- case '*':
- case '+':
- case '?':
- /* If its a wildcard, backup one step */
- *(--str_ptr) = '\0';
- count--;
- return count;
- case '[':
- tmp_count = get_list (regex, &r_list);
- free (r_list);
- /* In theory should not happen, but you never know
- * what may happen in future ... */
- if (-1 == tmp_count)
- goto error;
-
- /* Bail if we have a list */
- if (tmp_count > 0)
- {
- str_ptr[0] = '\0';
- return count;
- }
- default:
- *str_ptr++ = *regex++;
- count++;
- break;
- }
- }
-
- str_ptr[0] = '\0';
-
- return count;
-
-error:
- free (*r_word);
-
- return -1;
-}
-
-int
-match_word (regex_data_t * regex_data)
-{
- char *data_p = regex_data->data;
- char *r_word = NULL, *r_word_p;
- size_t count = 0;
-
- CHECK_REGEX_DATA_P (regex_data, exit);
-
- count = get_word (regex_data->regex, &r_word);
- if (-1 == count)
- goto error;
- if (0 == count)
- goto exit;
- r_word_p = r_word;
-
- while ((strlen (data_p) > 0) && (strlen (r_word_p) > 0))
- {
- /* If 'r_word' is not 100% part of 'string', we do not have
- * a match. If its a '.', it matches no matter what. */
- if ((data_p[0] != r_word_p[0]) && ('.' != r_word_p[0]))
- {
- count = 0;
- goto exit;
- }
-
- data_p++;
- r_word_p++;
- }
-
- /* If 'string' is shorter than 'r_word', we do not have a match */
- if ((0 == strlen (data_p)) && (0 < strlen (r_word_p)))
- {
- count = 0;
- goto exit;
- }
-
-exit:
- /* Fill in our structure */
- if (0 == count)
- regex_data->match = REGEX_NO_MATCH;
- else if (strlen (regex_data->data) == count)
- regex_data->match = REGEX_FULL_MATCH;
- else
- regex_data->match = REGEX_PARTIAL_MATCH;
- if (regex_data->match != REGEX_NO_MATCH)
- regex_data->where = regex_data->data;
- else
- regex_data->where = NULL;
- regex_data->count = count;
- regex_data->r_count = count;
-
- free (r_word);
- return 0;
-
-error:
- regex_data->match = REGEX_NO_MATCH;
-
- free (r_word);
- return -1;
-}
-
-size_t
-get_list_size (const char *regex)
-{
- size_t count = 0;
-
- if (!check_arg_str (regex))
- return 0;
-
- if ('[' != regex[0])
- {
- rc_errno_set (EINVAL);
- DBG_MSG ("Invalid argument passed!\n");
- return 0;
- }
-
- regex++;
-
- while ((strlen (regex) > 0) && (']' != regex[0]))
- {
- /* We have a sequence (x-y) */
- if (('-' == regex[0])
- && (']' != regex[1])
- && (strlen (regex) >= 2) && (regex[-1] < regex[1]))
- {
- /* Add current + diff in sequence */
- count += regex[1] - regex[-1];
- /* Take care of '-' and next char */
- regex += 2;
- }
- else
- {
- regex++;
- count++;
- }
- }
-
- return count;
-}
-
-size_t
-get_list (const char *regex, char **r_list)
-{
- char *buf = NULL;
- size_t count = 0;
- size_t size;
-
- if (!check_arg_str (regex))
- return 0;
-
- /* Bail if we do not have a list. Do not add debugging, as
- * it is very noisy (used a lot when we call match_list() in
- * __match() and match() to test for list matching) */
- if ('[' != regex[0])
- return 0;
-
- size = get_list_size (regex);
- if (0 == size)
- {
- /* Should not be an issue, but just in case */
- DBG_MSG ("0 returned by get_list_size.\n");
- return 0;
- }
-
- *r_list = xmalloc (size + 1);
- if (NULL == *r_list)
- return -1;
-
- buf = *r_list;
-
- /* Take care of '[' */
- regex++;
- count++;
-
- while ((strlen (regex) > 0) && (']' != regex[0]))
- {
- /* We have a sequence (x-y) */
- if (('-' == regex[0])
- && (']' != regex[1])
- && (strlen (regex) >= 2) && (regex[-1] < regex[1]))
- {
- /* Fill in missing chars in sequence */
- while (buf[-1] < regex[1])
- {
- buf[0] = (char) (buf[-1] + 1);
- buf++;
- /* We do not increase count */
- }
- /* Take care of '-' and next char */
- count += 2;
- regex += 2;
- }
- else
- {
- *buf++ = *regex++;
- count++;
- }
- }
-
- buf[0] = '\0';
- /* Take care of ']' */
- count++;
-
- /* We do not have a list as it does not end in ']' */
- if (']' != regex[0])
- {
- count = 0;
- free (*r_list);
- }
-
- return count;
-}
-
-/* If the first is the '^' character, everything but the list is matched
- * NOTE: We only evaluate _ONE_ data character at a time!! */
-int
-__match_list (regex_data_t * regex_data)
-{
- regex_data_t tmp_data;
- char *data_p = regex_data->data;
- char *list_p = regex_data->regex;
- char test_regex[2] = { '\0', '\0' };
- int invert = 0;
- int lmatch;
- int retval;
-
- CHECK_REGEX_DATA_P (regex_data, failed);
-
- if ('^' == list_p[0])
- {
- /* We need to invert the match */
- invert = 1;
- /* Make sure '^' is not part of our list */
- list_p++;
- }
-
- if (invert)
- /* All should be a match if not in the list */
- lmatch = 1;
- else
- /* We only have a match if in the list */
- lmatch = 0;
-
- while (strlen (list_p) > 0)
- {
- test_regex[0] = list_p[0];
-
- FILL_REGEX_DATA (tmp_data, data_p, test_regex);
- retval = match_word (&tmp_data);
- if (-1 == retval)
- goto error;
-
- if (REGEX_MATCH (tmp_data))
- {
- if (invert)
- /* If we exclude the list from
- * characters we try to match, we
- * have a match until one of the
- * list is found. */
- lmatch = 0;
- else
- /* If not, we have to keep looking
- * until one from the list match
- * before we have a match */
- lmatch = 1;
- break;
- }
- list_p++;
- }
-
- /* Fill in our structure */
- if (lmatch)
- {
- regex_data->match = REGEX_PARTIAL_MATCH;
- regex_data->where = regex_data->data;
- regex_data->count = 1;
- /* This one is more cosmetic, as match_list() will
- * do the right thing */
- regex_data->r_count = 0; /* strlen(regex_data->regex); */
- }
- else
- {
-failed:
- regex_data->match = REGEX_NO_MATCH;
- regex_data->where = NULL;
- regex_data->count = 0;
- regex_data->r_count = 0;
- }
-
- return 0;
-
-error:
- regex_data->match = REGEX_NO_MATCH;
-
- return -1;
-}
-
-int
-match_list (regex_data_t * regex_data)
-{
- regex_data_t tmp_data;
- char *data_p = regex_data->data;
- char *list_p = regex_data->regex;
- char *r_list = NULL;
- size_t r_count = 0;
- int retval;
-
- CHECK_REGEX_DATA_P (regex_data, failed);
-
- r_count = get_list (list_p, &r_list);
- if (-1 == r_count)
- goto error;
- if (0 == r_count)
- goto failed;
-
- FILL_REGEX_DATA (tmp_data, data_p, &list_p[r_count - 1]);
- retval = __match_wildcard (&tmp_data, __match_list, r_list);
- if (-1 == retval)
- goto error;
- if (REGEX_MATCH (tmp_data))
- {
- /* This should be 2 ('word' + 'wildcard'), so just remove
- * the wildcard */
- tmp_data.r_count--;
- goto exit;
- }
-
- FILL_REGEX_DATA (tmp_data, data_p, r_list);
- retval = __match_list (&tmp_data);
- if (-1 == retval)
- goto error;
- if (REGEX_MATCH (tmp_data))
- goto exit;
-
-failed:
- /* We will fill in regex_data below */
- tmp_data.match = REGEX_NO_MATCH;
- tmp_data.where = NULL;
- tmp_data.count = 0;
- tmp_data.r_count = 0;
-
-exit:
- /* Fill in our structure */
- regex_data->match = tmp_data.match;
- regex_data->where = tmp_data.where;
- regex_data->count = tmp_data.count;
- if (regex_data->match != REGEX_NO_MATCH)
- /* tmp_data.r_count for __match_wildcard will take care of the
- * wildcard, and tmp_data.r_count for __match_list will be 0 */
- regex_data->r_count = r_count + tmp_data.r_count;
- else
- regex_data->r_count = 0;
-
- free (r_list);
- return 0;
-
-error:
- regex_data->match = REGEX_NO_MATCH;
-
- free (r_list);
- return -1;
-}
-
-size_t
-get_wildcard (const char *regex, char *r_wildcard)
-{
- if (!check_arg_str (regex))
- return 0;
-
- r_wildcard[0] = regex[0];
- r_wildcard[2] = '\0';
-
- switch (regex[1])
- {
- case '*':
- case '+':
- case '?':
- r_wildcard[1] = regex[1];
- break;
- default:
- r_wildcard[0] = '\0';
- return 0;
- }
-
- return strlen (r_wildcard);
-}
-
-int
-__match_wildcard (regex_data_t * regex_data,
- int (*match_func) (regex_data_t * regex_data),
- const char *regex)
-{
- regex_data_t tmp_data;
- char *data_p = regex_data->data;
- char *wildcard_p = regex_data->regex;
- char r_wildcard[3];
- size_t count = 0;
- size_t r_count = 0;
- int is_match = 0;
- int retval;
-
- CHECK_REGEX_DATA_P (regex_data, exit);
-
- if (NULL == match_func)
- {
- rc_errno_set (EINVAL);
- DBG_MSG ("NULL match_func was passed!\n");
- goto exit;
- }
-
- r_count = get_wildcard (wildcard_p, r_wildcard);
- if (0 == r_count)
- goto exit;
-
- FILL_REGEX_DATA (tmp_data, data_p, (char *) regex);
- retval = match_func (&tmp_data);
- if (-1 == retval)
- goto error;
-
- switch (r_wildcard[1])
- {
- case '*':
- case '?':
- /* '*' and '?' always matches */
- is_match = 1;
- case '+':
- /* We need to match all of them */
- do
- {
- /* If we have at least one match for '+', or none
- * for '*' or '?', check if we have a word or list match.
- * We do this because a word weights more than a wildcard */
- if ((strlen (wildcard_p) > 2)
- && ((count > 0)
- || ('*' == r_wildcard[1])
- || ('?' == r_wildcard[1])))
- {
- regex_data_t tmp_data2;
-#if 0
- printf ("data_p = %s, wildcard_p = %s\n", data_p, wildcard_p);
-#endif
-
- FILL_REGEX_DATA (tmp_data2, data_p, &wildcard_p[2]);
- retval = match (&tmp_data2);
- if (-1 == retval)
- goto error;
-
- if (
- /* '.' might be a special case ... */
- /* ('.' != wildcard_p[2]) && */
- ((REGEX_MATCH (tmp_data2))
- && (REGEX_FULL_MATCH == tmp_data2.match)))
- {
- goto exit;
- }
- }
-
- if (REGEX_MATCH (tmp_data))
- {
- data_p += tmp_data.count;
- count += tmp_data.count;
- is_match = 1;
-
- FILL_REGEX_DATA (tmp_data, data_p, (char *) regex);
- retval = match_func (&tmp_data);
- if (-1 == retval)
- goto error;
- }
- /* Only once for '?' */
- }
- while ((REGEX_MATCH (tmp_data)) && ('?' != r_wildcard[1]));
-
- break;
- default:
- /* No wildcard */
- break;
- }
-
-exit:
- /* Fill in our structure */
- /* We can still have a match ('*' and '?'), although count == 0 */
- if ((0 == count) && (0 == is_match))
- regex_data->match = REGEX_NO_MATCH;
- else if (strlen (regex_data->data) == count)
- regex_data->match = REGEX_FULL_MATCH;
- else
- regex_data->match = REGEX_PARTIAL_MATCH;
- if (regex_data->match != REGEX_NO_MATCH)
- regex_data->where = regex_data->data;
- else
- regex_data->where = NULL;
- regex_data->count = count;
- regex_data->r_count = r_count;
-
- return 0;
-
-error:
- regex_data->match = REGEX_NO_MATCH;
-
- return -1;
-}
-
-int
-match_wildcard (regex_data_t * regex_data)
-{
- regex_data_t tmp_data;
- char *data_p = regex_data->data;
- char *wildcard_p = regex_data->regex;
- char r_wildcard[3];
- size_t r_count;
- int retval;
-
- CHECK_REGEX_DATA_P (regex_data, failed);
-
- /* Invalid wildcard - we need a character + a regex operator */
- if (strlen (wildcard_p) < 2)
- goto failed;
-
- r_count = get_wildcard (wildcard_p, r_wildcard);
- if (0 == r_count)
- goto failed;
-
- /* Needed so that match_word() will not bail if it sees the wildcard */
- r_wildcard[1] = '\0';
-
- FILL_REGEX_DATA (tmp_data, data_p, wildcard_p);
- retval = __match_wildcard (&tmp_data, match_word, r_wildcard);
- if (-1 == retval)
- goto error;
- if (REGEX_MATCH (tmp_data))
- goto exit;
-
-failed:
- /* We will fill in regex_data below */
- tmp_data.match = REGEX_NO_MATCH;
- tmp_data.where = NULL;
- tmp_data.count = 0;
- tmp_data.r_count = 0;
-
-exit:
- /* Fill in our structure */
- regex_data->match = tmp_data.match;
- regex_data->where = tmp_data.where;
- regex_data->count = tmp_data.count;
- regex_data->r_count = tmp_data.r_count;
-
- return 0;
-
-error:
- regex_data->match = REGEX_NO_MATCH;
-
- return -1;
-}
-
-int
-__match (regex_data_t * regex_data)
-{
- regex_data_t tmp_data;
- char *data_p = regex_data->data;
- char *regex_p = regex_data->regex;
- size_t count = 0;
- size_t r_count = 0;
- int rmatch = 0;
- int retval;
-
- CHECK_REGEX_DATA_P (regex_data, failed);
-
- while (strlen (regex_p) > 0)
- {
-#if 0
- printf ("data_p = '%s', regex_p = '%s'\n", data_p, regex_p);
-#endif
-
- FILL_REGEX_DATA (tmp_data, data_p, regex_p);
- retval = match_list (&tmp_data);
- if (-1 == retval)
- goto error;
- if (REGEX_MATCH (tmp_data))
- goto have_match;
-
- FILL_REGEX_DATA (tmp_data, data_p, regex_p);
- retval = match_wildcard (&tmp_data);
- if (-1 == retval)
- goto error;
- if (REGEX_MATCH (tmp_data))
- goto have_match;
-
- FILL_REGEX_DATA (tmp_data, data_p, regex_p);
- retval = match_word (&tmp_data);
- if (-1 == retval)
- goto error;
- if (REGEX_MATCH (tmp_data))
- goto have_match;
-
- break;
-
-have_match:
- data_p += tmp_data.count;
- count += tmp_data.count;
- regex_p += tmp_data.r_count;
- r_count += tmp_data.r_count;
- rmatch = 1;
-
- /* Check that we do not go out of bounds */
- if (((data_p - regex_data->data) > strlen (regex_data->data))
- || ((regex_p - regex_data->regex) > strlen (regex_data->regex)))
- goto failed;
- }
-
- /* We could not match the whole regex (data too short?) */
- if (0 != strlen (regex_p))
- goto failed;
-
- goto exit;
-
-failed:
- /* We will fill in regex_data below */
- count = 0;
- r_count = 0;
- rmatch = 0;
-
-exit:
- /* Fill in our structure */
- /* We can still have a match ('*' and '?'), although count == 0 */
- if ((0 == count) && (0 == rmatch))
- regex_data->match = REGEX_NO_MATCH;
- else if (strlen (regex_data->data) == count)
- regex_data->match = REGEX_FULL_MATCH;
- else
- regex_data->match = REGEX_PARTIAL_MATCH;
- if (regex_data->match != REGEX_NO_MATCH)
- regex_data->where = regex_data->data;
- else
- regex_data->where = NULL;
- regex_data->count = count;
- regex_data->r_count = r_count;
-
- return 0;
-
-error:
- regex_data->match = REGEX_NO_MATCH;
-
- return -1;
-}
-
-int
-match (regex_data_t * regex_data)
-{
- regex_data_t tmp_data;
- char *data_p = regex_data->data;
- char *regex_p;
- char *buf = NULL;
- int from_start = 0;
- int to_end = 0;
- int retval;
-
- CHECK_REGEX_DATA_P (regex_data, failed);
-
- /* We might be modifying regex_p, so make a copy */
- buf = xstrndup (regex_data->regex, strlen (regex_data->regex));
- if (NULL == buf)
- goto error;
-
- regex_p = buf;
-
- /* Should we only match from the start? */
- if ('^' == regex_p[0])
- {
- regex_p++;
- from_start = 1;
- }
-
- /* Should we match up to the end? */
- if ('$' == regex_p[strlen (regex_p) - 1])
- {
- regex_p[strlen (regex_p) - 1] = '\0';
- to_end = 1;
- }
-
- do
- {
- FILL_REGEX_DATA (tmp_data, data_p, regex_p);
- retval = __match (&tmp_data);
- if (-1 == retval)
- goto error;
- }
- while ((strlen (data_p++) > 0)
- && (!REGEX_MATCH (tmp_data)) && (0 == from_start));
-
- /* Compensate for above extra inc */
- data_p--;
-
- /* Fill in our structure */
- if (REGEX_MATCH (tmp_data))
- {
- /* Check if we had an '$' at the end of the regex, and
- * verify that we still have a match */
- if ((1 == to_end) && (tmp_data.count != strlen (data_p)))
- {
- goto failed;
- }
-
- if ((data_p == regex_data->data)
- && (tmp_data.match == REGEX_FULL_MATCH))
- regex_data->match = REGEX_FULL_MATCH;
- else
- regex_data->match = REGEX_PARTIAL_MATCH;
- regex_data->where = data_p;
- regex_data->count = tmp_data.count;
- regex_data->r_count = tmp_data.r_count;
- if (1 == from_start)
- regex_data->r_count++;
- if (1 == to_end)
- regex_data->r_count++;
- }
- else
- {
-failed:
- regex_data->match = REGEX_NO_MATCH;
- regex_data->where = NULL;
- regex_data->count = 0;
- regex_data->r_count = 0;
- }
-
- free (buf);
-
- return 0;
-
-error:
- regex_data->match = REGEX_NO_MATCH;
- free (buf);
-
- return -1;
-}
diff --git a/libsbutil/src/string.c b/libsbutil/src/string.c
index 4ebb61c..e9db24b 100644
--- a/libsbutil/src/string.c
+++ b/libsbutil/src/string.c
@@ -12,25 +12,6 @@
#include "rcscripts/rcutil.h"
char *
-rc_memrepchr (char **str, char old, char new, size_t size)
-{
- char *str_p;
-
- if (!check_arg_strv (str))
- return NULL;
-
- str_p = memchr (*str, old, size);
-
- while (NULL != str_p)
- {
- str_p[0] = new;
- str_p = memchr (&str_p[1], old, size - (str_p - *str) - 1);
- }
-
- return *str;
-}
-
-char *
rc_strcatpaths (const char *pathname1, const char *pathname2)
{
char *new_path = NULL;