summaryrefslogtreecommitdiff
path: root/cgi.c
diff options
context:
space:
mode:
authorMax Christian Pohle2021-12-04 14:29:49 +0100
committerMax Christian Pohle2021-12-04 14:29:49 +0100
commitbef7e1a6f6ed28d580b331063baa35b34a8f1d25 (patch)
tree2fdf190056351d42430bc2241f2c788f02673264 /cgi.c
parent512c406b4fb3bc4054073608707ae07f65a65890 (diff)
downloadohmycgi-labelprinter.tar.bz2
ohmycgi-labelprinter.zip
Prepared `letter` type and updated CSSlabelprinter
Diffstat (limited to 'cgi.c')
-rw-r--r--cgi.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/cgi.c b/cgi.c
index 81149af..a1f5ae2 100644
--- a/cgi.c
+++ b/cgi.c
@@ -37,9 +37,11 @@
37 37
38#include "main.h" 38#include "main.h"
39#include <cups/cups.h> 39#include <cups/cups.h>
40#include <magic.h>
40 41
41static const char * line1 = NULL, * line2 = NULL; 42static const char * line1 = NULL, * line2 = NULL;
42 43
44
43int print_on_correct_printer(void * user_data, unsigned flags, cups_dest_t * dest) { 45int print_on_correct_printer(void * user_data, unsigned flags, cups_dest_t * dest) {
44 if(!strstr(dest->name, user_data)) { 46 if(!strstr(dest->name, user_data)) {
45 // DEBUG("> Wrong printer name: '%s'; try next printer...\n", dest->name); 47 // DEBUG("> Wrong printer name: '%s'; try next printer...\n", dest->name);
@@ -89,7 +91,26 @@ int print_on_correct_printer(void * user_data, unsigned flags, cups_dest_t * des
89 91
90void send_answer_file(Http_Header * http_header, FILE * f) { 92void send_answer_file(Http_Header * http_header, FILE * f) {
91 fputs("HTTP/1.0 200 OK\n", f); 93 fputs("HTTP/1.0 200 OK\n", f);
92 fputs("content-type: text/html\n\n", f); 94
95 DEBUG("> PROBLEM: %s\n", &http_header->url[strlen(http_header->url) - 4]);
96 if(0 == strncmp(&http_header->url[strlen(http_header->url) - 4], ".css", 4)) {
97 fputs("content-type: text/css", f);
98 } else {
99
100 magic_t magic = magic_open(MAGIC_MIME);
101
102 magic_load(magic, NULL);
103 // magic_compile(magic, NULL);
104 const char * mime_type = magic_file(magic, &http_header->url[1]);
105 if(mime_type)
106 fprintf(f, "content-type: %s\n\n", mime_type);
107 else
108 fputs("content-type: text/html; charset=utf-8", f);
109 // fprintf(f, "content-type: %s; charset=utf-8\n\n", magic_file(magic, &http_header->url[1]));
110 magic_close(magic);
111 }
112
113 fputs("\n\n", f);
93 fflush(f); 114 fflush(f);
94 115
95 #define BUFFER_SIZE 1024 116 #define BUFFER_SIZE 1024
..