Added prototypes for many functions
This commit is contained in:
parent
fb09ab873d
commit
8b1dbe6064
3 changed files with 134 additions and 239 deletions
225
.clang-format
225
.clang-format
|
@ -1,225 +0,0 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BitFieldColonSpacing: Both
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterExternBlock: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakAfterAttributes: Never
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakArrays: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
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: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: false
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
BinaryMinDigits: 0
|
||||
Decimal: 0
|
||||
DecimalMinDigits: 0
|
||||
Hex: 0
|
||||
HexMinDigits: 0
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
LineEnding: DeriveLF
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PackConstructorInitializers: BinPack
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
PPIndentWidth: -1
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: LexicographicNumeric
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- BOOST_PP_STRINGIZE
|
||||
- CF_SWIFT_NAME
|
||||
- NS_SWIFT_NAME
|
||||
- PP_STRINGIZE
|
||||
- STRINGIZE
|
||||
...
|
||||
|
3
compile_flags.txt
Normal file
3
compile_flags.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
-I
|
||||
include
|
||||
|
145
src/haggis.c
145
src/haggis.c
|
@ -1,20 +1,20 @@
|
|||
/* _,.---._ .-._ .--.-. ,--.--------.
|
||||
/* _,.---._ .-._ .--.-. ,--.--------.
|
||||
* _,..---._ ,-.' , - `. /==/ \ .-._/==/ //==/, - , -\
|
||||
* /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./
|
||||
* /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./
|
||||
* |==| _ _\==| .=. |==|- \| | \==\- \`--`\==\- \
|
||||
* |==| .=. |==|_ : ;=: - |==| , | -| `--`-' \==\_ \
|
||||
* |==|,| | -|==| , '=' |==| - _ | |==|- |
|
||||
* |==| '=' /\==\ - ,_ /|==| /\ , | |==|, |
|
||||
* |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/
|
||||
* `-.`.____.' `--`--'' `--`./ `--` `--`--`
|
||||
* _ __ ,---. .-._ .=-.-. _,.----.
|
||||
* |==|,| | -|==| , '=' |==| - _ | |==|- |
|
||||
* |==| '=' /\==\ - ,_ /|==| /\ , | |==|, |
|
||||
* |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/
|
||||
* `-.`.____.' `--`--'' `--`./ `--` `--`--`
|
||||
* _ __ ,---. .-._ .=-.-. _,.----.
|
||||
* .-`.' ,`..--.' \ /==/ \ .-._ /==/_ /.' .' - \
|
||||
* /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-'
|
||||
* |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | .
|
||||
* /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-'
|
||||
* |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | .
|
||||
* |==| , '=',\==\, - \ |==| , | -||==|- ||==|_ `-' \
|
||||
* |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , |
|
||||
* |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. /
|
||||
* /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-'
|
||||
* |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , |
|
||||
* |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. /
|
||||
* /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-'
|
||||
* `--`---' `--` `--`./ `--``--`-`
|
||||
*
|
||||
* @(#)Copyright (c) 2023, Nathan D. Fisher.
|
||||
|
@ -31,9 +31,126 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "haggis.h"
|
||||
|
||||
int main() {
|
||||
printf("Hello, Haggis!\n");
|
||||
static unsigned char header[7] = {0x89, 'h', 'a', 'g', 'g', 'i', 's'};
|
||||
|
||||
int haggis_store_header(FILE *stream) {
|
||||
if (fwrite(header, 1, 7, stream) < 7)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_check_header(FILE *stream) {
|
||||
unsigned char *buf[7];
|
||||
if (fread(buf, 1, 7, stream) < 7)
|
||||
return 1;
|
||||
if (memcmp(buf, header, 7))
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int haggis_store_device(FILE *stream, struct haggis_device *dev) {
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_load_device(FILE *stream, struct haggis_device *dev) {
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_store_cksum(FILE *stream, struct haggis_checksum *cksum) {
|
||||
char flag;
|
||||
switch (cksum->tag) {
|
||||
case md5:
|
||||
flag = 0;
|
||||
if (fwrite(&flag, 1, 1, stream) != 1)
|
||||
return 1;
|
||||
if (fwrite(cksum->sum->md5, 1, 16, stream) != 16)
|
||||
return 1;
|
||||
break;
|
||||
case sha1:
|
||||
flag = 1;
|
||||
if (fwrite(&flag, 1, 1, stream) != 1)
|
||||
return 1;
|
||||
if (fwrite(cksum->sum->sha1, 1, 20, stream) != 20)
|
||||
return 1;
|
||||
break;
|
||||
case sha256:
|
||||
flag = 2;
|
||||
if (fwrite(&flag, 1, 1, stream) != 1)
|
||||
return 1;
|
||||
if (fwrite(cksum->sum->sha256, 1, 32, stream) != 32)
|
||||
return 1;
|
||||
break;
|
||||
case skip:
|
||||
flag = 3;
|
||||
if (fwrite(&flag, 1, 1, stream) != 1)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_load_cksum(FILE *stream, struct haggis_checksum *cksum) {
|
||||
// todo
|
||||
char flag;
|
||||
if (fread(&flag, 1, 1, stream) != 1)
|
||||
return 1;
|
||||
switch (flag) {
|
||||
case md5:
|
||||
cksum->tag = 0;
|
||||
if (fread(&cksum->sum->md5, 1, 16, stream) != 16)
|
||||
return 1;
|
||||
break;
|
||||
case sha1:
|
||||
cksum->tag = 1;
|
||||
if (fread(&cksum->sum->sha1, 1, 20, stream) != 20)
|
||||
return 1;
|
||||
break;
|
||||
case sha256:
|
||||
cksum->tag = 2;
|
||||
if (fread(&cksum->sum->sha256, 1, 32, stream) != 32)
|
||||
return 1;
|
||||
break;
|
||||
case skip:
|
||||
cksum->tag = 3;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_store_file(FILE *stream, struct haggis_normal *file) {
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_load_file(FILE *stream, struct haggis_normal *file) {
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_store_filetype(FILE *stream, struct haggis_filetype *filetype) {
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_load_filetype(FILE *stream, struct haggis_filetype *filetype) {
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_store_node(FILE *stream, struct haggis_node *node) {
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_load_node(FILE *stream, struct haggis_node *node) {
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() { printf("Hello, Haggis!\n"); }
|
||||
|
|
Loading…
Add table
Reference in a new issue