read.c

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.3 kB
6
Indexable
Never
  1 #include "read.h"
  2 /*have not freed old field with null pointers*/
  3
  4 header *populate_header(int fd, header *hb) {
  5     char *name, *mode, *uid, *gid, *size, *mtime, *chksum,
  6         *linkname, *uname, *gname, *devmajor, *devminor, *prefix;
  7     name = create_field(name, NAME_SIZE);
  8     hb->name = extract_field(fd, name, NAME_SIZE);
  9     hb->mode = extract_field(fd, mode, MODE_SIZE);
 10     hb->uid = extract_field(fd, uid, UID_SIZE);
 11     hb->gid = extract_field(fd, gid, GID_SIZE);
 12     hb->size = extract_field(fd, size, FILESIZE_SIZE);
 13     hb->mtime = extract_field(fd, mtime, MTIME_SIZE);
 14     hb->chksum = extract_field(fd, chksum, CHKSUM_SIZE);
 15     hb->linkname = extract_field(fd, linkname, LINKNAME_SIZE);
 16     hb->uname = extract_field(fd, uname, UNAME_SIZE);
 17     hb->gname = extract_field(fd, gname, GNAME_SIZE);
 18     hb->devmajor = extract_field(fd, devmajor, DEVMAJOR_SIZE);
 19     hb->devminor = extract_field(fd, devminor, DEVMINOR_SIZE);
 20     hb->prefix = extract_field(fd, prefix, PREFIX_SIZE);
 21     return hb;
 22 }
 23
 24 char *extract_field(int fd, char *field, unsigned field_size) {
                                                              1,9           Top
Leave a Comment