1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-09-22 04:15:55 -04:00

Feature: Added a basic igloo_initialize()

This commit is contained in:
Philipp Schafft 2018-11-01 08:53:27 +00:00
parent 0d8749c0c6
commit 26221864dd
2 changed files with 86 additions and 0 deletions

View File

@ -29,6 +29,24 @@ extern "C" {
/* Put stuff here */
#include "ro.h"
/*
* This initializes libigloo. This MUST BE called before any
* other functions can be called.
*
* Returns a refobject on success or igloo_RO_NULL on failure.
* This can be called multiple times (e.g. by the application
* and by the libraries it uses independently).
*
* The library is deinitialized when the last reference
* to a returned object is gone. This happens by
* calling igloo_ro_unref() on the last reference.
*
* All igloo_ro_*() functions can be used on this object.
*/
igloo_ro_t igloo_initialize(void);
#ifdef __cplusplus
}
#endif

View File

@ -1 +1,69 @@
/* Copyright (C) 2018 Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include "../include/igloo/typedef.h"
typedef struct igloo_instance_tag igloo_instance_t;
#define igloo_RO_PRIVATETYPES igloo_RO_TYPE(igloo_instance_t)
#include "../include/igloo/ro.h"
struct igloo_instance_tag {
igloo_ro_base_t __base;
};
static size_t igloo_initialize__refc;
static void igloo_initialize__free(igloo_ro_t self)
{
igloo_initialize__refc--;
if (igloo_initialize__refc)
return;
/* TODO: Add any uninit code here. */
}
igloo_RO_PRIVATE_TYPE(igloo_instance_t,
igloo_RO_TYPEDECL_FREE(igloo_initialize__free)
);
igloo_ro_t igloo_initialize(void)
{
igloo_instance_t *ret;
char name[128];
if (!igloo_initialize__refc) {
/* TODO: Add any init code here. */
}
snprintf(name, sizeof(name), "<libigloo instance %zu>", igloo_initialize__refc);
ret = igloo_ro_new_raw(igloo_instance_t, name, igloo_RO_NULL);
if (!ret)
return igloo_RO_NULL;
igloo_initialize__refc++;
return ret;
}