#ifndef WH_LX_XI_H_6d982c37_ #define WH_LX_XI_H_6d982c37_ // Copyright status: this file is in the public domain. #include /* * The LX eXtension Interface, the API used by extension * implementations. These are interfaces designed for use by * extensions, not by client programs. (Extensions may also find some * of the client-program interfaces useful.) * * Any identifier beginning lx_xi__ or LX_XI__ should be considered * internal to the implementation. Use of such identifiers is * dangerous, unsupported, and very much at your own risk. */ typedef unsigned int CARD32; typedef unsigned short int CARD16; typedef unsigned char CARD8; typedef signed int INT32; typedef signed short int INT16; /* * lx_xi_internal_op returns an LX_OP suitable for returning to client * code when the implementation needs to do behind-the-scenes work. * lx_xi_op_finished should be called on such an LX_OP to indicate to * the client code that the op has completed. * * lx_xi_predone_op returns an LX_OP which has already completed. This * is suitable for use when a call is made but the operation can be * completed without a server round-trip. */ extern LX_OP *lx_xi_internal_op(LX_CONN *); extern void lx_xi_op_finished(LX_OP *); extern LX_OP *lx_xi_predone_op(LX_CONN *); /* * Reading and writing multi-byte packet values. * * lx_xi_[rw]_{card,int}{16,32} read (r) and write (w) signed (int) or * unsigned (card) 16- (16) or 32- (32) -bit data. The read versions * are passed a pointer to the first byte and return the value; the * write versions are passed the pointer and the value and return * nothing. */ extern CARD16 lx_xi_r_card16(const unsigned char *); extern CARD32 lx_xi_r_card32(const unsigned char *); extern INT16 lx_xi_r_int16(const unsigned char *); extern INT32 lx_xi_r_int32(const unsigned char *); extern void lx_xi_w_card16(unsigned char *, CARD16); extern void lx_xi_w_card32(unsigned char *, CARD32); extern void lx_xi_w_int16(unsigned char *, INT16); extern void lx_xi_w_int32(unsigned char *, INT32); /* * Report a protocol error. */ extern void lx_xi_protoerr(LX_CONN *, const char *, ...) __attribute__((__format__(__printf__,2,3))); /* * Report a bad-call error. The first arg is the connection, the * second, the call name. (The connection is needed in order to * locate the correct error handler to call.) */ extern void lx_xi_bad_call(LX_CONN *, const char *); /* * Report an out-of-memory error. The arg is the connection. */ extern void lx_xi_nomem_fail(LX_CONN *); /* * Send a fire-and-forget request. * * lx_xi_send_req(xc,req,len); * * just sends the request. * * lx_xi_send_req_free(xc,req,len); * * sends the request and, once it's sent, does free(req). */ extern void lx_xi_send_req(LX_CONN *, const unsigned char *, int); extern void lx_xi_send_req_free(LX_CONN *, unsigned char *, int); /* * Send a request and expect a reply. * * lx_xi_expect_reply(xc,req,len,done,donearg) * * xc is the connection, of course. req and len describe the request * (len is in bytes). done is the function to be called when a reply * is received; donearg is passed as the third arg to done but is * otherwise unused. */ extern LX_OP *lx_xi_expect_reply(LX_CONN *, const unsigned char *, int, void (*)(LX_CONN *, const unsigned char *, void *), void *); /* * This must be called by all extension requests. It's part of the * batching support; if and when extensions need batching, there will * be a different routine to support it. */ extern void lx_xi_nochain(LX_CONN *); /* * Returns true iff the connection has failed. Every extension request * should check this before interacting with the connection. */ extern int lx_xi_conn_failed(LX_CONN *); /* * Converters to and from protocol values. * * Converting to protocol values returns -1 for invalid inputs; * converting from protocol values returns LX_XI_map_error for invalid * inputs. */ #define LX_XI_map_error 0x20000019 // LX_RECTORDER extern int lx_xi_rectorder_to_proto(LX_RECTORDER); extern LX_RECTORDER lx_xi_proto_to_rectorder(unsigned int); extern int lx_xi_boolean_to_proto(int); extern int lx_xi_proto_to_boolean(int); #endif