Deleted Added
full compact
write.c (280917) write.c (282911)
1/*-
2 * Copyright (c) 2007 Kai Wang
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 26 unchanged lines hidden (view full) ---

35#include <gelf.h>
36#include <libgen.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40
41#include "ar.h"
42
1/*-
2 * Copyright (c) 2007 Kai Wang
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 26 unchanged lines hidden (view full) ---

35#include <gelf.h>
36#include <libgen.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40
41#include "ar.h"
42
43ELFTC_VCSID("$Id: write.c 3174 2015-03-27 17:13:41Z emaste $");
43ELFTC_VCSID("$Id: write.c 3183 2015-04-10 16:18:42Z emaste $");
44
45#define _ARMAG_LEN 8 /* length of the magic string */
46#define _ARHDR_LEN 60 /* length of the archive header */
47#define _INIT_AS_CAP 128 /* initial archive string table size */
48#define _INIT_SYMOFF_CAP (256*(sizeof(uint32_t))) /* initial so table size */
49#define _INIT_SYMNAME_CAP 1024 /* initial sn table size */
50#define _MAXNAMELEN_SVR4 15 /* max member name length in svr4 variant */
51#define _MAXNAMELEN_BSD 16 /* max member name length in bsd variant */

--- 12 unchanged lines hidden (view full) ---

64static void write_cleanup(struct bsdar *bsdar);
65static void write_data(struct bsdar *bsdar, struct archive *a,
66 const void *buf, size_t s);
67static void write_objs(struct bsdar *bsdar);
68
69/*
70 * Create an object from a file, and return the created object
71 * descriptor. Return NULL if either an error occurs, or if the '-u'
44
45#define _ARMAG_LEN 8 /* length of the magic string */
46#define _ARHDR_LEN 60 /* length of the archive header */
47#define _INIT_AS_CAP 128 /* initial archive string table size */
48#define _INIT_SYMOFF_CAP (256*(sizeof(uint32_t))) /* initial so table size */
49#define _INIT_SYMNAME_CAP 1024 /* initial sn table size */
50#define _MAXNAMELEN_SVR4 15 /* max member name length in svr4 variant */
51#define _MAXNAMELEN_BSD 16 /* max member name length in bsd variant */

--- 12 unchanged lines hidden (view full) ---

64static void write_cleanup(struct bsdar *bsdar);
65static void write_data(struct bsdar *bsdar, struct archive *a,
66 const void *buf, size_t s);
67static void write_objs(struct bsdar *bsdar);
68
69/*
70 * Create an object from a file, and return the created object
71 * descriptor. Return NULL if either an error occurs, or if the '-u'
72 * option was specifed and the member is not newer than the existing
72 * option was specified and the member is not newer than the existing
73 * one in the archive.
74 */
75static struct ar_obj *
76create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime)
77{
78 struct ar_obj *obj;
79 struct stat sb;
80 const char *bname;

--- 340 unchanged lines hidden (view full) ---

421 * of current archive. Note that mode 'A' is a special mode
422 * for the 'ADDLIB' command in ar's script mode. Currently
423 * there is no option that invokes this function from ar's
424 * command line.
425 */
426 if (mode == 'A') {
427 /*
428 * Read objects from the target archive of the
73 * one in the archive.
74 */
75static struct ar_obj *
76create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime)
77{
78 struct ar_obj *obj;
79 struct stat sb;
80 const char *bname;

--- 340 unchanged lines hidden (view full) ---

421 * of current archive. Note that mode 'A' is a special mode
422 * for the 'ADDLIB' command in ar's script mode. Currently
423 * there is no option that invokes this function from ar's
424 * command line.
425 */
426 if (mode == 'A') {
427 /*
428 * Read objects from the target archive of the
429 * 'ADDLIB' command. If there are members spcified in
429 * 'ADDLIB' command. If there are members specified in
430 * 'argv', read those members only, otherwise the
431 * entire archive will be read.
432 */
433 read_objs(bsdar, bsdar->addlib, 1);
434 goto write_objs;
435 }
436
437 /*

--- 4 unchanged lines hidden (view full) ---

442 if (strcmp(obj->name, bsdar->posarg) == 0) {
443 pos = obj;
444 break;
445 }
446 }
447
448 /*
449 * If we cannot find the position specified by the
430 * 'argv', read those members only, otherwise the
431 * entire archive will be read.
432 */
433 read_objs(bsdar, bsdar->addlib, 1);
434 goto write_objs;
435 }
436
437 /*

--- 4 unchanged lines hidden (view full) ---

442 if (strcmp(obj->name, bsdar->posarg) == 0) {
443 pos = obj;
444 break;
445 }
446 }
447
448 /*
449 * If we cannot find the position specified by the
450 * user, sliently insert objects at the tail of the
450 * user, silently insert objects at the tail of the
451 * list.
452 */
453 if (pos == NULL)
454 bsdar->options &= ~(AR_A | AR_B);
455 }
456
457 for (i = 0; i < bsdar->argc; i++) {
458 av = &bsdar->argv[i];

--- 517 unchanged lines hidden ---
451 * list.
452 */
453 if (pos == NULL)
454 bsdar->options &= ~(AR_A | AR_B);
455 }
456
457 for (i = 0; i < bsdar->argc; i++) {
458 av = &bsdar->argv[i];

--- 517 unchanged lines hidden ---