Source code of Windows XP (NT5)
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.

175 lines
6.2 KiB

  1. /***************************************************************************/
  2. /* UTIL.H */
  3. /* Copyright (C) 1995-96 SYWARE Inc., All rights reserved */
  4. /***************************************************************************/
  5. #ifdef WIN32
  6. #define INTFUNC __stdcall
  7. #else
  8. #define INTFUNC PASCAL
  9. #endif
  10. /***************************************************************************/
  11. /* To turn on tracing, set ISAM_TRACE to TRUE and recompile */
  12. #define ISAM_TRACE FALSE
  13. /* Max size for SQL_LONGVARCHAR */
  14. #define ISAM_MAX_LONGVARCHAR 16384 //cannot be more than (32767 - 4)
  15. /***************************************************************************/
  16. #define BINARY_LENGTH(x) *((SDWORD FAR *) x)
  17. #define BINARY_DATA(x) (x + sizeof(SDWORD))
  18. /***************************************************************************/
  19. RETCODE INTFUNC ReturnString (
  20. PTR rgbValue,
  21. SWORD cbValueMax,
  22. SWORD FAR *pcbValue,
  23. LPCUSTR lpstr);
  24. RETCODE INTFUNC ReturnStringD (
  25. PTR rgbValue,
  26. SDWORD cbValueMax,
  27. SDWORD FAR *pcbValue,
  28. LPCUSTR lpstr);
  29. /* Takes the zero terminated string 'lpstr' and copies it to buffer */
  30. /* rgbValue[0..cbValueMax-1], truncating it if need be (if rgbValue */
  31. /* is null, no data is copied). Also, if pcbValue is not null, it */
  32. /* is set to the length of the un-truncated string. */
  33. /* */
  34. /* Returns ERR_SUCCESS or ERR_DATATRUNCATED */
  35. /***************************************************************************/
  36. RETCODE INTFUNC ConvertSqlToC (
  37. SWORD fSqlTypeIn,
  38. BOOL fUnsignedAttributeIn,
  39. PTR rgbValueIn,
  40. SDWORD cbValueIn,
  41. SDWORD FAR *pcbOffset,
  42. SWORD fCTypeOut,
  43. PTR rgbValueOut,
  44. SDWORD cbValueOutMax,
  45. SDWORD FAR *pcbValueOut);
  46. /* Copies rgbValueIn to rgbValueOut (if not null) and sets pcbValueOut (if */
  47. /* not null). Data is converted as need be. Data is copied stating at */
  48. /* rgbValueIn[*pcbOffset] and *pcbOffset is increased by the number of */
  49. /* bytes returned. */
  50. /* */
  51. /* Returns ERR_SUCCESS or ERR_DATATRUNCATED or some other error */
  52. /***************************************************************************/
  53. BOOL INTFUNC PatternMatch(
  54. BOOL fEscape,
  55. LPUSTR lpCandidate,
  56. SDWORD cbCandidate,
  57. LPUSTR lpPattern,
  58. SDWORD cbPattern,
  59. BOOL fCaseSensitive);
  60. /* Tests to see if lpCandidate matched the template specified by */
  61. /* lpPattern. Percent signs (%) match zero or more characters. */
  62. /* Underscores (_) match single characters. The camparison is done */
  63. /* case-insensitive if fCaseSensitive is FALSE. */
  64. /* */
  65. /* If fEscape is TRUE, "%%" in the pattern only matches a single '%' in */
  66. /* the candidate and "%_" in the pattern only matches a single '_' in the */
  67. /* candidate. */
  68. /* */
  69. /* Returns TRUE if there is a match, otherwise FALSE. */
  70. /***************************************************************************/
  71. SDWORD INTFUNC TrueSize(
  72. LPUSTR lpStr,
  73. SDWORD cbStr,
  74. SDWORD cbMax);
  75. /* Returns the size of a string (but not larger than cbMax) */
  76. /***************************************************************************/
  77. BOOL INTFUNC DoubleToChar (
  78. double dbl,
  79. BOOL ScientificNotationOK,
  80. LPUSTR lpChar,
  81. SDWORD cbChar);
  82. /* Convert a double to a character string. Returns TRUE if value is */
  83. /* truncated (lpChar will not contain a null terminator). Otherwise FALSE.*/
  84. /***************************************************************************/
  85. void INTFUNC DateToChar (
  86. DATE_STRUCT FAR *lpDate,
  87. LPUSTR lpChar);
  88. /* Convert a date to a character string */
  89. /***************************************************************************/
  90. void INTFUNC TimeToChar (
  91. TIME_STRUCT FAR *lpTime,
  92. LPUSTR lpChar);
  93. /* Convert a time to a character string */
  94. /***************************************************************************/
  95. void INTFUNC TimestampToChar (
  96. TIMESTAMP_STRUCT FAR *lpTimestamp,
  97. LPUSTR lpChar);
  98. /* Convert a timestamp to a character string */
  99. /***************************************************************************/
  100. RETCODE INTFUNC CharToDouble (
  101. LPUSTR lpChar,
  102. SDWORD cbChar,
  103. BOOL fIntegerOnly,
  104. double dblLowBound,
  105. double dblHighBound,
  106. double FAR *lpDouble);
  107. /* Convert a character string to a double */
  108. /***************************************************************************/
  109. RETCODE INTFUNC CharToDate (
  110. LPUSTR lpChar,
  111. SDWORD cbChar,
  112. DATE_STRUCT FAR *lpDate);
  113. /* Convert a character string to a date */
  114. /***************************************************************************/
  115. RETCODE INTFUNC CharToTime (
  116. LPUSTR lpChar,
  117. SDWORD cbChar,
  118. TIME_STRUCT FAR *lpTime);
  119. /* Convert a character string to a time */
  120. /***************************************************************************/
  121. RETCODE INTFUNC CharToTimestamp (
  122. LPUSTR lpChar,
  123. SDWORD cbChar,
  124. TIMESTAMP_STRUCT FAR *lpTimestamp);
  125. /* Convert a character string to a timestamp */
  126. /***************************************************************************/
  127. #ifndef WIN32
  128. BOOL INTFUNC DeleteFile (
  129. LPCSTR lpszFilename);
  130. /* Deletes specified file */
  131. #endif
  132. /***************************************************************************/