2
* Copyright 1999-2006 University of Chicago
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
#include "globus_gridftp_server.h"
19
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
20
* ADD ADDITIONAL INCLUDES HERE
21
*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
24
globus_version_t local_version =
26
0, /* major version number */
27
1, /* minor version number */
32
typedef struct globus_l_gfs_@DSI@_handle_s
35
} globus_l_gfs_@DSI@_handle_t;
37
/*************************************************************************
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
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.
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
************************************************************************/
56
globus_l_gfs_@DSI@_start(
57
globus_gfs_operation_t op,
58
globus_gfs_session_info_t * session_info)
60
globus_l_gfs_@DSI@_handle_t * @DSI@_handle;
61
globus_gfs_finished_info_t finished_info;
62
GlobusGFSName(globus_l_gfs_@DSI@_start);
64
@DSI@_handle = (globus_l_gfs_@DSI@_handle_t *)
65
globus_malloc(sizeof(globus_l_gfs_@DSI@_handle_t));
67
@DSI@_handle->some_needed_data = 0;
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 = "/";
76
globus_gridftp_server_operation_finished(
77
op, GLOBUS_SUCCESS, &finished_info);
80
/*************************************************************************
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
86
************************************************************************/
89
globus_l_gfs_@DSI@_destroy(
92
globus_l_gfs_@DSI@_handle_t * @DSI@_handle;
94
@DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
96
globus_free(@DSI@_handle);
99
/*************************************************************************
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
************************************************************************/
109
globus_l_gfs_@DSI@_stat(
110
globus_gfs_operation_t op,
111
globus_gfs_stat_info_t * stat_info,
114
globus_gfs_stat_t stat_array[1];
116
globus_l_gfs_@DSI@_handle_t * @DSI@_handle;
117
GlobusGFSName(globus_l_gfs_@DSI@_stat);
119
@DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
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;
132
globus_gridftp_server_finished_stat(
133
op, GLOBUS_SUCCESS, stat_array, stat_count);
136
/*************************************************************************
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.
143
* To determine which command is being requested look at:
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
************************************************************************/
157
globus_l_gfs_@DSI@_command(
158
globus_gfs_operation_t op,
159
globus_gfs_command_info_t * cmd_info,
162
globus_l_gfs_@DSI@_handle_t * @DSI@_handle;
163
GlobusGFSName(globus_l_gfs_@DSI@_command);
165
@DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
167
globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, GLOBUS_NULL);
170
/*************************************************************************
173
* This interface function is called when the client requests that a
174
* file be transfered to the server.
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.
180
* globus_gridftp_server_begin_transfer();
181
* globus_gridftp_server_register_read();
182
* globus_gridftp_server_finished_transfer();
184
************************************************************************/
187
globus_l_gfs_@DSI@_recv(
188
globus_gfs_operation_t op,
189
globus_gfs_transfer_info_t * transfer_info,
192
globus_l_gfs_@DSI@_handle_t * @DSI@_handle;
193
GlobusGFSName(globus_l_gfs_@DSI@_recv);
195
@DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
197
globus_gridftp_server_finished_transfer(op, GLOBUS_SUCCESS);
200
/*************************************************************************
203
* This interface function is called when the client requests to receive
204
* a file from the server.
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.
210
* globus_gridftp_server_begin_transfer();
211
* globus_gridftp_server_register_write();
212
* globus_gridftp_server_finished_transfer();
214
************************************************************************/
217
globus_l_gfs_@DSI@_send(
218
globus_gfs_operation_t op,
219
globus_gfs_transfer_info_t * transfer_info,
222
globus_l_gfs_@DSI@_handle_t * @DSI@_handle;
223
GlobusGFSName(globus_l_gfs_@DSI@_send);
225
@DSI@_handle = (globus_l_gfs_@DSI@_handle_t *) user_arg;
227
globus_gridftp_server_finished_transfer(op, GLOBUS_SUCCESS);
232
globus_l_gfs_@DSI@_activate(void);
236
globus_l_gfs_@DSI@_deactivate(void);
239
* no need to change this
241
static globus_gfs_storage_iface_t globus_l_gfs_@DSI@_dsi_iface =
243
GLOBUS_GFS_DSI_DESCRIPTOR_BLOCKING | GLOBUS_GFS_DSI_DESCRIPTOR_SENDER,
244
globus_l_gfs_@DSI@_start,
245
globus_l_gfs_@DSI@_destroy,
247
globus_l_gfs_@DSI@_send,
248
globus_l_gfs_@DSI@_recv,
252
NULL, /* data destroy */
253
globus_l_gfs_@DSI@_command,
254
globus_l_gfs_@DSI@_stat,
260
* no need to change this
262
GlobusExtensionDefineModule(globus_gridftp_server_@DSI@) =
264
"globus_gridftp_server_@DSI@",
265
globus_l_gfs_@DSI@_activate,
266
globus_l_gfs_@DSI@_deactivate,
273
* no need to change this
277
globus_l_gfs_@DSI@_activate(void)
279
globus_extension_registry_add(
280
GLOBUS_GFS_DSI_REGISTRY,
282
GlobusExtensionMyModule(globus_gridftp_server_@DSI@),
283
&globus_l_gfs_@DSI@_dsi_iface);
289
* no need to change this
293
globus_l_gfs_@DSI@_deactivate(void)
295
globus_extension_registry_remove(
296
GLOBUS_GFS_DSI_REGISTRY, "@DSI@");