/[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.10 Revision 1.11
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/Attic/scanelf.c,v 1.10 2005/03/30 23:43:30 vapier Exp $ 5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/Attic/scanelf.c,v 1.11 2005/03/31 00:03: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
31#include <dirent.h> 31#include <dirent.h>
32#include <getopt.h> 32#include <getopt.h>
33 33
34#include "paxelf.h" 34#include "paxelf.h"
35 35
36static const char *rcsid = "$Id: scanelf.c,v 1.10 2005/03/30 23:43:30 vapier Exp $"; 36static const char *rcsid = "$Id: scanelf.c,v 1.11 2005/03/31 00:03:25 solar Exp $";
37 37
38 38
39/* helper functions for showing errors */ 39/* helper functions for showing errors */
40#define argv0 "scanelf\0" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/ 40#define argv0 "scanelf\0" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/
41#define warn(fmt, args...) \ 41#define warn(fmt, args...) \
174 int len = 0; 174 int len = 0;
175 175
176 /* make sure path exists */ 176 /* make sure path exists */
177 if (lstat(path, &st) == -1) 177 if (lstat(path, &st) == -1)
178 return; 178 return;
179
179 /* ok, if it isn't a directory, assume we can open it */ 180 /* ok, if it isn't a directory, assume we can open it */
180 if (!S_ISDIR(st.st_mode)) { 181 if (!S_ISDIR(st.st_mode)) {
181 scanelf_file(path); 182 scanelf_file(path);
182 return; 183 return;
183 } 184 }
185 /* now scan the dir looking for fun stuff */ 186 /* now scan the dir looking for fun stuff */
186 if ((dir = opendir(path)) == NULL) { 187 if ((dir = opendir(path)) == NULL) {
187 warnf("could not opendir %s: %s", path, strerror(errno)); 188 warnf("could not opendir %s: %s", path, strerror(errno));
188 return; 189 return;
189 } 190 }
191
190 while ((dentry = readdir(dir))) { 192 while ((dentry = readdir(dir))) {
191 if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, "..")) 193 if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, ".."))
192 continue; 194 continue;
193 len = (strlen(path) + 2 + strlen(dentry->d_name)); 195 len = (strlen(path) + 2 + strlen(dentry->d_name));
194 p = malloc(len); 196 p = malloc(len);
308 while ((flag=getopt_long(argc, argv, PARSE_FLAGS, long_opts, NULL)) != -1) { 310 while ((flag=getopt_long(argc, argv, PARSE_FLAGS, long_opts, NULL)) != -1) {
309 switch (flag) { 311 switch (flag) {
310 312
311 case 'V': /* version info */ 313 case 'V': /* version info */
312 printf("%s compiled %s\n" 314 printf("%s compiled %s\n"
313 "%s written for Gentoo Linux by <solar@gentoo.org>\n" 315 "%s written for Gentoo Linux by <solar and vapier @ gentoo.org>\n"
314 "%s\n", 316 "%s\n",
315 __FILE__, __DATE__, argv0, rcsid); 317 __FILE__, __DATE__, argv0, rcsid);
316 exit(EXIT_SUCCESS); 318 exit(EXIT_SUCCESS);
317 break; 319 break;
318 case 'h': usage(EXIT_SUCCESS); break; 320 case 'h': usage(EXIT_SUCCESS); break;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20