/* BFDGREP: binary filename/directory grep. ********************************** * bfgrep.c/bfgrep, binary filename/directory grep. (from which exist) * * for obtaining existing filename(s) or directory(s) used by a binary * * executable. argument 1 will be treated as a (binary) file, if none is * * provided or the provided argument isn't accessable it will revert to * * standard input. * * * * EXAMPLES: * * # bfdgrep [filename] [...] * * # cat | bfdgrep * * * * DISPLAY: * * /path/file(location found:access): /path/file found. * * * * COMMENTS: * * this program will only display with full valid paths (files and dirs). * * also, this program will not display information that is not used in a * * function. for example, something mentioned in a printf() statement * * would not get displayed. * * * * by: vade79 -> v9[v9@realhalo.org] -> realhalo.org. (88l!271w!3208b) * *****************************************************************************/ #include #include #include #define MAX_PATHNAME 4096 /* maximum path storage. (max) */ #define INPUT "/dev/stdin" /* revert to this (input) if no file. */ char id[]="$Id: bfdgrep.c,v 3.0 2001/03/24 01:11:36 EST vade79 Exp $"; char *file; int main(int argc,char **argv) { int i=0; if(argc>1){ for(i=1;isizeof(string)){ bzero(string,sizeof(string)); i=0; } } else if(chr==0x0){ if(strlen(string)>1&&!stat(string,&mod)) if(string[0]==0x2f){ bzero(mode,sizeof(mode)); if(!access(string,F_OK)){ sprintf(mode,"+"); if(!access(string,R_OK)) strcat(mode,"r"); if(!access(string,W_OK)) strcat(mode,"w"); if(!access(string,X_OK)) strcat(mode,"x"); } else sprintf(mode,"-"); fprintf(stderr,"%s(0x%lx:%s): %s\n",strcmp(fn,INPUT)?fn:"input", (loc-strlen(string)),mode,string); } bzero(string,sizeof(string)); i=0; } else{ bzero(string,sizeof(string)); i=0; } loc++; } fclose(fd); } }