|
|
|
@ -86,6 +86,8 @@ int |
|
|
|
|
main(){ |
|
|
|
|
int rc = 0; |
|
|
|
|
int http_code = HTTP_ERROR; |
|
|
|
|
// text of errors which must be seen by people
|
|
|
|
|
char *error_msg; |
|
|
|
|
if (access(DIR, W_OK) != 0) { |
|
|
|
|
fprintf(stderr, "Directory %s does not exist or is not writable\n", DIR); |
|
|
|
|
goto out; |
|
|
|
@ -115,6 +117,16 @@ main(){ |
|
|
|
|
} |
|
|
|
|
char *cgi_width = cgiGetValue(cgi, "width"); |
|
|
|
|
char *cgi_height = cgiGetValue(cgi, "height"); |
|
|
|
|
int bal = 0; |
|
|
|
|
if ( (cgi_width != NULL) && (_verify_geometry(cgi_width) == 0) ) |
|
|
|
|
bal++; |
|
|
|
|
if ( (cgi_height != NULL) && (_verify_geometry(cgi_height) == 0) ) |
|
|
|
|
bal++; |
|
|
|
|
if (bal == 1) { |
|
|
|
|
error_msg = "Define both width and height"; |
|
|
|
|
http_code = HTTP_BAD_REQUEST; |
|
|
|
|
goto fcgi_out; |
|
|
|
|
} |
|
|
|
|
char *hex; |
|
|
|
|
int max_try = 10; |
|
|
|
|
for (int i = 1; i <= max_try; i++) { |
|
|
|
@ -139,10 +151,10 @@ main(){ |
|
|
|
|
goto fcgi_out; |
|
|
|
|
} |
|
|
|
|
fprintf(d, "ip=%s\n", ip); |
|
|
|
|
if ( (cgi_width != NULL) && (_verify_geometry(cgi_width) == 0) ) |
|
|
|
|
if (bal == 2) { |
|
|
|
|
fprintf(d, "width=%s\n", cgi_width); |
|
|
|
|
if ( (cgi_height != NULL) && (_verify_geometry(cgi_height) == 0) ) |
|
|
|
|
fprintf(d, "height=%s\n", cgi_height); |
|
|
|
|
} |
|
|
|
|
rc = fclose(d); |
|
|
|
|
if (rc != 0) { |
|
|
|
|
fprintf(stderr, "Error closing file %s/%s\n", DIR, hex); |
|
|
|
@ -159,6 +171,8 @@ fcgi_out: |
|
|
|
|
printf("%s\r\n", "OK"); |
|
|
|
|
rc = 0; |
|
|
|
|
} else { |
|
|
|
|
if (error_msg) |
|
|
|
|
printf("ERROR: %s\r\n", error_msg); |
|
|
|
|
rc = 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|