~ubuntu-branches/ubuntu/natty/globus-gridftp-server/natty-updates

« back to all changes in this revision

Viewing changes to dsi_bones/globus_gridftp_server_dsi.c.in

  • Committer: Bazaar Package Importer
  • Author(s): Mattias Ellert
  • Date: 2009-08-07 07:24:28 UTC
  • Revision ID: james.westby@ubuntu.com-20090807072428-0bb06irrkoi81fu1
Tags: upstream-3.17
ImportĀ upstreamĀ versionĀ 3.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 1999-2006 University of Chicago
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 * 
 
8
 * http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
#include "globus_gridftp_server.h"
 
18
 
 
19
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
20
 *  ADD ADDITIONAL INCLUDES HERE
 
21
 *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
 
22
 
 
23
static
 
24
globus_version_t local_version =
 
25
{
 
26
    0, /* major version number */
 
27
    1, /* minor version number */
 
28
    @DATE@,
 
29
    0 /* branch ID */
 
30
};
 
31
 
 
32
typedef struct globus_l_gfs_@DSI@_handle_s
 
33
{
 
34
    int                                 some_needed_data;
 
35
} globus_l_gfs_@DSI@_handle_t;
 
36
 
 
37
/*************************************************************************
 
38
 *  start
 
39
 *  -----
 
40
 *  This function is called when a new session is initialized, ie a user 
 
41
 *  connectes to the server.  This hook gives the dsi an oppertunity to
 
42
 *  set internal state that will be threaded through to all other
 
43
 *  function calls associated with this session.  And an oppertunity to
 
44
 *  reject the user.
 
45
 *
 
46
 *  finished_info.info.session.session_arg should be set to an DSI
 
47
 *  defined data structure.  This pointer will be passed as the void *
 
48
 *  user_arg parameter to all other interface functions.
 
49
 * 
 
50
 *  NOTE: at nice wrapper function should exist that hides the details 
 
51
 *        of the finished_info structure, but it currently does not.  
 
52
 *        The DSI developer should jsut follow this template for now
 
53
 ************************************************************************/
 
54
static
 
55
void
 
56
globus_l_gfs_@DSI@_start(
 
57
    globus_gfs_operation_t              op,
 
58
    globus_gfs_session_info_t *         session_info)
 
59
{
 
60
    globus_l_gfs_@DSI@_handle_t *       @DSI@_handle;
 
61
    globus_gfs_finished_info_t          finished_info;
 
62
    GlobusGFSName(globus_l_gfs_@DSI@_start);
 
63
 
 
64
    @DSI@_handle = (globus_l_gfs_@DSI@_handle_t *)
 
65
        globus_malloc(sizeof(globus_l_gfs_@DSI@_handle_t));
 
66
 
 
67
    @DSI@_handle->some_needed_data = 0;
 
68
 
 
69
    memset(&finished_info, '\0', sizeof(globus_gfs_finished_info_t));
 
70
    finished_info.type = GLOBUS_GFS_OP_SESSION_START;
 
71
    finished_info.result = GLOBUS_SUCCESS;
 
72
    finished_info.info.session.session_arg = @DSI@_handle;
 
73
    finished_info.info.session.username = session_info->username;
 
74
    finished_info.info.session.home_dir = "/";
 
75
 
 
76
    globus_gridftp_server_operation_finished(
 
77
        op, GLOBUS_SUCCESS, &finished_info);
 
78
}
 
79
 
 
80
/*************************************************************************
 
81
 *  destroy
 
82
 *  -------
 
83
 *  This is called when a session ends, ie client quits or disconnects.
 
84
 *  The dsi should clean up all memory they associated wit the session
 
85
 *  here. 
 
86
 ************************************************************************/
 
87
static
 
88
void
 
89
globus_l_gfs_@DSI@_destroy(
 
90
    void *                              user_arg)
 
91
{
 
92
    globus_l_gfs_@DSI@_handle_t *       @DSI@_handle;
 
93
 
 
94
    @DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
 
95
 
 
96
    globus_free(@DSI@_handle);
 
97
}
 
98
 
 
99
/*************************************************************************
 
100
 *  stat
 
101
 *  ----
 
102
 *  This interface function is called whenever the server needs 
 
103
 *  information about a given file or resource.  It is called then an
 
104
 *  LIST is sent by the client, when the server needs to verify that 
 
105
 *  a file exists and has the proper permissions, etc.
 
106
 ************************************************************************/
 
107
static
 
108
void
 
109
globus_l_gfs_@DSI@_stat(
 
110
    globus_gfs_operation_t              op,
 
111
    globus_gfs_stat_info_t *            stat_info,
 
112
    void *                              user_arg)
 
113
{
 
114
    globus_gfs_stat_t                   stat_array[1];
 
115
    int                                 stat_count = 1;
 
116
    globus_l_gfs_@DSI@_handle_t *       @DSI@_handle;
 
117
    GlobusGFSName(globus_l_gfs_@DSI@_stat);
 
118
 
 
119
    @DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
 
120
 
 
121
    stat_array[0].mode = 0;
 
122
    stat_array[0].nlink = 0;
 
123
    stat_array[0].uid = 0;
 
124
    stat_array[0].gid = 0;
 
125
    stat_array[0].size = 0;
 
126
    stat_array[0].mtime = 0;
 
127
    stat_array[0].atime = 0;
 
128
    stat_array[0].ctime = 0;
 
129
    stat_array[0].dev = 0;
 
130
    stat_array[0].ino = 0;
 
131
 
 
132
    globus_gridftp_server_finished_stat(
 
133
        op, GLOBUS_SUCCESS, stat_array, stat_count);
 
134
}
 
135
 
 
136
/*************************************************************************
 
137
 *  command
 
138
 *  -------
 
139
 *  This interface function is called when the client sends a 'command'.
 
140
 *  commands are such things as mkdir, remdir, delete.  The complete
 
141
 *  enumeration is below.
 
142
 *
 
143
 *  To determine which command is being requested look at:
 
144
 *      cmd_info->command
 
145
 *
 
146
 *      GLOBUS_GFS_CMD_MKD = 1,
 
147
 *      GLOBUS_GFS_CMD_RMD,
 
148
 *      GLOBUS_GFS_CMD_DELE,
 
149
 *      GLOBUS_GFS_CMD_RNTO,
 
150
 *      GLOBUS_GFS_CMD_RNFR,
 
151
 *      GLOBUS_GFS_CMD_CKSM,
 
152
 *      GLOBUS_GFS_CMD_SITE_CHMOD,
 
153
 *      GLOBUS_GFS_CMD_SITE_DSI
 
154
 ************************************************************************/
 
155
static
 
156
void
 
157
globus_l_gfs_@DSI@_command(
 
158
    globus_gfs_operation_t              op,
 
159
    globus_gfs_command_info_t *         cmd_info,
 
160
    void *                              user_arg)
 
161
{
 
162
    globus_l_gfs_@DSI@_handle_t *       @DSI@_handle;
 
163
    GlobusGFSName(globus_l_gfs_@DSI@_command);
 
164
 
 
165
    @DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
 
166
 
 
167
    globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, GLOBUS_NULL);
 
168
}
 
169
 
 
170
/*************************************************************************
 
171
 *  recv
 
172
 *  ----
 
173
 *  This interface function is called when the client requests that a
 
174
 *  file be transfered to the server.
 
175
 *
 
176
 *  To receive a file the following functions will be used in roughly
 
177
 *  the presented order.  They are doced in more detail with the
 
178
 *  gridftp server documentation.
 
179
 *
 
180
 *      globus_gridftp_server_begin_transfer();
 
181
 *      globus_gridftp_server_register_read();
 
182
 *      globus_gridftp_server_finished_transfer();
 
183
 *
 
184
 ************************************************************************/
 
185
static
 
186
void
 
187
globus_l_gfs_@DSI@_recv(
 
188
    globus_gfs_operation_t              op,
 
189
    globus_gfs_transfer_info_t *        transfer_info,
 
190
    void *                              user_arg)
 
191
{
 
192
    globus_l_gfs_@DSI@_handle_t *       @DSI@_handle;
 
193
    GlobusGFSName(globus_l_gfs_@DSI@_recv);
 
194
 
 
195
    @DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
 
196
 
 
197
    globus_gridftp_server_finished_transfer(op, GLOBUS_SUCCESS);
 
198
}
 
199
 
 
200
/*************************************************************************
 
201
 *  send
 
202
 *  ----
 
203
 *  This interface function is called when the client requests to receive
 
204
 *  a file from the server.
 
205
 *
 
206
 *  To send a file to the client the following functions will be used in roughly
 
207
 *  the presented order.  They are doced in more detail with the
 
208
 *  gridftp server documentation.
 
209
 *
 
210
 *      globus_gridftp_server_begin_transfer();
 
211
 *      globus_gridftp_server_register_write();
 
212
 *      globus_gridftp_server_finished_transfer();
 
213
 *
 
214
 ************************************************************************/
 
215
static
 
216
void
 
217
globus_l_gfs_@DSI@_send(
 
218
    globus_gfs_operation_t              op,
 
219
    globus_gfs_transfer_info_t *        transfer_info,
 
220
    void *                              user_arg)
 
221
{
 
222
    globus_l_gfs_@DSI@_handle_t *       @DSI@_handle;
 
223
    GlobusGFSName(globus_l_gfs_@DSI@_send);
 
224
 
 
225
    @DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
 
226
 
 
227
    globus_gridftp_server_finished_transfer(op, GLOBUS_SUCCESS);
 
228
}
 
229
 
 
230
static
 
231
int
 
232
globus_l_gfs_@DSI@_activate(void);
 
233
 
 
234
static
 
235
int
 
236
globus_l_gfs_@DSI@_deactivate(void);
 
237
 
 
238
/*
 
239
 *  no need to change this
 
240
 */
 
241
static globus_gfs_storage_iface_t       globus_l_gfs_@DSI@_dsi_iface = 
 
242
{
 
243
    GLOBUS_GFS_DSI_DESCRIPTOR_BLOCKING | GLOBUS_GFS_DSI_DESCRIPTOR_SENDER,
 
244
    globus_l_gfs_@DSI@_start,
 
245
    globus_l_gfs_@DSI@_destroy,
 
246
    NULL, /* list */
 
247
    globus_l_gfs_@DSI@_send,
 
248
    globus_l_gfs_@DSI@_recv,
 
249
    NULL, /* trev */
 
250
    NULL, /* active */
 
251
    NULL, /* passive */
 
252
    NULL, /* data destroy */
 
253
    globus_l_gfs_@DSI@_command, 
 
254
    globus_l_gfs_@DSI@_stat,
 
255
    NULL,
 
256
    NULL
 
257
};
 
258
 
 
259
/*
 
260
 *  no need to change this
 
261
 */
 
262
GlobusExtensionDefineModule(globus_gridftp_server_@DSI@) =
 
263
{
 
264
    "globus_gridftp_server_@DSI@",
 
265
    globus_l_gfs_@DSI@_activate,
 
266
    globus_l_gfs_@DSI@_deactivate,
 
267
    NULL,
 
268
    NULL,
 
269
    &local_version
 
270
};
 
271
 
 
272
/*
 
273
 *  no need to change this
 
274
 */
 
275
static
 
276
int
 
277
globus_l_gfs_@DSI@_activate(void)
 
278
{
 
279
    globus_extension_registry_add(
 
280
        GLOBUS_GFS_DSI_REGISTRY,
 
281
        "@DSI@",
 
282
        GlobusExtensionMyModule(globus_gridftp_server_@DSI@),
 
283
        &globus_l_gfs_@DSI@_dsi_iface);
 
284
    
 
285
    return 0;
 
286
}
 
287
 
 
288
/*
 
289
 *  no need to change this
 
290
 */
 
291
static
 
292
int
 
293
globus_l_gfs_@DSI@_deactivate(void)
 
294
{
 
295
    globus_extension_registry_remove(
 
296
        GLOBUS_GFS_DSI_REGISTRY, "@DSI@");
 
297
 
 
298
    return 0;
 
299
}