diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-05-21 18:04:47 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-05-21 18:04:47 +0200 |
commit | 20796bcf57a7f5e1921dc12e0568221f985fe4f2 (patch) | |
tree | 8f0540a602a9ea0031d656bc31c0b8bc1e91eb70 /source3/smbd/fake_file.c | |
parent | 323be4a6907e4915bb76aa103bf5b868f0b459b1 (diff) | |
parent | 1a416ff13ca7786f2e8d24c66addf00883e9cb12 (diff) | |
download | samba-20796bcf57a7f5e1921dc12e0568221f985fe4f2.tar.gz samba-20796bcf57a7f5e1921dc12e0568221f985fe4f2.tar.bz2 samba-20796bcf57a7f5e1921dc12e0568221f985fe4f2.zip |
Merge branch 'v3-3-test' of ssh://git.samba.org/data/git/samba into docbook
Conflicts:
source/Makefile.in
(This used to be commit 01987778a123f853fccdcb7fe9566143e2d7c490)
Diffstat (limited to 'source3/smbd/fake_file.c')
-rw-r--r-- | source3/smbd/fake_file.c | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 0a54c85cd0..565b557dd3 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -21,52 +21,52 @@ extern struct current_user current_user; -static FAKE_FILE fake_files[] = { +struct fake_file_type { + const char *name; + enum FAKE_FILE_TYPE type; + void *(*init_pd)(TALLOC_CTX *mem_ctx); +}; + +static struct fake_file_type fake_files[] = { #ifdef WITH_QUOTAS - {FAKE_FILE_NAME_QUOTA_UNIX, FAKE_FILE_TYPE_QUOTA, init_quota_handle, destroy_quota_handle}, + {FAKE_FILE_NAME_QUOTA_UNIX, FAKE_FILE_TYPE_QUOTA, init_quota_handle}, #endif /* WITH_QUOTAS */ - {NULL, FAKE_FILE_TYPE_NONE, NULL, NULL } + {NULL, FAKE_FILE_TYPE_NONE, NULL} }; /**************************************************************************** Create a fake file handle ****************************************************************************/ -static struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) +static struct fake_file_handle *init_fake_file_handle(enum FAKE_FILE_TYPE type) { - TALLOC_CTX *mem_ctx = NULL; - FAKE_FILE_HANDLE *fh = NULL; + struct fake_file_handle *fh = NULL; int i; - for (i=0;fake_files[i].name!=NULL;i++) { + for (i=0; fake_files[i].name!=NULL; i++) { if (fake_files[i].type==type) { - DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name)); - - if ((mem_ctx=talloc_init("fake_file_handle"))==NULL) { - DEBUG(0,("talloc_init(fake_file_handle) failed.\n")); - return NULL; - } + break; + } + } - if ((fh =TALLOC_ZERO_P(mem_ctx, FAKE_FILE_HANDLE))==NULL) { - DEBUG(0,("TALLOC_ZERO() failed.\n")); - talloc_destroy(mem_ctx); - return NULL; - } + if (fake_files[i].name == NULL) { + return NULL; + } - fh->type = type; - fh->mem_ctx = mem_ctx; + DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name)); - if (fake_files[i].init_pd) { - fh->pd = fake_files[i].init_pd(fh->mem_ctx); - } + fh = talloc(NULL, struct fake_file_handle); + if (fh == NULL) { + DEBUG(0,("TALLOC_ZERO() failed.\n")); + return NULL; + } - fh->free_pd = fake_files[i].free_pd; + fh->type = type; - return fh; - } + if (fake_files[i].init_pd) { + fh->private_data = fake_files[i].init_pd(fh); } - - return NULL; + return fh; } /**************************************************************************** @@ -147,18 +147,12 @@ NTSTATUS open_fake_file(connection_struct *conn, return NT_STATUS_OK; } -void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh) +void destroy_fake_file_handle(struct fake_file_handle **fh) { - if (!fh||!(*fh)) { + if (!fh) { return; } - - if ((*fh)->free_pd) { - (*fh)->free_pd(&(*fh)->pd); - } - - talloc_destroy((*fh)->mem_ctx); - (*fh) = NULL; + TALLOC_FREE(*fh); } NTSTATUS close_fake_file(files_struct *fsp) |