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.

109 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. getdrvrs.c
  5. Abstract:
  6. This module returns a web page with all ODBC drivers installed on the web server.
  7. The drivers are displayed as links, which when clicked will launch another application
  8. (DSNFORM.EXE) to prompt for the data source name and other driver specific info
  9. Author:
  10. Kyle Geiger 17-Nov-1995
  11. (with thanks to MuraliK for providing the ODBC dynamic loading routines)
  12. Revision History:
  13. --*/
  14. #include <windows.h>
  15. #include <stdio.h>
  16. #include "dynodbc.h"
  17. #include "html.h"
  18. #include "resource.h"
  19. #define MAX_DATA 2048
  20. #define SUCCESS(rc) (!((rc)>>1))
  21. int
  22. __cdecl
  23. main( int argc, char * argv[])
  24. {
  25. RETCODE rc; // Return code for ODBC functions
  26. HENV henv; // Environment Handle
  27. char szDriver[MAX_DATA+1]; // Variable to hold Driver name
  28. char szDriverNS[MAX_DATA+1]; // Variable to hold Driver name with space
  29. // converted to +
  30. SWORD cbDriver; // Output length of data Driver
  31. char szDesc[MAX_DATA+1]; // Variable to hold Driver description
  32. SWORD cbDesc; // Output length of data description
  33. BOOL fFirst; // flag for first time through loop
  34. char szList[MAX_DATA]; // driver list
  35. HINSTANCE hInst = GetModuleHandle(NULL);
  36. char szDsnFormExe[MAX_PATH];
  37. char szListODBCDrivers[MAX_PATH];
  38. char szCreateODBC[MAX_PATH*3];
  39. // see if ODBC is installed and can load. If not, an error is returned
  40. if ( !DynLoadODBC())
  41. return (1);
  42. // retrieve all installed drivers, put in szList formatted as HTML links to DSNFORM.EXE
  43. pSQLAllocEnv(&henv);
  44. rc=pSQLDrivers(henv, SQL_FETCH_FIRST,
  45. (UCHAR FAR *) szDriver,
  46. MAX_DATA, &cbDriver,
  47. (UCHAR FAR *) szDesc, MAX_DATA, &cbDesc);
  48. fFirst=FALSE;
  49. szList[0]='\0';
  50. while (SUCCESS(rc)) {
  51. //
  52. // Replace SP with +
  53. //
  54. strcpy(szDriverNS, szDriver);
  55. if (!fFirst) {
  56. fFirst=TRUE;
  57. }
  58. LoadString(hInst, IDS_DSNFORMEXE, szDsnFormExe, sizeof(szDsnFormExe));
  59. sprintf(
  60. szList+strlen(szList),szDsnFormExe,
  61. szDriverNS, szDriver);
  62. rc=pSQLDrivers(henv, SQL_FETCH_NEXT,
  63. (UCHAR FAR * ) szDriver, MAX_DATA, &cbDriver,
  64. (UCHAR FAR * ) szDesc, MAX_DATA, &cbDesc);
  65. }
  66. LoadString(hInst, IDS_LIST_ODBC_DRIVERS, szListODBCDrivers, sizeof(szListODBCDrivers));
  67. StartHTML(szListODBCDrivers, FALSE);
  68. // if no drivers found, return error page
  69. if (!fFirst) {
  70. LoadString(hInst, IDS_CREATE_ODBC_FAIL, szCreateODBC, sizeof(szCreateODBC));
  71. printf( szCreateODBC );
  72. }
  73. // otherwise, display the driver names as links
  74. else {
  75. LoadString(hInst, IDS_CREATE_ODBC_GETDRVR, szCreateODBC, sizeof(szCreateODBC));
  76. printf( szCreateODBC ,szList);
  77. }
  78. EndHTML();
  79. pSQLFreeEnv(henv);
  80. return (1);
  81. } // main()