int open_log() { char logfile[4096]; int loghandle; strcpy(logfile, WEBROOT); strcat(logfile, "/logs/access.log"); loghandle = open(logfile, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, 0600); if (loghandle < 0) { fprintf(stderr, "Couldn't open logfile: %s\n", logfile); exit(1); } else { return loghandle; } } void close_log(int loghandle) { close(loghandle); } void write_log(int loghandle, char string[1024]) { printf("requested file: %s\n", string); write(loghandle, string, sizeof(string)); }