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.

163 lines
3.5 KiB

  1. /*************************************************************************
  2. *
  3. * NTNW.C
  4. *
  5. * Dos NetWare to NT NetWare translation
  6. *
  7. * Copyright (c) 1995 Microsoft Corporation
  8. *
  9. * $Log: N:\NT\PRIVATE\NW4\NWSCRIPT\VCS\NTNW.C $
  10. *
  11. * Rev 1.1 22 Dec 1995 14:25:28 terryt
  12. * Add Microsoft headers
  13. *
  14. * Rev 1.0 15 Nov 1995 18:07:24 terryt
  15. * Initial revision.
  16. *
  17. * Rev 1.2 25 Aug 1995 16:23:08 terryt
  18. * Capture support
  19. *
  20. * Rev 1.1 23 May 1995 19:37:10 terryt
  21. * Spruce up source
  22. *
  23. * Rev 1.0 15 May 1995 19:10:44 terryt
  24. * Initial revision.
  25. *
  26. *************************************************************************/
  27. #include <stdio.h>
  28. #include <direct.h>
  29. #include <time.h>
  30. #include "common.h"
  31. extern int CONNECTION_ID;
  32. /********************************************************************
  33. NTGetCurrentDirectory
  34. Routine Description:
  35. Return the current directory.
  36. Arguments:
  37. DriveNumber = The drive to get the directory from.
  38. (0 = A, 1 = B, 2 = C, etc)
  39. pPath = A pointer to a 64 byte buffer to return the
  40. current directory.
  41. Return Value:
  42. 0 Success
  43. else Error
  44. ********************************************************************/
  45. unsigned int
  46. NTGetCurrentDirectory(
  47. unsigned char DriveNumber,
  48. unsigned char *pPath
  49. )
  50. {
  51. char * CurPath;
  52. int currentDrive = _getdrive() ;
  53. //
  54. // Change to the drive and get its current working directory.
  55. // Default to root if fail to get cwd. DriveNumber is from 0.
  56. //
  57. _chdrive (DriveNumber+1);
  58. CurPath = _getcwd(NULL,MAX_PATH) ;
  59. if ( CurPath != NULL ) {
  60. strcpy( pPath, CurPath );
  61. free(CurPath) ;
  62. }
  63. else {
  64. strcpy( pPath, "A:\\" );
  65. pPath[0] += DriveNumber;
  66. }
  67. _chdrive (currentDrive);
  68. return 0;
  69. }
  70. /********************************************************************
  71. AttachToFileServer
  72. Routine Description:
  73. Attach to a named file server
  74. Arguments:
  75. pServerName - Name of server
  76. pNewConnectionId - returned connection handle
  77. Return Value:
  78. 0 = success
  79. else NetWare error
  80. *******************************************************************/
  81. unsigned int
  82. AttachToFileServer(
  83. unsigned char *pServerName,
  84. unsigned int *pNewConnectionId
  85. )
  86. {
  87. unsigned int Result;
  88. if ( NTIsConnected( pServerName ) ) {
  89. return 0x8800; // Already atached.
  90. }
  91. Result = NTAttachToFileServer( pServerName, pNewConnectionId );
  92. return Result;
  93. }
  94. /********************************************************************
  95. GetConnectionHandle
  96. Routine Description:
  97. Given a server name, return the connection handle.
  98. The server should already be attached
  99. Note that this is not called for 4X servers. It's used
  100. for attaches and bindery connections.
  101. Arguments:
  102. pServerName - Name of server
  103. pConnectionHandle - pointer to returned connection handle
  104. Return Value:
  105. 0 = success
  106. else NetWare error
  107. *******************************************************************/
  108. unsigned int
  109. GetConnectionHandle(
  110. unsigned char *pServerName,
  111. unsigned int *pConnectionHandle
  112. )
  113. {
  114. unsigned int Result;
  115. if ( !NTIsConnected( pServerName ) ) {
  116. return 0xFFFF; // not already connected
  117. }
  118. Result = NTAttachToFileServer( pServerName, pConnectionHandle );
  119. return Result;
  120. }