/[gentoo-projects]/pax-utils/scanelf.c
Gentoo

Diff of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.20 Revision 1.21
1/* 1/*
2 * Copyright 2003 Ned Ludd <solar@gentoo.org> 2 * Copyright 2003 Ned Ludd <solar@gentoo.org>
3 * Copyright 1999-2005 Gentoo Foundation 3 * Copyright 1999-2005 Gentoo Foundation
4 * Distributed under the terms of the GNU General Public License v2 4 * Distributed under the terms of the GNU General Public License v2
5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.20 2005/04/02 19:06:36 solar Exp $ 5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.21 2005/04/03 16:02:25 solar Exp $
6 * 6 *
7 ******************************************************************** 7 ********************************************************************
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the 10 * published by the Free Software Foundation; either version 2 of the
29#include <unistd.h> 29#include <unistd.h>
30#include <sys/stat.h> 30#include <sys/stat.h>
31#include <dirent.h> 31#include <dirent.h>
32#include <getopt.h> 32#include <getopt.h>
33#include <assert.h> 33#include <assert.h>
34
34#include "paxelf.h" 35#include "paxelf.h"
35 36
36static const char *rcsid = "$Id: scanelf.c,v 1.20 2005/04/02 19:06:36 solar Exp $"; 37static const char *rcsid = "$Id: scanelf.c,v 1.21 2005/04/03 16:02:25 solar Exp $";
37 38
38 39
39/* helper functions for showing errors */ 40/* helper functions for showing errors */
40#define argv0 "scanelf" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/ 41#define argv0 "scanelf" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/
41#define warn(fmt, args...) \ 42#define warn(fmt, args...) \
188static void scanelf_dir(const char *path) 189static void scanelf_dir(const char *path)
189{ 190{
190 register DIR *dir; 191 register DIR *dir;
191 register struct dirent *dentry; 192 register struct dirent *dentry;
192 struct stat st_top, st; 193 struct stat st_top, st;
193 char buf[PATH_MAX]; 194 char buf[_POSIX_PATH_MAX];
194 size_t len = 0; 195 size_t len = 0;
195 196
196 /* make sure path exists */ 197 /* make sure path exists */
197 if (lstat(path, &st_top) == -1) 198 if (lstat(path, &st_top) == -1)
198 return; 199 return;
285} 286}
286 287
287 288
288 289
289/* usage / invocation handling functions */ 290/* usage / invocation handling functions */
290#define PARSE_FLAGS "plRmxetraqvBhV" 291#define PARSE_FLAGS "plRmxetro:aqvBhV"
291static struct option const long_opts[] = { 292static struct option const long_opts[] = {
292 {"path", no_argument, NULL, 'p'}, 293 {"path", no_argument, NULL, 'p'},
293 {"ldpath", no_argument, NULL, 'l'}, 294 {"ldpath", no_argument, NULL, 'l'},
294 {"recursive", no_argument, NULL, 'R'}, 295 {"recursive", no_argument, NULL, 'R'},
295 {"mount", no_argument, NULL, 'm'}, 296 {"mount", no_argument, NULL, 'm'},
296 {"pax", no_argument, NULL, 'x'}, 297 {"pax", no_argument, NULL, 'x'},
297 {"header", no_argument, NULL, 'e'}, 298 {"header", no_argument, NULL, 'e'},
298 {"textrel", no_argument, NULL, 't'}, 299 {"textrel", no_argument, NULL, 't'},
299 {"rpath", no_argument, NULL, 'r'}, 300 {"rpath", no_argument, NULL, 'r'},
301 {"file",required_argument, NULL, 'o'},
300 {"all", no_argument, NULL, 'a'}, 302 {"all", no_argument, NULL, 'a'},
301 {"quiet", no_argument, NULL, 'q'}, 303 {"quiet", no_argument, NULL, 'q'},
302 {"verbose", no_argument, NULL, 'v'}, 304 {"verbose", no_argument, NULL, 'v'},
303 {"nobanner", no_argument, NULL, 'B'}, 305 {"nobanner", no_argument, NULL, 'B'},
304 {"help", no_argument, NULL, 'h'}, 306 {"help", no_argument, NULL, 'h'},
312 "Don't recursively cross mount points\n", 314 "Don't recursively cross mount points\n",
313 "Print PaX markings", 315 "Print PaX markings",
314 "Print GNU_STACK markings", 316 "Print GNU_STACK markings",
315 "Print TEXTREL information", 317 "Print TEXTREL information",
316 "Print RPATH information", 318 "Print RPATH information",
319 "Write output stream to a filename",
317 "Print all scanned info (-x -e -t -r)\n", 320 "Print all scanned info (-x -e -t -r)\n",
318 "Only output 'bad' things", 321 "Only output 'bad' things",
319 "Be verbose (can be specified more than once)", 322 "Be verbose (can be specified more than once)",
320 "Don't display the header", 323 "Don't display the header",
321 "Print this help and exit", 324 "Print this help and exit",
357 exit(EXIT_SUCCESS); 360 exit(EXIT_SUCCESS);
358 break; 361 break;
359 case 's': /* reserved for -s, --symbol= */ 362 case 's': /* reserved for -s, --symbol= */
360 case 'h': usage(EXIT_SUCCESS); break; 363 case 'h': usage(EXIT_SUCCESS); break;
361 364
365 case 'o':
366 {
367 FILE *fp = NULL;
368 fp = freopen(optarg, "w", stdout);
369 if (fp == NULL) {
370 fputs("open ", stderr);
371 perror(optarg);
372 } else
373 stdout = fp;
374 break;
375 }
362 case 'B': show_banner = 0; break; 376 case 'B': show_banner = 0; break;
363 case 'l': scan_ldpath = 1; break; 377 case 'l': scan_ldpath = 1; break;
364 case 'p': scan_envpath = 1; break; 378 case 'p': scan_envpath = 1; break;
365 case 'R': dir_recurse = 1; break; 379 case 'R': dir_recurse = 1; break;
366 case 'm': dir_crossmount = 0; break; 380 case 'm': dir_crossmount = 0; break;
400int main(int argc, char *argv[]) 414int main(int argc, char *argv[])
401{ 415{
402 if (argc < 2) 416 if (argc < 2)
403 usage(EXIT_FAILURE); 417 usage(EXIT_FAILURE);
404 parseargs(argc, argv); 418 parseargs(argc, argv);
419 fclose(stdout);
405 return EXIT_SUCCESS; 420 return EXIT_SUCCESS;
406} 421}

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20