1 /******************************************************************************
14 * \brief BotSense /dev/null library python swig interface definitions file.
16 * \author Robin Knight (robin.knight@roadnarrows.com)
19 * (C) 2010. RoadNarrows LLC.
20 * (http://www.roadnarrows.com)
25 * Permission is hereby granted, without written agreement and without
26 * license or royalty fees, to use, copy, modify, and distribute this
27 * software and its documentation for any purpose, provided that
28 * (1) The above copyright notice and the following two paragraphs
29 * appear in all copies of the source code and (2) redistributions
30 * including binaries reproduces these notices in the supporting
31 * documentation. Substantial modifications to this software may be
32 * copyrighted by their authors and need not follow the licensing terms
33 * described here, provided that the new terms are clearly indicated in
34 * all files where they apply.
36 * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
37 * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
38 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
39 * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
40 * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
41 * THE POSSIBILITY OF SUCH DAMAGE.
43 * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
44 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
45 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
46 * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
47 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
49 ******************************************************************************/
53 #include "botsense/BotSense.h"
54 #include "botsense/bsNull.h"
60 * \brief Swig generated null wrapper c file.
65 * Required RNR C Types
67 typedef unsigned char byte_t;
68 typedef unsigned short ushort_t;
69 typedef unsigned int uint_t;
70 typedef unsigned long ulong_t;
74 * Required BotSense C Types
76 typedef struct _bsClientStruct *BsClient_P;
77 typedef int BsVConnHnd_T;
79 /* the swigged interface */
80 %include "botsense/bsNull.h"
84 * Higher-level python interface to the BotSense Null C library.
90 BotSense DevNull Python Inline Extensions and Wrappers.
94 ## \package BotSense.bsNull
96 ## \brief BotSense Swigged Null Python Interface Module.
98 ## \author Robin Knight (robin.knight@roadnarrows.com)
101 ## (C) 2010. RoadNarrows LLC.\n
102 ## (http://www.roadnarrows.com)\n
103 ## All Rights Reserved
106 import BotSenseCore as bsCore
107 import BotSenseError as bsError
108 import BotSenseTypes as bsTypes
111 def NullGetMsgName(client, hndVConn, msgId):
112 """ Get the DevNull message name.
114 For each (virtual connection, message id) 2-tuple, there can be a known
115 name string (provided the id is valid and an application provides the
119 client - BotSenseTypes.BsClient instance.
120 hndVConn - Virtual connection handle (ignored).
121 msgId - DevNull message id.
124 Returns message name string if it can be determined.
125 Otherwise returns 'unknown'.
127 bsTypes.BsClient.ChkClient(client)
128 return bsNullGetMsgName(client.pClient, hndVConn, msgId)
130 def NullReqOpen(client, trace=False):
131 """ Proxy server request to establish a virtual connection to the /dev/null
134 Raises a BotSenseError exception on failure.
137 client - BotSenseTypes.BsClient instance.
138 trace - Initial message tracing enable(true)/disable(false) state.
141 New virtual connection handle.
143 bsTypes.BsClient.ChkClient(client)
144 hndVConn = bsNullReqOpen(client.pClient, trace)
145 bsError.ChkReturnIsNonNeg(hndVConn,
146 "Client %s: DevNull Open request failed." % (client.AttrGetName()))
149 def NullReqClose(client, hndVConn):
150 """ Proxy server request to close client's proxied /dev/null device virtual
153 Raises a BotSenseError exception on failure.
156 client - BotSenseTypes.BsClient instance.
157 hndVConn - Virtual connection handle.
159 bsTypes.BsClient.ChkClient(client)
160 rc = bsNullReqClose(client.pClient, hndVConn)
161 bsError.ChkReturnIsOk(rc,
162 "Client %s: DevNull Close request failed." % (client.AttrGetName()))
164 def NullReqWrite(client, hndVConn, wbuf):
165 """ DevNull request to write /dev/null.
167 Raises a BotSenseError exception on failure.
170 client - BotSenseTypes.BsClient instance.
171 hndVConn - Virtual connection handle.
175 Number of bytes written.
177 bsTypes.BsClient.ChkClient(client)
178 wbytebuf = bsTypes.ByteBuf.Clone(wbuf)
179 wbytebuf.copyToSwigObj(len(wbytebuf))
180 n = bsNullReqWrite(client.pClient, hndVConn, wbytebuf.getSwigObj(),
182 bsError.ChkReturnIsNonNeg(n,
183 "Client %s: DevNull Write request failed." % (client.AttrGetName()))