/[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.1 Revision 1.2
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.1 2008/09/08 07:02:56 grobian Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.2 2008/09/08 08:01:35 grobian 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.1 2008/09/08 07:02:56 grobian Exp $"; 13static const char *rcsid = "$Id: scanmacho.c,v 1.2 2008/09/08 08:01:35 grobian 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 == '+')
328 } 328 }
329 329
330 return 0; 330 return 0;
331} 331}
332 332
333/* scan a single elf */ 333/* scan a single Mach-O */
334static int scanmacho_fat(const char *filename, int fd, size_t len) 334static int scanmacho_fat(const char *filename, int fd, size_t len)
335{ 335{
336 int ret = 1; 336 int ret = 1;
337 fatobj *fobj; 337 fatobj *fobj;
338 fatobj *walk; 338 fatobj *walk;
355 } while (walk->next != NULL && (walk = walk->next)); 355 } while (walk->next != NULL && (walk = walk->next));
356 goto label_done; 356 goto label_done;
357 default: 357 default:
358 break; 358 break;
359 } 359 }
360 /* TODO: match match_etypes against fobj->mhdr.hdr32.filetype */
361#if 0
362 if (strlen(match_etypes)) { 360 if (strlen(match_etypes)) {
363 char sbuf[126]; 361 char sbuf[128];
364 strncpy(sbuf, match_etypes, sizeof(sbuf)); 362 char ftype[32];
365 if (strchr(match_etypes, ',') != NULL) { 363
366 char *p; 364 snprintf(sbuf, 128, ",%s,", match_etypes);
367 while ((p = strrchr(sbuf, ',')) != NULL) { 365
368 *p = 0; 366 walk = fobj;
369 if (etype_lookup(p+1) == get_etype(elf)) 367 do {
370 goto label_ret; 368 snprintf(ftype, 32, ",%s,", get_machomhtype(walk));
371 } 369 if (strstr(sbuf, ftype) != NULL) {
370 ret = scanmacho_fatobj(walk);
372 } 371 }
373 if (etype_lookup(sbuf) != get_etype(elf)) 372 } while (walk->next != NULL && (walk = walk->next));
374 goto label_done; 373 goto label_done;
375 } 374 }
376label_ret: 375
377#endif
378 walk = fobj; 376 walk = fobj;
379 do { 377 do {
380 ret = scanmacho_fatobj(walk); 378 ret = scanmacho_fatobj(walk);
381 } while (walk->next != NULL && (walk = walk->next)); 379 } while (walk->next != NULL && (walk = walk->next));
382 380
649 case 'E': 647 case 'E':
650 strncpy(match_etypes, optarg, sizeof(match_etypes)); 648 strncpy(match_etypes, optarg, sizeof(match_etypes));
651 break; 649 break;
652 case 'M': 650 case 'M':
653 match_bits = atoi(optarg); 651 match_bits = atoi(optarg);
654 if (match_bits == 0) {
655 if (strcmp(optarg, "ELFCLASS32") == 0)
656 match_bits = 32;
657 if (strcmp(optarg, "ELFCLASS64") == 0)
658 match_bits = 64;
659 }
660 break; 652 break;
661 case 'O': 653 case 'O':
662 if (sscanf(optarg, "%o", &match_perms) == (-1)) 654 if (sscanf(optarg, "%o", &match_perms) == (-1))
663 match_bits = 0; 655 match_bits = 0;
664 break; 656 break;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20