summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 017bebe)
raw | patch | inline | side by side (parent: 017bebe)
author | Eric Wertz <ericwertz@Erics-MacBook-Pro.local> | |
Fri, 30 May 2025 23:57:34 +0000 (19:57 -0400) | ||
committer | Eric Wertz <ericwertz@Erics-MacBook-Pro.local> | |
Fri, 30 May 2025 23:57:34 +0000 (19:57 -0400) |
Makefile | patch | blob | history | |
backend/main.cpp | patch | blob | history |
diff --git a/Makefile b/Makefile
index cb3cdf00bb5cec9af5e61a74ed1e37327dbf0715..4da2277dd4c47de7028b9b7963dc81dce2a2ebc2 100644 (file)
--- a/Makefile
+++ b/Makefile
INCLUDES = -I$(SRC_DIR) -I$(OPENSSL_PATH)/include
# Link flags
-LDFLAGS_BASE = -L$(OPENSSL_PATH)/lib -lssl -lcrypto -framework Security
+LDFLAGS_BASE = -L$(OPENSSL_PATH)/lib -lssl -lcrypto
ifeq ($(OS),Darwin)
- LDFLAGS_OS_SPECIFIC = -Wl,-dead_strip
+ LDFLAGS_OS_SPECIFIC = -Wl,-dead_strip -framework Security
else # Default to Linux/GNU ld behavior (e.g., Linux)
LDFLAGS_OS_SPECIFIC = -Wl,--gc-sections
endif
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
+# Frontend dependencies installation
+frontend-deps:
+ @if [ ! -d "$(FRONTEND_SRC)/node_modules" ]; then \
+ echo "Installing frontend dependencies..."; \
+ cd $(FRONTEND_SRC) && npm install; \
+ else \
+ echo "Frontend dependencies already installed."; \
+ fi
+
# Frontend build
-frontend:
+frontend: frontend-deps
rm -rf $(BUILD_DIR)/www/*
cd $(FRONTEND_SRC) && NODE_ENV=production node esbuild.config.js || (echo "Frontend build failed" && exit 1)
@if [ ! -f $(BUILD_DIR)/www/bundle.js ]; then \
-include $(DEPS)
# Phony targets
-.PHONY: all clean setup run frontend run-decrypt
\ No newline at end of file
+.PHONY: all clean setup run frontend frontend-deps run-decrypt
\ No newline at end of file
diff --git a/backend/main.cpp b/backend/main.cpp
index c572ca3a61a280d4711b56c9d40db32b4df52035..aba716fdb4e13a699dc5fa97df9bc4a4f23d576a 100644 (file)
--- a/backend/main.cpp
+++ b/backend/main.cpp
#include "HTTPRequest.h"
#include "HTTPRequestRouter.h"
-const int PORT = 9000;
-
std::map<int,std::thread> threadMap;
std::vector<int> completeThreads;
std::mutex threadMapLock;
lk.unlock();
}
-int main() {
+void print_usage(const char* program_name) {
+ std::cout << "Usage: " << program_name << " [options]\n";
+ std::cout << "Options:\n";
+ std::cout << " -p <port> Port to listen on (default: 9000)\n";
+ std::cout << " -h Show this help message\n";
+}
+
+int main(int argc, char* argv[]) {
+ int port = 9000; // Default port
+
+ // Parse command line arguments
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-p") == 0) {
+ if (i + 1 < argc) {
+ port = atoi(argv[i + 1]);
+ if (port <= 0 || port > 65535) {
+ std::cerr << "Error: Invalid port number. Must be between 1 and 65535.\n";
+ return 1;
+ }
+ i++; // Skip the next argument since we've used it as the port number
+ } else {
+ std::cerr << "Error: -p flag requires a port number.\n";
+ print_usage(argv[0]);
+ return 1;
+ }
+ } else if (strcmp(argv[i], "-h") == 0) {
+ print_usage(argv[0]);
+ return 0;
+ } else {
+ std::cerr << "Error: Unknown argument " << argv[i] << "\n";
+ print_usage(argv[0]);
+ return 1;
+ }
+ }
+
int server_socket;
struct sockaddr_in server_address;
// Set up the server address
server_address.sin_family = AF_INET;
server_address.sin_addr.s_addr = INADDR_ANY;
- server_address.sin_port = htons(PORT);
+ server_address.sin_port = htons(port);
// Bind the socket to the port
if (bind(server_socket, (struct sockaddr*)&server_address, sizeof(server_address)) < 0) {
return 1;
}
- std::cout << "Server is running on port " << PORT << "\n";
+ std::cout << "Server is running on port " << port << "\n";
unsigned int threadId = 0;
while (true) {