Lines Matching defs:obj

59 static void	free_obj(struct ar_obj *obj);
60 static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj,
78 struct ar_obj *obj;
87 obj = malloc(sizeof(struct ar_obj));
88 if (obj == NULL)
91 obj->elf = NULL;
95 free(obj);
103 if ((obj->name = malloc(_TRUNCATE_LEN + 1)) == NULL)
105 (void)strncpy(obj->name, bname, _TRUNCATE_LEN);
106 obj->name[_TRUNCATE_LEN] = '\0';
108 if ((obj->name = strdup(bname)) == NULL)
113 bsdar_warnc(bsdar, errno, "can't fstat file: %s", obj->name);
117 bsdar_warnc(bsdar, 0, "%s is not an ordinary file", obj->name);
123 obj->name);
143 obj->uid = 0;
144 obj->gid = 0;
145 obj->mtime = 0;
146 obj->md = S_IFREG | 0644;
148 obj->uid = sb.st_uid;
149 obj->gid = sb.st_gid;
150 obj->mtime = sb.st_mtime;
151 obj->md = sb.st_mode;
153 obj->size = sb.st_size;
154 obj->dev = sb.st_dev;
155 obj->ino = sb.st_ino;
157 if (obj->size == 0) {
158 return (obj);
161 if ((obj->elf = elf_open(fd)) == NULL) {
163 obj->name, elf_errmsg(-1));
171 if (elf_cntl(obj->elf, ELF_C_FDREAD) < 0) {
173 obj->name, elf_errmsg(-1));
179 obj->name);
181 return (obj);
184 if (obj->elf)
185 elf_end(obj->elf);
189 obj->name);
190 free(obj->name);
191 free(obj);
199 free_obj(struct ar_obj *obj)
201 if (obj->elf)
202 elf_end(obj->elf);
204 free(obj->name);
205 free(obj);
209 * Insert an object into a list, either before/after the 'pos' obj or
213 insert_obj(struct bsdar *bsdar, struct ar_obj *obj, struct ar_obj *pos)
215 if (obj == NULL)
216 bsdar_errc(bsdar, 0, "try to insert a null obj");
218 if (pos == NULL || obj == pos)
221 * obj, or if there is no position obj, move the
227 TAILQ_INSERT_BEFORE(pos, obj, objs);
231 TAILQ_INSERT_AFTER(&bsdar->v_obj, pos, obj, objs);
236 TAILQ_INSERT_TAIL(&bsdar->v_obj, obj, objs);
251 struct ar_obj *obj;
322 obj = malloc(sizeof(struct ar_obj));
323 if (obj == NULL)
325 obj->elf = NULL;
327 obj->elf = elf_openmemory(buff, size);
328 if (obj->elf == NULL) {
333 free(obj);
337 if ((obj->name = strdup(name)) == NULL)
339 obj->size = size;
340 obj->uid = archive_entry_uid(entry);
341 obj->gid = archive_entry_gid(entry);
342 obj->md = archive_entry_mode(entry);
343 obj->mtime = archive_entry_mtime(entry);
344 obj->dev = 0;
345 obj->ino = 0;
347 TAILQ_INSERT_TAIL(&bsdar->v_obj, obj, objs);
361 struct ar_obj *nobj, *obj, *obj_temp, *pos;
444 TAILQ_FOREACH(obj, &bsdar->v_obj, objs) {
445 if (strcmp(obj->name, bsdar->posarg) == 0) {
446 pos = obj;
463 TAILQ_FOREACH_SAFE(obj, &bsdar->v_obj, objs, obj_temp) {
467 if (strncmp(bname, obj->name, _TRUNCATE_LEN))
470 if (strcmp(bname, obj->name) != 0)
479 obj->mtime);
490 TAILQ_REMOVE(&bsdar->v_obj, obj, objs);
492 free_obj(obj);
495 insert_obj(bsdar, obj, pos);
543 struct ar_obj *obj, *obj_temp;
545 TAILQ_FOREACH_SAFE(obj, &bsdar->v_obj, objs, obj_temp) {
546 TAILQ_REMOVE(&bsdar->v_obj, obj, objs);
547 free_obj(obj);
665 struct ar_obj *obj;
682 TAILQ_FOREACH(obj, &bsdar->v_obj, objs) {
683 if (!(bsdar->options & AR_SS) && obj->elf != NULL)
684 create_symtab_entry(bsdar, obj->elf);
687 namelen = strlen(obj->name);
691 strchr(obj->name, ' '))
694 add_to_ar_str_table(bsdar, obj->name);
696 obj_sz += obj->size; /* add the actual object size */
783 TAILQ_FOREACH(obj, &bsdar->v_obj, objs) {
784 if ((buf = elf_rawfile(obj->elf, NULL)) == NULL) {
791 archive_entry_copy_pathname(entry, obj->name);
792 archive_entry_set_uid(entry, obj->uid);
793 archive_entry_set_gid(entry, obj->gid);
794 archive_entry_set_mode(entry, obj->md);
795 archive_entry_set_size(entry, obj->size);
796 archive_entry_set_mtime(entry, obj->mtime, 0);
797 archive_entry_set_dev(entry, obj->dev);
798 archive_entry_set_ino(entry, obj->ino);
801 write_data(bsdar, a, buf, obj->size);