From 9e2b4fc9e3a8f19596a35b8a7aef7a9fa8681af9 Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Sat, 30 Dec 2023 14:30:29 +0100 Subject: [PATCH] basic config --- Makefile | 2 +- main.c | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1b2504c..fcfddf3 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ $(BIN) : $(SRC) gcc $(FLAGS) -o $(BIN) $(SRC) -l$(LIB) run : $(BIN) - ./$(BIN) + ./$(BIN) $(input) clean : rm $(BIN) diff --git a/main.c b/main.c index e1a00ba..1dcbc00 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -6,6 +7,15 @@ char page[1024]; +typedef struct UserConfig { + int port; + int addr; +} UserConfig; +UserConfig config = { + .port = 443, + .addr = 0x08080808, +}; + void getPage(void){ int sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd == -1){ @@ -15,8 +25,8 @@ void getPage(void){ struct sockaddr_in addr = { .sin_family = AF_INET, - .sin_port = htons(443), - .sin_addr = htonl(0x08080808) + .sin_port = htons(config.port), + .sin_addr = htonl(config.addr), }; if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(addr)) == -1){ @@ -58,11 +68,29 @@ void getPage(void){ strcpy(page, buffer); } -int main(){ +void getUserConfig(int argc, char* argv[]){ + for (int i=1; i