makefile
This commit is contained in:
parent
bcc7058591
commit
800ba738dc
15
Makefile
15
Makefile
|
@ -3,10 +3,19 @@ CFLAGS = -g -Wall
|
||||||
|
|
||||||
TARGET = server
|
TARGET = server
|
||||||
|
|
||||||
all: $(TARGET)
|
.PATH: ${.CURDIR}/src
|
||||||
|
.OBJPATH: ${.CURDIR}/obj
|
||||||
|
|
||||||
$(TARGET): src/$(TARGET).c
|
all: server
|
||||||
$(CC) $(CFLAGS) -o $(TARGET) src/$(TARGET).c
|
|
||||||
|
server: server.o file.o
|
||||||
|
$(CC) $(CFLAGS) -o server server.o file.o
|
||||||
|
|
||||||
|
server.o: server.c server.h
|
||||||
|
$(CC) $(CFLAGS) -c server.c
|
||||||
|
|
||||||
|
file.o: file.c file.h
|
||||||
|
$(CC) $(CFLAGS) -c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(TARGET)
|
$(RM) $(TARGET)
|
||||||
|
|
|
@ -13,7 +13,7 @@ void get_file_path(char *uri, char *file_path) {
|
||||||
strncat(uri, "index.html", 11);
|
strncat(uri, "index.html", 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(file_path, "htdocs", 7);
|
strncpy(file_path, file_dir, (int)sizeof(file_dir));
|
||||||
printf("%s\n", file_path);
|
printf("%s\n", file_path);
|
||||||
strncat(file_path, uri, (int)sizeof(uri));
|
strncat(file_path, uri, (int)sizeof(uri));
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,5 @@
|
||||||
|
|
||||||
void get_file_path(char *uri, char *file_path);
|
void get_file_path(char *uri, char *file_path);
|
||||||
void get_mime_type(char *file, char *mime);
|
void get_mime_type(char *file, char *mime);
|
||||||
|
|
||||||
|
static const char file_dir[] = "htdocs";
|
||||||
|
|
|
@ -122,7 +122,10 @@ int main() {
|
||||||
|
|
||||||
printf("Size of File: %ld\n", file_size);
|
printf("Size of File: %ld\n", file_size);
|
||||||
|
|
||||||
send_response(client_sock_fd, OK_HEAD, "text/html", file, file_size);
|
char mime_type[15];
|
||||||
|
get_mime_type(uri, mime_type);
|
||||||
|
|
||||||
|
send_response(client_sock_fd, OK_HEAD, mime_type, file, file_size);
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue