2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2004
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 this implements common utility functions that many NTVFS backends may wish to use
25 #include "dlinklist.h"
26 #include "smb_server/smb_server.h"
27 #include "ntvfs/ntvfs.h"
30 _PUBLIC_ struct ntvfs_request *ntvfs_request_create(struct ntvfs_context *ctx, TALLOC_CTX *mem_ctx,
31 struct auth_session_info *session_info,
32 uint16_t smbpid, uint16_t smbmid,
33 struct timeval request_time,
35 void (*send_fn)(struct ntvfs_request *),
38 struct ntvfs_request *req;
39 struct ntvfs_async_state *async;
41 req = talloc(mem_ctx, struct ntvfs_request);
42 if (!req) return NULL;
44 req->async_states = NULL;
45 req->session_info = session_info;
48 req->statistics.request_time = request_time;
50 async = talloc(req, struct ntvfs_async_state);
51 if (!async) goto failed;
54 async->private_data = private_data;
55 async->send_fn = send_fn;
56 async->status = NT_STATUS_INTERNAL_ERROR;
59 DLIST_ADD(req->async_states, async);
67 _PUBLIC_ NTSTATUS ntvfs_async_state_push(struct ntvfs_module_context *ntvfs,
68 struct ntvfs_request *req,
70 void (*send_fn)(struct ntvfs_request *))
72 struct ntvfs_async_state *async;
74 async = talloc(req, struct ntvfs_async_state);
75 NT_STATUS_HAVE_NO_MEMORY(async);
77 async->state = req->async_states->state;
78 async->private_data = private_data;
79 async->send_fn = send_fn;
80 async->status = NT_STATUS_INTERNAL_ERROR;
84 DLIST_ADD(req->async_states, async);
89 _PUBLIC_ void ntvfs_async_state_pop(struct ntvfs_request *req)
91 struct ntvfs_async_state *async;
93 async = req->async_states;
95 DLIST_REMOVE(req->async_states, async);
97 req->async_states->state = async->state;
98 req->async_states->status = async->status;