- f = fopen(name,"r");
- if (!f) {
- perror("fopen");
- return -1;
- }
-
- while (!feof(f)) {
- /* read a line from file */
- if (!fgets(buf, LINESIZE, f) || buf[0] == '#')
- continue;
-
- /* parse and return pref and value */
- if ((getpref(buf, &pref, &val)) != 0)
- continue;
-
- i = 0;
- /* now see if its a correct pref */
- while(ldap_prefs[i].pref != NULL) {
- if ((strcmp(ldap_prefs[i].name, pref)) == 0) {
- /* ok, found a valid pref */
-
- /* check if we have pre-defined values */
- if (0 == ldap_prefs[i].intfromarray) {
- /* no, its just a string */
- ldap_prefs[i].valid = 0;
- if (0 == ldap_prefs[i].strorint)
- /* store string as string */
- *((char **)(ldap_prefs[i].pref)) = val;
- else
- /* store as int */
- *((int *)(ldap_prefs[i].pref)) = atoi(val);
- } else {
- /* ok, we have string to int mapping for this pref
- eg. "none", "simple", "sasl" map to 0, 128, 129 */
- j = 0;
- while(prefs_array[j].pref != NULL) {
- if (((strcmp(prefs_array[j].pref, pref)) == 0) &&
- ((strcmp(prefs_array[j].valuestring, val)) == 0)) {
- ldap_prefs[i].valid = 0;
- *((int *)(ldap_prefs[i].pref)) = prefs_array[j].value;
- }
- j++;
- } /* while j*/
- } /* else */
+ i = 0;
+ /* now see if its a correct pref */
+ for (i = 0; ldap_prefs[i].name != NULL; i++) {
+ if ((val = iniparser_getstring(iniconfig, INISEC_GLOBAL, ldap_prefs[i].name, NULL))) {
+ /* check if we have pre-defined values */
+ if (ldap_prefs[i].intfromarray == 0) {
+ /* no, its just a string */
+ ldap_prefs[i].valid = 0;
+ if (ldap_prefs[i].strorint)
+ /* store as int */
+ *((int *)(ldap_prefs[i].pref)) = atoi(val);
+ else
+ /* store string as string */
+ *((const char **)(ldap_prefs[i].pref)) = val;
+ } else {
+ /* ok, we have string to int mapping for this pref
+ eg. "none", "simple", "sasl" map to 0, 128, 129 */
+ for (j = 0; prefs_array[j].pref != NULL; j++) {
+ if ((strcmp(prefs_array[j].pref, ldap_prefs[i].name) == 0)
+ && (strcmp(prefs_array[j].valuestring, val) == 0)) {
+ ldap_prefs[i].valid = 0;
+ *((int *)(ldap_prefs[i].pref)) = prefs_array[j].value;
+ break;
+ }
+ }