BSD 4_1_snap release
[unix-history] / usr / src / cmd / strings.c
index 9bb8c26..a3f4944 100644 (file)
@@ -1,3 +1,4 @@
+static char *sccsid = "@(#)strings.c   4.1 (Berkeley) 10/1/80";
 #include <stdio.h>
 #include <a.out.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <a.out.h>
 #include <ctype.h>
@@ -5,15 +6,7 @@
 long   ftell();
 
 /*
 long   ftell();
 
 /*
- * Strings - extract strings from an object file for whatever
- *
- * Bill Joy UCB 
- * April 22, 1978
- *
- * The algorithm is to look for sequences of "non-junk" characters
- * The variable "minlen" is the minimum length string printed.
- * This helps get rid of garbage.
- * Default minimum string length is 4 characters.
+ * strings
  */
 
 struct exec header;
  */
 
 struct exec header;
@@ -46,7 +39,7 @@ main(argc, argv)
 
                default:
                        if (!isdigit(argv[0][i])) {
 
                default:
                        if (!isdigit(argv[0][i])) {
-                               fprintf(stderr, "Usage: strings [ - ] [ -o ] [ -# ] [ file ... ]\n");
+                               fprintf(stderr, "Usage: strings [ -a ] [ -o ] [ -# ] [ file ... ]\n");
                                exit(1);
                        }
                        minlength = argv[0][i] - '0';
                                exit(1);
                        }
                        minlength = argv[0][i] - '0';
@@ -69,12 +62,12 @@ main(argc, argv)
                fseek(stdin, (long) 0, 0);
                if (asdata ||
                    fread((char *)&header, sizeof header, 1, stdin) != 1 || 
                fseek(stdin, (long) 0, 0);
                if (asdata ||
                    fread((char *)&header, sizeof header, 1, stdin) != 1 || 
-                   !ismagic(header.a_magic)) {
+                   N_BADMAG(header)) {
                        fseek(stdin, (long) 0, 0);
                        find((long) 100000000L);
                        continue;
                }
                        fseek(stdin, (long) 0, 0);
                        find((long) 100000000L);
                        continue;
                }
-               fseek(stdin, (long) header.a_text, 1);
+               fseek(stdin, (long) N_TXTOFF(header)+header.a_text, 1);
                find((long) header.a_data);
        } while (argc > 0);
 }
                find((long) header.a_data);
        } while (argc > 0);
 }
@@ -126,18 +119,3 @@ dirt(c)
                return (c > 0200 || c < ' ');
        }
 }
                return (c > 0200 || c < ' ');
        }
 }
-
-ismagic(a)
-       int a;
-{
-
-       switch (a) {
-
-       case A_MAGIC1:
-       case A_MAGIC2:
-       case A_MAGIC3:
-       case A_MAGIC4:
-               return (1);
-       }
-       return (0);
-}