NOEXPORT char *include_config(char *directory, SERVICE_OPTIONS **section_ptr) {
    struct dirent **namelist;
    int i, num, err=0;

    num=scandir(directory, &namelist, NULL, alphasort);
    if(num<0) {
        ioerror("scandir");
        return "Failed to include directory";
    }
    for(i=0; i<num; ++i) {
        if(!err) {
            struct stat sb;
            char *name=str_printf(
#ifdef USE_WIN32
                "%s\\%s",
#else
                "%s/%s",
#endif
                directory, namelist[i]->d_name);
            if(!stat(name, &sb) && S_ISREG(sb.st_mode))
                err=options_file(name, CONF_FILE, section_ptr);
            else
                s_log(LOG_DEBUG, "\"%s\" is not a file", name);
            str_free(name);
        }
        free(namelist[i]);
    }
    free(namelist);
    if(err)
        return "Failed to include a file";
    return NULL;
}
NOEXPORT char *include_config(char *directory, SERVICE_OPTIONS **section_ptr) {
    struct dirent **namelist;
    int i, num, err=0;

    num=scandir(directory, &namelist, NULL, alphasort);
    if(num<0) {
        ioerror("scandir");
        return "Failed to include directory";
    }
    for(i=0; i<num; ++i) {
        if(!err) {
            struct stat sb;
            char *name=str_printf(
#ifdef USE_WIN32
                "%s\\%s",
#else
                "%s/%s",
#endif
                directory, namelist[i]->d_name);
            if(!stat(name, &sb) && S_ISREG(sb.st_mode))
                err=options_file(name, CONF_FILE, section_ptr);
            else
                s_log(LOG_DEBUG, "\"%s\" is not a file", name);
            str_free(name);
        }
        free(namelist[i]);
    }
    free(namelist);
    if(err)
        return "Failed to include a file";
    return NULL;
}