/* * what.c * * Copyright (c) 1997-2003 DF7BE * * $Id$ * * Logbuchprogramm DF7BE * Amateur-Radio log by DF7BE * Utility to read ident-String in executables * This is a special for DOS. This command * is available on most recent UNIX / LINUX System. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the license, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA ( or visit * their web site at http://www.gnu.org/ ). * * * Modification documentation * * +------------+-------------------------+----------------------------------+ * + Date ! Name and Call ! Modification ! * +------------+-------------------------+----------------------------------+ * ! 27.01.2003 ! W.Brunken DF7BE ! first creation ! * +------------+-------------------------+----------------------------------+ * * Compiling: * * gcc what.c -o what.exe (DJGPP) * gcc what.c -o what (UNIX,LINUX) * cc what.c -o what (UNIX) * MICROSOFT QUICK C 2.5 : use Make Menu * set at Options model to "small" */ #include #include #include /* globale Variablen global vars*/ static int sflg,gefunden; /* what-String */ /* example for a what string */ const char what_string[] = { "@(#)CLLOG WHAT.C V1.0 (c) DF7BE 1997-2003" } ; const char what_string2[] = { "@(#)$Id$" } ; /* Prototypen */ void suche(); void suche() { int c; int t; t = 0; while (( c = getchar()) != EOF ) { /* ist zwar ein bischen wie BASIC, aber einfacher und schneller */ /* al little bit of BASIC, but simpler and faster */ schleife: if ( c != '@' ) continue; if (( c = getchar()) != '(' ) goto schleife; if (( c = getchar()) != '#' ) goto schleife; if (( c = getchar()) != ')' ) goto schleife; putchar('\t'); /* String solange ausgeben, bis EOF, 0x0 , " , > oder \ oder CR auftritt */ /* print string until EOF , 0x0 " > or \ or CR appears */ while ( ( c = getchar()) != EOF && c && c != '"' && c != '>' && c != '\\' && c != '\n' ) putchar(c); putchar('\n'); gefunden = 1; /* erster Treffer, fertig first match , ready */ if (sflg == 1 ) return; } } /* main */ int main(int argc, char **argv) { sflg = 0; gefunden = 0; if ( argc < 2 ) { printf("usage what [-s|/S] \n"); printf("\n"); printf("Copyright (c) 1997-2003 DF7BE\n"); printf("%s\n",what_string); printf("\n"); printf("This program is free software; you can redistribute it and/or modify\n"); printf("it under the terms of the GNU General Public License as published by\n"); printf("the Free Software Foundation; either version 2 of the license, or\n"); printf("(at your option) any later version.\n"); printf("\n"); printf("This program is distributed in the hope that it will be useful,\n"); printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n"); printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"); printf("GNU General Public License for more details.\n"); printf("You should have received a copy of the GNU General Public License\n"); printf("along with this program; if not, write to the Free Software\n"); printf("Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA ( or visit\n"); printf("their web site at http://www.gnu.org/ ).\n"); exit(1); } /* s-Option auswerten */ /* if ( strcmp((char *) argv[1] [0], "-s" ) || strcmp((char *) argv[1] [0], "-S" ) || strcmp((char *) argv[1] [0], "/s" ) || strcmp((char *) argv[1] [0], "/S" ) ) { printf("Option s gesetzt\n"); sflg = 1; *++argv; } */ if (! *argv) /* von Standardeingabe lesen */ suche(); else /* fuer jeden uebergebenen Dateinamen */ /* zuerst zeigt der argv auf 0 ==> eigener Name */ *++argv; do { if ( ! freopen(*argv, "rb" , stdin )) fprintf(stdout , "Kann nicht oeffnen : %s\n",argv); else { fprintf(stdout , "%s:\n", *argv); suche(); } } while ( *++argv); exit ( ! gefunden ); } /* main */