botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
bsProxyModIF.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: BotSense
4 //
5 // File: bsProxyModIF.h
6 //
7 /*! \file
8  *
9  * $LastChangedDate: 2010-08-20 11:36:38 -0600 (Fri, 20 Aug 2010) $
10  * $Rev: 568 $
11  *
12  * \brief \h_botsense bsProxy Dynamically Linked Library module interface.
13  *
14  * The client side assumes responsibility for "doing the right thing". So,
15  * bsProxy does minimal consistency checking.
16  *
17  * A bsProxy module must be thread safe. The bsProxy device thread provides
18  * context control and sequencing.
19  *
20  * The bsProxy provides a unique handle to identify a specific
21  * device-module instance (virtual connection).
22  *
23  * A bsProxy interface module:
24  * \li Typically supports simultaneous multiple device-module instances.
25  * \li Should support different devices of the same class simultaneously.
26  * (e.g. /dev/ttyS0 and /dev/ttyUSB0).
27  * \li Should support different handles to the same device-module association.
28  *
29  * \author Robin Knight (robin.knight@roadnarrows.com)
30  *
31  * \copyright
32  * \h_copy 2010-2017. RoadNarrows LLC.\n
33  * http://www.roadnarrows.com\n
34  * All Rights Reserved
35  */
36 // Permission is hereby granted, without written agreement and without
37 // license or royalty fees, to use, copy, modify, and distribute this
38 // software and its documentation for any purpose, provided that
39 // (1) The above copyright notice and the following two paragraphs
40 // appear in all copies of the source code and (2) redistributions
41 // including binaries reproduces these notices in the supporting
42 // documentation. Substantial modifications to this software may be
43 // copyrighted by their authors and need not follow the licensing terms
44 // described here, provided that the new terms are clearly indicated in
45 // all files where they apply.
46 //
47 // IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
48 // OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
49 // PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
50 // DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
51 // EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
52 // THE POSSIBILITY OF SUCH DAMAGE.
53 //
54 // THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
55 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
56 // FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
57 // "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
58 // PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
59 //
60 ////////////////////////////////////////////////////////////////////////////////
61 
62 #ifndef _BSPROXYMODIF_H
63 #define _BSPROXYMODIF_H
64 
65 #include "rnr/rnrconfig.h"
66 #include "rnr/netmsgs.h"
67 
68 #include "botsense/BotSense.h"
69 
70 C_DECLS_BEGIN
71 
72 
73 // ---------------------------------------------------------------------------
74 // Exported Interface Module Symbols
75 // ---------------------------------------------------------------------------
76 
77 /*!
78  * \brief Required Module Symbols. See below for function prototypes.
79  */
80 #define BSMOD_SYM_INIT bsModInit ///< module initialization function
81 #define BSMOD_SYM_EXIT bsModExit ///< module deinit exit function
82 #define BSMOD_SYM_OPEN bsModOpen ///< open device function
83 #define BSMOD_SYM_CLOSE bsModClose ///< close device function
84 #define BSMOD_SYM_REQUEST bsModRequest ///< process client request function
85 #define BSMOD_SYM_TRACE bsModTrace ///< enable/disable tracing function
86 #define BSMOD_SYM_INFO bsModInfo ///< get module static info function
87 
88 /*!
89  * \brief Convert expanded macro parameter to string literal.
90  * \param x Parameter.
91  */
92 #define _S_EXP(x) _S_LIT(x)
93 
94 /*!
95  * \brief Convert macro parameter to string literal.
96  * \param x Parameter.
97  */
98 #define _S_LIT(x) #x
99 
100 /*!
101  * \brief Required Module Symbols Strings.
102  */
103 #define BSMOD_SYM_INIT_S _S_EXP(BSMOD_SYM_INIT) ///< init function string
104 #define BSMOD_SYM_EXIT_S _S_EXP(BSMOD_SYM_EXIT) ///< exit function string
105 #define BSMOD_SYM_OPEN_S _S_EXP(BSMOD_SYM_OPEN) ///< open function string
106 #define BSMOD_SYM_CLOSE_S _S_EXP(BSMOD_SYM_CLOSE) ///< close function string
107 #define BSMOD_SYM_REQUEST_S _S_EXP(BSMOD_SYM_REQUEST) ///< request func string
108 #define BSMOD_SYM_TRACE_S _S_EXP(BSMOD_SYM_TRACE) ///< tracing func string
109 #define BSMOD_SYM_INFO_S _S_EXP(BSMOD_SYM_INFO) ///< info function string
110 
111 
112 // ---------------------------------------------------------------------------
113 // Interface Module Data Types and Helper Macros
114 // ---------------------------------------------------------------------------
115 
116 /*!
117  * \brief Standard bsProxy static interface module information structure type.
118  */
119 typedef struct
120 {
121  const char *mod_name; ///< module load name sans OS dependent substrings
122  const char *brief; ///< brief one-line description
123  const char *version; ///< dotted version x.y.z[-app[-a.b.c]]
124  const char *date; ///< version date
125  const char *maintainer; ///< maintainer/owner
126  const char *license; ///< short license/copyright statement
127 } BsModInfo_T;
128 
129 /*!
130  * \brief Useful indirect indexing of handle to resource instance structure.
131  *
132  * A module's implementation is not required to use this data structure and the
133  * associated functions. However, it can save developer's time in many
134  * instances when many handle values must be are mapped to few resources.
135  */
136 typedef struct
137 {
138  byte_t m_vecIndex[BSPROXY_VCONN_MOD_NUMOF]; ///< vecIndex[handle] -> index
139  void **m_vecRsrc; ///< vecRsrc[index] -> rsrc
140  uint_t m_uMaxResources; ///< maximum resource count
141  uint_t m_uInUseCount; ///< resources in-use count
143 
144 /*!
145  * \brief Test if the handle is in the valid module virtual connection range.
146  *
147  * \param hndVConn Virtual connection handle.
148  */
149 #define BSMOD_IS_VCONN_HANDLE(hndVConn) \
150  (((int)(hndVConn) >= BSPROXY_VCONN_MOD_MIN) && \
151  ((int)(hndVConn) <= BSPROXY_VCONN_MOD_MAX))
152 
153 /*!
154  * \brief Test if the resource table resource handle slot is free.
155  *
156  * \param pRsrcTbl Pointer to resource table.
157  * \param hndVConn Virtual connection handle.
158  */
159 #define BSMOD_RSRC_IS_FREE(pRsrcTbl, hndVConn) \
160  (BSMOD_IS_VCONN_HANDLE(hndVConn) && \
161  (pRsrcTbl)->m_vecIndex[hndVConn] == (byte_t)BSPROXY_VCONN_UNDEF)
162 
163 /*!
164  * \brief Test if the resource table resource handle slot is in-use.
165  *
166  * \param pRsrcTbl Pointer to resource table.
167  * \param hndVConn Virtual connection handle.
168  */
169 #define BSMOD_RSRC_IS_INUSE(pRsrcTbl, hndVConn) \
170  (BSMOD_IS_VCONN_HANDLE(hndVConn) && \
171  (pRsrcTbl)->m_vecIndex[hndVConn] != (byte_t)BSPROXY_VCONN_UNDEF)
172 
173 /*!
174  * \brief Get the resource index given the handle.
175  *
176  * \param pRsrcTbl Pointer to resource table.
177  * \param hndVConn Virtual connection handle.
178  *
179  * \return On success, returns \h_ge 0 index. Else returns -1.
180  */
181 #define BSMOD_RSRC_INDEX(pRsrcTbl, hndVConn) \
182  ( BSMOD_IS_VCONN_HANDLE(hndVConn)? \
183  ((pRsrcTbl)->m_vecIndex[hndVConn] != (byte_t)BSPROXY_VCONN_UNDEF? \
184  (int)((pRsrcTbl)->m_vecIndex[hndVConn]): -1): \
185  -1 \
186  )
187 
188 /*!
189  * \brief Get the resource given the handle.
190  *
191  * \param pRsrcTbl Pointer to resource table.
192  * \param hndVConn Virtual connection handle.
193  *
194  * \return On success, returns pointer to resource. Else returns NULL.
195  */
196 #define BSMOD_RSRC(pRsrcTbl, hndVConn) \
197  ( BSMOD_IS_VCONN_HANDLE(hndVConn)? \
198  ((pRsrcTbl)->m_vecIndex[hndVConn] != (byte_t)BSPROXY_VCONN_UNDEF? \
199  ((pRsrcTbl)->m_vecRsrc[(pRsrcTbl)->m_vecIndex[hndVConn]]): NULL): \
200  NULL \
201  )
202 
203 /*!
204  * \brief Get the resouce table current in-use count.
205  *
206  * \param pRsrcTbl Pointer to resource table.
207  */
208 #define BSMOD_RSRC_INUSE_COUNT(pRsrcTbl) ((pRsrcTbl)->m_uInUseCount)
209 
210 /*!
211  * \brief What to iterate over.
212  */
213 typedef enum
214 {
215  BsModIterOverDevUri, ///< iterator over device URI
216  BsModIterOverModUri, ///< iterator over module URI
217  BsModIterOverVConn ///< iterator over virtual connections (no pattern)
219 
220 /*!
221  * \brief Module Iterator Type.
222  */
223 typedef struct
224 {
225  BsModIterOver_T m_eOver; ///< iterator over enum
226  BsVConnHnd_T m_hndVConn; ///< virtual connection handle
227  char *m_sDevUri; ///< device URI
228  char *m_sModUri; ///< module URI
229  int m_rd; ///< module's resource descriptor
230 } BsModIter_T;
231 
232 /*!
233  * \brief Interface Module callbacks to bsProxy services type.
234  */
235 typedef struct
236 {
237  /*!
238  * \brief Send module-specific repsonse callback function.
239  *
240  * \param hndVConn Virtual connection handle.
241  * \param uTid Request-Response transaction id.
242  * \param uMsgId Response message id.
243  * \param bufRsp Packed repsonse message body.
244  * \param uRspLen Length of response in buffer (number of bytes).
245  */
246  void (*m_cbSendRsp)(BsVConnHnd_T hndVConn,
247  BsTid_T uTid,
248  BsMsgId_T uMsgId,
249  byte_t bufRsp[],
250  size_t uRspLen);
251 
252  /*!
253  * \brief Send generic ok repsonse callback function.
254  *
255  * \param hndVConn Virtual connection handle.
256  * \param uTid Request-Response transaction id.
257  */
258  void (*m_cbSendOkRsp)(BsVConnHnd_T hndVConn, BsTid_T uTid);
259 
260  /*!
261  * \brief Send generic error repsonse callback function.
262  *
263  * \param hndVConn Virtual connection handle.
264  * \param uTid Request-Response transaction id.
265  * \param nECode \copydoc doc_param_ecode
266  * \param sErrFmt Error format string.
267  * \param ... Variable arguments to format string.
268  */
269  void (*m_cbSendErrorRsp)(BsVConnHnd_T hndVConn,
270  BsTid_T uTid,
271  int nECode,
272  const char *sErrFmt,
273  ...);
274 
275  /*!
276  * \brief Allocatae a new module resource table of fixed size.
277  *
278  * The resource table is indexed by the virtual connection handle.
279  *
280  * \param nMaxResources Maximum number of simultaneous resources supported.
281  *
282  * \return Pointer to allocated resource block.
283  */
284  BsModRsrcTbl_T *(*m_cbModRsrcTblNew)(int nMaxResources);
285 
286  /*!
287  * \brief Delete an allocated resource table.
288  *
289  * \warning Module-specific resources should be freed up prior to calling this
290  * function.
291  *
292  * \param pRsrcTbl Pointer to resource table.
293  */
294  void (*m_cbModRsrcTblDelete)(BsModRsrcTbl_T *pRsrcTbl);
295 
296  /*!
297  * \brief Add a new resource to the resource table.
298  *
299  * \param pRsrcTbl Pointer to resource table.
300  * \param hndVConn Virtual connection handle.
301  * \param pRsrc Pointer to allocated resource associated with handle.
302  *
303  * \copydoc doc_return_std
304  */
305  int (*m_cbModRsrcAdd)(BsModRsrcTbl_T *pRsrcTbl,
306  BsVConnHnd_T hndVConn,
307  void *pRsrc);
308 
309  /*!
310  * \brief Remove a resource from the resource table.
311  *
312  * The resource is not deleted.
313  *
314  * \param pRsrcTbl Pointer to resource table.
315  * \param hndVConn Virtual connection handle.
316  *
317  * \return On success, returns pointer to removed resource. On failure, NULL
318  * is returned.
319  */
320  void *(*m_cbModRsrcRemove)(BsModRsrcTbl_T *pRsrcTbl, BsVConnHnd_T hndVConn);
321 
322  /*!
323  * \brief Copy the device URI associated with the virtual connection.
324  *
325  * \param hndVConn Virtual connection handle.
326  * \param [out] dest Destination buffer.
327  * \param n Size of buffer.
328  *
329  * \return Pointer to destination buffer dest.
330  */
331  const char *(*m_fnGetDevUri)(BsVConnHnd_T hndVConn, char dest[], size_t n);
332 
333  /*!
334  * \brief Start an iterator over the virtual connections matching the given
335  * pattern.
336  *
337  * If a virtual connection match is found, an iterator is allocated and its
338  * data is filled with the first set of information.
339  *
340  * The caller must delete the iterator by calling \ref m_cbModIterNext()
341  * until there are no more matches (auto-delete) or by calling \ref
342  * m_cbModIterDelete().
343  *
344  * \param eOver What pattern to iterator over (see \ref BsModIterOver_T).
345  * \param sPattern Device or module URI pattern string.
346  *
347  * \return On success, returns the pointer to the allocacted module
348  * iterator.\n
349  * On failure, NULL is returned.
350  */
351  BsModIter_T *(*m_cbModIterFirst)(BsModIterOver_T eOver, const char *sPattern);
352 
353  /*!
354  * \brief Get the next set of information given the iterator state.
355  *
356  * If a virtual connection match is found, an iterator data is updated.
357  *
358  * If no match is found, the iterator is auto-deleted.
359  *
360  * \param pIter Initialized, allocated iterator.
361  *
362  * \return On success, returns the pointer to the iterator.\n
363  * On failure, NULL is returned.
364  */
365  BsModIter_T *(*m_cbModIterNext)(BsModIter_T *pIter);
366 
367  /*!
368  * \brief Delete the module iterator.
369  *
370  * \param pIter Module iterator.
371  */
372  void (*m_cbModIterDelete)(BsModIter_T *pIter);
373 
374  // load a library - server keeps track - shares handle between modules
375  // client get symbols it needs
377 
378 
379 // ---------------------------------------------------------------------------
380 // Interface Module Logging, Error and Exception Responses
381 // ---------------------------------------------------------------------------
382 
383 /*!
384  * \brief Log Interface Module Warning.
385  *
386  * \param hndVConn Virtual connection handle.
387  * \param ecode \h_botsense error code.
388  * \param wfmt Warning output format string literal.
389  * \param ... Warning variable arguments.
390  */
391 #define BSMOD_LOG_WARN(hndVConn, ecode, wfmt, ...) \
392  LOGDIAG3("Warning: VConn=%d: %s(): %s(ecode=%d): " wfmt, \
393  hndVConn, LOGFUNCNAME, \
394  bsStrError(ecode), ((ecode)>=0? (ecode): -(ecode)), \
395  ##__VA_ARGS__)
396 
397 /*!
398  * \brief Log Interface Module Error.
399  *
400  * \param hndVConn Virtual connection handle.
401  * \param ecode \h_botsense error code.
402  * \param efmt Error output format string literal.
403  * \param ... Error variable arguments.
404  */
405 #define BSMOD_LOG_ERROR(hndVConn, ecode, efmt, ...) \
406  LOGERROR("VConn=%d: %s(): %s(ecode=%d): " efmt, \
407  hndVConn, LOGFUNCNAME, \
408  bsStrError(ecode), (ecode>=0? ecode: -ecode), \
409  ##__VA_ARGS__)
410 
411 /*!
412  * \brief Log Interface Module NetMsgs (Un)Packing Error.
413  *
414  * \param hndVConn Virtual connection handle.
415  * \param nmecode NetMsgs error code.
416  * \param efmt Error output format string literal.
417  * \param ... Error variable arguments.
418  */
419 #define BSMOD_LOG_NMERROR(hndVConn, nmecode, efmt, ...) \
420  BSMOD_LOG_ERROR(hndVConn, BS_ECODE_BAD_MSG, "%s(nmecode=%d): " efmt, \
421  nmStrError(nmecode), (nmecode>=0? nmecode: -nmecode), \
422  ##__VA_ARGS__)
423 
424 /*!
425  * \brief Log Interface Module System Error.
426  *
427  * \param hndVConn Virtual connection handle.
428  * \param efmt Error output format string litteral.
429  * \param ... Error variable arguments.
430  */
431 #define BSMOD_LOG_SYSERROR(hndVConn, efmt, ...) \
432  LOGERROR("VConn=%d: %s(): %s(ecode=%d): %s(errno=%d): " efmt, \
433  hndVConn, LOGFUNCNAME, \
434  bsStrError(BS_ECODE_SYS), BS_ECODE_SYS, \
435  strerror(errno), errno, ##__VA_ARGS__)
436 
437 /*!
438  * \brief Log \h_botsense Error and Send Error Response.
439  *
440  * \param pCb Pointer to server callbacks.
441  * \param hndVConn Virtual connection handle.
442  * \param uTid Request-Response transaction id.
443  * \param ecode \h_botsense error code.
444  * \param efmt Error output format string literal.
445  * \param ... Error variable arguments.
446  */
447 #define BSMOD_SEND_ERROR_RSP(pCb, hndVConn, uTid, ecode, efmt, ...) \
448  do \
449  { \
450  BSMOD_LOG_ERROR(hndVConn, ecode, efmt, ##__VA_ARGS__); \
451  (pCb)->m_cbSendErrorRsp(hndVConn, uTid, ecode, efmt, ##__VA_ARGS__); \
452  } while(0)
453 
454 /*!
455  * \brief Log NetMsgs (Un)Packing Error and Send Error Response.
456  *
457  * \param pCb Pointer to server callbacks.
458  * \param hndVConn Virtual connection handle.
459  * \param uTid Request-Response transaction id.
460  * \param nmecode NetMsgs error code.
461  * \param efmt Error output format string literal.
462  * \param ... Error variable arguments.
463  */
464 #define BSMOD_SEND_NMERROR_RSP(pCb, hndVConn, uTid, nmecode, efmt, ...) \
465  do \
466  { \
467  BSMOD_LOG_NMERROR(hndVConn, nmecode, efmt, ##__VA_ARGS__); \
468  (pCb)->m_cbSendErrorRsp(hndVConn, uTid, BS_ECODE_BAD_MSG, efmt, \
469  ##__VA_ARGS__); \
470  } while(0)
471 
472 /*!
473  * \brief Log System Error and Send Error Response.
474  *
475  * \param pCb Pointer to server callbacks.
476  * \param hndVConn Virtual connection handle.
477  * \param uTid Request-Response transaction id.
478  * \param efmt Error output format string literal.
479  * \param ... Error variable arguments.
480  */
481 #define BSMOD_SEND_SYSERROR_RSP(pCb, hndVConn, uTid, efmt, ...) \
482  do \
483  { \
484  BSMOD_LOG_SYSERROR(hndVConn, efmt, ##__VA_ARGS__); \
485  (pCb)->m_cbSendErrorRsp(hndVConn, uTid, BS_ECODE_SYS, \
486  "%s(errno=%d): " efmt, \
487  strerror(errno), errno, ##__VA_ARGS__); \
488  } while(0)
489 
490 /*!
491  * \brief Check if handle is within the range of module handles.
492  *
493  * If the check is false, an appropriate error is logged and the calling
494  * function is immediately exited by invoking a <b>return</b> with the
495  * appropriate \h_lt 0 error code.
496  *
497  * \param hndVConn Virtual connection handle.
498  */
499 #define BSMOD_TRY_VCONN_HND_RANGE(hndVConn) \
500  do \
501  { \
502  if( !BSMOD_IS_VCONN_HANDLE(hndVConn) ) \
503  { \
504  BSMOD_LOG_ERROR(hndVConn, BS_ECODE_BAD_VCONN_HND, \
505  "Module vconn handle out-of-range."); \
506  return -BS_ECODE_BAD_VCONN_HND; \
507  } \
508  } while(0)
509 
510 
511 // ---------------------------------------------------------------------------
512 // Module Exported Interface
513 // ---------------------------------------------------------------------------
514 
515 /*!
516  * \brief Initialize module.
517  *
518  * Called once after module is loaded.
519  *
520  * Global module initialization and resource allocation should be done here.
521  *
522  * \param sModUri Expanded, canonical module path name.
523  * \param pCallbacks Pointer to a set of module -> bsProxy core callback
524  * functions.
525  *
526  * \copydoc doc_return_std
527  */
528 typedef int (BsModInitFunc_T)(const char *sModUri,
529  const BsModProxyCb_T *pCallbacks);
530 typedef BsModInitFunc_T *BsModInitFunc_P; ///< pointer to init function
531 
532 /*!
533  * \brief Exit module.
534  *
535  * Called once prior to module being unloaded.
536  *
537  * Any module owned resources should be freed here. Any active handles
538  * associated opened devices should be closed.
539  */
540 typedef void (BsModExitFunc_T)();
541 typedef BsModExitFunc_T *BsModExitFunc_P; ///< pointer to exit function
542 
543 /*!
544  * \brief Open device controlled by module and associate with handle.
545  *
546  * Subsequent calls to the module use the given handle to associate the
547  * specific module-device instance.
548  *
549  * The argument buffer contains packed message arguements specific to the
550  * device and module.
551  *
552  * \param hndVConn Virtual connection handle.
553  * \param bTrace Do [not] enable message tracing on this handle.
554  * \param sDevUri Expanded, canonical device path name.
555  * \param argbuf Packed specific open configuration arguments submessage.
556  * \param uArgLen Length of packed argumets in buffer (number of bytes).
557  *
558  * \return
559  * On success, returns a unique resource descriptor \h_ge 0 which is typically
560  * an opened file descriptor or socket descriptor, but can be module defined.
561  * \copydoc doc_return_ecode
562  */
563 typedef int (BsModOpenFunc_T)(BsVConnHnd_T hndVConn,
564  bool_t bTrace,
565  const char *sDevUri,
566  byte_t argbuf[],
567  size_t uArgLen);
568 typedef BsModOpenFunc_T *BsModOpenFunc_P; ///< pointer to open function
569 
570 /*!
571  * \brief Close device controlled by module and disassociate handle.
572  *
573  * The handle instance specific resources should be freed.
574  *
575  * \param hndVConn Virtual connection handle.
576  *
577  * \return
578  * \copydoc doc_return_std
579  */
580 typedef int (BsModCloseFunc_T)(BsVConnHnd_T hndVConn);
581 typedef BsModCloseFunc_T *BsModCloseFunc_P; ///< pointer to close function
582 
583 /*!
584  * \brief Service client-specific request directed to this interface module.
585  *
586  * \note A module-specific request service must send a response.
587  *
588  * \param hndVConn Virtual connection handle.
589  * \param uTid Request-Response transaction id.
590  * \param uMsgIdReq Request message id.
591  * \param bufReq Packed request message buffer.
592  * \param uReqLen Length of request in buffer (number of bytes).
593  *
594  * \copydoc doc_return_std
595  */
596 typedef int (BsModRequestFunc_T)(BsVConnHnd_T hndVConn,
597  BsTid_T uTid,
598  BsMsgId_T uMsgIdReq,
599  byte_t bufReq[],
600  size_t uReqLen);
601 typedef BsModRequestFunc_T *BsModRequestFunc_P; ///< pointer to request func.
602 
603 /*!
604  * \brief Enable/disable message tracing on handle.
605  *
606  * \param hndVConn Virtual connection handle.
607  * \param bTrace Do [not] enable message tracing on this handle.
608  *
609  * \copydoc doc_return_std
610  */
611 typedef int (BsModTraceFunc_T)(BsVConnHnd_T hndVConn, bool_t bTrace);
612 typedef BsModTraceFunc_T *BsModTraceFunc_P; ///< pointer to msg trace func.
613 
614 /*!
615  * \brief Query for the static module information.
616  *
617  * \return
618  * Pointer to module static information.
619  */
620 typedef const BsModInfo_T *(BsModInfoFunc_T)();
621 typedef BsModInfoFunc_T *BsModInfoFunc_P; ///< pointer to mod info function
622 
623 
624 //..............................................................................
625 // Module Prototypes
626 //..............................................................................
627 
628 extern BsModInitFunc_T BSMOD_SYM_INIT; ///< init prototype
629 extern BsModExitFunc_T BSMOD_SYM_EXIT; ///< exit prototype
630 extern BsModOpenFunc_T BSMOD_SYM_OPEN; ///< open prototype
631 extern BsModCloseFunc_T BSMOD_SYM_CLOSE; ///< close prototype
632 extern BsModRequestFunc_T BSMOD_SYM_REQUEST; ///< request prototype
633 extern BsModTraceFunc_T BSMOD_SYM_TRACE; ///< trace prototype
634 extern BsModInfoFunc_T BSMOD_SYM_INFO; ///< mod info prototype
635 
636 C_DECLS_END
637 
638 
639 #endif // _BSPROXYMODIF_H
uint_t BsMsgId_T
client message id type [0-64k].
Definition: BotSense.h:188
iterator over virtual connections (no pattern)
Definition: bsProxyModIF.h:217
#define BSMOD_SYM_TRACE
enable/disable tracing function
Definition: bsProxyModIF.h:85
BsModTraceFunc_T * BsModTraceFunc_P
pointer to msg trace func.
Definition: bsProxyModIF.h:612
Useful indirect indexing of handle to resource instance structure.
Definition: bsProxyModIF.h:136
BsModRequestFunc_T * BsModRequestFunc_P
pointer to request func.
Definition: bsProxyModIF.h:601
BsModCloseFunc_T * BsModCloseFunc_P
pointer to close function
Definition: bsProxyModIF.h:581
const char * maintainer
maintainer/owner
Definition: bsProxyModIF.h:125
uint_t BsTid_T
client transaction id type [0-255].
Definition: BotSense.h:172
uint_t m_uInUseCount
resources in-use count
Definition: bsProxyModIF.h:141
BsModInfoFunc_T * BsModInfoFunc_P
pointer to mod info function
Definition: bsProxyModIF.h:621
#define BSMOD_SYM_INIT
Required Module Symbols. See below for function prototypes.
Definition: bsProxyModIF.h:80
const char * brief
brief one-line description
Definition: bsProxyModIF.h:122
BsModExitFunc_T * BsModExitFunc_P
pointer to exit function
Definition: bsProxyModIF.h:541
int( BsModOpenFunc_T)(BsVConnHnd_T hndVConn, bool_t bTrace, const char *sDevUri, byte_t argbuf[], size_t uArgLen)
Open device controlled by module and associate with handle.
Definition: bsProxyModIF.h:563
const BsModInfo_T *( BsModInfoFunc_T)()
Query for the static module information.
Definition: bsProxyModIF.h:620
const char * mod_name
module load name sans OS dependent substrings
Definition: bsProxyModIF.h:121
int( BsModCloseFunc_T)(BsVConnHnd_T hndVConn)
Close device controlled by module and disassociate handle.
Definition: bsProxyModIF.h:580
#define BSMOD_SYM_OPEN
open device function
Definition: bsProxyModIF.h:82
Interface Module callbacks to bsProxy services type.
Definition: bsProxyModIF.h:235
int( BsModTraceFunc_T)(BsVConnHnd_T hndVConn, bool_t bTrace)
Enable/disable message tracing on handle.
Definition: bsProxyModIF.h:611
#define BSMOD_SYM_REQUEST
process client request function
Definition: bsProxyModIF.h:84
int( BsModInitFunc_T)(const char *sModUri, const BsModProxyCb_T *pCallbacks)
Initialize module.
Definition: bsProxyModIF.h:528
BsModOpenFunc_T * BsModOpenFunc_P
pointer to open function
Definition: bsProxyModIF.h:568
char * m_sDevUri
device URI
Definition: bsProxyModIF.h:227
iterator over device URI
Definition: bsProxyModIF.h:215
uint_t m_uMaxResources
maximum resource count
Definition: bsProxyModIF.h:140
int m_rd
module&#39;s resource descriptor
Definition: bsProxyModIF.h:229
#define BSMOD_SYM_CLOSE
close device function
Definition: bsProxyModIF.h:83
const char * date
version date
Definition: bsProxyModIF.h:124
Standard bsProxy static interface module information structure type.
Definition: bsProxyModIF.h:119
#define BSMOD_SYM_INFO
get module static info function
Definition: bsProxyModIF.h:86
BsVConnHnd_T m_hndVConn
virtual connection handle
Definition: bsProxyModIF.h:226
int( BsModRequestFunc_T)(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
Service client-specific request directed to this interface module.
Definition: bsProxyModIF.h:596
const char * version
dotted version x.y.z[-app[-a.b.c]]
Definition: bsProxyModIF.h:123
#define BSPROXY_VCONN_MOD_NUMOF
number of module-specific handles
Definition: BotSense.h:143
Module Iterator Type.
Definition: bsProxyModIF.h:223
#define BSMOD_SYM_EXIT
module deinit exit function
Definition: bsProxyModIF.h:81
char * m_sModUri
module URI
Definition: bsProxyModIF.h:228
void ** m_vecRsrc
vecRsrc[index] -> rsrc
Definition: bsProxyModIF.h:139
iterator over module URI
Definition: bsProxyModIF.h:216
BsModInitFunc_T * BsModInitFunc_P
pointer to init function
Definition: bsProxyModIF.h:530
BsModIterOver_T
What to iterate over.
Definition: bsProxyModIF.h:213
BsModIterOver_T m_eOver
iterator over enum
Definition: bsProxyModIF.h:225
void( BsModExitFunc_T)()
Exit module.
Definition: bsProxyModIF.h:540
<b><i>BotSense</i></b> package top-level, unifying header declarations.
int BsVConnHnd_T
virtual connection handle type
Definition: BotSense.h:151
const char * license
short license/copyright statement
Definition: bsProxyModIF.h:126