NameRegistry.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:20k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       NameRegistry.h
  3.  
  4.      Contains:   NameRegistry Interfaces
  5.  
  6.      Version:    Technology: MacOS
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1993-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __NAMEREGISTRY__
  18. #define __NAMEREGISTRY__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #if PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #if PRAGMA_IMPORT
  29. #pragma import on
  30. #endif
  31. #if PRAGMA_STRUCT_ALIGN
  32.     #pragma options align=power
  33. #elif PRAGMA_STRUCT_PACKPUSH
  34.     #pragma pack(push, 2)
  35. #elif PRAGMA_STRUCT_PACK
  36.     #pragma pack(2)
  37. #endif
  38. /*******************************************************************************
  39.  * 
  40.  * Foundation Types
  41.  *
  42.  */
  43. /* Value of a property */
  44. typedef void *                          RegPropertyValue;
  45. /* Length of property value */
  46. typedef UInt32                          RegPropertyValueSize;
  47. /*******************************************************************************
  48.  * 
  49.  * RegEntryID   :   The Global x-Namespace Entry Identifier
  50.  *
  51.  */
  52. struct RegEntryID {
  53.     UInt32                          contents[4];
  54. };
  55. typedef struct RegEntryID               RegEntryID;
  56. typedef RegEntryID *                    RegEntryIDPtr;
  57. /*******************************************************************************
  58.  *
  59.  * Root Entry Name Definitions  (Applies to all Names in the RootNameSpace)
  60.  *
  61.  *  o Names are a colon-separated list of name components.  Name components
  62.  *    may not themselves contain colons.  
  63.  *  o Names are presented as null-terminated ASCII character strings.
  64.  *  o Names follow similar parsing rules to Apple file system absolute
  65.  *    and relative paths.  However the '::' parent directory syntax is
  66.  *    not currently supported.
  67.  */
  68. /* Max length of Entry Name */
  69. enum {
  70.     kRegCStrMaxEntryNameLength  = 47
  71. };
  72. /* Entry Names are single byte ASCII */
  73. typedef char                            RegCStrEntryName;
  74. typedef char *                          RegCStrEntryNamePtr;
  75. /* length of RegCStrEntryNameBuf =  kRegCStrMaxEntryNameLength+1*/
  76. typedef char                            RegCStrEntryNameBuf[48];
  77. typedef char                            RegCStrPathName;
  78. typedef UInt32                          RegPathNameSize;
  79. enum {
  80.     kRegPathNameSeparator       = ':',                          /* 0x3A */
  81.     kRegEntryNameTerminator     = 0x00,                         /* '' */
  82.     kRegPathNameTerminator      = 0x00                          /* '' */
  83. };
  84. /*******************************************************************************
  85.  *
  86.  * Property Name and ID Definitions
  87.  *  (Applies to all Properties Regardless of NameSpace)
  88.  */
  89. enum {
  90.     kRegMaximumPropertyNameLength = 31,                         /* Max length of Property Name */
  91.     kRegPropertyNameTerminator  = 0x00                          /* '' */
  92. };
  93. typedef char                            RegPropertyNameBuf[32];
  94. typedef char                            RegPropertyName;
  95. typedef char *                          RegPropertyNamePtr;
  96. /*******************************************************************************
  97.  *
  98.  * Iteration Operations
  99.  *
  100.  *  These specify direction when traversing the name relationships
  101.  */
  102. typedef UInt32                          RegIterationOp;
  103. typedef RegIterationOp                  RegEntryIterationOp;
  104. enum {
  105.                                                                 /* Absolute locations*/
  106.     kRegIterRoot                = 0x00000002,                   /* "Upward" Relationships */
  107.     kRegIterParents             = 0x00000003,                   /* include all  parent(s) of entry */
  108.                                                                 /* "Downward" Relationships*/
  109.     kRegIterChildren            = 0x00000004,                   /* include all children */
  110.     kRegIterSubTrees            = 0x00000005,                   /* include all sub trees of entry */
  111.     kRegIterDescendants         = 0x00000005,                   /* include all descendants of entry */
  112.                                                                 /* "Horizontal" Relationships */
  113.     kRegIterSibling             = 0x00000006,                   /* include all siblings */
  114.                                                                 /* Keep doing the same thing*/
  115.     kRegIterContinue            = 0x00000001
  116. };
  117. /*******************************************************************************
  118.  *
  119.  * Name Entry and Property Modifiers
  120.  *
  121.  *
  122.  *
  123.  * Modifiers describe special characteristics of names
  124.  * and properties.  Modifiers might be supported for
  125.  * some names and not others.
  126.  * 
  127.  * Device Drivers should not rely on functionality
  128.  * specified as a modifier.
  129.  */
  130. typedef UInt32                          RegModifiers;
  131. typedef RegModifiers                    RegEntryModifiers;
  132. typedef RegModifiers                    RegPropertyModifiers;
  133. enum {
  134.     kRegNoModifiers             = 0x00000000,                   /* no entry modifiers in place */
  135.     kRegUniversalModifierMask   = 0x0000FFFF,                   /* mods to all entries */
  136.     kRegNameSpaceModifierMask   = 0x00FF0000,                   /* mods to all entries within namespace */
  137.     kRegModifierMask            = (long)0xFF000000              /* mods to just this entry */
  138. };
  139. /* Universal Property Modifiers */
  140. enum {
  141.     kRegPropertyValueIsSavedToNVRAM = 0x00000020,               /* property is non-volatile (saved in NVRAM) */
  142.     kRegPropertyValueIsSavedToDisk = 0x00000040                 /* property is non-volatile (saved on disk) */
  143. };
  144. /* NameRegistry version, Gestalt/PEF-style -- MUST BE KEPT IN SYNC WITH MAKEFILE !! */
  145. enum {
  146.     LatestNR_PEFVersion         = 0x01030000                    /* latest NameRegistryLib version (Gestalt/PEF-style) */
  147. };
  148. /* ///////////////////////
  149. //
  150. // The Registry API
  151. //
  152. /////////////////////// */
  153. /* NameRegistry dispatch indexes */
  154. enum {
  155.     kSelectRegistryEntryIDInit  = 0,
  156.     kSelectRegistryEntryIDCompare = 1,
  157.     kSelectRegistryEntryIDCopy  = 2,
  158.     kSelectRegistryEntryIDDispose = 3,
  159.     kSelectRegistryCStrEntryCreate = 4,
  160.     kSelectRegistryEntryDelete  = 5,
  161.     kSelectRegistryEntryCopy    = 6,
  162.     kSelectRegistryEntryIterateCreate = 7,
  163.     kSelectRegistryEntryIterateDispose = 8,
  164.     kSelectRegistryEntryIterateSet = 9,
  165.     kSelectRegistryEntryIterate = 10,
  166.     kSelectRegistryEntrySearch  = 11,
  167.     kSelectRegistryCStrEntryLookup = 12,
  168.     kSelectRegistryEntryToPathSize = 13,
  169.     kSelectRegistryCStrEntryToPath = 14,
  170.     kSelectRegistryCStrEntryToName = 15,
  171.     kSelectRegistryPropertyCreate = 16,
  172.     kSelectRegistryPropertyDelete = 17,
  173.     kSelectRegistryPropertyRename = 18,
  174.     kSelectRegistryPropertyIterateCreate = 19,
  175.     kSelectRegistryPropertyIterateDispose = 20,
  176.     kSelectRegistryPropertyIterate = 21,
  177.     kSelectRegistryPropertyGetSize = 22,
  178.     kSelectRegistryPropertyGet  = 23,
  179.     kSelectRegistryPropertySet  = 24,
  180.     kSelectRegistryEntryGetMod  = 25,
  181.     kSelectRegistryEntrySetMod  = 26,
  182.     kSelectRegistryPropertyGetMod = 27,
  183.     kSelectRegistryPropertySetMod = 28,
  184.     kSelectRegistryEntryMod     = 29,
  185.     kSelectRegistryEntryPropertyMod = 30,                       /* if you add more selectors here, remember to change 'kSelectRegistryHighestSelector' below*/
  186.     kSelectRegistryHighestSelector = kSelectRegistryEntryPropertyMod
  187. };
  188. /* ///////////////////////
  189. //
  190. // Entry Management
  191. //
  192. /////////////////////// */
  193. /*-------------------------------
  194.  * EntryID handling
  195.  */
  196. /*
  197.  * Initialize an EntryID to a known invalid state
  198.  *   note: invalid != uninitialized
  199.  */
  200. #if CALL_NOT_IN_CARBON
  201. EXTERN_API_C( OSStatus )
  202. RegistryEntryIDInit             (RegEntryID *           id)                                 TWOWORDINLINE(0x7000, 0xABE9);
  203. /*
  204.  * Compare EntryID's for equality or if invalid
  205.  *
  206.  * If a NULL value is given for either id1 or id2, the other id 
  207.  * is compared with an invalid ID.  If both are NULL, the id's 
  208.  * are consided equal (result = true). 
  209.  */
  210. EXTERN_API_C( Boolean )
  211. RegistryEntryIDCompare          (const RegEntryID *     id1,
  212.                                  const RegEntryID *     id2)                                TWOWORDINLINE(0x7001, 0xABE9);
  213. /*
  214.  * Copy an EntryID
  215.  */
  216. EXTERN_API_C( OSStatus )
  217. RegistryEntryIDCopy             (const RegEntryID *     src,
  218.                                  RegEntryID *           dst)                                TWOWORDINLINE(0x7002, 0xABE9);
  219. /*
  220.  * Free an ID so it can be reused.
  221.  */
  222. EXTERN_API_C( OSStatus )
  223. RegistryEntryIDDispose          (RegEntryID *           id)                                 TWOWORDINLINE(0x7003, 0xABE9);
  224. /*-------------------------------
  225.  * Adding and removing entries
  226.  *
  227.  * If (parentEntry) is NULL, the name is assumed
  228.  * to be a rooted path. It is rooted to an anonymous, unnamed root.
  229.  */
  230. EXTERN_API_C( OSStatus )
  231. RegistryCStrEntryCreate         (const RegEntryID *     parentEntry,
  232.                                  const RegCStrPathName * name,
  233.                                  RegEntryID *           newEntry)                           TWOWORDINLINE(0x7004, 0xABE9);
  234. EXTERN_API_C( OSStatus )
  235. RegistryEntryDelete             (const RegEntryID *     id)                                 TWOWORDINLINE(0x7005, 0xABE9);
  236. EXTERN_API_C( OSStatus )
  237. RegistryEntryCopy               (RegEntryID *           parentEntryID,
  238.                                  RegEntryID *           sourceDevice,
  239.                                  RegEntryID *           destDevice)                         TWOWORDINLINE(0x7006, 0xABE9);
  240. /*---------------------------
  241.  * Traversing the namespace
  242.  *
  243.  * To support arbitrary namespace implementations in the future,
  244.  * I have hidden the form that the place pointer takes.  The previous
  245.  * interface exposed the place pointer by specifying it as a
  246.  * RegEntryID.
  247.  *
  248.  * I have also removed any notion of returning the entries
  249.  * in a particular order, because an implementation might
  250.  * return the names in semi-random order.  Many name service
  251.  * implementations will store the names in a hashed lookup
  252.  * table.
  253.  *
  254.  * Writing code to traverse some set of names consists of
  255.  * a call to begin the iteration, the iteration loop, and
  256.  * a call to end the iteration.  The begin call initializes
  257.  * the iteration cookie data structure.  The call to end the 
  258.  * iteration should be called even in the case of error so 
  259.  * that allocated data structures can be freed.
  260.  *
  261.  *  Create(...)
  262.  *  do {
  263.  *      Iterate(...);
  264.  *  } while (!done);
  265.  *  Dispose(...);
  266.  *
  267.  * This is the basic code structure for callers of the iteration
  268.  * interface.
  269.  */
  270. #endif  /* CALL_NOT_IN_CARBON */
  271. typedef struct OpaqueRegEntryIter*      RegEntryIter;
  272. /* 
  273.  * create/dispose the iterator structure
  274.  *   defaults to root with relationship = kRegIterDescendants
  275.  */
  276. #if CALL_NOT_IN_CARBON
  277. EXTERN_API_C( OSStatus )
  278. RegistryEntryIterateCreate      (RegEntryIter *         cookie)                             TWOWORDINLINE(0x7007, 0xABE9);
  279. EXTERN_API_C( OSStatus )
  280. RegistryEntryIterateDispose     (RegEntryIter *         cookie)                             TWOWORDINLINE(0x7008, 0xABE9);
  281. /* 
  282.  * set Entry Iterator to specified entry
  283.  */
  284. EXTERN_API_C( OSStatus )
  285. RegistryEntryIterateSet         (RegEntryIter *         cookie,
  286.                                  const RegEntryID *     startEntryID)                       TWOWORDINLINE(0x7009, 0xABE9);
  287. /*
  288.  * Return each value of the iteration
  289.  *
  290.  * return entries related to the current entry
  291.  * with the specified relationship
  292.  */
  293. EXTERN_API_C( OSStatus )
  294. RegistryEntryIterate            (RegEntryIter *         cookie,
  295.                                  RegEntryIterationOp    relationship,
  296.                                  RegEntryID *           foundEntry,
  297.                                  Boolean *              done)                               TWOWORDINLINE(0x700A, 0xABE9);
  298. /*
  299.  * return entries with the specified property
  300.  *
  301.  * A NULL RegPropertyValue pointer will return an
  302.  * entry with the property containing any value.
  303.  */
  304. EXTERN_API_C( OSStatus )
  305. RegistryEntrySearch             (RegEntryIter *         cookie,
  306.                                  RegEntryIterationOp    relationship,
  307.                                  RegEntryID *           foundEntry,
  308.                                  Boolean *              done,
  309.                                  const RegPropertyName * propertyName,
  310.                                  const void *           propertyValue,
  311.                                  RegPropertyValueSize   propertySize)                       TWOWORDINLINE(0x700B, 0xABE9);
  312. /*--------------------------------
  313.  * Find a name in the namespace
  314.  *
  315.  * This is the fast lookup mechanism.
  316.  * NOTE:  A reverse lookup mechanism
  317.  *    has not been provided because
  318.  *        some name services may not
  319.  *        provide a fast, general reverse
  320.  *        lookup.
  321.  */
  322. EXTERN_API_C( OSStatus )
  323. RegistryCStrEntryLookup         (const RegEntryID *     searchPointID,
  324.                                  const RegCStrPathName * pathName,
  325.                                  RegEntryID *           foundEntry)                         TWOWORDINLINE(0x700C, 0xABE9);
  326. /*---------------------------------------------
  327.  * Convert an entry to a rooted name string
  328.  *
  329.  * A utility routine to turn an Entry ID
  330.  * back into a name string.
  331.  */
  332. EXTERN_API_C( OSStatus )
  333. RegistryEntryToPathSize         (const RegEntryID *     entryID,
  334.                                  RegPathNameSize *      pathSize)                           TWOWORDINLINE(0x700D, 0xABE9);
  335. EXTERN_API_C( OSStatus )
  336. RegistryCStrEntryToPath         (const RegEntryID *     entryID,
  337.                                  RegCStrPathName *      pathName,
  338.                                  RegPathNameSize        pathSize)                           TWOWORDINLINE(0x700E, 0xABE9);
  339. /*
  340.  * Parse a path name.
  341.  *
  342.  * Retrieve the last component of the path, and
  343.  * return a spec for the parent.
  344.  */
  345. EXTERN_API_C( OSStatus )
  346. RegistryCStrEntryToName         (const RegEntryID *     entryID,
  347.                                  RegEntryID *           parentEntry,
  348.                                  RegCStrEntryName *     nameComponent,
  349.                                  Boolean *              done)                               TWOWORDINLINE(0x700F, 0xABE9);
  350. /* //////////////////////////////////////////////////////
  351. //
  352. // Property Management
  353. //
  354. ////////////////////////////////////////////////////// */
  355. /*-------------------------------
  356.  * Adding and removing properties
  357.  */
  358. EXTERN_API_C( OSStatus )
  359. RegistryPropertyCreate          (const RegEntryID *     entryID,
  360.                                  const RegPropertyName * propertyName,
  361.                                  const void *           propertyValue,
  362.                                  RegPropertyValueSize   propertySize)                       TWOWORDINLINE(0x7010, 0xABE9);
  363. EXTERN_API_C( OSStatus )
  364. RegistryPropertyDelete          (const RegEntryID *     entryID,
  365.                                  const RegPropertyName * propertyName)                      TWOWORDINLINE(0x7011, 0xABE9);
  366. EXTERN_API_C( OSStatus )
  367. RegistryPropertyRename          (const RegEntryID *     entry,
  368.                                  const RegPropertyName * oldName,
  369.                                  const RegPropertyName * newName)                           TWOWORDINLINE(0x7012, 0xABE9);
  370. /*---------------------------
  371.  * Traversing the Properties of a name
  372.  *
  373.  */
  374. #endif  /* CALL_NOT_IN_CARBON */
  375. typedef struct OpaqueRegPropertyIter*   RegPropertyIter;
  376. #if CALL_NOT_IN_CARBON
  377. EXTERN_API_C( OSStatus )
  378. RegistryPropertyIterateCreate   (const RegEntryID *     entry,
  379.                                  RegPropertyIter *      cookie)                             TWOWORDINLINE(0x7013, 0xABE9);
  380. EXTERN_API_C( OSStatus )
  381. RegistryPropertyIterateDispose  (RegPropertyIter *      cookie)                             TWOWORDINLINE(0x7014, 0xABE9);
  382. EXTERN_API_C( OSStatus )
  383. RegistryPropertyIterate         (RegPropertyIter *      cookie,
  384.                                  RegPropertyName *      foundProperty,
  385.                                  Boolean *              done)                               TWOWORDINLINE(0x7015, 0xABE9);
  386. /*
  387.  * Get the value of the specified property for the specified entry.
  388.  *
  389.  */
  390. EXTERN_API_C( OSStatus )
  391. RegistryPropertyGetSize         (const RegEntryID *     entryID,
  392.                                  const RegPropertyName * propertyName,
  393.                                  RegPropertyValueSize * propertySize)                       TWOWORDINLINE(0x7016, 0xABE9);
  394. /*
  395.  * (*propertySize) is the maximum size of the value returned in the buffer
  396.  * pointed to by (propertyValue).  Upon return, (*propertySize) is the size of the
  397.  * value returned.
  398.  */
  399. EXTERN_API_C( OSStatus )
  400. RegistryPropertyGet             (const RegEntryID *     entryID,
  401.                                  const RegPropertyName * propertyName,
  402.                                  void *                 propertyValue,
  403.                                  RegPropertyValueSize * propertySize)                       TWOWORDINLINE(0x7017, 0xABE9);
  404. EXTERN_API_C( OSStatus )
  405. RegistryPropertySet             (const RegEntryID *     entryID,
  406.                                  const RegPropertyName * propertyName,
  407.                                  const void *           propertyValue,
  408.                                  RegPropertyValueSize   propertySize)                       TWOWORDINLINE(0x7018, 0xABE9);
  409. /* //////////////////////////////////////////////////////
  410. //
  411. // Modifier Management
  412. //
  413. ////////////////////////////////////////////////////// */
  414. /*
  415.  * Modifiers describe special characteristics of names
  416.  * and properties.  Modifiers might be supported for
  417.  * some names and not others.
  418.  * 
  419.  * Device Drivers should not rely on functionality
  420.  * specified as a modifier.  These interfaces
  421.  * are for use in writing Experts.
  422.  */
  423. /*
  424.  * Get and Set operators for entry modifiers
  425.  */
  426. EXTERN_API_C( OSStatus )
  427. RegistryEntryGetMod             (const RegEntryID *     entry,
  428.                                  RegEntryModifiers *    modifiers)                          TWOWORDINLINE(0x7019, 0xABE9);
  429. EXTERN_API_C( OSStatus )
  430. RegistryEntrySetMod             (const RegEntryID *     entry,
  431.                                  RegEntryModifiers      modifiers)                          TWOWORDINLINE(0x701A, 0xABE9);
  432. /*
  433.  * Get and Set operators for property modifiers
  434.  */
  435. EXTERN_API_C( OSStatus )
  436. RegistryPropertyGetMod          (const RegEntryID *     entry,
  437.                                  const RegPropertyName * name,
  438.                                  RegPropertyModifiers * modifiers)                          TWOWORDINLINE(0x701B, 0xABE9);
  439. EXTERN_API_C( OSStatus )
  440. RegistryPropertySetMod          (const RegEntryID *     entry,
  441.                                  const RegPropertyName * name,
  442.                                  RegPropertyModifiers   modifiers)                          TWOWORDINLINE(0x701C, 0xABE9);
  443. /*
  444.  * Iterator operator for entry modifier search
  445.  */
  446. EXTERN_API_C( OSStatus )
  447. RegistryEntryMod                (RegEntryIter *         cookie,
  448.                                  RegEntryIterationOp    relationship,
  449.                                  RegEntryID *           foundEntry,
  450.                                  Boolean *              done,
  451.                                  RegEntryModifiers      matchingModifiers)                  TWOWORDINLINE(0x701D, 0xABE9);
  452. /*
  453.  * Iterator operator for entries with matching 
  454.  * property modifiers
  455.  */
  456. EXTERN_API_C( OSStatus )
  457. RegistryEntryPropertyMod        (RegEntryIter *         cookie,
  458.                                  RegEntryIterationOp    relationship,
  459.                                  RegEntryID *           foundEntry,
  460.                                  Boolean *              done,
  461.                                  RegPropertyModifiers   matchingModifiers)                  TWOWORDINLINE(0x701E, 0xABE9);
  462. #endif  /* CALL_NOT_IN_CARBON */
  463. #if PRAGMA_STRUCT_ALIGN
  464.     #pragma options align=reset
  465. #elif PRAGMA_STRUCT_PACKPUSH
  466.     #pragma pack(pop)
  467. #elif PRAGMA_STRUCT_PACK
  468.     #pragma pack()
  469. #endif
  470. #ifdef PRAGMA_IMPORT_OFF
  471. #pragma import off
  472. #elif PRAGMA_IMPORT
  473. #pragma import reset
  474. #endif
  475. #ifdef __cplusplus
  476. }
  477. #endif
  478. #endif /* __NAMEREGISTRY__ */