00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 typedef union
00033 {
00034 int integer;
00035 gu_boolean boolean;
00036 struct
00037 {
00038 char *text;
00039 } string;
00040 struct
00041 {
00042 int length;
00043 void *data;
00044 } unknown;
00045 } ipp_value_t;
00046
00047
00048 typedef struct ipp_attribute_s
00049 {
00050 struct ipp_attribute_s *next;
00051 int group_tag;
00052 int value_tag;
00053 char *name;
00054 gu_boolean free_name;
00055 gu_boolean free_values;
00056 int num_values;
00057 ipp_value_t values[1];
00058 } ipp_attribute_t;
00059
00060
00061 struct IPP
00062 {
00063 int magic;
00064
00065 const char *root;
00066 const char *path_info;
00067 int bytes_left;
00068 int in_fd;
00069 int out_fd;
00070
00071 const char *remote_user;
00072 const char *remote_addr;
00073
00074 int subst_reply_fd;
00075 unsigned char readbuf[512];
00076 char readbuf_guard;
00077 int readbuf_i;
00078 int readbuf_remaining;
00079 unsigned char writebuf[512];
00080 char writebuf_guard;
00081 int writebuf_i;
00082 int writebuf_remaining;
00083
00084 int version_minor;
00085 int version_major;
00086 int operation_id;
00087 int response_code;
00088 int request_id;
00089
00090 ipp_attribute_t *request_attrs;
00091 ipp_attribute_t *response_attrs_operation;
00092 ipp_attribute_t *response_attrs_printer;
00093 ipp_attribute_t *response_attrs_job;
00094 ipp_attribute_t *response_attrs_unsupported;
00095 };
00096
00097
00098 struct IPP *ipp_new(const char root[], const char path_info[], int content_length, int in_fd, int out_fd);
00099 void ipp_delete(struct IPP *p);
00100 int ipp_get_block(struct IPP *p, char **pptr);
00101 void ipp_set_remote_user(struct IPP *p, const char remote_user[]);
00102 void ipp_set_remote_addr(struct IPP *p, const char remote_addr[]);
00103 void ipp_request_to_fd(struct IPP *p, int fd);
00104 void ipp_reply_from_fd(struct IPP *p, int fd);
00105 unsigned char ipp_get_byte(struct IPP *p);
00106 void ipp_put_byte(struct IPP *p, unsigned char val);
00107 int ipp_get_sb(struct IPP *p);
00108 int ipp_get_ss(struct IPP *p);
00109 int ipp_get_si(struct IPP *p);
00110 void ipp_put_sb(struct IPP *p, int val);
00111 void ipp_put_ss(struct IPP *p, int val);
00112 void ipp_put_si(struct IPP *p, int val);
00113 unsigned char *ipp_get_bytes(struct IPP *p, int len);
00114 void ipp_put_bytes(struct IPP *ipp, const unsigned char *data, int len);
00115 void ipp_put_string(struct IPP *ipp, const char string[]);
00116 void ipp_put_attr(struct IPP *ipp, ipp_attribute_t *attr);
00117 void ipp_parse_request_header(struct IPP *ipp);
00118 void ipp_parse_request_body(struct IPP *ipp);
00119 void ipp_send_reply(struct IPP *ipp, gu_boolean header);
00120 void ipp_add_end(struct IPP *ipp, int group);
00121 void ipp_add_integer(struct IPP *ipp, int group, int tag, const char name[], int value);
00122 void ipp_add_string(struct IPP *ipp, int group, int tag, const char name[], const char value[]);
00123 void ipp_add_strings(struct IPP *ipp, int group, int tag, const char name[], int num_values, const char *values[]);
00124 void ipp_add_printf(struct IPP *ipp, int group, int tag, const char name[], const char value[], ...)
00125 #ifdef __GNUC__
00126 __attribute__ (( format (printf, 5, 6) ))
00127 #endif
00128 ;
00129 void ipp_add_boolean(struct IPP *ipp, int group, int tag, const char name[], gu_boolean value);
00130 ipp_attribute_t *ipp_find_attribute(struct IPP *ipp, int group, int tag, const char name[]);
00131
00132
00133 void debug(const char message[], ...)
00134 #ifdef __GNUC__
00135 __attribute__ (( format (printf, 1, 2) ))
00136 #endif
00137 ;
00138
00139