0 Members and 2 Guests are viewing this topic.
case 24: a=GetArgType(argptr); if (a!=STR_TAG) { DlgError("Arg 2 must be string"); return; } const char* f3=GetStrnArg(argptr); fio=fopen(f3,"r+b"); push_END_TAG(); push_longint((long)fio->fpos); push_longint((long)fio->base); push_longint(fio->handle); push_longint(fio->flags); push_longint(fio->unget); push_longint(fio->alloc); push_longint(fio->buffincrement); push_LIST_TAG(); VarStore(SYMSTR("n"),STOF_ESI,0,top_estack); break;
void WriteListToFilePtr(ESI temp,FILE* fio){ int i=0; long* u=NULL; if (!(u=calloc(7,sizeof(long)))) return; //clrscr(); for(i=0;i<7;i++) { u[i]=GetIntArg(temp); //printf("u[%d]=%ld\n",i,u[i]); } fio->fpos=(char*)u[6]; fio->base=(void*)u[5]; fio->handle=u[4]; fio->flags=u[3]; fio->unget=u[2]; fio->alloc=u[1]; fio->buffincrement=u[0]; free(u);}
case 25: a=GetArgType(argptr); if (a!=LIST_TAG) { DlgError("Arg 2 must be list"); return; } WriteListToFilePtr(argptr-1,fio); fclose(fio);
I'm serializing/deserializing the fields so that the user will be able to open and close with the same FILE structure.
Then I might replace fopen/fclose/fgetc/fputc with 4 file commands: fread, fwrite, fgetc, and fputc. Thanks for telling me that!
case 24: a=GetArgType(argptr); if (a!=STR_TAG) { DlgError("Arg 2 must be string"); return; } const char* f3=GetStrnArg(argptr); a=GetArgType(argptr); if (a!=STR_TAG) { DlgError("Arg 3 must be string"); return; } const char* f4=GetStrnArg(argptr); a=GetArgType(argptr); for (x=0;x<=16;x++) { if (!interface[x].handle) break; } if (x!=16) { interface[x]=*fopen(f3,f4); } WriteToNInt(x); break; case 25: a=GetArgType(argptr); if (a!=POSINT_TAG) { DlgError("Arg 2 must be int"); return; } x=GetIntArg(argptr); if (x<0||x>=16) { DlgError("Arg 2 out of range"); return; } fclose(&interface[x]); interface[x].handle=H_NULL; break;
EDIT: Does the handle field (fio->handle) remain consistent between runs though?