home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************/
- /* */
- /* MultiFind - Dateiensuche Version 1.1r000 */
- /* */
- /* ©1994 Boris Jakubaschk Entwicklungszeit: 01.03.1994 - 12.04.1994 */
- /* */
- /* Versionen: */
- /* */
- /* V0.0 01.03. Entwicklungsbeginn */
- /* V1.0 01.04. Horizontale Rollbalken eingebaut */
- /* V1.1 12.04. Lokalisiert */
- /* */
- /**************************************************************************/
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/lists.h>
- #include <exec/nodes.h>
- #include <rexx/storage.h>
- #include <intuition/intuition.h>
- #include <intuition/classes.h>
- #include <intuition/classusr.h>
- #include <intuition/imageclass.h>
- #include <intuition/gadgetclass.h>
- #include <libraries/asl.h>
- #include <libraries/gadtools.h>
- #include <libraries/locale.h>
- #include <graphics/displayinfo.h>
- #include <graphics/gfxbase.h>
- #include <dos/dostags.h>
- #include <workbench/workbench.h>
- #include <clib/exec_protos.h>
- #include <clib/alib_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/rexxsyslib_protos.h>
- #include <clib/locale_protos.h>
- #include <string.h>
-
- #define GD_Pattern 0
- #define GD_type 1
- #define GD_pattern 2
- #define GD_hex 3
- #define GD_case 4
- #define GD_subdir 5
- #define GD_found 6
- #define GD_source 7
- #define GD_new 8
- #define GD_del 9
- #define GD_start 10
- #define GD_stop 11
- #define GD_cancel 12
- #define GD_stat 13
- #define GD_clip 14
- #define GD_mtool 15
- #define GD_edit 16
- #define GD_clear 17
- #define GD_found_vs 18
- #define GD_source_vs 19
-
- #define MSG_Title 0
- #define MSG_Title_Str "MultiFind V1.0 (Boris Jakubaschk)"
- #define MSG_FName 1
- #define MSG_FName_Str "Filename"
- #define MSG_FCont 2
- #define MSG_FCont_Str "Contents"
- #define MSG_SPat 3
- #define MSG_SPat_Str "Pattern "
- #define MSG_NamesOnly 4
- #define MSG_NamesOnly_Str "Filenames only"
- #define MSG_HEXMode 5
- #define MSG_HEXMode_Str "HEX mode"
- #define MSG_CaseSen 6
- #define MSG_CaseSen_Str "Case sensitive"
- #define MSG_SubDir 7
- #define MSG_SubDir_Str "Subdirs"
- #define MSG_New 8
- #define MSG_New_Str "New"
- #define MSG_Del 9
- #define MSG_Del_Str "Del"
- #define MSG_Start 10
- #define MSG_Start_Str "Start"
- #define MSG_Stop 11
- #define MSG_Stop_Str "Stop"
- #define MSG_Cancel 12
- #define MSG_Cancel_Str "Cancel"
- #define MSG_Clip 13
- #define MSG_Clip_Str "Clipboard"
- #define MSG_MTool 14
- #define MSG_MTool_Str "MTool"
- #define MSG_Editor 15
- #define MSG_Editor_Str "Editor"
- #define MSG_Clear 16
- #define MSG_Clear_Str "Clear"
- #define MSG_STerm 17
- #define MSG_STerm_Str "< finished >"
- #define MSG_SCanc 18
- #define MSG_SCanc_Str "< cancelled >"
- #define MSG_GetPath 19
- #define MSG_GetPath_Str "Select the search path or -file"
- #define MSG_NoSel 20
- #define MSG_NoSel_Str "< no entry selected >"
- #define MSG_Welcome 21
- #define MSG_Welcome_Str "Welcome to MultiFind!"
-
- char *LS[]=
- {
- MSG_Title_Str,
- MSG_FName_Str,
- MSG_FCont_Str,
- MSG_SPat_Str,
- MSG_NamesOnly_Str,
- MSG_HEXMode_Str,
- MSG_CaseSen_Str,
- MSG_SubDir_Str,
- MSG_New_Str,
- MSG_Del_Str,
- MSG_Start_Str,
- MSG_Stop_Str,
- MSG_Cancel_Str,
- MSG_Clip_Str,
- MSG_MTool_Str,
- MSG_Editor_Str,
- MSG_Clear_Str,
- MSG_STerm_Str,
- MSG_SCanc_Str,
- MSG_GetPath_Str,
- MSG_NoSel_Str,
- MSG_Welcome_Str
- };
-
- struct Screen *Scr = NULL;
- APTR VisualInfo = NULL;
- struct Window *MainWnd = NULL;
- struct Gadget *MainGList = NULL;
- struct Gadget *MainGadgets[20];
- UWORD MainLeft = 0;
- UWORD MainTop = 0;
- UWORD MainWidth = 439;
- UWORD MainHeight = 269;
- UBYTE *MainWdt = NULL;
- struct Library *CxBase= NULL;
- struct DiskObject *DObj=NULL;
-
- char Pattern = 1;
- char HexMode = 0;
- char CaseSen = 0;
- char SubDirs = 1;
- char SearchPattern[256];
- char PatternMaske[256];
- LONG TypeCmp = 0;
- LONG LastSel =-1;
- struct List DirList;
- struct List FoundList;
- char ActDir[130];
- int ActOffset;
- LONG DirScPos = 0;
- LONG FoundScPos = 0;
- LONG DirScTot = 0;
- LONG FoundScTot = 0;
-
-
- char *ED_Command;
- char *ED_Port;
- char *ED_RexxCmd;
- char *MT_Port;
- char *MT_RexxCmd;
-
- struct InfoNode
- {
- struct Node in_Node;
- ULONG in_Offset;
- };
-
- UBYTE *type0Labels[] = {
- (UBYTE *)NULL,
- (UBYTE *)NULL,
- NULL };
-
- struct TextAttr topaz8 = {
- ( STRPTR )"topaz.font", 8, 0x00, 0x41 };
-
- struct Library *LocaleBase = NULL;
- static struct Catalog *Cat;
-
- InitLocale(void)
- {
- char **str=LS;
- ULONG i;
- if (LocaleBase=OpenLibrary("locale.library",38))
- {
- if (Cat=(struct Catalog *)OpenCatalog(NULL,"mfind.catalog",
- OC_Version, 10,
- OC_BuiltInLanguage, "english",
- TAG_DONE))
- {
- for (i=0; i<=MSG_Welcome; i++, str++)
- *str=(char *)GetCatalogStr(Cat,i,*str);
- }
- }
- }
-
- QuitLocale(void)
- {
- if (LocaleBase)
- {
- if (Cat) CloseCatalog(Cat);
- CloseLibrary(LocaleBase);
- }
- }
-
- int SetupScreen( void )
- {
- InitLocale();
-
- if ( ! ( Scr = LockPubScreen( NULL )))
- return( 1L );
-
- if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
- return( 2L );
-
- if ( ! ( CxBase = OpenLibrary( "commodities.library", 37L )))
- return( 3L );
-
- return( 0L );
- }
-
- void CloseDownScreen( void )
- {
- struct Node *NN;
-
- if ( VisualInfo ) {
- FreeVisualInfo( VisualInfo );
- VisualInfo = NULL;
- }
-
- if ( Scr ) {
- UnlockPubScreen( NULL, Scr );
- Scr = NULL;
- }
-
- if ( CxBase ) CloseLibrary( CxBase );
- if ( DObj ) FreeDiskObject( DObj );
-
- while ( (&DirList)->lh_Head->ln_Succ )
- {
- NN = DirList.lh_Head;
- Remove( NN );
- FreeMem( NN, sizeof(struct Node)+256 );
- };
-
- while ( (&FoundList)->lh_Head->ln_Succ )
- {
- NN = FoundList.lh_Head;
- Remove( NN );
- FreeMem( NN, sizeof(struct Node)+256 );
- };
-
- QuitLocale();
- }
-
- void CenterWnd( WORD WndWidth, WORD *WndHeight, WORD *x_pos, WORD *y_pos )
- {
- ULONG ModeID;
- struct Rectangle OSRect;
- WORD ScrWidth = 0, ScrHeight = 0;
-
- if (INVALID_ID != (ModeID = GetVPModeID(&(Scr->ViewPort) ) ) )
- {
- if (QueryOverscan (ModeID, &OSRect, OSCAN_TEXT) )
- {
- ScrWidth = OSRect.MaxX - OSRect.MinX + 1;
- ScrHeight = OSRect.MaxY - OSRect.MinY + 1;
- };
- };
- *WndHeight = (ScrHeight>320) ? 300 : ScrHeight-12-(ScrHeight%8);
- *x_pos = (ScrWidth/2 - WndWidth/2) - Scr->LeftEdge;
- *y_pos = (ScrHeight/2 - *WndHeight/2) - Scr->TopEdge;
- }
-
- int OpenMainWindow( void )
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD offx, offy;
-
- type0Labels[0] = (UBYTE *)LS[MSG_FName];
- type0Labels[1] = (UBYTE *)LS[MSG_FCont];
- MainWdt = (UBYTE *)LS[MSG_Title];
-
- CenterWnd( MainWidth, &MainHeight, &MainLeft, &MainTop );
-
- offx = Scr->WBorLeft;
- offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
-
- if ( ! ( g = CreateContext( &MainGList )))
- return( 1L );
-
- ng.ng_LeftEdge = offx + 101;
- ng.ng_TopEdge = offy + 3;
- ng.ng_Width = 201;
- ng.ng_Height = 14;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_SPat];
- ng.ng_TextAttr = &topaz8;
- ng.ng_GadgetID = GD_Pattern;
- ng.ng_Flags = PLACETEXT_LEFT;
- ng.ng_VisualInfo = VisualInfo;
-
- g = CreateGadget( STRING_KIND, g, &ng, GTST_MaxChars, 256, TAG_DONE );
-
- MainGadgets[ 0 ] = g;
-
- ng.ng_LeftEdge = offx + 304;
- ng.ng_Width = 123;
- ng.ng_GadgetText = NULL;
- ng.ng_GadgetID = GD_type;
- ng.ng_Flags = 0;
-
- g = CreateGadget( CYCLE_KIND, g, &ng, GTCY_Labels, &type0Labels[0], TAG_DONE );
-
- MainGadgets[ 1 ] = g;
-
- ng.ng_LeftEdge = offx + 101;
- ng.ng_TopEdge = offy + 19;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_NamesOnly];
- ng.ng_GadgetID = GD_pattern;
- ng.ng_Flags = PLACETEXT_RIGHT;
-
- g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
-
- MainGadgets[ 2 ] = g;
-
- ng.ng_TopEdge = offy + 32;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_HEXMode];
- ng.ng_GadgetID = GD_hex;
-
- g = CreateGadget( CHECKBOX_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 3 ] = g;
-
- ng.ng_LeftEdge = offx + 276;
- ng.ng_TopEdge = offy + 19;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_CaseSen];
- ng.ng_GadgetID = GD_case;
-
- g = CreateGadget( CHECKBOX_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 4 ] = g;
-
- ng.ng_TopEdge = offy + 32;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_SubDir];
- ng.ng_GadgetID = GD_subdir;
-
- g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
-
- MainGadgets[ 5 ] = g;
-
- ng.ng_LeftEdge = offx + 6;
- ng.ng_TopEdge = offy + 82;
- ng.ng_Width = 295;
- ng.ng_Height = MainHeight-113;
- ng.ng_GadgetText = NULL;
- ng.ng_GadgetID = GD_found;
- ng.ng_Flags = 0;
-
- g = CreateGadget( LISTVIEW_KIND, g, &ng, GTLV_Labels, NULL, TAG_DONE );
-
- MainGadgets[ 6 ] = g;
-
- ng.ng_LeftEdge = offx + 304;
- ng.ng_Width = 123;
- ng.ng_GadgetID = GD_source;
-
- g = CreateGadget( LISTVIEW_KIND, g, &ng, GTLV_Labels, &DirList, TAG_DONE );
-
- MainGadgets[ 7 ] = g;
-
- ng.ng_TopEdge = offy + 64;
- ng.ng_Width = 60;
- ng.ng_Height = 14;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_New];
- ng.ng_GadgetID = GD_new;
- ng.ng_Flags = PLACETEXT_IN;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 8 ] = g;
-
- ng.ng_LeftEdge = offx + 367;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_Del];
- ng.ng_GadgetID = GD_del;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 9 ] = g;
-
- ng.ng_LeftEdge = offx + 6;
- ng.ng_Width = 95;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_Start];
- ng.ng_GadgetID = GD_start;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 10 ] = g;
-
- ng.ng_LeftEdge = offx + 106;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_Stop];
- ng.ng_GadgetID = GD_stop;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 11 ] = g;
-
- ng.ng_Width = 123;
- ng.ng_LeftEdge = offx + 304;
- ng.ng_TopEdge = offy + MainHeight - 22;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_Cancel];
- ng.ng_GadgetID = GD_cancel;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 12 ] = g;
-
- ng.ng_LeftEdge = offx + 6;
- ng.ng_TopEdge = offy + 46;
- ng.ng_Width = 421;
- ng.ng_GadgetText = NULL;
- ng.ng_GadgetID = GD_stat;
-
- g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Border, TRUE, TAG_DONE );
-
- MainGadgets[ 13 ] = g;
-
- ng.ng_LeftEdge = offx + 106;
- ng.ng_TopEdge = offy + MainHeight - 22;
- ng.ng_Width = 95;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_Clip];
- ng.ng_GadgetID = GD_clip;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 14 ] = g;
-
- ng.ng_LeftEdge = offx + 6;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_MTool];
- ng.ng_GadgetID = GD_mtool;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 15 ] = g;
-
- ng.ng_LeftEdge = offx + 206;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_Editor];
- ng.ng_GadgetID = GD_edit;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 16 ] = g;
-
- ng.ng_TopEdge = offy + 64;
- ng.ng_LeftEdge = offx + 206;
- ng.ng_Width = 95;
- ng.ng_GadgetText = (UBYTE *)LS[MSG_Clear];
- ng.ng_GadgetID = GD_clear;
-
- g = CreateGadget( BUTTON_KIND, g, &ng, TAG_DONE );
-
- MainGadgets[ 17 ] = g;
-
- ng.ng_LeftEdge = offx + 6;
- ng.ng_TopEdge = offy + MainHeight - 37;
- ng.ng_Width = 295;
- ng.ng_Height = 11;
- ng.ng_GadgetText = NULL;
- ng.ng_GadgetID = GD_found_vs;
-
- g = CreateGadget( SCROLLER_KIND, g, &ng, GTSC_Total, 0, GTSC_Visible, 33, GTSC_Arrows, 0, GA_RelVerify, TRUE, GA_Immediate, TRUE, TAG_DONE );
-
- MainGadgets[ 18 ] = g;
-
- ng.ng_LeftEdge = offx + 304;
- ng.ng_Width = 123;
- ng.ng_GadgetID = GD_source_vs;
-
- g = CreateGadget( SCROLLER_KIND, g, &ng, GTSC_Total, 0, GTSC_Visible, 12, GTSC_Arrows, 0, GA_RelVerify, TRUE, GA_Immediate, TRUE, TAG_DONE );
-
- MainGadgets[ 19 ] = g;
-
- if ( ! g )
- return( 2L );
-
- if ( ! ( MainWnd = OpenWindowTags( NULL,
- WA_Left, MainLeft,
- WA_Top, MainTop,
- WA_Width, MainWidth,
- WA_Height, MainHeight + offy,
- WA_IDCMP, STRINGIDCMP|CYCLEIDCMP|CHECKBOXIDCMP|LISTVIEWIDCMP|BUTTONIDCMP|TEXTIDCMP|SCROLLERIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
- WA_Gadgets, MainGList,
- WA_Title, MainWdt,
- WA_ScreenTitle, "MultiTool II",
- WA_PubScreen, Scr,
- TAG_DONE )))
- return( 4L );
-
- GT_RefreshWindow( MainWnd, NULL );
-
- return( 0L );
- }
-
- void CloseMainWindow( void )
- {
- if ( MainWnd ) {
- CloseWindow( MainWnd );
- MainWnd = NULL;
- }
-
- if ( MainGList ) {
- FreeGadgets( MainGList );
- MainGList = NULL;
- }
- }
-
- int FileRequest( char *Header, char *Buffer, char *StartDrawer )
- {
- struct FileRequester *ASLFiR;
-
- if (ASLFiR = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest,
- ASLFR_Window, MainWnd, ASLFR_TitleText, Header,
- ASLFR_InitialDrawer, StartDrawer,
- ASLFR_RejectIcons, TRUE, TAG_DONE))
- {
- if (AslRequest( ASLFiR, NULL ))
- {
- strcpy( Buffer, ASLFiR->fr_Drawer );
- AddPart( Buffer, ASLFiR->fr_File, 130 );
- return(1);
- }
- else return(0);
- };
- }
-
- CallEditor( char *Filename, ULONG Offset )
- {
- char Buffer[256];
- char Command[256];
- int Counter=10;
-
- sprintf( Command, ED_Command, Filename );
- SystemTags( Command, SYS_Input, NULL, SYS_Output, NULL, TAG_DONE );
-
- while( (FindPort( ED_Port )==0) && Counter)
- {
- Counter--;
- Delay( 40 );
- };
-
- sprintf( Buffer, "rx \"ADDRESS '%s' '%s'\"", ED_Port, ED_RexxCmd );
- sprintf( Command, Buffer, Offset );
- SystemTags( Command, SYS_Input, NULL, SYS_Output, NULL, TAG_DONE );
- }
-
- AddLine( char *Text, ULONG Offset )
- {
- struct Node *NN;
-
- if (NN=AllocMem(sizeof(struct InfoNode)+256, MEMF_ANY|MEMF_CLEAR))
- {
- GT_SetGadgetAttrs( MainGadgets[6], MainWnd, 0, GTLV_Labels, ~0, TAG_DONE );
- NN->ln_Name = ((char *)NN)+sizeof(struct InfoNode);
- ((struct InfoNode*)NN)->in_Offset = Offset;
- strcpy( NN->ln_Name, Text );
- AddTail( &FoundList, (struct Node *)NN );
- GT_SetGadgetAttrs( MainGadgets[6], MainWnd, 0, GTLV_Labels, &FoundList, TAG_DONE );
- if (strlen(Text)>FoundScTot)
- {
- FoundScTot = strlen(Text);
- GT_SetGadgetAttrs( MainGadgets[18], MainWnd, 0, GTSC_Total, FoundScTot, TAG_DONE );
- };
- };
- }
-
- int CompareBlock( char *Buffer, ULONG Length )
- {
- ULONG i=0;
- ULONG j;
- ULONG slen = strlen(SearchPattern);
- int Offset;
- char SP[256];
-
- strcpy( SP, SearchPattern );
-
- if ((CaseSen==0)&&(HexMode==0))
- {
- for( i=0; i<strlen(SP); i++ ) SP[i]&=0xDF;
- for( i=0; i<Length; i++ ) Buffer[i]&=0xDF;
- };
-
- if (HexMode)
- {
- for( i=0; i<strlen(SP); i++ )
- {
- if (SearchPattern[i*2+0]>64) { SP[i] = ((SearchPattern[i*2]&0xDF)-55)*16; }
- else { SP[i] = (SearchPattern[i*2]-48)*16; };
- if (SearchPattern[i*2+1]>64) { SP[i] += (SearchPattern[i*2+1]&0xDF)-55; }
- else { SP[i] += SearchPattern[i*2+1]-48; };
- };
- slen /= 2;
- };
-
- if (Length>=slen)
- {
- for (i=0; i<Length-slen; i++)
- {
- j=0;
- while ((Buffer[i+j]==SP[j])&&(j<slen))
- {
- j++;
- };
- if (j==slen)
- {
- Offset = i;
- i = MAXINT-1;
- };
- };
- };
- return( (i==MAXINT)?Offset:-1 );
- };
-
- int CompareFile( char *Path )
- {
- struct FileInfoBlock *FIB;
- BPTR FL, FH;
- ULONG FileLen = 0;
- ULONG BlockLen, BytesRead;
- char *Buffer;
- int i, Offset;
-
- if (FIB = AllocMem( sizeof(struct FileInfoBlock), MEMF_ANY ))
- {
- if (FL = Lock( Path, ACCESS_READ ))
- {
- if (Examine( FL, FIB ))
- {
- FileLen = FIB->fib_Size;
- };
- UnLock( FL );
- };
- FreeMem( FIB, sizeof(struct FileInfoBlock) );
- };
- if (FileLen)
- {
- BlockLen = (FileLen>65536)? 65536 : FileLen;
- if (Buffer = AllocMem( BlockLen+strlen(SearchPattern), MEMF_ANY ))
- {
- if (FH = Open( Path, MODE_OLDFILE ))
- {
- for( i=0; i<((FileLen-1)/BlockLen)+1; i++ )
- {
- Seek( FH, i*BlockLen, OFFSET_BEGINNING );
- BytesRead = Read( FH, Buffer, BlockLen+strlen(SearchPattern) );
- if ((Offset=CompareBlock( Buffer, BytesRead ))!=-1)
- {
- i=MAXINT-1;
- };
- };
- Close( FH );
- };
- FreeMem( Buffer, BlockLen+strlen(SearchPattern) );
- };
- };
- return( (i==MAXINT)? Offset:-1 );
- }
-
- ProcessFile( char *Path, char *Name )
- {
- int success;
-
- switch(TypeCmp)
- {
- case 0: if (CaseSen)
- {
- success = MatchPattern( PatternMaske, Name );
- }
- else
- {
- success = MatchPatternNoCase( PatternMaske, Name );
- };
- if (success)
- {
- AddLine( Path, 0 );
- };
- break;
- case 1: if ((success = CompareFile( Path ))!=-1)
- {
- AddLine( Path, success );
- };
- break;
- }
- }
-
- ProcessDir( char *Path )
- {
- int success;
-
- if((TypeCmp==0)&&(Pattern==0))
- {
- if (CaseSen)
- {
- success = MatchPattern( PatternMaske, Path );
- }
- else
- {
- success = MatchPatternNoCase( PatternMaske, Path );
- };
- if (success)
- {
- AddLine( Path, 0 );
- };
- };
- }
-
- int ProcessName( char *Name, char Rekur )
- {
- struct FileInfoBlock *FIB;
- BPTR FL;
- char NewName[130];
- struct IntuiMessage *msg;
- char DoIt = 1;
-
- GT_SetGadgetAttrs(MainGadgets[13], MainWnd, 0, GTTX_Text, Name, TAG_DONE );
-
- while ( msg = (struct IntuiMessage *) GT_GetIMsg( MainWnd->UserPort ) )
- {
- if( (msg->Class==GADGETUP) &&
- (((struct Gadget *)msg->IAddress)->GadgetID==GD_stop) ) DoIt = 0;
- GT_ReplyIMsg(msg);
- };
-
- if (DoIt)
- {
- if (FIB = AllocMem( sizeof(struct FileInfoBlock), MEMF_ANY ))
- {
- if (FL = Lock( Name, ACCESS_READ ))
- {
- if (Examine( FL, FIB ))
- {
- if (FIB->fib_DirEntryType>0)
- {
- ProcessDir( Name );
- if (SubDirs || Rekur)
- {
- while( ExNext( FL, FIB ) && DoIt )
- {
- strcpy( NewName, Name );
- AddPart( NewName, FIB->fib_FileName, 130 );
- DoIt = ProcessName( NewName, 0 );
- };
- };
- }
- else
- {
- ProcessFile( Name, FIB->fib_FileName );
- }
- };
- UnLock( FL );
- };
- FreeMem( FIB, sizeof(struct FileInfoBlock) );
- };
- };
- return( DoIt );
- }
-
- FindIt()
- {
- struct Node *NN;
- int success = 1;
-
- if ((TypeCmp==0)&&(CaseSen==0))
- {
- success = ParsePatternNoCase( SearchPattern, PatternMaske, 256 )+1;
- }
- else if (TypeCmp==0)
- {
- success = ParsePattern( SearchPattern, PatternMaske, 256 )+1;
- };
-
- if (success)
- {
- NN = DirList.lh_Head;
- while ( NN->ln_Succ )
- {
- if (ProcessName( NN->ln_Name, 1 ))
- {
- GT_SetGadgetAttrs(MainGadgets[13], MainWnd, 0, GTTX_Text, LS[MSG_STerm], TAG_DONE );
- }
- else
- {
- GT_SetGadgetAttrs(MainGadgets[13], MainWnd, 0, GTTX_Text, LS[MSG_SCanc], TAG_DONE );
- };
- NN = NN->ln_Succ;
- };
- };
- }
-
- GetPathsFile( char *Name )
- {
- BPTR FH;
- char PN[130];
- char *PName = PN;
- struct Node *NN;
-
- if (FH = Open( Name, MODE_OLDFILE ))
- {
- while( FGets( FH, PName, 130 ) )
- {
- if (PName[strlen(PName)-1]==10) PName[strlen(PName)-1]=0;
- if (PName[strlen(PName)-1]==34) PName[strlen(PName)-1]=0;
- if (PName[strlen(PName)-1]=='?') PName[strlen(PName)-1]=0;
- if (PName[strlen(PName)-1]=='#') PName[strlen(PName)-1]=0;
- if (PName[0]==34) PName++;
- if (NN=AllocMem(sizeof(struct Node)+256, MEMF_ANY|MEMF_CLEAR))
- {
- GT_SetGadgetAttrs( MainGadgets[7], MainWnd, 0, GTLV_Labels, ~0, TAG_DONE );
- NN->ln_Name = ((char *)NN)+sizeof(struct Node);
- strcpy( NN->ln_Name, PName );
- NN->ln_Name += DirScPos;
- AddTail( &DirList, NN );
- GT_SetGadgetAttrs( MainGadgets[7], MainWnd, 0, GTLV_Labels, &DirList, TAG_DONE );
- if (strlen(PName)>DirScTot)
- {
- DirScTot = strlen(PName);
- GT_SetGadgetAttrs( MainGadgets[19], MainWnd, 0, GTSC_Total, DirScTot, TAG_DONE );
- }
- };
- };
- Close( FH );
- };
- }
-
- int GetNewPath()
- {
- struct Node *NN;
- char Name[256];
-
- if (FileRequest( LS[MSG_GetPath], Name, "SYS:" ))
- {
- if (NN=AllocMem(sizeof(struct Node)+256, MEMF_ANY|MEMF_CLEAR))
- {
- GT_SetGadgetAttrs( MainGadgets[7], MainWnd, 0, GTLV_Labels, ~0, TAG_DONE );
- NN->ln_Name = ((char *)NN)+sizeof(struct Node);
- strcpy( NN->ln_Name, Name );
- NN->ln_Name += DirScPos;
- AddTail( &DirList, NN );
- GT_SetGadgetAttrs( MainGadgets[7], MainWnd, 0, GTLV_Labels, &DirList, TAG_DONE );
- if (strlen(Name)>DirScTot)
- {
- DirScTot = strlen(Name);
- GT_SetGadgetAttrs( MainGadgets[19], MainWnd, 0, GTSC_Total, DirScTot, TAG_DONE );
- }
- return( 1 );
- };
- };
- return( 0 );
- };
-
- MainGadget( struct Gadget *GList, USHORT GCode, WORD GMouseY, ULONG GTimeS, GTimeM )
- {
- static ULONG OTimeS, OTimeM;
- struct Node *NN;
- LONG i;
- char Name[256];
- BPTR FH;
-
- switch (GList->GadgetID)
- {
- case GD_type:
- TypeCmp = GCode;
- break;
- case GD_pattern:
- Pattern ^= 1;
- break;
- case GD_hex:
- HexMode ^= 1;
- break;
- case GD_case:
- CaseSen ^= 1;
- break;
- case GD_subdir:
- SubDirs ^= 1;
- break;
- case GD_source:
- NN = DirList.lh_Head;
- for (i=0; i<GCode; i++) NN = NN->ln_Succ;
- strcpy( ActDir, ((char *)NN)+sizeof(struct Node) );
- ActOffset = 0;
- GT_SetGadgetAttrs(MainGadgets[13], MainWnd, 0, GTTX_Text, ActDir, TAG_DONE );
- LastSel = GCode;
- break;
- case GD_found:
- NN = FoundList.lh_Head;
- for (i=0; i<GCode; i++) NN = NN->ln_Succ;
- strcpy( ActDir, ((char *)NN)+sizeof(struct InfoNode) );
- ActOffset = ((struct InfoNode *)NN)->in_Offset;
- GT_SetGadgetAttrs(MainGadgets[13], MainWnd, 0, GTTX_Text, ActDir, TAG_DONE );
- LastSel = -1;
- break;
- case GD_new:
- GetNewPath();
- break;
- case GD_del:
- if (LastSel!=-1)
- {
- NN = DirList.lh_Head;
- for (i=0; i<LastSel; i++) NN = NN->ln_Succ;
- GT_SetGadgetAttrs( MainGadgets[7], MainWnd, 0, GTLV_Labels, ~0, TAG_DONE );
- Remove( NN );
- FreeMem( NN, sizeof(struct Node) + 256 );
- GT_SetGadgetAttrs( MainGadgets[7], MainWnd, 0, GTLV_Labels, &DirList, TAG_DONE );
- GT_SetGadgetAttrs(MainGadgets[13], MainWnd, 0, GTTX_Text, LS[MSG_NoSel], TAG_DONE );
- LastSel = -1;
- NN = DirList.lh_Head;
- DirScTot=0;
- while( NN->ln_Succ )
- {
- int a=strlen( ((char *)NN)+sizeof(struct Node ));
- if (a>DirScTot) DirScTot=a;
- NN = NN->ln_Succ;
- }
- GT_SetGadgetAttrs( MainGadgets[19], MainWnd, 0, GTSC_Total, DirScTot, TAG_DONE );
- };
- break;
- case GD_start:
- struct StringInfo *sti = MainGadgets[GD_Pattern]->SpecialInfo;
- strcpy( SearchPattern, sti->Buffer );
- FindIt();
- break;
- case GD_clear:
- GT_SetGadgetAttrs( MainGadgets[6], MainWnd, 0, GTLV_Labels, ~0, TAG_DONE );
- while ( (&FoundList)->lh_Head->ln_Succ )
- {
- NN = FoundList.lh_Head;
- Remove( NN );
- FreeMem( NN, sizeof(struct Node)+256 );
- };
- GT_SetGadgetAttrs( MainGadgets[6], MainWnd, 0, GTLV_Labels, &FoundList, TAG_DONE );
- FoundScTot = 0;
- FoundScPos = 0;
- GT_SetGadgetAttrs( MainGadgets[18], MainWnd, 0, GTSC_Total, FoundScTot, GTSC_Top, FoundScPos, TAG_DONE );
- break;
- case GD_edit:
- CallEditor( ActDir, ActOffset );
- break;
- case GD_clip:
- sprintf(Name, "FORM %cFTXTCHRS %c%s", strlen(ActDir)+12+(strlen(ActDir)%2), strlen(ActDir), ActDir);
- Name[4] = 0;
- Name[5] = 0;
- Name[6] = 0;
- Name[16] = 0;
- Name[17] = 0;
- Name[18] = 0;
- if (FH = Open( "Clips:0", MODE_NEWFILE ))
- {
- Write( FH, Name, strlen(ActDir)+20+(strlen(ActDir)%2) );
- Close( FH );
- };
- break;
- case GD_cancel:
- CloseMainWindow();
- CloseDownScreen();
- exit(0);
- break;
- case GD_found_vs:
- FoundScPos = GCode;
- GT_SetGadgetAttrs( MainGadgets[6], MainWnd, 0, GTLV_Labels, ~0, TAG_DONE );
- NN = FoundList.lh_Head;
- while( NN->ln_Succ )
- {
- NN->ln_Name = ((char *)NN)+sizeof(struct InfoNode) + FoundScPos;
- NN = NN->ln_Succ;
- };
- GT_SetGadgetAttrs( MainGadgets[6], MainWnd, 0, GTLV_Labels, &FoundList, TAG_DONE );
- break;
- case GD_source_vs:
- DirScPos = GCode;
- GT_SetGadgetAttrs( MainGadgets[7], MainWnd, 0, GTLV_Labels, ~0, TAG_DONE );
- NN = DirList.lh_Head;
- while( NN->ln_Succ )
- {
- NN->ln_Name = ((char *)NN)+sizeof(struct Node)+DirScPos;
- NN = NN->ln_Succ;
- };
- GT_SetGadgetAttrs( MainGadgets[7], MainWnd, 0, GTLV_Labels, &DirList, TAG_DONE );
- break;
- }
- }
-
- GetToolTypes(int argc, char **ttarray)
- {
- char *pfile;
-
- ED_Command = ArgString( ttarray, "ED_Cmd", "EDC %s" );
- ED_Port = ArgString( ttarray, "ED_Port", "rexx_ced" );
- ED_RexxCmd = ArgString( ttarray, "ED_RxCmd", "Jump to byte %d" );
- MT_Port = ArgString( ttarray, "MT_Port", "rexx_mtool" );
- MT_RexxCmd = ArgString( ttarray, "MT_RxCmd", "Display active %s" );
- if (ArgString( ttarray, "REQUESTPATHS", NULL ))
- while (GetNewPath());
- if (pfile = ArgString( ttarray, "PATHSFILE", NULL ))
- GetPathsFile(pfile);
- }
-
- wbmain(struct WBStartup *WBS)
- {
- struct WBArg *WA;
- BPTR DL;
- char **tt;
-
- WA = &WBS->sm_ArgList[WBS->sm_NumArgs-1];
- DL = CurrentDir( WA->wa_Lock );
- if (DObj=(struct DiskObject *)GetDiskObject(WA->wa_Name))
- {
- CurrentDir( DL );
- tt = DObj->do_ToolTypes;
- commonmain(0, tt);
- };
- }
-
- main(int argc, char **argv)
- {
- commonmain(argc, argv);
- }
-
- commonmain(int argc, char **argv)
- {
- ULONG GClass;
- USHORT GCode;
- UWORD GQual;
- ULONG GTimeS;
- ULONG GTimeM;
- struct Gadget *GList = 0l;
- WORD GMouseY;
- struct IntuiMessage *msg;
-
- if (SetupScreen()) exit(20);
- NewList(&DirList);
- NewList(&FoundList);
- if (OpenMainWindow()) exit(20);
- GT_SetGadgetAttrs(MainGadgets[13], MainWnd, 0, GTTX_Text, LS[MSG_Welcome], TAG_DONE );
-
- GetToolTypes(argc, argv);
-
- ActivateGadget( MainGadgets[0] , MainWnd, NULL );
-
- for(;;)
- {
- Wait( 1 << MainWnd->UserPort->mp_SigBit );
- while ( msg = (struct IntuiMessage *) GT_GetIMsg( MainWnd->UserPort ) )
- {
- GClass = msg->Class;
- GCode = msg->Code;
- GQual = msg->Qualifier;
- if (GClass & (GADGETDOWN | GADGETUP | MOUSEMOVE) )
- GList = (struct Gadget *) msg->IAddress;
- GMouseY = msg->MouseY;
- GTimeS = msg->Seconds;
- GTimeM = msg->Micros;
- GT_ReplyIMsg(msg);
-
- switch (GClass)
- {
- case CLOSEWINDOW : CloseMainWindow();
- CloseDownScreen();
- exit(0);
- break;
- case MOUSEMOVE :
- case GADGETUP : MainGadget( GList, GCode, GMouseY, GTimeS, GTimeM );
- break;
- };
- };
- };
- }
-
-
-