From 140e173e63c9741eb3f70cb81ef193a88a23d1c4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 27 Jun 2013 13:57:07 +0200 Subject: read QUERY_STRING for variable scale --- cqrlogo.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'cqrlogo.c') diff --git a/cqrlogo.c b/cqrlogo.c index dc76eac..5e522cb 100644 --- a/cqrlogo.c +++ b/cqrlogo.c @@ -70,10 +70,14 @@ int main(int argc, char **argv) { int rc = 0; GdkPixbuf *pixbuf; + int scale = 0; gchar *buffer; gsize size; + /* get query string for later use */ + char * query_string = getenv("QUERY_STRING"); + /* check if we have environment variables from CGI */ if ((server_name = getenv("SERVER_NAME")) == NULL) { fprintf(stderr, "This is a CGI executable. Running without a web service is not supported.\n" @@ -100,13 +104,20 @@ int main(int argc, char **argv) { free(pattern); } + /* do we have a special scale? */ + if (query_string) + sscanf(query_string, "scale=%u", &scale); + + if (!scale) + scale = QRCODE_SCALE; + /* initialize type system for glib < 2.36 */ #ifndef GLIB_VERSION_2_36 g_type_init(); #endif - if ((pixbuf = encode_qrcode(http_referer, QRCODE_SCALE)) == NULL) { - if ((pixbuf = encode_qrcode(server_name, QRCODE_SCALE)) == NULL) { + if ((pixbuf = encode_qrcode(http_referer, scale)) == NULL) { + if ((pixbuf = encode_qrcode(server_name, scale)) == NULL) { fprintf(stderr, "Could not generate QR-Code.\n"); return EXIT_FAILURE; } -- cgit v1.2.3-54-g00ecf