/[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.4 Revision 1.5
1/* 1/*
2 * Copyright 2003 Ned Ludd <solar@gentoo.org> 2 * Copyright 2003 Ned Ludd <solar@gentoo.org>
3 * Copyright 1999-2003 Gentoo Technologies, Inc. 3 * Copyright 1999-2003 Gentoo Technologies, Inc.
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.4 2003/11/01 08:58:23 solar Exp $ 5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.5 2003/11/09 17:46:41 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
31#include <getopt.h> 31#include <getopt.h>
32 32
33#include "paxelf.h" 33#include "paxelf.h"
34 34
35static const char *rcsid = 35static const char *rcsid =
36 "$Id: scanelf.c,v 1.4 2003/11/01 08:58:23 solar Exp $"; 36 "$Id: scanelf.c,v 1.5 2003/11/09 17:46:41 solar Exp $";
37 37
38#define PARSE_FLAGS "hvlp" 38#define PARSE_FLAGS "hvlp"
39static struct option const long_options[] = { 39static struct option const long_options[] = {
40 {"help", no_argument, 0, 'h'}, 40 {"help", no_argument, 0, 'h'},
41 {"version", no_argument, 0, 'v'}, 41 {"version", no_argument, 0, 'v'},
59 if (IS_ELF(elf)) 59 if (IS_ELF(elf))
60 printf("%s %s %s/%s\n", 60 printf("%s %s %s/%s\n",
61 pax_short_flags(PAX_FLAGS(elf)), 61 pax_short_flags(PAX_FLAGS(elf)),
62 get_elfetype(elf->ehdr->e_type), path, 62 get_elfetype(elf->ehdr->e_type), path,
63 dentry->d_name); 63 dentry->d_name);
64
64 if (elf != NULL) { 65 if (elf != NULL) {
65 munmap(elf->data, elf->len); 66 munmap(elf->data, elf->len);
66 free(elf); 67 free(elf);
67 elf = NULL; 68 elf = NULL;
68 } 69 }
72 } 73 }
73} 74}
74 75
75 76
76/* display usage and exit */ 77/* display usage and exit */
77int usage(char **argv) 78void usage(char **argv)
78{ 79{
79 fprintf(stderr, 80 fprintf(stderr,
80 "Usage: %s [options] dir1 dir2 dirN...\n", 81 "Usage: %s [options] dir1 dir2 dirN...\n",
81 (*argv != NULL) ? argv[0] : __FILE__ "\b\b"); 82 (*argv != NULL) ? argv[0] : __FILE__ "\b\b");
82 exit(EXIT_FAILURE);
83} 83}
84 84
85 85
86void showopt(int c, char *data) 86void showopt(int c, char *data)
87{ 87{
103 while ((flag = 103 while ((flag =
104 (int) getopt_long(argc, argv, 104 (int) getopt_long(argc, argv,
105 PARSE_FLAGS, long_options, NULL)) != EOF) { 105 PARSE_FLAGS, long_options, NULL)) != EOF) {
106 switch (flag) { 106 switch (flag) {
107 case 'h': 107 case 'h':
108 usage(argv);
108 showopt('p', "Scan all directories in PATH environment."); 109 showopt('p', "Scan all directories in PATH environment.");
109 showopt('l', "Scan all directories in /etc/ld.so.conf"); 110 showopt('l', "Scan all directories in /etc/ld.so.conf");
110 showopt('h', "Print this help and exit."); 111 showopt('h', "Print this help and exit.");
111 showopt('v', "Print version and exit."); 112 showopt('v', "Print version and exit.");
112 exit(EXIT_SUCCESS); 113 exit(EXIT_SUCCESS);
154 scanelf(argv[optind++]); 155 scanelf(argv[optind++]);
155} 156}
156 157
157int main(int argc, char **argv) 158int main(int argc, char **argv)
158{ 159{
159 if (argc < 2) 160 if (argc < 2) {
160 usage(argv); 161 usage(argv);
162 exit(EXIT_FAILURE);
163 }
161 parseargs(argc, argv); 164 parseargs(argc, argv);
162 return 0; 165 return 0;
163} 166}

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.20