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> |
41#include <unistd.h> 42 43#include <libelf.h> 44#include <libelftc.h> 45#include <gelf.h> 46 47#include "_elftc.h" 48 |
49ELFTC_VCSID("$Id: strings.c 3360 2016-01-24 18:34:06Z jkoshy $"); |
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 |
77static int encoding_size, entire_file, show_filename, show_loc; |
78static enum encoding_style encoding; 79static enum radix_style radix; |
80static intmax_t min_len; |
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': |
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."); |
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 --- |