Skip to content

Commit

Permalink
chore: use new format
Browse files Browse the repository at this point in the history
  • Loading branch information
exbotanical committed Nov 26, 2023
1 parent 42b56b2 commit 34e250f
Show file tree
Hide file tree
Showing 28 changed files with 1,030 additions and 435 deletions.
238 changes: 238 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
---
AccessModifierOffset: -1
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Left
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 2
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: All
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
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: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterAttributes: Never
BreakArrays: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: true
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: ^<ext/.*\.h>
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: ^<.*\.h>
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: ^<.*
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: .*
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: ([-_](test|unittest))?$
IncludeIsMainSourceRegex: ""
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: NoIndent
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: true
InsertNewlineAtEOF: true
InsertTrailingCommas: Wrapped
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
LineEnding: DeriveLF
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PPIndentWidth: -1
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
QualifierAlignment: Leave
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- c++
- C++
CanonicalDelimiter: ""
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: pb
BasedOnStyle: google
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: true
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 2
UseTab: Never
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ TESTS := $(wildcard $(TESTDIR)/*.c)
$(PROG):
$(CC) $(CFLAGS) $(SRC) $(DEPS) $(LIBS) -Ideps -Isrc -o $(PROG)

# Use make -s test 2>/dev/null to see only test results
test:
$(MAKE) unit_test

Expand All @@ -34,12 +33,12 @@ unit_test:

integ_test: $(PROG)
./$(TESTDIR)/integ/utils/run.bash
# $(MAKE) clean
$(MAKE) clean

clean:
rm -f $(UNIT_TARGET) $(PROG) .log

lint:
$(LINTER) -i $(SRC) $(wildcard $(TESTDIR)/*/*.c)

.PHONY: test unit_test clean lint
.PHONY: test unit_test integ_test clean lint
6 changes: 3 additions & 3 deletions clib.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"job",
"task runner"
],
"install": "echo TODO",
"uninstall": "echo TODO",
"dependencies": {
"exbotanical/libutil": "*",
"exbotanical/libhash": "*",
"clibs/commander": "1.3.2"
},
"development": {
"thlorenz/tap.c": "*"
},
// TODO: setup installer
"src": []
}
}
17 changes: 13 additions & 4 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,25 @@
* Optionally specify a path to which logs will be written.
* Otherwise, syslog or a comparable facility will be utilized.
*/
static void setopt_logfile(command_t* self) {
static void
setopt_logfile (command_t* self)
{
opts.log_file = (char*)self->arg;
}

void cli_init(int argc, char** argv) {
void
cli_init (int argc, char** argv)
{
command_t cmd;

command_init(&cmd, argv[0], CHRONIC_VERSION);
command_option(&cmd, "-L", "--log-file [path]",
"log to specified file instead of syslog", setopt_logfile);
command_option(
&cmd,
"-L",
"--log-file [path]",
"log to specified file instead of syslog",
setopt_logfile
);

command_parse(&cmd, argc, argv);
}
2 changes: 1 addition & 1 deletion src/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* CLI configuration options.
*/
typedef struct {
bool use_syslog;
bool use_syslog;
char* log_file;
} CliOptions;

Expand Down
30 changes: 15 additions & 15 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
#include "libhash/libhash.h"
#include "libutil/libutil.h"

#define ROOT_UNAME "root"
#define ROOT_UID 0
#define ROOT_UNAME "root"
#define ROOT_UID 0

#define ALL_PERMS 07777
#define OWNER_RW_PERMS 0600
#define ALL_PERMS 07777
#define OWNER_RW_PERMS 0600

#define HOMEDIR_ENVVAR "HOME"
#define SHELL_ENVVAR "SHELL"
#define PATH_ENVVAR "PATH"
#define UNAME_ENVVAR "USER"
#define MAILTO_ENVVAR "MAILTO"
#define HOMEDIR_ENVVAR "HOME"
#define SHELL_ENVVAR "SHELL"
#define PATH_ENVVAR "PATH"
#define UNAME_ENVVAR "USER"
#define MAILTO_ENVVAR "MAILTO"

#define SMALL_BUFFER 256
#define MED_BUFFER SMALL_BUFFER * 4
#define LARGE_BUFFER MED_BUFFER * 2
#define SMALL_BUFFER 256
#define MED_BUFFER SMALL_BUFFER * 4
#define LARGE_BUFFER MED_BUFFER * 2

#define MAILCMD_FMT "%s -r%s@%s -s 'job: %s' %s"
#define MAILCMD_FMT "%s -r%s@%s -s 'job: %s' %s"

#define CHRONIC_VERSION "0.0.1"
#define DAEMON_IDENT "crond"
#define DAEMON_IDENT "crond"

extern pid_t daemon_pid;
extern char hostname[SMALL_BUFFER];
extern char hostname[SMALL_BUFFER];

extern array_t *job_queue;
extern array_t *mail_queue;
Expand Down
12 changes: 8 additions & 4 deletions src/cronentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

unsigned int id_counter = 0;

CronEntry* new_cron_entry(char* raw, time_t curr, Crontab* ct) {
CronEntry*
new_cron_entry (char* raw, time_t curr, Crontab* ct)
{
CronEntry* entry = xmalloc(sizeof(CronEntry));

// TODO: Lift out
Expand All @@ -16,13 +18,15 @@ CronEntry* new_cron_entry(char* raw, time_t curr, Crontab* ct) {
}

entry->parent = ct;
entry->next = cron_next(entry->expr, curr);
entry->id = ++id_counter;
entry->next = cron_next(entry->expr, curr);
entry->id = ++id_counter;

return entry;
}

void renew_cron_entry(CronEntry* entry, time_t curr) {
void
renew_cron_entry (CronEntry* entry, time_t curr)
{
printlogf("Updating time for entry %d\n", entry->id);

entry->next = cron_next(entry->expr, curr);
Expand Down
Loading

0 comments on commit 34e250f

Please sign in to comment.