r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the
[jelmer/samba4-debian.git] / source / ntvfs / ntvfs_util.c
1 /* 
2    Unix SMB/CIFS implementation.
3    NTVFS utility code
4    Copyright (C) Stefan Metzmacher 2004
5
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.
10    
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.
15    
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.
19 */
20 /*
21   this implements common utility functions that many NTVFS backends may wish to use
22 */
23
24 #include "includes.h"
25 #include "dlinklist.h"
26 #include "smb_server/smb_server.h"
27
28
29 NTSTATUS ntvfs_async_state_push(struct smbsrv_request *req,
30                                 void *private_data,
31                                 void (*send_fn)(struct smbsrv_request *),
32                                 struct ntvfs_module_context *ntvfs)
33 {
34         struct ntvfs_async_state *async;
35
36         async = talloc(req, struct ntvfs_async_state);
37         if (!async) {
38                 return NT_STATUS_NO_MEMORY;
39         }
40
41         async->state            = req->async_states->state;
42         async->private_data     = private_data;
43         async->send_fn          = send_fn;
44         async->status           = NT_STATUS_INTERNAL_ERROR;
45
46         async->ntvfs            = ntvfs;
47
48         DLIST_ADD(req->async_states, async);
49
50         return NT_STATUS_OK;
51 }
52
53 void ntvfs_async_state_pop(struct smbsrv_request *req)
54 {
55         struct ntvfs_async_state *async;
56
57         async = req->async_states;
58
59         DLIST_REMOVE(req->async_states, async);
60
61         req->async_states->state        = async->state;
62         req->async_states->status       = async->status;
63
64         talloc_free(async);
65 }