• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * CGI support library definitions for CUPS.
3  *
4  * Copyright © 2020-2024 by OpenPrinting.
5  * Copyright © 2007-2019 by Apple Inc.
6  * Copyright © 1997-2006 by Easy Software Products.
7  *
8  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
9  * information.
10  */
11 
12 #ifndef _CUPS_CGI_H_
13 #  define _CUPS_CGI_H_
14 
15 #  include <stdio.h>
16 #  include <stdlib.h>
17 #  include <time.h>
18 #  include <sys/stat.h>
19 
20 #  ifdef _WIN32
21 #    include <direct.h>
22 #    include <io.h>
23 #  else
24 #    include <unistd.h>
25 #  endif /* _WIN32 */
26 
27 #  include <cups/cups.h>
28 #  include <cups/array.h>
29 #  include "help-index.h"
30 
31 
32 /*
33  * C++ magic...
34  */
35 
36 #  ifdef __cplusplus
37 extern "C" {
38 #  endif /* __cplusplus */
39 
40 /*
41  * Types...
42  */
43 
44 typedef struct cgi_file_s		/**** Uploaded file data ****/
45 {
46   char		tempfile[1024],		/* Temporary file containing data */
47 		*name,			/* Variable name */
48 		*filename,		/* Original filename */
49 		*mimetype;		/* MIME media type */
50   size_t	filesize;		/* Size of uploaded file */
51 } cgi_file_t;
52 
53 
54 /*
55  * Prototypes...
56  */
57 
58 extern void		cgiAbort(const char *title, const char *stylesheet,
59 			         const char *format, ...);
60 extern int		cgiCheckVariables(const char *names);
61 extern void		cgiClearVariables(void);
62 extern void		*cgiCompileSearch(const char *query);
63 extern void		cgiCopyTemplateFile(FILE *out, const char *tmpl);
64 extern void		cgiCopyTemplateLang(const char *tmpl);
65 extern int		cgiDoSearch(void *search, const char *text);
66 extern void		cgiEndHTML(void);
67 extern void		cgiEndMultipart(void);
68 extern char		*cgiFormEncode(char *dst, const char *src,
69 			               size_t dstsize);
70 extern void		cgiFreeSearch(void *search);
71 extern char		*cgiGetArray(const char *name, int element);
72 extern void		cgiGetAttributes(ipp_t *request, const char *tmpl);
73 extern int		cgiGetCheckbox(const char *name);
74 extern const char	*cgiGetCookie(const char *name);
75 extern const cgi_file_t	*cgiGetFile(void);
76 extern cups_array_t	*cgiGetIPPObjects(ipp_t *response, void *search);
77 extern int		cgiGetSize(const char *name);
78 extern char		*cgiGetTemplateDir(void);
79 extern const char	*cgiGetTextfield(const char *name);
80 extern char		*cgiGetVariable(const char *name);
81 extern int		cgiInitialize(void);
82 extern int		cgiIsPOST(void);
83 extern void		cgiMoveJobs(http_t *http, const char *dest, int job_id);
84 extern void		cgiPrintCommand(http_t *http, const char *dest,
85 			                const char *command, const char *title);
86 extern void		cgiPrintTestPage(http_t *http, const char *dest);
87 extern char		*cgiRewriteURL(const char *uri, char *url, int urlsize,
88 			               const char *newresource);
89 extern void		cgiSetArray(const char *name, int element,
90 			            const char *value);
91 extern void		cgiSetCookie(const char *name, const char *value,
92 			             const char *path, const char *domain,
93 				     time_t expires, int secure);
94 extern ipp_attribute_t	*cgiSetIPPObjectVars(ipp_attribute_t *obj,
95 			                     const char *prefix, int element);
96 extern int		cgiSetIPPVars(ipp_t *response, const char *filter_name,
97 			              const char *filter_value,
98 			              const char *prefix, int parent_el);
99 extern void		cgiSetServerVersion(void);
100 extern void		cgiSetSize(const char *name, int size);
101 extern void		cgiSetVariable(const char *name, const char *value);
102 extern void		cgiShowIPPError(const char *message);
103 extern void		cgiShowJobs(http_t *http, const char *dest);
104 extern void		cgiStartHTML(const char *title);
105 extern void		cgiStartMultipart(void);
106 extern int		cgiSupportsMultipart(void);
107 extern const char	*cgiText(const char *message);
108 
109 #  ifdef __cplusplus
110 }
111 #  endif /* __cplusplus */
112 
113 #endif /* !_CUPS_CGI_H_ */
114