File: globus_xio_load.h

package info (click to toggle)
globus-xio 5.14-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,144 kB
  • ctags: 3,031
  • sloc: ansic: 46,655; sh: 11,358; perl: 1,598; makefile: 358
file content (116 lines) | stat: -rw-r--r-- 4,325 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * Copyright 1999-2006 University of Chicago
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef GLOBUS_XIO_LOAD_INCLUDE
#define GLOBUS_XIO_LOAD_INCLUDE

#include "globus_xio_types.h"
#include "globus_common.h"

#ifdef __cplusplus
extern "C" {
#endif

extern globus_extension_registry_t      globus_i_xio_driver_registry;
#define GLOBUS_XIO_DRIVER_REGISTRY &globus_i_xio_driver_registry

typedef
globus_result_t
(*globus_xio_driver_init_t)(
    globus_xio_driver_t *               out_driver);

typedef
void
(*globus_xio_driver_destroy_t)(
    globus_xio_driver_t                 driver);

typedef struct
{
    const char *                        name;
    globus_xio_driver_init_t            init;
    globus_xio_driver_destroy_t         destroy;
} globus_xio_driver_hook_t;

globus_result_t
globus_xio_driver_load(
    const char *                        driver_name,
    globus_xio_driver_t *               out_driver);

globus_result_t
globus_xio_driver_unload(
    globus_xio_driver_t                 driver);

/**
 * GlobusXIODefineDriver(
 *      label                           driver_name,
 *      globus_xio_driver_init_t        init_func,
 *      globus_xio_driver_destroy_t     destroy_func)
 * 
 *  NOTE: driver_name is not a string.  Just put the unquoted name there.
 *  This needs to precede use of GlobusXIO{Un}RegisterDriver()
 */
#define GlobusXIODefineDriver(driver_name, init_func, destroy_func)         \
globus_xio_driver_hook_t globus_i_xio_##driver_name##_hook =                \
{                                                                           \
    #driver_name,                                                           \
    init_func,                                                              \
    destroy_func,                                                           \
}
#define GlobusXIODeclareDriver(driver_name)                                 \
    extern globus_xio_driver_hook_t globus_i_xio_##driver_name##_hook
#define GlobusXIOMyDriver(driver_name)                                      \
    &globus_i_xio_##driver_name##_hook

/**
 * The following are just utility macros for extensions that contain only one
 * driver.  If your extension contains multiple drivers, you'll need to
 * define your own extension module and register all the drivers in that
 * module's activate function manually
 */
#define GlobusXIORegisterDriver(driver_name)                                \
    globus_extension_registry_add(                                          \
        GLOBUS_XIO_DRIVER_REGISTRY,                                         \
        (void *)#driver_name,                                               \
        GlobusXIOMyModule(driver_name),                                     \
        GlobusXIOMyDriver(driver_name))
#define GlobusXIOUnRegisterDriver(driver_name)                              \
    globus_extension_registry_remove(                                       \
        GLOBUS_XIO_DRIVER_REGISTRY,                                         \
        (void*)#driver_name)

#define GlobusXIODefineModule(driver_name)                                  \
    GlobusExtensionDefineModule(globus_xio_##driver_name##_driver)
#define GlobusXIODeclareModule(driver_name)                                 \
    GlobusExtensionDeclareModule(globus_xio_##driver_name##_driver)
#define GlobusXIOMyModule(driver_name)                                      \
    GlobusExtensionMyModule(globus_xio_##driver_name##_driver)
#define GlobusXIOExtensionName(driver_name)                                 \
    "globus_xio_" #driver_name "_driver"

#define GLOBUS_XIO_EXTENSION_FORMAT "globus_xio_%s_driver"

/* internal activate funcs */
int
globus_i_xio_load_init(void);

int
globus_i_xio_load_destroy(void);
    
#ifdef __cplusplus
}
#endif

#endif