Index: trunk/config.h.in =================================================================== --- trunk/config.h.in (revision 24813) +++ trunk/config.h.in (revision 24814) @@ -274,6 +274,9 @@ # define remove never_use_remove__use_pcb_remove # define rename never_use_rename__use_pcb_rename # define mkdir never_use_mkdir__use_pcb_mkdir +# define opendir never_use_opendir__use_pcb_opendir +# define readdir never_use_readdir__use_pcb_readdir +# define closedir never_use_closedir__use_pcb_closedir # endif #endif Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 24813) +++ trunk/scconfig/Rev.h (revision 24814) @@ -1 +1 @@ -static const int myrev = 24736; +static const int myrev = 24814; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 24813) +++ trunk/scconfig/Rev.tab (revision 24814) @@ -1,3 +1,4 @@ +24814 configure safety wrapper around opendir and readdir 24736 configure make distclean fixes to really remove all generated files 24625 configure io_kicad common layer table code among read and write side 24585 configure io_kicad depends on the shape plugin for round-rect pads Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 24813) +++ trunk/src/plug_io.c (revision 24814) @@ -70,9 +70,6 @@ #include "macro.h" #include "view.h" -/* for opendir */ -#include "compat_inc.h" - pcb_plug_io_t *pcb_plug_io_chain = NULL; int pcb_io_err_inhibit = 0; pcb_view_list_t pcb_io_incompat_lst; Index: trunk/src/safe_fs.c =================================================================== --- trunk/src/safe_fs.c (revision 24813) +++ trunk/src/safe_fs.c (revision 24814) @@ -184,6 +184,26 @@ return res; } +DIR *pcb_opendir(const char *name) +{ + DIR *d; + char *path_exp = pcb_build_fn(name); + d = opendir(path_exp); + free(path_exp); + return d; +} + +struct dirent *pcb_readdir(DIR *dir) +{ + return readdir(dir); +} + +int pcb_closedir(DIR *dir) +{ + return closedir(dir); +} + + static FILE *pcb_fopen_at_(const char *from, const char *fn, const char *mode, char **full_path, int recursive) { char tmp[PCB_PATH_MAX]; @@ -205,11 +225,11 @@ if (!recursive) return NULL; - d = opendir(from); + d = pcb_opendir(from); if (d == NULL) return NULL; - while((de = readdir(d)) != NULL) { + while((de = pcb_readdir(d)) != NULL) { struct stat st; if (de->d_name[0] == '.') continue; Index: trunk/src/safe_fs_dir.h =================================================================== --- trunk/src/safe_fs_dir.h (nonexistent) +++ trunk/src/safe_fs_dir.h (revision 24814) @@ -0,0 +1,4 @@ +#include "compat_inc.h" +DIR *pcb_opendir(const char *name); +struct dirent *pcb_readdir(DIR *dir); +int pcb_closedir(DIR *dir); Index: trunk/src_plugins/export_vfs_fuse/export_vfs_fuse.c =================================================================== --- trunk/src_plugins/export_vfs_fuse/export_vfs_fuse.c (revision 24813) +++ trunk/src_plugins/export_vfs_fuse/export_vfs_fuse.c (revision 24814) @@ -1,5 +1,8 @@ #define _XOPEN_SOURCE 500 +/* Required because FUSE uses readdir as struct field name */ +#define PCB_SAFE_FS + #include "fuse_includes.h" #include "config.h" Index: trunk/src_plugins/fp_fs/fp_fs.c =================================================================== --- trunk/src_plugins/fp_fs/fp_fs.c (revision 24813) +++ trunk/src_plugins/fp_fs/fp_fs.c (revision 24814) @@ -36,6 +36,8 @@ #include #include +#include "compat_inc.h" + #include "data.h" #include "paths.h" #include "plugins.h" @@ -47,10 +49,8 @@ #include "conf_core.h" #include "macro.h" #include "safe_fs.h" +#include "safe_fs_dir.h" -/* opendir, readdir */ -#include "compat_inc.h" - static pcb_fptype_t pcb_fp_file_type(const char *fn, void ***tags); /* --------------------------------------------------------------------------- @@ -150,7 +150,7 @@ fn_end = fn + l + 1; /* First try opening the directory specified by path */ - if ((subdirobj = opendir(new_subdir)) == NULL) { + if ((subdirobj = pcb_opendir(new_subdir)) == NULL) { pcb_opendir_error_message(new_subdir); if (chdir(olddir)) pcb_chdir_error_message(olddir); @@ -160,7 +160,7 @@ /* Now loop over files in this directory looking for files. * We ignore certain files which are not footprints. */ - while ((subdirentry = readdir(subdirobj)) != NULL) { + while ((subdirentry = pcb_readdir(subdirobj)) != NULL) { #ifdef DEBUG /* printf("... Examining file %s ... \n", subdirentry->d_name); */ #endif @@ -211,7 +211,7 @@ } } /* Done. Clean up, cd back into old dir, and return */ - closedir(subdirobj); + pcb_closedir(subdirobj); if (chdir(olddir)) pcb_chdir_error_message(olddir); return n_footprints; Index: trunk/src_plugins/script/live_script.c =================================================================== --- trunk/src_plugins/script/live_script.c (revision 24813) +++ trunk/src_plugins/script/live_script.c (revision 24814) @@ -26,9 +26,6 @@ #include "config.h" -/* for opendir - must be the first */ -#include "compat_inc.h" - #include #include #include @@ -39,6 +36,7 @@ #include "hid_cfg.h" #include "hid_dad.h" #include "safe_fs.h" +#include "safe_fs_dir.h" #include "compat_fs.h" #include "event.h" #include "undo.h" @@ -103,7 +101,7 @@ char fn[PCB_PATH_MAX*2], *fn_end; int dirlen; struct dirent *de; - DIR *d = opendir(*path); + DIR *d = pcb_opendir(*path); if (d == NULL) continue; @@ -114,7 +112,7 @@ *fn_end = PCB_DIR_SEPARATOR_C; fn_end++; - while((de = readdir(d)) != NULL) { + while((de = pcb_readdir(d)) != NULL) { FILE *f; int el, len = strlen(de->d_name); char *s1, *s2, *eng, *s, *end, line[1024]; @@ -147,7 +145,7 @@ } fclose(f); } - closedir(d); + pcb_closedir(d); } lvs->langs = (char **)vl.array; lvs->lang_engines = (char **)ve.array;