Browse Source

+ check_config()

master
Alex 'AdUser' Z 9 years ago
parent
commit
4ef3a3f9de
  1. 30
      src/config.c
  2. 1
      src/config.h

30
src/config.c

@ -94,3 +94,33 @@ int parse_config(oal_config_t * const config, const char *file) {
return 0;
}
int check_config(oal_config_t * const config) {
enum { bufsize = 1024 };
char err[bufsize] = { '\0' };
assert(config != NULL);
if (!config->bindurls) {
snprintf(err, bufsize, "'bindurls' not set in config");
goto error;
}
if (!config->basedn) {
snprintf(err, bufsize, "'basedn' not set in config");
goto error;
}
if (!config->userfilter) {
snprintf(err, bufsize, "'userfilter' not set in config");
goto error;
}
if (config->binddn && !config->bindpass) {
snprintf(err, bufsize, "'bindn' set, but 'bindpass' missing in config");
goto error;
}
return 0;
error:
config->error = strndup(err, bufsize);
return 1;
}

1
src/config.h

@ -13,5 +13,6 @@ typedef struct {
} oal_config_t;
int parse_config(oal_config_t * const config, const char *file);
int check_config(oal_config_t * const config);
#endif /* OAL_CONFIG_H_INCLUDED */

Loading…
Cancel
Save