@@ -46,11 +46,11 @@ /* Remove trailing crap (but not spaces). */ linebuf_ptr = &linebuf[strlen(linebuf) - 1]; while (*linebuf_ptr < ' ' && linebuf_ptr >= linebuf) { *linebuf_ptr = '\0'; - *linebuf_ptr--; + linebuf_ptr--; } /* Handle section header. */ if (linebuf[0] == '[' && linebuf[strlen(linebuf) - 1] == ']') { linebuf[strlen(linebuf) - 1] = '\0'; @@ -58,20 +58,24 @@ /* If a section was open, close it. */ if (currsection != NULL) { lcpvret = lc_process_var(currsection, NULL, NULL, LC_FLAGS_SECTIONEND); if (lcpvret < 0) { - PRINTERR_D("Invalid section terminating: \"%s\"", currsection); +#ifdef DEBUG + fprintf(stderr, "Invalid section terminating: \"%s\"\n", currsection); +#endif } free(currsection); } /* Open new section. */ currsection = strdup(linebuf_ptr); lcpvret = lc_process_var(currsection, NULL, NULL, LC_FLAGS_SECTIONSTART); if (lcpvret < 0) { - PRINTERR_D("Invalid section: \"%s\"", currsection); +#ifdef DEBUG + fprintf(stderr, "Invalid section: \"%s\"\n", currsection); +#endif invalid_section = 1; lc_errno = LC_ERR_INVSECTION; retval = -1; } else { invalid_section = 0; @@ -85,51 +89,57 @@ } /* Remove leading spaces. */ linebuf_ptr = &linebuf[0]; while (*linebuf_ptr == ' ') { - *linebuf_ptr++; + linebuf_ptr++; } /* Drop comments and blank lines. */ if (*linebuf_ptr == ';' || *linebuf_ptr == '\0') { continue; } /* Don't handle things for a section that doesn't exist. */ if (invalid_section == 1) { - PRINTERR_D("Ignoring line (because invalid section): %s", linebuf); +#ifdef DEBUG + fprintf(stderr, "Ignoring line (because invalid section): %s\n", linebuf); +#endif continue; } /* Don't process commands if this section is specifically ignored. */ if (ignore_section == 1) { - PRINTERR_D("Ignoring line (because ignored section): %s", linebuf); +#ifdef DEBUG + fprintf(stderr, "Ignoring line (because ignored section): %s\n", linebuf); +#endif continue; } /* Find the command and the data in the line. */ cmdend = sep = strpbrk(linebuf_ptr, "="); if (sep == NULL) { - PRINTERR_D("Invalid line: \"%s\"", linebuf); +#ifdef DEBUG + fprintf(stderr, "Invalid line: \"%s\"\n", linebuf); +#endif continue; } /* Delete space at the end of the command. */ - *cmdend--; /* It currently derefs to the seperator.. */ + cmdend--; /* It currently derefs to the seperator.. */ while (*cmdend <= ' ') { *cmdend = '\0'; - *cmdend--; + cmdend--; } cmd = linebuf_ptr; /* Delete the seperator char and any leading space. */ *sep = '\0'; - *sep++; + sep++; while (*sep == ' ' || *sep == '\t') { - *sep++; + sep++; } value = sep; /* Create the fully qualified variable name. */ if (currsection == NULL) { @@ -142,14 +152,18 @@ save_lc_errno = lc_errno; lc_errno = LC_ERR_NONE; lcpvret = lc_process_var(qualifbuf, NULL, value, LC_FLAGS_VAR); if (lcpvret < 0) { if (lc_errno == LC_ERR_NONE) { - PRINTERR_D("Invalid command: \"%s\"", cmd); +#ifdef DEBUG + fprintf(stderr, "Invalid command: \"%s\"\n", cmd); +#endif lc_errno = LC_ERR_INVCMD; } else { - PRINTERR_D("Error processing command (command was valid, but an error occured, errno was set)"); +#ifdef DEBUG + fprintf(stderr, "Error processing command (command was valid, but an error occured, errno was set)\n"); +#endif } retval = -1; } else { lc_errno = save_lc_errno; } @@ -157,14 +171,16 @@ /* Close any open section, and clean-up. */ if (currsection != NULL) { lcpvret = lc_process_var(currsection, NULL, NULL, LC_FLAGS_SECTIONEND); if (lcpvret < 0) { - PRINTERR_D("Invalid section terminating: \"%s\"", currsection); +#ifdef DEBUG + fprintf(stderr, "Invalid section terminating: \"%s\"\n", currsection); +#endif } free(currsection); } fclose(configfp); return(retval); }