/* $Id$ * captive vfs 'vfs' interface to reactos * Copyright (C) 2002-2003 Jan Kratochvil * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; exactly version 2 of June 1991 is required * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "config.h" #include "captive/client-vfs.h" /* self */ #include "vfs.h" /* self-priv */ #include #include "captive/macros.h" #include "captive/sandbox.h" #include "init.h" static gpointer captive_vfs_object_parent_class=NULL; static GnomeVFSResult captive_vfs_close(CaptiveVfsObject *captive_vfs_object); static void captive_vfs_object_finalize(CaptiveVfsObject *captive_vfs_object) { GnomeVFSResult errvfsresult; g_return_if_fail(captive_vfs_object!=NULL); errvfsresult=captive_vfs_close(captive_vfs_object); g_assert(errvfsresult==GNOME_VFS_OK); G_OBJECT_CLASS(captive_vfs_object_parent_class)->finalize((GObject *)captive_vfs_object); } static void captive_vfs_object_class_init(CaptiveVfsObjectClass *class) { GObjectClass *gobject_class=G_OBJECT_CLASS(class); captive_vfs_object_parent_class=g_type_class_ref(G_TYPE_OBJECT); gobject_class->finalize=(void (*)(GObject *object))captive_vfs_object_finalize; } static void captive_vfs_object_init(CaptiveVfsObject *captive_vfs_object) { CAPTIVE_MEMZERO(&captive_vfs_object->options); } GType captive_vfs_object_get_type(void) { static GType captive_vfs_object_type=0; if (!captive_vfs_object_type) { static const GTypeInfo captive_vfs_object_info={ sizeof(CaptiveVfsObjectClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc)captive_vfs_object_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof(CaptiveVfsObject), 5, /* n_preallocs */ (GInstanceInitFunc)captive_vfs_object_init, }; captive_vfs_object_type=g_type_register_static(G_TYPE_OBJECT, "CaptiveVfsObject",&captive_vfs_object_info,0); } return captive_vfs_object_type; } GnomeVFSResult captive_vfs_new (CaptiveVfsObject **captive_vfs_object_return,const struct captive_options *options) { CaptiveVfsObject *captive_vfs_object; gboolean errbool; g_return_val_if_fail(captive_vfs_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(options!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); *captive_vfs_object_return=NULL; captive_vfs_object=g_object_new( CAPTIVE_VFS_TYPE_OBJECT, /* object_type */ NULL); /* first_property_name; FIXME: support properties */ captive_options_copy(&captive_vfs_object->options,options); g_assert(captive_options==NULL); captive_options=&captive_vfs_object->options; errbool=captive_init(); g_assert(errbool==TRUE); *captive_vfs_object_return=captive_vfs_object; return GNOME_VFS_OK; } static GnomeVFSResult captive_vfs_close(CaptiveVfsObject *captive_vfs_object) { gboolean errbool; if (CAPTIVE_IS_SANDBOX_PARENT()) return captive_sandbox_parent_vfs_close(captive_vfs_object); g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_assert(captive_options==&captive_vfs_object->options); errbool=captive_shutdown(); g_assert(errbool==TRUE); captive_options=NULL; captive_options_free(&captive_vfs_object->options); return GNOME_VFS_OK; }