Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Network Services Location Manager Miscellaneous Functions
NSLAddServiceToServicesList
Adds a service to a services list.
NSLError NSLAddServiceToServicesList ( NSLServicesList serviceList, NSLServiceType serviceType);
Parameters
- serviceList
On input, a value of type
NSLServicesList
previously created by callingNSLMakeNewServicesList
.- serviceType
On input, a value of type
NSLServiceType
containing the name of the service, such ashttp
orftp
that is to be added to the services list.- function result
An
NSLError
theErr
field contains the result code. If the value ofNSLError.theErr
isnoErr
, the service was added to the list. Other possible values arekNSLNotInitialized
,kNSLBadServiceTypeErr
, andkNSLNullListPtr
. CallNSLErrorToString
to get a problem and a solution string.
Discussion
This function adds the name of the specified service to a services list. If you need to add more than one service to the services list, call this function once for each service that you want to add.
Special Considerations
You must create
serviceList
by callingNSLMakeNewServicesList
before calling this function.-
NSLCancelRequest
NSLError NSLCancelRequest (NSLRequestRef ref);
Parameters
- ref
On input, a value of type
NSLRequestRef
, obtained by previously callingNSLPrepareRequest
, for the search that is to be canceled.- function result
An
NSLError
structure whosetheErr
field contains the result code. A value ofnoErr
indicates that the request was canceled successfully. Other possible values arekNSLNotInitialized
andkNSLBadReferenceErr
. CallNSLErrorToString
to get a problem and a solution string.
Discussion
This function cancels an ongoing search. Any outstanding I/O is also canceled.
-
NSLCloseNavigationAPI
Closes a session with the Network Services Location Manager.
void NSLCloseNavigationAPI (NSLClientRef theClient);
Parameters
- theClient
On input, a value of type
NSLClientRef
, obtained by previously callingNSLOpenNavigationAPI
, that identifies the session that is to be closed.
Discussion
This function closes the Network Services Location Manager session identified by
theClient
. If your application calls this function while a search is in progress, any data that would have been returned is lost.Special Considerations
Your application is responsible for reclaiming memory that it allocates for services lists, parameter blocks, and search request references. Your application should reclaim memory by calling
NSLDisposeServicesList
,NSLDeleteRequest
, andNSLFreeTypedDataPtr
, respectively. NSLContinueLookup
NSLError NSLContinueLookup ( NSLClientAsyncInfo *asyncInfo);
Parameters
- asyncInfo
On input, a pointer to the
NSLClientAsyncInfo
structure for this search.- function result
An
NSLError
theErr
field contains the result code. If the value ofNSLError.theErr
isnoErr
,NSLContinueLookip
returned successfully. Possible errors includekNSLNotInitialized
,kNSLNoContextAvailable
,kNSLBadClientInfoPtr
,kNSLCannotContinueLookup
, andkNSLBufferTooSmallForData
. CallNSLErrorToString
to get a problem and a solution string.
Discussion
This function is deprecated in Mac OS X and returns without performing any work. In Mac OS X, asynchronous searches continue automatically when the application’s notification routine returns. For compatibility with earlier versions of the Network Services Location Manager, applications can continue to call this function, but doing so is not necessary.
NSLCopyNeighborhood
Copies a neighborhood.
NSLNeighborhood NSLCopyNeighborhood ( NSLNeighborhood neighborhood);
Parameters
- neighborhood
On input, the neighborhood that is to be copied.
- result
An
NSLNeighborhood
value. If this function can’t copy the neighborhood specified by theneighborhood
parameter, it returnsNULL
. This might happen, for example, if there is not enough memory.
Discussion
This utility function creates a copy of the specified neighborhood. A neighborhood is guaranteed to exist only during the execution of an application’s notification routine, so you may want to call this utility function from your application’s notification routine in order to keep a copy of the neighborhood.
When you have no further use for an
NSLNeighborhood
value, you should reclaim the memory allocated to it by callingNSLFreeNeighborhood
.NSLDeleteRequest
Deletes a request reference.
NSLError NSLDeleteRequest ( NSLRequestRef ref);
Parameters
- ref
On input, the value of type
NSLRequestRef
, obtained by previously callingNSLPrepareRequest
, that is to be deleted.- function result
An
NSLError
structure whosetheErr
field contains the result code. If the value of thetheErr
field isnoErr
, the request reference was deleted. Other possible values arekNSLNotInitialized
andkNSLBadReferenceErr
. CallNSLErrorToString
to get a problem and a solution string.
Discussion
This function deletes the specified request reference and deallocates memory associated with it, including the
NSLClientAsyncInfo
structure associated with the request reference. If a search using the specified request reference is in progress when this function is called, the search is canceled and any outstanding I/O is lost.This function does not deallocate memory associated with services lists or request parameter blocks. To deallocate memory for services lists, call
NSLDisposeServicesList
; to deallocate memory for parameter blocks, callNSLFreeTypedDataPtr
.-
NSLDisposeServicesList
void NSLDisposeServicesList ( NSLServicesList theList);
Parameters
- theList
On input, a value of type
NSLServicesList
, previously created by callingNSLMakeNewServicesList
, that is to be disposed of.
Discussion
This utility function reclaims memory by disposing of a services list. Once you’ve incorporated the information in a services list into a request parameter block by passing the services list to
NSLMakeServicesRequestPB
, you can dispose of the services list.Calling
NSLCloseNavigationAPI
does not reclaim memory allocated for services lists, so your application should dispose of services lists before it closes a Network Services Location Manager session. NSLErrorToString
Obtains information about an error.
OSStatus NSLErrorToString ( NSLError theErr, char * errorString, char * solutionString);
Parameters
- theErr
On input, an
NSLError
structure whosetheErr
field contains a Network Services Location Manager result code.- errorString
On input, a pointer to the buffer in which this function is to place a null-terminated string containing a description of the problem that caused the error. The length of
errorString
should be 256 bytes.- solutionString
On input, a pointer to the buffer in which this function is to place a null-terminated string containing a possible solution to the problem. The length of
solutionString
should be 256 bytes.- function result
A value of
noErr
indicates that this function returned successfully. If the value of thetheContext
field of theNSLError
structure that was passed to this function is zero and thetheErr
field contains a result code that is not within the range of Network Services Location Manager result codes, this function returnskNSLBadReferenceErr
.
Discussion
This function obtains the error and solution strings for the result code stored in the
theErr
field of anNSLError
structure.Your application can use the strings to display an appropriate error message.NSLFreeNeighborhood
Disposes of an
NSLNeighborhood
value.NSLNeighborhood NSLFreeNeighborhood (NSLNeighborhood neighborhood);
Parameters
- neighborhood
On input, the
NSLNeighborhood
value, obtained by previously callingNSLMakeNewNeighborhood
, that is to be disposed of.- function result
An
NSLNeighborhood
whose value isNULL
.
Discussion
This utility function disposes of an
NSLNeighborhood
value and reclaims the memory that was allocated to it.-
NSLFreeTypedDataPtr
Frees memory allocated for a request parameter block.
NSLTypedDataPtr NSLFreeTypedDataPtr ( NSLTypedDataPtr nslTypeData);
Parameters
- nslTypeData
On input, a value of type
NSLTypedDataPtr
, obtained by previously callingNSLMakeServicesRequestPB
.- function result
A value of type
NSLTypedDataPtr
whose value is
NULL
.
Discussion
This utility function frees memory that was allocated when your application previously called
NSLMakeServicesRequestPB
. Your application should free the memory allocated for a request parameter block when it has no further use for the parameter block. -
NSLFreeURL
Frees memory allocated for a URL.
(char *) NSLFreeURL ( char * URL);
Parameters
- URL
On input, a pointer to a character string obtained by previously calling
NSLStandardGetURL
.- result
NULL
.
Discussion
This utility function frees the memory that was allocated for
URL
whenNSLStandardGetURL
was called. Your application should call this utility function when it has no further use for the URL. -
NSLGetDefaultDialogOptions
Assigns the default values to an
NSLDialogOptions
structure.OSStatus NSLGetDefaultDialogOptions ( NSLDialogOptions * dialogOptions);
Parameters
- dialogOptions
On input, a pointer to an
NSLDialogOptions
structure. On output, the fields of the structure are filled in with the default values.- function result
A value of
noErr
indicates that the fields were filled in with the default values. See“Network Services Location Manager Result Codes”
for other possible result codes.
Discussion
This utility function assigns default values to the
NSLDialogOptions
structure pointed to by the dialogOptions parameter. Assigning default values prepares the structure for use when callingNSLStandardGetURL
. After the default values are assigned, you can modify the structure as desired. For the default values, seeNSLDialogOptions
. -
NSLGetNameFromNeighborhood
Locates the name in a neighborhood.
void NSLGetNameFromNeighborhood ( NSLNeighborhood neighborhood, char ** name, long * length);
Parameters
- neighborhood
On input, a value of type
NSLNeighborhood
containing the name that is to be located.- name
On input, the address of a pointer. On output,
name
contains the address of a pointer to the name in theneighborhood
parameter.- length
On input, a pointer to a location in memory. On output,
length
points to the length in bytes of the name in theneighborhood
parameter.
Discussion
This utility function locates the null-terminated name in the neighborhood specified by the
neighborhood
parameter so that your application can, for example, display the name. Use the value pointed to bylength
to determine the length of the name. -
NSLGetNeighborhoodLength
Gets the length of a neighborhood.
long NSLGetNeighborhoodLength ( NSLNeighborhood neighborhood);
Parameters
- neighborhood
On input, the value of type
NSLNeighborhood
whose length is to be obtained.- function result
The length in bytes of the specified neighborhood.
Discussion
This utility function gets the length of the specified neighborhood, which you would need in order to make a copy of a neighborhood. Instead of calling this utility function, call
NSLCopyNeighborhood
to make a copy of a neighborhood.Special Considerations
This utility function may be deprecated in the future.
-
NSLGetNextNeighborhood
Gets the position of the next neighborhood in a result buffer.
Boolean NSLGetNextNeighborhood ( NSLClientAsyncInfoPtr infoPtr, NSLNeighborhood * neighborhood, long * neighborhoodLength);
Parameters
- infoPtr
On input, a pointer to an
NSLClientAsyncInfo
structure whose resultBuffer field may contain another neighborhood.- neighborhood
On input, a pointer to a value of type
NSLNeighborhood
. On output,neighborhood
points to the next neighborhood in theresultBuffer
field of theNSLClientAsyncInfo
structure pointed to byinfoPtr
.- neighborhoodLength
On output, the length of the neighborhood pointed to by
neighborhood
.- function result
A Boolean value. A value of
TRUE
indicates thatneighborhood
points to the next neighborhood in theresultBuffer
field pointed to by
infoPtr
. A value ofFALSE
indicates that there are no more neighborhoods in theresultBuffer field
.
Discussion
This utility function provides the starting position and the length of the next neighborhood in a result buffer. Typically, the neighborhoods were placed in the result buffer by a previous call to
NSLStartNeighborhoodLookup
.If you want to get a copy of the neighborhood, call
NSLCopyNeighborhood
. If you want to get the name from the neighborhood, callNSLGetNameFromNeighborhood
. -
NSLGetNextURL
Gets the position of the next URL in a result buffer.
Boolean NSLGetNextUrl ( NSLClientAsyncInfoPtr infoPtr, char ** urlPtr, long * urlLength);
Parameters
- infoPtr
On input, a pointer to an
NSLClientAsyncInfo
structure whoseresultBuffer
field may contain another URL.- urlPtr
On output, if another URL was found in the
resultBuffer
field, a pointer to the beginning of the URL.- urlLength
On output, the length of the URL pointed to by
urlPtr
.- function result
A Boolean value. A value of
TRUE
indicates thaturlPtr
points to the next URL in theresultBuffer
field pointed to byinfoPtr
. A value ofFALSE
indicates that there are no more URLs in theresultBuffer
field.
Discussion
This utility function obtains the starting position and the length of the next URL in a result buffer. Typically, the URLs were placed in the result buffer by a previous call to
NSLStartServicesLookup
. -
NSLGetServiceFromURL
Gets the service portion of a URL.
OSStatus NSLGetServiceFromURL ( char* theURL, char** svcString, UInt16* svcLen);
Parameters
- theURL
On input, a pointer to a null-terminated string containing a URL.
- svcString
On input, a pointer to the address of a string in memory. On output,
svcString
points to the service portion of the URL specified bytheURL
.- svcLen
On input, a pointer to an unsigned 16-bit value. On output,
svcLen
points to the length in bytes ofsvcString
.- function result
A value of
noErr
indicates thatsvcString
points to the service portion of the URL specified bytheURL
.
Discussion
This utility function gets the service portion of a URL. For example, if the URL is
http://www.apple.com
, the service portion of that URL ishttp
. -
NSLHexDecodeText
Decodes the encoded portion of a URL.
OSStatus NSLHexDecodeText ( char* encodedText, UInt16 encodedTextLen, char* decodedTextBuffer, UInt16* decodedTextBufferLen, Boolean* textChanged);
Parameters
- encodedText
On input, a pointer to a buffer containing the portion of a URL that has been encoded.
- encodedTextLen
On input, a value of type
UInt16
that specifies the length of the buffer pointed to by encodedText.- decodedTextBuffer
On input, a pointer to a buffer in which the decoded text is to be stored. On output, the buffer contains the decoded text.
- decodedTextBufferLen
On input, a pointer to a value of type
UInt16
containing the maximum length ofdecodedTextBuffer
. On output,decodedTextBufferLen
points to the length of the decoded text pointed to bydecodedTextBuffer
.- textChanged
On input, a pointer to a Boolean value. On output,
textChanged
points to a value that isTRUE
if decoding occurred or that isFALSE
if no decoding was required.- function result
A value of
noErr
indicates that this utility function returned successfully. See“Network Services Location Manager Result Codes”
for other possible result codes.
Discussion
This utility function decodes the portion of a URL that was previously encoded by
NSLHexEncodeText
. If this utility function returnsnoErr
, the buffer pointed to bydecodedTextBuffer
contains the decoded copy of the buffer pointed to byencodedTextBuffer
, or it contains an exact copy of the buffer pointed to byencodedTextBuffer
. Use thetextChanged
parameter to determine whether any decoding actually took place. NSLHexEncodeText
Encodes a portion of a URL.
OSStatus NSLHexEncodeText ( char* rawText, UInt16 rawTextLen, char* newTextBuffer, UInt16* newTextBufferLen, Boolean* textChanged);
Parameters
- rawText
On input, a pointer to a character array containing the portion of a URL that is to be encoded. For example, if the URL is
afp://17.221.40.66?NAME=Kevs G3
, the portion of the URL that contains a character that is not allowed isKevs G3
. In this example, the space character is not allowed.- rawTextLen
On input, a value of type
UInt16
containing the length in bytes of therawText
parameter.- newTextBuffer
On input, a pointer to a buffer. On output, the buffer contains the encoded text.
- newTextBufferLen
On input, a pointer to a value of type UInt16. On output,
newTextBufferLen
points to the length of the encoded text in the buffer pointed to bynewTextBuffer
.- textChanged
On input, a pointer to a Boolean value. On output,
textChanged
points to a value that isTRUE
if encoding occurred or that isFALSE
if no encoding was required.- function result
A value of
noErr
indicates that this utility function returned successfully. See“Network Services Location Manager Result Codes”
for other possible result codes.
Discussion
This utility function uses the US ASCII character set to encode characters that are not allowed in URLs. Hexadecimal values from 01 to 1F, from 80 to FF, and 7F are not allowed. In addition, the following characters are not allowed:
< > " # { } | \ ^ ~ [ ]
This utility function also encodes the following characters that are reserved for URL syntax:
; / ? : @ = % &
If this utility function returns
noErr
, the buffer pointed to bynewTextBuffer
contains the encoded copy of the buffer pointed to byrawText
, or it contains an exact copy of the buffer pointed to byrawText
. Use thetextChanged
parameter to determine whether any encoding actually took place.Call
NSLHexDecodeText
to decode a string that has been encoded.Special Considerations
The
NSLStandardRegisterURL
function returns an error if a URL you try to register contains characters that need to be encoded.NSLLibraryPresent
Determines whether the Network Services Location Manager is present.
Boolean NSLLibraryPresent (void);
Parameters
- function result
TRUE
if the Network Services Location Manager is present.
Discussion
This utility function returns
TRUE
when the Network Services Location Manager is available. The Network Services Location Manager is always present in Mac OS X, so for applications that only run on Mac OS X do not need to call this function.NSLLibraryVersion
Gets the Network Services Location Manager’s version.
UInt32 NSLLibraryVersion (void);
Parameters
- function result
The Network Services Location Manager’s version number in hexadecimal format, where the first two bytes represent the version number, the second two bytes represent the revision number, and the third two bytes represent the subrevision number.
Discussion
This utility function gets the version of the Network Services Location Manager installed on the system.
-
NSLMakeNewNeighborhood
Creates a neighborhood for use in searches.
NSLNeighborhood NSLMakeNewNeighborhood ( char * name, char * protocolList);
Parameters
- name
On input,
NULL
to create a neighborhood that can be used to obtain a list of default neighborhoods when callingNSLStartNeighborhoodLookup
, or a pointer to a null-terminated string containing the name of a neighborhood in which searches are to be conducted.- protocolList
On input,
NULL
, which creates a neighborhood that will cause all available protocols to participate in any search that uses it. For compatibility with earlier versions of the Network Services Location Manager,protocolList
can be a pointer to a comma-separated, null-terminated list of protocols (such asNBP,SLP
) that are to participate in a search conducted with the resulting neighborhood. The constantskDSProtocolType
,kNBPProtocolType
, andkSLPProtocolType
can be used to build a protocol list. However, searches conducted using the resulting neighborhood will not be limited to the protocols that were specified.- function result
An
NSLNeighborhood
value that can be used in subsequent calls to Network Services Location Manager functions, orNULL
if a neighborhood value could not be created. This might happen, for example, if there is not enough memory.
Discussion
This utility function creates a neighborhood that can be provided as a parameter to other Network Services Location Manager functions such as
NSLStartNeighborhoodLookup
,NSLStartServicesLookup
,NSLStandardRegisterURL
, andNSLStandardDeregisterURL
.When you have no further use for a neighborhood, you can reclaim the memory allocated to it by calling
NSLFreeNeighborhood
.Special Considerations
Specifying protocols in the
protocolList
parameter is deprecated. If you specify protocols when other protocols are available, any use of the resulting neighborhood will not be limited to the protocols you specified. -
NSLMakeServicesRequestPB
Creates a request parameter block.
OSStatus NSLMakeServicesRequestPB ( NSLServicesList serviceList, NSLTypedDataPtr * newDataPtr);
Parameters
- serviceList
On input, a value of type
NSLServicesList
created by previously callingNSLMakeNewServicesList
.- newDataPtr
On input, the address of the
NSLTypedDataPtr
- function result
A value of
noErr
indicates that the parameter block was created successfully. Possible errors includekNSLBadDomainErr
.
Discussion
This utility function creates a parameter block formatted properly for use with subsequent calls to
NSLStartServicesLookup
. -
NSLMakeNewServicesList
Creates a services list.
NSLServicesList NSLMakeNewServicesList ( char* initialServiceList);
Parameters
- initialServiceList
On input, a pointer to a comma-delimited, null-terminated string of service names, such as
http,ftp
.- function result
A value of type
NSLServicesList
. This function returnsNULL
if it can’t create the services list because, for example, there is not enough memory or because the Network Services Location Manager is not initialized.
Discussion
This function creates a services list and fills it with the names of the services specified by the
initialServiceList
parameter. After creating the services list, you can add the names of additional services by callingNSLAddServiceToServicesList
.Special Considerations
When you have no further use for the services list, you should reclaim the memory allocated to it by calling
NSLDisposeServicesList
. -
NSLOpenNavigationAPI
Opens a session with the Network Services Location Manager.
OSStatus NSLOpenNavigationAPI ( NSLClientRef * newRef);
Parameters
- newRef
On input, a pointer to a value of type
NSLClientRef
in which the Network Services Location Manager places a client reference. Pass the client reference toNSLPrepareRequest
andNSLCloseNavigationAPI
.- function result
A value of
noErr
indicates that the session was opened successfully. IfNSLOpenNavigationAPI
returns any of the following error codes, your application should not call any other Network Services Location Manager functions:kNSLNotInitialized
,kNSLInsufficientSysVer
,kNSLInsufficientOTVer
,kNSLPluginLoadFailed
, orkNSL68kContextNotSupported
.
Discussion
This function opens a session with the Network Services Location Manager and returns a client reference that your application later uses to prepare search requests and to close the Network Services Location Manager session. You must call
NSLOpenNavigationAPI
before calling any other Network Services Location Manager functions. NSLPrepareRequest
Creates a search request.
NSLError NSLPrepareRequest ( NSLClientNotifyUPP notifier, void * contextPtr, NSLClientRef theClient, NSLRequestRef * ref, char * bufPtr, unsigned long bufLen, NSLClientAsyncInfoPtr * infoPtr);
Parameters
- notifier
On input, a value of type
NSLClientNotifyUPP
that points to your application’s notification routine, orNULL
. Your notification routine will be called when data is available, when the search is complete, or when an error occurs.- contextPtr
On input, an untyped pointer to arbitrary data that the Network Services Location Manager will pass to your application’s notification routine when that routine is called. Your application can use
contextPtr
to associate any particular execution of your notification routine with any particular search request.- theClient
On input, a value of type
NSLClientRef
obtained by previously callingNSLOpenNavigationAPI
that identifies the Network Services Location Manager session for which this request is being prepared.- ref
On input, a pointer to a value of type
NSLRequestRef
in which the resulting search request reference is to be placed.- bufPtr
On input, a pointer to the buffer in which search results are to be placed.
- bufLen
On input, the length of the buffer pointed to by
bufPtr
.- infoPtr
On output, the
NSLClientAsyncInfo
structure pointed to byinfoPtr
contains default instructions for how the search is to be conducted. Your application can change the defaults before it starts the search.- function result
An
NSLError
theErr
field contains the result code. If the value ofNSLError.theErr
isnoErr
, the request was created. Other possible values includekNSLNotInitialized
,kNSLDuplicateSearchInProgress
,kNSLBadClientInfoPtr
, andkNSLErrNullPtrError
(if the value ofinfoPtr
isNULL
). CallNSLErrorToString
to get a problem and a solution string.
Discussion
This function creates a search request that your application later provides as a parameter when it calls
NSLStartNeighborhoodLookup
orNSLStartServicesLookup
. Searches are conducted asynchronously.Your application’s notification routine will be called when the result buffer contains data, the result buffer is full, when the search is complete, or when an error occurs. Your application can cause your application’s notification routine to be called at a specified interval, when a specified number of items is in the result buffer, or when a specified amount of time has elapsed by modifying the value of the
alertInterval
,alertThreshold
, andmaxSearchTime
fields, respectively, of theNSLClientAsyncInfo
structure pointed to byinfoPtr
.If this function returns a result code of
kNSLDuplicateSearchInProgress
, a search is in progress that is using a request reference that is identical to the newly created request reference. Your application can ignore this warning and use the newly created request reference, delete the newly created request reference, or cancel the search that is using the identical request reference.Special Considerations
When your application no longer needs the request reference, it should call
NSLDeleteRequest
to reclaim memory associated with it.NSLStandardDeregisterURL
Deregisters a service.
OSStatus NSLStandardDeregisterURL ( NSLPath urlToDeregister, NSLNeighborhood neighborhoodToDeregisterIn);
Parameters
- urlToDeregister
On input, a value of type
NSLPath
specifying the URL that is to be deregistered.- neighborhoodToDeregisterIn
On input, a value of type
NSLNeighborhood
specifying the neighborhood in which to deregister the service, orNULL
. IfNULL
is specified, the Network Services Location Manager determines the neighborhood from which the service is deregistered.- function result
A value of
noErr
indicates that the service was deregistered. A value ofkNSLBadURLSyntax
indicates that the URL contains characters that are not allowed, such as spaces. To encode characters that are not allowed, callNSLHexEncodeText
.
Discussion
This function deregisters the service specified by
urlToDeregister
. An application that registers services by callingNSLStandardRegisterURL
should call this function as part of its standard shutdown procedure.Special Considerations
You do not have to call
NSLOpenNavigationAPI
before calling this function.This function is available in version 1.1 of the Network Services Location Manager and later, and supersedes the
NSLDeRegisterService
function, which was provided in version 1.0.NSLStandardGetURL
Displays a dialog box that searches for services and allows the selection of a URL.
OSStatus NSLStandardGetURL ( NSLDialogOptions * dialogOptions, NSLEventUPP eventProc, void * eventProcContextPtr, NSLURLFilterUPP filterProc, char * serviceTypeList, char ** userSelectedURL);
Parameters
- dialogOptions
On input, a pointer to an
NSLDialogOptions
whose fields control the appearance of the dialog box. Before calling this function, callNSLGetDefaultDialogOptions
to fill the fields of yourNSLDialogOptions
structure with the default values. Then customize the values of the fields of theNSLDialogOptions
structure as desired.- eventProc
On input, a value of type
NSLEventUPP
that points to an application-defined system event callback, NSLEventProcPtr, orNULL
. IfeventProc
isNULL
, your application will not receive update events while theNSLStandardGetURL
dialog box is displayed.- eventProcContextPtr
On input, an untyped pointer to arbitrary data that the Network Services Location Manager passes to the system event callback specified by
eventProc
. Your application can useeventProcContextPtr
to associate any particular execution of your system event callback function with any particular call to this function.- filterProc
On input, a value of type
NSLURLFilterUPP
that specifies your filter callback function, NSLFilterProcPtr, orNULL
if you do not have a filter callback function. If specified, your filter callback function will be called for each URL that is about to be displayed in the dialog box. If your filter callback function returnsTRUE
, the URL is displayed in theNSLStandardGetURL
dialog box. If your filter callback function returnsFALSE
, the URL is not displayed.- userSelectedURL
On input, the address of a pointer to a string that will receive the URL that the user may select or enter. On output, if this function returns
noErr
,userSelectedURL
contains the null-terminated URL the user selected. When your application no longer needsuserSelectedURL
, it should callNSLFreeURL
to reclaim the memory associated with it.- serviceTypeList
On input, a null-terminated string of tuples that describes the services that are to be searched for. See the Discussion section for a description of the format and for information on how to use
serviceTypeList
to control the icon that is displayed for each service type.- function result
A value of
noErr
indicates that the user selected a URL, which is stored in theuserSelectedURL
parameter. A value ofkNSLUserCanceled
indicates that the user clicked the Cancel button in the dialog box; theuserSelectedURL
parameter is empty.
Discussion
This function displays a dialog box that allows the user to select the type of service that is to be searched for and the neighborhood in which the search is to be conducted. The calling application is responsible for specifying the list of services types, and the Network Services Location Manager is responsible for displaying the neighborhoods, which it obtains by querying Open Directory.
The
serviceTypeList
parameter consists of service names and service descriptor lists in the following format: service-name,
service-descriptor-list;
where service-descriptor-list is a comma-delimited list of services. For example, if you want to search for HTTP, HTTPS, and FTP services, the value ofserviceTypeList
would beWeb Servers,http,https;FTP Servers,ftp
SettingserviceTypeList
in this way would cause the Show pop-up menu in the dialog box displayed by this function to contain two items: “Web Servers” and “FTP Servers”. The result of a search performed on these two items would consist of the list of HTTP and HTTPS services that were found, followed by the list of FTP services that were found.This function displays a unique icon for each of the http, https, ftp, afp, lpr, LaserWriter, and AFPServer service descriptors and the same generic icon for any other service descriptor. You can have your own icon displayed by specifying an icon suite resource ID in the
serviceTypeList
parameter. For example, if the value ofserviceTypeList
isWeb Servers,http,https;Telnet Servers,telnet;NFS Servers,nfs,129
the Network Services Location Manager’s unique icons will be displayed for HTTP and HTTPS services, the Network Services Location Manager’s generic icon will be displayed for Telnet services, and the icon suite at resource ID 129 in your application’s resource fork will be displayed for NFS services.
Special Considerations
Be sure to dispose of the
userSelectedURL
parameter by callingNSLFreeURL
whenuserSelectedURL
is no longer needed.NSLStandardRegisterURL
Registers the URL of a service.
OSStatus NSLStandardRegisterURL ( NSLPath urlToRegister, NSLNeighborhood neighborhoodToRegisterIn);
Parameters
- urlToRegister
On input, a value of type
NSLPath
specifying the URL to register.- neighborhoodToRegisterIn
On input, a value of type
NSLNeighborhood
specifying the neighborhood in which to register the service, orNULL
. IfNULL
is specified, the Network Services Location Manager determines the neighborhood in which the URL is registered.- function result
A value of
noErr
indicates that the service was registered. A value ofkNSLBadURLSyntax
indicates that the URL contains characters that are not allowed, such as spaces. To encode characters that are not allowed, callNSLHexEncodeText
.
Discussion
This function registers the specified URL with the Network Services Location Manager.
Applications that provide a network service typically call this function as part of their startup procedure. They also call
NSLStandardDeregisterURL
as part of their shutdown procedure.Special Considerations
You do not have to call
NSLOpenNavigationAPI
This function is available in version 1.1 and later of the Network Services Location Manager, and supersedes the
NSLRegisterService
function, which was provided in version 1.0.NSLStartNeighborhoodLookup
Starts a search for neighborhoods.
NSLError NSLStartNeighborhoodLookup ( NSLRequestRef ref, NSLNeighborhood neighborhood, NSLClientAsyncInfo *asyncInfo);
Parameters
- ref
On input, a value of type
NSLRequestRef
created by previously callingNSLPrepareRequest
.- neighborhood
On input,
NULL
or anNSLNeighborhood
value created by previously callingNSLMakeNewNeighborhood
. PassingNULL
or aneighborhood
parameter that was created with aname
parameter whose value wasNULL
causes this function to get the default neighborhoods. Ifneighborhood
was created with a value ofname
that is the name of a neighborhood, this function gets names related to that neighborhood. For example, ifneighborhood
was created withname
set to “apple.com”, this function gets the subdomains of apple.com.- asyncInfo
On input, a pointer to an
NSLClientAsyncInfo
structure. Neighborhoods that are found will be stored in the structure’sresultBuffer
field.- function result
An
NSLError
structure whosetheErr
field contains the result code. If the value ofNSLError.theErr
isnoErr
, this function successfully started a neighborhood search. Possible errors arekNSLNotInitialized
,kNSLSearchAlreadyInProgress
,kNSLNoPluginsForSearch
,kNSLBufferTooSmallForData
, andkNSLNullNeighborhoodPtr
. CallNSLErrorToString
to get a problem and a solution string.
Discussion
This function starts a search for neighborhoods that your application can use to define the scope of a subsequent service search. The result of the search is returned to your application in the
resultBuffer
field of theNSLClientAsyncInfo
structure pointed to by theasyncInfo
parameter when the Network Services Location Manager calls your application’s notification routine. CallNSLGetNextNeighborhood
to process the data in the result buffer. To cancel an ongoing search, callNSLCancelRequest
. To delete a search request reference, callNSLDeleteRequest
.When the Network Services Location Manager calls your application’s notification routine, it should check the value of the
searchState
field of theNSLClientAsyncInfo
structure pointed to by theasyncInfo
parameter. ThesearchState
field will contain one of these values:kNSLSearchStateBufferFull
,kNSLSearchStateOnGoing
,kNSLSearchStateComplete
, orkNSLSearchStateStalled
.
If the value of the searchState field is
kNSLSearchStatausBufferFull
, your application’s notification routine should process the data returned in theresultBuffer
field of theNSLClientAsyncInfo
structure and return.If the value of the
searchState
field iskNSLSearchStateOnGoing
, the threshold set by the value of thealertInterval
field or thealertThreshold
field of theNSLClientAsyncInfo
structure has been reached. Your application’s notification routine should process the data returned in theresultBuffer
field of theNSLClientAsyncInfo
structure and return.If the value of the
searchState
field iskNSLSearchStateComplete
and the value ofNSLError.theErr
returned byNSLStartNeighborhoodLookup
isnoErr
, the search is complete. Your application’s notification routine should process the data returned inresultBuffer
and return. If the value of thesearchState
field iskNSLSearchStateComplete
and the value ofNSLError.theErr
returned byNSLStartNeighborhoodLookup
is notnoErr
, the error is a fatal error and the search has ended.If the value of the
searchState
field iskNSLSearchStateStalled
, the threshold set by the value of thealertInterval
field or themaxSearchTime
field of theNSLClientAsyncInfo
structure has been reached and there is no data in the result buffer. The Network Services Location Manager plug-ins that are processing this neighborhood search request are waiting to receive data from a server and may eventually time out. You can cancel the request by callingNSLCancelRequest
.If the value of
NSLError.theErr
returned by this function iskNSLBufferTooSmallForData
, the value of themaxBufferSize
field of theNSLClientAsyncInfo
structure is too small to hold data that would otherwise have been returned. Your notification routine can cancel the search, modify the size of the buffer, and restart the search, or it can ignore the error and return, thereby resuming the search even though some data has been lost.Special Considerations
For any request reference, only one neighborhood or service search can be in progress at any one time.
If this function returns an error, the
resultBuffer
field of theNSLClientAsyncInfo
structure may still contain valid data that was collected before the error occurred. Your notification routine should process the data in the result buffer and return, thereby continuing the search.NSLStartServicesLookup
NSLError NSLStartServicesLookup ( NSLRequestRef ref, NSLNeighborhood neighborhood, NSLTypedDataPtr requestData, NSLClientAsyncInfo *asyncInfo);
Parameters
- ref
On input, a value of type
NSLRequestRef
containing a request reference obtained by previously callingNSLPrepareRequest
.- neighborhood
On input,
NULL
or anNSLNeighborhood
value created by previously callingNSLMakeNewNeighborhood
. PassingNULL
or a neighborhood created with aname
parameter whose value wasNULL
causes this function to start a search for top-level services.- requestData
On input, a value of type
NSLTypedDataPtr
requestData
properly, callNSLMakeServicesRequestPB
.- asyncInfo
On input, a pointer to a
NSLClientAsyncInfo
structure obtained by previously callingNSLPrepareRequest
.- function result
An
NSLError
theErr
field contains the result code. If the value ofNSLError.theErr
isnoErr
, this function successfully started a service search. Other possible values arekNSLNotInitialized
,kNSLSearchAlreadyInProgress
,kNSLNoPluginsForSearch
,kNSLNullNeighborhoodPtr
, andkNSLBufferTooSmallForData
. CallNSLErrorToString
to get a problem and a solution string.
Discussion
This function starts a service search. The result of the search is returned to your application in the
resultBuffer
field of theNSLClientAsyncInfo
structure pointed to by theasyncInfo
parameter when the Network Services Location Manager calls your application’s notification routine. CallNSLGetNextURL
to process the data in the result buffer. To cancel an ongoing search, callNSLCancelRequest
. To delete a search request reference, callNSLDeleteRequest
.When the Network Services Location Manager calls your application’s notification routine, it should check the value of the
searchState
field of theNSLClientAsyncInfo
structure pointed to by theasyncInfo
parameter. ThesearchState
field will contain one of these values:kNSLSearchStateBufferFull
,kNSLSearchStateOnGoing
,kNSLSearchStateComplete
, orkNSLSearchStateStalled
.
If the value of the
searchState
field iskNSLSearchStatausBufferFull
, your application’s notification routine should process the data in theresultBuffer
field of theNSLClientAsyncInfo
structure and return.If the value of the
searchState
field iskNSLSearchStateOnGoing
, the threshold set by the value of thealertInterval
field or thealertThreshold
field of theNSLClientAsyncInfo
structure has been reached. Your application’s notification routine should process the data in theresultBuffer
field and return.If the value of the
searchState
field iskNSLSearchStateComplete
and the value ofNSLError.theErr
returned byNSLStartServicesLookup
isnoErr
, the search is complete. Your application’s notification routine should process the data returned inresultBuffer
and return. If the value of thesearchState
field iskNSLSearchStateComplete
and the value ofNSLError.theErr
returned byNSLStartServicesLookup
is notnoErr
, the error is a fatal error and the search has ended.If the value of the
searchState
field iskNSLSearchStateStalled
, the threshold set by the value of thealertInterval
field or themaxSearchTime
field of theNSLClientAsyncInfo
structure has been reached and there is no data in the result buffer. The Network Services Location Manager plug-ins that are processing this request are waiting to receive data from a server and may eventually time out. You can cancel the request by callingNSLCancelRequest
. If the value of thesearchState
field isnoErr
, your application’s notification routine should ignore the notification and return immediately, thereby resuming the search.If the value of
NSLError.theErr
returned by this function iskNSLBufferTooSmallForData
, the value of themaxBufferSize
field of theNSLClientAsyncInfo
structure is too small to hold data that would otherwise have been placed in the result buffer. Your application’s notification routine can cancel the search, modify the size of the buffer, and start the lookup again, or it can ignore the error and return, thereby resuming the search even though some data has been lost.Special Considerations
For any request reference, only one neighborhood or service search can be ongoing at any one time.
If this function returns an error, the
resultBuffer
field of theNSLClientAsyncInfo
structure may still contain valid data that was collected before the error occurred. Your notification routine should process the data in the result buffer and return, thereby continuing the search.-
NSLServiceIsInServiceList
Determines whether a service is in a services list.
Boolean NSLServiceIsInServiceList ( NSLServicesList serviceList, NSLServiceType svcToFind);
Parameters
- serviceList
On input, a value of type
NSLServicesList
created by previously callingNSLMakeNewServicesList
.- svcToFind
On input, a value of type
NSLServiceType
specifying the service that is to be checked.- function result
A value of
TRUE
indicates that the service specified bysvcToFind
is in the services list specified byserviceList
; otherwise, the value returned isFALSE
.
Discussion
This utility function determines whether the service specified by
svcToFind
is in the services list specified byserviceList
.
Copyright © 2006 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2006-05-23