aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-06-27 13:57:07 +0200
committerGravatar Christian Hesse <mail@eworm.de>2013-06-27 13:57:07 +0200
commit140e173e63c9741eb3f70cb81ef193a88a23d1c4 (patch)
tree65af0773bc683df95ebe7a094e71472144696084
parent5403395bcf563a1f5730ae5941493d6979be3155 (diff)
downloadcqrlogo-140e173e63c9741eb3f70cb81ef193a88a23d1c4.tar.gz
cqrlogo-140e173e63c9741eb3f70cb81ef193a88a23d1c4.tar.zst
read QUERY_STRING for variable scale
-rw-r--r--cqrlogo.c15
1 files changed, 13 insertions, 2 deletions
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;
}