~ubuntu-branches/ubuntu/oneiric/osptoolkit/oneiric

« back to all changes in this revision

Viewing changes to src/ospinit.c

  • Committer: Bazaar Package Importer
  • Author(s): TransNexus, Inc.
  • Date: 2007-12-30 20:37:26 UTC
  • Revision ID: james.westby@ubuntu.com-20071230203726-dysah2e93yqd3vbp
Tags: upstream-3.4.2
ImportĀ upstreamĀ versionĀ 3.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
*** COPYRIGHT (c) 2002 by TransNexus, Inc.                              ***
 
3
***                                                                     ***
 
4
*** This software is property of TransNexus, Inc.                       ***
 
5
*** This software is freely available under license from TransNexus.    ***
 
6
*** The license terms and conditions for free use of this software by   ***
 
7
*** third parties are defined in the OSP Toolkit Software License       ***
 
8
*** Agreement (LICENSE.txt).  Any use of this software by third         ***
 
9
*** parties, which does not comply with the terms and conditions of the ***
 
10
*** OSP Toolkit Software License Agreement is prohibited without        ***
 
11
*** the prior, express, written consent of TransNexus, Inc.             ***
 
12
***                                                                     ***
 
13
*** Thank you for using the OSP ToolKit(TM).  Please report any bugs,   ***
 
14
*** suggestions or feedback to support@transnexus.com                   ***
 
15
***                                                                     ***
 
16
**************************************************************************/
 
17
 
 
18
 
 
19
 
 
20
 
 
21
 
 
22
 
 
23
 
 
24
 
 
25
/*
 
26
 * ospinit.cpp - Provider space initialization.
 
27
 */
 
28
#include "osp/osp.h"
 
29
#include "osp/ospprovider.h"
 
30
 
 
31
OSPTPROVIDER    OSPVProviderCollection[OSPC_MAX_PROVIDERS];
 
32
OSPTMUTEX       OSPVProviderMutex;
 
33
 
 
34
#ifdef OSPC_GK_SIM
 
35
char *OSPVDeleteAllowed;
 
36
#endif
 
37
 
 
38
 
 
39
/*
 
40
 * The OSPPInit function performs internal housekeeping necessary to 
 
41
 * prepare the SDK software for operation.
 
42
 *
 
43
 * returns OSPC_ERR_NO_ERROR if successful, OSPC_ERR_XXX otherwise.
 
44
 */
 
45
int
 
46
OSPPInit(OSPTBOOL hw_enabled)
 
47
{
 
48
    int         providerindex = 0;
 
49
    int         errorcode     = OSPC_ERR_NO_ERROR,
 
50
                tmperror      = OSPC_ERR_NO_ERROR;
 
51
 
 
52
    /*
 
53
     * create global provider mutex
 
54
     */
 
55
    OSPM_MUTEX_INIT(OSPVProviderMutex, NULL, errorcode);
 
56
    if (errorcode == OSPC_ERR_NO_ERROR) 
 
57
    {
 
58
        /*
 
59
         * cycle thru collection, initializing each element.
 
60
         */
 
61
        for(providerindex = 0; providerindex < OSPC_MAX_PROVIDERS; providerindex++)
 
62
        {
 
63
            OSPM_MEMSET(&OSPVProviderCollection[providerindex], 0, 
 
64
                sizeof(OSPTPROVIDER));
 
65
        }
 
66
 
 
67
        /*
 
68
         * initialize Winsock Library if necessary
 
69
         */
 
70
        OSPM_INITWINSOCK(errorcode);
 
71
 
 
72
        /*
 
73
         * if initialization failed, destroy the mutex and return failure
 
74
         */
 
75
        if (errorcode != OSPC_ERR_NO_ERROR)
 
76
            OSPM_MUTEX_DESTROY(OSPVProviderMutex, tmperror);
 
77
    }
 
78
 
 
79
    if (errorcode != OSPC_ERR_NO_ERROR)
 
80
        errorcode = OSPC_ERR_PROV_INIT_FAILURE;
 
81
 
 
82
#ifdef OSPC_GK_SIM
 
83
    if (errorcode == OSPC_ERR_NO_ERROR)
 
84
    {
 
85
        OSPVDeleteAllowed = OSPM_GETENV("GKSIM_DELETE_ALLOWED");
 
86
    }
 
87
#endif
 
88
 
 
89
    /*
 
90
     * Initialize openssl global parameters
 
91
     */
 
92
    OSPPOpenSSLInit(hw_enabled);
 
93
 
 
94
    return errorcode;
 
95
}
 
96
 
 
97
void
 
98
OSPPCleanup(void)
 
99
{
 
100
    int errorcode = OSPC_ERR_NO_ERROR;
 
101
 
 
102
    /*
 
103
     * called to cleanup any resources allocated by OSPPinit
 
104
     */
 
105
    OSPM_MUTEX_DESTROY(OSPVProviderMutex, errorcode);
 
106
    OSPM_CLEANUPWINSOCK();
 
107
 
 
108
    /*
 
109
     * Clean up openssl global parameters
 
110
     */
 
111
    OSPPOpenSSLCleanUp();
 
112
    return;
 
113
}