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.

283 lines
11 KiB

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.77C-CCK-MCD Caldera Systems OpenLinux [en] (X11; U; Linux 2.4.2 i686) [Netscape]">
<title>OpenSLP Programmers Guide - SLPFindSrvs()</title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EF" vlink="#51188E" alink="#FF0000">
<h2>
SLPFindSrvs</h2>
<hr WIDTH="100%">
<h3>
Declaration</h3>
<tt>#include &lt;slp.h></tt>
<p><tt><a href="SLPError.html">SLPError</a> SLPFindSrvs( <a href="SLPTypes.html#SLPHandle">SLPHandle</a>
<a href="#hslp">hslp</a>,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const char* <a href="#srvtype">srvtype</a>,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const char* <a href="#scopelist">scopelist</a>,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const char* <a href="#filter">filter</a>,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="SLPSrvURLCallback.html">SLPSrvURLCallback</a> callback,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
void* <a href="#cookie">cookie</a>)</tt>
<h3>
Description</h3>
Issue a query for services.
<br>&nbsp;
<h3>
Parameters</h3>
<table BORDER CELLPADDING=5 NOSAVE >
<tr VALIGN=TOP NOSAVE>
<td NOSAVE><a NAME="hslp"></a><tt>hslp</tt></td>
<td NOSAVE>The language specific <tt>SLPHandle</tt> on which to register
the service.</td>
</tr>
<tr VALIGN=TOP NOSAVE>
<td><a NAME="srvtype"></a><tt>srvtype</tt></td>
<td NOSAVE>The service type string, including the authority string (if
any) for the request.&nbsp; May not be the empty string, "". May not be
NULL.&nbsp; See <a href="Syntax.html">Syntax</a> more information on Service
Type syntax.&nbsp;</td>
</tr>
<tr VALIGN=TOP NOSAVE>
<td><a NAME="scopelist"></a><tt>scopelist</tt></td>
<td NOSAVE>A pointer to a comma separated list of scope names.&nbsp; <i>May
be the empty string </i>if you wish to use scopes this machine is configured
for..&nbsp;</td>
</tr>
<tr VALIGN=TOP NOSAVE>
<td NOSAVE><a NAME="filter"></a><tt>filter</tt></td>
<td>A query formulated of attribute pattern matching expressions in the
form of an LDAPv3 search filter.&nbsp; Pass in&nbsp; the empty string,
"" for all services of the requested type.&nbsp; See <a href="Syntax.html">Syntax</a>
for more information on LDAP3 search filter syntax.</td>
</tr>
<tr VALIGN=TOP NOSAVE>
<td><a NAME="callback"></a><tt>callback</tt></td>
<td NOSAVE>The address of an <a href="SLPSrvURLCallback.html">SLPSrvURLCallback</a>
function that will be called to report the results of the query.&nbsp;
May not be NULL. See <a href="Callbacks.html">Callbacks</a> for more information
on how callbacks are used by the SLPAPI.</td>
</tr>
<tr VALIGN=TOP NOSAVE>
<td NOSAVE><a NAME="cookie"></a><tt>cookie</tt></td>
<td NOSAVE>Pointer to memory that gets passed to the callback code.&nbsp;
May be NULL.</td>
</tr>
</table>
<h3>
Returns</h3>
<table BORDER NOSAVE >
<tr NOSAVE>
<td NOSAVE>SLP_OK</td>
<td>Indicates that the no error occurred during the operation.</td>
</tr>
<tr>
<td>SLP_PARSE_ERROR</td>
<td>The SLP message was rejected by a remote SLP agent. The API returns
this error only when no information was retrieved, and at least one SA
or DA indicated a protocol error. The data supplied through the API may
be malformed or a may have been damaged in transit.</td>
</tr>
<tr>
<td>SLP_AUTHENTICATION_ABSENT</td>
<td>If the SLP framework supports authentication, this error arises when
the UA or SA failed to send an authenticator for requests or registrations.</td>
</tr>
<tr>
<td>SLP_AUTHENTICATION_FAILED</td>
<td>If the SLP framework supports authentication, this error arises when
a authentication on an SLP message failed.</td>
</tr>
<tr>
<td>SLP_NETWORK_TIMED_OUT</td>
<td>When no reply can be obtained in the time specified by the configured
timeout interval for a unicast request, this error is returned.&nbsp; In
other words, slpd is running, but something is wrong with it</td>
</tr>
<tr>
<td>SLP_NETWORK_INIT_FAILED</td>
<td>If the network cannot initialize properly, this error is returned.
Will also be returned if an SA or DA agent (slpd) can not be contacted.&nbsp;
slpd must be running in order to call SLPReg() or SLPDereg().</td>
</tr>
<tr>
<td>SLP_MEMORY_ALLOC_FAILED&nbsp;</td>
<td>Out of memory error</td>
</tr>
<tr>
<td>SLP_PARAMETER_BAD</td>
<td>If a parameter passed into a function is bad, this error is returned.</td>
</tr>
<tr>
<td>SLP_NETWORK_ERROR</td>
<td>The failure of networking during normal operations causes this error
to be returned.&nbsp; In OpenSLP, this is the error you'll get if an underlying
socket() call failed.</td>
</tr>
<tr>
<td>SLP_INTERNAL_SYSTEM_ERROR</td>
<td>A basic failure of the API causes this error to be returned. This occurs
when a system call or library fails. The operation could not recover.</td>
</tr>
<tr>
<td>SLP_HANDLE_IN_USE</td>
<td>Callback functions are not permitted to recursively call into the API
on the same SLPHandle, either directly or indirectly. If an attempt is
made to do so, this error is returned from the called API function.</td>
</tr>
</table>
<p>If no services can be found, no error is returned.&nbsp; However, no
calls (other than the SLP_LAST_CALL) will be made to the SLPSrvURLCallback.&nbsp;
Be aware, especially if the call is async, of error codes that may be passed
to the <tt>SLPSrvURLCallback</tt> callback function.
<br>&nbsp;
<h3>
Status</h3>
<table CELLPADDING=5 NOSAVE >
<tr VALIGN=TOP NOSAVE>
<td NOSAVE>OpenSLP 0.9.1</td>
<td NOSAVE>Implemented as specified by RFC 2614.</td>
</tr>
</table>
<h3>
See Also</h3>
<a href="Syntax.html">Syntax</a>, <a href="Callbacks.html">Callbacks</a>
<br>&nbsp;
<h3>
Example Code</h3>
<blockquote><tt>#include &lt;slp.h></tt>
<p><tt>SLPBoolean MySLPSrvURLCallback( SLPHandle hslp,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const char* srvurl,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
unsigned short lifetime,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
SLPError errcode,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
void* cookie )</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; if(errcode == SLP_OK || errcode == SLP_LAST_CALL)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Service URL&nbsp;&nbsp;&nbsp;&nbsp;
= %s\n",srvurl);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Service Timeout
= %i\n",lifetime);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *(SLPError*)cookie =
SLP_OK;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp; else</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *(SLPError*)cookie =
errcode;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<p><tt>&nbsp;&nbsp;&nbsp; /* return SLP_TRUE because we want to be called
again */</tt>
<br><tt>&nbsp;&nbsp;&nbsp; /* if more services were found&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
*/</tt>
<p><tt>&nbsp;&nbsp;&nbsp; return SLP_TRUE;</tt>
<br><tt>}</tt>
<p><tt>int main( int argc, char* argv[])</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; SLPError err;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; SLPError callbackerr;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; SLPHandle hslp;</tt>
<p><tt>&nbsp;&nbsp;&nbsp; err = SLPOpen("en",SLP_FALSE,&amp;hslp);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; if(err != SLP_OK)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Error opening
slp handle %i\n",err);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return err;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<br>&nbsp;
<p><tt>&nbsp;&nbsp;&nbsp; err = SLPFindSrvs( hslp,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"myservice.myorg",</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/* use configured scopes */</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/* no attr filter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
MySLPSrvURLCallback,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;callbackerr );</tt>
<p><tt>&nbsp;&nbsp;&nbsp; /* err may contain an error code that occurred
as the slp library&nbsp;&nbsp;&nbsp; */</tt>
<br><tt>&nbsp;&nbsp;&nbsp; /* _prepared_ to make the call.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
*/</tt>
<br><tt>&nbsp;&nbsp;&nbsp; if((err != SLP_OK) || (callbackerr != SLP_OK))</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Error registering
service with slp %i\n",err);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return err;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<p><tt>&nbsp;&nbsp;&nbsp; /* callbackerr may contain an error code (that
was assigned through */</tt>
<br><tt>&nbsp;&nbsp;&nbsp; /* the callback cookie) that occurred as slp
packets were sent on&nbsp;&nbsp;&nbsp; */</tt>
<br><tt>&nbsp;&nbsp;&nbsp; /* the wire */</tt>
<br><tt>&nbsp;&nbsp;&nbsp; if( callbackerr != SLP_OK)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Error registering
service with slp %i\n",callbackerr);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return callbackerr;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<p><tt>&nbsp;&nbsp;&nbsp; /* Now that we're done using slp, close the slp
handle */</tt>
<br><tt>&nbsp;&nbsp;&nbsp; SLPClose(hslp);</tt>
<br>&nbsp;
<p><tt>&nbsp;&nbsp;&nbsp; /* rest of program */</tt>
<br><tt>}</tt></blockquote>
</body>
</html>