Skip to content

Commit 6b41a71

Browse files
att
1 parent 81abf8b commit 6b41a71

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ teste.c
99
.cache
1010
CWebStudioOne.c
1111
TreinAiContext
12+
mylib.c
1213
release
1314
CWebStudioFirmware
1415
.cacherag

src/consts.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const char *PORTS_FLAGS[]={
2323
"p"
2424
};
2525

26-
const char *DYNAMIC_LIV_FLAGS[]={
26+
const char *DYNAMIC_LIB_FLAGS[]={
2727
"dynamic_lib",
2828
"d"
2929
};
@@ -63,11 +63,17 @@ const char *VERSION_FLAGS[]={
6363
"version",
6464
"v"
6565
};
66-
const char *TIMEOUT_FLAGS[]={
67-
"timeout",
66+
const char *FUNCTION_TIMEOUT_FLAGS[]={
67+
"function_timeout",
6868
"t"
6969
};
7070

71+
const char *CLIENT_TIMEOUT_FLAGS[]={
72+
"client_timeout",
73+
"ct"
74+
};
75+
76+
7177
//====================================ROUTES=========================================
7278
const char *CWEB_FIRMWARE_ROUTE = "/cweb_firmware";
7379
const char *READ_DYNAMIC_LIB = "/cweb_firmware/read_dynamic_lib";

src/main.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,32 @@ int main(int argc, char *argv[]){
3939
if(port_num <= 0){
4040
printf("--port not valid\n");
4141
return 1;
42+
}
43+
int function_timeout = 500;
44+
const char *function_timeout_flag = CArgvParse_get_flag(&args, FUNCTION_TIMEOUT_FLAGS, FLAGS_SIZE, 0);
45+
if(function_timeout_flag){
46+
function_timeout = atoi(function_timeout_flag);
4247
}
43-
int timeout = 500;
44-
const char *timeout_flag = CArgvParse_get_flag(&args, TIMEOUT_FLAGS, FLAGS_SIZE, 0);
45-
if(timeout_flag){
46-
timeout = atoi(timeout_flag);
48+
if(function_timeout <= 0){
49+
printf("--timeout not valid\n");
50+
return 1;
4751
}
48-
49-
const char *dynamic_lib_entrie = CArgvParse_get_flag(&args,DYNAMIC_LIV_FLAGS,FLAGS_SIZE,0);
52+
int client_timeout = 500;
53+
const char *client_timeout_flag = CArgvParse_get_flag(&args, CLIENT_TIMEOUT_FLAGS, FLAGS_SIZE, 1);
54+
if(client_timeout_flag){
55+
client_timeout = atoi(client_timeout_flag);
56+
}
57+
if(client_timeout <= 0){
58+
printf("--timeout not valid\n");
59+
return 1;
60+
}
61+
62+
const char *dynamic_lib_entrie = CArgvParse_get_flag(&args,DYNAMIC_LIB_FLAGS,FLAGS_SIZE,0);
5063
if(!dynamic_lib_entrie){
5164
printf("--dynamic_lib library not provided\n");
5265
return 1;
5366
}
67+
5468
bool is_absolute = dtw_starts_with(dynamic_lib_entrie, "/") || dtw_starts_with(dynamic_lib_entrie, "\\");
5569
if(is_absolute){
5670
strcpy(dynamic_lib_path, dynamic_lib_entrie);
@@ -90,8 +104,8 @@ int main(int argc, char *argv[]){
90104

91105

92106
CwebServer server = newCwebSever(port_num, main_sever);
93-
server.function_timeout = 500;
94-
server.client_timeout = 500;
107+
server.function_timeout = function_timeout;
108+
server.client_timeout = client_timeout;
95109
CwebServer_start(&server);
96110
return 0;
97111
}

0 commit comments

Comments
 (0)