/* -*-c-*- fixfoxpath.c This program solves a particularly pernicious problem in Microsoft's Foxpro and Visual Foxpro products where applications and executables insist on using the database in the developement directory rather that the current (test) directory. This and other similar problems apparently occur when the application is not developed on drive c: The original version was written in foxpro by Cy Welch who kindly provided it on the Net. I found the foxpro version to be rather slow, so I ported it to c. You may use and change it as you wish as long as you keep our names in the source code. Like most free software, and information in general, this program comes with no warranty. I am not responsible for the consequences of using this program. If you make any improvements please consider sending them to me. Suggestions and comments are also welcome. Gyepi Sam Praxis Software */ #include #include #define SEPARATOR '\\' #define COLON ':' #define SPACE ' ' #define exe_name argv[0] #define fox_file argv[1] int main(int argc,char *argv[]) { int Uc,c,c1,c2,c3; char *filename; FILE *fh; Uc=c=c1=c2=c3=SPACE; if (argc != 2){ fprintf(stderr,"usage: %s \n",exe_name); exit(1); } if (!(fh = fopen(fox_file,"r+b"))){ fprintf(stderr,"%s: Error while opening file %s\n",exe_name,fox_file); perror(exe_name); exit(1); } while((c = fgetc(fh)) != EOF){ c1 = c2; c2 = c3; c3 = c; Uc = toupper(c1); if ((c2 == COLON && c3 == SEPARATOR) && (Uc != 'A' && Uc != 'B' && Uc != 'C')){ if (fseek(fh,-3L,SEEK_CUR) == -1){ fprintf(stderr,"%s: seek backwards\n",exe_name); perror(exe_name); exit(1); } if (fputc('c',fh) == EOF){ fprintf(stderr,"%s: Writing character to file\n",exe_name); perror(exe_name); exit(1); }; if (fseek(fh,3L,SEEK_CUR) == -1 ){ fprintf(stderr,"%s: seek forward\n",exe_name); perror(exe_name); exit(1); } Uc = c1 = c2 = c3 = SPACE; } } fclose(fh); exit(0); } /* Local Variables: compile-command: "cl -O2 -o fixfoxpath.exe fixfoxpath.c" End: */