home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <bios.h>
- #include <dir.h>
- #include <tcutil.h>
- #include <dos.h>
- #include <process.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <string.h>
- long calc_tots(char *);
-
- char *split_arg(char *);
- char auto_key_ext[10][4] ={"ARC", /*format is ext,command*/
- "DOC",
- "C",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",};
-
-
- char auto_key_cmd[10][20] ={"LARK", /*format is ext,command*/
- "LIST",
- "Q",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",};
-
-
- char fkeyp[10][5] = {"HELP", /*format is ext,command*/
- "LIST",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "NAME",
- "EXT",
- "SIZE",
- "DATE",};
-
- char fkeyc[10][20] = {"HELP", /*format is ext,command*/
- "LIST",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "SORT BY NAME",
- "SORT BY EXTSION",
- "SORT BY SIZE",
- "SORT BY DATE"};
-
- char afkeyp[10][5] ={"\x00", /*format is ext,command*/
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",};
-
-
- char afkeyc[10][20] ={"\x00", /*format is ext,command*/
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",};
-
-
- char cfkeyp[10][5] ={"\x00", /*format is ext,command*/
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",};
-
-
- char cfkeyc[10][20] ={"\x00", /*format is ext,command*/
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",
- "\x00",};
-
-
- struct tablk {
- char my_attr;
- unsigned my_sec:5;
- unsigned my_min:6;
- unsigned my_hour:5;
- unsigned my_day:5;
- unsigned my_month:4;
- unsigned my_year:7;
- long my_size;
- char my_name[13];
- char my_ext[5];
- char my_fn[9];
- } tblk[500];
-
- char cmd_line[500][45];
- struct myblk {
- char my_res[21];
- struct tablk move;
- };
- struct myblk dta;
-
- int normal = setatr(CYAN,BLACK,0,0);
- int reverse = setatr(BLACK,CYAN,0,0);
- int file_a = setatr(GREEN,BLACK,0,0);
- int highlite = setatr(WHITE,BLUE,0,BOLD);
- int foot_a = setatr(BLACK,RED,0,0);
- int foot_ah = setatr(BLACK,GREEN,0,0);
- int foot_a2 = setatr(BLACK,WHITE,0,0);
- int foot_a3 = setatr(BLACK,YELLOW,0,0);
-
- char foot[81], foota[81], footc[81];
- char *foot_fmt ="F1=%-4.4s F2=%-4.4s F3=%-4.4s F4=%-4.4s F5=%-4.4s F6=%-4.4s F7=%-4.4s F8=%-4.4s F9=%-4.4s F10=%-4.4s";
-
-
- char b_line[81], quit_flag;
- char outline[81], curr_dir[68], org_dir[68];
- char mask[13], sort_type;
- int org_drive, curr_drive, disk_err, orow, ocol;
- char am_pm, pattr[5], drive[3], dir[66], fname[9], fext[6];
- char fattr[6];
- char *rattr=" ";
- int max=0;
- unsigned long int dir_size;
- int pending;
-
- char tline[81], inline[45], save_screen[4000], first_screen[4000];
-
-
- int err_hand(int errval, int ax, int bp, int si)
- {
- #define win_size setsize_w(8,22,14,57)
- static char line[33], win_save[win_size], resp;
- static char *emes[] = {"Disk is Write Protected",
- "Unknown Unit",
- "Drive is not Ready",
- "Unknown Command",
- "Bad CRC",
- "Bad Request Structure Length",
- "Seek Error",
- "Unknown Media Type",
- "Sector Not Found",
- "Printer out of Paper",
- "Write Fault",
- "Read Fault",
- "General Failure"};
- int attr = setatr(BLACK,RED,0,0), drive;
-
- if(ax < 0) {
- bdosptr(0x09,"Device error program aborting.$",0);
- hardresume(2);
- }
-
- drive = (ax & 0x00ff);
- save_scr(8,22,14,57,win_save);
- make_window(8,22,14,57,attr,attr,0,"DISK ERROR","");
-
- sprintf(line,"Error on Drive %c:",'A' + drive);
- writef(9,23,attr,line);
- writef(10,23,attr,"ERROR MESSAGE IS");
- writef(11,23,attr,emes[errval]);
- writef(13,23,attr,"PRESS R TO RETRY A TO ABORT");
- hide_cur();
- get_akey(&resp,"RA");
- show_cur(1);
- rest_scr(8,22,14,57,win_save);
- if(resp=='R') hardresume(1);
- disk_err=1;
- hardretn(2);
- }
-
-
- sort_ext(el1,el2)
- struct tablk *el1, *el2;
- {
- char ext1[15], ext2[15];
- strcpy(ext1,el1->my_ext);
- strcpy(ext2,el2->my_ext);
- if(el1->my_attr & 0x10) strcpy(ext1,"\x01");
- if(el2->my_attr & 0x10) strcpy(ext2,"\x01");
- strcat(ext1,el1->my_fn);
- strcat(ext2,el2->my_fn);
- return(stricmp(&ext1,&ext2));
- }
-
- sort_name(el1,el2)
- struct tablk *el1, *el2;
- {
- return(stricmp(el1->my_name,el2->my_name));
- }
-
-
- sort_size(el1,el2)
- struct tablk *el1, *el2;
- {
- if(el1->my_size > el2->my_size) return(1);
- if(el1->my_size < el2->my_size) return(-1);
- return(0);
- }
-
-
- sort_date(el1,el2)
- struct tablk *el1, *el2;
- {
- if(el1->my_year > el2->my_year) return(1);
- if(el1->my_year < el2->my_year) return(-1);
- if(el1->my_month > el2->my_month) return(1);
- if(el1->my_month < el2->my_month) return(-1);
- if(el1->my_day > el2->my_day) return(1);
- if(el1->my_day < el2->my_day) return(-1);
- return(0);
- }
-
- void common_exit()
- {
- rest_scr(0,0,24,79,first_screen);
- locate(orow,ocol);
- if(quit_flag == 'q') {
- setdisk(curr_drive);
- chdir(&curr_dir);
- }
- else {
- setdisk(org_drive);
- chdir(&org_dir);
- }
- }
-
-
- main(int argc, char *argv[])
- {
- char *head = "NAME TYPE------------------COMMAND------------RHSA SIZE TIME DATE";
- struct dfree disks;
- char *mask_pt, cfg_pt, *pt_cga, *pt_bios;
- extern int cga, bios;
- int point, scr_row, term_ch, idx;
- unsigned long int disk_tot, disk_aval;
-
- pending=0;
- quit_flag=' ';
-
- strcpy(&mask,"*.*");
- sort_type = '\x00';
- memset(&b_line,' ',80);
- b_line[80]=0x00;
- video_type();
-
- pt_cga=getenv("CGA");
- if(pt_cga && toupper(*pt_cga)=='N') cga=0;
- pt_bios=getenv("BIOS");
- if(pt_bios && toupper(*pt_bios)=='Y') bios=1;
-
- save_scr(0,0,24,79,first_screen);
- get_cur(&orow,&ocol);
- getcwd(curr_dir,68);
- strupr(curr_dir);
- strcpy(org_dir,curr_dir);
- org_drive = org_dir[0] - 'A';
- curr_drive = org_drive;
- harderr(err_hand);
- atexit(common_exit);
- if(argc > 1) {
- mask_pt=split_arg(argv[1]);
- if(mask_pt != NULL) strcpy(&mask,mask_pt);
- }
- get_cfg_file();
- clr(normal);
- sprintf(foot,foot_fmt,
- fkeyp[0],fkeyp[1],fkeyp[2],fkeyp[3],fkeyp[4],fkeyp[5],fkeyp[6],
- fkeyp[7],fkeyp[8],fkeyp[9]);
- sprintf(foota,foot_fmt,
- afkeyp[0],afkeyp[1],afkeyp[2],afkeyp[3],afkeyp[4],afkeyp[5],afkeyp[6],
- afkeyp[7],afkeyp[8],afkeyp[9]);
- sprintf(footc,foot_fmt,
- cfkeyp[0],cfkeyp[1],cfkeyp[2],cfkeyp[3],cfkeyp[4],cfkeyp[5],cfkeyp[6],
- cfkeyp[7],cfkeyp[8],cfkeyp[9]);
- restart:
- clrarea(0,0,3,79,reverse);
- writef(3,0,reverse,head);
- writef(24,0,foot_a,foot);
- highlite_foot();
- writef(0,0,reverse,"CURRENT DIR=>");
- writef(0,13,reverse,curr_dir);
- writef(1,0,reverse,"FILE MASK===>");
- writef(1,13,reverse,&mask);
- getdfree(0,&disks);
- disk_tot = (unsigned long) disks.df_total * disks.df_bsec * disks.df_sclus;
- sprintf(&tline,"TOTAL DISK SPACE=%9lu",disk_tot);
- writef(0,54,reverse,&tline);
- re_read:
- reset_cmd_line();
- point=0;
- get_names();
- if(sort_type) do_sort();
- re_show:
- getdfree(0,&disks);
- disk_aval = (unsigned long) disks.df_avail * disks.df_bsec * disks.df_sclus;
- sprintf(&tline,"AVAILABLE SPACE=%9lu",disk_aval);
- writef(1,54,reverse,&tline);
- sprintf(&tline,"BYTES IN DIR =%9lu",dir_size);
- writef(2,54,reverse,&tline);
- sprintf(&tline,"NUM FILES===>%-d",max+1);
- writef(2,0,reverse,&tline);
-
- scr_row=4;
- get_commands:
- show_em(point);
- get_commands2:
- locate(scr_row,13);
- rcolor(scr_row,0,highlite,13);
- rcolor(scr_row,49,highlite,31);
- while(!bioskey(1)) do_foot();
- idx=(scr_row - 4) + point;
- inline[0]=0x00;
- strcpy(&inline,cmd_line[idx]);
- term_ch=get_line(&inline,44,file_a,35);
- if(strlen(&inline)>0) pending++;
- rcolor(scr_row,0,file_a,13);
- rcolor(scr_row,49,file_a,31);
- strcpy(cmd_line[idx],&inline);
- switch (term_ch) {
- case(K_ENTER):
- if(strlen(&inline) < 1 || inline[0]=='*' || inline[0]==' ') {
- if(tblk[idx].my_attr & 0x10) {
- switch_dir(idx);
- goto restart;
- }
- else {
- if(pending) {exe_the_cmd(); goto get_commands;}
- else goto get_commands2;
- }
- }
- exe_the_cmd();
- goto get_commands;
- case(K_DOWN):
- scr_row++;
- if(scr_row - 4 + point > max) {
- scr_row--;
- goto get_commands2;
- }
- if(scr_row > 23) {
- scr_row=23;
- point=point+1;
- scroll_up(4,0,23,79,file_a,1);
- format_line(point+19);
- writef(23,0,file_a,&outline);
- goto get_commands2;
- }
- if(point > max) point=point-20;
- if(scr_row > 4) goto get_commands2;
- goto get_commands;
- case(K_UP):
- scr_row--;
- if(scr_row < 4) {
- scr_row=4;
- if(point ==0) goto get_commands2;
- scroll_dn(4,0,23,79,file_a,1);
- point--;
- format_line(point);
- writef(4,0,file_a,&outline);
- goto get_commands2;
- }
- goto get_commands2;
- case(K_CPGUP):
- scr_row=4;
- point=0;
- goto get_commands;
- case(K_CPGDN):
- scr_row=4;
- point=max-19;
- goto get_commands;
- case(K_PGDN):
- scr_row=4;
- if(point + 20 > max) goto get_commands2;
- point=point+20;
- if(point > max) point=max-19;
- if(max < 20) point=0;
- goto get_commands;
- case(K_PGUP):
- scr_row=4;
- if(point == 0) goto get_commands2;
- if(point > 19) point=point-20;
- else point=0;
- goto get_commands;
- case(K_F1):
- help();
- goto get_commands2;
- case(K_F2):
- case(K_F3):
- case(K_F4):
- case(K_F5):
- case(K_F6):
- term_ch = term_ch - K_F1;
- if(fkeyc[term_ch][0]) {
- strcpy(cmd_line[idx],fkeyc[term_ch]);
- exe_the_cmd();
- }
- goto get_commands;
- case(K_F7):
- sort_type='n';
- do_sort();
- point=0; scr_row=4;
- highlite_foot();
- goto get_commands;
- case(K_F8):
- sort_type='e';
- do_sort();
- point=0; scr_row=4;
- highlite_foot();
- goto get_commands;
- case(K_F9):
- sort_type='s';
- do_sort();
- point=0; scr_row=4;
- highlite_foot();
- goto get_commands;
- case(K_F10):
- sort_type='d';
- do_sort();
- point=0; scr_row=4;
- highlite_foot();
- goto get_commands;
- case(K_AF1):
- case(K_AF2):
- case(K_AF3):
- case(K_AF4):
- case(K_AF5):
- case(K_AF6):
- case(K_AF7):
- case(K_AF8):
- case(K_AF9):
- case(K_AF10):
- term_ch = term_ch - K_AF1;
- if(afkeyc[term_ch][0]) {
- strcpy(cmd_line[idx],afkeyc[term_ch]);
- exe_the_cmd();
- }
- goto get_commands;
- case(K_CF1):
- case(K_CF2):
- case(K_CF3):
- case(K_CF4):
- case(K_CF5):
- case(K_CF6):
- case(K_CF7):
- case(K_CF8):
- case(K_CF9):
- case(K_CF10):
- term_ch = term_ch - K_CF1;
- if(cfkeyc[term_ch][0]) {
- strcpy(cmd_line[idx],cfkeyc[term_ch]);
- exe_the_cmd();
- }
- goto get_commands;
- case(K_ALTX):
- dos_shell();
- goto get_commands;
- case(K_ALTA):
- do_auto_key(idx);
- exe_the_cmd();
- goto get_commands;
- case(K_ALTM):
- rcolor(1,13,normal,12);
- locate(1,13);
- get_line(&mask,12,normal,12);
- if(!strlen(&mask)) strcpy(&mask,"*.*");
- goto restart;
- case(K_ALTP):
- do_pgm(idx);
- goto get_commands;
- case(K_ALTQ):
- quit_flag='q';
- goto quit_it;
- case(K_ALTR):
- sort_type=' ';
- goto re_read;
- case(K_ALTS):
- do_tots();
- goto get_commands;
- case(K_ALTT):
- tag_all();
- goto get_commands;
- case(K_ALTD):
- rcolor(0,13,normal,40);
- locate(0,13);
- get_line(&curr_dir,67,normal,40);
- mask_pt=split_arg(&curr_dir);
- if(mask_pt != NULL) strcpy(&mask,mask_pt);
- goto restart;
- case(K_TAB):
- if(tblk[idx].my_attr & 0x10) goto get_commands2;
- strcpy(fattr," ");
- locate(scr_row,50);
- rcolor(scr_row,50,reverse,4);
- term_ch=get_line(&fattr,4,reverse,4);
- if(term_ch != K_ENTER) goto get_commands2;
- strupr(fattr);
- set_file_atr(idx);
- goto get_commands;
- case(K_ESC):
- goto quit_it;
- default:
- goto get_commands2;
- }
-
- quit_it:
- exit(0);
- }
-
- do_pgm(int idx)
- {
- int orow, ocol;
- save_scr(0,0,24,79,save_screen);
- get_cur(&orow,&ocol);
- clr(normal);
- spawnlp(P_WAIT,tblk[idx].my_name,tblk[idx].my_name,NULL);
- rest_scr(0,0,24,79,save_screen);
- locate(&orow,&ocol);
- }
-
-
- dos_shell()
- {
- int orow, ocol;
- save_scr(0,0,24,79,save_screen);
- get_cur(&orow,&ocol);
- clr(normal);
- put_sa("Exiting to DOS. Type EXIT and press enter to return\n",file_a);
- spawnlp(P_WAIT,"command.com","command.com",NULL);
- rest_scr(0,0,24,79,save_screen);
- locate(&orow,&ocol);
- }
-
- do_auto_key(int idx)
- {
- int x;
- for(x=0;x<10;x++) {
- if(!(stricmp(auto_key_ext[x],tblk[idx].my_ext))) {
- strcpy(&cmd_line[idx],&auto_key_cmd[x]);
- break;
- }
- }
- }
-
- tag_all()
- {
- int idx;
- for(idx=0;idx<=max;idx++) {
- if(tblk[idx].my_attr & 0x10) continue;
- else strcpy(cmd_line[idx],"=");
- }
- }
-
- do_tots()
- {
- int idx, x;
- char work_dir[69];
- for(idx=0;idx<=max;idx++) {
- if(tblk[idx].my_attr & 0x10) {
- if(tblk[idx].my_name[0] != '.') {
- strcpy(work_dir,curr_dir);
- x=strlen(work_dir) -1;
- if(work_dir[x] != '\\')
- strcat(work_dir,"\\");
- strcat(work_dir,&tblk[idx].my_name);
- tblk[idx].my_size=calc_tots(work_dir);
- }
- else continue;
- }
- else continue;
- }
- }
- exe_the_cmd()
- {
- static char work_line[40], work_line2[40];
- static int first=1;
- int orow, ocol, idx, x, no_pause;
- char work_cmd[128], work_file[81], *pt;
- no_pause=0; pending=0;
- if(first) {work_line[0]=0x00; work_line2[0]=0x00; first=0;}
- save_scr(0,0,24,79,save_screen);
- get_cur(&orow,&ocol);
- clr(normal);
- for(idx=0;idx <=max;idx++) {
- if(cmd_line[idx][0]=='\x00' || cmd_line[idx][0]=='*' || cmd_line[idx][0] == ' ')
- continue;
- strcpy(&work_line,&cmd_line[idx]);
- if(work_line[0]=='=')
- strcpy(&work_line,&work_line2);
- else
- strcpy(&work_line2,&work_line);
- if(work_line[0]=='=' || work_line[0]=='\x00') {
- strcpy(cmd_line[idx],"*?");
- continue;
- }
- if(work_line[0]=='/') {
- s_str_lf(1,&work_line);
- put_sa(&work_line,file_a);
- cputs("\r\n");
- system(&work_line);
- cmd_line[idx][0]='*';
- no_pause=1;
- put_sa("\nStrike a key to continue..",file_a);
- bioskey(0);
- continue;
- }
- cmd_line[idx][0]='*';
- strcpy(&work_file,&curr_dir);
- if(strlen(&curr_dir) > 3)
- strcat(&work_file,"\\");
- strcat(&work_file,&tblk[idx].my_name);
- strip(&work_file,' ');
- if(work_line[0]=='@') {
- no_pause=1;
- s_str_lf(1,&work_line);
- }
- pt=(char *)strtok(&work_line," ");
- strcpy(&work_cmd,pt);
- strcat(&work_cmd," ");
- strcat(&work_cmd,&work_file);
- pt=(char *)strtok(NULL," ");
- while(pt) {
- strcat(&work_cmd," ");
- strcat(&work_cmd,pt);
- pt=(char *)strtok(NULL," ");
- }
- put_sa(&work_cmd,file_a);
- cputs("\r\n");
- system(&work_cmd);
- }
-
- if(!no_pause) {
- put_sa("\nStrike a key to continue..",file_a);
- bioskey(0);
- }
- rest_scr(0,0,24,79,save_screen);
- locate(&orow,&ocol);
- }
-
-
- switch_dir(int idx)
- {
- char *wpt;
- int x;
- if(stricmp(&tblk[idx].my_name,"..")) {
- x=strlen(curr_dir) -1;
- if(curr_dir[x] != '\\')
- strcat(curr_dir,"\\");
- strcat(curr_dir,&tblk[idx].my_name);
- }
- else {
- wpt=strrchr(curr_dir,'\\');
- if(wpt) {
- if(*(wpt-1) != ':') *wpt=0x00;
- else *(wpt+1)=0x00;
- }
- }
- }
-
- get_names()
- {
- extern int errno, _doserrno;
- char f_dir[80];
- int done, x;
- max=0;
- dir_size=0;
- disk_err=0;
- strcpy(f_dir,curr_dir);
- x=strlen(curr_dir) -1;
- if(f_dir[x] != '\\')
- strcat(f_dir,"\\");
- strcat(f_dir,&mask);
- done=findfirst(&f_dir,(struct ffblk *)&dta,0xf7);
- if(done) {
- getcwd(curr_dir,67);
- strcpy(f_dir,curr_dir);
- x=strlen(curr_dir) -1;
- if(f_dir[x] != '\\')
- strcat(f_dir,"\\");
- strcat(f_dir,&mask);
- writef_n(0,13,reverse,b_line,67);
- writef(0,13,reverse,curr_dir);
- }
- done=findfirst(&f_dir,(struct ffblk *)&dta,0xf7);
- if(disk_err==1) exit(0);
- while(!done) {
- memcpy(&tblk[max],&dta.move,sizeof(dta.move));
- dir_size = dir_size + tblk[max].my_size;
- fnsplit(&tblk[max].my_name,drive,dir,fname,fext);
- if(fext[0] == '.') s_str_lf(1,fext);
- strip(&fext,' ');
- if(tblk[max].my_attr & 0x10) {
- strcpy(fname,&tblk[max].my_name);
- strcpy(fext,"<DR>");
- }
- strcpy(&tblk[max].my_ext,fext);
- strcpy(&tblk[max].my_fn,fname);
- done=findnext((struct ffblk *)&dta);
- max++;
- if(max > 499) {
- printf("OUT OF MEMORY TO MANY FILES\n");
- bioskey(0);
- exit(0);
- }
- }
- max--;
- }
-
- show_em(int curr)
- {
- int srow=4;
- while(1) {
- format_line(curr);
- writef(srow,0,file_a,&outline);
- curr++; srow++;
- if(curr > max) break;
- if(srow > 23) return;
- }
- while(srow < 24) {
- writef(srow,0,file_a,&b_line);
- srow++;
- }
- return;
- }
-
- format_line(int curr)
- {
- strcpy(pattr,rattr);
- if(tblk[curr].my_hour==00) {
- tblk[curr].my_hour=12;
- am_pm='p';
- }
- if(tblk[curr].my_hour > 12) {
- am_pm='a';
- tblk[curr].my_hour = tblk[curr].my_hour - 12;
- }
- else am_pm='p';
- strcpy(pattr,"----");
- if(tblk[curr].my_attr & 0x10) strcpy(pattr," ");
- if(tblk[curr].my_attr & 0x01) pattr[0]='R';
- if(tblk[curr].my_attr & 0x02) pattr[1]='H';
- if(tblk[curr].my_attr & 0x04) pattr[2]='S';
- if(tblk[curr].my_attr & 0x20) pattr[3]='A';
- sprintf(&outline,"%-8.8s %-4.4s%-36.36s %4.4s %10li %2.2i:%2.2i%c %2.2i%2.2i%2.2i",
- tblk[curr].my_fn,tblk[curr].my_ext,cmd_line[curr],pattr,tblk[curr].my_size,
- tblk[curr].my_hour,tblk[curr].my_min,am_pm,
- tblk[curr].my_month,tblk[curr].my_day,tblk[curr].my_year+80);
- }
-
-
- char *split_arg(char *cmd_arg)
- {
- static char imask[15];
- int idx;
- disk_err=0;
- strupr(cmd_arg);
-
- fnsplit(cmd_arg,&drive,&dir,&fname,&fext);
- if(drive[0] != 0x00)
- curr_drive=drive[0] - 'A';
- else {
- curr_drive=getdisk();
- drive[0]=curr_drive + 'A';
- drive[1]=':';
- drive[2]=0x00;
- }
-
- if(dir[0] != 0x00) {
- idx=strlen(&dir) - 1;
- if(idx>0) {
- if(dir[idx] == '\\') {dir[idx]=0x00;}
- if((fext[0]==0x00) && (fname[0] != 0x00)) {
- strcat(dir,"\\");
- strcat(dir,fname);
- fname[0]='\x00';
- }
- }
- else {
- if(fname[0] !=0x00) {
- strcat(dir,fname);
- fname[0]=0x00;
- }
- }
- }
-
- strcpy(curr_dir,drive);
- strcat(curr_dir,dir);
-
- if(fname[0] != 0x00) {
- strcpy(&imask,&fname);
- strcat(&imask,&fext);
- return(&imask);
- }
- else return(NULL);
- }
-
- do_sort()
- {
- reset_cmd_line();
- switch(sort_type) {
- case('e'):
- qsort(&tblk[0],max+1,sizeof(tblk[0]),sort_ext);
- break;
- case('n'):
- qsort(&tblk[0],max+1,sizeof(tblk[0]),sort_name);
- break;
- case('s'):
- qsort(&tblk[0],max+1,sizeof(tblk[0]),sort_size);
- break;
- case('d'):
- qsort(&tblk[0],max+1,sizeof(tblk[0]),sort_date);
- break;
- }
- }
-
- do_foot()
- {
- static int okey_stat = 3;
- static int ckey_stat = 3;
- if(bioskey(2) & 0x08) ckey_stat=1;
- else
- if(bioskey(2) & 0x04) ckey_stat=2;
- else
- ckey_stat=0;
- if(ckey_stat == okey_stat)
- return;
- okey_stat = ckey_stat;
- if(ckey_stat==1) writef(24,0,foot_a2,foota);
- else
- if(ckey_stat==2) writef(24,0,foot_a3,footc);
- else {
- writef(24,0,foot_a,foot);
- highlite_foot();
- }
- }
-
- highlite_foot()
- {
- rcolor(24,48,foot_a,32);
- switch (sort_type) {
- case 'n':
- rcolor(24,48,foot_ah,8);
- break;
- case 'e':
- rcolor(24,56,foot_ah,8);
- break;
- case 's':
- rcolor(24,64,foot_ah,8);
- break;
- case 'd':
- rcolor(24,72,foot_ah,8);
- break;
- }
- }
-
- set_file_atr(int idx)
- {
- char new_attr;
- int x;
- new_attr=0x00;
- for(x=0;x<4;x++) {
- if(fattr[x]=='H') new_attr=new_attr | FA_HIDDEN;
- if(fattr[x]=='R') new_attr=new_attr | FA_RDONLY;
- if(fattr[x]=='S') new_attr=new_attr | FA_SYSTEM;
- if(fattr[x]=='A') new_attr=new_attr | FA_ARCH;
- }
- tblk[idx].my_attr=_chmod(&tblk[idx].my_name,1,new_attr);
- }
-
- reset_cmd_line()
- {
- int idx;
- for(idx=0;idx < 500;idx++) cmd_line[idx][0]=0x00;
- }
-
-
- get_cfg_file()
- {
- char *pt1, *pt2, *pt3;
- char *buff, *path;
- int idx, type;
- FILE *in;
- path=(char *)searchpath("fm.cfg");
- if(!path) return;
- buff=(char *)malloc(200);
- in=fopen(path,"rt");
- while(fgets(buff,100,in)) {
- if(*buff=='*') {
- continue;
- }
- strupr(buff);
- pt1=(char *)strtok(buff,"#");
- pt2=(char *)strtok(NULL,"#");
- pt3=(char *)strtok(NULL,"#");
- if(pt1==NULL | pt2==NULL | pt3==NULL) continue;
- if(!strncmp(pt1,"AF",2)) type=3;
- else
- if(!strncmp(pt1,"CF",2)) type=4;
- else
- if(*pt1=='F') type=2;
- else
- if(*pt1=='A') type=1;
- else type=0;
- switch (type) {
- case(1):
- idx=atoi(pt1+1)-1;
- if(idx < 0 | idx > 9) break;
- strcpy(auto_key_ext[idx],pt2);
- strcpy(auto_key_cmd[idx],pt3);
- break;
- case(2):
- idx=atoi(pt1+1) - 1;
- if(idx < 0 | idx > 6) break;
- strcpy(fkeyp[idx],pt2);
- strcpy(fkeyc[idx],pt3);
- break;
- case(3):
- idx=atoi(pt1+2)-1;
- if(idx < 0 | idx > 9) break;
- strcpy(afkeyp[idx],pt2);
- strcpy(afkeyc[idx],pt3);
- break;
- case(4):
- idx=atoi(pt1+2)-1;
- if(idx < 0 | idx > 9) break;
- strcpy(cfkeyp[idx],pt2);
- strcpy(cfkeyc[idx],pt3);
- break;
- }
- }
- fclose(in);
- free(buff);
- }
-
-
- help()
- {
- int orow, ocol, x;
- save_scr(0,0,24,79,save_screen);
- get_cur(&orow,&ocol);
- clr(normal);
- locate(0,0);
- printf("Current Function Key Definitions\n");
- for(x=0;x<10;x++) {
- printf("F%-2.2d = %-4.4s = %-19.19s\n",x+1,fkeyp[x],fkeyc[x]);
- }
- printf("\nCurrent ALT Function Key Definitions\n");
- for(x=0;x<10;x++) {
- printf("F%-2.2d = %-4.4s = %-19.19s\n",x+1,afkeyp[x],afkeyc[x]);
- }
- locate(0,38);
- printf("│Current Auto-commands ALT-A");
- for(x=0;x<10;x++) {
- locate(x+1,38);
- printf("│EXT=%3.3s CMD=%-19.19s",auto_key_ext[x],auto_key_cmd[x]);
- }
- rcolor(0,0,foot_ah,80);
- locate(12,38);printf("│PERMANENT KEY DEFITIONS");
- locate(13,38);printf("│ALT-A = Exit to DOS");
- locate(14,38);printf("│ALT-D = Change Directory");
- locate(15,38);printf("│ALT-M = Change file mask");
- locate(16,38);printf("│ALT-P = Execute highlited file");
- locate(17,38);printf("│ALT-Q = Exit to current DIR");
- locate(18,38);printf("│ALT-R = Re-Read the Directory");
- locate(19,38);printf("│ALT-T = Tag all files");
- locate(20,38);printf("│ALT-S = Calc DIR Sizes");
- locate(21,38);printf("│ALT-X = Exit to DOS");
- locate(22,38);printf("│TAB = Modify File ATTRS");
- locate(23,38);printf("│ESC = Quit FM");
- rcolor(12,0,foot_ah,80);
- locate(24,20);printf("Strike any key to continue");
- bioskey(0);
- rest_scr(0,0,24,79,save_screen);
- locate(&orow,&ocol);
- }