r3463: separated out some more headers (asn_1.h, messages.h, dlinklist.h and ioctl.h)
[sfrench/samba-autobuild/.git] / source4 / 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
27 NTSTATUS ntvfs_async_state_push(struct smbsrv_request *req,
28                                 void *private_data,
29                                 void (*send_fn)(struct smbsrv_request *),
30                                 struct ntvfs_module_context *ntvfs)
31 {
32         struct ntvfs_async_state *async;
33
34         async = talloc_p(req, struct ntvfs_async_state);
35         if (!async) {
36                 return NT_STATUS_NO_MEMORY;
37         }
38
39         async->state            = req->async_states->state;
40         async->private_data     = private_data;
41         async->send_fn          = send_fn;
42         async->status           = NT_STATUS_INTERNAL_ERROR;
43
44         async->ntvfs            = ntvfs;
45
46         DLIST_ADD(req->async_states, async);
47
48         return NT_STATUS_OK;
49 }
50
51 void ntvfs_async_state_pop(struct smbsrv_request *req)
52 {
53         struct ntvfs_async_state *async;
54
55         async = req->async_states;
56
57         DLIST_REMOVE(req->async_states, async);
58
59         req->async_states->state        = async->state;
60         req->async_states->status       = async->status;
61
62         talloc_free(async);
63 }