*/
#include "bfd.h"
#include "sysdep.h"
-#include "ar.h"
+#include "bucomm.h"
+#include "aout/ar.h"
+#include "../bfd/libbfd.h"
#include <stdio.h>
#include <sys/time.h>
#include <errno.h>
#define BUFSIZE 8192
-/* FIXME: Not great to have these here. Should they be exported or not? */
-PROTO(size_t, bfd_read, (void *ptr, size_t size, size_t nitems, bfd * abfd));
-PROTO(size_t, bfd_write, (void *ptr, size_t size, size_t nitems, bfd * abfd));
/* PROTO (void, open_inarch, (char *archive_filename)); */
#ifdef __STDC__
static void open_inarch(char *archive_filename);
bfd *inarch; /* The input arch we're manipulating */
/* This flag distinguishes between ar and ranlib:
- 1 means this is 'ranlib'; -1 means this is 'ar'.
- 0 means if we should use argv[0] to decide. */
+ 1 means this is 'ranlib'; 0 means this is 'ar'.
+ -1 means if we should use argv[0] to decide. */
extern int is_ranlib;
/* Nonzero means don't warn about creating the archive file if necessary. */
int silent_create = 0;
temp = program_name; /* shouldn't happen, but... */
else
++temp;
- if (is_ranlib > 0 || (is_ranlib == 0 && strcmp(temp, "ranlib") == 0)) {
+ if (is_ranlib > 0 || (is_ranlib < 0 && strcmp(temp, "ranlib") == 0)) {
if (argc < 2)
- fatal("Too few command arguments.");
+ bfd_fatal("Too few command arguments.");
ranlib_only(argv[1]);
}
if (argc < 3)
- fatal("Too few command arguments.");
+ bfd_fatal("Too few command arguments.");
arg_ptr = argv[1];
}
-/* Things which are interesting to map over all or some of the files: */
-
-void
-print_descr(abfd)
- bfd *abfd;
-{
- print_arelt_descr(abfd, verbose);
-}
-
void
print_contents(abfd)
bfd *abfd;
ostream = 0;
if (size == 0) {
/* Seems like an abstraction violation, eh? Well it's OK! */
- ostream = fopen(abfd->filename, "w");
+ ostream = fopen(abfd->filename, "wb");
if (!ostream) {
perror(abfd->filename);
exit(1);
/* See comment above; this saves disk arm motion */
if (!ostream) {
/* Seems like an abstraction violation, eh? Well it's OK! */
- ostream = fopen(abfd->filename, "w");
+ ostream = fopen(abfd->filename, "wb");
if (!ostream) {
perror(abfd->filename);
exit(1);
}
- ofile = fopen(archive_filename, "a+");
+ ofile = fopen(archive_filename, "a+b");
if (ofile == NULL) {
perror(program_name);
exit(1);
BFD_SEND(temp, _bfd_truncate_arname, (temp, *files_to_append, (char *) hdr));
- ifile = fopen(*files_to_append, "r");
+ ifile = fopen(*files_to_append, "rb");
if (ifile == NULL)
bfd_perror(program_name);
write_archive()
{
bfd *obfd;
- char *xmalloc();
int namelen = strlen(inarch->filename);
char *new_name = xmalloc(namelen + 6);
bfd *contents_head = inarch->next;
else {
#endif
strcpy(new_name, inarch->filename);
- strcpy(new_name + namelen, ".art");
+ strcpy(new_name + namelen, "-art");
obfd = bfd_openw(new_name,
/* FIXME: violates abstraction; need a better protocol */
(inarch->xvec ? bfd_get_target(inarch) : NULL));
if (!strcmp((*after_bfd)->filename, posname)) {
if (realpos == pos_after)
after_bfd = &(*after_bfd)->next;
+ break;
}
}
return after_bfd;
}
+
+/* Things which are interesting to map over all or some of the files: */
+
+void
+print_descr(abfd)
+ bfd *abfd;
+{
+ print_arelt_descr(abfd, verbose);
+}