Leaked source code of windows server 2003
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.

122 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. mkilog.c
  5. Abstract:
  6. This module creates a log table using ODBC data sources.
  7. Author:
  8. Kyle Geiger & Murali R. Krishnan (MuraliK) 1-Nov-1995
  9. Revision History:
  10. --*/
  11. #include <windows.h>
  12. #include <stdio.h>
  13. # include "dynodbc.h"
  14. #include "html.h"
  15. #include "resource.h"
  16. # define DEFAULT_LEN ( 256)
  17. # define MAX_DATA 2048
  18. # define FOUND_DRIVER ( 7)
  19. #define SUCCESS(rc) (!((rc)>>1))
  20. int __cdecl
  21. main( int argc, char * argv[])
  22. {
  23. RETCODE rc; // Return code for ODBC functions
  24. HENV henv; // Environment Handle
  25. char szDSN[MAX_DATA+1]; // Variable to hold DSN name
  26. SWORD cbDSN; // Output length of data DSN
  27. char szDesc[MAX_DATA+1]; // Variable to hold DSN description
  28. SWORD cbDesc; // Output length of data description
  29. int fFirst;
  30. char szList[MAX_DATA];
  31. char szSQLServer[MAX_DATA];
  32. char szCreateLogTable[MAX_DATA];
  33. HINSTANCE hInst = GetModuleHandle(NULL);
  34. if ( !DynLoadODBC())
  35. return (1);
  36. pSQLAllocEnv(&henv);
  37. rc=pSQLDrivers(henv, SQL_FETCH_FIRST,
  38. (UCHAR FAR *) szDSN,
  39. MAX_DATA, &cbDSN,
  40. (UCHAR FAR *) szDesc, MAX_DATA, &cbDesc);
  41. LoadString(hInst, IDS_SQL_SERVER, szSQLServer, sizeof(szSQLServer));
  42. while (SUCCESS(rc)) {
  43. if (!_stricmp(szDSN, szSQLServer) )
  44. rc=FOUND_DRIVER;
  45. else
  46. rc=pSQLDrivers(henv, SQL_FETCH_NEXT,
  47. (UCHAR FAR * ) szDSN, MAX_DATA, &cbDSN,
  48. (UCHAR FAR * ) szDesc, MAX_DATA, &cbDesc);
  49. }
  50. LoadString(hInst, IDS_CREATE_LOG_TABLE, szCreateLogTable, sizeof(szCreateLogTable));
  51. StartHTML(szCreateLogTable, 1);
  52. if (FOUND_DRIVER != rc) {
  53. char szAttemptCreateLog[MAX_DATA*3];
  54. LoadString(hInst, IDS_ATTEMPT_CREATE_LOG, szAttemptCreateLog, sizeof(szAttemptCreateLog));
  55. printf( szAttemptCreateLog);
  56. pSQLFreeEnv(henv);
  57. return (1);
  58. }
  59. rc=pSQLDataSources(henv, SQL_FETCH_FIRST,
  60. (UCHAR FAR *) szDSN, MAX_DATA, &cbDSN,
  61. (UCHAR FAR *) szDesc, MAX_DATA, &cbDesc);
  62. fFirst=FALSE;
  63. while (SUCCESS(rc)) {
  64. if (!_stricmp(szDesc, szSQLServer) ) {
  65. char szOption[MAX_DATA];
  66. if (!fFirst) {
  67. char szSelectName[MAX_DATA];
  68. fFirst=TRUE;
  69. LoadString(hInst, IDS_SELECT_NAME, szSelectName, sizeof(szSelectName));
  70. strcpy(szList,szSelectName);
  71. }
  72. LoadString(hInst, IDS_OPTION, szOption, sizeof(szOption));
  73. sprintf(szList+strlen(szList),szOption, szDSN);
  74. }
  75. rc=pSQLDataSources(henv, SQL_FETCH_NEXT,
  76. (UCHAR FAR *) szDSN, MAX_DATA, &cbDSN,
  77. (UCHAR FAR *) szDesc, MAX_DATA, &cbDesc);
  78. } // while data sources found
  79. /* any datasources for SQL Server found? if so, generate the form for create*/
  80. if (fFirst) {
  81. char szSelect[MAX_DATA];
  82. char szCreateMSLog[MAX_DATA*3];
  83. LoadString(hInst, IDS_SELECT, szSelect, sizeof(szSelect));
  84. strcat(szList, szSelect);
  85. LoadString(hInst, IDS_CREATE_MS_LOG, szCreateMSLog, sizeof(szCreateMSLog));
  86. printf( szCreateMSLog, szList);
  87. }
  88. else {
  89. char szCreateMSLog[MAX_DATA*3];
  90. LoadString(hInst, IDS_CREATE_MS_LOG_2, szCreateMSLog, sizeof(szCreateMSLog));
  91. printf( szCreateMSLog );
  92. }
  93. EndHTML();
  94. pSQLFreeEnv(henv);
  95. return (1);
  96. } // main()