⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srch_strings.c

📁 linux下开发的针对所有磁盘的数据恢复的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* From binutils-2.15  * removed getopt_long stuff *   *//* strings -- print the strings of printable characters in files   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,   2002, 2003 Free Software Foundation, Inc.   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, 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., 59 Temple Place - Suite 330, Boston, MA   02111-1307, USA.  *//* Usage: strings [options] file...   Options:   -a   -		Do not scan only the initialized data section of object files.   -f		Print the name of the file before each string.   -n min-len   -min-len	Print graphic char sequences, MIN-LEN or more bytes long,		that are followed by a NUL or a newline.  Default is 4.   -t {o,x,d}	Print the offset within the file before each string,		in octal/hex/decimal.   -o		Like -to.  (Some other implementations have -o like -to,		others like -td.  We chose one arbitrarily.)   -e {s,S,b,l,B,L}		Select character encoding: 7-bit-character, 8-bit-character,		bigendian 16-bit, littleendian 16-bit, bigendian 32-bit,		littleendian 32-bit.   -h		Print the usage message on the standard output.   -v		Print the program version number.   Written by Richard Stallman <rms@gnu.ai.mit.edu>   and David MacKenzie <djm@gnu.ai.mit.edu>.  */#if HAVE_CONFIG_H#include "tsk_config.h"#endif#include <sys/types.h>#include <sys/stat.h>#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <unistd.h>#include <string.h>#include <inttypes.h>/* Some platforms need to put stdin into binary mode, to read    binary files.  */#ifdef HAVE_SETMODE#ifndef O_BINARY#ifdef _O_BINARY#define O_BINARY _O_BINARY#define setmode _setmode#else#define O_BINARY 0#endif#endif#if O_BINARY#include <io.h>#define SET_BINARY(f) do { if (!isatty (f)) setmode (f,O_BINARY); } while (0)#endif#endif#ifndef PRIx64#define PRIx64 "llx"#endif#ifndef PRId64#define PRId64 "lld"#endif#ifndef PRIo64#define PRIo64 "llo"#endif/* The following were taken from other files in binutils */// from include/libiberty.henum {   /* In C99 */  _sch_isblank  = 0x0001,       /* space \t */  _sch_iscntrl  = 0x0002,       /* nonprinting characters */  _sch_isdigit  = 0x0004,       /* 0-9 */  _sch_islower  = 0x0008,       /* a-z */  _sch_isprint  = 0x0010,       /* any printing character including ' ' */  _sch_ispunct  = 0x0020,       /* all punctuation */  _sch_isspace  = 0x0040,       /* space \t \n \r \f \v */  _sch_isupper  = 0x0080,       /* A-Z */  _sch_isxdigit = 0x0100,       /* 0-9A-Fa-f */  /* Extra categories useful to cpplib.  */  _sch_isidst   = 0x0200,       /* A-Za-z_ */  _sch_isvsp    = 0x0400,       /* \n \r */  _sch_isnvsp   = 0x0800,       /* space \t \f \v \0 */  /* Combinations of the above.  */  _sch_isalpha  = _sch_isupper|_sch_islower,    /* A-Za-z */  _sch_isalnum  = _sch_isalpha|_sch_isdigit,    /* A-Za-z0-9 */  _sch_isidnum  = _sch_isidst|_sch_isdigit,     /* A-Za-z0-9_ */  _sch_isgraph  = _sch_isalnum|_sch_ispunct,    /* isprint and not space */  _sch_iscppsp  = _sch_isvsp|_sch_isnvsp,       /* isspace + \0 */  _sch_isbasic  = _sch_isprint|_sch_iscppsp     /* basic charset of ISO C                                                   (plus ` and @)  */};// from libiberty/safe-ctype.h/* Shorthand */#define bl _sch_isblank#define cn _sch_iscntrl#define di _sch_isdigit#define is _sch_isidst#define lo _sch_islower#define nv _sch_isnvsp#define pn _sch_ispunct#define pr _sch_isprint#define sp _sch_isspace#define up _sch_isupper#define vs _sch_isvsp#define xd _sch_isxdigit/* Masks.  */ #define L  (const unsigned short) (lo|is   |pr) /* lower case letter */#define XL (const unsigned short) (lo|is|xd|pr) /* lowercase hex digit */#define U  (const unsigned short) (up|is   |pr) /* upper case letter */#define XU (const unsigned short) (up|is|xd|pr) /* uppercase hex digit */#define D  (const unsigned short) (di   |xd|pr) /* decimal digit */#define P  (const unsigned short) (pn      |pr) /* punctuation */#define _  (const unsigned short) (pn|is   |pr) /* underscore */#define C  (const unsigned short) (         cn) /* control character */#define Z  (const unsigned short) (nv      |cn) /* NUL */#define M  (const unsigned short) (nv|sp   |cn) /* cursor movement: \f \v */#define V  (const unsigned short) (vs|sp   |cn) /* vertical space: \r \n */#define T  (const unsigned short) (nv|sp|bl|cn) /* tab */#define S  (const unsigned short) (nv|sp|bl|pr) /* space */const unsigned short _sch_istable[256] ={  Z,  C,  C,  C,   C,  C,  C,  C,   /* NUL SOH STX ETX  EOT ENQ ACK BEL */  C,  T,  V,  M,   M,  V,  C,  C,   /* BS  HT  LF  VT   FF  CR  SO  SI  */  C,  C,  C,  C,   C,  C,  C,  C,   /* DLE DC1 DC2 DC3  DC4 NAK SYN ETB */  C,  C,  C,  C,   C,  C,  C,  C,   /* CAN EM  SUB ESC  FS  GS  RS  US  */  S,  P,  P,  P,   P,  P,  P,  P,   /* SP  !   "   #    $   %   &   '   */  P,  P,  P,  P,   P,  P,  P,  P,   /* (   )   *   +    ,   -   .   /   */  D,  D,  D,  D,   D,  D,  D,  D,   /* 0   1   2   3    4   5   6   7   */  D,  D,  P,  P,   P,  P,  P,  P,   /* 8   9   :   ;    <   =   >   ?   */  P, XU, XU, XU,  XU, XU, XU,  U,   /* @   A   B   C    D   E   F   G   */  U,  U,  U,  U,   U,  U,  U,  U,   /* H   I   J   K    L   M   N   O   */  U,  U,  U,  U,   U,  U,  U,  U,   /* P   Q   R   S    T   U   V   W   */  U,  U,  U,  P,   P,  P,  P,  _,   /* X   Y   Z   [    \   ]   ^   _   */  P, XL, XL, XL,  XL, XL, XL,  L,   /* `   a   b   c    d   e   f   g   */  L,  L,  L,  L,   L,  L,  L,  L,   /* h   i   j   k    l   m   n   o   */  L,  L,  L,  L,   L,  L,  L,  L,   /* p   q   r   s    t   u   v   w   */  L,  L,  L,  P,   P,  P,  P,  C,   /* x   y   z   {    |   }   ~   DEL */  /* high half of unsigned char is locale-specific, so all tests are     false in "C" locale */  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,};#define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit))#define ISPRINT(c)  _sch_test(c, _sch_isprint)#define bfd_boolean unsigned char#ifndef FALSE#define FALSE 0#endif#ifndef TRUE#define TRUE 1#endifchar *program_name;/* End of stuff added by brian */#define STRING_ISGRAPHIC(c) \      (   (c) >= 0 \       && (c) <= 255 \       && ((c) == '\t' || ISPRINT (c) || (encoding == 'S' && (c) > 127)))#ifndef errnoextern int errno;#endif#ifdef HAVE_FOPEN64//typedef off64_t file_off;#define file_open(s,m) fopen64(s, m)#else//typedef off_t file_off;#define file_open(s,m) fopen(s, m)#endif/* Radix for printing addresses (must be 8, 10 or 16).  */static int address_radix;/* Minimum length of sequence of graphic chars to trigger output.  */static int string_min;/* TRUE means print address within file for each string.  */static bfd_boolean print_addresses;/* TRUE means print filename for each string.  */static bfd_boolean print_filenames;/* The character encoding format.  */static char encoding;static int encoding_bytes;static bfd_boolean strings_file (char *file);static int integer_arg (char *s);static void print_strings (const char *, FILE *, uint64_t, uint64_t, int, char *);static void usage (FILE *, int);static long get_char (FILE *, uint64_t *, int *, char **);int main (int, char **);intmain (int argc, char **argv){  int optc;  int exit_status = 0;  bfd_boolean files_given = FALSE;  program_name = argv[0];  string_min = -1;  print_addresses = FALSE;  print_filenames = FALSE;  encoding = 's';  while ((optc = getopt (argc, argv, "afhHn:ot:e:Vv0123456789")) != EOF)    {      switch (optc)	{	case 'a':	  break;	case 'f':	  print_filenames = TRUE;	  break;	case 'H':	case 'h':	  usage (stdout, 0);	case 'n':	  string_min = integer_arg (optarg);	  if (string_min < 1) {	    fprintf (stderr, "invalid number %s", optarg);	  }	  break;	case 'o':	  print_addresses = TRUE;	  address_radix = 8;	  break;	case 't':	  print_addresses = TRUE;	  if (optarg[1] != '\0')	    usage (stderr, 1);	  switch (optarg[0])	    {	    case 'o':	      address_radix = 8;	      break;	    case 'd':	      address_radix = 10;	      break;	    case 'x':	      address_radix = 16;	      break;	    default:	      usage (stderr, 1);	    }	  break;	case 'e':	  if (optarg[1] != '\0')	    usage (stderr, 1);	  encoding = optarg[0];	  break;	case 'V':	case 'v':#ifdef VER	        printf("The Sleuth Kit ver %s\n", VER);#else	        printf("The Sleuth Kit\n");#endif	  	printf("Modified version of strings from GNU binutils-2.15\n");		exit(0);	case '?':

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -