1*5e7646d2SAndroid Build Coastguard Worker /* 2*5e7646d2SAndroid Build Coastguard Worker * Private IPP definitions for CUPS. 3*5e7646d2SAndroid Build Coastguard Worker * 4*5e7646d2SAndroid Build Coastguard Worker * Copyright © 2007-2018 by Apple Inc. 5*5e7646d2SAndroid Build Coastguard Worker * Copyright © 1997-2006 by Easy Software Products. 6*5e7646d2SAndroid Build Coastguard Worker * 7*5e7646d2SAndroid Build Coastguard Worker * Licensed under Apache License v2.0. See the file "LICENSE" for more 8*5e7646d2SAndroid Build Coastguard Worker * information. 9*5e7646d2SAndroid Build Coastguard Worker */ 10*5e7646d2SAndroid Build Coastguard Worker 11*5e7646d2SAndroid Build Coastguard Worker #ifndef _CUPS_IPP_PRIVATE_H_ 12*5e7646d2SAndroid Build Coastguard Worker # define _CUPS_IPP_PRIVATE_H_ 13*5e7646d2SAndroid Build Coastguard Worker 14*5e7646d2SAndroid Build Coastguard Worker /* 15*5e7646d2SAndroid Build Coastguard Worker * Include necessary headers... 16*5e7646d2SAndroid Build Coastguard Worker */ 17*5e7646d2SAndroid Build Coastguard Worker 18*5e7646d2SAndroid Build Coastguard Worker # include <cups/cups.h> 19*5e7646d2SAndroid Build Coastguard Worker 20*5e7646d2SAndroid Build Coastguard Worker 21*5e7646d2SAndroid Build Coastguard Worker /* 22*5e7646d2SAndroid Build Coastguard Worker * C++ magic... 23*5e7646d2SAndroid Build Coastguard Worker */ 24*5e7646d2SAndroid Build Coastguard Worker 25*5e7646d2SAndroid Build Coastguard Worker # ifdef __cplusplus 26*5e7646d2SAndroid Build Coastguard Worker extern "C" { 27*5e7646d2SAndroid Build Coastguard Worker # endif /* __cplusplus */ 28*5e7646d2SAndroid Build Coastguard Worker 29*5e7646d2SAndroid Build Coastguard Worker 30*5e7646d2SAndroid Build Coastguard Worker /* 31*5e7646d2SAndroid Build Coastguard Worker * Constants... 32*5e7646d2SAndroid Build Coastguard Worker */ 33*5e7646d2SAndroid Build Coastguard Worker 34*5e7646d2SAndroid Build Coastguard Worker # define IPP_BUF_SIZE (IPP_MAX_LENGTH + 2) 35*5e7646d2SAndroid Build Coastguard Worker /* Size of buffer */ 36*5e7646d2SAndroid Build Coastguard Worker 37*5e7646d2SAndroid Build Coastguard Worker 38*5e7646d2SAndroid Build Coastguard Worker /* 39*5e7646d2SAndroid Build Coastguard Worker * Structures... 40*5e7646d2SAndroid Build Coastguard Worker */ 41*5e7646d2SAndroid Build Coastguard Worker 42*5e7646d2SAndroid Build Coastguard Worker typedef union _ipp_request_u /**** Request Header ****/ 43*5e7646d2SAndroid Build Coastguard Worker { 44*5e7646d2SAndroid Build Coastguard Worker struct /* Any Header */ 45*5e7646d2SAndroid Build Coastguard Worker { 46*5e7646d2SAndroid Build Coastguard Worker ipp_uchar_t version[2]; /* Protocol version number */ 47*5e7646d2SAndroid Build Coastguard Worker int op_status; /* Operation ID or status code*/ 48*5e7646d2SAndroid Build Coastguard Worker int request_id; /* Request ID */ 49*5e7646d2SAndroid Build Coastguard Worker } any; 50*5e7646d2SAndroid Build Coastguard Worker 51*5e7646d2SAndroid Build Coastguard Worker struct /* Operation Header */ 52*5e7646d2SAndroid Build Coastguard Worker { 53*5e7646d2SAndroid Build Coastguard Worker ipp_uchar_t version[2]; /* Protocol version number */ 54*5e7646d2SAndroid Build Coastguard Worker ipp_op_t operation_id; /* Operation ID */ 55*5e7646d2SAndroid Build Coastguard Worker int request_id; /* Request ID */ 56*5e7646d2SAndroid Build Coastguard Worker } op; 57*5e7646d2SAndroid Build Coastguard Worker 58*5e7646d2SAndroid Build Coastguard Worker struct /* Status Header */ 59*5e7646d2SAndroid Build Coastguard Worker { 60*5e7646d2SAndroid Build Coastguard Worker ipp_uchar_t version[2]; /* Protocol version number */ 61*5e7646d2SAndroid Build Coastguard Worker ipp_status_t status_code; /* Status code */ 62*5e7646d2SAndroid Build Coastguard Worker int request_id; /* Request ID */ 63*5e7646d2SAndroid Build Coastguard Worker } status; 64*5e7646d2SAndroid Build Coastguard Worker 65*5e7646d2SAndroid Build Coastguard Worker /**** New in CUPS 1.1.19 ****/ 66*5e7646d2SAndroid Build Coastguard Worker struct /* Event Header @since CUPS 1.1.19/macOS 10.3@ */ 67*5e7646d2SAndroid Build Coastguard Worker { 68*5e7646d2SAndroid Build Coastguard Worker ipp_uchar_t version[2]; /* Protocol version number */ 69*5e7646d2SAndroid Build Coastguard Worker ipp_status_t status_code; /* Status code */ 70*5e7646d2SAndroid Build Coastguard Worker int request_id; /* Request ID */ 71*5e7646d2SAndroid Build Coastguard Worker } event; 72*5e7646d2SAndroid Build Coastguard Worker } _ipp_request_t; 73*5e7646d2SAndroid Build Coastguard Worker 74*5e7646d2SAndroid Build Coastguard Worker typedef union _ipp_value_u /**** Attribute Value ****/ 75*5e7646d2SAndroid Build Coastguard Worker { 76*5e7646d2SAndroid Build Coastguard Worker int integer; /* Integer/enumerated value */ 77*5e7646d2SAndroid Build Coastguard Worker 78*5e7646d2SAndroid Build Coastguard Worker char boolean; /* Boolean value */ 79*5e7646d2SAndroid Build Coastguard Worker 80*5e7646d2SAndroid Build Coastguard Worker ipp_uchar_t date[11]; /* Date/time value */ 81*5e7646d2SAndroid Build Coastguard Worker 82*5e7646d2SAndroid Build Coastguard Worker struct 83*5e7646d2SAndroid Build Coastguard Worker { 84*5e7646d2SAndroid Build Coastguard Worker int xres, /* Horizontal resolution */ 85*5e7646d2SAndroid Build Coastguard Worker yres; /* Vertical resolution */ 86*5e7646d2SAndroid Build Coastguard Worker ipp_res_t units; /* Resolution units */ 87*5e7646d2SAndroid Build Coastguard Worker } resolution; /* Resolution value */ 88*5e7646d2SAndroid Build Coastguard Worker 89*5e7646d2SAndroid Build Coastguard Worker struct 90*5e7646d2SAndroid Build Coastguard Worker { 91*5e7646d2SAndroid Build Coastguard Worker int lower, /* Lower value */ 92*5e7646d2SAndroid Build Coastguard Worker upper; /* Upper value */ 93*5e7646d2SAndroid Build Coastguard Worker } range; /* Range of integers value */ 94*5e7646d2SAndroid Build Coastguard Worker 95*5e7646d2SAndroid Build Coastguard Worker struct 96*5e7646d2SAndroid Build Coastguard Worker { 97*5e7646d2SAndroid Build Coastguard Worker char *language; /* Language code */ 98*5e7646d2SAndroid Build Coastguard Worker char *text; /* String */ 99*5e7646d2SAndroid Build Coastguard Worker } string; /* String with language value */ 100*5e7646d2SAndroid Build Coastguard Worker 101*5e7646d2SAndroid Build Coastguard Worker struct 102*5e7646d2SAndroid Build Coastguard Worker { 103*5e7646d2SAndroid Build Coastguard Worker int length; /* Length of attribute */ 104*5e7646d2SAndroid Build Coastguard Worker void *data; /* Data in attribute */ 105*5e7646d2SAndroid Build Coastguard Worker } unknown; /* Unknown attribute type */ 106*5e7646d2SAndroid Build Coastguard Worker 107*5e7646d2SAndroid Build Coastguard Worker /**** New in CUPS 1.1.19 ****/ 108*5e7646d2SAndroid Build Coastguard Worker ipp_t *collection; /* Collection value @since CUPS 1.1.19/macOS 10.3@ */ 109*5e7646d2SAndroid Build Coastguard Worker } _ipp_value_t; 110*5e7646d2SAndroid Build Coastguard Worker 111*5e7646d2SAndroid Build Coastguard Worker struct _ipp_attribute_s /**** IPP attribute ****/ 112*5e7646d2SAndroid Build Coastguard Worker { 113*5e7646d2SAndroid Build Coastguard Worker ipp_attribute_t *next; /* Next attribute in list */ 114*5e7646d2SAndroid Build Coastguard Worker ipp_tag_t group_tag, /* Job/Printer/Operation group tag */ 115*5e7646d2SAndroid Build Coastguard Worker value_tag; /* What type of value is it? */ 116*5e7646d2SAndroid Build Coastguard Worker char *name; /* Name of attribute */ 117*5e7646d2SAndroid Build Coastguard Worker int num_values; /* Number of values */ 118*5e7646d2SAndroid Build Coastguard Worker _ipp_value_t values[1]; /* Values */ 119*5e7646d2SAndroid Build Coastguard Worker }; 120*5e7646d2SAndroid Build Coastguard Worker 121*5e7646d2SAndroid Build Coastguard Worker struct _ipp_s /**** IPP Request/Response/Notification ****/ 122*5e7646d2SAndroid Build Coastguard Worker { 123*5e7646d2SAndroid Build Coastguard Worker ipp_state_t state; /* State of request */ 124*5e7646d2SAndroid Build Coastguard Worker _ipp_request_t request; /* Request header */ 125*5e7646d2SAndroid Build Coastguard Worker ipp_attribute_t *attrs; /* Attributes */ 126*5e7646d2SAndroid Build Coastguard Worker ipp_attribute_t *last; /* Last attribute in list */ 127*5e7646d2SAndroid Build Coastguard Worker ipp_attribute_t *current; /* Current attribute (for read/write) */ 128*5e7646d2SAndroid Build Coastguard Worker ipp_tag_t curtag; /* Current attribute group tag */ 129*5e7646d2SAndroid Build Coastguard Worker 130*5e7646d2SAndroid Build Coastguard Worker /**** New in CUPS 1.2 ****/ 131*5e7646d2SAndroid Build Coastguard Worker ipp_attribute_t *prev; /* Previous attribute (for read) @since CUPS 1.2/macOS 10.5@ */ 132*5e7646d2SAndroid Build Coastguard Worker 133*5e7646d2SAndroid Build Coastguard Worker /**** New in CUPS 1.4.4 ****/ 134*5e7646d2SAndroid Build Coastguard Worker int use; /* Use count @since CUPS 1.4.4/macOS 10.6.?@ */ 135*5e7646d2SAndroid Build Coastguard Worker /**** New in CUPS 2.0 ****/ 136*5e7646d2SAndroid Build Coastguard Worker int atend, /* At end of list? */ 137*5e7646d2SAndroid Build Coastguard Worker curindex; /* Current attribute index for hierarchical search */ 138*5e7646d2SAndroid Build Coastguard Worker }; 139*5e7646d2SAndroid Build Coastguard Worker 140*5e7646d2SAndroid Build Coastguard Worker typedef struct _ipp_option_s /**** Attribute mapping data ****/ 141*5e7646d2SAndroid Build Coastguard Worker { 142*5e7646d2SAndroid Build Coastguard Worker int multivalue; /* Option has multiple values? */ 143*5e7646d2SAndroid Build Coastguard Worker const char *name; /* Option/attribute name */ 144*5e7646d2SAndroid Build Coastguard Worker ipp_tag_t value_tag; /* Value tag for this attribute */ 145*5e7646d2SAndroid Build Coastguard Worker ipp_tag_t group_tag; /* Group tag for this attribute */ 146*5e7646d2SAndroid Build Coastguard Worker ipp_tag_t alt_group_tag; /* Alternate group tag for this 147*5e7646d2SAndroid Build Coastguard Worker * attribute */ 148*5e7646d2SAndroid Build Coastguard Worker const ipp_op_t *operations; /* Allowed operations for this attr */ 149*5e7646d2SAndroid Build Coastguard Worker } _ipp_option_t; 150*5e7646d2SAndroid Build Coastguard Worker 151*5e7646d2SAndroid Build Coastguard Worker typedef struct _ipp_file_s _ipp_file_t;/**** File Parser ****/ 152*5e7646d2SAndroid Build Coastguard Worker typedef struct _ipp_vars_s _ipp_vars_t;/**** Variables ****/ 153*5e7646d2SAndroid Build Coastguard Worker 154*5e7646d2SAndroid Build Coastguard Worker typedef int (*_ipp_fattr_cb_t)(_ipp_file_t *f, void *user_data, const char *attr); 155*5e7646d2SAndroid Build Coastguard Worker /**** File Attribute (Filter) Callback ****/ 156*5e7646d2SAndroid Build Coastguard Worker typedef int (*_ipp_ferror_cb_t)(_ipp_file_t *f, void *user_data, const char *error); 157*5e7646d2SAndroid Build Coastguard Worker /**** File Parser Error Callback ****/ 158*5e7646d2SAndroid Build Coastguard Worker typedef int (*_ipp_ftoken_cb_t)(_ipp_file_t *f, _ipp_vars_t *v, void *user_data, const char *token); 159*5e7646d2SAndroid Build Coastguard Worker /**** File Parser Token Callback ****/ 160*5e7646d2SAndroid Build Coastguard Worker 161*5e7646d2SAndroid Build Coastguard Worker struct _ipp_vars_s /**** Variables ****/ 162*5e7646d2SAndroid Build Coastguard Worker { 163*5e7646d2SAndroid Build Coastguard Worker char *uri, /* URI for printer */ 164*5e7646d2SAndroid Build Coastguard Worker scheme[64], /* Scheme from URI */ 165*5e7646d2SAndroid Build Coastguard Worker username[256], /* Username from URI */ 166*5e7646d2SAndroid Build Coastguard Worker *password, /* Password from URI (if any) */ 167*5e7646d2SAndroid Build Coastguard Worker host[256], /* Hostname from URI */ 168*5e7646d2SAndroid Build Coastguard Worker portstr[32], /* Port number string */ 169*5e7646d2SAndroid Build Coastguard Worker resource[1024]; /* Resource path from URI */ 170*5e7646d2SAndroid Build Coastguard Worker int port; /* Port number from URI */ 171*5e7646d2SAndroid Build Coastguard Worker int num_vars; /* Number of variables */ 172*5e7646d2SAndroid Build Coastguard Worker cups_option_t *vars; /* Array of variables */ 173*5e7646d2SAndroid Build Coastguard Worker int password_tries; /* Number of retries for password */ 174*5e7646d2SAndroid Build Coastguard Worker _ipp_fattr_cb_t attrcb; /* Attribute (filter) callback */ 175*5e7646d2SAndroid Build Coastguard Worker _ipp_ferror_cb_t errorcb; /* Error callback */ 176*5e7646d2SAndroid Build Coastguard Worker _ipp_ftoken_cb_t tokencb; /* Token callback */ 177*5e7646d2SAndroid Build Coastguard Worker }; 178*5e7646d2SAndroid Build Coastguard Worker 179*5e7646d2SAndroid Build Coastguard Worker struct _ipp_file_s /**** File Parser */ 180*5e7646d2SAndroid Build Coastguard Worker { 181*5e7646d2SAndroid Build Coastguard Worker const char *filename; /* Filename */ 182*5e7646d2SAndroid Build Coastguard Worker cups_file_t *fp; /* File pointer */ 183*5e7646d2SAndroid Build Coastguard Worker int linenum; /* Current line number */ 184*5e7646d2SAndroid Build Coastguard Worker ipp_t *attrs; /* Attributes */ 185*5e7646d2SAndroid Build Coastguard Worker ipp_tag_t group_tag; /* Current group for new attributes */ 186*5e7646d2SAndroid Build Coastguard Worker }; 187*5e7646d2SAndroid Build Coastguard Worker 188*5e7646d2SAndroid Build Coastguard Worker 189*5e7646d2SAndroid Build Coastguard Worker /* 190*5e7646d2SAndroid Build Coastguard Worker * Prototypes for private functions... 191*5e7646d2SAndroid Build Coastguard Worker */ 192*5e7646d2SAndroid Build Coastguard Worker 193*5e7646d2SAndroid Build Coastguard Worker /* encode.c */ 194*5e7646d2SAndroid Build Coastguard Worker #ifdef DEBUG 195*5e7646d2SAndroid Build Coastguard Worker extern const char *_ippCheckOptions(void) _CUPS_PRIVATE; 196*5e7646d2SAndroid Build Coastguard Worker #endif /* DEBUG */ 197*5e7646d2SAndroid Build Coastguard Worker extern _ipp_option_t *_ippFindOption(const char *name) _CUPS_PRIVATE; 198*5e7646d2SAndroid Build Coastguard Worker 199*5e7646d2SAndroid Build Coastguard Worker /* ipp-file.c */ 200*5e7646d2SAndroid Build Coastguard Worker extern ipp_t *_ippFileParse(_ipp_vars_t *v, const char *filename, void *user_data) _CUPS_PRIVATE; 201*5e7646d2SAndroid Build Coastguard Worker extern int _ippFileReadToken(_ipp_file_t *f, char *token, size_t tokensize) _CUPS_PRIVATE; 202*5e7646d2SAndroid Build Coastguard Worker 203*5e7646d2SAndroid Build Coastguard Worker /* ipp-vars.c */ 204*5e7646d2SAndroid Build Coastguard Worker extern void _ippVarsDeinit(_ipp_vars_t *v) _CUPS_PRIVATE; 205*5e7646d2SAndroid Build Coastguard Worker extern void _ippVarsExpand(_ipp_vars_t *v, char *dst, const char *src, size_t dstsize) _CUPS_NONNULL(1,2,3) _CUPS_PRIVATE; 206*5e7646d2SAndroid Build Coastguard Worker extern const char *_ippVarsGet(_ipp_vars_t *v, const char *name) _CUPS_PRIVATE; 207*5e7646d2SAndroid Build Coastguard Worker extern void _ippVarsInit(_ipp_vars_t *v, _ipp_fattr_cb_t attrcb, _ipp_ferror_cb_t errorcb, _ipp_ftoken_cb_t tokencb) _CUPS_PRIVATE; 208*5e7646d2SAndroid Build Coastguard Worker extern const char *_ippVarsPasswordCB(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data) _CUPS_PRIVATE; 209*5e7646d2SAndroid Build Coastguard Worker extern int _ippVarsSet(_ipp_vars_t *v, const char *name, const char *value) _CUPS_PRIVATE; 210*5e7646d2SAndroid Build Coastguard Worker 211*5e7646d2SAndroid Build Coastguard Worker 212*5e7646d2SAndroid Build Coastguard Worker /* 213*5e7646d2SAndroid Build Coastguard Worker * C++ magic... 214*5e7646d2SAndroid Build Coastguard Worker */ 215*5e7646d2SAndroid Build Coastguard Worker 216*5e7646d2SAndroid Build Coastguard Worker # ifdef __cplusplus 217*5e7646d2SAndroid Build Coastguard Worker } 218*5e7646d2SAndroid Build Coastguard Worker # endif /* __cplusplus */ 219*5e7646d2SAndroid Build Coastguard Worker #endif /* !_CUPS_IPP_H_ */ 220