1 /** 2 * Copyright (C) 2001-2004 Artifex Software, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person 5 * obtaining a copy of this software and associated documentation 6 * files (the "Software"), to deal in the Software without 7 * restriction, including without limitation the rights to use, copy, 8 * modify, merge, publish, distribute, sublicense, and/or sell copies 9 * of the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 * SOFTWARE. 23 **/ 24 25 /* This file contains common data types for IJS */ 26 27 /* IJS_VERSION is decimal version number times 100 */ 28 #define IJS_VERSION 35 29 30 typedef int ijs_bool; 31 32 #ifndef FALSE 33 #define FALSE 0 34 #endif 35 #ifndef TRUE 36 #define TRUE 1 37 #endif 38 39 typedef enum { 40 IJS_CMD_ACK, 41 IJS_CMD_NAK, 42 IJS_CMD_PING, 43 IJS_CMD_PONG, 44 IJS_CMD_OPEN, 45 IJS_CMD_CLOSE, 46 IJS_CMD_BEGIN_JOB, 47 IJS_CMD_END_JOB, 48 IJS_CMD_CANCEL_JOB, 49 IJS_CMD_QUERY_STATUS, 50 IJS_CMD_LIST_PARAMS, 51 IJS_CMD_ENUM_PARAM, 52 IJS_CMD_SET_PARAM, 53 IJS_CMD_GET_PARAM, 54 IJS_CMD_BEGIN_PAGE, 55 IJS_CMD_SEND_DATA_BLOCK, 56 IJS_CMD_END_PAGE, 57 IJS_CMD_EXIT 58 } IjsCommand; 59 60 typedef int IjsJobId; 61 62 #define IJS_EIO -2 /* I/O error */ 63 #define IJS_EPROTO -3 /* protocol error */ 64 #define IJS_ERANGE -4 /* out of range */ 65 #define IJS_EINTERNAL -5 /* internal error */ 66 #define IJS_ENYI -6 /* not yet implemented */ 67 #define IJS_ESYNTAX -7 /* syntax error */ 68 #define IJS_ECOLORSPACE -8 /* unknown color space */ 69 #define IJS_EUNKPARAM -9 /* unknown parameter */ 70 #define IJS_EJOBID -10 /* job id doesn't match */ 71 #define IJS_ETOOMANYJOBS -11 /* reached limit of server's #jobs */ 72 #define IJS_EBUF -12 /* buffer isn't big enough */ 73 74 #define IJS_HELO_STR "IJS\n\252v1\n" 75 #define IJS_RESP_STR "IJS\n\253v1\n" 76 77 typedef struct { 78 int fd; 79 char buf[4096]; 80 int buf_size; 81 } IjsSendChan; 82 83 typedef struct { 84 int fd; 85 char buf[4096]; 86 int buf_size; 87 int buf_idx; 88 } IjsRecvChan; 89 90 void 91 ijs_send_init (IjsSendChan *ch, int fd); 92 93 int 94 ijs_send_int (IjsSendChan *ch, int val); 95 96 int 97 ijs_send_begin (IjsSendChan *ch, IjsCommand cmd); 98 99 int 100 ijs_send_block (IjsSendChan *ch, const char *buf, int len); 101 102 int 103 ijs_send_buf (IjsSendChan *ch); 104 105 int 106 ijs_get_int (const char *p); 107 108 void 109 ijs_recv_init (IjsRecvChan *ch, int fd); 110 111 int 112 ijs_recv_read (IjsRecvChan *ch, char *buf, int size); 113 114 int 115 ijs_recv_buf (IjsRecvChan *ch); 116 117 int 118 ijs_recv_ack (IjsRecvChan *ch); 119 120 int 121 ijs_recv_int (IjsRecvChan *ch, int *val); 122 123 int 124 ijs_recv_block (IjsRecvChan *ch, char *buf, int buf_size); 125