home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / dbadm101.zip / msql.h < prev    next >
C/C++ Source or Header  |  1999-01-06  |  5KB  |  187 lines

  1. /*
  2. **    msql.h    - 
  3. **
  4. **
  5. ** Copyright (c) 1993-95  David J. Hughes
  6. ** Copyright (c) 1995  Hughes Technologies Pty Ltd
  7. **
  8. ** Permission to use, copy, and distribute for non-commercial purposes,
  9. ** is hereby granted without fee, providing that the above copyright
  10. ** notice appear in all copies and that both the copyright notice and this
  11. ** permission notice appear in supporting documentation.
  12. **
  13. ** This software is provided "as is" without any expressed or implied warranty.
  14. **
  15. ** ID = "$Id:"
  16. **
  17. */
  18.  
  19.  
  20. #ifndef MSQL_H
  21. #define MSQL_H
  22.  
  23. #pragma library( "msql")
  24.  
  25. #ifndef APIENTRY
  26. #  if defined(_OS_OS2)
  27. #    ifdef BCPP
  28. #      define _System   _syscall
  29. #      define _Optlink
  30. #    endif
  31. #    ifdef __EMX__
  32. #      define _System   
  33. #    endif
  34. #    define APIENTRY _System
  35. #  endif /* _OS_OS2 */
  36. #  if defined(_OS_WIN32)
  37. #    define APIENTRY __stdcall
  38. #  endif /* _OS_WIN32 */
  39. #  if defined(_OS_UNIX)
  40. #    define APIENTRY
  41. #  endif
  42. #endif
  43.  
  44. #if defined(__STDC__) || defined(__cplusplus)
  45. #  define __ANSI_PROTO(x)    x
  46. #else
  47. #  define __ANSI_PROTO(x)    ()
  48. #endif
  49.  
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53.  
  54. typedef    char    ** m_row;
  55.  
  56. typedef struct field_s {
  57.     char    *name,
  58.         *table;
  59.     int    type,
  60.         length,
  61.         flags;
  62. } m_field;
  63.  
  64.  
  65. typedef struct     m_seq_s {
  66.     int    step,
  67.         value;
  68. } m_seq;
  69.  
  70.  
  71. typedef    struct    m_data_s {
  72.     int    width;
  73.     m_row    data;
  74.     struct    m_data_s *next;
  75. } m_data;
  76.  
  77. typedef struct m_fdata_s {
  78.     m_field    field;
  79.     struct m_fdata_s *next;
  80. } m_fdata;
  81.  
  82.  
  83.  
  84. typedef struct result_s {
  85.         m_data     *queryData,
  86.                 *cursor;
  87.     m_fdata    *fieldData,
  88.         *fieldCursor;
  89.     int    numRows,
  90.         numFields;
  91. } m_result;
  92.  
  93.  
  94. #define    msqlNumRows(res) res->numRows
  95. #define    msqlNumFields(res) res->numFields
  96.  
  97.  
  98. #define INT_TYPE    1
  99. #define CHAR_TYPE    2
  100. #define REAL_TYPE    3
  101. #define IDENT_TYPE    4
  102. #define NULL_TYPE    5
  103. #define TEXT_TYPE    6
  104. #define DATE_TYPE    7
  105. #define UINT_TYPE    8
  106. #define MONEY_TYPE    9
  107. #define TIME_TYPE    10
  108. #define LAST_REAL_TYPE    10
  109. #define IDX_TYPE    253
  110. #define SYSVAR_TYPE    254
  111. #define    ANY_TYPE    255
  112.  
  113. #define NOT_NULL_FLAG   1
  114. #define UNIQUE_FLAG    2
  115.  
  116. #define IS_UNIQUE(n)    (n & UNIQUE_FLAG)
  117. #define IS_NOT_NULL(n)    (n & NOT_NULL_FLAG)
  118.  
  119. static char msqlTypeNames[][12] = 
  120.     {"???", "int", "char","real","ident","null","text","date","uint",
  121.     "money","time","???"};
  122.  
  123.  
  124. /*
  125. ** Pre-declarations for the API library functions
  126. */
  127.     int    msqlLoadConfigFile __ANSI_PROTO((char *));
  128.  
  129. #ifndef _MSQL_SERVER_SOURCE
  130.  
  131. #  if defined(_OS_OS2) || defined(_OS_WIN32) || defined(__EMX__)
  132. #    define msqlErrMsg   msqlGetErrMsg(NULL)
  133. #  else
  134.     extern  char msqlErrMsg[];
  135. #  endif
  136.  
  137. #if defined(_OS_OS2) || defined(_OS_WIN32)
  138.         char  * APIENTRY msqlGetErrMsg __ANSI_PROTO((char *));    
  139.         int     APIENTRY msqlUserConnect __ANSI_PROTO((char *, char *)); 
  140. #endif
  141.     int     APIENTRY msqlConnect __ANSI_PROTO((char *));
  142.     int     APIENTRY msqlSelectDB __ANSI_PROTO((int, char*));
  143.     int     APIENTRY msqlQuery __ANSI_PROTO((int, char*));
  144.     int     APIENTRY msqlCreateDB __ANSI_PROTO((int, char*));
  145.     int     APIENTRY msqlDropDB __ANSI_PROTO((int, char*));
  146.     int     APIENTRY msqlShutdown __ANSI_PROTO((int));
  147.     int     APIENTRY msqlGetProtoInfo __ANSI_PROTO((void));
  148.     int     APIENTRY msqlReloadAcls __ANSI_PROTO((int));
  149.     int     APIENTRY msqlGetServerStats __ANSI_PROTO((int));
  150.     int     APIENTRY msqlCopyDB __ANSI_PROTO((int, char*, char*));
  151.     int     APIENTRY msqlMoveDB __ANSI_PROTO((int, char*, char*));
  152.     char     * APIENTRY msqlGetServerInfo __ANSI_PROTO((void));
  153.     char     * APIENTRY msqlGetHostInfo __ANSI_PROTO((void));
  154.     char     * APIENTRY msqlUnixTimeToDate __ANSI_PROTO((time_t));
  155.     char     * APIENTRY msqlUnixTimeToTime __ANSI_PROTO((time_t));
  156.     void    APIENTRY msqlClose __ANSI_PROTO((int));
  157.     void     APIENTRY msqlDataSeek __ANSI_PROTO((m_result*, int));
  158.     void     APIENTRY msqlFieldSeek __ANSI_PROTO((m_result*, int));
  159.     void     APIENTRY msqlFreeResult __ANSI_PROTO((m_result*));
  160.         m_row   APIENTRY msqlFetchRow __ANSI_PROTO((m_result*));
  161.     m_seq    * APIENTRY msqlGetSequenceInfo __ANSI_PROTO((int, char*));
  162.     m_field    * APIENTRY msqlFetchField __ANSI_PROTO((m_result *));
  163.     m_result * APIENTRY msqlListDBs __ANSI_PROTO((int));
  164.     m_result * APIENTRY msqlListTables __ANSI_PROTO((int));
  165.     m_result * APIENTRY msqlListFields __ANSI_PROTO((int, char*));
  166.     m_result * APIENTRY msqlListIndex __ANSI_PROTO((int, char*, char*));
  167.     m_result * APIENTRY msqlStoreResult __ANSI_PROTO((void));
  168.     time_t    APIENTRY msqlDateToUnixTime __ANSI_PROTO((char *));
  169.     time_t    APIENTRY msqlTimeToUnixTime __ANSI_PROTO((char *));
  170. #endif
  171.  
  172. #if defined(_MSQL_SERVER_SOURCE) || defined(_MSQL_SERVER_PROTO)
  173.     /*
  174.     ** These functions are not part of the mSQL API.  Any use
  175.     ** of these functions is discouraged as the interface may
  176.     ** change in future releases
  177.     */
  178.     int     APIENTRY msqlGetIntConf __ANSI_PROTO((char *, char *));
  179.     char     * APIENTRY msqlGetCharConf __ANSI_PROTO((char *, char*));
  180. #endif
  181.  
  182.  
  183. #ifdef __cplusplus
  184.     }
  185. #endif
  186. #endif /*MSQL_H*/
  187.