A Norton Commander style directory browser, part 04/05

0 views
Skip to first unread message

Gadzhiev A. M.

unread,
Mar 15, 1995, 8:17:41 PM3/15/95
to
Submitted-by: ale...@angel.energy.msk.su (Gadzhiev A. M.)
Posting-number: Volume 7, Issue 46
Archive-name: directory_browser/part04

-+-+-+-+-+-+-+-+ START OF PART 4 -+-+-+-+-+-+-+-+
X`09`09mvwaddstr(bwin,0,0,out);
X`09`09sprintf(out,"%sm%sj%s",_on,tmp,_off);
X`09`09mvwaddstr(bwin,bwin->_max_y-1,0,out);
X
X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20for(i=0;i<bwin->_max_x-2;i++)
V
X`09`09`09tmp`5Bi`5D='`20';
X`09`09`20`20`20tmp`5Bi`5D=0;
X`09`09sprintf(out,"%sx%s%s%sx%s",_on,_off,tmp,_on,_off);
X
X`09`09for`20(i=1;i<bwin->_max_y-1;i++)
X`09`09`09`09mvwaddstr(bwin,i,0,out);
X`09
X`09`09/*`09wrefresh(bwin);`20*/
X`09`09
X`7D`09
X`09`09
X
X
Xchar`20*strupr(char`20*str)
X`7B`20`20`20
X`20register`20`20`20char`20*beg;
X`20`20`20`20
X`20`20`20`20beg=str;
X`09`20while`20((*str)!=0)
X`20`20`20`20`20`20`20`20`09`20`20`20`20`7B`09
X`09`09`20`20`20`20*str=(char)_toupper(*str);
X`09`09`09str++;
X`09`09`09`7D
X`09`09return`20beg;
X`7D`09`09`09`09`09`09`09`20`20`20/*2*/
X`20`20`20`20`09`09`09`09`09`09`09`20`20`20/*2*/
Xchar`20*strlwr(char`20*str)
X`7B`20`20`20
X`20`20`20register`20`20char`20*beg;
X`20`20`20`20
X`20`20`20`20beg=str;
X`09`20while`20((*str)!=0)
X`20`20`20`20`20`20`20`20`09`20`20`20`20`7B`09
X`09`09`20`20`20`20*str=(char)_tolower(*str);
X`09`09`09str++;
X`09`09`09`7D
X`09`09return`20beg;
X`7D`20`20`20`20`09
X
X`09`09`09`09`09`09`09`20`20`20/*2*/
X/*`20Just`20like`20system()`20but`20output`20to`20NULL`20device`20*/`09`20`20
V`20/*2*/
X`09`09
Xunsigned`20run(char*`20_command)
X`7B
X`09unsigned`20stat,ret_st,flg=0;
X`09$DESCRIPTOR(d_cmd,"");
X`09$DESCRIPTOR(d_null,"_NLA0:");
X`09
X
X`09d_cmd.dsc$w_length=strlen(_command);
X`09d_cmd.dsc$a_pointer=_command;
X`09
X`09status=lib$spawn(`26d_cmd,0,`26d_null,`26flg,0,0,`26ret_st);
X`09`09`09
X`09if`20(!(ret_st`20`26`201))`20
X`09`09_mess(`26ret_st);
X`09else`20
X`09`09return`20ret_st;`20
X`7D
X`09
X`09
Xvoid`20save(unsigned`20*`20dis_id)
X`7B
X`09smg$save_physical_screen(`26(stdpb->_id),
X`09`09dis_id);`20
X`09
X`7D
X
Xvoid`20restore(unsigned`20*`20dis_id)
X`7B
X`09smg$restore_physical_screen(`26(stdpb->_id),dis_id);
X`7D`09`09
X
$ call unpack MISC.C;1 712726672 "" 24 21 31
$!
$ create 'f'
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20MISC.H*/
X/*`20*3`20`20`20`20`203-NOV-1994`2016:41:37`20ALEXEY`20"DEC`20C`20compiled`20o
Vk.`20"*/
X/*`20*2`20`20`20`2015-APR-1994`2015:26:49`20ALEXEY`20"GCC`20port`20fixed."*/
X/*`20*1`20`20`20`2014-APR-1994`2015:12:47`20ALEXEY`20"Prototipes`20for`20funct
Vions`20from`20misc.c"*/
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20MISC.H*/
X#include`20<curses.h>
X#include`20<vms/smgtrmptr.h>`09`09`09`09`20`20`20/*2*/
X#include`20<stddef.h>`09`09`09`09`09`20`20`20/*2*/
X
X
Xtypedef`20struct`20dsc$descriptor`20dsc_s`20;
X
Xchar`20*`20search(char`20*filenam,unsigned`20*context);
Xunsigned`20`20`20`20_system(char`20*command,unsigned`20waitflag);
Xunsigned`20parse(char`20*filename,char`20*node,char`20*dev,
X`09`20`20char`20*dir,char`20*name,char`20*type,char`20*ver);
Xunsigned`20short`20_getch(void);
Xvoid`20delkbd(void);
Xunsigned`20term_tbl(char`20*term_type);
Xunsigned`20set_term(unsigned`20term,unsigned`20code);
Xvoid`20del_term_tbl(void);
Xdsc_s`20*dsc(char`20*str);
Xunsigned`20_box();
Xunsigned`20init_term_tbl();
Xchar`20*get_com(unsigned`20code,...);
Xvoid`20put_back(unsigned);
Xchar`20*strupr(char*);
Xchar`20*strlwr(char*);
Xint`20`20exist(char`20*);
Xunsigned`20run(char*);
Xvoid`20save(unsigned`20*);
Xvoid`20restore(unsigned`20*);
Xvoid`20*`20xmalloc(size_t);`09`09`09`09`09`20`20`20/*2*/
X`09`09`09`09`09`09`09`20`20`20/*2*/
Xextern`20unsigned`20`20PASTEBOARD_ID;`09`09`09`09`20`20`20/*2*/
X
Xextern`20unsigned`20status;`09`09`09`09`09`20`20`20/*3*/
Xextern`20unsigned`20kbd_id;`09`09`09`09`09`20`20`20/*3*/
Xextern`20unsigned`20term_table;`09`09`09`09`20`20`20/*3*/
X
Xstatic`20const`20unsigned`20long`20`20cursor_off=SMG$M_CURSOR_OFF;`20`20`20/*3
V*/
Xstatic`20const`20unsigned`20long`20`20cursor_on=SMG$M_CURSOR_ON;`09`20`20`20/*
V3*/
X`09`09`09`09`09`09`09`20`20`20/*2*/
X#define`20WAIT`20`20`200
X#define`20NOWAIT`201
X`09`09`09`09`09`09`09`20`20`20/*2*/
X#define`20DRAW_ON()`20set_term(term_table,SMG$K_BEGIN_LINE_DRAWING_CHAR)
X#define`20DRAW_OFF()`20set_term(term_table,SMG$K_END_LINE_DRAWING_CHAR)
X`09`09`09`09`09`09`09`20`20`20/*2*/
X#define`20CURSOR_OFF()`20smg$set_cursor_mode(`26(stdpb->_id),`26cursor_off)`20
V/*2*/
X#define`20CURSOR_ON()`20smg$set_cursor_mode(`26(stdpb->_id),`26cursor_on)`20/*
V2*/
X#define`20CURSOR_SAVE()`20set_term(term_table,SMG$K_SAVE_CURSOR)
X#define`20CURSOR_RESTORE()`20set_term(term_table,SMG$K_RESTORE_CURSOR)
$ call unpack MISC.H;1 1762745362 "" 4 22 31
$!
$ create 'f'
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20NAVIGATE.C*/
X/*`20*2`20`20`20`2015-APR-1994`2015:16:36`20ALEXEY`20"GCC`20port`20fixed."*/
X/*`20*1`20`20`20`2013-APR-1994`2017:45:51`20ALEXEY`20"Main`20file`20drawing`20
Vand`20screen`20navigation`20module."*/
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20NAVIGATE.C*/
X/*
X`20*`20This`20file`20hold`20main`20functions`20for`20screen`20and`20window`20m
Vanipulation`20.
X`20*/
X
X
X#include`20<curses.h>
X#include`20<errno.h>
X#include`20<setjmp.h>
X#include`20<unixlib.h>
X#include`20<stdlib.h>
X#include`20<sys/stat.h>`09`09`09`09`09`20`20`20/*2*/
X#include`20<vms/smg$routines.h>
X#include`20<string.h>
X#include`20"misc.h"`09`09`09`09`09`20`20`20/*2*/
X#include`20"definitions.h"
X#include`20"variables.h"
X#include`20"key.h"
X
X
X/*`20
X`20*`20Numbers`20of`20files`20selected`20in`20panels`20.
X`20*/`20
X
Xint`20number_selected`5B2`5D=`7B0,0`7D;`09`09`09`09`20`20`20/*2*/
X/*
X`20*`20Complete`20size`20of`20all`20selected`20files`20in`20panels.
X`20*/`20`20
X
Xlong`20all_size`5B2`5D=`7B0,0`7D;`09`09`09`09`09`20`20`20/*2*/
X
X/*
X`20*`20This`20structure`20used`20to`20get`20information`20about`20selected`20f
Viles`20.
X`20*/
Xstat_t`20buffer`5B2`5D;
X
Xextern`20int`20char_pos;`09
Xextern`20no_display;
X
Xchar`20*`20`20menu(WINDOW*,char**);
Xvoid`20`20`20`20build_icons();
Xchar`20**`20build_dir(void);`09`09`09`09`20`20`20/*2*/
Xvoid`20`20`20`20initialize(void);`09`09`09`09`20`20`20/*2*/
Xchar`20*`20`20indls(int,char**);
Xvoid`20`20`20`20good_bye(void);`09`09`09`09`09`20`20`20/*2*/
Xvoid`20`20`20`20main_loop(void);`09`09`09`09`20`20`20/*2*/
Xvoid`20`20`20`20panel();
Xvoid`20`20`20`20reread(char*,int);
Xvoid`20`20`20`20init_panels(int);
Xvoid`20`20`20`20actions();
Xvoid`20`20`20`20arrow();
Xvoid`20`20`20`20change_panel();
Xvoid`20`20`20`20set_fatal();
Xint`20`20`20`20`20if_chdir();
Xchar`20`20`20*inside(char,int,int);
Xvoid`20`20`20`20fresh();
Xvoid`20`20`20`20print_name();
Xvoid`20`20`20`20draw_ttl();
Xvoid`20`20`20`20file_edit();
Xvoid`20`20`20`20reface();
Xvoid`20`20`20`20line_flash();
Xvoid`20`20`20`20sort_dir(char**,int,int);
Xint`20`20`20`20`20prom_chdir(int,int);
Xint`20`20`20`20`20_alarm(char*,char*,char*);
Xvoid`20`20`20`20set_timer(void);`09`09`09`09`20`20`20/*2*/
Xvoid`20`20`20`20cli_init(void);`09`09`09`09`09`20`20`20/*2*/
Xvoid`20`20`20`20cre_dir();
Xchar`20*onl_name(char*);
Xvoid`20`20`20`20call_info(char`20*);
Xvoid`20`20`20`20dev_scan(void);`09`09`09`09`09`20`20`20/*2*/
X
Xint`20is_sel(int,char**);
Xvoid`20del_sel(int,char**);
Xint`20reg_sel(int,char**);`09`20
Xint`20chdir`20(char`20*);
Xint`20find_file(),find_dir();
X
X
Xint`20is_sel(int`20ind,char`20**base)
X`7B
X
X`09return`20select_list`5Bcurrent_panel`5D`5B(base+ind)-dirs`5Bcurrent_panel
V`5D`5D;
X`7D
X
Xint`20`20reg_sel(int`20ind,char`20**base)`09`09`09`20`20`20/*2*/
X`7B`09`09`09`09`09`09`09`20`20`20/*2*/
X`09int`20in;`09`09`09`09`09`09`20`20`20/*2*/
X`09in=(base+ind)-dirs`5Bcurrent_panel`5D;`09`09`20`20`20/*2*/
X`09`09`09`09`09`09`09`20`20`20/*2*/
X`20`20`20if`20(strcmp(dirs`5Bcurrent_panel`5D`5Bin`5D,"-")`20`20`26`26`20`20!s
Vtrstr(dirs`5Bcurrent_panel`5D`5Bin`5D,`20/*2*/
X`09`09`09".DIR;"))`09`09`09`20`20`20/*2*/
X`09`7B`09`09`09`09`09`09`20`20`20/*2*/
X`09select_list`5Bcurrent_panel`5D`5Bin`5D=1;`09`09`20`20`20/*2*/
X`09number_selected`5Bcurrent_panel`5D++;`09`09`20`20`20/*2*/
X`09stat(dirs`5Bcurrent_panel`5D`5Bin`5D,`26(buffer`5Bcurrent_panel`5D));`20/*2
V*/
X`09all_size`5Bcurrent_panel`5D+=buffer`5Bcurrent_panel`5D.st_size;`20/*2*/
X`09return`201;`09`09`09`09`09`20`20`20/*2*/
X`09`7D`09`09`09`09`09`09`20`20`20/*2*/
X`09return`200;`09`09`09`09`09`20`20`20/*2*/
X`7D`09`09`09`09`09`09`09`20`20`20/*2*/
Xvoid`20del_sel(int`20ind,char`20**base)`09`09`09`20`20`20/*2*/
X`7B`09`09`09`09`09`09`09`20`20`20/*2*/
X`09int`20in;`09`09`09`09`09`09`20`20`20/*2*/
X`09in=(base+ind)-dirs`5Bcurrent_panel`5D;`09`09`20`20`20/*2*/
X`09`09`09`09`09`09`09`20`20`20/*2*/
X`09if(select_list`5Bcurrent_panel`5D`5Bin`5D)`09`09`20`20`20/*2*/
X`09`7B`09`09`09`09`09`09`20`20`20/*2*/
X`09number_selected`5Bcurrent_panel`5D--;`09`09`20`20`20/*2*/
X`09stat(dirs`5Bcurrent_panel`5D`5Bin`5D,`26(buffer`5Bcurrent_panel`5D));`20/*2
V*/
X`09all_size`5Bcurrent_panel`5D-=buffer`5Bcurrent_panel`5D.st_size;`20/*2*/
X`09`7D`09`09`09`09`09`09`20`20`20/*2*/
X`09select_list`5Bcurrent_panel`5D`5B(base+ind)-dirs`5Bcurrent_panel`5D`5D=(int
V)NULL;`20/*2*/
X`7D`09`09`09`09`09`09`09`20`20`20/*2*/
X`09`09`09`09`09`09`09`20`20`20/*2*/
X
Xvoid`20init_panels(int`20is_new)
X`7B`20int`20i;
X`20`20i=current_panel;
X`20`20for(current_panel=0;current_panel<2;current_panel++)
X`20`20`20`20`7B
X`20`20`20`20`20`20if(is_new==NEW)`20prom_chdir(current_panel,INIT_TIME);`09
X`20`20`20`20`20`20reread((is_new==NEW)?NULL:SLK_FILE,(is_new==NEW)?(int)NULL:G
VLB_SLK);
X`20`20`20`20`20`20print_name();
X`20`20`20`20`7D
X`20`20current_panel=i;
X`20`20
X`20`20ACT(_CHOICE);
X`20`20chdir(cwd`5Bcurrent_panel`5D);
X`20`20fresh();
X`20`20
X`7D
X
Xvoid`20fresh(void)
X`7B
X`20`20
X`20`20
X`20`20wrefresh(face1);
X`20`20wrefresh(face2);
X`20`20wrefresh(panels`5B0`5D`5B0`5D);
X`20`20wrefresh(panels`5B1`5D`5B0`5D);
X`20`20wrefresh(panels`5B2`5D`5B0`5D);
X`20`20wrefresh(panels`5B0`5D`5B1`5D);
X`20`20wrefresh(panels`5B1`5D`5B1`5D);
X`20`20wrefresh(panels`5B2`5D`5B1`5D);
X`20`20wrefresh(prompt);
X`20`20wrefresh(input);
X`20`20wrefresh(help);
X`20`20
X`20`20
X`7D
X
Xvoid`20re_paint(void)
X`7B
X`20`20
X`20`20smg$repaint_screen(`26(stdpb->_id));
X`7D
X
X
X
Xextract_dir(char`20*full_dir)
X`7B
X`20`20int`20i;
X`20`20char`20*end;
X`20`20char`20tmp`5B80`5D;
X`20`20
X`20`20*(strchr(full_dir,'`5D'))='`5C0';`09
X`20`20
X`20`20for(i=strlen(full_dir)-1;i>=0;i--)
X`20`20`20`20if(full_dir`5Bi`5D=='.'`7C`7Cfull_dir`5Bi`5D=='`5B')`20break;
X`20`20strcpy(tmp,full_dir+i+1);
X`20`20strcpy(full_dir,tmp);
X`20`20strcat(full_dir,".DIR;1");
X`7D`09
X
Xint`20if_chdir(void)
X`7B`20`20char`20_name`5B100`5D,_type`5B20`5D;
X`09char`20rez_dir`5B30`5D;
X`09int`20is_parent=0;
Xstatic`20char`20leave_dir`5B80`5D;
X`09if(!strcmp(SLK_FILE,"-"))
X`09`09`7B
X`09`09`09strcpy(_name,"-");
X`09`09`09is_parent++;
X
X
X`09`09`7D
X`09else
X`09
X`09`20`20`20`20`20parse(SLK_FILE,NULL,NULL,NULL,_name,_type,NULL);
X
X
X`09if`20((!strcmp(_type,".DIR"))`7C`7Cis_parent)
X`09`09`7B
X`09`09`09if(strstr(cwd`5Bcurrent_panel`5D,"`5B000000`5D"))
X`09`09`09`20`20`20sprintf(rez_dir,"`5B%s`5D",_name);
X`09`09`09else
X`09`09`09`20`20`20`20sprintf(rez_dir,"`5B.%s`5D",_name);
X`09`09`20`20`20`20`20if(is_parent)
X`09`09`09`7B`09`09
X`09`09`09`20strcpy(leave_dir,cwd`5Bcurrent_panel`5D);
X`09`09`09`20extract_dir(leave_dir);`09`09`09
X`09`09`09`7D
X`09`09`09strcpy(cwd`5Bcurrent_panel`5D,rez_dir);
X
X`09`09`09ACT(_UNCHOICE);
X`09`09`09reread(is_parent?leave_dir:0,
X`09`09`09`20`20`20`20`20`20`20is_parent?(-1):0);
X`09`09`09ACT(_CHOICE);
X`09`09`09return`201;
X`09`09`7D
X`09return`200;
X`7D
X
Xvoid`20change_panel(void)
X`7B
X
X`09ACT(_UNCHOICE);
X`09current_panel=(current_panel==LEFT)?RIGHT:LEFT;
X`09chdir(cwd`5Bcurrent_panel`5D);`09
X`09ACT(_CHOICE);
X`7D
X
X
X
Xvoid`20print_name(void)
X`7B`09char`20*name="<UP-DIR>";
X`09char`20line`5B40`5D;
X`09char`20*point;
X
X`09werase(WIN(NAME_WIN));
X`09
X`09if`20(NMB_FLS==0)`7B`20mvwaddstr(WIN(NAME_WIN),0,0,"*USE`20`20FILTER`20`20-
V`20(CTRL/A)*");
X`09`09`09`20wrefresh(WIN(NAME_WIN));
X`09`09`09`20return;
X`09`09`09`20`7D
X
X`09if(number_selected`5Bcurrent_panel`5D)
X`09`09`7B
X`09`09`09sprintf(line,"`20%-d.%-d`20KB`20`20in`20%d`20Selected`20File%c`20",
X`09`09`09`09`09
X`09`09`09`09`09all_size`5Bcurrent_panel`5D
X`09`09`09`09`09/1024,
X`09`09`09`09`09all_size`5Bcurrent_panel`5D
X`09`09`09`09`09%1024,
X`09`09`09`09`09number_selected`5Bcurrent_panel`5D,
X`09`09`09`09`09(number_selected`5Bcurrent_panel`5D==1)?'`20':'s');
X`09`09`09point=line;
X`09`09`7D
X`09else
X`09`7B
X`09if`20(strcmp(SLK_FILE,"-"))
X`09`20`20`20`7B
X`09`09point=strchr(SLK_FILE,'`5D')+1;
X`09`09
X`09`20`20`20`7D
X`09else
X`09`20`20`20`7B
X`09`09point=name;
X`09`20`20`20`7D`09`09`20
X`09`7D`09
X`09mvwaddstr(WIN(NAME_WIN),0,0,point);
X`09wrefresh(WIN(NAME_WIN));
X`7D
X
Xvoid`20hide_password(char`20*string)`7B
Xchar`20*`20end_of_pass,*first_space;
Xint`20i;
X
Xend_of_pass=strstr(string,"`5C"::");
Xif(!end_of_pass)
X`20`20return;
Xelse
X`20`20`7B
X`20`20`20`20first_space=strstr(string,"`20");
X`20`20`20`20if(!first_space)
X`20`20`20`20`20`20return;
X`20`20`20`20else`20if(first_space>=end_of_pass)
X`20`20`20`20`20`20return;
X`20`20`20`20else
X`20`20`20`20`20`20`7B
X`09first_space++;
X`09*first_space='*';
X`09first_space++;
X`09strcpy(first_space,end_of_pass);
X`20`20`20`20`20`20`7D
X
X`20`20`7D
X`7D
X`09
X`20`20`20`20
X
Xvoid`20draw_ttl(void)`09`09`09`09`09`20`20`20/*2*/
X`7B
X`09int`20len;
X`09char`20ttl`5B256`5D;
X`09char`20tmp`5B40`5D;
X`09char`20*point;
X`09
X`09getcwd(cwd`5Bcurrent_panel`5D,256);
X`09strcpy(ttl,cwd`5Bcurrent_panel`5D);
X`09
X`09hide_password(ttl);
X
X`09if((len=strlen(ttl))>39)
X`09`09`09`7B
X`09`09`09`09point=strchr(ttl,'`5B');
X`09`09`09`09*(point+1)='*';
X`09`09`09`09strcpy(tmp,point+2+len-39);
X`09`09`09`09strcpy(point+2,tmp);
X`09`09`09`7D
X
X`09werase(title`5Bcurrent_panel`5D);
X`09wsetattr(title`5Bcurrent_panel`5D,_BOLD);
X`09mvwaddstr(title`5Bcurrent_panel`5D,0,0,ttl);
X`09wclrattr(title`5Bcurrent_panel`5D,_BOLD);`09`09`20`20`20/*2*/
X`09wrefresh(title`5Bcurrent_panel`5D);
X`7D
X`09`09`09`09`09
X
Xvoid`20set_offset(char*`20file,int`20num)
X`7B
X`09register`20int`20offset,frame=0;
X`09
X`20`20`20if`20((file==(int)NULL)`20`26`26`20(num==(int)NULL))`09`09`20`20`20/*
V2*/
X`20`20`20`20`20`20`20`7B`09`09
X`09GLB_SLK=1;
X`09LST_OFS=0;
X`09return;
X`20`20`20`20`20`20`20`7D
X
X`20`20`20else`20if`20(strstr(file,".DIR;")`20`26`26`20(num==-1))
X`20`20`20`20`20`20`7B`09`09
X`09if`20(offset=find_dir(dirs`5Bcurrent_panel`5D,NMB_FLS,file))
X`09`09`7B
X`09`09`20`20GLB_SLK=offset;
X`09`09`20`20while`09(offset>frame+ITEM_IN_PANEL*2)
X`09`09`09`09frame++;
X`09`09`20`20LST_OFS=frame;
X`09`09`20`20return;
X`09`09`7D
X`09else
X`09`09`7B
X`09`09`20`20GLB_SLK=1;
X`09`09`20`20LST_OFS=0;
X`09`09`20`20return;
X`09`09`7D`09`09`09
X`20`20`20`20`20`7D
X`20`20`20else`20if`20(file)
X`09`20`20`20`20`20if(offset=find_file(dirs`5Bcurrent_panel`5D,NMB_FLS,file))
X`09`09`20`7B
X`09`09`20`20`20frame=LST_OFS;
X`09`09`20`20`20while`20(frame>NMB_FLS)
X`09`09`09`09frame-=ITEM_IN_PANEL*2;
X`09`09`20`20`20LST_OFS=(frame>=0)?frame:0;
X`09`09`20`20`20GLB_SLK=offset;
X`09`09`20`20`20return;
X`09`09`20`7D
X
X
X`20`20if`20`20(num)
X`09`20`20`20`20`20`7B
X`09`09`20`20`20offset=(num<=NMB_FLS)?num:NMB_FLS;
X`09`20`09
X`09`09`20`20`20frame=LST_OFS;
X`09`09`20`20`20while`20(frame>NMB_FLS)
X`09`09`09`09frame-=ITEM_IN_PANEL*2;
X
X`09`09`20`20`20LST_OFS=(frame>=0)?frame:0;
X`09`09`20`20`20GLB_SLK=offset;
X`09`09
X`09`20`20`20`20`20`7D
X`20`20else
X`09`20`20`20`20
X`20`20`20`20`20`20`20`20`20`20`20`20`20`7B
X`09`09
X`09`09GLB_SLK=1;
X`09`09LST_OFS=0;
X
X`20`20`20`20`20`20`20`20`20`20`20`20`20`7D
X`09`09
X`09
X`7D
X`09
Xvoid`20reread(char`20*found_file,int`20offs)
X`7B
X`09char`20stor_sel`5B256`5D;
X
X
X`09CURSOR_OFF();`09
X`09
X`09if(found_file)
X`09`09strcpy(stor_sel,found_file);
X`09`09`20`20`09
X
X`09number_selected`5Bcurrent_panel`5D=0;
X`09all_size`5Bcurrent_panel`5D=0;
X`20`20`20`20for(;(`20`20(chdir(cwd`5Bcurrent_panel`5D)!=(int)NULL)`20`7C`7C`09
V`20`20`20/*2*/
X`09((dirs`5Bcurrent_panel`5D=build_dir())==(int)NULL)`20`20);)`20/*2*/
X`09`09`7B
X`09`09`09switch(_alarm("`20Error`20(`5Ed-CHdev)`20","CHdir","Back"))
X`09`09`09`09`7B
X
X`09`09`09`09`09case`201:
X`09`09`09`09`09`09prom_chdir(current_panel,
X`09`09`09`09`09`09`09`09RECOV);
X`09`09`09`09`09`09break;
X
X`09`09`09`09`09case`200:
X`09`09`09`09`09`09prom_chdir(current_panel,
X`09`09`09`09`09`09`09`09NO_SAFE);
X`09`09`09`09`09
X`09`09`09`09`7D
X`09`09`7D
X`09`09`09`09`09`09
X`09`09`09`09`09`09
X`09sort_dir(dirs`5Bcurrent_panel`5D,NMB_FLS,sort);
X
X`20`20`20`20`20`20`20`20if`20(LST_OFS>NMB_FLS)
X`09`20`20`20`20`20if`20(NMB_FLS<2*ITEM_IN_PANEL)
X`09`09LST_OFS`20=`201;
X`20`20`20`20`20`20`20`20`20`20`20`20`20else
X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20LST_OFS`20=`20NMB_FLS`20-`202*
VITEM_IN_PANEL;
X
X`09set_offset(found_file?stor_sel:NULL,offs);`09
X`09`09`09`09`09`09`09`09`09
X`09panel(WIN(RIGHT),LOC_LS(RIGHT),
X`09`09WIN(LEFT)`20,LOC_LS(LEFT)`20,
X`20`09`09NULL,_BUILD_NO_FRESH);
X`09draw_ttl();
X`09CURSOR_ON();
X`7D`09
X
X
Xvoid`20arrow(unsigned`20ch)
X`7B
X`09int`20local_sel,half;
X
X
X`09`20local_sel=LOC_SLK;
X`09`20half=PART;
X
X
X`09switch(ch)`20`7B
X`09`09`09
X`09`09`20case`20AR_UP:
X`09`09`20`09if`20(GLB_SLK==1)
X`09`09`09`09`09`7B
X`09`09`09`09`09`20ACT(_CHOICE);
X`09`09`20`20`09`09`09`20return;
X`09`09`09`09`09`7D
X`09`09`09else
X`09`09`09`20`20`20`7B
X`09`09`09`20`20`20
X`09`09`09`09`20`20`20`20`20`20
X`09`09`09`20`20`20`20if`20(local_sel!=1`20`7C`7C`20(local_sel==1`20`26`26`20ha
Vlf==LEFT))
X`09`09`09`09`7B
X`09`09`09`09`20ACT(_UNCHOICE);
X
X`09`09`09`09`20GLB_SLK--;
X`09`09`09`09
X`09`09`09`09`20ACT(_CHOICE);
X`09`09`09`09`7D
X
X`09`09`09`20`20`20`20else`20
X`09`09`09`09`20`7B
X`09`09`09`09`20`20LST_OFS--;
X`09`09`09`09`20`20GLB_SLK--;`09`09`09
X`09`09`09`09`20`20panel(WIN(RIGHT),LOC_LS(RIGHT),
X`09`09`09`09`09`20WIN(LEFT)`20,LOC_LS(LEFT)`20,
X`20`09`09`09`09`09`20NULL,_BUILD);
X`09`09`09`09`20`20ACT(_CHOICE);`09
X`09`09`09`20`20`20`20`20`20`20`20`20`7D
X`09`09`09`20`20`20`20`7D
X`09`09`09`20`20`20return;
X`09`09`20`20case`20AR_DOWN:`09
X`09`09`09`20`20`20`20if`20(GLB_SLK==NMB_FLS)
X`09`09`09`09`09`7B
X`09`09`09`09`09ACT(_CHOICE);
X`09`09`20`20`09`09`09return;
X`09`09`09`09`09`7D
X`09`09`09else
X`09`09`09`20`20`20`7B
X`09`09`09`09`09`20`20`20`20`20`20
X`09`09`09`20`20`20`20if`20(local_sel!=ITEM_IN_PANEL`20`7C`7C
X`09`09`09`09`20(local_sel==ITEM_IN_PANEL`20`26`26`20half==RIGHT))
X`09`09`09`09`7B
X`09`09`09`09`20ACT(_UNCHOICE);
X
X`09`09`09`09`20GLB_SLK++;
X`09`09`09`09
X`09`09`09`09`20ACT(_CHOICE);
X`09`09`09`09`20`7D
X
X`09`09`09`20`20`20`20else`20
X`09`09`09`09`20`7B
X`09`09`09`09`20`20LST_OFS++;
X`09`09`09`09`20`20GLB_SLK++;`09`09`09`09`09`09`09`09`09`09`09
X`09`09`09`09`20`20panel(WIN(RIGHT),LOC_LS(RIGHT),
X`09`09`09`09`09`20WIN(LEFT)`20,LOC_LS(LEFT)`20,
X`20`09`09`09`09`09`20NULL,_BUILD);
X`09`09`09`09`20`20ACT(_CHOICE);`09
X`09`09`09`20`20`20`20`20`20`20`20`20`7D
X`09`09`09`20`20`20`20`7D
X`09`09`09`20`20`20return;
X`09`09`20`20`20`20case`20AR_RIGHT:`09
X`09`09`09`09`20if(half==LEFT)
X`09`09`09`09`09`7B
X`09`09`09`09`09
X`09`09`09`09`09`09return;
X`09`09`09`09`09`7D
X
X`09`09`09`09`20ACT(_UNCHOICE);
X`09`09`09`09`20GLB_SLK+=ITEM_IN_PANEL;
X`09`09`09`09`20GLB_SLK=(GLB_SLK>NMB_FLS)?NMB_FLS:GLB_SLK;
X`09`09`09`09`20ACT(_CHOICE);
X`09`09`09`09`20return;
X`09`09`20`20`20`20case`20AR_LEFT:
X`09`09`09`09`20if(half==RIGHT)
X`09`09`09`09`09`7B
X`09`09`09`09`09
X`09`09`09`09`09`09return;
X`09`09`09`09`09`7D`20
X`09`09`09`09`20ACT(_UNCHOICE);
X`09`09`09`09`20GLB_SLK-=ITEM_IN_PANEL;
X`09`09`09`09`20GLB_SLK=(GLB_SLK<1)?1:GLB_SLK;
X`09`09`09`09`20ACT(_CHOICE);
X`09`09`09`09`20return;
X`09`09`20`20case`20NEXT:
X`09`09`09`09`7B
X`09`09`09`09`20`20register`20int`20frame;
X`09`09`09`09`20`20`20`20`20if((frame=GLB_SLK-1-LST_OFS)<
X`09`09`09`09`09`09`092*ITEM_IN_PANEL-1)
X`09`09`09`09`09`7B
X`09`09`09`09`09`09ACT(_UNCHOICE);
X`09`09`09`09`09`09GLB_SLK=GLB_SLK-1+
X`09`09`09`09`09`09`20`20`20`202*ITEM_IN_PANEL-frame;
X
X`09`09`09`09`09`20`20`20`20if(GLB_SLK>NMB_FLS)
X`09`09`09`09`09`09`20`20GLB_SLK=NMB_FLS;`09
X`09`09`09`09`09`09
X`09`09`09`09`09`09ACT(_CHOICE);
X`09`09`09`09`09`09return;
X`09`09`09`09`09`7D`09
X`09`09`09`09`09frame=LST_OFS+2*ITEM_IN_PANEL;
X`09`09`09`09`20`20`20`20`20if(frame+1>NMB_FLS)
X`09`09`09`09`09`7B
X`09`09`09`09`09`20`20`20`20`20
X`09`09`09`09`09`20`20`20`20`20ACT(_UNCHOICE);
X`09`09`09`09`09`20`20`20`20`20GLB_SLK=NMB_FLS;
X`09`09`09`09`09`20`20`20`20`20ACT(_CHOICE);
X`09`09`09`09`09`7D
X`09`09`09`09`20`20`20`20`20`20else
X`09`09`09`09`09`7B
X`09`09`09`09`09`20`20LST_OFS=frame;
X`09`09`09`09`09`20`20GLB_SLK=frame+ITEM_IN_PANEL*2;
X
X`09`09`09`09`09`20`20`20`20if(GLB_SLK>NMB_FLS)
X`09`09`09`09`09`09`20`20GLB_SLK=NMB_FLS;`09
X`09`09`20`09`09`09`09`09
X`09`09`09`09`09`20`20panel(WIN(RIGHT),LOC_LS(RIGHT),
X`09`09`09`09`09`20`20WIN(LEFT)`20,LOC_LS(LEFT)`20,
X`20`09`09`09`09`09`20`20NULL,_BUILD);
X
X`09`09`09`09`20`20`20`20`20`20`20`20`20`20ACT(_CHOICE);
X`09`09`09`09`09`7D
X`09`09`09`09`09return;
X`09`09`09`09`7D`09
X`09`09`20case`20PREV:
X`09`09`09`09`7B
X`09`09`09`09`20`20register`20int`20frame;
X`09`09`09`09`20`20`20`20`20if((frame=GLB_SLK-1-LST_OFS)!=
X`09`09`09`09`09`09`090)
X`09`09`09`09`09`7B
X`09`09`09`09`09`09ACT(_UNCHOICE);
X
X`09`09`09`09`09`09GLB_SLK=GLB_SLK-frame;
X`09`09`09`09`09`09
X`09`09`09`09`09`09ACT(_CHOICE);
X`09`09`09`09`09`09return;
X`09`09`09`09`09`7D`09
X`09
X
X`09`09`09`09`09frame=LST_OFS-2*ITEM_IN_PANEL;
X`09`09`09`09`20`20`20`20`20if(frame+1<1)
X`09`09`09`09`09`7B
X`09`09`09`09`09`20`20`20`20`20ACT(_UNCHOICE);
X`09`09`09`09`09`20`20`20`20`20LST_OFS=0;`09
X`09`09`09`09`09`20`20`20`20`20GLB_SLK=1;
X`09`09`09`09`09`20`20`20`20`20panel(WIN(RIGHT),LOC_LS(RIGHT),
X`09`09`09`09`09`20`20`20`20`20WIN(LEFT)`20,LOC_LS(LEFT)`20,
X`20`09`09`09`09`09`20`20`20`20`20NULL,_BUILD);
X`09`09`09`09`09`20`20`20`20`20ACT(_CHOICE);
X`09`09`09`09`09`7D
X`09`09`09`09`20`20`20`20`20`20else
X`09`09`09`09`09`7B
X`09`09`09`09`09`20`20LST_OFS=frame;
X`09`09`09`09`09`20`20GLB_SLK=frame+1;`09`09`20`09`09`09`09`09
X`09`09`09`09`09`20`20panel(WIN(RIGHT),LOC_LS(RIGHT),
X`09`09`09`09`09`20`20WIN(LEFT)`20,LOC_LS(LEFT)`20,
X`20`09`09`09`09`09`20`20NULL,_BUILD);
X`09`09`09`09`20`20`20`20`20`20`20`20`20`20ACT(_CHOICE);
X`09`09`09`09`09`7D
X`09`09`09`09`09return;
X`09`09`09`09`7D`09
X`09`09`09`20`20`20`20`20`20`20`20`09`09`09`09`09`09
X`09`09`7D
X`7D
X
X
X
X`09`09`09`09`20`20
X`09`09`20`09`09`09
X/*This`20function`20must`20prepear`20file`20name`20for`20display`20*/`20`09`20
V`20`20/*2*/
X
Xchar`20*indls(int`20number,char**list)
X`7B
X`20static`20char`20ret_str`5B256`5D,name`5B100`5D,type`5B100`5D,ver`5B10`5D;
X`09char`20*space="`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20";
X`20`20`20`20`20`20`20`20char`20*name_without_dir;
X`09int`20len;
X`09int`20f_len;
X`09int`20t_len;
X
X
X`09f_len=(is_ver)?11:13;
X`09t_len=(is_ver)?4:5;
X`09if`20(list+number>dirs`5Bcurrent_panel`5D+NMB_FLS-1)`20return`20space;
X`09
X`09name_without_dir=strchr(list`5Bnumber`5D,'`5D')+1;
X`09if`20(number)
X`20`20`20`20`20`20`20`20`20`20`20`20`20strcpy(ret_str,name_without_dir);
X`09else`20
X`09`20`20`20`20`20`09strcpy(ret_str,list`5Bnumber`5D);
X
X`20`20`20`20if(strcmp(ret_str,"-"))
X`09`7B
X`09`20`20parse(ret_str,NULL,NULL,NULL,name,type,ver);
X`09`09if`20(!(strstr(type,".DIR")`20`26`26`20strlen(type)==4))
X`09`09`09`7B
X`09`09`09`09strlwr(name);
X`09`09`09`09strlwr(type);
X`09`09`09`7D
X
X`09if`20((len=strlen(name))<=f_len)
X`09`09`09`09`7B
X`09`09`09`09`09strcat(name,space+(18-(f_len-len)));
X`09`09`09`09
X`09`09`09`09`7D
X
X`09else`09
X`20`20`20`20`20`20`20`20`20`20`20`20`20`09`09`09`7B
X`09`09`09`09`09
X`09`09`09`09`09`20`20`20name`5Bf_len-1`5D='*';
X`09`09`09`09`09`20`20`20name`5Bf_len`5D='`5C0';
X`09`09`09`09`7D
X
X
X
X`09if`20((len=strlen(type))<=t_len)
X`09`09`09`7B`09`09
X`09`09`09`09`09strcat(type,space+(18-(t_len-len)));
X`09`09`09`7D
X`09else`09`09`09`09
X`09`09`09`7B
X`09`09`09`20`20`20`20`20`20type`5Bt_len-1`5D='*';
X`09`09`09`20`20`20`20`20`20type`5Bt_len`5D='`5C0';
X`09`09`09`7D
X
X
X
X
X`09if`20((len=strlen(ver))<=3)
X`09`09`09`7B
X`09`09`09`09strcat(ver,space+(18-(3-len)));
X`09`09`09`7D
X`09else
X`09`09`09`7B
X`09`09`09`09ver`5B2`5D='*';
X`09`09`09`09ver`5B3`5D='`5C0';
X`09`09`09`7D
X
X
X`09`09`09
X`09`09`09`09`20`20strcpy(ret_str,name);
X`09`09`09`09`20`20strcat(ret_str,type);
X`09`09`09`09if(is_ver)
X`09`09`09`09`20`20strcat(ret_str,ver);`09
X`09`09`09`09`20`20return`20ret_str;`09
X`09`09`09`09
X`09`7D
X
X`20`20else`20return`20"-`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20";
V`09`09`09`09
X`09`09`09`09`09
X`7D
X
X
X
X
X
X`20/*This`20function`20display`20list`20of`20files`20on`20screen`20*/`09`20`20
V`20/*2*/
X
Xchar`20**build_list(WINDOW`20*`20menu,char`20**curr,int`20numitem)`20`20`20/*2
V*/
X`7B
X`09int`20ind;
X`09int`20blank=0;
X`09char`20folder`5B20`5D;
X
X`20`20`20`20`20wclrattr(menu,_REVERSE);
X`09
X`20`20`20`20`20for(ind=0;ind<numitem;ind++)
X`09`09`7B
X`09`09`09int`20pri;
X`09`09`09if(pri=is_sel(ind,curr))
X
X`09`09`09`09wsetattr(menu,_BOLD);`09`09`09
X`09`09`09mvwaddstr(menu,ind,0,indls(ind,curr));
X
X`09`09`09if(pri)
X`09`09`09`09wclrattr(menu,_BOLD);
X`09`09`7D
X`09return`20curr;
X`7D
X
X
X
Xvoid`20panel(WINDOW`20*dira,char`20**lista,WINDOW`20*dirb,
X`09`20`20`20`20`20char`20**listb,int`20sel,int`20command)
X`7B
X
X`09static`20int`20no_fresh,curs_on;
X`09
X`09switch(command)`20`7B
X
X`09`09`09`20`20case`20_BUILD:
X`09`09`09`09`20`20`20`20if`20(curs_on)`20`7Bcurs_on=0;CURSOR_OFF();`7D`09`20
X`09`09`09`09`20`20`20`20build_list(dira,lista,ITEM_IN_PANEL);
X`09`09`09`09`20`20`20`20build_list(dirb,listb,ITEM_IN_PANEL);
X`09`09`09`09`20`20`20`20wrefresh(dira);
X`09`09`09`09`20`20`20`20wrefresh(dirb);
X`09`09`09`09`20`20`20`20req_fresh=0;`09`20`20`09
X`09`09`09`09`20`20`20`20return;
X`09`09`09`20`20case`20_BUILD_NO_FRESH:
X`09`09`09`09`20`20`20`20if`20(curs_on)`20`7Bcurs_on=0;CURSOR_OFF();`7D`09`20
X`09`09`09`09`20`20`20`20build_list(dira,lista,ITEM_IN_PANEL);
X`09`09`09`09`20`20`20`20build_list(dirb,listb,ITEM_IN_PANEL);
X`09`09`09`09`20`20`20`20no_fresh=1;
X`09`09`09`09`20`20`20`20req_fresh=0;`09`09
X`09`09`09`09`20`20`20`20return;
X
X`09`09`09`20`20case`20_CHOICE:
X`09`09`09`09`20`20`20if`20(NMB_FLS==0)
X`09`09`09`09`09`7B
X`09`09`09`09`20`20`20`20`20`20if(no_fresh)
X`09`09`09`09`09`7B
X`09`09`09`09`09`20`20`20wrefresh(WIN(RIGHT));
X`09`09`09`09`09`20`20`20wrefresh(WIN(LEFT));
X`09`09`09`09`09`20`20`20no_fresh=0;
X`09`09`09`09`09`7D
X
X`09`09`09`09`09`09print_name();
X`09`09`09`09`09`09req_fresh=1;
X`09`09`09`09`09`09if`20(!curs_on)`20`7Bcurs_on=1;
X`09`09`09`09`09`09`09`20`20`20`20`20`20`20CURSOR_ON();
X`09`09`09`09`09`09`09`20`20`20`20`20`20`7D`09`09
X`09`09`09`09`09`09return;
X`09`09`09`09`09`7D
X`09`09`09`09`20`20`20if(is_sel(sel-1,lista))
X`09`09`09`09`09wsetattr(dira,_BOLD);`20`09`09`09`09`09`09
X`09`09`09`09`20`20`20wsetattr(dira,_REVERSE);
X`09`09`09`09`20`20`20MK_sel();
X`09`09`09`09`20`20`20wclrattr(dira,_REVERSE);
X`09`09`09`09`20`20`20wclrattr(dira,_BOLD);
X`09`09`09`09`20`20`20if(no_fresh)
X`09`09`09`09`09`7B
X`09`09`09`09`09`20`20`20wrefresh(WIN(RIGHT));
X`09`09`09`09`09`20`20`20wrefresh(WIN(LEFT));
X`09`09`09`09`09`20`20`20no_fresh=0;
X`09`09`09`09`09`7D
X`09`09`09`09`20`20`20else`20`20`09
X`09`09`09`09`20`20`20`09wrefresh(dira);
X`09`09`09`09`20`20`20print_name();
X`09`09`09`09`20`20`20if`20(!curs_on)`20`7Bcurs_on=1;CURSOR_ON();`7D
X`09`09`09`09`20`20`20req_fresh=1;`09`09`20`09
X`09`09`09`09`20`20`20return;
X
X`09`09`09`20`20case`20_UNCHOICE:
X`09`09`09`09`20`20`20if`20(curs_on)`20`7Bcurs_on=0;CURSOR_OFF();`7D`09
X`09`09`09`09`20`20`20if(is_sel(sel-1,lista))
X`09`09`09`09`09wsetattr(dira,_BOLD);`20`09`09`09`09`09`09
X`09`09`09`09`20`20`20wclrattr(dira,_REVERSE);
X`09`09`09`09`20`20`20MK_sel();
X`09`09`09`09`20`20`20wrefresh(dira);`09
X`09`09`09`09`20`20`20wclrattr(dira,_BOLD);
X`09`09`09`09`20`20`20req_fresh=0;
X`09`09`09`09`20`20`20return;
X
X`09`09`09`20`20case`20_SELK:
X`09`09`09`09`20`20`20if`20(curs_on)`20`7Bcurs_on=0;CURSOR_OFF();`7D`09
X`09`09`09`09`20`20`20if`20(NMB_FLS==0)`20return;`09
X`09`09`09`09`20`20`20if(!reg_sel(sel-1,lista))
X`09`09`09`09`09`09return;`09`09`09`09`09`09`09
X`09`09`09`09`20`20`20wsetattr(dira,_BOLD);
X`09`09`09`09`20`20`20wsetattr(dira,_REVERSE);`09
X`09`09`09`09`20`20`20MK_sel();
X`09`09`09`09`20`20`20wclrattr(dira,_BOLD);
X`09`09`09`09`20`20`20wclrattr(dira,_REVERSE);`09
X`09`09`09`09`20`20`20wrefresh(dira);
X`09`09`09`09`20`20`20req_fresh=0;
X`09`09`09`09`20`20`20return;
X
X`09`09`09`20`20case`20_UNSELK:
X`09`09`09`09`20`20`20if`20(curs_on)`20`7Bcurs_on=0;CURSOR_OFF();`7D`09
X`09`09`09`09`20`20`20del_sel(sel-1,lista);
X`09`09`09`09`20`20`20wsetattr(dira,_REVERSE);`09
X`09`09`09`09`20`20`20wclrattr(dira,_BOLD);
X`09`09`09`09`20`20`20MK_sel();
X`09`09`09`09`20`20`20wclrattr(dira,_REVERSE);`09
X`09`09`09`09`20`20`20wrefresh(dira);
X`09`09`09`09`20`20`20req_fresh=0;
X`09`09`09`09`20`20`20return;
X`09`20`09`20`09`7D
X`7D`09`09
X
$ call unpack NAVIGATE.C;1 103326396 "" 34 23 31
$!
$ create 'f'
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20PARSE-CMD.C*/
X/*`20*2`20`20`20`2015-APR-1994`2015:15:51`20ALEXEY`20"GCC`20port`20fixed."*/
X/*`20*1`20`20`20`2014-APR-1994`2015:17:53`20ALEXEY`20"Break`20line`20to`20inpu
Vt,output`20stream`20,`20..."*/
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20PARSE-CMD.C*/
X#include`20<stdio.h>
X#include`20<string.h>
X
X
X
X#define`20To_space`20while(comm`5Bcount`5D=='`20'`20`7C`7C`20comm`5Bcount`5D==
V'`5Ct')`20count++
X
X#define`20add_word(c,b)`20`7BTo_space;strcat(c,b);`20`5C
X`20while(comm`5Bcount`5D!='`20'`20`26`26`20comm`5Bcount`5D!='`5Ct'`20`5C
X`20`26`26`20comm`5Bcount`5D!='`5Cn'`20`20`26`26`20comm`5Bcount`5D!='`5C0'`20
V`5C
X`20`26`26`20comm`5Bcount`5D!='<'`20`20`20`26`26`20comm`5Bcount`5D!='>')`20`5C
V
X`20`7B*dubl=comm`5Bcount++`5D;strcat(c,dubl);`7D;To_space;`7D
X
X#define`20err_return`20`20`20`7Berr_string="CRS-E-CMDSYNERR`20,command`20line
V`20syntax`20error";`5C
X`20return`200;`7D`20`09`09`09
X
Xchar`20*err_string;
Xint`20parse_cmd(char`20*comm,char`20**`20run_file,
X`09`20`20`20`20`20`20char`20**tail,char`20**in_file,
X`09`20`20`20`20`20`20char`20**out_file,int`20*`20wflag)
X`7B
Xstatic`09char`20_tail`5B255`5D="",
X`09`20`20`20`20`20_in_file`5B100`5D="",
X`09`20`20`20`20`20_out_file`5B100`5D="",
X`09`20`20`20`20`20_run_file`5B100`5D="";
X`20`20`09char`20dubl`5B2`5D;
X`20`20`20`20`20`20`20`20int`20count,is_in,is_out,is_run;
X`09`20`20`20`20`20
X
X`09count=
X`09is_in=
X`09is_out=
X`09is_run=
X`09dubl`5B1`5D=
X`09_in_file`5B0`5D=
X`09_out_file`5B0`5D=
X`09_run_file`5B0`5D=
X`09_tail`5B0`5D=
X`090;
X
Xwhile(*comm=='`20'`20`7C`7C`20*comm=='`5Ct')`20comm++;
X`20
Xif`20(*comm=='`26')
X`20`20`7B
X`09*wflag=1;
X`09comm++;
X`09while(*comm=='`20'`20`7C`7C`20*comm=='`5Ct')`20comm++;
X`20`20`7D
Xelse
X`09*wflag=0;
X`09`20
X
Xwhile`20(comm`5Bcount`5D)`20`09
X`20`20switch(comm`5Bcount`5D)`20`7B
X`09
X`20`20`20`20`20case`20'*':
X`09`20`20if(!count)
X`09`09`7B
X`09`09`20`20count++;
X`09`09`20`20To_space;
X`09`09`20`20is_run++;`09
X`09`09`20`20add_word(_run_file,"")
X`09`09`20`20break;`09
X`09`20`20`20`20`20`20`20`20`7D
X`09`20`20else`20`20
X`09`09`7B
X
X`09`09`20if`20(is_out==1)`20
X`09`09`09`7Badd_word(_out_file,"");is_out++;`7D
X`09`09`20else`20if`20(is_in==1)
X`09`09`09`7Badd_word(_in_file,"");is_in++;`7D
X`09`09`20else
X`09`09`09add_word(_tail,"`20")
X`09`09`20break;
X`09`09`7D
X`20`20case`20'>':
X`09`09`7B
X`09`09`20is_out++;`20
X`09`09`20if`20(is_out>1)`20err_return;
X`09`09`20count++;
X`09`09`20To_space;
X`09`09`20break;
X`09`09`7D
X`20case`20'<':
X`09`09`7B
X`09`09`20is_in++;`20`20`20
X`09`09`20if`20(is_in>1)`20err_return;
X`09`09`20count++;
X`09`09`20To_space;
X`09`09`20break;
X`09`09`7D
X`20default:
X`09`09`7B
X
X`09`09`20if`20(is_out==1)`20
X`09`09`09`7Badd_word(_out_file,"");is_out++;`7D
X`09`09`20else`20if`20(is_in==1)
X`09`09`09`7Badd_word(_in_file,"");is_in++;`7D
X`09`09`20else
X`09`09`09add_word(_tail,"`20")
X`09`09`20break;
X`09`09`20`7D
X`20`20`20`20`20`20`7D
X`09`09
X*tail=_tail;
X
X*in_file=(is_in)?_in_file:NULL;
X
X*out_file=(is_out)?_out_file:NULL;
X`09`09`20`09`09
X*run_file=(is_run)?_run_file:NULL;
X
Xreturn`201;
X
X`7D`09
X
X`20
X`09`09
X
$ call unpack PARSE-CMD.C;1 123428316 "" 5 24 31
$!
$ create 'f'
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20QSORT.C*/
X/*`20*1`20`20`20`2014-APR-1994`2014:42:13`20ALEXEY`20"VAXC`20versions`20whith
V`20BUG`20."*/
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20QSORT.C*/
X/*-
X`20*`20Copyright`20(c)`201980,`201983,`201990`20The`20Regents`20of`20the`20Uni
Vversity`20of`20California.
X`20*`20All`20rights`20reserved.
X`20*
X`20*`20Redistribution`20and`20use`20in`20source`20and`20binary`20forms,`20with
V`20or`20without
X`20*`20modification,`20are`20permitted`20provided`20that`20the`20following`20c
Vonditions
X`20*`20are`20met:
X`20*`201.`20Redistributions`20of`20source`20code`20must`20retain`20the`20above
V`20copyright
X`20*`20`20`20`20notice,`20this`20list`20of`20conditions`20and`20the`20followin
Vg`20disclaimer.
X`20*`202.`20Redistributions`20in`20binary`20form`20must`20reproduce`20the`20ab
Vove`20copyright
X`20*`20`20`20`20notice,`20this`20list`20of`20conditions`20and`20the`20followin
Vg`20disclaimer`20in`20the
X`20*`20`20`20`20documentation`20and/or`20other`20materials`20provided`20with
V`20the`20distribution.
X`20*`203.`20All`20advertising`20materials`20mentioning`20features`20or`20use
V`20of`20this`20software
X`20*`20`20`20`20must`20display`20the`20following`20acknowledgement:
X`20*`09This`20product`20includes`20software`20developed`20by`20the`20Universit
Vy`20of
X`20*`09California,`20Berkeley`20and`20its`20contributors.
X`20*`204.`20Neither`20the`20name`20of`20the`20University`20nor`20the`20names
V`20of`20its`20contributors
X`20*`20`20`20`20may`20be`20used`20to`20endorse`20or`20promote`20products`20der
Vived`20from`20this`20software
X`20*`20`20`20`20without`20specific`20prior`20written`20permission.
X`20*
X`20*`20THIS`20SOFTWARE`20IS`20PROVIDED`20BY`20THE`20REGENTS`20AND`20CONTRIBUTO
VRS`20`60`60AS`20IS''`20AND
X`20*`20ANY`20EXPRESS`20OR`20IMPLIED`20WARRANTIES,`20INCLUDING,`20BUT`20NOT`20L
VIMITED`20TO,`20THE
X`20*`20IMPLIED`20WARRANTIES`20OF`20MERCHANTABILITY`20AND`20FITNESS`20FOR`20A
V`20PARTICULAR`20PURPOSE
X`20*`20ARE`20DISCLAIMED.`20`20IN`20NO`20EVENT`20SHALL`20THE`20REGENTS`20OR`20C
VONTRIBUTORS`20BE`20LIABLE
X`20*`20FOR`20ANY`20DIRECT,`20INDIRECT,`20INCIDENTAL,`20SPECIAL,`20EXEMPLARY,
V`20OR`20CONSEQUENTIAL
X`20*`20DAMAGES`20(INCLUDING,`20BUT`20NOT`20LIMITED`20TO,`20PROCUREMENT`20OF`20
VSUBSTITUTE`20GOODS
X`20*`20OR`20SERVICES;`20LOSS`20OF`20USE,`20DATA,`20OR`20PROFITS;`20OR`20BUSINE
VSS`20INTERRUPTION)
X`20*`20HOWEVER`20CAUSED`20AND`20ON`20ANY`20THEORY`20OF`20LIABILITY,`20WHETHER
V`20IN`20CONTRACT,`20STRICT
X`20*`20LIABILITY,`20OR`20TORT`20(INCLUDING`20NEGLIGENCE`20OR`20OTHERWISE)`20AR
VISING`20IN`20ANY`20WAY
X`20*`20OUT`20OF`20THE`20USE`20OF`20THIS`20SOFTWARE,`20EVEN`20IF`20ADVISED`20OF
V`20THE`20POSSIBILITY`20OF
X`20*`20SUCH`20DAMAGE.
X`20*/
X
X#if`20defined(LIBC_SCCS)`20`26`26`20!defined(lint)
Xstatic`20char`20sccsid`5B`5D`20=`20"@(#)qsort.c`095.9`20(Berkeley)`202/23/91";
V
X#endif`20/*`20LIBC_SCCS`20and`20not`20lint`20*/
X
X#include`20<stddef.h>
X/*
X`20*`20MTHRESH`20is`20the`20smallest`20partition`20for`20which`20we`20compare
V`20for`20a`20median
X`20*`20value`20instead`20of`20using`20the`20middle`20value.
X`20*/
X#define`09MTHRESH`096
X
X/*
X`20*`20THRESH`20is`20the`20minimum`20number`20of`20entries`20in`20a`20partitio
Vn`20for`20continued
X`20*`20partitioning.
X`20*/
X#define`09THRESH`094
X
X/*
X`20*`20Swap`20two`20areas`20of`20size`20number`20of`20bytes.`20`20Although`20q
Vsort(3)`20permits`20random
X`20*`20blocks`20of`20memory`20to`20be`20sorted,`20sorting`20pointers`20is`20al
Vmost`20certainly`20the
X`20*`20common`20case`20(and,`20were`20it`20not,`20could`20easily`20be`20made
V`20so).`20`20Regardless,`20it
X`20*`20isn't`20worth`20optimizing;`20the`20SWAP's`20get`20sped`20up`20by`20the
V`20cache,`20and`20pointer
X`20*`20arithmetic`20gets`20lost`20in`20the`20time`20required`20for`20compariso
Vn`20function`20calls.
X`20*/
X#define`09SWAP(a,`20b)`20`7B`20`5C
X`09cnt`20=`20size;`20`5C
X`09do`20`7B`20`5C
X`09`09ch`20=`20*a;`20`5C
X`09`09*a++`20=`20*b;`20`5C
X`09`09*b++`20=`20ch;`20`5C
X`09`7D`20while`20(--cnt);`20`5C
X`7D
X
X/*
X`20*`20Knuth,`20Vol.`203,`20page`20116,`20Algorithm`20Q,`20step`20b,`20argues
V`20that`20a`20single`20pass
X`20*`20of`20straight`20insertion`20sort`20after`20partitioning`20is`20complete
V`20is`20better`20than
X`20*`20sorting`20each`20small`20partition`20as`20it`20is`20created.`20`20This
V`20isn't`20correct`20in`20this
X`20*`20implementation`20because`20comparisons`20require`20at`20least`20one`20(
Vand`20often`20two)
X`20*`20function`20calls`20and`20are`20likely`20to`20be`20the`20dominating`20ex
Vpense`20of`20the`20sort.
X`20*`20Doing`20a`20final`20insertion`20sort`20does`20more`20comparisons`20than
V`20are`20necessary
X`20*`20because`20it`20compares`20the`20"edges"`20and`20medians`20of`20the`20pa
Vrtitions`20which`20are
X`20*`20known`20to`20be`20already`20sorted.
X`20*
X`20*`20This`20is`20also`20the`20reasoning`20behind`20selecting`20a`20small`20T
VHRESH`20value`20(see
X`20*`20Knuth,`20page`20122,`20equation`2026),`20since`20the`20quicksort`20algo
Vrithm`20does`20less
X`20*`20comparisons`20than`20the`20insertion`20sort.
X`20*/
X#define`09SORT(bot,`20n)`20`7B`20`5C
X`09if`20(n`20>`201)`20`5C
X`09`09if`20(n`20==`202)`20`7B`20`5C
X`09`09`09t1`20=`20bot`20+`20size;`20`5C
X`09`09`09if`20(compar(t1,`20bot)`20<`200)`20`5C
X`09`09`09`09SWAP(t1,`20bot);`20`5C
X`09`09`7D`20else`20`5C
X`09`09`09insertion_sort(bot,`20n,`20size,`20compar);`20`5C
X`7D
X
X
Xstatic`20void
Xinsertion_sort(bot,`20nmemb,`20size,`20compar)
X`09char`20*bot;
X`09register`20int`20size;
X`09int`20nmemb,`20(*compar)();
X`7B
X`09register`20int`20cnt;
X`09register`20unsigned`20ch;
X`09register`20char`20*s1,`20*s2,`20*t1,`20*t2,`20*top;
X
X`09/*
X`09`20*`20A`20simple`20insertion`20sort`20(see`20Knuth,`20Vol.`203,`20page`208
V1,`20Algorithm
X`09`20*`20S).`20`20Insertion`20sort`20has`20the`20same`20worst`20case`20as`20m
Vost`20simple`20sorts
X`09`20*`20(O`20N`5E2).`20`20It`20gets`20used`20here`20because`20it`20is`20(O
V`20N)`20in`20the`20case`20of
X`09`20*`20sorted`20data.
X`09`20*/
X`09top`20=`20bot`20+`20nmemb`20*`20size;
X`09for`20(t1`20=`20bot`20+`20size;`20t1`20<`20top;)`20`7B
X`09`09for`20(t2`20=`20t1;`20(t2`20-=`20size)`20>=`20bot`20`26`26`20compar(t1,
V`20t2)`20<`200;);
X`09`09if`20(t1`20!=`20(t2`20+=`20size))`20`7B
X`09`09`09/*`20Bubble`20bytes`20up`20through`20each`20element.`20*/
X`09`09`09for`20(cnt`20=`20size;`20cnt--;`20++t1)`20`7B
X`09`09`09`09ch`20=`20*t1;
X`09`09`09`09for`20(s1`20=`20s2`20=`20t1;`20(s2`20-=`20size)`20>=`20t2;`20s1`20
V=`20s2)
X`09`09`09`09`09*s1`20=`20*s2;
X`09`09`09`09*s1`20=`20ch;
X`09`09`09`7D
X`09`09`7D`20else
X`09`09`09t1`20+=`20size;
X`09`7D
X`7D
X
X
X
Xstatic`20void
Xquick_sort(bot,`20nmemb,`20size,`20compar)
X`09register`20char`20*bot;
X`09register`20int`20size;
X`09int`20nmemb,`20(*compar)();
X`7B
X`09register`20int`20cnt;
X`09register`20unsigned`20ch;
X`09register`20char`20*top,`20*mid,`20*t1,`20*t2;
X`09register`20int`20n1,`20n2;
X`09char`20*bsv;
X
X`09/*`20bot`20and`20nmemb`20must`20already`20be`20set.`20*/
Xpartition:
X
X`09/*`20find`20mid`20and`20top`20elements`20*/
X`09mid`20=`20bot`20+`20size`20*`20(nmemb`20>>`201);
X`09top`20=`20bot`20+`20(nmemb`20-`201)`20*`20size;
X
X`09/*
X`09`20*`20Find`20the`20median`20of`20the`20first,`20last`20and`20middle`20elem
Vent`20(see`20Knuth,
X`09`20*`20Vol.`203,`20page`20123,`20Eq.`2028).`20`20This`20test`20order`20gets
V`20the`20equalities
X`09`20*`20right.
X`09`20*/
X`09if`20(nmemb`20>=`20MTHRESH)`20`7B
X`09`09n1`20=`20compar(bot,`20mid);
X`09`09n2`20=`20compar(mid,`20top);
X`09`09if`20(n1`20<`200`20`26`26`20n2`20>`200)
X`09`09`09t1`20=`20compar(bot,`20top)`20<`200`20?`20top`20:`20bot;
X`09`09else`20if`20(n1`20>`200`20`26`26`20n2`20<`200)
X`09`09`09t1`20=`20compar(bot,`20top)`20>`200`20?`20top`20:`20bot;
X`09`09else
X`09`09`09t1`20=`20mid;
X
X`09`09/*`20if`20mid`20element`20not`20selected,`20swap`20selection`20there`20*
V/
X`09`09if`20(t1`20!=`20mid)`20`7B
X`09`09`09SWAP(t1,`20mid);
X`09`09`09mid`20-=`20size;
X`09`09`7D
X`09`7D
X
X`09/*`20Standard`20quicksort,`20Knuth,`20Vol.`203,`20page`20116,`20Algorithm
V`20Q.`20*/
X#define`09didswap`09n1
X#define`09newbot`09t1
X#define`09replace`09t2
X`09didswap`20=`200;
X`09for`20(bsv`20=`20bot;;)`20`7B
X`09`09for`20(;`20bot`20<`20mid`20`26`26`20compar(bot,`20mid)`20<=`200;`20bot
V`20+=`20size);
X`09`09while`20(top`20>`20mid)`20`7B
X`09`09`09if`20(compar(mid,`20top)`20<=`200)`20`7B
X`09`09`09`09top`20-=`20size;
X`09`09`09`09continue;
X`09`09`09`7D
X`09`09`09newbot`20=`20bot`20+`20size;`09/*`20value`20of`20bot`20after`20swap
V`20*/
X`09`09`09if`20(bot`20==`20mid)`09`09/*`20top`20<->`20mid,`20mid`20==`20top`20*
V/
X`09`09`09`09replace`20=`20mid`20=`20top;
X`09`09`09else`20`7B`09`09`09/*`20bot`20<->`20top`20*/
X`09`09`09`09replace`20=`20top;
X`09`09`09`09top`20-=`20size;
X`09`09`09`7D
X`09`09`09goto`20swap;
X`09`09`7D
X`09`09if`20(bot`20==`20mid)
X`09`09`09break;
X
X`09`09/*`20bot`20<->`20mid,`20mid`20==`20bot`20*/
X`09`09replace`20=`20mid;
X`09`09newbot`20=`20mid`20=`20bot;`09`09/*`20value`20of`20bot`20after`20swap`20
V*/
X`09`09top`20-=`20size;
X
Xswap:`09`09SWAP(bot,`20replace);
X`09`09bot`20=`20newbot;
X`09`09didswap`20=`201;
X`09`7D
X
X`09/*
X`09`20*`20Quicksort`20behaves`20badly`20in`20the`20presence`20of`20data`20whic
Vh`20is`20already
X`09`20*`20sorted`20(see`20Knuth,`20Vol.`203,`20page`20119)`20going`20from`20O
V`20N`20lg`20N`20to`20O`20N`5E2.
X`09`20*`20To`20avoid`20this`20worst`20case`20behavior,`20if`20a`20re-partition
Ving`20occurs
X`09`20*`20without`20swapping`20any`20elements,`20it`20is`20not`20further`20par
Vtitioned`20and
X`09`20*`20is`20insert`20sorted.`20`20This`20wins`20big`20with`20almost`20sorte
Vd`20data`20sets`20and
X`09`20*`20only`20loses`20if`20the`20data`20set`20is`20very`20strangely`20parti
Vtioned.`20`20A`20fix
X`09`20*`20for`20those`20data`20sets`20would`20be`20to`20return`20prematurely
V`20if`20the`20insertion
X`09`20*`20sort`20routine`20is`20forced`20to`20make`20an`20excessive`20number
V`20of`20swaps,`20and
X`09`20*`20continue`20the`20partitioning.
X`09`20*/
X`09if`20(!didswap)`20`7B
X`09`09insertion_sort(bsv,`20nmemb,`20size,`20compar);
X`09`09return;
X`09`7D
X
X`09/*
X`09`20*`20Re-partition`20or`20sort`20as`20necessary.`20`20Note`20that`20the`20
Vmid`20element
X`09`20*`20itself`20is`20correctly`20positioned`20and`20can`20be`20ignored.
X`09`20*/
X#define`09nlower`09n1
X#define`09nupper`09n2
X`09bot`20=`20bsv;
X`09nlower`20=`20(mid`20-`20bot)`20/`20size;`09/*`20size`20of`20lower`20partiti
Von`20*/
X`09mid`20+=`20size;
X`09nupper`20=`20nmemb`20-`20nlower`20-`201;`09/*`20size`20of`20upper`20partiti
Von`20*/
X
X`09/*
X`09`20*`20If`20must`20call`20recursively,`20do`20it`20on`20the`20smaller`20par
Vtition;`20this
X`09`20*`20bounds`20the`20stack`20to`20lg`20N`20entries.
X`09`20*/
X`09if`20(nlower`20>`20nupper)`20`7B
X`09`09if`20(nupper`20>=`20THRESH)
X`09`09`09quick_sort(mid,`20nupper,`20size,`20compar);
X`09`09else`20`7B
X`09`09`09SORT(mid,`20nupper);
X`09`09`09if`20(nlower`20<`20THRESH)`20`7B
X`09`09`09`09SORT(bot,`20nlower);
X`09`09`09`09return;
X`09`09`09`7D
X`09`09`7D
X`09`09nmemb`20=`20nlower;
X`09`7D`20else`20`7B
X`09`09if`20(nlower`20>=`20THRESH)
X`09`09`09quick_sort(bot,`20nlower,`20size,`20compar);
X`09`09else`20`7B
X`09`09`09SORT(bot,`20nlower);
X`09`09`09if`20(nupper`20<`20THRESH)`20`7B
X`09`09`09`09SORT(mid,`20nupper);
X`09`09`09`09return;
X`09`09`09`7D
X`09`09`7D
X`09`09bot`20=`20mid;
X`09`09nmemb`20=`20nupper;
X`09`7D
X`09goto`20partition;
X`09/*`20NOTREACHED`20*/
X`7D
X
Xvoid
Xbsd_qsort(bot,`20nmemb,`20size,`20compar)
X`09void`20*bot;
X`09size_t`20nmemb,`20size;
X`09int`20(*compar)`20(const`20void`20*,`20const`20void`20*);
X`7B
X
X
X`09if`20(nmemb`20<=`201)
X`09`09return;
X
X`09if`20(nmemb`20>=`20THRESH)
X`09`09quick_sort(bot,`20nmemb,`20size,`20compar);
X`09else
X`09`09insertion_sort(bot,`20nmemb,`20size,`20compar);
X`7D
X
$ call unpack QSORT.C;1 777846452 "" 17 25 31
$!
$ create 'f'
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20RENAME.C*/
X/*`20*2`20`20`20`2022-APR-1994`2020:56:01`20ALEXEY`20"New`20optimized`20rename
V`20version."*/
X/*`20*1`20`20`20`2014-APR-1994`2015:00:09`20ALEXEY`20"Small`20rename`20module.
V"*/
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20RENAME.C*/
X#include`20<errno.h>
X
Xextern`20void`20_mess(int`20*status);
Xextern`20int`20rename(char`20*,char*);
X
Xint`20crs_rename(char`20*s,char`20*d)
X`7B
X`09vaxc$errno=0;`09`09`09`09`09`20`20`20/*2*/
X`09rename(s,d);`20`09`09`09`09`09`20`20`20/*2*/
X`09return`20vaxc$errno;`09`09`09`09`20`20`20/*2*/
X`7D
X`09`09`09`20`20`20
$ call unpack RENAME.C;1 1578896601 "" 1 26 31
$!
$ create 'f'
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20TIMER.C*/
X/*`20*2`20`20`20`2015-APR-1994`2015:17:34`20ALEXEY`20"GCC`20port`20fixed."*/
X/*`20*1`20`20`20`2014-APR-1994`2014:26:15`20ALEXEY`20"Time`20displaying`20func
Vtions."*/
X/*`20VAX/DEC`20CMS`20REPLACEMENT`20HISTORY,`20Element`20TIMER.C*/
X#include`20<curses.h>
X#include`20<string.h>
X#include`20<time.h>
X#include`20<sys/signal.h>`09`09`09`09`09`20`20`20/*2*/
X#include`20"misc.h"`09`09`09`09`09`20`20`20/*2*/
X
XWINDOW`20*time_win;
X
Xint`20no_display=0;
Xint`20set_tm=0;
Xextern`20int`20io_now;
X`09`09`09`09`09`09`09`20`20`20/*2*/
Xvoid`20timer(int`20xxx)
X`7B
X`09`20time_t`20current;`09`09`09`09`20`20`20/*2*/
X`09`20register`20tm_t`20*dif_tm;`09`09`09`09`20`20`20/*2*/
X`09`20char`20out`5B8`5D;
X`09`20char`20temp`5B5`5D;
X`09
+-+-+-+-+-+-+-+- END OF PART 4 +-+-+-+-+-+-+-+-

Reply all
Reply to author
Forward
0 new messages