⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libslp_findattrs.c

📁 SLP协议在linux下的实现。此版本为1.2.1版。官方网站为www.openslp.org
💻 C
📖 第 1 页 / 共 2 页
字号:
					  cookie);	    break;	}	else	#endif	sock = NetworkConnectToDA(handle,                                  handle->params.findattrs.scopelist,                                  handle->params.findattrs.scopelistlen,                                  &peeraddr);        if(sock == -1)        {            /* use multicast as a last resort */                        #ifndef MI_NOT_SUPPORTED            result = NetworkMcastRqstRply(handle,                                          buf,                                          SLP_FUNCT_ATTRRQST,                                          bufsize,                                          ProcessAttrRplyCallback,                                          NULL);            #else		    result = NetworkMcastRqstRply(handle->langtag,                                          buf,                                          SLP_FUNCT_ATTRRQST,                                          bufsize,                                          ProcessAttrRplyCallback,                                          handle);            #endif /* MI_NOT_SUPPORTED */			            break;        }        result = NetworkRqstRply(sock,                                 &peeraddr,                                 handle->langtag,                                 0,                                 buf,                                 SLP_FUNCT_ATTRRQST,                                 bufsize,                                 ProcessAttrRplyCallback,                                 handle);        if(result)        {            NetworkDisconnectDA(handle);        }    }while(result == SLP_NETWORK_ERROR);    FINISHED:    if(buf) xfree(buf);#ifdef ENABLE_SLPv2_SECURITY    if(spistr) xfree(spistr);#endif    return result;}#ifdef ENABLE_ASYNC_API/*-------------------------------------------------------------------------*/ SLPError AsyncProcessAttrRqst(PSLPHandleInfo handle)/*-------------------------------------------------------------------------*/{    SLPError result = ProcessAttrRqst(handle);    xfree((void*)handle->params.findattrs.url);    xfree((void*)handle->params.findattrs.scopelist);    xfree((void*)handle->params.findattrs.taglist);    handle->inUse = SLP_FALSE;    return result;}#endif/*=========================================================================*/SLPError SLPAPI SLPFindAttrs(SLPHandle   hSLP,                      const char *pcURLOrServiceType,                      const char *pcScopeList,                      const char *pcAttrIds,                      SLPAttrCallback callback,                      void *pvCookie)/*                                                                         *//* This function returns service attributes matching the attribute ids     *//* for the indicated service URL or service type.  If pcURLOrServiceType   *//* is a service URL, the attribute information returned is for that        *//* particular advertisement in the language locale of the SLPHandle.       *//*                                                                         *//* If pcURLOrServiceType is a service type name (including naming          *//* authority if any), then the attributes for all advertisements of that   *//* service type are returned regardless of the language of registration.   *//* Results are returned through the callback.                              *//*                                                                         *//* The result is filtered with an SLP attribute request filter string      *//* parameter, the syntax of which is described in RFC 2608. If the filter  *//* string is the empty string, i.e.  "", all attributes are returned.      *//*                                                                         *//* hSLP                 The language specific SLPHandle on which to search *//*                      for attributes.                                    *//*                                                                         *//* pcURLOrServiceType   The service URL or service type.  See RFC 2608 for *//*                      URL and service type syntax.  May not be the empty *//*                      string.                                            *//*                                                                         *//* pcScopeList          A pointer to a char containing a comma separated   *//*                      list of scope names. Pass in NULL or the empty     *//*                      string "" to find services in all the scopes the   *//*                      local host is configured query.                    *//*                                                                         *//* pcAttrIds            A comma separated list of attribute ids to return. *//*                      Use NULL or the empty string, "", to indicate all  *//*                      values. Wildcards are not currently supported      *//*                                                                         *//* callback             A callback function through which the results of   *//*                      the operation are reported.                        *//*                                                                         *//* pvCookie             Memory passed to the callback code from the client.*/  /*                      May be NULL.                                       *//*                                                                         *//* Returns:             If an error occurs in starting the operation, one  *//*                      of the SLPError codes is returned.                 *//*=========================================================================*/{    PSLPHandleInfo      handle;    SLPError            result;    /*------------------------------*/    /* check for invalid parameters */    /*------------------------------*/    if(hSLP == 0 ||       *(unsigned int*)hSLP != SLP_HANDLE_SIG ||       pcURLOrServiceType == 0 ||       *pcURLOrServiceType == 0 ||        callback == 0)    {        return SLP_PARAMETER_BAD;    }    /*-----------------------------------------*/    /* cast the SLPHandle into a SLPHandleInfo */    /*-----------------------------------------*/    handle = (PSLPHandleInfo)hSLP;     /*-----------------------------------------*/    /* Check to see if the handle is in use    */    /*-----------------------------------------*/    if(handle->inUse == SLP_TRUE)    {        return SLP_HANDLE_IN_USE;    }    handle->inUse = SLP_TRUE;    /*-------------------------------------------*/    /* Set the handle up to reference parameters */    /*-------------------------------------------*/    handle->params.findattrs.urllen   = strlen(pcURLOrServiceType);    handle->params.findattrs.url      = pcURLOrServiceType;    if(pcScopeList && *pcScopeList)    {        handle->params.findattrs.scopelistlen = strlen(pcScopeList);        handle->params.findattrs.scopelist    = pcScopeList;    }    else    {        handle->params.findattrs.scopelist    = SLPGetProperty("net.slp.useScopes");        handle->params.findattrs.scopelistlen = strlen(handle->params.findattrs.scopelist);    }    if(pcAttrIds && *pcAttrIds)    {        handle->params.findattrs.taglistlen = strlen(pcAttrIds);        handle->params.findattrs.taglist    = pcAttrIds;    }    else    {        handle->params.findattrs.taglistlen = 0;        handle->params.findattrs.taglist    = (char*)&handle->params.findattrs.taglistlen;    }    handle->params.findattrs.callback   = callback;    handle->params.findattrs.cookie     = pvCookie;     /*----------------------------------------------*/    /* Check to see if we should be async or sync   */    /*----------------------------------------------*/#ifdef ENABLE_ASYNC_API    if(handle->isAsync)    {        /* COPY all the referenced parameters */        handle->params.findattrs.url = xstrdup(handle->params.findattrs.url);        handle->params.findattrs.scopelist = xstrdup(handle->params.findattrs.scopelist);        handle->params.findattrs.taglist = xstrdup(handle->params.findattrs.taglist);        /* make sure strdups did not fail */        if(handle->params.findattrs.url &&           handle->params.findattrs.scopelist &&           handle->params.findattrs.taglist)        {            result = ThreadCreate((ThreadStartProc)AsyncProcessAttrRqst,handle);        }        else        {            result = SLP_MEMORY_ALLOC_FAILED;            }        if(result)        {            if(handle->params.findattrs.url) xfree((void*)handle->params.findattrs.url);            if(handle->params.findattrs.scopelist) xfree((void*)handle->params.findattrs.scopelist);            if(handle->params.findattrs.taglist) xfree((void*)handle->params.findattrs.taglist);            handle->inUse = SLP_FALSE;        }    }    else#endif /* ifdef ENABLE_ASYNC_API */    {        /* Leave all parameters REFERENCED */        result = ProcessAttrRqst(handle);        handle->inUse = SLP_FALSE;    }    return result;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -