diff options
author | Christian Hesse <mail@eworm.de> | 2013-05-29 17:42:27 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2013-05-29 17:42:27 +0200 |
commit | 18998289da11226ea180b1f6bbcb103473d36b6c (patch) | |
tree | 8a5da339e05d170e7d9d959e0e7b28b151f79698 /cqrlogo.c | |
parent | 90536d7963fa30b3cb86b8797a7869612305073b (diff) | |
download | cqrlogo-18998289da11226ea180b1f6bbcb103473d36b6c.tar.gz cqrlogo-18998289da11226ea180b1f6bbcb103473d36b6c.tar.zst |
add comments
Diffstat (limited to 'cqrlogo.c')
-rw-r--r-- | cqrlogo.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); } |