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.

427 lines
12 KiB

  1. /*++
  2. Copyright (c) 1989-1993 Microsoft Corporation
  3. Module Name:
  4. icanon.h
  5. Abstract:
  6. Function prototypes and definitions for the internal APIs which
  7. canonicalize, validate, and compare pathnames, LANMAN object
  8. names, and lists.
  9. Author:
  10. Danny Glasser (dannygl) 15 June 1989
  11. Notes:
  12. The references to the old set of canonicalization routines,
  13. which live in NETLIB, are being kept around for now. When
  14. these routines are expunged the references in here should also
  15. be removed.
  16. Revision History:
  17. 06-May-1991 rfirth
  18. 32-bit version
  19. 11-Jun-1991 rfirth
  20. Added WI_Net prototypes
  21. 22-Jan-1992 rfirth
  22. Changed names to be in line with NT naming convention (I_Net => Netp)
  23. Removed WI_Net prototypes
  24. Added mapping for old names. Names should be changed in all sources
  25. 24-Feb-1992 rfirth
  26. Added LM2X_COMPATIBLE support
  27. 10-May-1993 JohnRo
  28. RAID 6987: allow spaces in computer names (use comma for API lists).
  29. Also corrected copyright dates and re-ordered this history.
  30. Allow multiple includes of this file to be harmless.
  31. --*/
  32. #ifndef _ICANON_
  33. #define _ICANON_
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. //
  38. // keep old names for now
  39. //
  40. #if 0
  41. #define I_NetPathType NetpPathType
  42. #define I_NetPathCanonicalize NetpPathCanonicalize
  43. #define I_NetPathCompare NetpPathCompare
  44. #define I_NetNameValidate NetpNameValidate
  45. #define I_NetNameCanonicalize NetpNameCanonicalize
  46. #define I_NetNameCompare NetpNameCompare
  47. #define I_NetListCanonicalize NetpListCanonicalize
  48. #define I_NetListTraverse NetpListTraverse
  49. #else
  50. #define NetpPathType I_NetPathType
  51. #define NetpPathCanonicalize I_NetPathCanonicalize
  52. #define NetpPathCompare I_NetPathCompare
  53. #define NetpNameValidate I_NetNameValidate
  54. #define NetpNameCanonicalize I_NetNameCanonicalize
  55. #define NetpNameCompare I_NetNameCompare
  56. #define NetpListCanonicalize I_NetListCanonicalize
  57. #define NetpListTraverse I_NetListTraverse
  58. #endif
  59. //
  60. // canonicalization routine prototypes
  61. //
  62. NET_API_STATUS
  63. NetpIsRemote(
  64. IN LPWSTR ComputerName OPTIONAL,
  65. OUT LPDWORD LocalOrRemote,
  66. OUT LPWSTR CanonicalizedName OPTIONAL,
  67. IN DWORD Flags
  68. );
  69. NET_API_STATUS
  70. NET_API_FUNCTION
  71. NetpPathType(
  72. IN LPWSTR ServerName OPTIONAL,
  73. IN LPWSTR PathName,
  74. OUT LPDWORD PathType,
  75. IN DWORD Flags
  76. );
  77. NET_API_STATUS
  78. NET_API_FUNCTION
  79. NetpPathCanonicalize(
  80. IN LPWSTR ServerName OPTIONAL,
  81. IN LPWSTR PathName,
  82. IN LPWSTR Outbuf,
  83. IN DWORD OutbufLen,
  84. IN LPWSTR Prefix OPTIONAL,
  85. IN OUT LPDWORD PathType,
  86. IN DWORD Flags
  87. );
  88. LONG
  89. NET_API_FUNCTION
  90. NetpPathCompare(
  91. IN LPWSTR ServerName OPTIONAL,
  92. IN LPWSTR PathName1,
  93. IN LPWSTR PathName2,
  94. IN DWORD PathType,
  95. IN DWORD Flags
  96. );
  97. NET_API_STATUS
  98. NET_API_FUNCTION
  99. NetpNameValidate(
  100. IN LPWSTR ServerName OPTIONAL,
  101. IN LPWSTR Name,
  102. IN DWORD NameType,
  103. IN DWORD Flags
  104. );
  105. NET_API_STATUS
  106. NET_API_FUNCTION
  107. NetpNameCanonicalize(
  108. IN LPWSTR ServerName OPTIONAL,
  109. IN LPWSTR Name,
  110. OUT LPWSTR Outbuf,
  111. IN DWORD OutbufLen,
  112. IN DWORD NameType,
  113. IN DWORD Flags
  114. );
  115. LONG
  116. NET_API_FUNCTION
  117. NetpNameCompare(
  118. IN LPWSTR ServerName OPTIONAL,
  119. IN LPWSTR Name1,
  120. IN LPWSTR Name2,
  121. IN DWORD NameType,
  122. IN DWORD Flags
  123. );
  124. NET_API_STATUS
  125. NET_API_FUNCTION
  126. NetpListCanonicalize(
  127. IN LPWSTR ServerName OPTIONAL,
  128. IN LPWSTR List,
  129. IN LPWSTR Delimiters OPTIONAL,
  130. OUT LPWSTR Outbuf,
  131. IN DWORD OutbufLen,
  132. OUT LPDWORD OutCount,
  133. OUT LPDWORD PathTypes,
  134. IN DWORD PathTypesLen,
  135. IN DWORD Flags
  136. );
  137. LPWSTR
  138. NET_API_FUNCTION
  139. NetpListTraverse(
  140. IN LPWSTR Reserved OPTIONAL,
  141. IN LPWSTR* pList,
  142. IN DWORD Flags
  143. );
  144. //
  145. // ** Manifest constants for use with the above functions **
  146. //
  147. //
  148. // Global flags (across all canonicalization functions)
  149. //
  150. #define LM2X_COMPATIBLE 0x80000000L
  151. #define GLOBAL_CANON_FLAGS (LM2X_COMPATIBLE)
  152. //
  153. // These are the values which can be returned from NetpIsRemote in LocalOrRemote
  154. //
  155. #define ISREMOTE (-1)
  156. #define ISLOCAL 0
  157. //
  158. // Flags for NetpIsRemote
  159. //
  160. #define NIRFLAG_MAPLOCAL 0x00000001L
  161. #define NIRFLAG_RESERVED (~(GLOBAL_CANON_FLAGS|NIRFLAG_MAP_LOCAL))
  162. //
  163. // Flags for I_NetPathType
  164. //
  165. #define INPT_FLAGS_OLDPATHS 0x00000001
  166. #define INPT_FLAGS_RESERVED (~(GLOBAL_CANON_FLAGS|INPT_FLAGS_OLDPATHS))
  167. //
  168. // Flags for I_NetPathCanonicalize
  169. //
  170. #define INPCA_FLAGS_OLDPATHS 0x00000001
  171. #define INPCA_FLAGS_RESERVED (~(GLOBAL_CANON_FLAGS|INPCA_FLAGS_OLDPATHS))
  172. //
  173. // Flags for I_NetPathCompare
  174. //
  175. #define INPC_FLAGS_PATHS_CANONICALIZED 0x00000001
  176. #define INPC_FLAGS_RESERVED (~(GLOBAL_CANON_FLAGS|INPC_FLAGS_PATHS_CANONICALIZED))
  177. //
  178. // Flags for I_NetNameCanonicalize
  179. //
  180. #define INNCA_FLAGS_FULL_BUFLEN 0x00000001
  181. #define INNCA_FLAGS_RESERVED (~(GLOBAL_CANON_FLAGS|INNCA_FLAGS_FULL_BUFLEN))
  182. //
  183. // Flags for I_NetNameCompare
  184. //
  185. #define INNC_FLAGS_NAMES_CANONICALIZED 0x00000001
  186. #define INNC_FLAGS_RESERVED (~(GLOBAL_CANON_FLAGS|INNC_FLAGS_NAMES_CANONICALIZED))
  187. //
  188. // Flags for I_NetNameValidate
  189. //
  190. #define INNV_FLAGS_RESERVED (~GLOBAL_CANON_FLAGS)
  191. //
  192. // Name types for I_NetName* and I_NetListCanonicalize
  193. //
  194. #define NAMETYPE_USER 1
  195. #define NAMETYPE_PASSWORD 2
  196. #define NAMETYPE_GROUP 3
  197. #define NAMETYPE_COMPUTER 4
  198. #define NAMETYPE_EVENT 5
  199. #define NAMETYPE_DOMAIN 6
  200. #define NAMETYPE_SERVICE 7
  201. #define NAMETYPE_NET 8
  202. #define NAMETYPE_SHARE 9
  203. #define NAMETYPE_MESSAGE 10
  204. #define NAMETYPE_MESSAGEDEST 11
  205. #define NAMETYPE_SHAREPASSWORD 12
  206. #define NAMETYPE_WORKGROUP 13
  207. //
  208. // Special name types for I_NetListCanonicalize
  209. //
  210. #define NAMETYPE_COPYONLY 0
  211. #define NAMETYPE_PATH INLC_FLAGS_MASK_NAMETYPE
  212. //
  213. // Flags for I_NetListCanonicalize
  214. //
  215. #define INLC_FLAGS_MASK_NAMETYPE 0x000000FF
  216. #define INLC_FLAGS_MASK_OUTLIST_TYPE 0x00000300
  217. #define OUTLIST_TYPE_NULL_NULL 0x00000100
  218. #define OUTLIST_TYPE_API 0x00000200
  219. #define OUTLIST_TYPE_SEARCHPATH 0x00000300
  220. #define INLC_FLAGS_CANONICALIZE 0x00000400
  221. #define INLC_FLAGS_MULTIPLE_DELIMITERS 0x00000800
  222. #define INLC_FLAGS_MASK_RESERVED (~(GLOBAL_CANON_FLAGS| \
  223. INLC_FLAGS_MASK_NAMETYPE | \
  224. INLC_FLAGS_MASK_OUTLIST_TYPE | \
  225. INLC_FLAGS_CANONICALIZE | \
  226. INLC_FLAGS_MULTIPLE_DELIMITERS))
  227. //
  228. // Delimiter strings for the three types of input lists accepted by
  229. // I_NetListCanonicalize.
  230. //
  231. #define LIST_DELIMITER_STR_UI TEXT(" \t;,")
  232. #define LIST_DELIMITER_STR_API TEXT(",")
  233. #define LIST_DELIMITER_STR_NULL_NULL TEXT("")
  234. //
  235. // The API list delimiter character
  236. //
  237. #define LIST_DELIMITER_CHAR_API TEXT(',')
  238. //
  239. // The Search-path list delimiter character
  240. //
  241. #define LIST_DELIMITER_CHAR_SEARCHPATH ';'
  242. //
  243. // The list quote character
  244. //
  245. #define LIST_QUOTE_CHAR '\"'
  246. /*NOINC*/
  247. /*
  248. * MAX_API_LIST_SIZE(maxelts, maxsize)
  249. * MAX_SEARCHPATH_LIST_SIZE(maxelts, maxsize)
  250. * MAX_NULL_NULL_LIST_SIZE(maxelts, maxsize)
  251. *
  252. * These macros specify the maximum size (in bytes) of API, search-path,
  253. * and null-null lists, respectively, given the maximum number of elements
  254. * and the maximum size (in bytes, not including the terminating null) of
  255. * an element. They are intended to be used in allocating arrays large
  256. * enough to hold the output of I_NetListCanonicalize.
  257. *
  258. * The size of an API or search-path list entry is three more than the size
  259. * of the element. This includes two bytes for leading and trailing quote
  260. * characters and one byte for a trailing delimiter (or null, for the last
  261. * element).
  262. *
  263. * The size of a null-null list is one more than the size the elements
  264. * concantenated (allowing for a terminating null after each element). The
  265. * extra byte is for the second null which follows the last element.
  266. */
  267. #define MAX_API_LIST_SIZE(maxelts, maxsize) \
  268. ((maxelts) * ((maxsize) + 3))
  269. #define MAX_SEARCHPATH_LIST_SIZE(maxelts, maxsize) \
  270. ((maxelts) * ((maxsize) + 3))
  271. #define MAX_NULL_NULL_LIST_SIZE(maxelts, maxsize) \
  272. ((maxelts) * ((maxsize) + 1) + 1)
  273. /*INC*/
  274. /***
  275. * Constants for type return value.
  276. * --> THESE ARE ONLY BUILDING BLOCKS, THEY ARE NOT RETURNED <---
  277. */
  278. #define ITYPE_WILD 0x1
  279. #define ITYPE_NOWILD 0
  280. #define ITYPE_ABSOLUTE 0x2
  281. #define ITYPE_RELATIVE 0
  282. #define ITYPE_DPATH 0x4
  283. #define ITYPE_NDPATH 0
  284. #define ITYPE_DISK 0
  285. #define ITYPE_LPT 0x10
  286. #define ITYPE_COM 0x20
  287. #define ITYPE_COMPNAME 0x30
  288. #define ITYPE_CON 0x40
  289. #define ITYPE_NUL 0x50
  290. /*
  291. * Meta-system names are used in the permission database. A meta
  292. * system name applies to a whole class of objects. For example,
  293. * \MAILSLOT applies to all mailslots. These are NOT valid
  294. * system object names themselves.
  295. */
  296. #define ITYPE_SYS 0x00000800
  297. #define ITYPE_META 0x00008000 /* See above */
  298. #define ITYPE_SYS_MSLOT (ITYPE_SYS|0)
  299. #define ITYPE_SYS_SEM (ITYPE_SYS|0x100)
  300. #define ITYPE_SYS_SHMEM (ITYPE_SYS|0x200)
  301. #define ITYPE_SYS_PIPE (ITYPE_SYS|0x300)
  302. #define ITYPE_SYS_COMM (ITYPE_SYS|0x400)
  303. #define ITYPE_SYS_PRINT (ITYPE_SYS|0x500)
  304. #define ITYPE_SYS_QUEUE (ITYPE_SYS|0x600)
  305. #define ITYPE_UNC 0x1000 /* unc paths */
  306. #define ITYPE_PATH 0x2000 /* 'local' non-unc paths */
  307. #define ITYPE_DEVICE 0x4000
  308. #define ITYPE_PATH_SYS (ITYPE_PATH_ABSND|ITYPE_SYS)
  309. #define ITYPE_UNC_SYS (ITYPE_UNC|ITYPE_SYS)
  310. /* End of building blocks. */
  311. /***
  312. * The real things...
  313. * WHAT GETS RETURNED
  314. */
  315. /* ITYPE_UNC: \\foo\bar and \\foo\bar\x\y */
  316. #define ITYPE_UNC_COMPNAME (ITYPE_UNC|ITYPE_COMPNAME)
  317. #define ITYPE_UNC_WC (ITYPE_UNC|ITYPE_COMPNAME|ITYPE_WILD)
  318. #define ITYPE_UNC_SYS_SEM (ITYPE_UNC_SYS|ITYPE_SYS_SEM)
  319. #define ITYPE_UNC_SYS_SHMEM (ITYPE_UNC_SYS|ITYPE_SYS_SHMEM)
  320. #define ITYPE_UNC_SYS_MSLOT (ITYPE_UNC_SYS|ITYPE_SYS_MSLOT)
  321. #define ITYPE_UNC_SYS_PIPE (ITYPE_UNC_SYS|ITYPE_SYS_PIPE)
  322. #define ITYPE_UNC_SYS_QUEUE (ITYPE_UNC_SYS|ITYPE_SYS_QUEUE)
  323. #define ITYPE_PATH_ABSND (ITYPE_PATH|ITYPE_ABSOLUTE|ITYPE_NDPATH)
  324. #define ITYPE_PATH_ABSD (ITYPE_PATH|ITYPE_ABSOLUTE|ITYPE_DPATH)
  325. #define ITYPE_PATH_RELND (ITYPE_PATH|ITYPE_RELATIVE|ITYPE_NDPATH)
  326. #define ITYPE_PATH_RELD (ITYPE_PATH|ITYPE_RELATIVE|ITYPE_DPATH)
  327. #define ITYPE_PATH_ABSND_WC (ITYPE_PATH_ABSND|ITYPE_WILD)
  328. #define ITYPE_PATH_ABSD_WC (ITYPE_PATH_ABSD|ITYPE_WILD)
  329. #define ITYPE_PATH_RELND_WC (ITYPE_PATH_RELND|ITYPE_WILD)
  330. #define ITYPE_PATH_RELD_WC (ITYPE_PATH_RELD|ITYPE_WILD)
  331. #define ITYPE_PATH_SYS_SEM (ITYPE_PATH_SYS|ITYPE_SYS_SEM)
  332. #define ITYPE_PATH_SYS_SHMEM (ITYPE_PATH_SYS|ITYPE_SYS_SHMEM)
  333. #define ITYPE_PATH_SYS_MSLOT (ITYPE_PATH_SYS|ITYPE_SYS_MSLOT)
  334. #define ITYPE_PATH_SYS_PIPE (ITYPE_PATH_SYS|ITYPE_SYS_PIPE)
  335. #define ITYPE_PATH_SYS_COMM (ITYPE_PATH_SYS|ITYPE_SYS_COMM)
  336. #define ITYPE_PATH_SYS_PRINT (ITYPE_PATH_SYS|ITYPE_SYS_PRINT)
  337. #define ITYPE_PATH_SYS_QUEUE (ITYPE_PATH_SYS|ITYPE_SYS_QUEUE)
  338. #define ITYPE_PATH_SYS_SEM_M (ITYPE_PATH_SYS|ITYPE_SYS_SEM|ITYPE_META)
  339. #define ITYPE_PATH_SYS_SHMEM_M (ITYPE_PATH_SYS|ITYPE_SYS_SHMEM|ITYPE_META)
  340. #define ITYPE_PATH_SYS_MSLOT_M (ITYPE_PATH_SYS|ITYPE_SYS_MSLOT|ITYPE_META)
  341. #define ITYPE_PATH_SYS_PIPE_M (ITYPE_PATH_SYS|ITYPE_SYS_PIPE|ITYPE_META)
  342. #define ITYPE_PATH_SYS_COMM_M (ITYPE_PATH_SYS|ITYPE_SYS_COMM|ITYPE_META)
  343. #define ITYPE_PATH_SYS_PRINT_M (ITYPE_PATH_SYS|ITYPE_SYS_PRINT|ITYPE_META)
  344. #define ITYPE_PATH_SYS_QUEUE_M (ITYPE_PATH_SYS|ITYPE_SYS_QUEUE|ITYPE_META)
  345. #define ITYPE_DEVICE_DISK (ITYPE_DEVICE|ITYPE_DISK)
  346. #define ITYPE_DEVICE_LPT (ITYPE_DEVICE|ITYPE_LPT)
  347. #define ITYPE_DEVICE_COM (ITYPE_DEVICE|ITYPE_COM)
  348. #define ITYPE_DEVICE_CON (ITYPE_DEVICE|ITYPE_CON)
  349. #define ITYPE_DEVICE_NUL (ITYPE_DEVICE|ITYPE_NUL)
  350. #ifdef __cplusplus
  351. }
  352. #endif
  353. #endif // ndef _ICANON_