Deleted Added
full compact
strings.c (280932) strings.c (295577)
1/*-
2 * Copyright (c) 2007 S.Sam Arun Raj
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 23 unchanged lines hidden (view full) ---

32#include <errno.h>
33#include <fcntl.h>
34#include <getopt.h>
35#include <inttypes.h>
36#include <stdint.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
1/*-
2 * Copyright (c) 2007 S.Sam Arun Raj
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 23 unchanged lines hidden (view full) ---

32#include <errno.h>
33#include <fcntl.h>
34#include <getopt.h>
35#include <inttypes.h>
36#include <stdint.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <sysexits.h>
40#include <unistd.h>
41
42#include <libelf.h>
43#include <libelftc.h>
44#include <gelf.h>
45
46#include "_elftc.h"
47
41#include <unistd.h>
42
43#include <libelf.h>
44#include <libelftc.h>
45#include <gelf.h>
46
47#include "_elftc.h"
48
48ELFTC_VCSID("$Id: strings.c 3174 2015-03-27 17:13:41Z emaste $");
49ELFTC_VCSID("$Id: strings.c 3360 2016-01-24 18:34:06Z jkoshy $");
49
50enum return_code {
51 RETURN_OK,
52 RETURN_NOINPUT,
53 RETURN_SOFTWARE
54};
55
56enum radix_style {

--- 11 unchanged lines hidden (view full) ---

68 ENCODING_32BIT_LITTLE
69};
70
71#define PRINTABLE(c) \
72 ((c) >= 0 && (c) <= 255 && \
73 ((c) == '\t' || isprint((c)) || \
74 (encoding == ENCODING_8BIT && (c) > 127)))
75
50
51enum return_code {
52 RETURN_OK,
53 RETURN_NOINPUT,
54 RETURN_SOFTWARE
55};
56
57enum radix_style {

--- 11 unchanged lines hidden (view full) ---

69 ENCODING_32BIT_LITTLE
70};
71
72#define PRINTABLE(c) \
73 ((c) >= 0 && (c) <= 255 && \
74 ((c) == '\t' || isprint((c)) || \
75 (encoding == ENCODING_8BIT && (c) > 127)))
76
76
77static int encoding_size, entire_file, min_len, show_filename, show_loc;
77static int encoding_size, entire_file, show_filename, show_loc;
78static enum encoding_style encoding;
79static enum radix_style radix;
78static enum encoding_style encoding;
79static enum radix_style radix;
80static intmax_t min_len;
80
81static struct option strings_longopts[] = {
82 { "all", no_argument, NULL, 'a'},
83 { "bytes", required_argument, NULL, 'n'},
84 { "encoding", required_argument, NULL, 'e'},
85 { "help", no_argument, NULL, 'h'},
86 { "print-file-name", no_argument, NULL, 'f'},
87 { "radix", required_argument, NULL, 't'},

--- 51 unchanged lines hidden (view full) ---

139 } else
140 usage();
141 /* NOTREACHED */
142 break;
143 case 'f':
144 show_filename = 1;
145 break;
146 case 'n':
81
82static struct option strings_longopts[] = {
83 { "all", no_argument, NULL, 'a'},
84 { "bytes", required_argument, NULL, 'n'},
85 { "encoding", required_argument, NULL, 'e'},
86 { "help", no_argument, NULL, 'h'},
87 { "print-file-name", no_argument, NULL, 'f'},
88 { "radix", required_argument, NULL, 't'},

--- 51 unchanged lines hidden (view full) ---

140 } else
141 usage();
142 /* NOTREACHED */
143 break;
144 case 'f':
145 show_filename = 1;
146 break;
147 case 'n':
147 min_len = (int)strtoimax(optarg, (char**)NULL, 10);
148 min_len = strtoimax(optarg, (char**)NULL, 10);
149 if (min_len <= 0)
150 errx(EX_USAGE, "option -n should specify a "
151 "positive decimal integer.");
148 break;
149 case 'o':
150 show_loc = 1;
151 radix = RADIX_OCTAL;
152 break;
153 case 't':
154 show_loc = 1;
155 if (*optarg == 'd')

--- 298 unchanged lines hidden ---
152 break;
153 case 'o':
154 show_loc = 1;
155 radix = RADIX_OCTAL;
156 break;
157 case 't':
158 show_loc = 1;
159 if (*optarg == 'd')

--- 298 unchanged lines hidden ---