00001 /* 00002 ** mouse:~ppr/src/include/libppr_query.h 00003 ** Copyright 1995--2003, 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 17 October 2003. 00029 */ 00030 00031 /* 00032 ** This is the definition of the query object. Call one of the query_new_*() functions 00033 ** to create one of these things. 00034 */ 00035 struct QUERY 00036 { 00037 const char *interface; 00038 const char *address; 00039 const char *options; 00040 gu_boolean control_d; 00041 char buf_stdin[512]; 00042 char buf_stdout[512]; 00043 char buf_stderr[512]; 00044 int buf_stdin_len; 00045 int buf_stdout_len; 00046 int buf_stderr_len; 00047 int buf_stdout_eaten; 00048 int buf_stderr_eaten; 00049 gu_boolean eof_stdout; 00050 gu_boolean eof_stderr; 00051 int pipe_stdin[2]; 00052 int pipe_stdout[2]; 00053 int pipe_stderr[2]; 00054 int last_stdout_crlf; 00055 int maxfd; /* first argument for select() */ 00056 char *line; /* last line read from printer */ 00057 int line_len; /* number of bytes currently allocated to line */ 00058 gu_boolean connected; 00059 gu_boolean disconnecting; /* are we going to close() once the output buffer is empty? */ 00060 gu_boolean job_started; /* has query_puts() been called yet? */ 00061 }; 00062 00063 struct QUERY *query_new_byaddress(const char interface[], const char address[], const char options[]); 00064 struct QUERY *query_new_byprinter(const char printer[]); 00065 void query_connect(struct QUERY *q, gu_boolean probe); 00066 void query_puts(struct QUERY *q, const char s[]); 00067 char *query_getline(struct QUERY *q, gu_boolean *is_stderr, int timeout); 00068 void query_sendquery(struct QUERY *q, const char *name, const char values[], const char default_response[], const char pstext[]); 00069 void query_endjob(struct QUERY *q); 00070 void query_disconnect(struct QUERY *q); 00071 void query_delete(struct QUERY *q); 00072 00073 /* end of file */