Files
Trashbox/style.c
2025-11-20 16:05:18 +08:00

37 lines
1000 B
C
Executable File

// Подгрузка CSS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
int main() {
char css_path[1024] = "/home/romkazvo/www/cgi-bin/style.css";
struct stat st;
if (stat(css_path, &st) != 0) {
printf("Status: 404 Not Found\n");
printf("Content-type: text/plain\n\n");
printf("CSS file not found\n");
return 1;
}
printf("Content-type: text/css\n");
printf("Cache-Control: public, max-age=3600\n\n");
FILE *css_file = fopen(css_path, "r");
if (!css_file) {
printf("Status: 500 Internal Server Error\n");
printf("Content-type: text/plain\n\n");
printf("Cannot open CSS file\n");
return 1;
}
char buffer[4096];
size_t bytes_read;
while ((bytes_read = fread(buffer, 1, sizeof(buffer), css_file)) > 0) {
fwrite(buffer, 1, bytes_read, stdout);
}
fclose(css_file);
return 0;
}