ta_common.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* TA-LIB Copyright (c) 1999-2007, Mario Fortier
  2. * All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or
  5. * without modification, are permitted provided that the following
  6. * conditions are met:
  7. *
  8. * - Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. *
  11. * - Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in
  13. * the documentation and/or other materials provided with the
  14. * distribution.
  15. *
  16. * - Neither name of author nor the names of its contributors
  17. * may be used to endorse or promote products derived from this
  18. * software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  30. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  31. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #ifndef TA_COMMON_H
  34. #define TA_COMMON_H
  35. /* The following macros are used to return internal errors.
  36. * The Id can be from 1 to 999 and translate to the user
  37. * as the return code 5000 to 5999.
  38. *
  39. * Everytime you wish to add a new fatal error code,
  40. * use the "NEXT AVAILABLE NUMBER" and increment the
  41. * number in this file.
  42. *
  43. * NEXT AVAILABLE NUMBER: 181
  44. */
  45. #define TA_INTERNAL_ERROR(Id) ((TA_RetCode)(TA_INTERNAL_ERROR+Id))
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. #include <stdio.h>
  50. #include <limits.h>
  51. #include <float.h>
  52. #ifndef TA_DEFS_H
  53. #include "ta_defs.h"
  54. #endif
  55. /* Some functions to get the version of TA-Lib.
  56. *
  57. * Format is "Major.Minor.Patch (Month Day Year Hour:Min:Sec)"
  58. *
  59. * Example: "1.2.0 (Jan 17 2004 23:59:59)"
  60. *
  61. * Major increments indicates an "Highly Recommended" update.
  62. *
  63. * Minor increments indicates arbitrary milestones in the
  64. * development of the next major version.
  65. *
  66. * Patch are fixes to a "Major.Minor" release.
  67. */
  68. const char *TA_GetVersionString( void );
  69. /* Get individual component of the Version string */
  70. const char *TA_GetVersionMajor ( void );
  71. const char *TA_GetVersionMinor ( void );
  72. const char *TA_GetVersionBuild ( void );
  73. const char *TA_GetVersionDate ( void );
  74. const char *TA_GetVersionTime ( void );
  75. /* Misc. declaration used throughout the library code. */
  76. typedef double TA_Real;
  77. typedef int TA_Integer;
  78. /* General purpose structure containing an array of string.
  79. *
  80. * Example of usage:
  81. * void printStringTable( TA_StringTable *table )
  82. * {
  83. * int i;
  84. * for( i=0; i < table->size; i++ )
  85. * cout << table->string[i] << endl;
  86. * }
  87. *
  88. */
  89. typedef struct TA_StringTable
  90. {
  91. unsigned int size; /* Number of string. */
  92. const char **string; /* Pointer to the strings. */
  93. /* Hidden data for internal use by TA-Lib. Do not modify. */
  94. void *hiddenData;
  95. } TA_StringTable;
  96. /* End-user can get additional information related to a TA_RetCode.
  97. *
  98. * Example:
  99. * TA_RetCodeInfo info;
  100. *
  101. * retCode = TA_Initialize( ... );
  102. *
  103. * if( retCode != TA_SUCCESS )
  104. * {
  105. * TA_SetRetCodeInfo( retCode, &info );
  106. * printf( "Error %d(%s): %s\n",
  107. * retCode,
  108. * info.enumStr,
  109. * info.infoStr );
  110. * }
  111. *
  112. * Would display:
  113. * "Error 1(TA_LIB_NOT_INITIALIZE): TA_Initialize was not sucessfully called"
  114. */
  115. typedef struct TA_RetCodeInfo
  116. {
  117. const char *enumStr; /* Like "TA_IP_SOCKETERROR" */
  118. const char *infoStr; /* Like "Error creating socket" */
  119. } TA_RetCodeInfo;
  120. /* Info is always returned, even when 'theRetCode' is invalid. */
  121. void TA_SetRetCodeInfo( TA_RetCode theRetCode, TA_RetCodeInfo *retCodeInfo );
  122. /* TA_Initialize() initialize the ressources used by TA-Lib. This
  123. * function must be called once prior to any other functions declared in
  124. * this file.
  125. *
  126. * TA_Shutdown() allows to free all ressources used by TA-Lib. Following
  127. * a shutdown, TA_Initialize() must be called again for re-using TA-Lib.
  128. *
  129. * TA_Shutdown() should be called prior to exiting the application code.
  130. */
  131. TA_RetCode TA_Initialize( void );
  132. TA_RetCode TA_Shutdown( void );
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif