/* ARC_OP.C - п/п аpхивиpования действий опеpатоpа */ #include "complex.h" struct { byte day; byte mon; byte year; byte hour; byte min; byte sec; char str[50]; } aop1; union REGS r; struct SREGS sr; void arc_op1(char *fmt, ...) { word_s h_op, loc_fl; byte hour,min,sec,year,mon,day; char str[50]; va_list argptr; va_start (argptr,fmt); vsprintf(str,fmt,argptr); va_end(argptr); if((h_op=sopen(NameFile[32],O_BINARY|O_RDWR,SH_DENYNO,S_IREAD|S_IWRITE))==-1) { h_op=sopen(NameFile[32],O_BINARY|O_RDWR|O_CREAT,SH_DENYNO,S_IREAD|S_IWRITE); loc_fl=0; write(h_op,&loc_fl,sizeof(word_s)); lseek(h_op,0L,SEEK_SET); } read(h_op,&loc_fl,sizeof(word_s)); r.h.ah= 0x02; int386x (0x1A, &r, &r, &sr); hour=r.h.ch; min=r.h.cl; sec=r.h.dh; r.h.ah= 0x04; int386x (0x1A, &r, &r, &sr); day=r.h.dl; mon=r.h.dh; year=r.h.cl; aop1.hour=hour; aop1.min=min; aop1.sec=sec; aop1.day=day; aop1.mon=mon; aop1.year=year; strncpy(aop1.str,str,50); lseek(h_op,(long)(sizeof(word_s)+loc_fl*sizeof(aop1)),SEEK_SET); write(h_op,&aop1,sizeof(aop1)); if(++loc_fl >= 27000) loc_fl=0; lseek(h_op,0L,SEEK_SET); write(h_op,&loc_fl,sizeof(word_s)); close(h_op); } /*-------------------------------------------------------------------*/ int f_err_sz = 100000; int f_err_cnt = 4; void fix_err(char * text) { static char oldstr[250]; static char olddata[30]; static char first_err = 1; char str[20],str1[20]; char *data;//[20]; word_s hd; time_t t_tm; int i; if( first_err == 1 ) remove(NameFile[33]); first_err = 0; if((hd=sopen(NameFile[33],O_BINARY|O_RDWR|O_APPEND,SH_DENYNO,S_IREAD|S_IWRITE))==-1) hd=sopen(NameFile[33],O_BINARY|O_RDWR|O_CREAT|O_APPEND,SH_DENYNO,S_IREAD|S_IWRITE); if( lseek(hd,0,SEEK_END) > f_err_sz ) { close(hd); for(i=f_err_cnt;i>0;i--) { sprintf(str,"%s%d",NameFile[33],i); if(i != 1) sprintf(str1,"%s%d",NameFile[33],i-1); else sprintf(str1,"%s",NameFile[33]); if(i == f_err_cnt) remove(str); rename(str1,str); } hd = sopen(NameFile[33],O_BINARY|O_RDWR|O_CREAT|O_APPEND,SH_DENYNO,S_IREAD|S_IWRITE); oldstr[0] = 0 ; } if(!strcmp(text,oldstr)) write(hd,".",1); else { // data=malloc(256); strncpy(oldstr,text,sizeof(oldstr)-1); write(hd,"\x0d\x0a",2); time(&t_tm); data=ctime(&t_tm); if(strcmp(data,olddata)) { write(hd,data,strlen(data)-1); write(hd,"\x0d\x0a",2); strcpy(olddata,data); } write(hd,text,strlen(text)); } close(hd); }