Annotation of src/external/gpl3/binutils/dist/binutils/binemul.c, Revision 1.1.1.2.2.1
1.1 skrll 1: /* Binutils emulation layer.
1.1.1.2.2.1! yamt 2: Copyright 2002, 2003, 2005, 2007, 2008, 2010
! 3: Free Software Foundation, Inc.
1.1 skrll 4: Written by Tom Rix, Red Hat Inc.
5:
6: This file is part of GNU Binutils.
7:
8: This program is free software; you can redistribute it and/or modify
9: it under the terms of the GNU General Public License as published by
10: the Free Software Foundation; either version 3 of the License, or
11: (at your option) any later version.
12:
13: This program is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: GNU General Public License for more details.
17:
18: You should have received a copy of the GNU General Public License
19: along with this program; if not, write to the Free Software
20: Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21: MA 02110-1301, USA. */
22:
23: #include "binemul.h"
24:
25: extern bin_emulation_xfer_type bin_dummy_emulation;
26:
27: void
28: ar_emul_usage (FILE *fp)
29: {
30: if (bin_dummy_emulation.ar_usage)
31: bin_dummy_emulation.ar_usage (fp);
32: }
33:
34: void
35: ar_emul_default_usage (FILE *fp)
36: {
37: AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp);
38: /* xgettext:c-format */
39: fprintf (fp, _(" No emulation specific options\n"));
40: }
41:
42: bfd_boolean
1.1.1.2 christos 43: ar_emul_append (bfd **after_bfd, char *file_name, const char *target,
44: bfd_boolean verbose, bfd_boolean flatten)
1.1 skrll 45: {
46: if (bin_dummy_emulation.ar_append)
1.1.1.2 christos 47: return bin_dummy_emulation.ar_append (after_bfd, file_name, target,
48: verbose, flatten);
1.1 skrll 49:
50: return FALSE;
51: }
52:
53: static bfd_boolean
1.1.1.2.2.1! yamt 54: any_ok (bfd *new_bfd ATTRIBUTE_UNUSED)
! 55: {
! 56: return TRUE;
! 57: }
! 58:
! 59: bfd_boolean
! 60: do_ar_emul_append (bfd **after_bfd, bfd *new_bfd,
! 61: bfd_boolean verbose, bfd_boolean flatten,
! 62: bfd_boolean (*check) (bfd *))
! 63: {
1.1 skrll 64: /* When flattening, add the members of an archive instead of the
65: archive itself. */
66: if (flatten && bfd_check_format (new_bfd, bfd_archive))
67: {
68: bfd *elt;
69: bfd_boolean added = FALSE;
70:
71: for (elt = bfd_openr_next_archived_file (new_bfd, NULL);
72: elt;
73: elt = bfd_openr_next_archived_file (new_bfd, elt))
74: {
1.1.1.2.2.1! yamt 75: if (do_ar_emul_append (after_bfd, elt, verbose, TRUE, check))
1.1 skrll 76: {
77: added = TRUE;
78: after_bfd = &((*after_bfd)->archive_next);
79: }
80: }
81:
82: return added;
83: }
84:
1.1.1.2.2.1! yamt 85: if (!check (new_bfd))
! 86: return FALSE;
! 87:
1.1 skrll 88: AR_EMUL_APPEND_PRINT_VERBOSE (verbose, new_bfd->filename);
89:
90: new_bfd->archive_next = *after_bfd;
91: *after_bfd = new_bfd;
92:
93: return TRUE;
94: }
95:
96: bfd_boolean
97: ar_emul_default_append (bfd **after_bfd, char *file_name,
1.1.1.2 christos 98: const char *target, bfd_boolean verbose,
99: bfd_boolean flatten)
1.1 skrll 100: {
101: bfd *new_bfd;
102:
1.1.1.2 christos 103: new_bfd = bfd_openr (file_name, target);
1.1 skrll 104: AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
1.1.1.2.2.1! yamt 105: return do_ar_emul_append (after_bfd, new_bfd, verbose, flatten, any_ok);
1.1 skrll 106: }
107:
108: bfd_boolean
1.1.1.2 christos 109: ar_emul_replace (bfd **after_bfd, char *file_name, const char *target,
110: bfd_boolean verbose)
1.1 skrll 111: {
112: if (bin_dummy_emulation.ar_replace)
1.1.1.2 christos 113: return bin_dummy_emulation.ar_replace (after_bfd, file_name,
114: target, verbose);
1.1 skrll 115:
116: return FALSE;
117: }
118:
119: bfd_boolean
120: ar_emul_default_replace (bfd **after_bfd, char *file_name,
1.1.1.2 christos 121: const char *target, bfd_boolean verbose)
1.1 skrll 122: {
1.1.1.2.2.1! yamt 123: bfd *new_bfd;
1.1 skrll 124:
1.1.1.2.2.1! yamt 125: new_bfd = bfd_openr (file_name, target);
! 126: AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
1.1 skrll 127:
128: AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name);
129:
1.1.1.2.2.1! yamt 130: new_bfd->archive_next = *after_bfd;
! 131: *after_bfd = new_bfd;
1.1 skrll 132:
133: return TRUE;
134: }
135:
136: bfd_boolean
137: ar_emul_parse_arg (char *arg)
138: {
139: if (bin_dummy_emulation.ar_parse_arg)
140: return bin_dummy_emulation.ar_parse_arg (arg);
141:
142: return FALSE;
143: }
144:
145: bfd_boolean
146: ar_emul_default_parse_arg (char *arg ATTRIBUTE_UNUSED)
147: {
148: return FALSE;
149: }
CVSweb <webmaster@jp.NetBSD.org>