Header | cups/cgi.h |
---|---|
Library | -lcupscgi |
See Also | Programming: Introduction to CUPS Programming |
The CGI API provides Common Gateway Interface functions for CUPS.
Check for the presence of "required" variables.
int cgiCheckVariables (
const char *names
);
1 if all variables present, 0 otherwise
Names may be separated by spaces and/or commas.
Clear all form variables.
void cgiClearVariables (void);
Compile a search string.
void *cgiCompileSearch (
const char *query
);
Search context
Copy a template file and replace all the '{variable}' strings with the variable value.
void cgiCopyTemplateFile (
FILE *out,
const char *tmpl
);
Copy a template file using a language...
void cgiCopyTemplateLang (
const char *tmpl
);
Do a search of some text.
int cgiDoSearch (
void *search,
const char *text
);
Number of matches
End a HTML page.
void cgiEndHTML (void);
End the delivery of a multipart web page.
void cgiEndMultipart (void);
Encode a string as a form variable.
char *cgiFormEncode (
char *dst,
const char *src,
size_t dstsize
);
Destination string
Free a compiled search context.
void cgiFreeSearch (
void *search
);
Get an element from a form array.
const char *cgiGetArray (
const char *name,
int element
);
Element value or NULL
Get the list of attributes that are needed by the template file.
void cgiGetAttributes (
ipp_t *request,
const char *tmpl
);
Get a cookie value.
const char *cgiGetCookie (
const char *name
);
Value or NULL
Get the file (if any) that was submitted in the form.
const cgi_file_t *cgiGetFile (void);
Attached file or NULL
Get the objects in an IPP response.
cups_array_t *cgiGetIPPObjects (
ipp_t *response,
void *search
);
Array of objects
Get the size of a form array value.
int cgiGetSize (
const char *name
);
Number of elements
Get the templates directory...
char *cgiGetTemplateDir (void);
Template directory
Get a CGI variable from the database.
const char *cgiGetVariable (
const char *name
);
Value of variable
Returns NULL if the variable doesn't exist. If the variable is an array of values, returns the last element.
Initialize the CGI variable "database".
int cgiInitialize (void);
Non-zero if there was form data
Determine whether this page was POSTed.
int cgiIsPOST (void);
1 if POST, 0 if GET
Move one or more jobs.
void cgiMoveJobs (
http_t *http,
const char *dest,
int job_id
);
At least one of dest or job_id must be non-zero/NULL.
Print a CUPS command job.
void cgiPrintCommand (
http_t *http,
const char *dest,
const char *command,
const char *title
);
Print a test page.
void cgiPrintTestPage (
http_t *http,
const char *dest
);
Rewrite a printer URI into a web browser URL...
char *cgiRewriteURL (
const char *uri,
char *url,
int urlsize,
const char *newresource
);
New URL
Set array element N to the specified string.
void cgiSetArray (
const char *name,
int element,
const char *value
);
If the variable array is smaller than (element + 1), the intervening elements are set to NULL.
Set a cookie value.
void cgiSetCookie (
const char *name,
const char *value,
const char *path,
const char *domain,
time_t expires,
int secure
);
Set CGI variables from an IPP object.
ipp_attribute_t *cgiSetIPPObjectVars (
ipp_attribute_t *obj,
const char *prefix,
int element
);
Next object
Set CGI variables from an IPP response.
int cgiSetIPPVars (
ipp_t *response,
const char *filter_name,
const char *filter_value,
const char *prefix,
int parent_el
);
Maximum number of elements
Set the server name and CUPS version...
void cgiSetServerVersion (void);
Set the array size.
void cgiSetSize (
const char *name,
int size
);
Set a CGI variable in the database.
void cgiSetVariable (
const char *name,
const char *value
);
If the variable is an array, this truncates the array to a single element.
Show the last IPP error message.
void cgiShowIPPError (
const char *message
);
The caller must still call cgiStartHTML() and cgiEndHTML().
Show print jobs.
void cgiShowJobs (
http_t *http,
const char *dest
);
Start a HTML page.
void cgiStartHTML (
const char *title
);
Start a multipart delivery of a web page.
void cgiStartMultipart (void);
Does the browser support multi-part documents?
int cgiSupportsMultipart (void);
1 if multi-part supported, 0 otherwise
Return localized text.
const char *cgiText (
const char *message
);
Localized message
Delete an index, freeing all memory used.
void helpDeleteIndex (
help_index_t *hi
);
Find a node in an index.
help_node_t *helpFindNode (
help_index_t *hi,
const char *filename,
const char *anchor
);
Node pointer or NULL
Load a help index from disk.
help_index_t *helpLoadIndex (
const char *hifile,
const char *directory
);
Index pointer or NULL
Save a help index to disk.
int helpSaveIndex (
help_index_t *hi,
const char *hifile
);
0 on success, -1 on error
Search an index.
help_index_t *helpSearchIndex (
help_index_t *hi,
const char *query,
const char *section,
const char *filename
);
Search index
Uploaded file data
typedef struct cgi_file_s cgi_file_t;
Help index structure
typedef struct help_index_s help_index_t;
Help node structure...
typedef struct help_node_s help_node_t;
Help word structure...
typedef struct help_word_s help_word_t;
Uploaded file data
struct cgi_file_s {
size_t filesize;
char tempfile[1024], *name, *filename, *mimetype;
};
Help index structure
struct help_index_s {
cups_array_t *nodes;
int search;
cups_array_t *sorted;
};
Help node structure...
struct help_node_s {
char *anchor;
char *filename;
size_t length;
time_t mtime;
off_t offset;
int score;
char *section;
char *text;
cups_array_t *words;
};
Help word structure...
struct help_word_s {
int count;
char *text;
};