OpenSLP Programmers Guide - SLPFindAttrs

About
what is openslp

Download
how to get openslp

Contribute
how to help out

Documentation
how to find out more

Credits
who to blame

## SLPFindAttrs
OpenSLP Programmer's Guide » Service Location Functions » SLPFindAttrs

### Declaration

    #include <slp.h>

    SLPEXP SLPError SLPAPISLPFindAttrs(
        SLPHandle      hslp,
        const char *    srvurl,
        const char *    scopelist,
        const char *    attrids,
        SLPAttrCallback callback,
        void *          cookie);

### Description

This function returns service attributes matching the `attrids` for the indicated Service URL or service type. OpenSLP does not support location of attributes by service type with `attrids` containing wildcards (see status below).

### Parameters

`hslp` | The language specific `SLPHandle` on which to search for attributes the service.
`srvurl` | The service URL of the service to the attributes of. See Syntax for more information SLP Service URLs.
`attrids` | A comma separated list of attribute ids to return. Use the empty string ("") for all attributes. Wildcards are not supported.
`scopelist` | A pointer to a comma separated list of scope names. May be the empty string if you wish to use scopes this machine is configured for..
`callback` | The address of an SLPAttrCallback function that will be called to report the results of the operation. May not be NULL. See Callbacks for more information on how callbacks are used by the SLPAPI.
`cookie` | Pointer to memory that gets passed to the callback code. May be NULL.

### Returns

SLP_OK | Indicates that the no error occurred during the operation.
SLP_PARSE_ERROR | 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.
SLP_AUTHENTICATION_ABSENT | If the SLP framework supports authentication, this error arises when the UA or SA failed to send an authenticator for requests or registrations.
SLP_AUTHENTICATION_FAILED | If the SLP framework supports authentication, this error arises when a authentication on an SLP message failed.
SLP_NETWORK_TIMED_OUT | When no reply can be obtained in the time specified by the configured timeout interval for a unicast request, this error is returned. In other words, slpd is running, but something is wrong with it
SLP_NETWORK_INIT_FAILED | 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. slpd must be running in order to call SLPReg() or SLPDereg().
SLP_MEMORY_ALLOC_FAILED | Out of memory error
SLP_PARAMETER_BAD | If a parameter passed into a function is bad, this error is returned.
SLP_NETWORK_ERROR | The failure of networking during normal operations causes this error to be returned. In OpenSLP, this is the error you'll get if an underlying socket() call failed.
SLP_INTERNAL_SYSTEM_ERROR | 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.
SLP_HANDLE_IN_USE | 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.

If no service types can be found, no error is returned. However, no calls (other than the SLP_LAST_CALL) will be made to the SLPSrvTypesCallback. Be aware, especially if the call is async, of error codes that may be passed to the `SLPAttrCallback` callback function.

### Status

OpenSLP 0.9.1 | Fully implemented as specified by RFC2614 except for finding attributes by service type or with attrids containing wildcards. These behaviors are expected to be depreciated in the next RFC 2614 revision.

### See Also

SLPSrvTypeCallback, Syntax, Callbacks

### Example Code

      #include <slp.h>

      SLPBoolean myAttrCallback(
          SLPHandle hslp,
          const char* attrlist,
          SLPError errcode,
          void* cookie )
      {
          if(errcode == SLP_OK)
          {
              printf("%s\n",attrlist);
          }

          return SLP_FALSE;
      }

      int main(int argc, char* argv[])
      {
          SLPError    result;
          SLPHandle   hslp;

          if(SLPOpen("en",SLP_FALSE,&hslp) == SLP_OK)
          {
              result =
                  SLPFindAttrs(
                      hslp,
                      "service:myservice.x://myhost.mydomain.org"
                      "", /* return all attributes */
                      "", /* use configured scopes */
                      myAttrCallback,
                      NULL);

              if(result != SLP_OK)
              {
                  printf("errorcode: %i\n",result);
              }

              result =
                  SLPFindAttrs(
                      hslp,
                      "service:myservice.x://myhost.mydomain.org"
                      "attr1,attr2", /* return attr1 and attr1 only */
                      "", /* use configured scopes */
                      myAttrCallback,
                      NULL);

              if(result != SLP_OK)
              {
                  printf("errorcode: %i\n",result);
              }

              SLPClose(hslp);
          }
      }

Prepared by: Caldera Systems Inc
Maintained by: openslp.org