From 18998289da11226ea180b1f6bbcb103473d36b6c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 May 2013 17:42:27 +0200 Subject: add comments --- cqrlogo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cqrlogo.c b/cqrlogo.c index b76fb13..43e353f 100644 --- a/cqrlogo.c +++ b/cqrlogo.c @@ -66,6 +66,7 @@ int main(int argc, char **argv) { gchar *buffer; gsize size; + /* check if we have environment variables from CGI */ if ((http_referer = getenv("HTTP_REFERER")) == NULL || (server_name = getenv("SERVER_NAME")) == NULL) { printf("This is a CGI executable. Running without a web service is not supported.\n" @@ -73,13 +74,14 @@ int main(int argc, char **argv) { return EXIT_FAILURE; } + /* prepare pattern matching */ pattern = malloc(11 + strlen(server_name)); sprintf(pattern, "^http://%s/", server_name); if ((rc = regcomp(&preg, pattern, 0)) != 0) printf("regcomp() failed, returning nonzero (%d)\n", rc); + /* check if the QR-Code is for the correct server */ if ((rc = regexec(&preg, http_referer, nmatch, pmatch, 0)) != 0) { - /* stolen... */ http_referer = malloc(44 + strlen(server_name)); sprintf(http_referer, "This QR Code has been stolen from http://%s/!", server_name); } -- cgit v1.2.3-54-g00ecf