Example #1
0
DWORD
WSAAPI
WsTcLoadProvider(IN PTCATALOG Catalog,
                 IN PTCATALOG_ENTRY CatalogEntry)
{
    INT ErrorCode = ERROR_SUCCESS;
    PTPROVIDER Provider;

    /* Lock the catalog */
    WsTcLock();

    /* Check if we have a provider already */
    if (!CatalogEntry->Provider)
    {
        /* Try to find another instance */
        Provider = WsTcFindProvider(Catalog,
                                    &CatalogEntry->ProtocolInfo.ProviderId);

        /* Check if we found one now */
        if (Provider)
        {
            /* Set this one as the provider */
            WsTcEntrySetProvider(CatalogEntry, Provider);
            ErrorCode = ERROR_SUCCESS;
        }
        else
        {
            /* Nothing found, Allocate a provider */
            if ((Provider = WsTpAllocate()))
            {
                /* Initialize it */
                ErrorCode = WsTpInitialize(Provider,
                                           CatalogEntry->DllPath,
                                           &CatalogEntry->ProtocolInfo);

                /* Ensure success */
                if (ErrorCode == ERROR_SUCCESS)
                {
                    /* Set the provider */
                    WsTcEntrySetProvider(CatalogEntry, Provider);
                }

                /* Dereference it */
                WsTpDereference(Provider);
            }
            else
            {
                /* No memory */
                ErrorCode = WSA_NOT_ENOUGH_MEMORY;
            }
        }
    }

    /* Release the lock */
    WsTcUnlock();
    return ErrorCode;
}
Example #2
0
VOID
WSAAPI
WsTcEntryDelete(IN PTCATALOG_ENTRY CatalogEntry)
{
    /* Check if a provider is loaded */
    if (CatalogEntry->Provider)
    {
        /* Dereference it too */
        WsTpDereference(CatalogEntry->Provider);
        CatalogEntry->Provider = NULL;
    }

    /* Delete us */
    HeapFree(WsSockHeap, 0, CatalogEntry);
}