From e1892e63c2e74fa997a99cbc3a26a9c60d652025 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 20 Jun 2011 20:32:02 +0300 Subject: [PATCH] gobex: Add initial stubs --- gobex/gobex.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ gobex/gobex.h | 35 +++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 gobex/gobex.c create mode 100644 gobex/gobex.h diff --git a/gobex/gobex.c b/gobex/gobex.c new file mode 100644 index 000000000..8ae23b8aa --- /dev/null +++ b/gobex/gobex.c @@ -0,0 +1,66 @@ +/* + * + * OBEX library with GLib integration + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "gobex.h" + +struct _GObex { + gint ref_count; + GIOChannel *io; +}; + +GObex *g_obex_new(GIOChannel *io) +{ + GObex *obex; + + if (io == NULL) + return NULL; + + obex = g_new0(GObex, 1); + + obex->io = io; + obex->ref_count = 1; + + return obex; +} + +GObex *g_obex_ref(GObex *obex) +{ + if (obex == NULL) + return NULL; + + g_atomic_int_inc(&obex->ref_count); + + return obex; +} + +void g_obex_unref(GObex *obex) +{ + gboolean last_ref; + + last_ref = g_atomic_int_dec_and_test(&obex->ref_count); + + if (!last_ref) + return; + + g_io_channel_unref(obex->io); + + g_free(obex); +} diff --git a/gobex/gobex.h b/gobex/gobex.h new file mode 100644 index 000000000..cdc7f77eb --- /dev/null +++ b/gobex/gobex.h @@ -0,0 +1,35 @@ +/* + * + * OBEX library with GLib integration + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __GOBEX_H +#define __GOBEX_H + +#include +#include + +typedef struct _GObex GObex; + +GObex *g_obex_new(GIOChannel *io); + +GObex *g_obex_ref(GObex *obex); +void g_obex_unref(GObex *obex); + +#endif /* __GOBEX_H */ -- 2.47.3