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.

147 lines
4.3 KiB

  1. //+---------------------------------------------------------------
  2. //
  3. // File: dbsetup.h
  4. //
  5. // Synopsis:
  6. //
  7. // Copyright (C) 1995 Microsoft Corporation
  8. // All rights reserved.
  9. //
  10. // History: Antony Halim Created 07/10/96
  11. //
  12. //----------------------------------------------------------------
  13. #ifndef _DBSETUP_H_
  14. #define _DBSETUP_H_
  15. #define DBNTWIN32
  16. #include <stdio.h>
  17. #include <windows.h>
  18. #pragma warning (disable:4121)
  19. #include <sqlfront.h>
  20. #pragma warning (default:4121)
  21. #include <sqldb.h>
  22. #include <dbgtrace.h>
  23. #include <listmacr.h>
  24. /* scanner stuff */
  25. #define MBUFFER_SIZE (1024*4)
  26. #define LBUFFER_SIZE (1024)
  27. #define BUFFER_SIZE (MBUFFER_SIZE + LBUFFER_SIZE + 1)
  28. #define FULL_BUFFER_SIZE (1024)
  29. #define HALF_BUFFER_SIZE (FULL_BUFFER_SIZE/2)
  30. #define TOKEN_ERROR 0
  31. #define TOKEN_EOF 1
  32. #define TOKEN_GO 2
  33. #define TOKEN_LINE 3
  34. typedef struct SCANBUF {
  35. CHAR pchBuffer[BUFFER_SIZE];
  36. CHAR *pchEndBuf;
  37. CHAR *pchMBuffer;
  38. CHAR *pchForward;
  39. CHAR *pchStart;
  40. CHAR *pchBegin;
  41. HANDLE hFile;
  42. INT state;
  43. } *PSCANBUF;
  44. extern int ScanToken(PSCANBUF pScanBuf);
  45. extern BOOL InitScanner(PSCANBUF pScanBuf, HANDLE hExtFile);
  46. extern LPSTR GetTokenString(PSCANBUF pScanBuf, CHAR *pchSaved);
  47. extern VOID RestoreTokenString(PSCANBUF pScanBuf, CHAR chSaved);
  48. /* end of scanner stuff */
  49. //
  50. // dbsetup functions use this structure as the connection handle
  51. //
  52. typedef struct DBCONN {
  53. PDBPROCESS pDbproc; // DB-Lib handle
  54. DWORD dwDBError; // DB-Lib db error
  55. DWORD dwOSError; // DB-Lib os error
  56. char lpszDBError[128]; // SQL Message
  57. char lpszSQLError[128]; // SQL Message
  58. SCANBUF ScanBuf; // Scanner buffer
  59. LIST_ENTRY le; // linked list
  60. } *PDBCONN;
  61. typedef enum __COLTYPE {
  62. sql_int, sql_smallint, sql_tinyint, sql_char, sql_varchar, sql_float, sql_real,
  63. sql_text, sql_image
  64. } COLTYPE;
  65. typedef struct __COLUMN {
  66. CHAR name[32];
  67. COLTYPE type;
  68. int length;
  69. BOOL fNull;
  70. } COLUMN;
  71. //
  72. // Function API
  73. //
  74. BOOL InitDB();
  75. PDBCONN OpenDBConnection(LPSTR lpszServerName, LPSTR lpszLoginName,
  76. LPSTR lpszPasswd, LPSTR lpszDBName);
  77. BOOL CloseDBConnection(PDBCONN pDBConn);
  78. BOOL TerminateDB();
  79. BOOL UseDatabase(PDBCONN pDBConn, LPSTR lpszDBName);
  80. BOOL AddAlias(PDBCONN pDBConn, LPSTR lpszLoginName, LPSTR lpszUserName);
  81. BOOL DropUser(PDBCONN pDBConn, LPSTR lpszUserName);
  82. BOOL CheckLoginExist(PDBCONN pDBConn, LPSTR lpszLogin, BOOL *pfExist);
  83. BOOL SetOption(PDBCONN pDBConn, INT iOption, LPSTR lpszParam);
  84. BOOL SetConfig(PDBCONN pDBConn, LPSTR lpszConfigName, INT iValue);
  85. BOOL CreateLogin(PDBCONN pDBConn, LPSTR lpszLoginName, LPSTR lpszPassword,
  86. LPSTR lpszDefaultDatabase);
  87. BOOL DropLogin(PDBCONN pDBConn, LPSTR lpszLoginName);
  88. BOOL CreateDevice(PDBCONN pDBConn, LPSTR lpszLogicalName,
  89. LPSTR lpszPhysicalName, DWORD dwSize);
  90. BOOL DropDevice(PDBCONN pDBConn, LPSTR lpszLogicalName, BOOL fDeleteFile);
  91. BOOL CheckDeviceExist(PDBCONN pDBConn, LPSTR lpszDevice, BOOL *pfExist);
  92. BOOL CreateDatabase(PDBCONN pDBConn, LPSTR lpszDBName, LPSTR lpszDataDev,
  93. DWORD dwDataSize, LPSTR lpszLogDev, DWORD dwLogSize);
  94. BOOL DropDatabase(PDBCONN pDBConn, LPSTR lpszDBName);
  95. BOOL CheckDatabaseExist(PDBCONN pDBConn, LPSTR lpszDatabase, BOOL *pfExist);
  96. BOOL AlterDatabase(PDBCONN pDBConn, LPSTR lpszDBName, LPSTR lpszDev,DWORD dwSize);
  97. BOOL SetDBOption(PDBCONN pDBConn, LPSTR lpszDB, LPSTR lpszOption, BOOL fFlag);
  98. BOOL CreateTable(PDBCONN pDBConn, LPSTR lpszTableName, COLUMN *Columns,
  99. DWORD dwCount);
  100. BOOL DropTable(PDBCONN pDBConn, LPSTR lpszTableName);
  101. BOOL DropAllTables(PDBCONN pDBConn, LPSTR lpszDB);
  102. BOOL CreateIndex(PDBCONN pDBConn, LPSTR lpszIndexName, LPSTR lpszTableName,
  103. BOOL fUnique, BOOL fClustered, LPSTR lpszColName[], DWORD dwCount);
  104. BOOL DropIndex(PDBCONN pDBConn, LPSTR lpszIndexName);
  105. BOOL DropAllIndexes(PDBCONN pDBConn, LPSTR lpszDB);
  106. BOOL ExecFile(PDBCONN pDBConn, LPSTR lpszFileName);
  107. BOOL ExecCmd(PDBCONN pDBConn, LPSTR lpszSQLCmd);
  108. #define CreateProc(pDBConn, lpszfileName) ExecFile(pDBConn, lpszFileName)
  109. BOOL DropProc(PDBCONN pDBConn, LPSTR lpszProcName);
  110. BOOL DropAllProc(PDBCONN pDBConn, LPSTR lpszDB);
  111. BOOL GetVersion(PDBCONN pDBConn, LPSTR lpszDatabase, LPSTR lpszTag, INT *iVer);
  112. BOOL GetUserConnections(PDBCONN pDBConn, INT *lpiUserConn);
  113. INT GetDbopenErrorNum();
  114. LPSTR GetDbopenErrorMsg();
  115. #endif