Main Page | Data Structures | File List | Globals

include/ipp_utils.h

00001 /*
00002 ** mouse:~ppr/src/ipp/ipp_utils.h
00003 ** Copyright 1995--2004, Trinity College Computing Center.
00004 ** Written by David Chappell.
00005 **
00006 ** Redistribution and use in source and binary forms, with or without
00007 ** modification, are permitted provided that the following conditions are met:
00008 ** 
00009 ** * Redistributions of source code must retain the above copyright notice,
00010 ** this list of conditions and the following disclaimer.
00011 ** 
00012 ** * Redistributions in binary form must reproduce the above copyright
00013 ** notice, this list of conditions and the following disclaimer in the
00014 ** documentation and/or other materials provided with the distribution.
00015 ** 
00016 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
00020 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00021 ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00022 ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00023 ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00024 ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00025 ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
00026 ** POSSIBILITY OF SUCH DAMAGE.
00027 **
00028 ** Last modified 11 February 2004.
00029 */
00030 
00031 /* This union holds any kind of IPP value. */
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 /* This structure holds any kind of IPP attribute. */
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 /* The IPP object. */
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 /* IPP object methods */
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 /* Other functions */
00133 void debug(const char message[], ...)
00134 #ifdef __GNUC__
00135 __attribute__ (( format (printf, 1, 2) ))
00136 #endif
00137 ;
00138 
00139 /* end of file */

Generated on Fri Feb 20 15:17:47 2004 for PPR Libraries by doxygen 1.3.5