home *** CD-ROM | disk | FTP | other *** search
- /*
- valid.C Search a file for a text string.
- R.J.P. 9-5/90
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <kernel.h>
- #include <swis.h>
- #include "grep.h"
-
- char *ValidObject(char *CharPattern , char *path , char *fnB )
- {/*0*/
-
- _kernel_swi_regs KI ;
- _kernel_swi_regs KO ;
- _kernel_oserror *KE ;
- int Fatt ;
- /*
- Finds the directory information on the given file.
- and determines the type.
- If no file can be found, give up and return.
- If the file given is a directory, then recurse .
- Otherwise, find if the file is a Machine code dump
- by looking at the load address which has the top 3
- 3 nibbles set to 0xfff if it is not.
- */
- KI.r[0] = 5 ; /* Using File$Path */
- KI.r[1] = (int)path ; /* R1 points to object name */
- if( (KE = _kernel_swi( OS_File , &KI , &KO ) ) != 0 )
- {
- fprintf(stderr,"OS_File Error : %d\n%s\n",KE->errnum,KE->errmess) ;
- return 0 ;
- }
- if( !KO.r[0] )
- {
- fprintf(stderr,"**Find error : %s\n" , path ) ;
- return( 0 ) ;
- }
-
- if( KO.r[0] == 2 ) /* It's Directory..... */
- {
- ++N_Direc ;
- FileTree(CharPattern,path,fnB) ; /* Recurse */
- return 0 ; /* Flag no file search on return.*/
- }
-
- if( KO.r[0] != 1 ) /* Unknown........ */
- return 0 ;
- /*
- Ok .. It's a File .......
- Decode Load Address to find if Date-Stamped....
- Load address should be 0xfffIIIId bottom bit is part
- of the 5-byte date field .
- */
- ++N_Files ;
- if( ( ( KO.r[2] >> 20) & 0xfff) != 0xfff )
- return 0 ; /* It's a Dump.... */
-
- Fatt = (KO.r[2] >> 8) & 0xfff ;
- switch( Fatt )
- {
- case TEXT_TYPE: return("Text" ) ;
- case DATA_TYPE: return("Data" ) ;
- case COMMAND_TYPE: return("Cmd." ) ;
- case OBEY_TYPE: return("Obey" ) ;
- case PRINT_TYPE: return("Prt." ) ;
- default: break;
- }
- return 0 ;
- }/*0*/
-
-
-