SmsApi.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:73k
源码类别:

模拟服务器

开发平台:

C/C++

  1. // **************************************************************************
  2. //
  3. //  File: SMSAPI.H
  4. //
  5. //  Copyright (c) 199 - 1999 Microsoft Corp.
  6. //
  7. //  This is the header file for the SMS API.
  8. //
  9. //  This file contains all data definitions, manifests, return codes and
  10. //  API declarations that constitute the API set.
  11. //
  12. //
  13. // **************************************************************************
  14. // **************************************************************************
  15. //
  16. //  The SMS API set provides a set of interfaces to enable querying and,
  17. //  in some cases creation and deletion, of data from an SMS database.
  18. //
  19. //  SMS contains numerous objects to which an ISV needs access. These objects
  20. //  are (not in any particular order): packages, jobs, workstation command
  21. //  lines, program items, sites, domains, machines, machine groups.
  22. //
  23. //  The SMS API is built using a technology known as the objectity technique.
  24. //  This technique expresses all objects in terms of containers, folders,
  25. //  and scalars. All SMS objects are thus expressed in these terms.
  26. //  The advantage of this is that we have a standard interface to all
  27. //  objects. That is, the API does not distinguish between, say, a job and
  28. //  a machine.
  29. //
  30. //  The starting point is the container. There are certain types of container
  31. //  defined (container types below). A container is opened and then
  32. //  populated. The act of populating a container causes it to be filled with
  33. //  folders of defned types. A folder can contain sub-folders and scalars.
  34. //  Scalars are akin to leaf nodes in a hierarchy graph. The contain a
  35. //  name, type, and value.
  36. //
  37. //  Much of the power to the objectity technique is provided by filters.
  38. //  These are objects which specify selection criteria. Filters are applied
  39. //  by the user at the container level, at which point the implementation of
  40. //  the API will assume ownership of the filter. It is guaranteed that only
  41. //  folders matching the filters will be included in the container hierarchy.
  42. //
  43. //  Every folder can contain a set of scalars. Not all folders do, for
  44. //  example a machine folder does not. In some cases a folder contains a
  45. //  defined set of scalars, in other cases the scalar set can only be
  46. //  determined at run time. In cases where the scalar set is predetermined
  47. //  it will be documented in supporting documentation.
  48. //
  49. //  The APIs behave in a uniform manner.
  50. //  1. They all return a status code (SMS_STATUS).
  51. //  2. Where a value needs to be returned, it is done via a reference
  52. //     parameter.
  53. //
  54. //  An API is provided to determine the API version. Any problems involving
  55. //  the SMS API should include the information provided by this API.
  56. //
  57. //  The first step in using the APIs to to establish a connection to a
  58. //  datasource. Currently the only datasource supported in SQL, but the
  59. //  API is designed in such a way that additional datasources can be
  60. //  added. Two APIs are provided for dealing with datasources:
  61. //  DataSourceConnect and DataSourceDisonnect. The connect API returns a
  62. //  connection handle, this is used in subsequent calls to open containers.
  63. //
  64. //  Apart from these APIs, the rest of the API set is divided into four
  65. //  groups:
  66. //  1. Container APIs.
  67. //  2. Folder APIs.
  68. //  3. Scalar APIs.
  69. //  4. Filter APIs.
  70. //
  71. //  1. Container APIs.
  72. //  These allow a container to be opened, a filter to be applied to a
  73. //  container, a container to be populated with folders, a folder to be
  74. //  retrieved, and the container to be closed. An API also exists to
  75. //  return the number of folders currently contained in a container.
  76. //
  77. //  2. Folder APIs.
  78. //  These allow a for retrieval of various types of information about a
  79. //  folder (its ID or name, its type, the number of sub-folders, the number
  80. //  of scalars). Retrieval of sub-folders within a folder in both a
  81. //  sequential fashion and by name. Retrieval of scalars (sequential and by
  82. //  name. And closure of the folder.
  83. //  An API exists to allow folder creation. However, this is implementation
  84. //  dependant. That is, most folders do not permit creation, some (eg
  85. //  ceratin types of jobs) do.
  86. //
  87. //  3. Scalar APIs.
  88. //  There is a bit of overlap between this and the previous group. Although
  89. //  scalar retrieval is included in the Folder API group, it can also be
  90. //  considered a scalar API.
  91. //  An API is provided to set/update the value of a scalar. This can
  92. //  currently only be done in a folder that is being newly created.
  93. //
  94. //  4. Filter APIs.
  95. //  APIs for opening and closing a filter, and adding tokens into a filter.
  96. //  Filters are composed of one or more tokens of the same type. Some filters
  97. //  permit grouping of tokens within the filter (ie machine filter). This
  98. //  allows for complex boolean expressions.
  99. //  Tokens differ between different filters, but have a common interface.
  100. //  Tokens are contructed via the SmsAddToken API.
  101. //
  102. //  5. Filter container APIs
  103. //  Certain filters can be persistent, that is they are saved in the database
  104. //  and can be reloaded by separate processes. These filters can be created
  105. //  either the APIs, or via the SMS Admin.
  106. //   These APIs enable the retrieval of these filters from the datasource
  107. //  and the commital of new filters into the datasource.
  108. //  Currently machine filters are the only filters capable of exhibiting
  109. //  persistence.
  110. //
  111. // **************************************************************************
  112. #ifndef _SMSAPI_H_
  113. #define _SMSAPI_H_
  114. // ====================================================================
  115. //
  116. //  Includes
  117. //
  118. // ====================================================================
  119. #include <qrycodes.h>           // The query codes for Machine queries.
  120. #include <smsinfo.h>            // Manifests related to scalar settings.
  121. #include <objectty.h>           // Objectity engine.
  122. #ifdef __cplusplus
  123. extern "C" {
  124. #endif
  125. // ====================================================================
  126. //
  127. //  Datasource definition information.
  128. //
  129. // ====================================================================
  130. //
  131. // Supported datasources.
  132. // (NOTE: only sql supported currently).
  133. //
  134. typedef enum { DB_SQL, DB_SQL_CONNECTED, DB_OTHER } DATASOURCE_TYPE;
  135. //
  136. // Prototype for a decryption function. This is the last parameter
  137. // to the SQL_CONNECT_PARAMS structure.
  138. // When a user calls the DataSourceConnect API he can pass in the
  139. // user name and password in encrypted form. If the decryption function
  140. // pointer is non-null the the API will attempt to call this function
  141. // both for the user name and password.
  142. // The decryption function is user-supplied, it is expected to return
  143. // the decrypted data in the first parameter.
  144. //
  145. typedef void (*PDECRYPTFUNC)(char *pszBuffer, char *pszDecryptMe, char *pszKey);
  146. //
  147. //  The information block needed for the DataSourceConnect API.
  148. //  1. SQL datasource.
  149. //
  150. typedef struct _SQL_CONNECT_PARAMS {
  151.     DATASOURCE_TYPE ds;
  152.     char *pszServer;                    // SQL Server name.
  153.     char *pszUserName;                  // User name (possibly encrypted).
  154.     char *pszPasswd;                    // Password (possibly encrypted).
  155.     char *pszDbName;                    // Database name.
  156.     char *pszKey;                       // Decryption key.
  157.     PDECRYPTFUNC pFunc;                 // Pointer to a decryption function.
  158. } SQL_CONNECT_PARAMS;
  159. //
  160. //  2. RESERVED DO NOT USE
  161. //
  162. typedef struct _SQL_CONNECT_CONNECTED_PARAMS {
  163.     DATASOURCE_TYPE ds;
  164.     HANDLE hDataSource;
  165.     const char *pszAccessType;
  166. } SQL_CONNECT_CONNECTED_PARAMS;
  167. //
  168. // This only has the type field. It is used for extracting the type
  169. // in such a fashion that user code doesn't have to imply any
  170. // particular data source. It has no use other than that.
  171. //
  172. typedef struct _GENERIC {
  173.     DATASOURCE_TYPE ds;
  174. } GENERIC;
  175. // We can now define the DATASOURCE. It is a union of the structs above.
  176. typedef union {
  177.     GENERIC             type;
  178.     SQL_CONNECT_PARAMS  sqlParams;
  179.     SQL_CONNECT_CONNECTED_PARAMS sqlConnectedParams;
  180. } DATASOURCE;
  181. // ====================================================================
  182. //
  183. //  Return codes. See also objectty.h.
  184. //
  185. // ====================================================================
  186. typedef DWORD SMS_STATUS;           // All APIs return an SMS_STATUS.
  187. #define SMS_OK                          OTT_OK
  188. #define SMS_MORE_DATA                   OTT_MORE_DATA
  189. #define SMS_NO_MORE_DATA                OTT_NO_MORE_DATA
  190. #define SMS_FOLDER_NO_UPDATE            OTT_FOLDER_NO_UPDATE
  191. // Error codes when registering (and accessing) containers and filters
  192. #define SMS_DUPLICATE_CONTAINER_ID      OTT_DUPLICATE_CONTAINER_ID
  193. #define SMS_DUPLICATE_FOLDER_ID         OTT_DUPLICATE_FOLDER_ID
  194. #define SMS_DUPLICATE_FILTER_ID         OTT_DUPLICATE_FILTER_ID
  195. #define SMS_DUPLICATE_FILTER            OTT_DUPLICATE_FILTER
  196. #define SMS_SCALAR_NO_UPDATE            OTT_SCALAR_NO_UPDATE
  197. #define SMS_SCALAR_WRONG_TYPE           OTT_SCALAR_WRONG_TYPE
  198. #define SMS_INVALID_CONTAINER_ID        OTT_INVALID_CONTAINER_ID
  199. #define SMS_INVALID_FOLDER_ID           OTT_INVALID_FOLDER_ID
  200. #define SMS_INVALID_FILTER_ID           OTT_INVALID_FILTER_ID
  201. #define SMS_CONTAINER_NO_UPDATE         OTT_CONTAINER_NO_UPDATE
  202. #define SMS_PARAMETER_ERROR             OTT_PARAMETER_ERROR
  203. #define SMS_UNSUPPORTED                 OTT_UNSUPPORTED
  204. // This is returned when a specific object
  205. // (folder or scalar) is requested and not
  206. // found. APIs returning this are GetFolderByID
  207. // and GetScalarByName.
  208. #define SMS_NOT_FOUND                   OTT_NOT_FOUND
  209. #define SMS_PARENT_NOT_FOUND            OTT_PARENT_NOT_FOUND
  210. #define SMS_CANT_DELETE                 OTT_CANT_DELETE
  211. #define SMS_NEW_FOLDER                  OTT_NEW_FOLDER
  212. // Error when attempting to multiply
  213. // link a folder.
  214. #define SMS_FOLDER_LINKED               OTT_FOLDER_LINKED
  215. // Filter operations.
  216. #define SMS_RANGE_ERROR                 OTT_RANGE_ERROR
  217. // These are returned when a container
  218. // operation is tried when it shouldn't be.
  219. #define SMS_CONTAINER_NOT_POPULATED     OTT_CONTAINER_NOT_POPULATED
  220. #define SMS_CONTAINER_POPULATED         OTT_CONTAINER_POPULATED
  221. // Attempt to perform persistent operation
  222. // on a non-persistent filter.
  223. #define SMS_FILTER_NOT_PERSISTENT       OTT_FILTER_NOT_PERSISTENT
  224. // Error return if the connection handle
  225. // of a filter doesn't match that of a
  226. // container to which the filter is being
  227. // applied.
  228. #define SMS_INVALID_CONNECTION_HANDLE   OTT_INVALID_CONNECTION_HANDLE
  229. #define SMS_INVALID_FILTER_TYPE         OTT_INVALID_FILTER_TYPE
  230. // Folder's can't be unlinked if there are multiple handles
  231. // to the same object.
  232. #define SMS_IN_USE_BY_OTHER             OTT_IN_USE_BY_OTHER
  233. // User (ie non-engine) codes begin here.
  234. #define SMS_ERROR                       (OTT_END + 1)
  235. #define SMS_SQL_ERROR                   (OTT_END + 2)
  236. #define SMS_INVALID_DATASOURCE          (OTT_END + 3)
  237. #define SMS_INVALID_HANDLE              (OTT_END + 4)
  238. #define SMS_INVALID_FOLDER_TYPE         (OTT_END + 6)
  239. #define SMS_CONNECT_FAILED              (OTT_END + 7)
  240. #define SMS_NO_CREATE                   (OTT_END + 8)
  241. #define SMS_FOLDER_NOT_MODIFIED         (OTT_END + 9)
  242. #define SMS_INCORRECT_FOLDER_TYPE       (OTT_END + 10)  // Unused.
  243. #define SMS_INVALID_PARAMETER           (OTT_END + 11)
  244. #define SMS_EMPTY                       (OTT_END + 12)
  245. // Return when commiting a child folder
  246. // and the parent folder must be committed.
  247. #define SMS_PARENT_NEEDS_COMMIT         (OTT_END + 13)
  248. #define SMS_PARENT_ALREADY_COMMITTED    (OTT_END+ 14)
  249. // Used in asynchronous folder retrieval.
  250. // Indicates that there might be more
  251. // data but it isn't available yet.
  252. #define SMS_NOT_READY                   (OTT_END + 15)
  253. #define SMS_FILTER_NO_MODIFY            (OTT_END + 16)
  254. #define SMS_FOLDER_ALREADY_DELETED      (OTT_END + 17)
  255. // Only allow one active connection.
  256. // This is an SMS restriction.
  257. #define SMS_ALREADY_CONNECTED           (OTT_END + 18)
  258. // Some failure in committing a folder
  259. #define SMS_COMMIT_FAILED               (OTT_END + 19)
  260. // Specific failure in linking a folder
  261. #define SMS_DUPLICATE_FOLDER            (OTT_END + 20)
  262. // ====================================================================
  263. //
  264. //  Various manifests.
  265. //
  266. // ====================================================================
  267. // The location of the SMS registry root.
  268. #define SMS_REG_ROOT "SOFTWARE\Microsoft\SMS\"
  269. // The max size of character (string) data that we return.
  270. #define SMS_DATA_BUFF_SIZE  255
  271. // 'SMSBUFF' and 'OBJDESCRIPTOR' used in object type enumeration APIs.
  272. // ===================================================================
  273. // A character buffer.
  274. // -------------------
  275. typedef char SMSBUFF[SMS_DATA_BUFF_SIZE+1];
  276. // Describes an object returned from SmsEnumObjects.
  277. // -------------------------------------------------
  278. typedef struct _OBJDESCRIPTOR {
  279.     DWORD objType;                  // Type of this object.
  280.     SMSBUFF szName;                 // Object name (eg 'Personal Computer')
  281.     SMSBUFF szFriendlyName;         // Friendly name. Only used in groups
  282.                                     // where szName would be, eg,
  283.                                     // 'MICROSOFT|IDENTIFICATION|1.0', the
  284.                                     // friendly name would be 'Identification'.
  285.     BOOL bGotFriendlyName;          // TRUE if we have a friendly name.
  286.     DWORD dwRelopMin;               // For attributes, indicates range of
  287.     DWORD dwRelopMax;               // relational operators that can be used
  288.                                     // for this attribute.
  289.     BOOL bGotRelops;                // TRUE if we have the relops fields set.
  290. } OBJDESCRIPTOR;
  291. // Object types.
  292. // =============
  293. // This is the value that is inserted by the object
  294. // enumeration APIs into the OBJDESCRIPTOR structure.
  295. // --------------------------------------------------
  296. #define OT_ARCHLIST         1
  297. #define OT_ARCH             2
  298. #define OT_GROUP            3
  299. #define OT_ATTRIBUTE        4
  300. #define OT_PLATFORMS        5
  301. #define OT_PLATFORM_PDF     6
  302. #define OT_PLATFORM_WINST   7
  303. #define OT_PLATFORM_NAD     8
  304. #define OT_UNKNOWN          100
  305. // --------------------------------------------------------------------
  306. // Flags for Populate options.
  307. // --------------------------------------------------------------------
  308. #define POP_SYNC            0x00000000
  309. #define POP_ASYNC           0x00000001
  310. #define POP_EVENT           0x00000010
  311. #define POP_WINDOW          0x00000020
  312. // --------------------------------------------------------------------
  313. // Folder types supported by smsapi (MUST NOT BEGIN AT ZERO).
  314. // --------------------------------------------------------------------
  315. #define F_SITE              1               // Site folder.
  316. #define F_MACHINE           2               // Machine folder.
  317. #define F_GROUP             3               // Subfolder of machine
  318. #define F_DOMAIN            4               // Domain folder, subfolder
  319.                                             // of a site.
  320. // Jobs
  321. #define F_SYSTEMJOB         5               // System (NAD/Site) job folder.
  322. //#define F_MINIJOB           6               // Mini-job folder.
  323. #define F_INSTALLJOB        7               // Job folder (wksta install).
  324. #define F_SRVINSTALLJOB     8               // Job folder (server install).
  325. #define F_REMPKGJOB         9               // Remove package Job folder.
  326. #define F_PACKAGE           10              // Packages.
  327. #define F_WCL               11              // Workstation command lines.
  328. #define F_PROGITEM          12              // Program items.
  329. #define F_INVENTORY         13              // Inventory rules.
  330. #define F_MACHINEGROUP      14              // Machine group
  331. #define F_SITEGROUP         15              // Site group folder
  332. // --------------------------------------------------------------------
  333. // Container types supported by smsapi (MUST NOT BEGIN AT ZERO).
  334. // --------------------------------------------------------------------
  335. #define C_SITE              1               // Site container.
  336. #define C_JOB               2               // Job container.
  337. #define C_MACHINE           3               // Machine container.
  338. #define C_PACKAGE           4               // Package container.
  339. #define C_MACHINEGROUP      5               // Machine group
  340. #define C_SITEGROUP         6               // Site group
  341. // ====================================================================
  342. //
  343. //      Filter information.
  344. //
  345. // ====================================================================
  346. // --------------------------------------------------------------------
  347. //  Filter types
  348. // --------------------------------------------------------------------
  349. #define SITE_FILTER         1
  350. #define MACHINE_FILTER      2
  351. #define GROUP_FILTER        3
  352. #define JOB_FILTER          4
  353. #define ARCHITECTURE_FILTER 5
  354. #define PACKAGE_FILTER      6
  355. #define ATTRIBUTE_FILTER    7
  356. #define SITELIMIT_FILTER    8
  357. // --------------------------------------------------------------------
  358. // Token types.
  359. // --------------------------------------------------------------------
  360. #define TOKEN_USER          0x8    // 1000 bit 3 always set for user-token
  361. #define TOKEN_OR            0x2    // 0010 bit 1 always set for AND/OR
  362. #define TOKEN_AND           0x3    // 0011 bit 1 always set for AND/OR
  363. #define TOKEN_OPENPAREN     0x4    // 0100 bit 2 always set for PAREN
  364. #define TOKEN_CLOSEPAREN    0x5    // 0101 bit 2 always set for PAREN
  365. #define TOKEN_NOTIN         0x20   //10100 bit 2 set for a PAREN plus bit 4 for an extra indicator.
  366. #define TOKEN_OPERATOR      0x2    // Detects both AND or OR
  367. #define TOKEN_PAREN         0x4    // Detects either open or close paren
  368. // --------------------------------------------------------------------
  369. // Manifests used in filter token APIs.
  370. // --------------------------------------------------------------------
  371. #define AT_START        OTT_AT_START    // Token will be inserted at start of
  372.                                         // expression.
  373. #define AT_END          OTT_AT_END      // Token will be appended to end of
  374.                                         // expression.
  375. //
  376. // Flags field in SmsManipulateTokens.
  377. //
  378. #define TOK_GROUP           1
  379. #define TOK_UNGROUP         2
  380. #define TOK_DELETE          3
  381. #define TOK_GROUP_NOT       4
  382. /////////////////////////////////////////////////////////////////////////////
  383. /////////////////////////////////////////////////////////////////////////////
  384. /////////////////////////////////////////////////////////////////////////////
  385. ///////////     The APIs     ////////////////////////////////////////////////
  386. /////////////////////////////////////////////////////////////////////////////
  387. /////////////////////////////////////////////////////////////////////////////
  388. /////////////////////////////////////////////////////////////////////////////
  389. // **************************************************************************
  390. //
  391. //  This DLL provides a "C" interface for accessing SMS objects.
  392. //
  393. //===========================================================================
  394. //
  395. //  SmsAPIVer
  396. //
  397. //  This API returns a version string to identify the SMS API version.
  398. //
  399. //  Parameters:
  400. //      char **ppVersion                The version string is returned
  401. //                                      in this pointer.
  402. //                                      The user must not free this memory,
  403. //                                      it is a static buffer inside the API
  404. //                                      dll.
  405. //
  406. //  Returns:
  407. //      SMS_STATUS                      Always SMS_OK.
  408. //
  409. //===========================================================================
  410. //
  411. //===========================================================================
  412. //  1.  Connection APIs.
  413. //===========================================================================
  414. //
  415. //  SmsDataSourceConnect
  416. //
  417. //  This API connects to the datasource as specified in the DATASOURCE
  418. //  parameter. The API returns a connection handle in the second
  419. //  parameter.
  420. //  This handle is passed to OpenContainer.
  421. //
  422. //  Parameters:
  423. //      DATASOURCE *pd                  Pointer to DATASOURCE structure.
  424. //                                      The user must have already set up
  425. //                                      the appropriate parameters in this
  426. //                                      structure. For SQL this contains
  427. //                                      the server name, user name, password,
  428. //                                      database, public encryption key, and
  429. //                                      a pointer to a decryption function.
  430. //                                      See the description above.
  431. //      HANDLE *phConn                  Handle to a connection. This is
  432. //                                      filled in by the API.
  433. //
  434. //  Returns:
  435. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  436. //                                      error codes listed above.
  437. //
  438. //===========================================================================
  439. //
  440. //  SmsDataSourceDisconnect
  441. //
  442. //  This API releases a datasource connection that was established by
  443. //  DataSourceConnect.
  444. //
  445. //  Parameters:
  446. //      HANDLE hConn                    Handle to the connection to be closed.
  447. //
  448. //  Returns:
  449. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  450. //                                      error codes listed above.
  451. //
  452. //===========================================================================
  453. //
  454. //  2.  Engine APIs.
  455. //
  456. //  These are straight "pass-through" APIs that just call the engine APIs
  457. //  (in objectty.dll) directly. Here for name conformance and so to ensure
  458. //  that smsapi.dll will get loaded before the engine.
  459. //
  460. //===========================================================================
  461. //
  462. //  SmsEnumContainers
  463. //
  464. //  This returns an array of pointers to FOLDER_INFO structures.
  465. //  If the pData parameter is NULL the API sets pCount to the number of
  466. //  containers registered. Thus, a user can call this API with a NULL
  467. //  buffer to get the count, which enables the application to allocate
  468. //  sufficient memory. If pData is non-NULL the API will copy up to
  469. //  pCount FOLDER_INFO pointers into the data buffer. If that number
  470. //  is less than the number of containers the count will be set as
  471. //  previously described.
  472. //  The data buffer is an array of pointers to FOLDER_INFO structures.
  473. //  These point to memory in the engine's address space, it should
  474. //  not be deallocated or modified.
  475. //LATER: make this pointer to const.
  476. //
  477. //
  478. //  Parameters:
  479. //      FOLDER_INFO **pData         Pointer to array of FOLDER_INFO structures.
  480. //      DWORD *pCount               Pointer to count of containers.
  481. //
  482. //  Returns:
  483. //      SMS_STATUS                  OTT_OK: success.
  484. //                                  OTT_MORE_DATA: passed buffer not
  485. //                                      big enough. *pCount says how
  486. //                                      many containers registered.
  487. //
  488. // ====================================================================
  489. //
  490. //  SmsEnumFilters
  491. //
  492. //  This API returns a list of all filters currently registered
  493. //  in the filter registry. This list is actually an array of
  494. //  FILTER_INFO structs.
  495. //
  496. //  The memory for this array must be allocated by the caller.
  497. //  To determine the size of the array call this API with NULL as
  498. //  the first parameter. This will result in the number of filters
  499. //  being returned in pCount.
  500. //
  501. //
  502. //  Parameters:
  503. //      FILTER_INFO *paFI           Pointer to an array of FILTER_INFO
  504. //                                  structures.
  505. //                                  The user is responsible for allocating
  506. //                                  (and deallocating) this memory.
  507. //      DWORD *pCount               Pointer to count of filters.
  508. //
  509. //  Returns:
  510. //      SMS_STATUS                  OTT_OK: success.
  511. //                                  OTT_MORE_DATA: passed buffer not
  512. //                                      big enough. *pCount says how
  513. //                                      many containers registered.
  514. //
  515. // ==========================================================================
  516. //
  517. //  SmsEnumFolders
  518. //
  519. //  This API returns a list of all folders currently registered
  520. //  in the folder registry. This list is actually an array of
  521. //  FOLDER_INFO structs.
  522. //
  523. //  The memory for this array must be allocated by the caller.
  524. //  To determine the size of the array call this API with NULL as
  525. //  the first parameter. This will result in the number of filters
  526. //  being returned in pCount.
  527. //
  528. //
  529. //  Parameters:
  530. //      FOLDER_INFO **pData         Pointer to an array of FOLDER_INFO structures.
  531. //      DWORD *pCount               Pointer to count of folders.
  532. //
  533. //  Returns:
  534. //      SMS_STATUS                  OTT_OK: success.
  535. //                                  OTT_MORE_DATA: passed buffer not
  536. //                                      big enough. *pCount says how
  537. //                                      many containers registered.
  538. //
  539. // ==========================================================================
  540. //
  541. //  SmsDescribeFolder
  542. //
  543. //  This API retrieves information about a container/folder and returns
  544. //  it in the FOLDER_INFO parameter (see description of FOLDER_INFO).
  545. //  Because containers and folders share the same id space for their
  546. //  tags, it is necessary for the caller to specify which one they are
  547. //  interested in.
  548. //  Note that the Enum... APIs return a set of objects, this API returns
  549. //  only a single one.
  550. //
  551. //
  552. //
  553. //  Parameters:
  554. //      BASETYPE tObjectity         T_CONTAINER or T_FOLDER
  555. //                                  (do we want a container or folder).
  556. //      DWORD dwTag                 Container/folder type.
  557. //      FOLDER_INFO **ppFInfo       Store the retrieved FOLDER_INFO here.
  558. //
  559. //  Returns:
  560. //      SMS_STATUS                  OTT_OK: success.
  561. //                                  OTT_INVALID_CONTAINER_ID:
  562. //                                  OTT_INVALID_FOLDER_ID:
  563. //                                      The container/folder cannot be
  564. //                                      located in the registry.
  565. //
  566. //===========================================================================
  567. //  3.  Container APIs.
  568. //===========================================================================
  569. //
  570. //  SmsOpenContainer
  571. //
  572. //  Opens a container of the specified type (cType). The container is opened
  573. //  but is currently empty. The only operations that can be performed on it
  574. //  in this state is SetFilter, Populate, and CloseContainer.
  575. //  It is permissible to have multiple containers of the same type opened
  576. //  simultaneously.
  577. //  Only when a container has been populated does it have information that
  578. //  can resonably be examined.
  579. //  The container type is one of the C_xxx manifests in the list above.
  580. //
  581. //  Parameters:
  582. //      DWORD cType                     Type of the container to open.
  583. //                                      This should be one of thr C_xxx
  584. //                                      manifests above.
  585. //      HANDLE hConnect                 Handle to a connection that has been
  586. //                                      established via SmsDataSourceConnect.
  587. //      HANDLE *phContainer             Handle to the container, filled in by
  588. //                                      the API.
  589. //
  590. //  Returns:
  591. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  592. //                                      error codes listed above.
  593. //
  594. //===========================================================================
  595. //
  596. //  SmsSetFilter
  597. //
  598. //  This API submitts a filter to the container. The filter consists
  599. //  of tokens (possibly grouped) which express conditions for folder
  600. //  inclusion within a container.
  601. //  Note: when applying multiple filters an implicit AND is performed between
  602. //  filters.
  603. //
  604. //  Parameters:
  605. //      HANDLE hContainer               Identifies the container.
  606. //      HANDLE hFilter                  Handle to the filter to assign to
  607. //                                      the container.
  608. //
  609. //  Returns:
  610. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  611. //                                      error codes listed above.
  612. //
  613. //===========================================================================
  614. //
  615. //  SmsPopulate
  616. //
  617. //  This causes the container to be populated with folders according to the
  618. //  filters applied to the container.
  619. //  It should be noted that not all filters that are applied to a container
  620. //  will be activated at this stage. For instance, applying an attribute
  621. //  filter to a site container has no effect at this stage. However, the
  622. //  filter is held internally within the system and will be applied to the
  623. //  appropriate folder. For an attribute filter, its activation in a site
  624. //  container would come at the level of a child domain folder. This
  625. //  technique is known as percolating filters.
  626. //  Containers are the only level at which filters can be applied at the
  627. //  API level.
  628. //  The dwOpts parameter allows the caller to specify whether the population
  629. //  (and the folder retrieval) should be asynchronous or synchronous.
  630. //  Synchronous is the default. These options are described earlier (see
  631. //  "Populate options").
  632. //  This parameter also specifies how the event handle should be set. The
  633. //  event handle can be set by the API whenever a folder has been retrieved,
  634. //  when all folders have been retrieved, or it can not be used at all (the
  635. //  default).
  636. //
  637. //  A third parameter is an event handle. According
  638. //
  639. //  Parameters:
  640. //      HANDLE hContainer               Identifies the container.
  641. //      DWORD dwOptions                 Synchronous/asynch, event handle usage.
  642. //      NOTIFY *pNotify                 Contains information about asynchronous
  643. //                                      notification. NULL if synchronous.
  644. //                                      parameter.
  645. //  Returns:
  646. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  647. //                                      error codes listed above.
  648. //
  649. //===========================================================================
  650. //
  651. //  SmsGetNextFolder
  652. //
  653. //  This API retrieves the next folder in a parent container or folder.
  654. //
  655. //  Parameters:
  656. //      HANDLE hParent                  Identifies the parent (container or
  657. //                                      folder).
  658. //      DWORD fType                     Which type of sub-folder we want to
  659. //                                      retrieve.
  660. //      HANDLE *phFolder                Receives a handle to the next
  661. //                                      folder in the parent.
  662. //
  663. //  Returns:
  664. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  665. //                                      error codes listed above.
  666. //
  667. //===========================================================================
  668. //
  669. //  SmsCloseContainer
  670. //
  671. //  Closes a currently open container, and frees resources held be the
  672. //  container.
  673. //  It is possible to open a container's child folders and then close the
  674. //  container. This has no adverse effects on either the folders or on any
  675. //  filters that have been applied to the container.
  676. //
  677. //  Parameters:
  678. //      HANDLE hContainer               Identifies the container.
  679. //
  680. //  Returns:
  681. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  682. //                                      error codes listed above.
  683. //
  684. //===========================================================================
  685. //  4.  Folder APIs.
  686. //===========================================================================
  687. //
  688. //  SmsCreateFolder
  689. //
  690. //  This API attempts to create a folder (initally empty) of the specified
  691. //  type. Folder creation is done in the context of a parent (folder or
  692. //  container). Not all containers/folder support folder creation.
  693. //  Once created, a folder must have its scalars set by the application.
  694. //  Failure to do so will result in the system not accepting the newly
  695. //  created folder. See DescribeFolder for information on retrieving details
  696. //  about a folder's scalars.
  697. //
  698. //  Parameters:
  699. //      HANDLE hParent                  Identifies the parent (can be either
  700. //                                      container or folder).
  701. //      DWORD fType                     The type of folder to create. See
  702. //                                      the list of folders above).
  703. //      char *pszFolderID               A name to give the folder. Not all
  704. //                                      creatable folders can be named by the
  705. //                                      user. In many cases SMS itself will
  706. //                                      assign the name.
  707. //      HANDLE *phFolder                Receives a handle to the newly-created
  708. //                                      folder (if successful).
  709. //
  710. //  Returns:
  711. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  712. //                                      error codes listed above.
  713. //
  714. //===========================================================================
  715. //
  716. //  SmsGetFolderID
  717. //
  718. //  This API retrives the ID/name of the folder referenced by the folder handle.
  719. //
  720. //  Parameters:
  721. //      HANDLE hFolder                  Which folder object we're talking about.
  722. //      char *pszFolderID               Pointer to buffer to receive the
  723. //                                      folder's ID. It is the caller's
  724. //                                      responsibility to ensure that this
  725. //                                      buffer is large enough. If in doubt
  726. //                                      use of buffer of size SMS_DATA_BUFF_SIZE.
  727. //                                      This is guaranteed to be sufficient.
  728. //
  729. //  Returns:
  730. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  731. //                                      error codes listed above.
  732. //
  733. //===========================================================================
  734. //
  735. //  SmsGetFolderType
  736. //
  737. //  This API retrieves the folder's type as both an integer value and as
  738. //  a character string. For instance invoking this API on a domain folder
  739. //  will result in a type string of "Domain folder" and an integer type of
  740. //  F_DOMAIN being returned. The caller is responsible for ensuring that
  741. //  the character buffer is of sufficient size.
  742. //
  743. //  Parameters:
  744. //      HANDLE hFolder                  The folder to query.
  745. //      DWORD *pfType                   Receive's the folder's type (integer).
  746. //      char *pszfType                  Receives folder's type (as a string).
  747. //
  748. //  Returns:
  749. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  750. //                                      error codes listed above.
  751. //
  752. //===========================================================================
  753. //
  754. //  SmsEnumFolderTypes
  755. //
  756. //  This API returns an array of DWORDs which indicate what folder types
  757. //  CAN be contained within this folder. It is the caller's responsibility
  758. //  to ensure that the DWORD array (*pfTypes) is of sufficient size.
  759. //  Calling this API with pfTypes of NULL or with *pctFolderTypes of 0,
  760. //  will result in the correct count being returned to the caller in
  761. //  pctFolderTypes.
  762. //  If the *pctFolderTypes is less than the number of folders, then up to
  763. //  *pctFolderTypes are returned in the DWORD array, and a status of
  764. //  SMS_MORE_DATA is returned.
  765. //  If *pctFolderTypes is greater than the number of folders then the maximum
  766. //  number of folder types will be stored in the array, and a value of
  767. //  PARAMETER_ERROR returned. *pctFolderTypes will be updated to indicate
  768. //  the number of folder types.
  769. //
  770. //  Note the difference between this API and GetFolderCount. This returns
  771. //  a list of sub-folder types that can be contained in the folder,
  772. //  GetFolderCount returns a count of how many sub-folders of a specified
  773. //  type actually are contained in the folder.
  774. //
  775. //  Parameters:
  776. //      HANDLE hFolder                  The folder to query.
  777. //      DWORD *pfTypes                  Points to an array of DWORD.
  778. //                                      Filled in with the types of sub-
  779. //                                      folders that this folder can contain.
  780. //      DWORD *pctFolderTypes           How many types of sub-folders this
  781. //                                      folder can contain.
  782. //
  783. //  Returns:
  784. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  785. //                                      error codes listed above.
  786. //
  787. //===========================================================================
  788. //
  789. //  SmsGetFolderCount
  790. //
  791. //  This API returns (in the DWORD parameter) how many sub-folders of the
  792. //  specified folder-type are contained in this folder.
  793. //  Note that a DWORD of F_ANY means return the total count of sub-folders.
  794. //
  795. //  Parameters:
  796. //      HANDLE hFolder                  The folder (or container) to query.
  797. //      DWORD fType                     Which type of sub-folder we're
  798. //                                      interested in. F_ANY means all types.
  799. //      DWORD *pctFolders               Receives the count.
  800. //
  801. //  Returns:
  802. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  803. //                                      error codes listed above.
  804. //
  805. //===========================================================================
  806. //
  807. //  SmsGetFolderByID
  808. //
  809. //  This API the retrieves from the folder a sub-folder of the specified
  810. //  type and with a specified ID.
  811. //  This method of folder retrieval is non-sequential. Once a sub-folder has
  812. //  been retrieved it can be re-retrieved. It is always legal to open a
  813. //  folder multiple times. Doing this will create multiple instances of a
  814. //  folder. Thus, it is possible to retrieve a folder twice, close once
  815. //  instance, and still have an instance of the folder available.
  816. //  Note that a folder type of F_ANY is not accepted here, it will result
  817. //  in a return code of SMS_INVALID_FOLDER_TYPE.
  818. //  Note that a type of F_ANY is not allowed.
  819. //
  820. //
  821. //  Parameters:
  822. //      HANDLE hFolder                  The folder to query.
  823. //      DWORD fType                     Which type of sub-folder we want to
  824. //                                      retrieve (see GetFolderCount).
  825. //      char *pszFolderID               The sub-folder's ID (name).
  826. //      HANDLE *phSubFolder             Receives a handle to the sub-folder.
  827. //
  828. //  Returns:
  829. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  830. //                                      error codes listed above.
  831. //
  832. //===========================================================================
  833. //
  834. //  SmsRewind
  835. //
  836. //  This API resets the internal counts of either a container, a folder, or
  837. //  a filter so that contained sub-folders and/or scalars can be re-
  838. //  enumerated.
  839. //  Because GetNextFolder and GetNextScalar are sequential, once thay have
  840. //  been retrieved once they cannot be re-retrieved with these APIs.
  841. //  The Rewind API enbles the retrieval to be restarted.
  842. //  The options parameter allows the user to specify that either the folder
  843. //  list or the scalar list or both be rewound.
  844. //
  845. //
  846. //  Parameters:
  847. //      HANDLE hObject                  The container, folder, or filter
  848. //                                      to be rewound.
  849. //      DWORD  dwOptions                Rewind options:-
  850. //                                      RW_FOLDER: rewind folder lists.
  851. //                                      RW_SCALAR: rewind scalar lists.
  852. //                                      RW_ALL:    both.
  853. //
  854. //                                      If the object is a container or
  855. //                                      folder, a particular type of sub-
  856. //                                      folder list may be rewound by passing
  857. //                                      the child folder type in the
  858. //                                      dwOptions parameter.
  859. //
  860. //                                      If the object is a filter container,
  861. //                                      then a particular type of filter list
  862. //                                      may be rewound by passing the filter
  863. //                                      type in the dwOptions parameter.
  864. //
  865. //                                      If the object is a filter then only
  866. //                                      RW_SCALAR is valid.
  867. //
  868. //  Returns:
  869. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  870. //                                      error codes listed above.
  871. //
  872. //===========================================================================
  873. //
  874. //  SmsCloseFolder
  875. //
  876. //  This API closes the specified folder.
  877. //  Closing a folder causes sub-folders to be closed and deallocated UNLESS
  878. //  they have already been retrieved by a GetSubFolder/GetFolderByID call
  879. //  in which case they remain open.
  880. //  A folder's scalars are always closed and their memory deallocated.
  881. //
  882. //  Parameters:
  883. //      HANDLE hFolder                  The folder to close.
  884. //
  885. //  Returns:
  886. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  887. //                                      error codes listed above.
  888. //
  889. //===========================================================================
  890. //
  891. //  SmsLinkFolder
  892. //
  893. //  This API inserts the specified folder into the in-memory list of folders
  894. //  and causes it to be linked to its parent (must still be open).
  895. //  The folder is not written back to the datasource until CommitFolder is
  896. //  called.
  897. //
  898. //  Parameters:
  899. //      HANDLE hFolder                  The folder to insert.
  900. //
  901. //  Returns:
  902. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  903. //                                      error codes listed above.
  904. //
  905. //===========================================================================
  906. //
  907. //  SmsUnlinkFolder
  908. //
  909. //  This API deletes the specified folder from the in-memory list of folders.
  910. //  All memory associated with the folder is deallocated. However, the
  911. //  folder is not deleted from the datasource until CommitFolder is called.
  912. //
  913. //  Parameters:
  914. //      HANDLE hFolder                  The folder to delete.
  915. //
  916. //  Returns:
  917. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  918. //                                      error codes listed above.
  919. //
  920. //===========================================================================
  921. //
  922. //  SmsCommitFolder
  923. //
  924. //  This API causes any changes in the specified folder to be written back to
  925. //  the datasource.
  926. //  This should be called after LinkFolder and UnlinkFolder in order to make
  927. //  the changes permanent.
  928. //  Note that a Commit following an Unlink will render the specified folder
  929. //  unavailable to all operations (other that SmsCloseFolder).
  930. //
  931. //  Parameters:
  932. //      HANDLE hFolder                  The folder to update (insert or delete).
  933. //
  934. //  Returns:
  935. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  936. //                                      error codes listed above.
  937. //
  938. //===========================================================================
  939. //
  940. //  SmsDupFolder
  941. //
  942. //  This API causes the folder (hFolder) to be copied (into hNewFolder)
  943. //  in the context of the specified parent (hParent - container or folder).
  944. //
  945. //  Parameters:
  946. //      HANDLE hParent                  The parent folder in whose context
  947. //                                      the new folder will be inserted.
  948. //      HANDLE hFolder                  The folder to be duplicated
  949. //      HANDLE *phNewFolder             The handle to the new folder
  950. //                                      is returned here.
  951. //
  952. //  Returns:
  953. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  954. //                                      error codes listed above.
  955. //
  956. //===========================================================================
  957. //  5.  Scalar APIs.
  958. //===========================================================================
  959. //
  960. //  SmsGetScalarCount
  961. //
  962. //  This API returns the count of scalars in this folder.
  963. //
  964. //  Parameters:
  965. //      HANDLE hFolder                  The folder to query.
  966. //      DWORD *pctScalars               Receives the count of scalars.
  967. //
  968. //  Returns:
  969. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  970. //                                      error codes listed above.
  971. //
  972. //===========================================================================
  973. //
  974. //  SmsGetNextScalar
  975. //
  976. //  This API retrieves the next scalar from the folder.
  977. //  Scalars can either be retrieved in a sequential fashion (this API)
  978. //  or by name (GetScalarByName). The RewindFolder API enables the sequential
  979. //  enumeration of scalars to be restarted.
  980. //
  981. //  Parameters:
  982. //      HANDLE hFolder                  The folder to query.
  983. //      SCALAR *pScalar                 Pointer to a SCALAR that has been
  984. //                                      allocated by the caller.
  985. //                                      See notes on SCALAR for a full
  986. //                                      description of this structure and
  987. //                                      its use.
  988. //  Returns:
  989. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  990. //                                      error codes listed above.
  991. //
  992. //===========================================================================
  993. //
  994. //  SmsGetScalarByName
  995. //
  996. //  This API retrieves the scalar specified by its name.
  997. //
  998. //  Parameters:
  999. //      HANDLE hFolder                  The folder to query.
  1000. //      const char *pszName             Name of the scalar.
  1001. //      SCALAR *pScalar                 Pointer to a SCALAR that has been
  1002. //                                      allocated by the caller.
  1003. //                                      See notes on SCALAR for a full
  1004. //                                      description of this structure and
  1005. //                                      its use.
  1006. //  Returns:
  1007. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1008. //                                      error codes listed above.
  1009. //
  1010. //===========================================================================
  1011. //
  1012. //  SmsSetScalar
  1013. //
  1014. //  This API is used to set the value of a scalar. It is used when creating a
  1015. //  folder. In the future it will also be used to modify the value of a
  1016. //  scalar in an existing folder.
  1017. //  The set of scalars supported by a folder is always known at the time a
  1018. //  folder is opened, this is true even when a folder is being created.
  1019. //  Scalars have a name, a type, and a value. This API allows the value to
  1020. //  be set. Only values of the correct type are allowed. Attempting to set,
  1021. //  for instance, an integer value in a string scalar will result in a
  1022. //  SMS_SCALAR_WRONG_TYPE error return.
  1023. //  The API set supports the notion of access rights on folders and scalars,
  1024. //  in order for this API to succeed the caller must have the correct
  1025. //  access to both. Failure results in an error return of SMS_SCALAR_NO_UPDATE
  1026. //  or SMS_FOLDER_NO_UPDATE.
  1027. //
  1028. //  Parameters:
  1029. //      HANDLE hFolder                  The folder containing the scalar.
  1030. //      SCALAR *pScalar                 Pointer to a SCALAR that has been
  1031. //                                      allocated and filled in by the caller.
  1032. //                                      See notes on SCALAR for a full
  1033. //                                      description of this structure and
  1034. //                                      its use.
  1035. //  Returns:
  1036. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1037. //                                      error codes listed above.
  1038. //
  1039. //===========================================================================
  1040. //  6.  Filter container APIs.
  1041. //===========================================================================
  1042. //
  1043. //  SmsOpenFilterContainer
  1044. //
  1045. //  The filter container is a storage mechanism for persistent filters,
  1046. //  currently only Machine Filters (SMS Queries) fall into this category.
  1047. //
  1048. //  Calling this API causes the filter container to be automatically populated
  1049. //  with all persistent filters in the system.
  1050. //
  1051. //  Parameters:
  1052. //      HANDLE hConnection              Which connection to use.
  1053. //      HANDLE *phFContainer            Receives the handle to the opened
  1054. //                                      filter container.
  1055. //
  1056. //  Returns:
  1057. //      SMS_STATUS                      Status. Either SMS_OK or an error code.
  1058. //                                      LIST POSSIBLE ERROR CODES HERE.
  1059. //
  1060. //===========================================================================
  1061. //
  1062. //  SmsCloseFilterContainer
  1063. //
  1064. //  Closes the filter container. All filters container herein that have
  1065. //  not been explicitly opened are closed and the memory associated with
  1066. //  them is freed.
  1067. //
  1068. //  Parameters:
  1069. //      HANDLE hFContainer              The handle to the filter container.
  1070. //
  1071. //  Returns:
  1072. //      SMS_STATUS                      Status. Either SMS_OK or an error code.
  1073. //                                      LIST POSSIBLE ERROR CODES HERE.
  1074. //
  1075. //===========================================================================
  1076. //
  1077. //  SmsGetNextFilter
  1078. //
  1079. //  This returns (in *phFilter) a handle to the next sequential filter of
  1080. //  the specified type from the filter container (specified by hFContainer).
  1081. //  A filter type of F_ANY is not acceptable.
  1082. //
  1083. //  Parameters:
  1084. //      HANDLE hFContainer              Handle to the filter container.
  1085. //      DWORD frType                    Filter type.
  1086. //      HANDLE *phFilter                Handle to the filter returned here.
  1087. //
  1088. //  Returns:
  1089. //      SMS_STATUS                      Status. Either SMS_OK or an error code.
  1090. //                                      LIST POSSIBLE ERROR CODES HERE.
  1091. //
  1092. //===========================================================================
  1093. //
  1094. //  SmsGetFilterByID
  1095. //
  1096. //  The API will return (in *phFilter) a handle to the filter of the specified
  1097. //  type which has the specified ID.
  1098. //  As above, the handle to the filter container is also passed into the API.
  1099. //  A filter type of F_ANY is not acceptable.
  1100. //
  1101. //  Parameters:
  1102. //      HANDLE hFContainer              Handle to the filter container.
  1103. //      DWORD frType                    Filter type.
  1104. //      const char *pszID               ID of the filter to retrieve.
  1105. //      HANDLE *phFilter                Handle to the filter returned here.
  1106. //
  1107. //  Returns:
  1108. //      SMS_STATUS                      Status. Either SMS_OK or an error code.
  1109. //                                      LIST POSSIBLE ERROR CODES HERE.
  1110. //
  1111. //===========================================================================
  1112. //
  1113. //  SmsGetFilterID
  1114. //
  1115. //  This returns, in pszID, the ID of the filter specified by the handle.
  1116. //
  1117. //  Parameters:
  1118. //      HANDLE hFilter
  1119. //      char *pszID
  1120. //
  1121. //  Returns:
  1122. //      SMS_STATUS                      Status. Either SMS_OK or an error code.
  1123. //                                      LIST POSSIBLE ERROR CODES HERE.
  1124. //
  1125. //===========================================================================
  1126. //
  1127. //  SmsCommitFilter
  1128. //
  1129. //  This API will attempt to make the specified filter persistent. The filter
  1130. //  must be of a type that supports persistence, and all manadatory scalars
  1131. //  for the filter must have been set.
  1132. //
  1133. //  Parameters:
  1134. //      HANDLE hFilter
  1135. //      HANDLE hFContainer
  1136. //
  1137. //  Returns:
  1138. //      SMS_STATUS                      Status. Either SMS_OK or an error code.
  1139. //                                      LIST POSSIBLE ERROR CODES HERE.
  1140. //
  1141. //===========================================================================
  1142. //
  1143. //===========================================================================
  1144. //  7.  Filter APIs.
  1145. //===========================================================================
  1146. //
  1147. //  SmsCreateFilter
  1148. //
  1149. //  This API creates a filter of the specified type, initially empty. The
  1150. //  caller must then set tokens in this filter.
  1151. //  Filter types are listed above.
  1152. //
  1153. //  Parameters:
  1154. //      DWORD fType                     Type of filter to create.
  1155. //      HANDLE hConnection              Filters are associated with a
  1156. //                                      connection.
  1157. //      HANDLE *phFilter                Receives a handle to the filter.
  1158. //  Returns:
  1159. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1160. //                                      error codes listed above.
  1161. //
  1162. //============================================================================
  1163. //
  1164. //  SmsCloseFilter
  1165. //
  1166. //  Close the specified filter and deallocate any memory asociated with it.
  1167. //  Once a filter has been applied to a container (SetFilter), the user is
  1168. //  free to close it. The API system has made it own copy which will be freed
  1169. //  when no longer necessary.
  1170. //
  1171. //  Parameters:
  1172. //      HANDLE hFilter                  The filter to close.
  1173. //
  1174. //  Returns:
  1175. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1176. //                                      error codes listed above.
  1177. //
  1178. //============================================================================
  1179. //
  1180. //  SmsGetFilterType
  1181. //
  1182. //  This API gets the type for a particular filter. Using this type it is
  1183. //  possible to get the filter template.
  1184. //  Parameters:
  1185. //      HANDLE hFilter                  The filter to retrieve the type for.
  1186. //      DWORD *pfilterType              The filter type is returned here.
  1187. //      char *pszTag                    The filter tag is returned here.
  1188. //
  1189. //  Returns:
  1190. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1191. //                                      error codes listed above.
  1192. //
  1193. //===========================================================================
  1194. //
  1195. //  SmsGetToken
  1196. //
  1197. //  This API retrieves a token from the specified filter or folder. The token
  1198. //  to retrieve is given by the index parameter. See also SmsGetTokenCount.
  1199. //  The TOKEN structure is detailed in the file objectty.h.
  1200. //
  1201. //  Parameters:
  1202. //      HANDLE hObject                  Handle to filter or folder.
  1203. //      INT iIndex
  1204. //      TOKEN *pTokenInfo
  1205. //
  1206. //  Returns:
  1207. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1208. //                                      error codes listed above.
  1209. //
  1210. //===========================================================================
  1211. //
  1212. //  SmsAddToken
  1213. //
  1214. //  This API allows the caller to add a token into a filter (or folder). The
  1215. //  ANDOR parameter specifies if the token is to be ANDed or ORed with the
  1216. //  preceeding token. The index specifies whereabout in the filter expression
  1217. //  the token is to be inserted. The rules are as follows:
  1218. //  1. index is AT_START (-1), the token will be inserted at the start of the
  1219. //     expression and the ANDOR operator will be postfixed.
  1220. //  2. index is AT_END (-2), the token will be appended to the end of the
  1221. //     expression, the ANDOR operator will prefix the token.
  1222. //  3. if index is anything else, if the expression is currently empty then
  1223. //     the token will be inserted at the start of the expression, and the
  1224. //     ANDOR operator is ignored. If the expression is not empty then the
  1225. //     token will be inserted at the given index and the operator prefixed.
  1226. //     The exception here is if the index is out of range, in this case the
  1227. //     token will be appended with the ANDOR being prefixed.
  1228. //     In all cases, if inserting the token would cause the resulting
  1229. //     expression to be illegal a status of SMS_RANGE_ERROR will be returned.
  1230. //
  1231. //  Parameters:
  1232. //      HANDLE hObject                  Handle to filter or folder.
  1233. //      ANDOR opAndOr
  1234. //      TOKEN *pTokenInfo
  1235. //      INT iIndex
  1236. //
  1237. //  Returns:
  1238. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1239. //                                      error codes listed above.
  1240. //
  1241. //===========================================================================
  1242. //
  1243. //  SmsGetTokenCount
  1244. //
  1245. //  This API will return (in *pctTokens) the number of tokens currently in
  1246. //  the filter or folder expression.
  1247. //
  1248. //  Parameters:
  1249. //      HANDLE hObject                  Handle to either filter or folder.
  1250. //      DWORD *pctTokens
  1251. //
  1252. //  Returns:
  1253. //      SMS_STATUS                      SMS_OK, or SMS_INVALID_HANDLE.
  1254. //
  1255. //===========================================================================
  1256. //
  1257. //  SmsManipulateTokens
  1258. //
  1259. //  This APIs allows for the manipulation of tokens within a filter or folder
  1260. //  expression in various ways, according to the flags parameter.
  1261. //  TOK_GROUP       The tokens between the specified indicies are grouped
  1262. //                  together to form a sub-expression, ie they are backeted by
  1263. //                  parentheses.
  1264. //  TOK_UNGROUP     The tokens between the specified indicies have their
  1265. //                  parenthesis removed. This undoes the action of TOK_GROUP.
  1266. //  TOK_DELETE      The tokens within the specified indecies are deleted.
  1267. //                  In this case the tokens must not form a legal sub-
  1268. //                  expression.
  1269. //  TOK_GROUP_NOT   This is applicable only to persistent filters. At the
  1270. //                  moment that means only machine filters.
  1271. //                  This flag is applied to a range of one or more tokens that
  1272. //                  form a legal sub-expression. That is, a range of tokens
  1273. //                  that can ge grouped. The action performed by this is to
  1274. //                  group these tokens and preceed them with a 'NOT IN'
  1275. //                  token. This has the effect of specifying exclusion.
  1276. //
  1277. //  The user may use the manifests AT_START and AT_END to indicate
  1278. //  the full range of tokens within the filter or folder object.
  1279. //  The iStart and iEnd may be one of the following:
  1280. //  1. AT_START (-1), the index will be at the start of the expression.
  1281. //  2. AT_END (-2), the index will be at the end of the expression.
  1282. //  3. For any other valid indexes, the tokens will be manipulated within the given indexes
  1283. //
  1284. //  Parameters:
  1285. //      HANDLE hObject                  Handle to either filter or folder.
  1286. //      DWORD dwFlags
  1287. //      INT iStart
  1288. //      INT iEnd
  1289. //
  1290. //  Returns:
  1291. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1292. //                                      error codes listed above.
  1293. //
  1294. //===========================================================================
  1295. //
  1296. //  SmsGetAllFilters
  1297. //
  1298. //  This API retrieves from the specified container a list of filter handles
  1299. //  that have been applied to that container.
  1300. //  It is important to note that once this has been called, the API
  1301. //  SmsCloseFilter must be called for each of the filters in the array.
  1302. //
  1303. //  Calling this with NULL for the array of filters will cause the *pctFilters
  1304. //  parameter to be set with the number of filters, in this case the API
  1305. //  will return a status of SMS_MORE_DATA.
  1306. //  The user should then allocate sufficient memory and call the API again.
  1307. //
  1308. //  Note that the container specified here is a normal (ie folder) container
  1309. //  and not a filter container.
  1310. //
  1311. //  Parameters:
  1312. //      HANDLE hContainer
  1313. //      HANDLE *pahFilters
  1314. //      DWORD *pctFilters
  1315. //
  1316. //  Returns:
  1317. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1318. //                                      error codes listed above.
  1319. //
  1320. //===========================================================================
  1321. //
  1322. //===========================================================================
  1323. //  8.  Object enumeration APIs.
  1324. //===========================================================================
  1325. //
  1326. //  SmsEnumObjectTypes
  1327. //
  1328. //  This API returns a list of first-class objects that are known to the
  1329. //  API.
  1330. //  These objects do not have a direct existence in the container hierarchy,
  1331. //  but play an important part in the API. The objects of major concern are
  1332. //  architectures and their descendents, but Platforms are also supported.
  1333. //
  1334. //  A first-class object is one that is known directly to the APIs and which
  1335. //  does not require any additional informaion. Thus the system knows
  1336. //  directly about architectures and platforms, while it cannot know about,
  1337. //  for instance, attributes, without first knowing about an architecture
  1338. //  and a groupclass.
  1339. //
  1340. //  The 'pObjects' parameter is an array of SMSBUFF objects. On successful
  1341. //  completion of the API this array will be filled with the names of
  1342. //  each first-class object known to the system.
  1343. //
  1344. //  On entry the 'pCtObjects' parameter tells the API the size of the
  1345. //  pObjects array. On exit it contains the actual number of objects
  1346. //  known to the system.
  1347. //  If this parameter is less than the number of objects known to the system
  1348. //  then it is still set to the total, but no information will have been
  1349. //  copied to the pObjects array, and a status of SMS_MORE_DATA will be
  1350. //  returned.
  1351. //
  1352. //  Parameters:
  1353. //      HANDLE hConnection              Handle to a connection that has been
  1354. //                                      established via SmsDataSourceConnect.
  1355. //      SMSBUFF *pObjects
  1356. //      DWORD *pCtObjects
  1357. //
  1358. //  Returns:
  1359. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1360. //                                      error codes listed above.
  1361. //
  1362. //===========================================================================
  1363. //
  1364. //  SmsEnumObjects
  1365. //
  1366. //  This object actually does the work of enumerating objects. For first-
  1367. //  class objects (see above) the 'pPredecessor' parameter is not used,
  1368. //  in this case it may be set to NULL. For non first-class objects this
  1369. //  list states the predecessor objects that must be given to the system
  1370. //  in order for it to locate the requested object.
  1371. //
  1372. //  The 'ctPredecessors' parameter tells the API the number of entries in the
  1373. //  predecessor list.
  1374. //
  1375. //  'pszObjectType' tells the API what object type the user is interested in.
  1376. //
  1377. //  'pObjects' is an array of OBJDESCRIPTORS, this array will be filled in
  1378. //  with details of the requested object type.
  1379. //
  1380. //  'pCtObjects' is a pointer to a DWORD. On entry it tells the API the number
  1381. //  of entries in 'pObjects'. On exit it is always set to then count of
  1382. //  objects of the specified type. If the entry value is less than the actual
  1383. //  number of objects then no data is copied and a status of SMS_NMO_MORE_DATA
  1384. //  is returned.
  1385. //
  1386. //  Consider an example.
  1387. //  If we want to enumerate the attributes in the 'MICROSOFT|IDENTIFICATION|1.0'
  1388. //  groupclass for 'Personal Computer' objects then we would set the parameters
  1389. //  as follows:
  1390. //      pszObjectType    = "MICROSOFT|IDENTIFICATION|1.0"
  1391. //      pPredecessors[0] = "Architectures"
  1392. //      pPredecessors[1] = "Personal Computer"
  1393. //      ctPredecessors   = 2
  1394. //      pObjects - you can declare it as 'OBJDESCRIPTOR pObjects[SOME_SIZE]'
  1395. //      *pCtObjects      = SOME_SIZE
  1396. //
  1397. //  On exit the pObjects array would have 9 entries (as currently defined,
  1398. //  this can change). The first entry would look like this:
  1399. //      pObjects[0].objType          = OT_ATTRIBUTE
  1400. //      pObjects[0].szName           = 'Name"
  1401. //      pObjects[0].szFriendlyName - unused
  1402. //      pObjects[0].bGotFriendlyName = FALSE
  1403. //      pObjects[0].dwRelopMin       = QOP_STR_EQ
  1404. //      pObjects[0].dwRelopMax       = QOP_UPCASE_NOTLIKE
  1405. //      pObjects[0].bGotRelops       = TRUE
  1406. //  Parameters:
  1407. //      HANDLE hConn
  1408. //      char *pszObjectType
  1409. //      SMSBUFF *pPredecessors
  1410. //      DWORD ctPredecessors
  1411. //      OBJDESCRIPTOR *pObjects
  1412. //      DWORD *pCtObjects
  1413. //
  1414. //  Returns:
  1415. //      SMS_STATUS                      Status. Either SMS_OK or one of the
  1416. //                                      error codes listed above.
  1417. //
  1418. //===========================================================================
  1419. // ====================================================================
  1420. //      Version number API.
  1421. // ====================================================================
  1422. __declspec (dllexport) SMS_STATUS SmsAPIVer( char **ppVersion );
  1423. // ====================================================================
  1424. //      Engine APIs.
  1425. // ====================================================================
  1426. __declspec (dllexport) SMS_STATUS SmsEnumContainers(
  1427.                 FOLDER_INFO **pData,
  1428.                 DWORD *pCount );
  1429. __declspec (dllexport) SMS_STATUS SmsEnumFilters(
  1430.                 FILTER_INFO *paFI,
  1431.                 DWORD *pCount );
  1432. __declspec (dllexport) SMS_STATUS SmsEnumFolders(
  1433.                 FOLDER_INFO **pData,
  1434.                 DWORD *pCount );
  1435. __declspec (dllexport) SMS_STATUS SmsDescribeFolder(
  1436.                 BASETYPE tObjectity,        // T_CONTAINER or T_FOLDER.
  1437.                 DWORD dwTag,                // folder type (or F_ANY)
  1438.                 FOLDER_INFO **ppFInfo );    // We store the FOLDER_INFO here.
  1439. // ====================================================================
  1440. //      Connection APIs.
  1441. // ====================================================================
  1442. __declspec (dllexport) SMS_STATUS SmsDataSourceConnect(
  1443.                                 DATASOURCE *pd,
  1444.                                 HANDLE *phConn );
  1445. __declspec (dllexport) SMS_STATUS SmsDataSourceDisconnect(
  1446.                                 HANDLE hConn );
  1447. // ====================================================================
  1448. //      Container APIS.
  1449. // ====================================================================
  1450. __declspec (dllexport) SMS_STATUS SmsOpenContainer(
  1451.                                 DWORD cType,
  1452.                                 HANDLE hConnection,
  1453.                                 HANDLE *phContainer );
  1454. __declspec (dllexport) SMS_STATUS SmsSetFilter(
  1455.                                 HANDLE hContainer,
  1456.                                 HANDLE hFilter );
  1457. __declspec (dllexport) SMS_STATUS SmsPopulate(
  1458.                                 HANDLE hContainer,
  1459.                                 DWORD dwOptions,
  1460.                                 NOTIFY *pNotify );
  1461. __declspec (dllexport) SMS_STATUS SmsGetNextFolder(
  1462.                                 HANDLE hParent,
  1463.                                 DWORD fType,
  1464.                                 HANDLE *phFolder );
  1465. __declspec (dllexport) SMS_STATUS SmsCloseContainer(
  1466.                                 HANDLE hContainer );
  1467. // ====================================================================
  1468. //  Folder (collection) APIs.
  1469. //  A collection contains other things, that is it can have embedded
  1470. //  collections and it can also have properties (scalars).
  1471. // ====================================================================
  1472. __declspec (dllexport) SMS_STATUS SmsCreateFolder(
  1473.                                 HANDLE hParent,
  1474.                                 DWORD fType,
  1475.                                 const char *pszFolderID,
  1476.                                 HANDLE *phFolder );
  1477. __declspec (dllexport) SMS_STATUS SmsGetFolderID(
  1478.                                 HANDLE hFolder,
  1479.                                 char *pszFolderID );
  1480. __declspec (dllexport) SMS_STATUS SmsGetFolderType(
  1481.                                 HANDLE hFolder,
  1482.                                 DWORD *pfType,
  1483.                                 char *pszfType );
  1484. __declspec (dllexport) SMS_STATUS SmsEnumFolderTypes(
  1485.                                 HANDLE hFolder,
  1486.                                 DWORD *pfTypes,
  1487.                                 DWORD *pctFolderTypes );
  1488. __declspec (dllexport) SMS_STATUS SmsGetFolderCount(
  1489.                                 HANDLE hFolder,
  1490.                                 DWORD fType,
  1491.                                 DWORD *pctFolders );
  1492. __declspec (dllexport) SMS_STATUS SmsGetFolderByID(
  1493.                                 HANDLE hFolder,
  1494.                                 DWORD fType,
  1495.                                 char *pszFolderID,
  1496.                                 HANDLE *phSubFolder );
  1497. __declspec (dllexport) SMS_STATUS SmsRewind(
  1498.                                 HANDLE hObject,
  1499.                                 DWORD dwOptions );
  1500. __declspec (dllexport) SMS_STATUS SmsCloseFolder(
  1501.                                 HANDLE hFolder );
  1502. __declspec (dllexport) SMS_STATUS SmsLinkFolder(
  1503.                                 HANDLE hFolder );
  1504. __declspec (dllexport) SMS_STATUS SmsUnlinkFolder(
  1505.                                 HANDLE hFolder );
  1506. __declspec (dllexport) SMS_STATUS SmsCommitFolder(
  1507.                                 HANDLE hFolder );
  1508. __declspec (dllexport) SMS_STATUS SmsDupFolder(
  1509.                                 HANDLE hParent,
  1510.                                 HANDLE hFolder,
  1511.                                 HANDLE *phNewFolder );
  1512. // ====================================================================
  1513. //  Scalar APIs.
  1514. // ====================================================================
  1515. __declspec (dllexport) SMS_STATUS SmsGetScalarCount(
  1516.                                 HANDLE hFolder,
  1517.                                 DWORD *pctScalars );
  1518. __declspec (dllexport) SMS_STATUS SmsGetNextScalar(
  1519.                                 HANDLE hFolder,
  1520.                                 SCALAR *pScalarStruct );
  1521. __declspec (dllexport) SMS_STATUS SmsGetScalarByName(
  1522.                                 HANDLE hFolder,
  1523.                                 const char *pszName,
  1524.                                 SCALAR *pScalarStruct );
  1525. __declspec (dllexport) SMS_STATUS SmsSetScalar(
  1526.                                 HANDLE hFolder,
  1527.                                 SCALAR *pScalarStruct );
  1528. // ====================================================================
  1529. //
  1530. //  FilterContainer APIs
  1531. //
  1532. // ====================================================================
  1533. __declspec (dllexport) SMS_STATUS SmsOpenFilterContainer(
  1534.                                 HANDLE hConnection,
  1535.                                 HANDLE *phFContainer );
  1536. __declspec (dllexport) SMS_STATUS SmsCloseFilterContainer(
  1537.                                 HANDLE hFContainer );
  1538. __declspec (dllexport) SMS_STATUS SmsGetNextFilter(
  1539.                                 HANDLE hFContainer,
  1540.                                 DWORD frType,
  1541.                                 HANDLE *phFilter );
  1542. __declspec (dllexport) SMS_STATUS SmsGetFilterByID(
  1543.                                 HANDLE hFContainer,
  1544.                                 DWORD frType,
  1545.                                 const char *pszID,
  1546.                                 HANDLE *phFilter );
  1547. __declspec (dllexport) SMS_STATUS SmsGetFilterID(
  1548.                                 HANDLE hFilter,
  1549.                                 char *pszID );
  1550. __declspec (dllexport) SMS_STATUS SmsCommitFilter(
  1551.                                 HANDLE hFilter,
  1552.                                 HANDLE hFContainer );
  1553. // ====================================================================
  1554. //
  1555. //  Filter APIs
  1556. //
  1557. // ====================================================================
  1558. __declspec (dllexport) SMS_STATUS SmsCreateFilter(
  1559.                                 DWORD frType,
  1560.                                 HANDLE hConnection,
  1561.                                 HANDLE *phFilter );
  1562. __declspec (dllexport) SMS_STATUS SmsCloseFilter(
  1563.                                 HANDLE hFilter );
  1564. __declspec (dllexport) SMS_STATUS SmsGetFilterType(
  1565.                                 HANDLE hFilter,
  1566.                                 DWORD *pfilterType,
  1567.                                 char *pszTag );
  1568. __declspec (dllexport) SMS_STATUS SmsGetToken(
  1569.                                 HANDLE hObject,
  1570.                                 INT iIndex,
  1571.                                 TOKEN *pTokenInfo);
  1572. __declspec (dllexport) SMS_STATUS SmsAddToken(
  1573.                                 HANDLE hObject,
  1574.                                 ANDOR opAndOr,
  1575.                                 TOKEN *pTokenInfo,
  1576.                                 INT iIndex );
  1577. __declspec (dllexport) SMS_STATUS SmsGetTokenCount(
  1578.                                 HANDLE hObject,
  1579.                                 DWORD *pctTokens );
  1580. __declspec (dllexport) SMS_STATUS SmsManipulateTokens(
  1581.                                 HANDLE hObject,
  1582.                                 DWORD dwFlags,
  1583.                                 INT iStart,
  1584.                                 INT iEnd );
  1585. __declspec (dllexport) SMS_STATUS SmsGetAllFilters(
  1586.                                 HANDLE hContainer,
  1587.                                 HANDLE *pahFilters,
  1588.                                 DWORD *pctFilters );
  1589. __declspec (dllexport) SMS_STATUS SmsEnumObjectTypes(
  1590.                                 HANDLE hConnection,
  1591.                                 SMSBUFF *pObjects,
  1592.                                 DWORD *pCtObjects );
  1593. __declspec (dllexport) SMS_STATUS SmsEnumObjects(
  1594.                                 HANDLE hConn,
  1595.                                 char *pszObjectType,
  1596.                                 SMSBUFF *pPredecessors,
  1597.                                 DWORD ctPredecessors,
  1598.                                 OBJDESCRIPTOR *pObjects,
  1599.                                 DWORD *pCtObjects );
  1600. #ifdef __cplusplus
  1601. }
  1602. #endif
  1603. #endif  // _SMSAPI_H_
  1604. /* EOF: smsapi.h */