removed rcs cruft
[deliverable/binutils-gdb.git] / binutils / bucomm.c
CommitLineData
b886a6e3
JG
1/* bucomm.c -- Bin Utils COMmon code.
2 Copyright (C) 1991 Free Software Foundation, Inc.
2fa0b342 3
096aefc0 4 This file is part of GNU Binutils.
b886a6e3 5
096aefc0
KR
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
b886a6e3 10
096aefc0
KR
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
b886a6e3 15
096aefc0
KR
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19\f
20/* We might put this in a library someday so it could be dynamically
21 loaded, but for now it's not necessary. */
2fa0b342 22
2fa0b342 23#include "bfd.h"
b886a6e3 24#include "sysdep.h"
0886e098
SS
25#include "bucomm.h"
26
27#ifdef __STDC__
28#include <stdarg.h>
29#else
2fa0b342 30#include <varargs.h>
0886e098 31#endif
2fa0b342
DHW
32
33char *target = NULL; /* default as late as possible */
34
35/* Yes, this is what atexit is for, but that isn't guaranteed yet.
096aefc0 36 And yes, I know this isn't as good, but it does what is needed just fine. */
2fa0b342 37void (*exit_handler) ();
2fa0b342 38
2fa0b342 39
2fa0b342
DHW
40/* Error reporting */
41
42char *program_name;
43
44void
096aefc0 45bfd_nonfatal (string)
0886e098 46 CONST char *string;
2fa0b342 47{
096aefc0
KR
48 CONST char *errmsg = bfd_errmsg (bfd_error);
49
2fa0b342
DHW
50 if (string)
51 fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg);
52 else
53 fprintf (stderr, "%s: %s\n", program_name, errmsg);
096aefc0 54}
2fa0b342 55
096aefc0
KR
56void
57bfd_fatal (string)
0886e098 58 CONST char *string;
096aefc0
KR
59{
60 bfd_nonfatal (string);
61
62 if (NULL != exit_handler)
63 (*exit_handler) ();
2fa0b342
DHW
64 exit (1);
65}
66
0886e098 67#ifdef __STDC__
2fa0b342 68void
0886e098 69fatal (const char *format, ...)
2fa0b342
DHW
70{
71 va_list args;
096aefc0
KR
72
73 fprintf (stderr, "%s: ", program_name);
0886e098
SS
74 va_start (args, format);
75 vfprintf (stderr, format, args);
2fa0b342 76 va_end (args);
096aefc0
KR
77 putc ('\n', stderr);
78 if (NULL != exit_handler)
79 (*exit_handler) ();
2fa0b342
DHW
80 exit (1);
81}
82#else
096aefc0
KR
83void
84fatal (va_alist)
2fa0b342
DHW
85 va_dcl
86{
096aefc0
KR
87 char *Format;
88 va_list args;
2fa0b342 89
096aefc0
KR
90 fprintf (stderr, "%s: ", program_name);
91 va_start (args);
92 Format = va_arg (args, char *);
93 vfprintf (stderr, Format, args);
94 va_end (args);
95 putc ('\n', stderr);
96 if (NULL != exit_handler)
97 (*exit_handler) ();
98 exit (1);
99}
100#endif
2fa0b342 101\f
096aefc0
KR
102/* Display the archive header for an element as if it were an ls -l listing:
103
104 Mode User\tGroup\tSize\tDate Name */
2fa0b342
DHW
105
106void
096aefc0
KR
107print_arelt_descr (file, abfd, verbose)
108 FILE *file;
109 bfd *abfd;
110 boolean verbose;
2fa0b342
DHW
111{
112 struct stat buf;
2fa0b342 113
096aefc0
KR
114 if (verbose)
115 {
116 if (bfd_stat_arch_elt (abfd, &buf) == 0)
117 {
118 char modebuf[11];
119 char timebuf[40];
0886e098 120 time_t when = buf.st_mtime;
096aefc0
KR
121 CONST char *ctime_result = (CONST char *) ctime (&when);
122
123 /* POSIX format: skip weekday and seconds from ctime output. */
124 sprintf (timebuf, "%.12s %.4s", ctime_result + 4, ctime_result + 20);
125
126 mode_string (buf.st_mode, modebuf);
127 modebuf[10] = '\0';
128 /* POSIX 1003.2/D11 says to skip first character (entry type). */
129 fprintf (file, "%s %d/%d %6ld %s ", modebuf + 1,
130 buf.st_uid, buf.st_gid, buf.st_size, timebuf);
131 }
2fa0b342 132 }
2fa0b342 133
096aefc0 134 fprintf (file, "%s\n", abfd->filename);
2fa0b342 135}
This page took 0.100519 seconds and 4 git commands to generate.