Advertisement
Guest User

Untitled

a guest
May 23rd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. char* indexes(const char* path){
  2.     char* indexhtml = "/index.html";
  3.     char* indexphp = "/index.php";
  4.     char* pathhtml = malloc(strlen(path) + strlen(indexhtml) + 1);
  5.     strcpy(pathhtml, path);
  6.     strcat(pathhtml, indexhtml);
  7.     char* pathphp = malloc(strlen(path) + strlen(indexphp) +1);
  8.     strcpy(pathphp, path);
  9.     strcat(pathphp, indexphp);
  10.     if(access(pathhtml, F_OK) == 1){
  11.         return pathhtml;
  12.     }else if(access(pathphp, F_OK) == 1) return pathphp;
  13.     return NULL;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement