Apply formatting
This commit is contained in:
parent
4a2b0328f9
commit
f72b120b0c
3 changed files with 944 additions and 754 deletions
166
.clang-format
Normal file
166
.clang-format
Normal file
|
@ -0,0 +1,166 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequires: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Latest
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
...
|
||||
|
13
Makefile
13
Makefile
|
@ -52,22 +52,31 @@ srcs += jobq.c
|
|||
srcs += mq.c
|
||||
srcs += linkmap.c
|
||||
|
||||
binsrc += bin.c
|
||||
|
||||
objs = $(srcs:.c=.o)
|
||||
|
||||
all: shared static
|
||||
|
||||
bin: haggis
|
||||
|
||||
shared: libhaggis.so
|
||||
|
||||
static: libhaggis.a
|
||||
|
||||
$(srcs): $(hdrs)
|
||||
|
||||
$(binsrc): $(hdrs) $(srcs)
|
||||
|
||||
libhaggis.a: $(objs)
|
||||
$(AR) rcs $@ $?
|
||||
|
||||
libhaggis.so: $(objs)
|
||||
$(CC) -shared -o $@ $? $(LIBS)
|
||||
|
||||
haggis: $(binsrc) libhaggis.a
|
||||
$(CC) -I./include -o $@ $?
|
||||
|
||||
install: install_include install_man install_shared install_static
|
||||
|
||||
install_include: include/haggis.h
|
||||
|
@ -93,8 +102,8 @@ testclean:
|
|||
$(MAKE) -C test clean
|
||||
|
||||
clean:
|
||||
rm -rf *.a *.so *.o
|
||||
rm -rf *.a *.so *.o haggis
|
||||
$(MAKE) -C test clean
|
||||
|
||||
.PHONY: all shared static clean install install_include install_man \
|
||||
.PHONY: all bin shared static clean install install_include install_man \
|
||||
install_static install_shared testclean test
|
||||
|
|
41
haggis.c
41
haggis.c
|
@ -212,7 +212,7 @@ void init_sha1(haggis_file *f) {
|
|||
f->cksum.tag = sha1;
|
||||
SHA1Init(&ctx);
|
||||
SHA1Update(&ctx, f->data, (size_t)f->len.val);
|
||||
SHA1Final(f->cksum.sum.sha1, &ctx);
|
||||
SHA1Final(f->cksum.sha1, &ctx);
|
||||
}
|
||||
|
||||
int validate_sha1(haggis_file *file) {
|
||||
|
@ -222,7 +222,7 @@ int validate_sha1(haggis_file *file) {
|
|||
SHA1Init(&ctx);
|
||||
SHA1Update(&ctx, file->data, (size_t)file->len.val);
|
||||
SHA1Final(digest, &ctx);
|
||||
if (memcmp(file->cksum.sum.sha1, digest, sizeof(digest)))
|
||||
if (memcmp(file->cksum.sha1, digest, sizeof(digest)))
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ void init_sha256(haggis_file *f) {
|
|||
f->cksum.tag = sha256;
|
||||
SHA256Init(&ctx);
|
||||
SHA256Update(&ctx, f->data, (size_t)f->len.val);
|
||||
SHA256Final(f->cksum.sum.sha256, &ctx);
|
||||
SHA256Final(f->cksum.sha256, &ctx);
|
||||
}
|
||||
|
||||
int validate_sha256(haggis_file *file) {
|
||||
|
@ -266,7 +266,7 @@ int validate_sha256(haggis_file *file) {
|
|||
SHA256Init(&ctx);
|
||||
SHA256Update(&ctx, file->data, (size_t)file->len.val);
|
||||
SHA256Final(digest, &ctx);
|
||||
if (memcmp(file->cksum.sum.sha256, digest, sizeof(digest)))
|
||||
if (memcmp(file->cksum.sha256, digest, sizeof(digest)))
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
@ -407,8 +407,11 @@ int haggis_store_filename(FILE *stream, haggis_filename *n) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int haggis_load_filetype(FILE *stream, haggis_typeflag tag,
|
||||
haggis_filetype *file) {
|
||||
int haggis_load_filetype(
|
||||
FILE *stream,
|
||||
haggis_typeflag tag,
|
||||
haggis_filetype *file
|
||||
) {
|
||||
switch (tag) {
|
||||
case normal:
|
||||
file->tag = 0;
|
||||
|
@ -531,8 +534,12 @@ void haggis_node_deinit(haggis_node *node) {
|
|||
free(node);
|
||||
}
|
||||
|
||||
int haggis_init_hardlink_node(haggis_node *node, char *target,
|
||||
haggis_linkmap *map, haggis_mq *mq) {
|
||||
int haggis_init_hardlink_node(
|
||||
haggis_node *node,
|
||||
char *target,
|
||||
haggis_linkmap *map,
|
||||
haggis_mq *mq
|
||||
) {
|
||||
haggis_message_body body;
|
||||
haggis_msg *msg;
|
||||
|
||||
|
@ -546,9 +553,13 @@ int haggis_init_hardlink_node(haggis_node *node, char *target,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int haggis_init_file_node(haggis_node *node, struct stat *st,
|
||||
haggis_algorithm a, haggis_linkmap *map,
|
||||
haggis_mq *mq) {
|
||||
int haggis_init_file_node(
|
||||
haggis_node *node,
|
||||
struct stat *st,
|
||||
haggis_algorithm a,
|
||||
haggis_linkmap *map,
|
||||
haggis_mq *mq
|
||||
) {
|
||||
haggis_message_body body;
|
||||
haggis_msg *msg;
|
||||
char *target;
|
||||
|
@ -593,8 +604,12 @@ int haggis_init_dev_node(haggis_node *node, struct stat *st,
|
|||
return 0;
|
||||
}
|
||||
|
||||
haggis_node *haggis_create_node(char *file, haggis_algorithm a,
|
||||
haggis_linkmap *map, haggis_mq *mq) {
|
||||
haggis_node *haggis_create_node(
|
||||
char *file,
|
||||
haggis_algorithm a,
|
||||
haggis_linkmap *map,
|
||||
haggis_mq *mq
|
||||
) {
|
||||
u16 mode;
|
||||
char *target;
|
||||
char pathbuf[PATH_MAX];
|
||||
|
|
Loading…
Add table
Reference in a new issue