Skip to content
Snippets Groups Projects
Commit 986c04ec authored by Saleh Ahmed Khan's avatar Saleh Ahmed Khan
Browse files

cleaned comments

parent 33bd6650
Branches
No related tags found
Loading
......@@ -13,22 +13,15 @@ void valid_get(char* buffer) { // checks if the request is valid
void parse(char* req, char* root) {
// Extract just the file path from the request
// message into the char array 'path'.
// printf("%s\n", req);
const char* path_start = strchr(req, ' ') + 1;
// printf("%c start\n", *path_start);
const char* path_end = strrchr(req, ' ');
// printf("%c final\n", *path_end);
// int path_len = path_start - path_end;
char path[path_end - path_start];
strncpy(path, path_start, path_end - path_start);
path[sizeof(path)] = '\0'; // null terminator
// printf("root %s\n", root);
// printf("path %s\n", path);
char full_path[sizeof(path) + sizeof(root)];
strcpy(full_path, root);
strcat(full_path, path);
// full_path[sizeof(full_path)-1] = 9;
printf("waiittt %s end\n", full_path);
find_file(full_path);
}
......@@ -37,7 +30,8 @@ void find_file(char* path_to_file) {
fp = fopen(path_to_file, "r");
if (fp != NULL) {
printf("success...\n");fclose(fp);
printf("success...\n");
fclose(fp);
} else {
printf("fail\n");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment