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.

850 lines
22 KiB

  1. /*++
  2. Copyright (C) 1993 Microsoft Corporation
  3. Module Name:
  4. NWAPI32.C
  5. Abstract:
  6. This module contains NetWare compatible APIs. The NWC* functions
  7. are implemented as wrappers around NWP* or NW* functions.
  8. Author:
  9. Chuck Y. Chan (ChuckC) 06-Mar-1995
  10. Revision History:
  11. ChuckC Moved over from DSM to consolidate.
  12. --*/
  13. #include "procs.h"
  14. //
  15. // define define categories of errors
  16. //
  17. typedef enum _NCP_CLASS {
  18. NcpClassConnect,
  19. NcpClassBindery,
  20. NcpClassDir
  21. } NCP_CLASS ;
  22. extern NWCCODE
  23. MapNtStatus(
  24. const NTSTATUS ntstatus,
  25. const NCP_CLASS ncpclass
  26. );
  27. extern DWORD
  28. SetWin32ErrorFromNtStatus(
  29. NTSTATUS NtStatus
  30. ) ;
  31. //
  32. // Function bodies
  33. //
  34. NWCCODE
  35. NWCAddTrusteeToDirectory(
  36. NWCONN_HANDLE hConn,
  37. NWDIR_HANDLE dirHandle,
  38. const char *pszPath,
  39. NWOBJ_ID dwTrusteeID,
  40. NWACCESS_RIGHTS rightsMask
  41. )
  42. {
  43. return (NWAddTrusteeToDirectory(
  44. hConn,
  45. dirHandle,
  46. pszPath,
  47. dwTrusteeID,
  48. rightsMask)) ;
  49. }
  50. NWCCODE
  51. NWCAllocPermanentDirectoryHandle(
  52. NWCONN_HANDLE hConn,
  53. NWDIR_HANDLE dirHandle,
  54. char *pszDirPath,
  55. NWDIR_HANDLE *pbNewDirHandle,
  56. NWACCESS_RIGHTS *pbRightsMask
  57. )
  58. {
  59. return (NWAllocPermanentDirectoryHandle(
  60. hConn,
  61. dirHandle,
  62. pszDirPath,
  63. pbNewDirHandle,
  64. pbRightsMask)) ;
  65. }
  66. NWCCODE
  67. NWCAllocTemporaryDirectoryHandle(
  68. NWCONN_HANDLE hConn,
  69. NWDIR_HANDLE dirHandle,
  70. char *pszDirPath,
  71. NWDIR_HANDLE *pbNewDirHandle,
  72. NWACCESS_RIGHTS *pbRightsMask
  73. )
  74. {
  75. return (NWAllocTemporaryDirectoryHandle(
  76. hConn,
  77. dirHandle,
  78. pszDirPath,
  79. pbNewDirHandle,
  80. pbRightsMask)) ;
  81. }
  82. NWCCODE
  83. NWCAttachToFileServer(
  84. const char *pszServerName,
  85. NWLOCAL_SCOPE ScopeFlag,
  86. NWCONN_HANDLE *phNewConn
  87. )
  88. {
  89. return (NWAttachToFileServer(
  90. pszServerName,
  91. ScopeFlag,
  92. phNewConn)) ;
  93. }
  94. NWCCODE
  95. NWCAttachToFileServerW(
  96. const WCHAR *pszServerName,
  97. NWLOCAL_SCOPE ScopeFlag,
  98. NWCONN_HANDLE *phNewConn
  99. )
  100. {
  101. return (NWAttachToFileServerW(
  102. pszServerName,
  103. ScopeFlag,
  104. phNewConn)) ;
  105. }
  106. NWCCODE
  107. NWCCheckConsolePrivileges(
  108. NWCONN_HANDLE hConn
  109. )
  110. {
  111. return(NWCheckConsolePrivileges(hConn));
  112. }
  113. NWCCODE
  114. NWCDeallocateDirectoryHandle(
  115. NWCONN_HANDLE hConn,
  116. NWDIR_HANDLE dirHandle
  117. )
  118. {
  119. return(NWDeallocateDirectoryHandle(
  120. hConn,
  121. dirHandle)) ;
  122. }
  123. NWCCODE
  124. NWCDetachFromFileServer(
  125. NWCONN_HANDLE hConn
  126. )
  127. {
  128. return(NWDetachFromFileServer(hConn)) ;
  129. }
  130. NWCCODE
  131. NWCGetFileServerVersionInfo(
  132. NWCONN_HANDLE hConn,
  133. VERSION_INFO *lpVerInfo
  134. )
  135. {
  136. return(NWGetFileServerVersionInfo(
  137. hConn,
  138. lpVerInfo)) ;
  139. }
  140. NWCCODE
  141. NWCGetInternetAddress(
  142. NWCONN_HANDLE hConn,
  143. NWCONN_NUM nConnNum,
  144. NWNET_ADDR *pIntAddr
  145. )
  146. {
  147. return (NWGetInternetAddress(
  148. hConn,
  149. nConnNum,
  150. pIntAddr)) ;
  151. }
  152. NWCCODE
  153. NWCGetObjectName(
  154. NWCONN_HANDLE hConn,
  155. NWOBJ_ID dwObjectID,
  156. char *pszObjName,
  157. NWOBJ_TYPE *pwObjType )
  158. {
  159. return(NWGetObjectName(
  160. hConn,
  161. dwObjectID,
  162. pszObjName,
  163. pwObjType )) ;
  164. }
  165. NWCCODE
  166. NWCGetVolumeInfoWithNumber(
  167. NWCONN_HANDLE hConn,
  168. NWVOL_NUM nVolNum,
  169. char *pszVolName,
  170. NWNUMBER *pwTotalBlocks,
  171. NWNUMBER *pwSectors,
  172. NWNUMBER *pwAvailBlocks,
  173. NWNUMBER *pwTotalDir,
  174. NWNUMBER *pwAvailDir,
  175. NWVOL_FLAGS *pfVolRemovable
  176. )
  177. {
  178. return(NWGetVolumeInfoWithNumber(
  179. hConn,
  180. nVolNum,
  181. pszVolName,
  182. pwTotalBlocks,
  183. pwSectors,
  184. pwAvailBlocks,
  185. pwTotalDir,
  186. pwAvailDir,
  187. pfVolRemovable)) ;
  188. }
  189. NWCCODE
  190. NWCGetVolumeInfoWithHandle(
  191. NWCONN_HANDLE hConn,
  192. NWDIR_HANDLE nDirHand,
  193. char *pszVolName,
  194. NWNUMBER *pwTotalBlocks,
  195. NWNUMBER *pwSectors,
  196. NWNUMBER *pwAvailBlocks,
  197. NWNUMBER *pwTotalDir,
  198. NWNUMBER *pwAvailDir,
  199. NWVOL_FLAGS *pfVolRemovable
  200. )
  201. {
  202. return(NWGetVolumeInfoWithHandle(
  203. hConn,
  204. nDirHand,
  205. pszVolName,
  206. pwTotalBlocks,
  207. pwSectors,
  208. pwAvailBlocks,
  209. pwTotalDir,
  210. pwAvailDir,
  211. pfVolRemovable)) ;
  212. }
  213. NWCCODE
  214. NWCGetVolumeName(
  215. NWCONN_HANDLE hConn,
  216. NWVOL_NUM bVolNum,
  217. char *pszVolName
  218. )
  219. {
  220. return(NWGetVolumeName(
  221. hConn,
  222. bVolNum,
  223. pszVolName)) ;
  224. }
  225. NWCCODE
  226. NWCIsObjectInSet(
  227. NWCONN_HANDLE hConn,
  228. const char *lpszObjectName,
  229. NWOBJ_TYPE wObjType,
  230. const char *lpszPropertyName,
  231. const char *lpszMemberName,
  232. NWOBJ_TYPE wMemberType
  233. )
  234. {
  235. return(NWIsObjectInSet(
  236. hConn,
  237. lpszObjectName,
  238. wObjType,
  239. lpszPropertyName,
  240. lpszMemberName,
  241. wMemberType)) ;
  242. }
  243. NWCCODE
  244. NWCLoginToFileServer(
  245. NWCONN_HANDLE hConn,
  246. const char *pszUserName,
  247. NWOBJ_TYPE wObjType,
  248. const char *pszPassword
  249. )
  250. {
  251. return(NWLoginToFileServer(
  252. hConn,
  253. pszUserName,
  254. wObjType,
  255. pszPassword)) ;
  256. }
  257. NWCCODE
  258. NWCLogoutFromFileServer(
  259. NWCONN_HANDLE hConn
  260. )
  261. {
  262. return(NWLogoutFromFileServer( hConn )) ;
  263. }
  264. NWCCODE
  265. NWCReadPropertyValue(
  266. NWCONN_HANDLE hConn,
  267. const char *pszObjName,
  268. NWOBJ_TYPE wObjType,
  269. char *pszPropName,
  270. unsigned char ucSegment,
  271. char *pValue,
  272. NWFLAGS *pucMoreFlag,
  273. NWFLAGS *pucPropFlag
  274. )
  275. {
  276. return(NWReadPropertyValue(
  277. hConn,
  278. pszObjName,
  279. wObjType,
  280. pszPropName,
  281. ucSegment,
  282. pValue,
  283. pucMoreFlag,
  284. pucPropFlag)) ;
  285. }
  286. NWCCODE
  287. NWCScanObject(
  288. NWCONN_HANDLE hConn,
  289. const char *pszSearchName,
  290. NWOBJ_TYPE wObjSearchType,
  291. NWOBJ_ID *pdwObjectID,
  292. char *pszObjectName,
  293. NWOBJ_TYPE *pwObjType,
  294. NWFLAGS *pucHasProperties,
  295. NWFLAGS *pucObjectFlags,
  296. NWFLAGS *pucObjSecurity
  297. )
  298. {
  299. return(NWScanObject(
  300. hConn,
  301. pszSearchName,
  302. wObjSearchType,
  303. pdwObjectID,
  304. pszObjectName,
  305. pwObjType,
  306. pucHasProperties,
  307. pucObjectFlags,
  308. pucObjSecurity)) ;
  309. }
  310. NWCCODE
  311. NWCScanProperty(
  312. NWCONN_HANDLE hConn,
  313. const char *pszObjectName,
  314. NWOBJ_TYPE wObjType,
  315. char *pszSearchName,
  316. NWOBJ_ID *pdwSequence,
  317. char *pszPropName,
  318. NWFLAGS *pucPropFlags,
  319. NWFLAGS *pucPropSecurity,
  320. NWFLAGS *pucHasValue,
  321. NWFLAGS *pucMore
  322. )
  323. {
  324. return( NWScanProperty(
  325. hConn,
  326. pszObjectName,
  327. wObjType,
  328. pszSearchName,
  329. pdwSequence,
  330. pszPropName,
  331. pucPropFlags,
  332. pucPropSecurity,
  333. pucHasValue,
  334. pucMore)) ;
  335. }
  336. NWCCODE
  337. NWCGetFileServerDateAndTime(
  338. NWCONN_HANDLE hConn,
  339. BYTE *year,
  340. BYTE *month,
  341. BYTE *day,
  342. BYTE *hour,
  343. BYTE *minute,
  344. BYTE *second,
  345. BYTE *dayofweek
  346. )
  347. {
  348. return( NWGetFileServerDateAndTime(
  349. hConn,
  350. year,
  351. month,
  352. day,
  353. hour,
  354. minute,
  355. second,
  356. dayofweek ));
  357. }
  358. NWCCODE
  359. NWCAddTrustee(
  360. NWCONN_HANDLE hConn,
  361. NWDIR_HANDLE dirHandle,
  362. const char *pszPath,
  363. NWOBJ_ID dwTrusteeID,
  364. NWRIGHTS_MASK rightsMask
  365. )
  366. {
  367. NTSTATUS NtStatus;
  368. NtStatus = NWPAddTrustee(
  369. hConn,
  370. dirHandle,
  371. pszPath,
  372. dwTrusteeID,
  373. rightsMask
  374. );
  375. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  376. return MapNtStatus( NtStatus, NcpClassDir );
  377. }
  378. NWCCODE
  379. NWCDeleteObject(
  380. NWCONN_HANDLE hConn,
  381. const char *pszObjectName,
  382. NWOBJ_TYPE wObjType
  383. )
  384. {
  385. NTSTATUS NtStatus;
  386. NtStatus = NWPDeleteObject( hConn,
  387. pszObjectName,
  388. wObjType );
  389. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  390. return MapNtStatus( NtStatus, NcpClassBindery );
  391. }
  392. NWCCODE
  393. NWCCreateObject(
  394. NWCONN_HANDLE hConn,
  395. const char *pszObjectName,
  396. NWOBJ_TYPE wObjType,
  397. NWFLAGS ucObjectFlags,
  398. NWFLAGS ucObjSecurity
  399. )
  400. {
  401. NTSTATUS NtStatus ;
  402. NtStatus = NWPCreateObject( hConn,
  403. pszObjectName,
  404. wObjType,
  405. ucObjectFlags,
  406. ucObjSecurity );
  407. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  408. return MapNtStatus( NtStatus, NcpClassBindery );
  409. }
  410. NWCCODE
  411. NWCCreateProperty(
  412. NWCONN_HANDLE hConn,
  413. const char *pszObjectName,
  414. NWOBJ_TYPE wObjType,
  415. const char *pszPropertyName,
  416. NWFLAGS ucObjectFlags,
  417. NWFLAGS ucObjSecurity
  418. )
  419. {
  420. NTSTATUS NtStatus ;
  421. NtStatus = NWPCreateProperty( hConn,
  422. pszObjectName,
  423. wObjType,
  424. pszPropertyName,
  425. ucObjectFlags,
  426. ucObjSecurity );
  427. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  428. return MapNtStatus( NtStatus, NcpClassBindery );
  429. }
  430. NWCCODE
  431. NWCDeleteProperty(
  432. NWCONN_HANDLE hConn,
  433. const char *pszObjectName,
  434. NWOBJ_TYPE wObjType,
  435. const char *pszPropertyName
  436. )
  437. {
  438. NTSTATUS NtStatus ;
  439. NtStatus = NWPDeleteProperty( hConn,
  440. pszObjectName,
  441. wObjType,
  442. pszPropertyName );
  443. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  444. return MapNtStatus( NtStatus, NcpClassBindery );
  445. }
  446. NWCCODE
  447. NWCWritePropertyValue(
  448. NWCONN_HANDLE hConn,
  449. const char *pszObjectName,
  450. NWOBJ_TYPE wObjType,
  451. const char *pszPropertyName,
  452. NWSEGMENT_NUM segmentNumber,
  453. NWSEGMENT_DATA *segmentData,
  454. NWFLAGS moreSegments
  455. )
  456. {
  457. NTSTATUS NtStatus ;
  458. NtStatus = NWPWritePropertyValue( hConn,
  459. pszObjectName,
  460. wObjType,
  461. pszPropertyName,
  462. segmentNumber,
  463. segmentData,
  464. moreSegments );
  465. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  466. return MapNtStatus( NtStatus, NcpClassBindery );
  467. }
  468. NWCCODE
  469. NWCGetObjectID(
  470. NWCONN_HANDLE hConn,
  471. const char *pszObjectName,
  472. NWOBJ_TYPE wObjType,
  473. NWOBJ_ID *objectID
  474. )
  475. {
  476. NTSTATUS NtStatus ;
  477. NtStatus = NWPGetObjectID( hConn,
  478. pszObjectName,
  479. wObjType,
  480. objectID );
  481. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  482. return MapNtStatus( NtStatus, NcpClassBindery );
  483. }
  484. NWCCODE
  485. NWCRenameBinderyObject(
  486. NWCONN_HANDLE hConn,
  487. const char *pszObjectName,
  488. const char *pszNewObjectName,
  489. NWOBJ_TYPE wObjType
  490. )
  491. {
  492. NTSTATUS NtStatus;
  493. NtStatus = NWPRenameBinderyObject(
  494. hConn,
  495. pszObjectName,
  496. pszNewObjectName,
  497. wObjType
  498. );
  499. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  500. return MapNtStatus( NtStatus, NcpClassBindery );
  501. }
  502. NWCCODE
  503. NWCAddObjectToSet(
  504. NWCONN_HANDLE hConn,
  505. const char *pszObjectName,
  506. NWOBJ_TYPE wObjType,
  507. const char *pszPropertyName,
  508. const char *pszMemberName,
  509. NWOBJ_TYPE memberType
  510. )
  511. {
  512. NTSTATUS NtStatus ;
  513. NtStatus = NWPAddObjectToSet( hConn,
  514. pszObjectName,
  515. wObjType,
  516. pszPropertyName,
  517. pszMemberName,
  518. memberType );
  519. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  520. return MapNtStatus( NtStatus, NcpClassBindery );
  521. }
  522. NWCCODE
  523. NWCDeleteObjectFromSet(
  524. NWCONN_HANDLE hConn,
  525. const char *pszObjectName,
  526. NWOBJ_TYPE wObjType,
  527. const char *pszPropertyName,
  528. const char *pszMemberName,
  529. NWOBJ_TYPE memberType
  530. )
  531. {
  532. NTSTATUS NtStatus ;
  533. NtStatus = NWPDeleteObjectFromSet( hConn,
  534. pszObjectName,
  535. wObjType,
  536. pszPropertyName,
  537. pszMemberName,
  538. memberType );
  539. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  540. return MapNtStatus( NtStatus, NcpClassBindery );
  541. }
  542. NWCCODE
  543. NWCCreateDirectory(
  544. NWCONN_HANDLE hConn,
  545. NWDIR_HANDLE dirHandle,
  546. const char *pszPath,
  547. NWACCESS_RIGHTS accessMask
  548. )
  549. {
  550. NTSTATUS NtStatus;
  551. NtStatus = NWPCreateDirectory(
  552. hConn,
  553. dirHandle,
  554. pszPath,
  555. accessMask
  556. );
  557. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  558. return MapNtStatus( NtStatus, NcpClassBindery );
  559. }
  560. NWCCODE
  561. NWCScanForTrustees(
  562. NWCONN_HANDLE hConn,
  563. NWDIR_HANDLE dirHandle,
  564. char *pszsearchDirPath,
  565. NWSEQUENCE *pucsequenceNumber,
  566. BYTE *numberOfEntries,
  567. TRUSTEE_INFO *ti
  568. )
  569. {
  570. NTSTATUS NtStatus;
  571. NtStatus = NWPScanForTrustees(
  572. hConn,
  573. dirHandle,
  574. pszsearchDirPath,
  575. pucsequenceNumber,
  576. numberOfEntries,
  577. ti
  578. ) ;
  579. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  580. return MapNtStatus( NtStatus, NcpClassBindery );
  581. }
  582. NWCCODE
  583. NWCScanDirectoryForTrustees2(
  584. NWCONN_HANDLE hConn,
  585. NWDIR_HANDLE dirHandle,
  586. char *pszsearchDirPath,
  587. NWSEQUENCE *pucsequenceNumber,
  588. char *pszdirName,
  589. NWDATE_TIME *dirDateTime,
  590. NWOBJ_ID *ownerID,
  591. TRUSTEE_INFO *ti
  592. )
  593. {
  594. NTSTATUS NtStatus;
  595. NtStatus = NWPScanDirectoryForTrustees2(
  596. hConn,
  597. dirHandle,
  598. pszsearchDirPath,
  599. pucsequenceNumber,
  600. pszdirName,
  601. dirDateTime,
  602. ownerID,
  603. ti
  604. );
  605. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  606. return MapNtStatus( NtStatus, NcpClassBindery );
  607. }
  608. NWCCODE
  609. NWCGetBinderyAccessLevel(
  610. NWCONN_HANDLE hConn,
  611. NWFLAGS *accessLevel,
  612. NWOBJ_ID *objectID
  613. )
  614. {
  615. NTSTATUS NtStatus;
  616. NtStatus = NWPGetBinderyAccessLevel(
  617. hConn,
  618. accessLevel,
  619. objectID
  620. );
  621. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  622. return MapNtStatus( NtStatus, NcpClassBindery );
  623. }
  624. NWCCODE
  625. NWCGetFileServerDescription(
  626. NWCONN_HANDLE hConn,
  627. char *pszCompany,
  628. char *pszVersion,
  629. char *pszRevision
  630. )
  631. {
  632. NTSTATUS NtStatus ;
  633. NtStatus = NWPGetFileServerDescription(
  634. hConn,
  635. pszCompany,
  636. pszVersion,
  637. pszRevision
  638. );
  639. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  640. return MapNtStatus( NtStatus, NcpClassBindery );
  641. }
  642. NWCCODE
  643. NWCGetVolumeNumber(
  644. NWCONN_HANDLE hConn,
  645. char *pszVolume,
  646. NWVOL_NUM *VolumeNumber
  647. )
  648. {
  649. NTSTATUS NtStatus ;
  650. NtStatus = NWPGetVolumeNumber(
  651. hConn,
  652. pszVolume,
  653. VolumeNumber
  654. );
  655. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  656. return MapNtStatus( NtStatus, NcpClassBindery );
  657. }
  658. NWCCODE
  659. NWCGetVolumeUsage(
  660. NWCONN_HANDLE hConn,
  661. NWVOL_NUM VolumeNumber,
  662. DWORD *TotalBlocks,
  663. DWORD *FreeBlocks,
  664. DWORD *PurgeableBlocks,
  665. DWORD *NotYetPurgeableBlocks,
  666. DWORD *TotalDirectoryEntries,
  667. DWORD *AvailableDirectoryEntries,
  668. BYTE *SectorsPerBlock
  669. )
  670. {
  671. NTSTATUS NtStatus ;
  672. NtStatus = NWPGetVolumeUsage(
  673. hConn,
  674. VolumeNumber,
  675. TotalBlocks,
  676. FreeBlocks,
  677. PurgeableBlocks,
  678. NotYetPurgeableBlocks,
  679. TotalDirectoryEntries,
  680. AvailableDirectoryEntries,
  681. SectorsPerBlock
  682. );
  683. (void) SetWin32ErrorFromNtStatus(NtStatus) ;
  684. return MapNtStatus( NtStatus, NcpClassBindery );
  685. }
  686. NWCCODE
  687. NWCCreateQueue(
  688. NWCONN_HANDLE hConn,
  689. NWDIR_HANDLE dirHandle,
  690. const char NWFAR *pszQueueName,
  691. NWOBJ_TYPE wQueueType,
  692. const char NWFAR *pszPathName,
  693. NWOBJ_ID NWFAR *pdwQueueId
  694. )
  695. {
  696. return (NWCreateQueue(
  697. hConn,
  698. dirHandle,
  699. pszQueueName,
  700. wQueueType,
  701. pszPathName,
  702. pdwQueueId
  703. ));
  704. }
  705. NWCCODE
  706. NWCChangePropertySecurity(
  707. NWCONN_HANDLE hConn,
  708. const char NWFAR *pszObjName,
  709. NWOBJ_TYPE wObjType,
  710. const char NWFAR *pszPropertyName,
  711. NWFLAGS ucObjSecurity
  712. )
  713. {
  714. return (NWChangePropertySecurity(
  715. hConn,
  716. pszObjName,
  717. wObjType,
  718. pszPropertyName,
  719. ucObjSecurity
  720. ));
  721. }
  722. NWCCODE
  723. NWCDestroyQueue(
  724. NWCONN_HANDLE hConn,
  725. NWOBJ_ID dwQueueId
  726. )
  727. {
  728. return (NWDestroyQueue(
  729. hConn,
  730. dwQueueId
  731. ));
  732. }