Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
170 changes: 124 additions & 46 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
---
Language: Cpp
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignArrayOfStructures: Left
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: true
PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
Expand All @@ -21,26 +43,31 @@ AlwaysBreakAfterDefinitionReturnType: All
AlwaysBreakAfterReturnType: AllDefinitions
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Linux
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
Expand All @@ -49,17 +76,23 @@ BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 132
CommentPragmas: '^ IWYU pragma:'
ColumnLimit: 132
CommentPragmas: "^ IWYU pragma:"
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: NextLine
BasedOnStyle: ""
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- forv_Vec
Expand All @@ -68,72 +101,117 @@ ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '$'
IncludeIsMainSourceRegex: ''
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: ".*"
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: "$"
IncludeIsMainSourceRegex: ""
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentExternBlock: AfterExternBlock
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
LambdaBodyIndentation: Signature
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 30000
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
ReflowComments: true
SortIncludes: false
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RequiresClausePosition: OwnLine
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: Never
SortJavaStaticImport: Before
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
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
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
BitFieldColonSpacing: Both
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
...

TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
---
6 changes: 3 additions & 3 deletions example/plugins/c-api/basic_auth/basic_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ base64_decode(const char *input)
*output++ = decode(0) << 2 | decode(1) >> 4;
*output++ = decode(1) << 4 | decode(2) >> 2;
*output++ = decode(2) << 6 | decode(3);
len -= 4;
input += 4;
len -= 4;
input += 4;
}

/*
Expand Down Expand Up @@ -139,7 +139,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
goto done;
}
*password = '\0';
password += 1;
password += 1;

if (!authorized(user, password)) {
TSError("[%s] %s:%s not authorized", PLUGIN_NAME, user, password);
Expand Down
2 changes: 1 addition & 1 deletion example/plugins/c-api/bnull_transform/bnull_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#define PLUGIN_NAME "bnull_transform"

#define TS_NULL_MUTEX NULL
#define TS_NULL_MUTEX NULL
#define STATE_BUFFER_DATA 0
#define STATE_OUTPUT_DATA 1

Expand Down
28 changes: 14 additions & 14 deletions example/plugins/c-api/cache_scan/cache_scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
cache_scan_state *cstate = static_cast<cache_scan_state *>(TSContDataGet(contp));

if (event == TS_EVENT_CACHE_REMOVE) {
cstate->done = 1;
const char error[] = "Cache remove operation succeeded";
cstate->cache_vc = static_cast<TSVConn>(edata);
cstate->write_vio = TSVConnWrite(cstate->net_vc, contp, cstate->resp_reader, INT64_MAX);
cstate->done = 1;
const char error[] = "Cache remove operation succeeded";
cstate->cache_vc = static_cast<TSVConn>(edata);
cstate->write_vio = TSVConnWrite(cstate->net_vc, contp, cstate->resp_reader, INT64_MAX);
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, error, sizeof(error) - 1);
TSVIONBytesSet(cstate->write_vio, cstate->total_bytes);
TSVIOReenable(cstate->write_vio);
Expand All @@ -83,8 +83,8 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
const char error[] = "Cache remove operation failed error=";
char rc[12];
snprintf(rc, 12, "%p", edata);
cstate->cache_vc = static_cast<TSVConn>(edata);
cstate->write_vio = TSVConnWrite(cstate->net_vc, contp, cstate->resp_reader, INT64_MAX);
cstate->cache_vc = static_cast<TSVConn>(edata);
cstate->write_vio = TSVConnWrite(cstate->net_vc, contp, cstate->resp_reader, INT64_MAX);
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, error, sizeof(error) - 1);
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, rc, strlen(rc));

Expand All @@ -104,7 +104,7 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
event == TS_EVENT_CACHE_SCAN_OPERATION_FAILED) {
cstate->done = 1;
if (cstate->resp_buffer) {
const char error[] = "Cache scan operation blocked or failed";
const char error[] = "Cache scan operation blocked or failed";
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, error, sizeof(error) - 1);
}
if (cstate->write_vio) {
Expand Down Expand Up @@ -159,12 +159,12 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
if (event == TS_EVENT_CACHE_SCAN_DONE) {
cstate->done = 1;
char s[512];
int s_len = snprintf(s, sizeof(s),
"</pre></p>\n<p>%d total objects in cache</p>\n"
"<form method=\"GET\" action=\"/show-cache\">"
"Enter URL to delete: <input type=\"text\" size=\"40\" name=\"remove_url\">"
"<input type=\"submit\" value=\"Delete URL\">",
cstate->total_items);
int s_len = snprintf(s, sizeof(s),
"</pre></p>\n<p>%d total objects in cache</p>\n"
"<form method=\"GET\" action=\"/show-cache\">"
"Enter URL to delete: <input type=\"text\" size=\"40\" name=\"remove_url\">"
"<input type=\"submit\" value=\"Delete URL\">",
cstate->total_items);
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, s, s_len);
TSVIONBytesSet(cstate->write_vio, cstate->total_bytes);
if (!cstate->write_pending) {
Expand Down Expand Up @@ -271,7 +271,7 @@ handle_io(TSCont contp, TSEvent event, void * /* edata ATS_UNUSED */)
cstate->pending_action = actionp;
}
} else {
char head[] = "<h3>Cache Contents:</h3>\n<p><pre>\n";
char head[] = "<h3>Cache Contents:</h3>\n<p><pre>\n";
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, head, sizeof(head) - 1);
// start scan
TSAction actionp = TSCacheScan(contp, nullptr, 512000);
Expand Down
11 changes: 6 additions & 5 deletions example/plugins/c-api/intercept/intercept.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// request. You can enable extensive logging with the "intercept" diagnostic tag.

#define PLUGIN_NAME "intercept"
#define PORT 60000
#define PORT 60000

#define VDEBUG(fmt, ...) TSDebug(PLUGIN_NAME, fmt, ##__VA_ARGS__)

Expand Down Expand Up @@ -164,7 +164,8 @@ static const char *
InterceptProxySideVC(const InterceptState *istate, TSVConn vc)
{
return (istate->client.vc && vc == istate->client.vc) ? "<client>" :
(istate->server.vc && vc == istate->server.vc) ? "<server>" : "<unknown>";
(istate->server.vc && vc == istate->server.vc) ? "<server>" :
"<unknown>";
}

static bool
Expand Down Expand Up @@ -244,9 +245,9 @@ InterceptTransferData(InterceptIO *from, InterceptIO *to)
while (ptr && remain) {
int64_t nbytes;

nbytes = TSIOBufferWrite(to->writeio.iobuf, ptr, remain);
remain -= nbytes;
ptr += nbytes;
nbytes = TSIOBufferWrite(to->writeio.iobuf, ptr, remain);
remain -= nbytes;
ptr += nbytes;
consumed += nbytes;
}
}
Expand Down
Loading