#include "os.h" #define OS_PATH "/phoenix/install/TI-Nspire.tnc" int error = 0; char* buf; unsigned int size = 0; int sizeoffset = -1; static char *title = "nPatch says"; static char *doneinfo = "Your OS file was corrupt and has been fixed."; static char *noneinfo = "Your OS file seems valid and was not altered."; static char *cancelinfo = "Your OS+Ndless is not 3.1 - no problem."; static char *errinfo = "An error occurred..."; int searchFile(FILE* h, char* str, int size, int start, int end) { int l = strlen(str); char* tmp = malloc(l+1); tmp[l]=0; if(start>size-l) start = size-l; if(end>size-l) end = size-l; if(start<0) start = 0; if(end<0) end = 0; int i = start; fseek(h,start,SEEK_SET); int f=0; while(((i>=start && i<=end) || (i<=start && i>=end)) && !f) { fread(tmp,1,l,h); if(!strcmp(tmp,str)) f=1; else if(end=0) { sizeoffset++; fseek(h,sizeoffset,SEEK_SET); fread(osize,1,8,h); memset(tsize,' ',7); sprintf(tsize+7,"%i",size); int d = 8-strlen(tsize+7); if(strcmp(osize,tsize+7-d)) { fseek(h,sizeoffset,SEEK_SET); fwrite(tsize+7-d,1,8,h); } else error=-1; } else error=2; fclose(h); } else error=1; } if(!nl_isstartup()) { if (nl_ndless_rev() >= 989) show_msgbox(title, cancelinfo); else if(!error) show_msgbox(title, doneinfo); else if(error<0) show_msgbox(title, noneinfo); else show_msgbox(title, errinfo); } return 0; }