Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char* indexes(const char* path)
- {
- int res_p; // store access return integer
- int res_h;
- char php[strlen(path) + 1 + 9];
- char html[strlen(path) + 1 + 10];
- strcpy(php, path);
- strcat(php, "index.php");
- const char* php_c =(const char*)php;
- strcpy(html, path);
- strcat(html, "index.html");
- const char* html_c =(const char*)html;
- char* path_p = malloc(strlen(path) + 1 + 9);
- strcpy(path_p, path);
- strcat(path_p, "index.php");
- char* path_h = malloc(strlen(path) + 1 + 10);
- strcpy(path_h, path);
- strcat(path_h, "index.html");
- res_p = access(php_c, F_OK);
- res_h = access(html_c, F_OK);
- if (res_p == 0)
- return path_p;
- else
- {
- if (res_h == 0)
- return path_h;
- else
- return NULL;
- }
- }
- bool load(FILE* file, BYTE** content, size_t* length)
- {
- int counter = 0;
- BYTE* ptr;
- ptr = (BYTE *)malloc(sizeof(BYTE));
- BYTE* b_ptr = ptr;
- while(fread(b_ptr, sizeof(BYTE), 1, file) == 1)
- {
- counter++;
- ptr = (BYTE *)realloc(ptr,sizeof(BYTE)*(counter + 1));
- b_ptr++;
- }
- *content = ptr;
- *length = counter;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement