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

Diff of /pax-utils/scanmacho.c

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

Revision 1.12 Revision 1.13
1/* 1/*
2 * Copyright 2008 Gentoo Foundation 2 * Copyright 2008 Gentoo Foundation
3 * Distributed under the terms of the GNU General Public License v2 3 * Distributed under the terms of the GNU General Public License v2
4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.12 2008/12/30 13:27:09 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.13 2008/12/30 13:34:46 vapier Exp $
5 * 5 *
6 * based on scanelf by: 6 * based on scanelf by:
7 * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> 7 * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org>
8 * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> 8 * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org>
9 * for Darwin specific fun: 9 * for Darwin specific fun:
10 * 2008 Fabian Groffen - <grobian@gentoo.org> 10 * 2008 Fabian Groffen - <grobian@gentoo.org>
11 */ 11 */
12 12
13static const char *rcsid = "$Id: scanmacho.c,v 1.12 2008/12/30 13:27:09 vapier Exp $"; 13static const char *rcsid = "$Id: scanmacho.c,v 1.13 2008/12/30 13:34:46 vapier Exp $";
14const char * const argv0 = "scanmacho"; 14const char * const argv0 = "scanmacho";
15 15
16#include "paxinc.h" 16#include "paxinc.h"
17 17
18#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') 18#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+')
51static char g_match = 0; 51static char g_match = 0;
52 52
53static int match_bits = 0; 53static int match_bits = 0;
54static unsigned int match_perms = 0; 54static unsigned int match_perms = 0;
55 55
56static const char *getstr_perms(const char *fname)
57{
58 struct stat st;
59 static char buf[8];
60
61 if (stat(fname, &st) == -1)
62 return "";
63
64 snprintf(buf, sizeof(buf), "%o", st.st_mode);
65
66 return buf + 2;
67}
68
69static const char *macho_file_needed_lib( 56static const char *macho_file_needed_lib(
70 fatobj *fobj, 57 fatobj *fobj,
71 char *found_needed, 58 char *found_needed,
72 char *found_lib, 59 char *found_lib,
73 int op, 60 int op,
265 xstrcat(&out_buffer, fobj->base_filename, &out_len); 252 xstrcat(&out_buffer, fobj->base_filename, &out_len);
266 break; 253 break;
267 case 'o': out = get_machomhtype(fobj); break; 254 case 'o': out = get_machomhtype(fobj); break;
268 case 'M': out = get_machocputype(fobj); break; 255 case 'M': out = get_machocputype(fobj); break;
269 case 'D': out = get_machoendian(fobj); break; 256 case 'D': out = get_machoendian(fobj); break;
270 case 'O': out = getstr_perms(fobj->filename); break; 257 case 'O': out = strfileperms(fobj->filename); break;
271 case 'n': 258 case 'n':
272 case 'N': out = macho_file_needed_lib(fobj, &found_needed, &found_lib, (out_format[i]=='N'), &out_buffer, &out_len); break; 259 case 'N': out = macho_file_needed_lib(fobj, &found_needed, &found_lib, (out_format[i]=='N'), &out_buffer, &out_len); break;
273 case 'i': out = macho_file_interp(fobj, &found_interp); break; 260 case 'i': out = macho_file_interp(fobj, &found_interp); break;
274 case 'b': get_machomhflags(fobj, &out_buffer, &out_len); break; 261 case 'b': get_machomhflags(fobj, &out_buffer, &out_len); break;
275 case 'S': out = macho_file_soname(fobj, &found_soname); break; 262 case 'S': out = macho_file_soname(fobj, &found_soname); break;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20