summaryrefslogtreecommitdiffstats
path: root/config.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-19 07:33:05 +0200
committerNeil Brown <neilb@suse.de>2006-05-19 07:33:05 +0200
commit8fe9db0ffef630b9403206d0c7b8e3a404bd9e8e (patch)
tree2b73f6ea0fd2d0da23766dfa8e5c0d6041f0c727 /config.c
parentJust updaqte copyright dates and email address (diff)
downloadmdadm-8fe9db0ffef630b9403206d0c7b8e3a404bd9e8e.tar.xz
mdadm-8fe9db0ffef630b9403206d0c7b8e3a404bd9e8e.zip
Improve code for recognising config lines.
No more magic numbers. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to '')
-rw-r--r--config.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/config.c b/config.c
index b083140b..ec9e3e16 100644
--- a/config.c
+++ b/config.c
@@ -79,10 +79,17 @@
char DefaultConfFile[] = CONFFILE;
char DefaultAltConfFile[] = CONFFILE2;
-char *keywords[] = { "devices", "array",
- "mailaddr", "program", "mailfrom",
- "create",
- NULL };
+enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev, Homehost, LTEnd };
+char *keywords[] = {
+ [Devices] = "devices",
+ [Array] = "array",
+ [Mailaddr] = "mailaddr",
+ [Mailfrom] = "mailfrom",
+ [Program] = "program",
+ [CreateDev] = "create",
+ [Homehost] = "homehost",
+ [LTEnd] = NULL
+};
/*
* match_keyword returns an index into the keywords array, or -1 for no match
@@ -589,22 +596,22 @@ void load_conffile(char *conffile)
loaded = 1;
while ((line=conf_line(f))) {
switch(match_keyword(line)) {
- case 0: /* DEVICE */
+ case Devices:
devline(line);
break;
- case 1: /* ARRAY */
+ case Array:
arrayline(line);
break;
- case 2: /* MAIL */
+ case Mailaddr:
mailline(line);
break;
- case 3: /* PROGRAM */
- programline(line);
- break;
- case 4: /* MAILFROM */
+ case Mailfrom:
mailfromline(line);
break;
- case 5: /* CREATE */
+ case Program:
+ programline(line);
+ break;
+ case CreateDev:
createline(line);
break;
default: