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
00033
00034
00035
00036 #ifndef lint
00037 #define PKG_H_VERSION "@(#)$Header: /cvsroot/brlcad/brlcad/include/pkg.h,v 14.14 2006/09/18 05:24:07 lbutler Exp $ (ARL)"
00038 #endif
00039
00040 #ifndef PKG_H_SEENYET
00041 #define PKG_H_SEENYET
00042
00043 #ifndef PKG_EXPORT
00044 # if defined(_WIN32) && !defined(__CYGWIN__) && defined(BRLCAD_DLL)
00045 # ifdef PKG_EXPORT_DLL
00046 # define PKG_EXPORT __declspec(dllexport)
00047 # else
00048 # define PKG_EXPORT __declspec(dllimport)
00049 # endif
00050 # else
00051 # define PKG_EXPORT
00052 # endif
00053 #endif
00054
00055
00056
00057
00058
00059
00060
00061
00062 #if USE_PROTOTYPES
00063 # define PKG_EXTERN(type_and_name,args) extern type_and_name args
00064 # define PKG_ARGS(args) args
00065 #else
00066 # define PKG_EXTERN(type_and_name,args) extern type_and_name()
00067 # define PKG_ARGS(args) ()
00068 #endif
00069
00070
00071 #ifdef __cplusplus
00072 extern "C" {
00073 #endif
00074
00075 struct pkg_conn;
00076
00077 struct pkg_switch {
00078 unsigned short pks_type;
00079 void (*pks_handler)PKG_ARGS((struct pkg_conn*, char*));
00080 char *pks_title;
00081 };
00082
00083
00084
00085
00086
00087
00088
00089
00090 #define PKG_MAGIC 0x41FE
00091 struct pkg_header {
00092 unsigned char pkh_magic[2];
00093 unsigned char pkh_type[2];
00094 unsigned char pkh_len[4];
00095 };
00096
00097 #define PKG_STREAMLEN (32*1024)
00098 struct pkg_conn {
00099 int pkc_fd;
00100 const struct pkg_switch *pkc_switch;
00101 void (*pkc_errlog)PKG_ARGS((char *msg));
00102 struct pkg_header pkc_hdr;
00103 long pkc_len;
00104 unsigned short pkc_type;
00105
00106 char pkc_stream[PKG_STREAMLEN];
00107 int pkc_magic;
00108 int pkc_strpos;
00109
00110 char *pkc_inbuf;
00111 int pkc_incur;
00112 int pkc_inend;
00113 int pkc_inlen;
00114
00115 int pkc_left;
00116
00117 char *pkc_buf;
00118 char *pkc_curpos;
00119 };
00120 #define PKC_NULL ((struct pkg_conn *)0)
00121 #define PKC_ERROR ((struct pkg_conn *)(-1L))
00122
00123
00124 #define pkg_send_vls(type,vlsp,pkg) \
00125 pkg_send( (type), bu_vls_addr((vlsp)), bu_vls_strlen((vlsp))+1, (pkg) )
00126
00127
00128 PKG_EXPORT PKG_EXTERN(int pkg_init, ());
00129 PKG_EXPORT PKG_EXTERN(void pkg_terminate, ());
00130 PKG_EXPORT PKG_EXTERN(int pkg_process, (register struct pkg_conn *));
00131 PKG_EXPORT PKG_EXTERN(int pkg_suckin, (register struct pkg_conn *));
00132 PKG_EXPORT PKG_EXTERN(struct pkg_conn *pkg_open, (const char *host, const char *service, const char *protocol, const char *uname, const char *passwd, const struct pkg_switch* switchp, void (*errlog)PKG_ARGS((char *msg))));
00133 PKG_EXPORT PKG_EXTERN(struct pkg_conn *pkg_transerver, (const struct pkg_switch* switchp, void (*errlog)PKG_ARGS((char *msg))));
00134 PKG_EXPORT PKG_EXTERN(int pkg_permserver, (char *service, char *protocol, int backlog, void (*errlog)PKG_ARGS((char *msg))));
00135 PKG_EXPORT PKG_EXTERN(int pkg_permserver_ip, (char *ipOrHostname, char *service, char *protocol, int backlog, void (*errlog)PKG_ARGS((char *msg))));
00136 PKG_EXPORT PKG_EXTERN(struct pkg_conn *pkg_getclient, (int fd, const struct pkg_switch *switchp, void (*errlog)PKG_ARGS((char *msg)), int nodelay));
00137 PKG_EXPORT PKG_EXTERN(void pkg_close, (struct pkg_conn* pc));
00138 PKG_EXPORT PKG_EXTERN(int pkg_send, (int type, char *buf, int len, struct pkg_conn* pc));
00139 PKG_EXPORT PKG_EXTERN(int pkg_2send, (int type, char *buf1, int len1, char *buf2, int len2, struct pkg_conn* pc));
00140 PKG_EXPORT PKG_EXTERN(int pkg_stream, (int type, char *buf, int len, struct pkg_conn* pc));
00141 PKG_EXPORT PKG_EXTERN(int pkg_flush, (struct pkg_conn* pc));
00142 PKG_EXPORT PKG_EXTERN(int pkg_waitfor, (int type, char *buf, int len, struct pkg_conn* pc));
00143 PKG_EXPORT PKG_EXTERN(char *pkg_bwaitfor, (int type, struct pkg_conn* pc));
00144 PKG_EXPORT PKG_EXTERN(int pkg_block, (struct pkg_conn* pc));
00145
00146
00147 PKG_EXPORT PKG_EXTERN(unsigned short pkg_gshort, (char *buf));
00148 PKG_EXPORT PKG_EXTERN(unsigned long pkg_glong, (char *buf));
00149 PKG_EXPORT PKG_EXTERN(char *pkg_pshort, (char *buf, short unsigned int s));
00150 PKG_EXPORT PKG_EXTERN(char *pkg_plong, (char *buf, long unsigned int l));
00151
00152 #ifdef __cplusplus
00153 }
00154 #endif
00155
00156 #endif
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167