// Updated 6/29/95 - only minor changes made. // Compiled using TC++ 3.0 #include #include #include #include #include "tools.h" FILE *fPr; void Path_Slash(char *s,int flg){ while(*s!='\0') s++; s--; if((strcmp(s,"\\")) && (flg==0)) strcat(s,"\\"); if((!strcmp(s,"\\")) && (flg==1)){ strcpy(s,"\0"); } } void Getcwdname(char *s,char *rs){ char buffer[255]; getcwd(buffer,255); strcat(buffer,"\\"); strcat(buffer,s); strcpy(rs,buffer);} void Prt_Attr_Str(int col, int row, int color, char *s){ gotoxy(col,row); textcolor(color); cprintf(s);} int Julian(int day,int month, int year) { int runsum[] ={0,31,59,90,120,151,181,212,243,273,304,334,365}; int total; total = runsum[month - 1]+day; if(month > 2) total += Leapyear(year); return(total);} int Leapyear(int year) { if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return 1; else return 0;} void Hex_Str(char *str) { int i; for (i=0;str[i] != '\0';i++) printf ("%02x ",str[i]);} void New_To_Null(char *str) { char *pointer; if((pointer = (char *) strchr(str,'\n'))!=0) strcpy(pointer,'\0');} void Str_Toupper(char *str) { char *s; s = str; while (*s != '\0') { *s = toupper(*s); s++; }} void Get_Time(char *buff, int sep){ char time[3]; union REGS ireg; ireg.h.ah=0x2c; intdos(&ireg,&ireg); sprintf(buff,"%02d%c%02d",ireg.h.ch,sep,ireg.h.cl);} void Get_Date(char *buff,int sep) { char form[20]; union REGS ireg; ireg.h.ah = 0x2a; intdos(&ireg,&ireg); strcpy(form,"%02d%c%02d%c%02d"); sprintf(buff,form,ireg.h.dh,sep,ireg.h.dl,sep,ireg.x.cx-1900);} /*::::::::::::::::::::[ FILE OPERATION ROUTINES ]:::::::::::::::::::::*/ void Ropenfile(char *filename){ if((fPr=fopen(filename,"r"))==NULL){ printf("%c\n\n%s file is not available!\n\n",7,filename); exit(1); }} void Wopenfile(char *filename){ if((fPr=fopen(filename,"w"))==NULL){ printf("%c\n\n%s file is cannot be written!\n\n",7,filename); exit(1); }} void Aopenfile(char *filename){ if((fPr=fopen(filename,"a"))==NULL){ printf("%c\n\n%s file cannot be opened!\n\n",7,filename); exit(1); }} int Fexist(char *filename){ int stat; stat=( (fPr=fopen(filename,"r"))==NULL )? 0:1; if(stat) fclose(fPr); return(stat);} void Fclosefile(){ fclose(fPr);} void Freadline(char *s){ fgets(s,FileLen,fPr); New_To_Null(s);} void Fwriteline(char *s){ fprintf(fPr,s);} void Fwritelinec(char *s){ fprintf(fPr,"%s\n",s);} void Readfile (char *filename,char *s,int linenum){ char buffer[82]; int i; strcpy(s,'\0'); Ropenfile(filename); for(i=1;i nul"); system(filename);}