MCPcopy Create free account
hub / github.com/OpenPrinting/cups / is_cgi

Function is_cgi

scheduler/client.c:3200–3246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3198 */
3199
3200static int /* O - 1 = CGI, 0 = file */
3201is_cgi(cupsd_client_t *con, /* I - Client connection */
3202 const char *filename, /* I - Real filename */
3203 struct stat *filestats, /* I - File information */
3204 mime_type_t *type) /* I - MIME type */
3205{
3206 const char *options; /* Options on URL */
3207
3208
3209 /*
3210 * Get the options, if any...
3211 */
3212
3213 if ((options = strchr(con->uri, '?')) != NULL)
3214 {
3215 options ++;
3216 cupsdSetStringf(&(con->query_string), "QUERY_STRING=%s", options);
3217 }
3218
3219 /*
3220 * Check for known types...
3221 */
3222
3223 if (!type || _cups_strcasecmp(type->super, "application"))
3224 {
3225 cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 0.", filename, filestats, type ? type->super : "unknown", type ? type->type : "unknown");
3226 return (0);
3227 }
3228
3229 if (!_cups_strcasecmp(type->type, "x-httpd-cgi") && (filestats->st_mode & 0111) && (getuid() || !(filestats->st_mode & 022)))
3230 {
3231 /*
3232 * "application/x-httpd-cgi" is a CGI script.
3233 */
3234
3235 cupsdSetString(&con->command, filename);
3236
3237 if (options)
3238 cupsdSetStringf(&con->options, " %s", options);
3239
3240 cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 1.", filename, filestats, type->super, type->type);
3241 return (1);
3242 }
3243
3244 cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 0.", filename, filestats, type->super, type->type);
3245 return (0);
3246}
3247
3248
3249/*

Callers 1

cupsdReadClientFunction · 0.85

Calls 4

cupsdSetStringfFunction · 0.85
_cups_strcasecmpFunction · 0.85
cupsdLogClientFunction · 0.85
cupsdSetStringFunction · 0.85

Tested by

no test coverage detected