1 /*** bucomm.c -- Bin Utils COMmon code.
3 We might put this in a library someday so it could be dynamically
4 loaded, but for now it's not necessary */
10 char *target = NULL; /* default as late as possible */
12 /* Yes, this is what atexit is for, but that isn't guaranteed yet.
13 And yes, I know this isn't as good, but it does what is needed just fine */
14 void (*exit_handler) ();
18 PROTO (char *, malloc, (unsigned size));
19 PROTO (char *, realloc, (char *ptr, unsigned size));
30 char *errmsg = bfd_errmsg (bfd_error);
33 fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg);
35 fprintf (stderr, "%s: %s\n", program_name, errmsg);
37 if (NULL != exit_handler) (*exit_handler) ();
48 va_start (args, Format);
49 vfprintf (stderr, Format, args);
51 (void) putc ('\n', stderr);
52 if (NULL != exit_handler) (*exit_handler) ();
64 Format = va_arg(args, char *);
65 vfprintf (stderr, Format, args);
67 (void) putc ('\n', stderr);
68 if (NULL != exit_handler) (*exit_handler) ();
77 _doprnt (Format, &args, stderr); /* not terribly portable, but... */
78 (void) putc ('\n', stderr);
79 if (NULL != exit_handler) (*exit_handler) ();
82 #endif /* not NO_VARARGS */
83 #endif /* not NO_STDARG */
86 /** Display the archive header for an element as if it were an ls -l listing */
88 /* Mode User\tGroup\tSize\tDate Name */
91 print_arelt_descr (abfd, verbose)
99 long current_time = time ((long *) 0);
103 if (bfd_stat_arch_elt (abfd, &buf) == 0) { /* if not, huh? */
105 mode_string (buf.st_mode, modebuf);
107 fputs (modebuf, stdout);
110 strcpy (timebuf, ctime (&when));
112 /* This code comes from gnu ls. */
113 if ((current_time - when > 6 * 30 * 24 * 60 * 60)
114 || (current_time - when < 0)) {
115 /* The file is fairly old or in the future.
116 POSIX says the cutoff is 6 months old;
117 approximate this by 6*30 days.
118 Show the year instead of the time of day. */
119 strcpy (timebuf + 11, timebuf + 19);
123 printf (" %d\t%d\t%ld\t%s ", buf.st_uid, buf.st_gid, buf.st_size, timebuf);
127 puts (abfd->filename);
130 /* Like malloc but get fatal error if memory is exhausted. */
135 register char *result = malloc (size);
136 if (result == NULL && size != NULL) fatal ("virtual memory exhausted");
141 /* Like realloc but get fatal error if memory is exhausted. */
147 register char *result = realloc (ptr, size);
148 if (result == 0 && size != 0) fatal ("virtual memory exhausted");