#include #include #include #include "ntl2.h" enum { Pmax = 16 }; static int pp = 0; static char* path[Pmax]; int addpath(const char* p) { if (pp == Pmax) return -1; path[pp++] = strdup(p); return 0; } FILE* path_fopen(const char* file, const char* mode) { int i; FILE* fp; char buf[4096]; if (!file || !mode) return 0; if (file[0] == '/' || file[0] == '.') return fopen(file, mode); for (i = 0; i < pp; ++i) { sprintf(buf, "%s/%s", path[i], file); if (fp = fopen(buf, mode)) return fp; } return fopen(file, mode); }