Skip to content

Commit

Permalink
Merge pull request #22 from samih713/http-parser
Browse files Browse the repository at this point in the history
pulling Http parser into main
  • Loading branch information
samih713 authored Feb 25, 2024
2 parents 494abff + 689a0aa commit 847df00
Show file tree
Hide file tree
Showing 62 changed files with 3,623 additions and 289 deletions.
223 changes: 223 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
---
BasedOnStyle: Mozilla
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: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: false
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterAttributes: Never
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ColumnLimit: 90
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
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: true
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: true
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
Language: Cpp
LineEnding: DeriveLF
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PPIndentWidth: -1
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 4
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
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: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
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
29 changes: 23 additions & 6 deletions .github/workflows/compile-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name: Compilation Check
on:
push:
branches:
- server/ver-01.1
- main
- server/*
- conf-parser

jobs:
build:
runs-on: ubuntu-latest
build-linux:
runs-on:
- ubuntu-latest

steps:
- name: Checkout repository
Expand All @@ -19,6 +22,20 @@ jobs:
compiler: gcc

- name: Build project
run: |
cd ver-01.1
make
run: make

build-Mac:
runs-on:
- macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up C++ environment
uses: aminya/setup-cpp@v1
with:
compiler: gcc

- name: Build project
run: make
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.clang-format
.vscode/

*/objects/
*/.cache/
.cache/
*.o
libserver.a
libparser.a
webserv
test_parser
test_server
test_socket
client
*.d
85 changes: 85 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
### COLORS ####
BLUE:= \033[1;34m
GREEN:= \033[1;32m
MAGENTA:= \033[1;35m
RED:= \033[1;31m
YELLOW:= \033[1;33m
RESET:= \033[0m

CXX:= c++
CXXFLAGS:= -Wall -Werror -Wextra -MMD -MP
DEBUGFLAGS:= -ggdb3 -D__DEBUG__ -fsanitize=address

ifeq ($(shell uname), Linux)
CXXFLAGS += -D__LINUX__
else ifeq ($(shell uname), Darwin)
CXXFLAGS += -D__MAC__
endif

RM:= rm -rf

INCLUDES:= -I./includes

SRCS:= main.cpp

OBJS_DIR:= objects
OBJS:= $(SRCS:%.cpp=$(OBJS_DIR)/%.o)

DEP:= $(OBJS:%.o=%.d)

LIBRARY_FLAGS:= -Lserver/ -lserver -Lparser/ -lparser

NAME:= webserv

all: $(NAME)

run: re
./$(NAME)

$(NAME): parser server http $(OBJS)
@$(CXX) $(CXXFLAGS) $(INCLUDES) $(OBJS) -o $@ $(LIBRARY_FLAGS)
@echo "$(YELLOW)[ EXECUTABLE ]$(RESET) $(NAME) is ready.\n"

$(OBJS_DIR)/%.o: %.cpp | $(OBJS_DIR)
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
@echo "$(GREEN)[ COMPILE ]$(RESET) $<."

$(OBJS_DIR):
@mkdir -p objects

debug: CXXFLAGS += $(DEBUGFLAGS)
debug: all
@echo "$(MAGENTA)[ DEBUG ]$(RESET) $(NAME) is ready for debugging."

# @make -sC tester/ # need to add tests for parser and server
tests:
@make tests -sC parser/
@make tests -sC server/
@echo "$(BLUE)[ TEST ]$(RESET) Ready for testing."

parser:
@make -sC parser/

server:
@make -sC server/

http:
@make -sC HTTP/

clean:
@$(RM) $(OBJS_DIR) *.o
@make clean -sC parser/ > /dev/null 2>&1
@make clean -sC server/ > /dev/null 2>&1
@echo "$(RED)[ DELETE ]$(RESET) Removed object files."

fclean: clean
@$(RM) $(NAME)
@make fclean -sC parser/ > /dev/null 2>&1
@make fclean -sC server/ > /dev/null 2>&1
@echo "$(RED)[ DELETE ]$(RESET) Removed $(NAME) and libraries.\n"

-include $(DEP)

re: fclean all

.PHONY: clean fclean all re tests server parser http debug run
25 changes: 25 additions & 0 deletions compile_commands.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"arguments": [
"/usr/bin/c++",
"-Wall",
"-Werror",
"-Wextra",
"-std=c++98",
"-D__LINUX__",
"-I./",
"-Isocket/",
"-I../includes/",
"-I../HTTP/",
"-I../HTTP/request/",
"-I../HTTP/response/",
"-c",
"-o",
"objects/Server.o",
"Server.cpp"
],
"directory": "/home/eva001/42/webserv/server",
"file": "/home/eva001/42/webserv/server/Server.cpp",
"output": "/home/eva001/42/webserv/server/objects/Server.o"
}
]
Loading

0 comments on commit 847df00

Please sign in to comment.