You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
10 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: pantheios/backends/bec.WindowsConsole.h
  3. *
  4. * Purpose: Declaration of the Pantheios WindowsConsole Stock Back-end API.
  5. *
  6. * Created: 17th July 2006
  7. * Updated: 30th April 2010
  8. *
  9. * Home: http://www.pantheios.org/
  10. *
  11. * Copyright (c) 2006-2010, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are
  16. * met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  24. * names of any contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  28. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  29. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  31. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  32. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  33. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  34. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  35. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  36. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  37. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /** \file pantheios/backends/bec.WindowsConsole.h
  41. *
  42. * [C, C++] Pantheios Windows Console Back-end Common API
  43. */
  44. #ifndef PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_BEC_WINDOWSCONSOLE
  45. #define PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_BEC_WINDOWSCONSOLE
  46. /* /////////////////////////////////////////////////////////////////////////
  47. * Version information
  48. */
  49. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  50. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_WINDOWSCONSOLE_MAJOR 5
  51. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_WINDOWSCONSOLE_MINOR 1
  52. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_WINDOWSCONSOLE_REVISION 1
  53. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_WINDOWSCONSOLE_EDIT 24
  54. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  55. /* /////////////////////////////////////////////////////////////////////////
  56. * Includes
  57. */
  58. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
  59. # include <pantheios/pantheios.h>
  60. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
  61. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_BACKEND
  62. # include <pantheios/backend.h>
  63. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_BACKEND */
  64. /* /////////////////////////////////////////////////////////////////////////
  65. * Documentation
  66. */
  67. /** \defgroup group__backend__stock_backends__WindowsConsole Pantheios Windows Console Stock Back-end
  68. * \ingroup group__backend__stock_backends
  69. * Back-end library that outputs to the Windows console, colour-coding
  70. * based on severity level.
  71. */
  72. /* /////////////////////////////////////////////////////////////////////////
  73. * Constants
  74. */
  75. /** \defgroup group__backend__stock_backends__WindowsConsole__flags Pantheios Windows Console Stock Back-end Flags
  76. * \ingroup group__backend__stock_backends__WindowsConsole
  77. * Flags for the \ref group__backend__stock_backends__WindowsConsole
  78. */
  79. /** \def PANTHEIOS_BE_WINDOWSCONSOLE_F_NO_COLOURS
  80. * Causes the \ref group__backend__stock_backends__WindowsConsole to
  81. * emit log statements without colouring based on severity.
  82. * \ingroup group__backend__stock_backends__WindowsConsole__flags
  83. */
  84. #define PANTHEIOS_BE_WINDOWSCONSOLE_F_NO_COLOURS (0x00100000)
  85. /* /////////////////////////////////////////////////////////////////////////
  86. * Typedefs
  87. */
  88. /** Structure used for specifying initialisation information to the
  89. * be.WindowsConsole library.
  90. * \ingroup group__backend__stock_backends__WindowsConsole
  91. */
  92. struct pan_be_WindowsConsole_init_t
  93. {
  94. #if !defined(PANTHEIOS_DOCUMENTATION_SKIP_SECTION) && \
  95. !defined(PANTHEIOS_NO_NAMESPACE)
  96. typedef pantheios::pan_uint16_t pan_uint16_t;
  97. typedef pantheios::pan_uint32_t pan_uint32_t;
  98. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION && !PANTHEIOS_NO_NAMESPACE */
  99. pan_uint32_t version; /*!< Must be initialised to the value of PANTHEIOS_VER */
  100. pan_uint32_t flags; /*!< \ref group__backend__stock_backends__WindowsConsole__flags "Flags" that control the information displayed. */
  101. pan_uint16_t colours[8]; /*!< Array of colour indexes corresponding to the 8 stock severity levels. */
  102. #ifdef __cplusplus
  103. public: /* Construction */
  104. # ifndef PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT
  105. pan_be_WindowsConsole_init_t();
  106. # endif /* !PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT */
  107. #endif /* __cplusplus */
  108. };
  109. #ifndef __cplusplus
  110. typedef struct pan_be_WindowsConsole_init_t pan_be_WindowsConsole_init_t;
  111. #endif /* !__cplusplus */
  112. /* /////////////////////////////////////////////////////////////////////////
  113. * Application-defined functions
  114. */
  115. /** \ref page__backend__callbacks "Callback" function defined by
  116. * the application, invoked when the
  117. * API is initialised with a NULL <code>init</code> parameter.
  118. * \ingroup group__backend__stock_backends__WindowsConsole
  119. *
  120. * \param backEndId The back-end identifier passed to the back-end
  121. * during its initialisation.
  122. * \param init A pointer to an already-initialised instance of
  123. * pan_be_WindowsConsole_init_t.
  124. *
  125. * If any application-specific changes are required they can be made to
  126. * the structure to which <code>init</code> points, which will already
  127. * have been initialised. These changes will then be incorporated into
  128. * the back-end state, and reflected in its behaviour.
  129. *
  130. * If no changes are required, then the function can be a simple stub,
  131. * containing no instructions.
  132. *
  133. * \note This function is only required when the
  134. * \ref page__backend__callbacks "callback" version of the library is
  135. * used.
  136. *
  137. * \exception "throw()" This function must <b>not</b> throw any exceptions!
  138. *
  139. * \warning This function will be called during the initialisation of
  140. * Pantheios, and so <b>must not</b> make any calls into Pantheios, either
  141. * directly or indirectly!
  142. */
  143. PANTHEIOS_CALL(void) pantheios_be_WindowsConsole_getAppInit(
  144. int backEndId
  145. , pan_be_WindowsConsole_init_t* init
  146. ) /* throw() */;
  147. /* /////////////////////////////////////////////////////////////////////////
  148. * API functions
  149. */
  150. /** Fills out a copy of the initialisation structure with default
  151. * values (representative of the default behaviour of the library),
  152. * ready to be customised and passed to the API initialiser function
  153. * pantheios_be_WindowsConsole_init().
  154. * \ingroup group__backend__stock_backends__WindowsConsole
  155. *
  156. * \note This function should <b>not</b> be called on an
  157. * already-initialised instance, as is the case in the implementation
  158. * of the pantheios_be_WindowsConsole_getAppInit() function, as it will
  159. * already have been called by pantheios_be_WindowsConsole_init() prior
  160. * to the callback.
  161. */
  162. PANTHEIOS_CALL(void) pantheios_be_WindowsConsole_getDefaultAppInit(
  163. pan_be_WindowsConsole_init_t* init
  164. ) /* throw() */;
  165. /** Implements the functionality for pantheios_be_init() over the Windows Console API.
  166. * \ingroup group__backend__stock_backends__WindowsConsole
  167. */
  168. PANTHEIOS_CALL(int) pantheios_be_WindowsConsole_init(
  169. PAN_CHAR_T const* processIdentity
  170. , int id
  171. , pan_be_WindowsConsole_init_t const* init
  172. , void* param
  173. , void** ptoken
  174. );
  175. /** Implements the functionality for pantheios_be_uninit() over the Windows Console API.
  176. * \ingroup group__backend__stock_backends__WindowsConsole
  177. */
  178. PANTHEIOS_CALL(void) pantheios_be_WindowsConsole_uninit(
  179. void* token
  180. );
  181. /** Implements the functionality for pantheios_be_logEntry() over the Windows Console API.
  182. * \ingroup group__backend__stock_backends__WindowsConsole
  183. */
  184. PANTHEIOS_CALL(int) pantheios_be_WindowsConsole_logEntry(
  185. void* feToken
  186. , void* beToken
  187. , int severity
  188. , PAN_CHAR_T const* entry
  189. , size_t cchEntry
  190. );
  191. /** Parses the be.WindowsConsole back-end flags
  192. *
  193. * \ingroup group__backend
  194. *
  195. * Processes an argument list in the same way as
  196. * pantheios_be_parseStockArgs(), filling out the
  197. * pan_be_WindowsConsole_init_t in accordance with the arguments
  198. * found.
  199. *
  200. * Recognises the following standard argument names:
  201. * - "showProcessId" (Boolean)
  202. * - "showTime" (Boolean)
  203. * - "showSeverity" (Boolean)
  204. * - "useSystemTime" (Boolean)
  205. * - "showDetailsAtStart" (Boolean)
  206. * - "useUnixFormat" (Boolean)
  207. * - "showDate" (Boolean)
  208. * - "showTime" (Boolean)
  209. * - "highResolution" (Boolean)
  210. * - "lowResolution" (Boolean)
  211. *
  212. * Recognises the following back-end specific argument names:
  213. * - "noColours" (Boolean)
  214. * - "noColors" (Boolean)
  215. */
  216. PANTHEIOS_CALL(int) pantheios_be_WindowsConsole_parseArgs(
  217. size_t numArgs
  218. #ifdef PANTHEIOS_NO_NAMESPACE
  219. , struct pan_slice_t* const args
  220. #else /* ? PANTHEIOS_NO_NAMESPACE */
  221. , pantheios::pan_slice_t* const args
  222. #endif /* PANTHEIOS_NO_NAMESPACE */
  223. , pan_be_WindowsConsole_init_t* init
  224. );
  225. /* ////////////////////////////////////////////////////////////////////// */
  226. #ifdef __cplusplus
  227. # ifndef PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT
  228. inline pan_be_WindowsConsole_init_t::pan_be_WindowsConsole_init_t()
  229. {
  230. pantheios_be_WindowsConsole_getDefaultAppInit(this);
  231. }
  232. # endif /* !PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT */
  233. #endif /* __cplusplus */
  234. /* ////////////////////////////////////////////////////////////////////// */
  235. #endif /* PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_BEC_WINDOWSCONSOLE */
  236. /* ///////////////////////////// end of file //////////////////////////// */