Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
1.3 kB
3
Indexable
Never
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <stdio.h>

#ifndef HH
#define HH

/* Field size macros */
#define NAME_SIZE 100
#define MODE_SIZE 8
#define UID_SIZE 8
#define GID_SIZE 8
#define FILESIZE_SIZE 12
#define MTIME_SIZE 12
#define CHKSUM_SIZE 8
#define DEVMAJOR_SIZE 8
#define DEVMINOR_SIZE 8

/* Name length macros */
#define MAX_NAME_LEN 256

typedef struct header{
    char *name; /* NUL-terminated is NUL fits; size: 100 */
    char *mode; /* Octal string; size: 8 */
    char *uid; /* Octal string; size: 8 */
    char *gid; /* Octal string; size: 8 */
    char *size; /* Octal string; size: 12 */
    char *mtime; /* Octal string; size: 12 */
    char *chksum; /* Octal string; size: 8 */
    char typeflag;
    char *linkname; /* NUL-terminated if NUL fits; size: 100 */
    char *magic; /* Must be "ustar", NUL-terminated; size: 48 */
    char *version; /* Must be "00"; size: 2 */
    char *uname; /* NUL-terminated; size: 32 */
    char *gname; /* NUL-terminated; size: 32 */
    char *devmajor; /* Octal string; size: 8 */
    char *devminor; /* Octal string; size: 8 */
    char *prefix; /* NUL-terminated if NUL fits; size: 155 */
} header;

header *create_header(struct stat sb, char *path);

char *duplicate_buff(char *buff);

#endif
Leave a Comment