From: norm.grant@wmich.edu Sent: Thursday, November 21, 2002 3:31 PM To: Carlos Costa Cc: Everhart, Glenn (Card Services); dallen@nist.gov Subject: Re: CSWING ZIP Well, if it is wrong those two places, than it is almost certainly also wrong in SWING_21.C in the "search_for_the_file()" function, and in SWING_35.C in the "protect_a_dir" function, as they are all using the identical qio/fib/SS$_NOMOREFILES code. Here are the difs for all three cases. ************ File DISK$UCS:[GRANT.CSWING]swing_17.c;11 517 filename[0] = 0; 518 file_length = 0; 519 520 while(1) 521 { 522 strcpy(spec_str, spec); ****** File DISK$UCS:[GRANT.CSWING]swing_17.c;10 517 while(1) 518 { 519 filename[0] = 0; 520 file_length = 0; 521 strcpy(spec_str, spec); ************ Number of difference sections found: 1 Number of difference records found: 5 DIFFERENCES /IGNORE=()/MERGED=1/OUTPUT=DISK$UCS:[GRANT.CSWING]swing_17.DIF;2- DISK$UCS:[GRANT.CSWING]swing_17.c;11- DISK$UCS:[GRANT.CSWING]swing_17.c;10 ************ File DISK$UCS:[GRANT.CSWING]swing_21.c;11 274 filename[0] = 0; 275 file_length = 0; 276 277 while(1) 278 { 279 status = sys$qiow(0, ****** File DISK$UCS:[GRANT.CSWING]swing_21.c;10 274 while(1) 275 { 276 filename[0] = 0; 277 file_length = 0; 278 status = sys$qiow(0, ************ Number of difference sections found: 1 Number of difference records found: 5 DIFFERENCES /IGNORE=()/MERGED=1/OUTPUT=DISK$UCS:[GRANT.CSWING]swing_21.DIF;1- DISK$UCS:[GRANT.CSWING]swing_21.c;11- DISK$UCS:[GRANT.CSWING]swing_21.c;10 ************ File DISK$UCS:[GRANT.CSWING]swing_35.c;8 193 filename[0] = 0; 194 file_length = 0; 195 196 while(1) 197 { 198 status = sys$qiow(0, ****** File DISK$UCS:[GRANT.CSWING]swing_35.c;7 193 while(1) 194 { 195 filename[0] = 0; 196 file_length = 0; 197 status = sys$qiow(0, ************ Number of difference sections found: 1 Number of difference records found: 5 DIFFERENCES /IGNORE=()/MERGED=1/OUTPUT=DISK$UCS:[GRANT.CSWING]swing_35.DIF;1- DISK$UCS:[GRANT.CSWING]swing_35.c;8- DISK$UCS:[GRANT.CSWING]swing_35.c;7 > Hi. Found another instance of CSWING looping while looking for files. The > code in SWING_17.C has the same logic (and bug) that the SWING.C code had. > In the "delete_many_more_files( )" function, the lines: > filename[0] = 0; > file_length = 0; > need to be moved outside the "while(1)" loop. Otherwise when a PURGE is done > CSWING just loops forever. > I've attached my fixed version for your enjoyment. > car!os > /* > ** delete or purge files in a directory > ** specified by fid and channel > */ > static ULONG delete_many_more_files(USHORT *fid, USHORT channel, int > sub_dirs, > int option, char *spec, char *text) > { > ... > ... > /* > ** pull out all the files in the directory, checking to see if the > ** files themselves are directories > */ > filename[0] = 0; > file_length = 0; > while(1) > { > strcpy(spec_str, spec); > uchar = 0; > /* iosb.status = 0; ### obsolete code - for bad type */ > status = sys$qiow(0, > channel, > IO$_ACCESS, > &iosb, > 0, > 0, > &fib_desc, > DSC1(spec_str), > &file_length, > DSCA1(filename), > acb1, > 0); > if((status & 1) != 1) > panic(status, > "io$_access directory lookup", > "delete many more files"); > if(iosb.status == SS$_NOMOREFILES) > { > return(TRUE); > } > ----------------------------------------------------------------------- > NOTE: This e-mail, including any attachments, may contain privileged and > confidential material and its transmission is not a waiver of that > privilege. It is intended for the sole use of the person to whom it is > addressed. Any copying, disclosure, distribution or reliance on this > material by anyone other than the intended recipient is strictly prohibited. > We assume no responsibility to persons other than the intended recipient. If > you have received this transmission in error, please notify the sender > immediately by reply e-mail and destroy any hard copies you may have printed > and remove all electronic copies from your hard drive, network or any other > location where electronic information is stored. Thank you. > ----------------------------------------------------------------------- Content-type: application/octet-stream; name=swing_17.c Content-transfer-encoding: QUOTED-PRINTABLE Content-disposition: attachment; filename=swing_17.c /********************************************************************= **********=0D=0A*****************************************************= **************************=0D=0A** = **=0D=0A** C Swing - A g= raphical file and directory maintenance utility **=0D=0A** = = **=0D=0A**********************************************************= *********************=0D=0A** = **=0D=0A** Original C coding = by: S. J. Brown **=0D=0A** = **= =0D=0A** Modifications by many others; see the documentation for= a list **=0D=0A** = **=0D=0A** Copyright 1994, Harry F= lowers and Foteos Macrides **=0D=0A** = **=0D= =0A** Terms of Copyright: This software may be freely distribut= ed **=0D=0A** and used by anyone, providing the dist= ributor provides it **=0D=0A** free of charge or at a= price which only covers distribution **=0D=0A** costs.= It may not be sold. Note that versions prior to **=0D=0A**= V3.7.4 were public domain, and are not subject to these ter= ms. **=0D=0A** = **=0D=0A** Disclaimer: No warranties as to= the use or reliability of this **=0D=0A** software ar= e given by the authors or distributors. Use at **=0D=0A** = your own risk. = **=0D=0A** = **=0D=0A********************************************= ***********************************=0D=0A****************************= **************************************************/=0D=0A=0D=0A/*= =0D=0A** swing_17.c=0D=0A*/=0D=0A#include =0D=0A#include =0D=0A#include =0D=0A#include =0D=0A#inclu= de =0D=0A#include =0D=0A#include =0D=0A#inc= lude =0D=0A#include =0D=0A#include =0D=0A#include =0D=0A#include =0D=0A#include =0D=0A#include =0D=0A#include = =0D=0A#include "more_descrip.h"=0D=0A#include "swing.h"=0D=0A#include= "swing_refs.h"=0D=0A=0D=0A#define EXAMINED_WEDGE=09=09=0950=0D=0A#de= fine DELETE_SCREEN_EXTRA_ROWS=094=0D=0A#define DELETE_SCREEN_EXTRA_CO= LS=098=0D=0A#define DELETE_SCREEN_EXTRA_X=09=094=0D=0A#define DELETE_= SCREEN_EXTRA_Y=09=092=0D=0A=0D=0Astatic char delete_device[SPEC_SIZE+= 1];=0D=0Astatic USHORT return_length;=0D=0Astatic int errcnt, freebk,= maxbk;=0D=0Astatic char volnam[100];=0D=0Astatic int delete_screen, = display_delete_blank;=0D=0A=0D=0AITM_LST itmlst[5] =3D {=0D=0A=09{4,= =09DVI$_ERRCNT, =09=09&errcnt,=09&return_length},=0D=0A=09{4,=09DVI$_= FREEBLOCKS,=09&freebk,=09&return_length},=0D=0A=09{4,=09DVI$_MAXBLOCK= ,=09=09&maxbk,=09=09&return_length},=0D=0A=09{12,=09DVI$_VOLNAM,=09= =09&volnam[0], &return_length},=0D=0A=09{0,=090,=09=09=090,=09= =090}=0D=0A};=0D=0A=0D=0A=0D=0A/*=0D=0A** acb elements=0D=0A*/=0D= =0Aunsigned long uchar;=0D=0A=0D=0A/*=0D=0A** acb descriptor for io$= _access=0D=0A*/=0D=0AACB acb1[] =3D {=0D=0A /*=0D= =0A ** file characteristics (directory ??)=0D=0A = */=0D=0A ATR$S_UCHAR, ATR$C_UCHAR, &uc= har,=0D=0A=0D=0A /*=0D=0A ** terminate t= he list=0D=0A */=0D=0A 0, 0= , 0};=0D=0A=0D=0A=0D=0A/*=0D=0A** a blank fib used for= initialising other fibs=0D=0A*/=0D=0Astruct fibdef blank_fib;=0D= =0A=0D=0Astatic ULONG delete_many_more_files(USHORT *fid, USHORT chan= nel, int sub_dirs,=0D=0A int optio= n, char *spec, char *text);=0D=0Astatic int delete_screen_init(void= );=0D=0Astatic void label_delete_screen(char *text);=0D=0A=0D=0A= =0C=0D=0A/*=0D=0A** initialise the SMG side of the delete operation= =0D=0A*/=0D=0Astatic int delete_screen_init(void)=0D=0A{=0D=0A /*= =0D=0A ** initialize the delete screen display if it's not alread= y been=0D=0A ** initialized=0D=0A */=0D=0A int status, rows= , cols;=0D=0A=0D=0A if (delete_screen_initialized)=0D=0A re= turn(TRUE);=0D=0A=0D=0A delete_screen_initialized =3D TRUE;=0D= =0A=0D=0A status =3D smg$create_virtual_display(&DELETE_SCREEN_ROW= S,=0D=0A &DELETE_SCREEN_COLUMN= S,=0D=0A &display_delete,=0D= =0A &SMG$M_BORDER);=0D=0A i= f((status & 1) !=3D 1)=0D=0A panic(status,"create virtual disp= lay","delete_screen_init");=0D=0A=0D=0A rows =3D DELETE_SCREEN_ROW= S + DELETE_SCREEN_EXTRA_ROWS;=0D=0A cols =3D DELETE_SCREEN_COLUMNS= + DELETE_SCREEN_EXTRA_COLS;=0D=0A=0D=0A status =3D smg$create_vir= tual_display(&rows,=0D=0A &col= s,=0D=0A &display_delete_blank= );=0D=0A if((status & 1) !=3D 1)=0D=0A panic(status,"create= virtual blank display","delete_screen_init");=0D=0A}=0D=0A=0C=0D= =0A/*=0D=0A** slam out the delete screen=0D=0A*/=0D=0Avoid delete_sc= reen_on(char *text)=0D=0A{=0D=0A int status,x,y;=0D=0A=0D=0A /*= =0D=0A ** display (init if nec) the delete screen=0D=0A */= =0D=0A delete_screen_init();=0D=0A=0D=0A /*=0D=0A ** get cu= rrent device - we'll use this later=0D=0A */=0D=0A translate("S= YS$DISK",delete_device);=0D=0A=0D=0A smg$set_cursor_mode(&paste,&1= );=0D=0A=0D=0A label_delete_screen(text);=0D=0A=0D=0A status = =3D smg$erase_display(&display_delete);=0D=0A if((status & 1) != =3D 1)=0D=0A panic(status,"erase display","delete_screen_on");= =0D=0A=0D=0A /*=0D=0A ** reset vars=0D=0A */=0D=0A delet= ed_ok =3D 0;=0D=0A not_deleted_ok =3D 0;=0D=0A total_examined = =3D 0;=0D=0A originally_ok =3D -1;=0D=0A=0D=0A smg$begin_pasteb= oard_update(&paste);=0D=0A=0D=0A delete_screen_status("* STARTING = UP *",=0D=0A deleted_ok,=0D=0A = not_deleted_ok,=0D=0A total_examine= d,=0D=0A TRUE,=0D=0A=09=09=09 text);=0D=0A= =0D=0A x =3D DELETE_SCREEN_X - DELETE_SCREEN_EXTRA_X;=0D=0A y = =3D DELETE_SCREEN_Y - DELETE_SCREEN_EXTRA_Y;=0D=0A=0D=0A smg$paste= _virtual_display(&display_delete_blank,=0D=0A = &paste,=0D=0A &y,=0D=0A = &x);=0D=0A=0D=0A smg$paste_virtual_display(&dis= play_delete,=0D=0A &paste,=0D=0A = &DELETE_SCREEN_Y,=0D=0A = &DELETE_SCREEN_X);=0D=0A=0D=0A smg$end_pasteboard_update(&pa= ste);=0D=0A}=0D=0A=0C=0D=0A/*=0D=0A** label the screen=0D=0A*/=0D= =0Astatic void label_delete_screen(char *text)=0D=0A{=0D=0A int st= atus;=0D=0A unsigned long used, perm, over;=0D=0A char label[10= 0];=0D=0A=0D=0A strcpy(label,text);=0D=0A=0D=0A status =3D get_= user_quota("SYS$DISK",=0D=0A &used,=0D= =0A &perm,=0D=0A = &over);=0D=0A if((status & 1) =3D=3D 1)=0D=0A sprintf(&la= bel[strlen(label)]," QUOTA %d USED %d ",perm,used);=0D=0A=0D=0A = status =3D smg$label_border(&display_delete,=0D=0A = DSC1(label),=0D=0A &SMG$K_TO= P,=0D=0A 0,=0D=0A = &(SMG$M_REVERSE));=0D=0A if((status & 1) !=3D 1)=0D=0A = panic(status,"label border display_delete","label_delete_screen");= =0D=0A}=0D=0A=0C=0D=0A/*=0D=0A** away with the delete screen and res= tore the display=0D=0A*/=0D=0Avoid delete_screen_off(void)=0D=0A{= =0D=0A /*=0D=0A ** remove the delete screen=0D=0A */=0D= =0A int status;=0D=0A=0D=0A smg$begin_pasteboard_update(&paste)= ;=0D=0A=0D=0A smg$unpaste_virtual_display(&display_delete,=0D=0A = &paste);=0D=0A=0D=0A smg$unpaste_vir= tual_display(&display_delete_blank,=0D=0A = &paste);=0D=0A=0D=0A smg$end_pasteboard_update(&paste);=0D= =0A=0D=0A smg$set_cursor_mode(&paste,&0);=0D=0A}=0D=0A=0C=0D=0A/*= =0D=0A** update the status of files deleted, not deleted etc.=0D= =0A*/=0D=0Avoid delete_screen_status(char *filename, int ok, int not_= ok, int tot,=0D=0A int opt, = char *text)=0D=0A{=0D=0A /*=0D=0A ** update the delete screen = display=0D=0A */=0D=0A int i,status,row,col;=0D=0A float siz= e,left,used,percent;=0D=0A char file[SPEC_SIZE+1];=0D=0A=0D=0A = label_delete_screen(text);=0D=0A=0D=0A /*=0D=0A ** only update= filename if opt =3D=3D TRUE=0D=0A */=0D=0A if (opt)=0D=0A {= =0D=0A /*=0D=0A ** strip out the dir part of file name= - preset file to filename=0D=0A ** in case no dir part suppl= ied=0D=0A */=0D=0A strcpy(file,filename);=0D=0A=0D=0A = for (i =3D strlen(filename); i > 0; i--)=0D=0A if (f= ilename[i] =3D=3D ']')=0D=0A {=0D=0A strcpy= (file,&filename[i+1]);=0D=0A break;=0D=0A }= =0D=0A=0D=0A smg$set_cursor_abs(&display_delete,&DELETE_FILE_Y= ,&DELETE_FILE_X);=0D=0A smg$put_chars(&display_delete,DSC1("FI= LE "));=0D=0A sprintf(junk," %s ",file);=0D=0A smg$put_= chars(&display_delete,DSC1(junk),0,0,0,0);=0D=0A smg$erase_lin= e(&display_delete);=0D=0A=0D=0A /*=0D=0A ** now let's = make a summary of our device if we've deleted anything=0D=0A *= * or this is the first call=0D=0A */=0D=0A if (ok != =3D originally_ok)=0D=0A {=0D=0A originally_ok = =3D ok;=0D=0A=0D=0A status =3D sys$getdviw(0,=09=09=09= =09/* efn */=0D=0A =09 =09 =09 0,=09=09=09=09/* chan *= /=0D=0A =09 =09=09 DSC1(delete_device),=09=09/* devnam */= =0D=0A =09 =09=09 &itmlst,=09=09=09/* itmlst */=0D=0A = =09=09=09 0,=0D=0A =09=09=09 0,=0D=0A =09=09=09 0,= =0D=0A =09=09=09 0);=0D=0A if((status & 1) =3D=3D 1= )=0D=0A {=0D=0A =09size =3D (float)maxbk;=0D= =0A size =3D size / 2048;=0D=0A=0D=0A l= eft =3D (float)freebk;=0D=0A left =3D left / 2048;= =0D=0A=0D=0A used =3D size - left;=0D=0A = if (size > 0.0)=0D=0A percent =3D (left * 100)/s= ize;=0D=0A else=0D=0A percent =3D 0= .0;=0D=0A=0D=0A smg$set_cursor_abs(&display_delete,&DE= LETE_STAT_Y,&DELETE_STAT_X);=0D=0A sprintf(junk,"Curre= nt Device: %s %s",delete_device,volnam);=0D=0A smg$put= _line(&display_delete,DSC1(junk));=0D=0A=0D=0A /*=0D= =0A=09=09** show current usage=0D=0A */=0D=0A = smg$set_cursor_abs(&display_delete,&DELETE_STAT1_Y,&DELETE_ST= AT1_X);=0D=0A sprintf(junk,=0D=0A = "Size: %4.2fmb Used: %4.2fmb Free: %4.2fmb (%3.2f%c)",=0D=0A = size,=0D=0A used,=0D=0A = left,=0D=0A percent,=0D= =0A '%c');=0D=0A smg$put_line(&= display_delete,DSC1(junk));=0D=0A }=0D=0A }=0D=0A = }=0D=0A=0D=0A smg$set_cursor_abs(&display_delete,&DELETE_STATUS_= Y,&DELETE_STATUS_X);=0D=0A sprintf(junk,"Total files examined %d",= tot);=0D=0A smg$put_line(&display_delete,DSC1(junk));=0D=0A=0D= =0A if (ok || not_ok)=0D=0A {=0D=0A smg$set_cursor_abs(&= display_delete,&DELETE_STATUS1_Y,&DELETE_STATUS1_X);=0D=0A if = (deleted_option =3D=3D PURGE)=0D=0A sprintf(junk,"Purged s= uccessfully %d",ok);=0D=0A else=0D=0A sprintf(junk,= "Deleted successfully %d",ok);=0D=0A smg$put_line(&display_del= ete,DSC1(junk));=0D=0A }=0D=0A=0D=0A if (not_ok)=0D=0A {= =0D=0A smg$set_cursor_abs(&display_delete,&DELETE_STATUS2_Y,&D= ELETE_STATUS2_X);=0D=0A if (deleted_option =3D=3D PURGE)=0D= =0A sprintf(junk,"Failed to purge %d files",not_ok);=0D= =0A else=0D=0A sprintf(junk,"Failed to delete %d fi= les",not_ok);=0D=0A smg$put_line(&display_delete,DSC1(junk));= =0D=0A }=0D=0A smg$set_cursor_abs(&display_delete,&DELETE_SCREE= N_ROWS,&DELETE_SCREEN_COLUMNS);=0D=0A}=0D=0A=0C=0D=0A/*=0D=0A** outp= ut a message to the status line of the delete screen=0D=0A*/=0D=0Avoi= d delete_screen_message(char *text)=0D=0A{=0D=0A smg$set_cursor_ab= s(&display_delete,&DELETE_MSG_Y,&DELETE_MSG_X);=0D=0A smg$put_line= (&display_delete,DSC1(text),0,0);=0D=0A}=0D=0A=0C=0D=0A/*=0D=0A** de= lete files in dir n (NODE structure)=0D=0A**=0D=0A** if sub_dirs the= n go down the dirs=0D=0A** option =3D=3D DELETE then we delete all f= iles, otherwise=0D=0A** option =3D=3D PURGE, and we just purge the d= irectories=0D=0A*/=0D=0Aint delete_many_files(NODE *n, int sub_dirs, = int option, char *spec)=0D=0A{=0D=0A char text [256];=0D=0A ULO= NG status;=0D=0A USHORT channel;=0D=0A=0D=0A=0D=0A /*=0D=0A = ** make sure this is a kosher directory=0D=0A */=0D=0A if (!s= et_default(n->dir_name))=0D=0A return(FALSE);=0D=0A=0D=0A /= *=0D=0A ** assign a channel to the current device=0D=0A */= =0D=0A channel =3D 0;=0D=0A status =3D sys$assign(DSC1("SYS$DIS= K"),=0D=0A &channel,=0D=0A = 0,=0D=0A 0);=0D=0A if((status & 1) != =3D 1)=0D=0A panic(status,"sys$asign","delete_many_files");= =0D=0A=0D=0A /*=0D=0A ** display delete screen with the desire= d title=0D=0A */=0D=0A if (option =3D=3D PURGE)=0D=0A {=0D= =0A if (sub_dirs)=0D=0A sprintf(text," PURGING [...= ]*.*;* ");=0D=0A else=0D=0A sprintf(text," PURGING = %s ",spec);=0D=0A }=0D=0A else=0D=0A {=0D=0A if (sub_= dirs)=0D=0A strcpy(text," DELETING [...]*.*;* ");=0D=0A = else=0D=0A strcpy(text," DELETING ");=0D=0A }=0D= =0A=0D=0A deleted_option =3D option;=0D=0A=0D=0A delete_screen_= on(text);=0D=0A=0D=0A /*=0D=0A ** now do the deleting or purgi= ng, as selected=0D=0A */=0D=0A delete_many_more_files(n->fid,= =0D=0A channel,=0D=0A = sub_dirs,=0D=0A option,=0D=0A = spec,=0D=0A text);=0D= =0A=0D=0A /*=0D=0A ** if we're deleteing, then we delete the s= tarting directory as well=0D=0A */=0D=0A if (option =3D=3D DELE= TE)=0D=0A {=0D=0A status =3D delete_a_file_by_fid(n->fid,= =0D=0A n->did,=0D=0A = "SYS$DISK");=0D=0A=0D=0A if (status)= =0D=0A deleted_ok++;=0D=0A else=0D=0A no= t_deleted_ok++;=0D=0A=0D=0A total_examined++;=0D=0A }=0D= =0A /*=0D=0A ** say it's over, get user to acknowledge, restor= e display=0D=0A */=0D=0A delete_screen_status("* FINISHED *",= =0D=0A deleted_ok,=0D=0A = not_deleted_ok,=0D=0A total_examined,= =0D=0A TRUE,=0D=0A te= xt);=0D=0A=0D=0A smg$ring_bell(&display_delete);=0D=0A delete_s= creen_message(PRESS_TO_CONTINUE);=0D=0A get_key(ALLOW_AUTO);=0D= =0A delete_screen_off();=0D=0A=0D=0A /*=0D=0A ** deassign t= he i/o channel=0D=0A */=0D=0A sys$dassgn(channel);=0D=0A=0D= =0A return(TRUE);=0D=0A}=0D=0A=0C=0D=0A/*=0D=0A** delete or purge= files in a directory=0D=0A** specified by fid and channel=0D=0A*/= =0D=0Astatic ULONG delete_many_more_files(USHORT *fid, USHORT channel= , int sub_dirs,=0D=0A int option, = char *spec, char *text)=0D=0A{=0D=0A int del_opt;=0D=0A int ver= 1, ver2, len1, len2, file_length;=0D=0A int purge, delete;=0D=0A = int status, i, length;=0D=0A long last_wcc;=0D=0A char filena= me[256];=0D=0A char last_file[256];=0D=0A char spec_str[256];= =0D=0A IOSB_DEF iosb;=0D=0A struct dsc$descriptor_s fib_desc;= =0D=0A struct fibdef fib;=0D=0A=0D=0A /*=0D=0A ** initializ= e=0D=0A */=0D=0A=0D=0A strcpy(last_file,";");=0D=0A=0D=0A fi= b =3D blank_fib;=0D=0A last_wcc =3D 0;=0D=0A=0D=0A fib_desc.dsc= $w_length =3D FIB$C_LENGTH;=0D=0A fib_desc.dsc$a_pointer =3D (voi= d *) &fib;=0D=0A fib_desc.dsc$b_class =3D DSC$K_CLASS_S;=0D=0A = fib_desc.dsc$b_dtype =3D DSC$K_DTYPE_T;=0D=0A=0D=0A#ifdef __DECC= =0D=0A fib.fib$w_did[0] =3D fid[0];=0D=0A fib.fib$w_did[1] = =3D fid[1];=0D=0A fib.fib$w_did[2] =3D fid[2];=0D=0A fib.fib$w_= nmctl =3D FIB$M_WILD;=0D=0A#else=0D=0A fib.fib$r_did_overlay.fib$w= _did[0] =3D fid[0];=0D=0A fib.fib$r_did_overlay.fib$w_did[1] =3D f= id[1];=0D=0A fib.fib$r_did_overlay.fib$w_did[2] =3D fid[2];=0D= =0A fib.fib$r_nmctl_overlay.fib$w_nmctl =3D FIB$M_WILD;=0D=0A#endi= f=0D=0A=0D=0A /*=0D=0A ** pull out all the files in the direct= ory, checking to see if the=0D=0A ** files themselves are directo= ries=0D=0A */=0D=0A=0D=0A filename[0] =3D 0;=0D=0A file_leng= th =3D 0;=0D=0A=0D=0A while(1)=0D=0A {=0D=0A=09strcpy(spec_str,= spec);=0D=0A uchar =3D 0;=0D=0A/* iosb.status =3D 0;= =09### obsolete code - for bad type */=0D=0A status =3D sys$qi= ow(0,=0D=0A channel,=0D=0A = IO$_ACCESS,=0D=0A &iosb,=0D=0A = 0,=0D=0A 0,=0D=0A = &fib_desc,=0D=0A DSC1(spe= c_str),=0D=0A &file_length,=0D=0A = DSCA1(filename),=0D=0A acb1,= =0D=0A 0);=0D=0A if((status & 1) != =3D 1)=0D=0A panic(status,=0D=0A "io$_acc= ess directory lookup",=0D=0A "delete many more files= ");=0D=0A=0D=0A if(iosb.status =3D=3D SS$_NOMOREFILES)=0D=0A = {=0D=0A return(TRUE);=0D=0A }=0D=0A=0D=0A = /*=0D=0A ** file in dir but not indexf.sys=0D=0A *= /=0D=0A if (iosb.status =3D=3D SS$_NOSUCHFILE)=0D=0A {= =0D=0A fib.fib$l_wcc++;=0D=0A continue;=0D=0A = }=0D=0A=0D=0A /*=0D=0A ** on error go get next f= ile unless fib.l_wcc =3D=3D 0; in which case=0D=0A ** we can'= t read the dir, so we bomb=0D=0A */=0D=0A if((iosb.stat= us & 1) !=3D 1)=0D=0A {=0D=0A if (fib.fib$l_wcc = =3D=3D 0)=0D=0A {=0D=0A /*=0D=0A = ** we can't read this directory - go home=0D=0A = */=0D=0A warning(full_error_text(iosb.status));=0D= =0A return(iosb.status);=0D=0A }=0D=0A=0D= =0A /*=0D=0A ** assume not a dir=0D=0A = */=0D=0A continue;=0D=0A }=0D=0A=0D=0A /= *=0D=0A ** carry on=0D=0A */=0D=0A filename[fil= e_length] =3D 0;=0D=0A=0D=0A /*=0D=0A ** if it was a d= irectory (& not [000000].dir) we'll go and process it=0D=0A **= by calling this same function=0D=0A */=0D=0A if (ucha= r & FCH$M_DIRECTORY &&=0D=0A#ifdef __DECC=0D=0A (fib.fib$w= _fid[0] !=3D mfd_did[0] ||=0D=0A fib.fib$w_fid[1] !=3D mf= d_did[1]) )=0D=0A#else=0D=0A (fib.fib$r_fid_overlay.fib$w_= fid[0] !=3D mfd_did[0] ||=0D=0A fib.fib$r_fid_overlay.fib= $w_fid[1] !=3D mfd_did[1]) )=0D=0A#endif=0D=0A {=0D=0A = /*=0D=0A ** we've a directory, so call this function = first if we're=0D=0A ** handling sub-directories=0D=0A = */=0D=0A if (sub_dirs)=0D=0A#ifdef __DECC=0D=0A = delete_many_more_files(fib.fib$w_fid,=0D=0A#else=0D= =0A delete_many_more_files(fib.fib$r_fid_overlay.fib$w= _fid,=0D=0A#endif=0D=0A channel= ,=0D=0A sub_dirs,=0D=0A = option,=0D=0A = spec_str,=0D=0A t= ext);=0D=0A }=0D=0A /*=0D=0A ** now process thi= s file=0D=0A */=0D=0A total_examined++;=0D=0A de= l_opt =3D FALSE;=0D=0A=0D=0A /*=0D=0A ** if we're purg= ing and this one wasn't a directory, try to=0D=0A ** purge it= =0D=0A */=0D=0A if (option =3D=3D PURGE && !(uchar & FC= H$M_DIRECTORY))=0D=0A {=0D=0A /*=0D=0A *= * let's see if this file is a junior version=0D=0A ** of= the previous - if so it's purgeable=0D=0A */=0D=0A = len1 =3D strcspn(filename,";");=0D=0A len2 =3D strcsp= n(last_file,";");=0D=0A ver1 =3D atoi(&filename[len1+1]);= =0D=0A ver2 =3D atoi(&last_file[len2+1]);=0D=0A = if (len1 =3D=3D len2 &&=0D=0A strncmp(last_file,filen= ame,len1) =3D=3D 0 &&=0D=0A ver1 < ver2)=0D=0A = {=0D=0A /*=0D=0A ** same name.type= =0D=0A */=0D=0A del_opt =3D TRUE;=0D= =0A#ifdef __DECC=0D=0A i =3D delete_a_file_by_fid(fib.= fib$w_fid,=0D=0A fib.fib$w_di= d,=0D=0A#else=0D=0A i =3D delete_a_file_by_fid(fib.fib= $r_fid_overlay.fib$w_fid,=0D=0A = fib.fib$r_did_overlay.fib$w_did,=0D=0A#endif=0D=0A = "SYS$DISK");=0D=0A }=0D=0A = }=0D=0A else if (option =3D=3D DELETE)=0D=0A {=0D=0A = /*=0D=0A ** delete it=0D=0A */=0D= =0A del_opt =3D TRUE;=0D=0A#ifdef __DECC=0D=0A = i =3D delete_a_file_by_fid(fib.fib$w_fid,=0D=0A = fib.fib$w_did,=0D=0A#else=0D=0A i =3D delet= e_a_file_by_fid(fib.fib$r_fid_overlay.fib$w_fid,=0D=0A = fib.fib$r_did_overlay.fib$w_did,=0D=0A#endif= =0D=0A "SYS$DISK");=0D=0A = }=0D=0A=0D=0A if (del_opt)=0D=0A {=0D=0A if = (i)=0D=0A {=0D=0A /*=0D=0A *= * Drop context back one - this is a kludge. The problem=0D=0A = ** is that we'll miss files if we delete now, cos the=0D= =0A ** context will be out. It would be better to bui= ld up a list=0D=0A ** of the files to be deleted at t= he end of the directory=0D=0A ** walk-through (perhap= s).=0D=0A */=0D=0A fib.fib$l_wcc =3D la= st_wcc;=0D=0A deleted_ok++;=0D=0A }=0D=0A = else=0D=0A not_deleted_ok++;=0D=0A }= =0D=0A=0D=0A /*=0D=0A ** update the delete screen info= if we've tried to delete or=0D=0A ** the no of files examine= d is a multiple of EXAMINED_WEDGE=0D=0A */=0D=0A if (de= l_opt || total_examined % EXAMINED_WEDGE =3D=3D 0)=0D=0A {= =0D=0A delete_screen_status(filename,=0D=0A = deleted_ok,=0D=0A n= ot_deleted_ok,=0D=0A total_examined,= =0D=0A del_opt,=0D=0A = text);=0D=0A }=0D=0A strcpy(last_file,= filename);=0D=0A=09last_wcc =3D fib.fib$l_wcc;=0D=0A }=0D=0A}= =0D=0A=0C=0D=0A/*=0D=0A** delete the file fid on device removing it = =66rom directory did=0D=0A** use RMS (couldn't get sys$qiow to go) c= hange protection to make sure=0D=0A** we can delete it=0D=0A*/=0D= =0Aint delete_a_file_by_fid(USHORT *fid, USHORT *did, char *device)= =0D=0A{=0D=0A ULONG status;=0D=0A USHORT prot, dummy;=0D=0A = struct FAB fab;=0D=0A struct NAM nam;=0D=0A=0D=0A fab =3D cc$r= ms_fab;=0D=0A nam =3D cc$rms_nam;=0D=0A=0D=0A fab.fab$b_fac = =3D 0;=0D=0A fab.fab$l_fop =3D FAB$M_NAM;=0D=0A fab.fab$l_nam = =3D &nam;=0D=0A=0D=0A nam.nam$w_fid[0] =3D fid[0];=0D=0A nam.na= m$w_fid[1] =3D fid[1];=0D=0A nam.nam$w_fid[2] =3D fid[2];=0D=0A= =0D=0A nam.nam$w_did[0] =3D did[0];=0D=0A nam.nam$w_did[1] = =3D did[1];=0D=0A nam.nam$w_did[2] =3D did[2];=0D=0A=0D=0A spri= ntf(nam.nam$t_dvi,"%c%s",strlen(device),device);=0D=0A=0D=0A statu= s =3D sys$erase(&fab);=0D=0A if (status !=3D RMS$_SUC)=0D=0A {= =0D=0A#ifdef CHANGE_PROT_TO_DELETE=0D=0A /*=0D=0A ** r= emove any file protection=0D=0A */=0D=0A set_protection= (device,fid,0,&prot);=0D=0A=0D=0A=09/*=0D=0A=09** try again=0D=0A= =09*/=0D=0A if (sys$erase(&fab) !=3D RMS$_SUC)=0D=0A {= =0D=0A /*=0D=0A ** failed - restore the protec= tion=0D=0A */=0D=0A set_protection(device,fid,p= rot,&dummy);=0D=0A return(FALSE);=0D=0A=09}=0D=0A#else= =0D=0A return(FALSE);=0D=0A#endif /* CHANGE_PROT_TO_DELETE */=0D= =0A }=0D=0A return(TRUE);=0D=0A}=0D=0A=0C=0D=0A/*=0D=0A** dele= te a file by standard file spec (dev:[dir]name.type;version)=0D=0A*/= =0D=0AULONG delete_a_file(char *spec)=0D=0A{=0D=0A int status;= =0D=0A=0D=0A /*=0D=0A ** delete=0D=0A */=0D=0A status = =3D lib$delete_file(DSC1(spec));=0D=0A return(status);=0D=0A}=0D= =0A= ------------- Norman D. Grant INTERNET: norm.grant@wmich.edu Western Michigan University Voice: (269) 387-5449 Office of Information Technology/UCS Kalamazoo, MI 49008