From 3619d7da2ac629f8b980eb30daa979431ad5eaf9 Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Fri, 16 Apr 2010 13:47:42 -0400 Subject: Modify config parsing and domain struct to use a partition handler entry instead of just a program name. Signed-off-by: Doug Ledford --- config.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index 88f11e1..30764c9 100644 --- a/config.c +++ b/config.c @@ -709,8 +709,6 @@ void free_domain(struct domain_ent *de) } if (de->spare_group) free(de->spare_group); - if (de->program) - free(de->program); if (de->table) free(de->table); free(de); @@ -731,7 +729,7 @@ void domainline(char *line) } de->paths = NULL; de->spare_group = NULL; - de->program = NULL; + de->handler = NULL; de->table = NULL; de->action = incremental; de->st = NULL; @@ -813,6 +811,8 @@ void domainline(char *line) return; } } else if (strncasecmp("program=", w, 8) == 0) { + int i = 0; + struct partition_handler *h = partition_list[i]; if (!p_seen) p_seen = 1; else { @@ -821,13 +821,18 @@ void domainline(char *line) "ignoring\n"); continue; } - de->program = strdup(w+8); - if (!de->program) { - fprintf(stderr, Name ": failed to allocate " - "memory for program\n"); + while(h) { + if (strncasecmp(w+8, h->match, strlen(h->match)) == 0) + break; + h = partition_list[++i]; + } + if (!h) { + fprintf(stderr, Name ": failed to recognize " + "program %s\n", w+8); free_domain(de); return; } + de->handler = h; } else if (strncasecmp("table=", w, 6) == 0) { if (!t_seen) t_seen = 1; @@ -893,7 +898,7 @@ void domainline(char *line) free_domain(de); return; } - if (!de->table || !de->program) { + if (!de->table || !de->handler) { fprintf(stderr, Name ": partition action requires " "both a table and program setting.\n"); free_domain(de); -- cgit