home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / smsapi.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  75KB  |  1,772 lines

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