Add .clang-format
This commit is contained in:
parent
6e0b65aaa8
commit
6c916ad861
12
.clang-format
Normal file
12
.clang-format
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
BasedOnStyle: Microsoft
|
||||
CompactNamespaces: 'false'
|
||||
FixNamespaceComments: 'false'
|
||||
NamespaceIndentation: All
|
||||
AllowShortBlocksOnASingleLine: 'true'
|
||||
AllowShortCaseLabelsOnASingleLine: 'true'
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: 'true'
|
||||
PointerAlignment: Left
|
10
src/tar.c
10
src/tar.c
@ -1,6 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "minitar.h"
|
||||
#include "tar.h"
|
||||
#include "minitar.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
int minitar_read_header(struct minitar* mp, struct tar_header* hdr);
|
||||
int minitar_validate_header(struct tar_header* hdr);
|
||||
@ -13,7 +13,11 @@ struct minitar* minitar_open(const char* path)
|
||||
FILE* fp = fopen(path, "rb"); // On some systems, this might be necessary to read the file properly.
|
||||
if (!fp) return NULL;
|
||||
struct minitar* mp = malloc(sizeof(struct minitar));
|
||||
if(!mp) { fclose(fp); return NULL; }
|
||||
if (!mp)
|
||||
{
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
mp->stream = fp;
|
||||
return mp;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#ifndef MINITAR_TAR_H
|
||||
#define MINITAR_TAR_H
|
||||
|
||||
struct tar_header {
|
||||
struct tar_header
|
||||
{
|
||||
char name[100];
|
||||
char mode[8];
|
||||
char uid[8];
|
||||
|
38
src/util.c
38
src/util.c
@ -1,11 +1,11 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "minitar.h"
|
||||
#include "tar.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdnoreturn.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "minitar.h"
|
||||
#include "tar.h"
|
||||
|
||||
noreturn void minitar_panic(const char* message)
|
||||
{
|
||||
@ -19,7 +19,9 @@ void minitar_parse_tar_header(struct tar_header* hdr, struct minitar_entry_metad
|
||||
{
|
||||
strncpy(metadata->name, hdr->name, 100);
|
||||
metadata->name[100] = '\0';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(metadata->name, hdr->prefix);
|
||||
strcat(metadata->name, "/");
|
||||
strncat(metadata->name, hdr->name, 100);
|
||||
@ -43,26 +45,14 @@ void minitar_parse_tar_header(struct tar_header* hdr, struct minitar_entry_metad
|
||||
switch (hdr->typeflag)
|
||||
{
|
||||
case '\0':
|
||||
case '0':
|
||||
metadata->type = MTAR_REGULAR;
|
||||
break;
|
||||
case '1':
|
||||
minitar_panic("Links to other files within a tar archive are unsupported");
|
||||
case '2':
|
||||
minitar_panic("Symbolic links are unsupported");
|
||||
case '3':
|
||||
metadata->type = MTAR_CHRDEV;
|
||||
break;
|
||||
case '4':
|
||||
metadata->type = MTAR_BLKDEV;
|
||||
break;
|
||||
case '5':
|
||||
metadata->type = MTAR_DIRECTORY;
|
||||
break;
|
||||
case '6':
|
||||
minitar_panic("FIFOs are unsupported");
|
||||
default:
|
||||
minitar_panic("Unknown entry type in tar header");
|
||||
case '0': metadata->type = MTAR_REGULAR; break;
|
||||
case '1': minitar_panic("Links to other files within a tar archive are unsupported");
|
||||
case '2': minitar_panic("Symbolic links are unsupported");
|
||||
case '3': metadata->type = MTAR_CHRDEV; break;
|
||||
case '4': metadata->type = MTAR_BLKDEV; break;
|
||||
case '5': metadata->type = MTAR_DIRECTORY; break;
|
||||
case '6': minitar_panic("FIFOs are unsupported");
|
||||
default: minitar_panic("Unknown entry type in tar header");
|
||||
}
|
||||
|
||||
strcpy(metadata->uname, hdr->uname);
|
||||
|
Loading…
Reference in New Issue
Block a user