Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1022 lines
34 KiB

  1. /*
  2. File: NSLCore.h
  3. Contains: Interface to API for using the NSL Manager
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 2000-2001 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __NSLCORE__
  11. #define __NSLCORE__
  12. #ifndef __CODEFRAGMENTS__
  13. #include <CodeFragments.h>
  14. #endif
  15. #ifndef __FILES__
  16. #include <Files.h>
  17. #endif
  18. #ifndef __THREADS__
  19. #include <Threads.h>
  20. #endif
  21. #if PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #if PRAGMA_IMPORT
  28. #pragma import on
  29. #endif
  30. #if PRAGMA_STRUCT_ALIGN
  31. #pragma options align=mac68k
  32. #elif PRAGMA_STRUCT_PACKPUSH
  33. #pragma pack(push, 2)
  34. #elif PRAGMA_STRUCT_PACK
  35. #pragma pack(2)
  36. #endif
  37. enum {
  38. kNSLMinSystemVersion = 0x0900, /* equivalent to 9.0*/
  39. kNSLMinOTVersion = 0x0130 /* equivalent to 1.3*/
  40. };
  41. enum {
  42. kNSLDefaultListSize = 256 /* default list size for service and protocol lists*/
  43. };
  44. enum {
  45. kNSLURLDelimiter = ',' /* delimits URL's within memory buffers*/
  46. };
  47. #define kNSLErrorNoErr {noErr, kNSLNoContext} /* an initializer for the NSLError struct */
  48. enum {
  49. kNSLNoContext = 0 /* the default context for NSLError structs*/
  50. };
  51. struct NSLError {
  52. OSStatus theErr;
  53. UInt32 theContext;
  54. };
  55. typedef struct NSLError NSLError;
  56. typedef NSLError * NSLErrorPtr;
  57. enum {
  58. /* Constants to use with NSLPrepareRequest*/
  59. /* kNSLDuplicateSearchInProgress is not strictly an error. The client is free to ignore*/
  60. /* this result, and nothing bad will happen if it does. It is*/
  61. /* informational only.*/
  62. kNSLDuplicateSearchInProgress = 100,
  63. kNSLUserCanceled = userCanceledErr, /* User hit cancel from the NSLStandardGetURL dialog */
  64. /* Invalid enumeratorRef */
  65. kNSLInvalidEnumeratorRef = 0 /* this is not an error; it is the equiv to a NULL ptr*/
  66. };
  67. typedef UInt16 NSLSearchState;
  68. enum {
  69. /* State codes for notifiers.*/
  70. kNSLSearchStateBufferFull = 1,
  71. kNSLSearchStateOnGoing = 2,
  72. kNSLSearchStateComplete = 3,
  73. kNSLSearchStateStalled = 4,
  74. kNSLWaitingForContinue = 5
  75. };
  76. typedef UInt32 NSLEventCode;
  77. enum {
  78. /* Event codes*/
  79. kNSLServicesLookupDataEvent = 6,
  80. kNSLNeighborhoodLookupDataEvent = 7,
  81. kNSLNewDataEvent = 8,
  82. kNSLContinueLookupEvent = 9
  83. };
  84. typedef UInt32 NSLClientRef;
  85. typedef UInt32 NSLRequestRef;
  86. typedef UInt32 NSLOneBasedIndex;
  87. typedef char * NSLPath;
  88. typedef char * NSLServiceType;
  89. typedef Handle NSLServicesList;
  90. typedef unsigned char * NSLNeighborhood;
  91. /*
  92. cstring which is a comma delimited list of protocols which can be used to
  93. create a NSLProtocolList internally
  94. */
  95. /* the async information block for client<->manager interaction*/
  96. struct NSLClientAsyncInfo {
  97. void * clientContextPtr; /* set by the client for its own use*/
  98. void * mgrContextPtr; /* set by NSL mgr; ptr to request object ptr*/
  99. char * resultBuffer;
  100. long bufferLen;
  101. long maxBufferSize;
  102. UInt32 startTime; /* when the search starts, to use with maxSearchTime to determine time-out condition*/
  103. UInt32 intStartTime; /* used with alertInterval*/
  104. UInt32 maxSearchTime; /* total time for search, in ticks (0 == no time limit)*/
  105. UInt32 alertInterval; /* call client's notifier or return, every this many ticks ( 0 == don't use this param)*/
  106. UInt32 totalItems; /* total number of tuples currently in buffer*/
  107. UInt32 alertThreshold; /* call client's notifier or return, every this many items found ( 0 == don't use this param)*/
  108. NSLSearchState searchState;
  109. NSLError searchResult;
  110. NSLEventCode searchDataType; /* this is a data type code which allows the client's asyncNotifier to properly*/
  111. /* handle the data in resultBuffer.*/
  112. };
  113. typedef struct NSLClientAsyncInfo NSLClientAsyncInfo;
  114. typedef NSLClientAsyncInfo * NSLClientAsyncInfoPtr;
  115. /* the async information block plugin<->manager interaction*/
  116. struct NSLPluginAsyncInfo {
  117. void * mgrContextPtr; /* set by NSL mgr; ptr to request object ptr*/
  118. void * pluginContextPtr; /* set/used by individual plugins*/
  119. void * pluginPtr; /* ptr to the plugin object waiting for continue lookup call*/
  120. char * resultBuffer; /* set by plugin to point at data*/
  121. long bufferLen;
  122. long maxBufferSize;
  123. UInt32 maxSearchTime; /* total time for search, in ticks (0 == no time limit)*/
  124. UInt32 reserved1;
  125. UInt32 reserved2;
  126. UInt32 reserved3;
  127. NSLClientRef clientRef;
  128. NSLRequestRef requestRef;
  129. NSLSearchState searchState;
  130. OSStatus searchResult;
  131. };
  132. typedef struct NSLPluginAsyncInfo NSLPluginAsyncInfo;
  133. typedef NSLPluginAsyncInfo * NSLPluginAsyncInfoPtr;
  134. /* the manager asynchronous notifier routine.*/
  135. typedef CALLBACK_API( void , NSLMgrNotifyProcPtr )(NSLPluginAsyncInfo * thePluginAsyncInfo);
  136. /* the client asynchronous notifier routine.*/
  137. typedef CALLBACK_API( void , NSLClientNotifyProcPtr )(NSLClientAsyncInfo * theClientAsyncInfo);
  138. typedef STACK_UPP_TYPE(NSLMgrNotifyProcPtr) NSLMgrNotifyUPP;
  139. typedef STACK_UPP_TYPE(NSLClientNotifyProcPtr) NSLClientNotifyUPP;
  140. /*
  141. * NewNSLMgrNotifyUPP()
  142. *
  143. * Availability:
  144. * Non-Carbon CFM: available as macro/inline
  145. * CarbonLib: in CarbonLib 1.0 and later
  146. * Mac OS X: in version 10.0 and later
  147. */
  148. EXTERN_API_C( NSLMgrNotifyUPP )
  149. NewNSLMgrNotifyUPP(NSLMgrNotifyProcPtr userRoutine);
  150. #if !OPAQUE_UPP_TYPES
  151. enum { uppNSLMgrNotifyProcInfo = 0x000000C0 }; /* pascal no_return_value Func(4_bytes) */
  152. #ifdef __cplusplus
  153. inline DEFINE_API_C(NSLMgrNotifyUPP) NewNSLMgrNotifyUPP(NSLMgrNotifyProcPtr userRoutine) { return (NSLMgrNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLMgrNotifyProcInfo, GetCurrentArchitecture()); }
  154. #else
  155. #define NewNSLMgrNotifyUPP(userRoutine) (NSLMgrNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLMgrNotifyProcInfo, GetCurrentArchitecture())
  156. #endif
  157. #endif
  158. /*
  159. * NewNSLClientNotifyUPP()
  160. *
  161. * Availability:
  162. * Non-Carbon CFM: available as macro/inline
  163. * CarbonLib: in CarbonLib 1.0 and later
  164. * Mac OS X: in version 10.0 and later
  165. */
  166. EXTERN_API_C( NSLClientNotifyUPP )
  167. NewNSLClientNotifyUPP(NSLClientNotifyProcPtr userRoutine);
  168. #if !OPAQUE_UPP_TYPES
  169. enum { uppNSLClientNotifyProcInfo = 0x000000C0 }; /* pascal no_return_value Func(4_bytes) */
  170. #ifdef __cplusplus
  171. inline DEFINE_API_C(NSLClientNotifyUPP) NewNSLClientNotifyUPP(NSLClientNotifyProcPtr userRoutine) { return (NSLClientNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLClientNotifyProcInfo, GetCurrentArchitecture()); }
  172. #else
  173. #define NewNSLClientNotifyUPP(userRoutine) (NSLClientNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLClientNotifyProcInfo, GetCurrentArchitecture())
  174. #endif
  175. #endif
  176. /*
  177. * DisposeNSLMgrNotifyUPP()
  178. *
  179. * Availability:
  180. * Non-Carbon CFM: available as macro/inline
  181. * CarbonLib: in CarbonLib 1.0 and later
  182. * Mac OS X: in version 10.0 and later
  183. */
  184. EXTERN_API_C( void )
  185. DisposeNSLMgrNotifyUPP(NSLMgrNotifyUPP userUPP);
  186. #if !OPAQUE_UPP_TYPES
  187. #ifdef __cplusplus
  188. inline DEFINE_API_C(void) DisposeNSLMgrNotifyUPP(NSLMgrNotifyUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  189. #else
  190. #define DisposeNSLMgrNotifyUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  191. #endif
  192. #endif
  193. /*
  194. * DisposeNSLClientNotifyUPP()
  195. *
  196. * Availability:
  197. * Non-Carbon CFM: available as macro/inline
  198. * CarbonLib: in CarbonLib 1.0 and later
  199. * Mac OS X: in version 10.0 and later
  200. */
  201. EXTERN_API_C( void )
  202. DisposeNSLClientNotifyUPP(NSLClientNotifyUPP userUPP);
  203. #if !OPAQUE_UPP_TYPES
  204. #ifdef __cplusplus
  205. inline DEFINE_API_C(void) DisposeNSLClientNotifyUPP(NSLClientNotifyUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  206. #else
  207. #define DisposeNSLClientNotifyUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  208. #endif
  209. #endif
  210. /*
  211. * InvokeNSLMgrNotifyUPP()
  212. *
  213. * Availability:
  214. * Non-Carbon CFM: available as macro/inline
  215. * CarbonLib: in CarbonLib 1.0 and later
  216. * Mac OS X: in version 10.0 and later
  217. */
  218. EXTERN_API_C( void )
  219. InvokeNSLMgrNotifyUPP(
  220. NSLPluginAsyncInfo * thePluginAsyncInfo,
  221. NSLMgrNotifyUPP userUPP);
  222. #if !OPAQUE_UPP_TYPES
  223. #ifdef __cplusplus
  224. inline DEFINE_API_C(void) InvokeNSLMgrNotifyUPP(NSLPluginAsyncInfo * thePluginAsyncInfo, NSLMgrNotifyUPP userUPP) { CALL_ONE_PARAMETER_UPP(userUPP, uppNSLMgrNotifyProcInfo, thePluginAsyncInfo); }
  225. #else
  226. #define InvokeNSLMgrNotifyUPP(thePluginAsyncInfo, userUPP) CALL_ONE_PARAMETER_UPP((userUPP), uppNSLMgrNotifyProcInfo, (thePluginAsyncInfo))
  227. #endif
  228. #endif
  229. /*
  230. * InvokeNSLClientNotifyUPP()
  231. *
  232. * Availability:
  233. * Non-Carbon CFM: available as macro/inline
  234. * CarbonLib: in CarbonLib 1.0 and later
  235. * Mac OS X: in version 10.0 and later
  236. */
  237. EXTERN_API_C( void )
  238. InvokeNSLClientNotifyUPP(
  239. NSLClientAsyncInfo * theClientAsyncInfo,
  240. NSLClientNotifyUPP userUPP);
  241. #if !OPAQUE_UPP_TYPES
  242. #ifdef __cplusplus
  243. inline DEFINE_API_C(void) InvokeNSLClientNotifyUPP(NSLClientAsyncInfo * theClientAsyncInfo, NSLClientNotifyUPP userUPP) { CALL_ONE_PARAMETER_UPP(userUPP, uppNSLClientNotifyProcInfo, theClientAsyncInfo); }
  244. #else
  245. #define InvokeNSLClientNotifyUPP(theClientAsyncInfo, userUPP) CALL_ONE_PARAMETER_UPP((userUPP), uppNSLClientNotifyProcInfo, (theClientAsyncInfo))
  246. #endif
  247. #endif
  248. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  249. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  250. #define NewNSLMgrNotifyProc(userRoutine) NewNSLMgrNotifyUPP(userRoutine)
  251. #define NewNSLClientNotifyProc(userRoutine) NewNSLClientNotifyUPP(userRoutine)
  252. #define CallNSLMgrNotifyProc(userRoutine, thePluginAsyncInfo) InvokeNSLMgrNotifyUPP(thePluginAsyncInfo, userRoutine)
  253. #define CallNSLClientNotifyProc(userRoutine, theClientAsyncInfo) InvokeNSLClientNotifyUPP(theClientAsyncInfo, userRoutine)
  254. #endif /* CALL_NOT_IN_CARBON */
  255. /*
  256. this struct is a format for dealing with our internal data representation. Typed data will be contiguous chunk of
  257. memory, with the first 4 bytes being a data "descriptor".
  258. */
  259. struct NSLTypedData {
  260. unsigned long dataType;
  261. unsigned long lengthOfData;
  262. /* void* theData; */
  263. };
  264. typedef struct NSLTypedData NSLTypedData;
  265. typedef NSLTypedData * NSLTypedDataPtr;
  266. #define kNSLDataType 'NSL_'
  267. /*
  268. This is just a header at the beginning of a handle that stores our list of service types.
  269. Each service type is a pascal string, so each service type starts after the end of the
  270. previous one.
  271. */
  272. struct NSLServicesListHeader {
  273. unsigned long numServices;
  274. unsigned long logicalLen; /* length of all usable data in handle*/
  275. /* Ptr firstService; */
  276. };
  277. typedef struct NSLServicesListHeader NSLServicesListHeader;
  278. typedef NSLServicesListHeader * NSLServicesListHeaderPtr;
  279. /* some defs for common protocols*/
  280. #define kSLPProtocolType "SLP"
  281. #define kDNSProtocolType "DNS"
  282. #define kLDAPProtocolType "LDAP"
  283. #define kNBPProtocolType "NBP"
  284. #define kNSLDirectoryServiceProtocolType "DirService"
  285. /*
  286. general information from a plug-in. Includes supported protocols, data types and services,
  287. as well as an info/comment string describing the function of the plug-in in human-readable
  288. form. The offsets point to the beginning of each list of data returned, and the protocol
  289. data offset is the startOfData member of the struct
  290. */
  291. struct NSLPluginData {
  292. long reserved1;
  293. long reserved2;
  294. long reserved3;
  295. Boolean supportsRegistration;
  296. Boolean isPurgeable;
  297. UInt16 totalLen; /* length of everything, including header*/
  298. UInt16 dataTypeOffset;
  299. UInt16 serviceListOffset;
  300. UInt16 protocolListOffset;
  301. UInt16 commentStringOffset;
  302. /* char* startOfData; */
  303. /* protocol data is first on the list*/
  304. };
  305. typedef struct NSLPluginData NSLPluginData;
  306. typedef NSLPluginData * NSLPluginDataPtr;
  307. /*
  308. -----------------------------------------------------------------------------
  309. Finding out if the library is present and getting its version
  310. -----------------------------------------------------------------------------
  311. */
  312. /*
  313. * NSLLibraryVersion()
  314. *
  315. * Availability:
  316. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  317. * CarbonLib: in CarbonLib 1.0 and later
  318. * Mac OS X: in version 10.0 and later
  319. */
  320. EXTERN_API( UInt32 )
  321. NSLLibraryVersion(void);
  322. #ifdef __cplusplus
  323. inline pascal Boolean NSLLibraryPresent() { return NSLLibraryVersion != (void*)kUnresolvedCFragSymbolAddress; }
  324. #else
  325. #define NSLLibraryPresent() ((NSLLibraryVersion != (void*)kUnresolvedCFragSymbolAddress))
  326. #endif
  327. /*
  328. -----------------------------------------------------------------------------
  329. High level API calls: the following two calls are ALL an application needs
  330. to register/deregister its service.
  331. If you use these, you don't need to make any of the other calls to NSLAPI
  332. (including NSLOpenNavigationAPI)
  333. -----------------------------------------------------------------------------
  334. */
  335. /* <--- error code from registration */
  336. /* ---> urlToRegister is a null terminated url that has only legal characters defined for URLs. Use HexEncodeText to encode*/
  337. /* portions of the url that have illegal characters */
  338. /* ---> neighborhoodToRegisterIn is an optional parameter for explicitly defining a neighborhood to register in.
  339. If parameter is NULL, then the plugins will determine where to register the service */
  340. /*
  341. * NSLStandardRegisterURL()
  342. *
  343. * Availability:
  344. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  345. * CarbonLib: in CarbonLib 1.0 and later
  346. * Mac OS X: in version 10.0 and later
  347. */
  348. EXTERN_API( NSLError )
  349. NSLStandardRegisterURL(
  350. NSLPath urlToRegister,
  351. NSLNeighborhood neighborhoodToRegisterIn); /* can be NULL */
  352. /* <--- error code from registration */
  353. /* ---> urlToRegister is a null terminated url that has only legal characters defined for URLs. Use HexEncodeText to encode*/
  354. /* portions of the url that have illegal characters */
  355. /* ---> neighborhoodToDeregisterIn is an optional parameter for explicitly defining a neighborhood to register in.
  356. If parameter is NULL, then the plugins will determine where to register the service */
  357. /*
  358. * NSLStandardDeregisterURL()
  359. *
  360. * Availability:
  361. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  362. * CarbonLib: in CarbonLib 1.0 and later
  363. * Mac OS X: in version 10.0 and later
  364. */
  365. EXTERN_API( NSLError )
  366. NSLStandardDeregisterURL(
  367. NSLPath urlToDeregister,
  368. NSLNeighborhood neighborhoodToDeregisterIn); /* can be NULL */
  369. /*-----------------------------------------------------------------------------*/
  370. /*
  371. * NSLHexEncodeText()
  372. *
  373. * Availability:
  374. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  375. * CarbonLib: in CarbonLib 1.0 and later
  376. * Mac OS X: in version 10.0 and later
  377. */
  378. EXTERN_API( OSStatus )
  379. NSLHexEncodeText(
  380. const char * rawText,
  381. UInt16 rawTextLen,
  382. char * newTextBuffer,
  383. UInt16 * newTextBufferLen,
  384. Boolean * textChanged);
  385. /*
  386. * NSLHexDecodeText()
  387. *
  388. * Availability:
  389. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  390. * CarbonLib: in CarbonLib 1.0 and later
  391. * Mac OS X: in version 10.0 and later
  392. */
  393. EXTERN_API( OSStatus )
  394. NSLHexDecodeText(
  395. const char * encodedText,
  396. UInt16 encodedTextLen,
  397. char * decodedTextBuffer,
  398. UInt16 * decodedTextBufferLen,
  399. Boolean * textChanged);
  400. /*
  401. -----------------------------------------------------------------------------
  402. Basic API Utility calls: sufficient to create, and parse data structures
  403. -----------------------------------------------------------------------------
  404. */
  405. /*
  406. * NSLMakeNewServicesList()
  407. *
  408. * Availability:
  409. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  410. * CarbonLib: in CarbonLib 1.0 and later
  411. * Mac OS X: in version 10.0 and later
  412. */
  413. EXTERN_API( NSLServicesList )
  414. NSLMakeNewServicesList(const char * initialServiceList);
  415. /*
  416. * NSLAddServiceToServicesList()
  417. *
  418. * Availability:
  419. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  420. * CarbonLib: in CarbonLib 1.0 and later
  421. * Mac OS X: in version 10.0 and later
  422. */
  423. EXTERN_API( NSLError )
  424. NSLAddServiceToServicesList(
  425. NSLServicesList serviceList,
  426. NSLServiceType serviceType);
  427. /*
  428. * NSLDisposeServicesList()
  429. *
  430. * Availability:
  431. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  432. * CarbonLib: in CarbonLib 1.0 and later
  433. * Mac OS X: in version 10.0 and later
  434. */
  435. EXTERN_API( void )
  436. NSLDisposeServicesList(NSLServicesList theList);
  437. /*
  438. The name reflects the name of the Neighborhood, i.e. "apple.com." or "AppleTalk Zone One".
  439. The protocolList is a comma delimited list of protocols that the Neighborhood might exist in.
  440. If the user passes in NULL, then all protocols will be queried. The result must be disposed
  441. of by the user by calling NSLFreeNeighborhood.
  442. */
  443. /*
  444. * NSLMakeNewNeighborhood()
  445. *
  446. * Availability:
  447. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  448. * CarbonLib: in CarbonLib 1.0 and later
  449. * Mac OS X: in version 10.0 and later
  450. */
  451. EXTERN_API( NSLNeighborhood )
  452. NSLMakeNewNeighborhood(
  453. const char * name,
  454. const char * protocolList); /* can be NULL */
  455. /* creates an exact copy of an existing neighborhood */
  456. /*
  457. * NSLCopyNeighborhood()
  458. *
  459. * Availability:
  460. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  461. * CarbonLib: in CarbonLib 1.0 and later
  462. * Mac OS X: in version 10.0 and later
  463. */
  464. EXTERN_API( NSLNeighborhood )
  465. NSLCopyNeighborhood(NSLNeighborhood neighborhood);
  466. /*
  467. * NSLFreeNeighborhood()
  468. *
  469. * Availability:
  470. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  471. * CarbonLib: in CarbonLib 1.0 and later
  472. * Mac OS X: in version 10.0 and later
  473. */
  474. EXTERN_API( NSLNeighborhood )
  475. NSLFreeNeighborhood(NSLNeighborhood neighborhood);
  476. /*
  477. * NSLGetNameFromNeighborhood()
  478. *
  479. * Availability:
  480. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  481. * CarbonLib: in CarbonLib 1.0 and later
  482. * Mac OS X: in version 10.0 and later
  483. */
  484. EXTERN_API( void )
  485. NSLGetNameFromNeighborhood(
  486. NSLNeighborhood neighborhood,
  487. char ** name,
  488. long * length);
  489. /*
  490. create a block of formatted data, pointed to by newDataPtr. This will be used
  491. in calls (typically request-related calls) for plug-ins that handle the NSL data type.
  492. */
  493. /*
  494. * NSLMakeServicesRequestPB()
  495. *
  496. * Availability:
  497. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  498. * CarbonLib: in CarbonLib 1.0 and later
  499. * Mac OS X: in version 10.0 and later
  500. */
  501. EXTERN_API( OSStatus )
  502. NSLMakeServicesRequestPB(
  503. NSLServicesList serviceList,
  504. NSLTypedDataPtr * newDataPtr);
  505. /* releases any storage created with MakeXXXPB calls, associated with TypedData.*/
  506. /*
  507. * NSLFreeTypedDataPtr()
  508. *
  509. * Availability:
  510. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  511. * CarbonLib: in CarbonLib 1.0 and later
  512. * Mac OS X: in version 10.0 and later
  513. */
  514. EXTERN_API( NSLTypedDataPtr )
  515. NSLFreeTypedDataPtr(NSLTypedDataPtr nslTypeData);
  516. /*
  517. utility function that returns whether a url was found, a pointer to the beginning
  518. of the url, and the length of the URL.
  519. */
  520. /*
  521. * NSLGetNextUrl()
  522. *
  523. * Availability:
  524. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  525. * CarbonLib: in CarbonLib 1.0 and later
  526. * Mac OS X: in version 10.0 and later
  527. */
  528. EXTERN_API( Boolean )
  529. NSLGetNextUrl(
  530. NSLClientAsyncInfoPtr infoPtr,
  531. char ** urlPtr,
  532. long * urlLength);
  533. /*
  534. utility function that returns whether a Neighborhood was found, a pointer to the beginning
  535. of the Neighborhood, and the length of the Neighborhood.
  536. */
  537. /*
  538. * NSLGetNextNeighborhood()
  539. *
  540. * Availability:
  541. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  542. * CarbonLib: in CarbonLib 1.0 and later
  543. * Mac OS X: in version 10.0 and later
  544. */
  545. EXTERN_API( Boolean )
  546. NSLGetNextNeighborhood(
  547. NSLClientAsyncInfoPtr infoPtr,
  548. NSLNeighborhood * neighborhood,
  549. long * neighborhoodLength);
  550. /*
  551. NSLErrorToString: convert a numeric error code to its string equivalent. Caller must
  552. have allocated sufficient space to store both strings. (Max 255 chars each)
  553. The errorString parameter will return a textual explanation of what is wrong,
  554. while the solutionString returns a possible solution to get around the problem
  555. */
  556. /*
  557. * NSLErrorToString()
  558. *
  559. * Availability:
  560. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  561. * CarbonLib: in CarbonLib 1.0 and later
  562. * Mac OS X: in version 10.0 and later
  563. */
  564. EXTERN_API( OSStatus )
  565. NSLErrorToString(
  566. NSLError theErr,
  567. char * errorString,
  568. char * solutionString);
  569. /*
  570. -----------------------------------------------------------------------------
  571. Basic API calls: sufficient to create simple requests, and receive answers
  572. -----------------------------------------------------------------------------
  573. */
  574. /*
  575. * NSLOpenNavigationAPI()
  576. *
  577. * Availability:
  578. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  579. * CarbonLib: in CarbonLib 1.0 and later
  580. * Mac OS X: in version 10.0 and later
  581. */
  582. EXTERN_API( OSStatus )
  583. NSLOpenNavigationAPI(NSLClientRef * newRef);
  584. /*
  585. * NSLCloseNavigationAPI()
  586. *
  587. * Availability:
  588. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  589. * CarbonLib: in CarbonLib 1.0 and later
  590. * Mac OS X: in version 10.0 and later
  591. */
  592. EXTERN_API( void )
  593. NSLCloseNavigationAPI(NSLClientRef theClient);
  594. /*
  595. NSLPrepareRequest: creates an NSLRequestRef, sets up some internal data
  596. notifier is an NSLClientNotifyUPP that will be called when data is available, when the lookup has
  597. completed, or if an error occurs. When the notifier is called, the cookie will be the NSLRequestRef.
  598. If notifier is NULL, then the NSLManager will assume that the request is made synchronously. This
  599. should only be used while in a separate thread, so that the client app can still process events, etc.
  600. contextPtr is a void* which is passed as the contextPtr argument when the notifier is called.
  601. upon exit:
  602. 1) ref will contain a pointer to a NSLRequestRef which must be passed to all other functions
  603. which require a NSLRequestRef.
  604. 2) infoPtr will point to a newly created ClientAsycnInfoPtr which will be disposed by the manager when the search is completed
  605. NOTE: Only one search can be running at a time per clientRef.
  606. */
  607. /*
  608. * NSLPrepareRequest()
  609. *
  610. * Availability:
  611. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  612. * CarbonLib: in CarbonLib 1.0 and later
  613. * Mac OS X: in version 10.0 and later
  614. */
  615. EXTERN_API( NSLError )
  616. NSLPrepareRequest(
  617. NSLClientNotifyUPP notifier,
  618. void * contextPtr,
  619. NSLClientRef theClient,
  620. NSLRequestRef * ref,
  621. char * bufPtr,
  622. unsigned long bufLen,
  623. NSLClientAsyncInfoPtr * infoPtr);
  624. /*
  625. NSLStartNeighborhoodLookup: looking for neighborhoods associated with or neighboring a particular neighborhood
  626. Passing in NULL for neighborhood will generate a list of a default neighborhood(s)
  627. */
  628. /*
  629. * NSLStartNeighborhoodLookup()
  630. *
  631. * Availability:
  632. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  633. * CarbonLib: in CarbonLib 1.0 and later
  634. * Mac OS X: in version 10.0 and later
  635. */
  636. EXTERN_API( NSLError )
  637. NSLStartNeighborhoodLookup(
  638. NSLRequestRef ref,
  639. NSLNeighborhood neighborhood,
  640. NSLClientAsyncInfo * asyncInfo);
  641. /*
  642. NSLStartServicesLookup: starts looking for entities if the specified type in the specified neighborhood
  643. */
  644. /*
  645. * NSLStartServicesLookup()
  646. *
  647. * Availability:
  648. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  649. * CarbonLib: in CarbonLib 1.0 and later
  650. * Mac OS X: in version 10.0 and later
  651. */
  652. EXTERN_API( NSLError )
  653. NSLStartServicesLookup(
  654. NSLRequestRef ref,
  655. NSLNeighborhood neighborhood,
  656. NSLTypedDataPtr requestData,
  657. NSLClientAsyncInfo * asyncInfo);
  658. /* NSLContinueLookup: continues a paused/outstanding lookup*/
  659. /*
  660. * NSLContinueLookup()
  661. *
  662. * Availability:
  663. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  664. * CarbonLib: in CarbonLib 1.0 and later
  665. * Mac OS X: in version 10.0 and later
  666. */
  667. EXTERN_API( NSLError )
  668. NSLContinueLookup(NSLClientAsyncInfo * asyncInfo);
  669. /* NSLCancelRequest: cancels an ongoing search*/
  670. /*
  671. * NSLCancelRequest()
  672. *
  673. * Availability:
  674. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  675. * CarbonLib: in CarbonLib 1.0 and later
  676. * Mac OS X: in version 10.0 and later
  677. */
  678. EXTERN_API( NSLError )
  679. NSLCancelRequest(NSLRequestRef ref);
  680. /*
  681. NSLDeleteRequest: deletes info associated with this ref. The ClientAsyncInfoPtr will no longer be valid
  682. This must be called when the client is no longer using this requestRef.
  683. */
  684. /*
  685. * NSLDeleteRequest()
  686. *
  687. * Availability:
  688. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  689. * CarbonLib: in CarbonLib 1.0 and later
  690. * Mac OS X: in version 10.0 and later
  691. */
  692. EXTERN_API( NSLError )
  693. NSLDeleteRequest(NSLRequestRef ref);
  694. /*
  695. -----------------------------------------------------------------------------
  696. Utility API calls: use these accessors to manipulate NSL's typed data
  697. -----------------------------------------------------------------------------
  698. */
  699. /* NSLParseServicesRequestPB provides the inverse of NSLMakeRequestPB, filling out the offsets found within newDataPtr*/
  700. /* <--- returns an OSStatus if any errors occur parsing the data */
  701. /* <--- newDataPtr is the construct passed to the plugin */
  702. /* ---> serviceListPtr is the address of a pointer which will be set to point at the portion of the newDataPtr that holds the serviceList to be searched */
  703. /* ---> serviceListLen is the length of the serviceListPtr data pointed to by serviceListPtr */
  704. /*
  705. * NSLParseServicesRequestPB()
  706. *
  707. * Availability:
  708. * Non-Carbon CFM: in NSLPPCLib 1.0 and later
  709. * CarbonLib: in CarbonLib 1.0 and later
  710. * Mac OS X: in version 10.0 and later
  711. */
  712. EXTERN_API( OSStatus )
  713. NSLParseServicesRequestPB(
  714. NSLTypedDataPtr newDataPtr,
  715. char ** serviceListPtr,
  716. UInt16 * serviceListLen);
  717. /* NSLParseServiceRegistrationPB provides for breaking apart a registration request from a client to a plugin */
  718. /* <--- returns an OSStatus if any errors occur parsing the data */
  719. /* <--- newDataPtr is the construct passed to the plugin */
  720. /* ---> neighborhoodPtr gets set to point at the portion of the newDataPtr that contains the neighborhood */
  721. /* ---> neighborhoodLen is the length of the neighborhood pointed to by neighborhoodPtr */
  722. /* ---> urlPtr is the address of a pointer which will be set to point at the portion of the newDataPtr that holds the url to be registered */
  723. /* ---> urlLen is the length of the url data pointed to by urlPtr */
  724. /*
  725. * NSLParseServiceRegistrationPB()
  726. *
  727. * Availability:
  728. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  729. * CarbonLib: in CarbonLib 1.0 and later
  730. * Mac OS X: in version 10.0 and later
  731. */
  732. EXTERN_API( OSStatus )
  733. NSLParseServiceRegistrationPB(
  734. NSLTypedDataPtr newDataPtr,
  735. NSLNeighborhood * neighborhoodPtr,
  736. UInt16 * neighborhoodLen,
  737. char ** urlPtr,
  738. UInt16 * urlLen);
  739. /* NSLGetErrorStringsFromResource is obsolete in X. It will ignore the fileSpecPtr */
  740. /* and errorResID parameters and return the standard error strings. */
  741. /* NSLGetErrorStringsFromResource makes a basic assumption: */
  742. /* errorString and solutionString both point to valid memory of at least 256 bytes! */
  743. /* <--- returns an OSStatus if any errors occur */
  744. /* ---> theErr is an OSStatus to be matched against a resource list of errors */
  745. /* ---> fileSpecPtr is a FSSpecPtr to the resource containing the list of errors */
  746. /* ---> errorResID is the resourceID of the NSLI resource of the list of errors */
  747. /* <--> errorString is a pointer to valid memory of at least 256 bytes which will be filled out by the error portion of the error string */
  748. /* <--> solutionString is a pointer to valid memory of at least 256 bytes which will be filled out by the solution portion of the error string */
  749. /*
  750. * NSLGetErrorStringsFromResource()
  751. *
  752. * Availability:
  753. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  754. * CarbonLib: in CarbonLib 1.0 and later
  755. * Mac OS X: in version 10.0 and later
  756. */
  757. EXTERN_API( OSStatus )
  758. NSLGetErrorStringsFromResource(
  759. OSStatus theErr,
  760. const FSSpec * fileSpecPtr,
  761. SInt16 errorResID,
  762. char * errorString,
  763. char * solutionString);
  764. /* <--- Returns true if given service is in the given service list */
  765. /* ---> serviceList is a valid NSLServicesList containing information about services to be searched */
  766. /* ---> svcToFind is an NSLServiceType of a particular service to check if it is in the serviceList */
  767. /*
  768. * NSLServiceIsInServiceList()
  769. *
  770. * Availability:
  771. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  772. * CarbonLib: in CarbonLib 1.0 and later
  773. * Mac OS X: in version 10.0 and later
  774. */
  775. EXTERN_API( Boolean )
  776. NSLServiceIsInServiceList(
  777. NSLServicesList serviceList,
  778. NSLServiceType svcToFind);
  779. /* <--- returns an OSStatus if any errors occur parsing the data */
  780. /* ---> svcString is the address of a pointer which will be set to point at the portion of theURL that holds the serviceType of theURL */
  781. /* ---> svcLen is the length of the serviceType pointed to by svcString */
  782. /*
  783. * NSLGetServiceFromURL()
  784. *
  785. * Availability:
  786. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  787. * CarbonLib: in CarbonLib 1.0 and later
  788. * Mac OS X: in version 10.0 and later
  789. */
  790. EXTERN_API( OSStatus )
  791. NSLGetServiceFromURL(
  792. char * theURL,
  793. char ** svcString,
  794. UInt16 * svcLen);
  795. /* <--- returns the length of a Neighborhood data structure */
  796. /* ---> neighborhood is a valid NSLNeighborhood */
  797. /*
  798. * NSLGetNeighborhoodLength()
  799. *
  800. * Availability:
  801. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  802. * CarbonLib: in CarbonLib 1.0 and later
  803. * Mac OS X: in version 10.0 and later
  804. */
  805. EXTERN_API( long )
  806. NSLGetNeighborhoodLength(NSLNeighborhood neighborhood);
  807. /*
  808. -------------------------------------------------------------------------------------
  809. Utility API calls: use these routines to separate plugin threads from client threads
  810. -------------------------------------------------------------------------------------
  811. */
  812. /* this routine works the same as the Thread manager's routine NewThread, except */
  813. /* that the thread is added to the NSL manager's thread list. */
  814. /*
  815. * NSLNewThread()
  816. *
  817. * Availability:
  818. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  819. * CarbonLib: in CarbonLib 1.0 and later
  820. * Mac OS X: in version 10.0 and later
  821. */
  822. EXTERN_API( OSErr )
  823. NSLNewThread(
  824. ThreadStyle threadStyle,
  825. ThreadEntryProcPtr threadEntry,
  826. void * threadParam,
  827. Size stackSize,
  828. ThreadOptions options,
  829. void ** threadResult,
  830. ThreadID * threadMade);
  831. /* this routine works the same as the Thread manager's routine DisposeThread, except */
  832. /* that the thread is removed from the NSL manager's thread list. */
  833. /*
  834. * NSLDisposeThread()
  835. *
  836. * Availability:
  837. * Non-Carbon CFM: in NSLPPCLib 1.1 and later
  838. * CarbonLib: in CarbonLib 1.0 and later
  839. * Mac OS X: in version 10.0 and later
  840. */
  841. EXTERN_API( OSErr )
  842. NSLDisposeThread(
  843. ThreadID threadToDump,
  844. void * threadResult,
  845. Boolean recycleThread);
  846. #if OLDROUTINENAMES
  847. typedef NSLClientAsyncInfo ClientAsyncInfo;
  848. typedef NSLPluginAsyncInfo PluginAsyncInfo;
  849. typedef NSLTypedData TypedData;
  850. typedef NSLPluginData PluginData;
  851. typedef NSLClientAsyncInfoPtr ClientAsyncInfoPtr;
  852. typedef NSLPluginAsyncInfoPtr PluginAsyncInfoPtr;
  853. typedef NSLTypedDataPtr TypedDataPtr;
  854. typedef NSLPluginDataPtr PluginDataPtr;
  855. #endif /* OLDROUTINENAMES */
  856. #if PRAGMA_STRUCT_ALIGN
  857. #pragma options align=reset
  858. #elif PRAGMA_STRUCT_PACKPUSH
  859. #pragma pack(pop)
  860. #elif PRAGMA_STRUCT_PACK
  861. #pragma pack()
  862. #endif
  863. #ifdef PRAGMA_IMPORT_OFF
  864. #pragma import off
  865. #elif PRAGMA_IMPORT
  866. #pragma import reset
  867. #endif
  868. #ifdef __cplusplus
  869. }
  870. #endif
  871. #endif /* __NSLCORE__ */