#include /* module loadram9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /****************************************************************************/ loadram(void) /* load database from hard drive */ { int fail; printf("LOADING FILES\n"); /*--------------------------------------------------------------------------*/ if(fail=!(stream=fopen("palette.723","rb"))) { warn("couldn't open PALETTE.723"); goto abort; } else { if(fail=iload(pal,48)) { warn("couldn't load custom color palette"); goto abort; } fclose(stream); } /*--------------------------------------------------------------------------*/ if(fail=!(stream=fopen("idens.723","rb"))) { warn("couldn't open idens.723"); goto abort; } else { if(fail=load(password,10)) { warn("couldn't load password"); goto abort; } if(fail=load(idents,100)) { warn("couldn't load identities"); goto abort; } if(fail=uload(prohibs,200)) { warn("couldn't load prohibited commands"); goto abort; } if(fail=load(codec,4)) { warn("couldn't load cipher"); goto abort; } fclose(stream); } /*--------------------------------------------------------------------------*/ if(fail=!(stream=fopen("presets.723","rb"))) { warn("couldn't open presets.723"); goto abort; } else { if(fail=iload(prepow,10)) { warn("couldn't load preset power values"); goto abort; } if(fail=iload(prebeam,10)) { warn("couldn't load preset beam values"); goto abort; } if(fail=iload(predriv,10)) { warn("couldn't load preset drive values"); goto abort; } if(fail=iload(prebal,10)) { warn("couldn't load preset balance values"); goto abort; } if(fail=iload(prepha,10)) { warn("couldn't load preset phase values"); goto abort; } if(fail=iload(preoff,10)) { warn("couldn't load preset offset values"); goto abort; } if(fail=iload(pregain,10)) { warn("couldn't load preset gain values"); goto abort; } fclose(stream); } /*--------------------------------------------------------------------------*/ if(fail=!(stream=fopen("scales.723","rb"))) { warn("couldn't open SCALES.723"); goto abort; } else { if(fail=iload(scale,32)) { warn("couldn't load metering scales"); goto abort; } fclose(stream); } /*--------------------------------------------------------------------------*/ if(fail=!(stream=fopen("funcs.723","rb"))) { warn("couldn't open FUNCS.723"); goto abort; } else { if(fail=load(func,960)) { warn("couldn't load function key macros"); goto abort; } fclose(stream); } /*---------------------------------------------------------------------------*/ if(fail=!(stream=fopen("dnames.723","rb"))) /* open file */ { warn("couldn't open DNAMES.723"); goto abort; } else { if(fail=load(dname,320)) /* user defined input titles */ { warn("couldn't load spare input titles"); goto abort; } if(fail=load(dname1,160)) /* user defined high state */ { warn("couldn't load spare input high names"); goto abort; } if(fail=load(dname2,160)) /* user defined low state */ { warn("couldn't load spare input low names"); goto abort; } if(fail=load(dname3,16)) /* user defined warning */ { warn("couldn't load spare input warning states"); goto abort; } if(fail=load(dname4,16)) /* user defined warning */ { warn("couldn't load spare input warning colors"); goto abort; } fclose(stream); } /*---------------------------------------------------------------------------*/ if(fail=!(stream=fopen("cnames.723","rb"))) /* open file */ { warn("couldn't open CNAMES.723"); goto abort; } else { if(fail=load(cname,160)) /* user defined commands */ { warn("couldn't load spare command titles"); goto abort; } if(fail=load(cname1,16)) /* user defined assertion */ { warn("couldn't load spare command levels"); goto abort; } if(fail=load(cname2,16)) /* user defined boot level */ { warn("couldn't load spare command boot levels"); goto abort; } if(fail=load(cname3,16)) /* user defined duration */ { warn("couldn't load spare command durations"); goto abort; } fclose(stream); } /*-------------------------------------------------------------------------*/ if(fail=!(stream=fopen("limits.723","rb"))) { warn("couldn't open LIMITS.723"); goto abort; } else { if(fail=iload(lolim,64)) /* read lower meter limits */ { warn("couldn't load lower meter limits"); goto abort; } if(fail=iload(hilim,64)) /* read upper meter limits */ { warn("couldn't load upper meter limits"); goto abort; } fclose(stream); } /*-------------------------------------------------------------------------*/ if(fail=!(stream=fopen("misc.723","rb"))) { warn("couldn't open MISC.723"); goto abort; } else { if(fail=iload(counter,80)) { warn("couldn't load miscellaneous"); goto abort; } fclose(stream); } /*-------------------------------------------------------------------------*/ if(fail=!(stream=fopen("hist.723","rb"))) { warn("couldn't open HIST.723"); goto abort; } else { if(fail=load(histime,320)) { warn("couldn't load history times"); goto abort; } if(fail=uload(histat,nb*20)) { warn("couldn't load history status"); goto abort; } if(fail=iload(hismet,640)) { warn("couldn't load history metering"); goto abort; } fclose(stream); } abort: if(fail) fclose(stream); return(fail); } /*****************************************************************************/ load(char *data, unsigned int n) /* read n bytes from hard drive file */ { int fail=0; unsigned int nread; /* hard drive byte counter */ nread=fread(data,1,n,stream); if(n!=nread) { brief("UNDESIRED NUMBER OF CHARS READ"); if(feof(stream)) brief("READING PAST EOF"); fail=1; } return(fail); } /*****************************************************************************/ uload(unsigned char *data, unsigned int n) /* read n bytes from hard drive file */ { int fail=0; unsigned int nread; /* hard drive byte counter */ nread=fread(data,1,n,stream); if(n!=nread) { brief("UNDESIRED NUMBER OF CHARS READ"); if(feof(stream)) brief("READING PAST EOF"); fail=1; } return(fail); } /*****************************************************************************/ iload(int *data, unsigned int n) /* read 2n bytes from hard drive file */ { int fail=0; unsigned int nread; nread=fread(data,2,n,stream); if(n!=nread) { brief("UNDESIRED NUMBER OF CHARS READ"); if(feof(stream)) brief("READING PAST EOF"); fail=1; } return(fail); } /*****************************************************************************/ lload(long *data,unsigned int n) /* read 4n bytes from hard drive file */ { int fail=0; unsigned int nread; nread=fread(data,4,n,stream); if(n!=nread) { brief("UNDESIRED NUMBER OF CHARS READ"); if(feof(stream)) brief("READING PAST EOF"); fail=1; } return(fail); }