Refactor command parsing

- normalize command line before parsing
- compare whole words
- check for missing/extra arguments in config parsing
- use strdup for string allocation
- share code for reporting syntax errors
- avoid using function pointers
- cleanup the code a bit
This commit is contained in:
Miroslav Lichvar
2013-05-09 17:29:37 +02:00
parent 182ec04e24
commit 0f8def4ca4
6 changed files with 706 additions and 628 deletions

View File

@@ -53,8 +53,12 @@ typedef struct {
} CPS_NTP_Source;
/* Parse a command to add an NTP server or peer */
extern CPS_Status CPS_ParseNTPSourceAdd(const char *line, CPS_NTP_Source *src);
extern CPS_Status CPS_ParseNTPSourceAdd(char *line, CPS_NTP_Source *src);
/* Remove extra white-space and comments */
extern void CPS_NormalizeLine(char *line);
/* Terminate first word and return pointer to the next word */
extern char *CPS_SplitWord(char *line);
#endif /* GOT_CMDPARSE_H */