summaryrefslogtreecommitdiff
path: root/src/monitor
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2010-05-21 09:36:04 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-05-27 14:44:12 -0400
commit8b420102e0d91edb2acbd2e8a40fc7d9995de2ba (patch)
tree56456ff9213b2037a6914d6df6f97d2a80863979 /src/monitor
parentc2caac87520c2f5a7db764d4827d1ad4cadcb696 (diff)
downloadsssd-8b420102e0d91edb2acbd2e8a40fc7d9995de2ba.tar.gz
sssd-8b420102e0d91edb2acbd2e8a40fc7d9995de2ba.tar.bz2
sssd-8b420102e0d91edb2acbd2e8a40fc7d9995de2ba.zip
Move parse_args() to util
Diffstat (limited to 'src/monitor')
-rw-r--r--src/monitor/monitor.c100
1 files changed, 0 insertions, 100 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index c7997e42..8820d695 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1991,106 +1991,6 @@ static int service_check_alive(struct mt_svc *svc)
return ECHILD;
}
-static void free_args(char **args)
-{
- int i;
-
- if (args) {
- for (i = 0; args[i]; i++) free(args[i]);
- free(args);
- }
-}
-
-
-/* parse a string into arguments.
- * arguments are separated by a space
- * '\' is an escape character and can be used only to escape
- * itself or the white space.
- */
-static char **parse_args(const char *str)
-{
- const char *p;
- char **ret, **r;
- char *tmp;
- int num;
- int i, e;
-
- tmp = malloc(strlen(str) + 1);
- if (!tmp) return NULL;
-
- ret = NULL;
- num = 0;
- e = 0;
- i = 0;
- p = str;
- while (*p) {
- switch (*p) {
- case '\\':
- if (e) {
- tmp[i] = '\\';
- i++;
- e = 0;
- } else {
- e = 1;
- }
- break;
- case ' ':
- if (e) {
- tmp[i] = ' ';
- i++;
- e = 0;
- } else {
- tmp[i] = '\0';
- i++;
- }
- break;
- default:
- if (e) {
- tmp[i] = '\\';
- i++;
- e = 0;
- }
- tmp[i] = *p;
- i++;
- break;
- }
-
- p++;
-
- /* check if this was the last char */
- if (*p == '\0') {
- if (e) {
- tmp[i] = '\\';
- i++;
- e = 0;
- }
- tmp[i] = '\0';
- i++;
- }
- if (tmp[i-1] != '\0' || strlen(tmp) == 0) {
- /* check next char and skip multiple spaces */
- continue;
- }
-
- r = realloc(ret, (num + 2) * sizeof(char *));
- if (!r) goto fail;
- ret = r;
- ret[num+1] = NULL;
- ret[num] = strdup(tmp);
- if (!ret[num]) goto fail;
- num++;
- i = 0;
- }
-
- free(tmp);
- return ret;
-
-fail:
- free(tmp);
- free_args(ret);
- return NULL;
-}
-
static void service_startup_handler(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval t, void *ptr);