diff options
author | Neil Brown <neilb@suse.de> | 2006-05-19 07:33:05 +0200 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2006-05-19 07:33:05 +0200 |
commit | 8fe9db0ffef630b9403206d0c7b8e3a404bd9e8e (patch) | |
tree | 2b73f6ea0fd2d0da23766dfa8e5c0d6041f0c727 /config.c | |
parent | Just updaqte copyright dates and email address (diff) | |
download | mdadm-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.c | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -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: |