Files
Trashbox/style.c
2026-07-24 02:02:37 +08:00

38 lines
1.1 KiB
C
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#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;
}
// Отдаем CSS с правильными заголовками
printf("Content-type: text/css\n");
printf("Cache-Control: public, max-age=3600\n\n"); // Кэшируем на 1 час
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;
}