Index: src/Makefile.dep =================================================================== --- src/Makefile.dep (revision 823) +++ src/Makefile.dep (revision 824) @@ -103,8 +103,8 @@ const.h ../globalconst.h ../config.h macro.h hid.h polyarea.h \ libpcb_fp.h data.h buffer.h create.h crosshair.h draw.h error.h file.h \ set.h action.h misc.h ds.h mymem.h lrealpath.h free_atexit.h polygon.h \ - pcb-printf.h buildin.h hid/common/actions.h hid/hidint.h dolists.h \ - action_list.h + pcb-printf.h buildin.h paths.h hid/common/actions.h hid/hidint.h \ + dolists.h action_list.h mirror.o: mirror.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h hid.h polyarea.h \ libpcb_fp.h data.h draw.h mirror.h misc.h ds.h mymem.h polygon.h \ @@ -128,6 +128,7 @@ global.h const.h ../globalconst.h ../config.h macro.h hid.h polyarea.h \ libpcb_fp.h action.h buffer.h command.h data.h djopt.h error.h file.h \ find.h mymem.h misc.h ds.h rats.h set.h vendor.h create.h +paths.o: paths.c paths.h pcb-printf.o: pcb-printf.c ../config.h ../config.manual.h \ ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ hid.h polyarea.h libpcb_fp.h pcb-printf.h @@ -418,7 +419,7 @@ autoroute.h buffer.h change.h command.h copy.h create.h crosshair.h \ draw.h error.h file.h find.h gpcb-menu.h insert.h line.h mymem.h move.h \ pcb-printf.h polygon.h rats.h remove.h report.h rotate.h rubberband.h \ - search.h select.h set.h undo.h vendor.h event.h free_atexit.h \ + search.h select.h set.h undo.h vendor.h event.h free_atexit.h paths.h \ hid/gtk/gui-icons-mode-buttons.data hid/gtk/gui-icons-misc.data gui-utils.o: hid/gtk/gui-utils.c ../config.h ../config.manual.h \ ../config.auto.h hid/gtk/gui.h global.h const.h ../globalconst.h \ Index: src/Makefile.in =================================================================== --- src/Makefile.in (revision 823) +++ src/Makefile.in (revision 824) @@ -44,6 +44,7 @@ mtspace.o mymem.o netlist.o + paths.o pcb-printf.o plugins.o polygon.o Index: src/hid/gtk/gui-top-window.c =================================================================== --- src/hid/gtk/gui-top-window.c (revision 823) +++ src/hid/gtk/gui-top-window.c (revision 824) @@ -119,6 +119,7 @@ #include "vendor.h" #include "event.h" #include "free_atexit.h" +#include "paths.h" #include "gui-icons-mode-buttons.data" #include "gui-icons-misc.data" Index: src/main.c =================================================================== --- src/main.c (revision 823) +++ src/main.c (revision 824) @@ -57,6 +57,7 @@ #include "polygon.h" #include "pcb-printf.h" #include "buildin.h" +#include "paths.h" #include "hid/common/actions.h" @@ -1384,39 +1385,6 @@ exit (0); } - -void resolve_paths(const char **in, char **out, int numpaths) -{ - for(out; numpaths > 0; numpaths--,in++,out++) { - if (*in != NULL) { - if (**in == '~') { - if (homedir == NULL) { - Message("can't resolve home dir required for path %s\n", *in); - exit(1); - } - *out = Concat(homedir, (*in)+1, NULL); - } - else - *out = strdup(*in); - } - else - *out = NULL; - } -} - -void resolve_path(const char *in, char **out) -{ - resolve_paths(&in, out, 1); -} - -char *resolve_path_inplace(char *in) -{ - char *out; - resolve_path(in, &out); - free(in); - return out; -} - /* ---------------------------------------------------------------------- * Figure out the canonical name of the executed program * and fix up the defaults for various paths Index: src/misc.h =================================================================== --- src/misc.h (revision 823) +++ src/misc.h (revision 824) @@ -144,28 +144,4 @@ void NetlistChanged (int force_unfreeze); - -/* Allocate *out and copy the path from in to out, replacing ~ with homedir */ -void resolve_path(const char *in, char **out); - -/* Same as resolve_path, but it returns the pointer to the new path and calls - free() on in */ -char *resolve_path_inplace(char *in); - - -/* Resolve all paths from a in[] into out[](should be large enough) */ -void resolve_paths(const char **in, char **out, int numpaths); - -/* Resolve all paths from a char *in[] into a freshly allocated char **out */ -#define resolve_all_paths(in, out) \ -do { \ - int __numpath__ = sizeof(in) / sizeof(char *); \ - if (__numpath__ > 0) { \ - out = malloc(sizeof(char *) * __numpath__); \ - resolve_paths(in, out, __numpath__); \ - } \ -} while(0) - - #endif /* PCB_MISC_H */ - Index: src/paths.c =================================================================== --- src/paths.c (nonexistent) +++ src/paths.c (revision 824) @@ -0,0 +1,37 @@ +#include +#include +#include "paths.h" + +extern char *homedir; + +void resolve_paths(const char **in, char **out, int numpaths) +{ + for(out; numpaths > 0; numpaths--,in++,out++) { + if (*in != NULL) { + if (**in == '~') { + if (homedir == NULL) { + Message("can't resolve home dir required for path %s\n", *in); + exit(1); + } + *out = Concat(homedir, (*in)+1, NULL); + } + else + *out = strdup(*in); + } + else + *out = NULL; + } +} + +void resolve_path(const char *in, char **out) +{ + resolve_paths(&in, out, 1); +} + +char *resolve_path_inplace(char *in) +{ + char *out; + resolve_path(in, &out); + free(in); + return out; +} Index: src/paths.h =================================================================== --- src/paths.h (nonexistent) +++ src/paths.h (revision 824) @@ -0,0 +1,23 @@ + +/* Allocate *out and copy the path from in to out, replacing ~ with homedir */ +void resolve_path(const char *in, char **out); + +/* Same as resolve_path, but it returns the pointer to the new path and calls + free() on in */ +char *resolve_path_inplace(char *in); + + +/* Resolve all paths from a in[] into out[](should be large enough) */ +void resolve_paths(const char **in, char **out, int numpaths); + +/* Resolve all paths from a char *in[] into a freshly allocated char **out */ +#define resolve_all_paths(in, out) \ +do { \ + int __numpath__ = sizeof(in) / sizeof(char *); \ + if (__numpath__ > 0) { \ + out = malloc(sizeof(char *) * __numpath__); \ + resolve_paths(in, out, __numpath__); \ + } \ +} while(0) + + Index: src/pcb-gpmi/gpmi_plugin/gpmi_plugin.c =================================================================== --- src/pcb-gpmi/gpmi_plugin/gpmi_plugin.c (revision 823) +++ src/pcb-gpmi/gpmi_plugin/gpmi_plugin.c (revision 824) @@ -5,6 +5,7 @@ #include #include "src/misc.h" #include "src/event.h" +#include "src/paths.h" #include "scripts.h" extern char *homedir; /* detected by pcn-rnd in InitPaths() */