]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/ipp-private.h
6a4708ed100927c0827e8988939acd22d522d13d
[thirdparty/cups.git] / cups / ipp-private.h
1 /*
2 * Private IPP definitions for CUPS.
3 *
4 * Copyright © 2007-2018 by Apple Inc.
5 * Copyright © 1997-2006 by Easy Software Products.
6 *
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more
8 * information.
9 */
10
11 #ifndef _CUPS_IPP_PRIVATE_H_
12 # define _CUPS_IPP_PRIVATE_H_
13
14 /*
15 * Include necessary headers...
16 */
17
18 # include <cups/cups.h>
19
20
21 /*
22 * C++ magic...
23 */
24
25 # ifdef __cplusplus
26 extern "C" {
27 # endif /* __cplusplus */
28
29
30 /*
31 * Constants...
32 */
33
34 # define IPP_BUF_SIZE (IPP_MAX_LENGTH + 2)
35 /* Size of buffer */
36
37
38 /*
39 * Structures...
40 */
41
42 typedef struct /**** Attribute mapping data ****/
43 {
44 int multivalue; /* Option has multiple values? */
45 const char *name; /* Option/attribute name */
46 ipp_tag_t value_tag; /* Value tag for this attribute */
47 ipp_tag_t group_tag; /* Group tag for this attribute */
48 ipp_tag_t alt_group_tag; /* Alternate group tag for this
49 * attribute */
50 const ipp_op_t *operations; /* Allowed operations for this attr */
51 } _ipp_option_t;
52
53 typedef struct _ipp_file_s _ipp_file_t;/**** File Parser ****/
54 typedef struct _ipp_vars_s _ipp_vars_t;/**** Variables ****/
55
56 typedef int (*_ipp_fattr_cb_t)(_ipp_file_t *f, void *user_data, const char *attr);
57 /**** File Attribute (Filter) Callback ****/
58 typedef int (*_ipp_ferror_cb_t)(_ipp_file_t *f, void *user_data, const char *error);
59 /**** File Parser Error Callback ****/
60 typedef int (*_ipp_ftoken_cb_t)(_ipp_file_t *f, _ipp_vars_t *v, void *user_data, const char *token);
61 /**** File Parser Token Callback ****/
62
63 struct _ipp_vars_s /**** Variables ****/
64 {
65 char *uri, /* URI for printer */
66 scheme[64], /* Scheme from URI */
67 username[256], /* Username from URI */
68 *password, /* Password from URI (if any) */
69 host[256], /* Hostname from URI */
70 portstr[32], /* Port number string */
71 resource[1024]; /* Resource path from URI */
72 int port; /* Port number from URI */
73 int num_vars; /* Number of variables */
74 cups_option_t *vars; /* Array of variables */
75 int password_tries; /* Number of retries for password */
76 _ipp_fattr_cb_t attrcb; /* Attribute (filter) callback */
77 _ipp_ferror_cb_t errorcb; /* Error callback */
78 _ipp_ftoken_cb_t tokencb; /* Token callback */
79 };
80
81 struct _ipp_file_s /**** File Parser */
82 {
83 const char *filename; /* Filename */
84 cups_file_t *fp; /* File pointer */
85 int linenum; /* Current line number */
86 ipp_t *attrs; /* Attributes */
87 ipp_tag_t group_tag; /* Current group for new attributes */
88 };
89
90
91 /*
92 * Prototypes for private functions...
93 */
94
95 /* encode.c */
96 #ifdef DEBUG
97 extern const char *_ippCheckOptions(void);
98 #endif /* DEBUG */
99 extern _ipp_option_t *_ippFindOption(const char *name);
100
101 /* ipp-file.c */
102 extern ipp_t *_ippFileParse(_ipp_vars_t *v, const char *filename, void *user_data);
103 extern int _ippFileReadToken(_ipp_file_t *f, char *token, size_t tokensize);
104
105 /* ipp-vars.c */
106 extern void _ippVarsDeinit(_ipp_vars_t *v);
107 extern void _ippVarsExpand(_ipp_vars_t *v, char *dst, const char *src, size_t dstsize) __attribute__((nonnull(1,2,3)));
108 extern const char *_ippVarsGet(_ipp_vars_t *v, const char *name);
109 extern void _ippVarsInit(_ipp_vars_t *v, _ipp_fattr_cb_t attrcb, _ipp_ferror_cb_t errorcb, _ipp_ftoken_cb_t tokencb);
110 extern const char *_ippVarsPasswordCB(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data);
111 extern int _ippVarsSet(_ipp_vars_t *v, const char *name, const char *value);
112
113
114 /*
115 * C++ magic...
116 */
117
118 # ifdef __cplusplus
119 }
120 # endif /* __cplusplus */
121 #endif /* !_CUPS_IPP_H_ */