<commit_before>/*
 * Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Header$
 */

#include "gnome2perl.h"

/* ------------------------------------------------------------------------- */

void *
SvGnomeConfigIterator (SV *object)
{
	MAGIC *mg;

	if (!object || !SvOK (object) || !SvROK (object) || !(mg = mg_find (SvRV (object), PERL_MAGIC_ext)))
		return NULL;

	return (void *) mg->mg_ptr;
}

SV *
newSVGnomeConfigIterator (const char *app_id)
{
	SV *object = (SV *) newHV ();

	sv_magic (object, 0, PERL_MAGIC_ext, (const char *) app_id, 0);

	return sv_bless (newRV_noinc (object),
	                 gv_stashpv ("Gnome2::Config::Iterator", 1));
}

/* ------------------------------------------------------------------------- */

MODULE = Gnome2::Config	PACKAGE = Gnome2::Config	PREFIX = gnome_config_

char *
get_string (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_string = 0
	Gnome2::Config::get_translated_string = 1
	Gnome2::Config::Private::get_string = 2
	Gnome2::Config::Private::get_translated_string = 3
    CODE:
	switch (ix) {
		case 0: RETVAL = gnome_config_get_string (path); break;
		case 1: RETVAL = gnome_config_get_translated_string (path); break;
		case 2: RETVAL = gnome_config_private_get_string (path); break;
		case 3: RETVAL = gnome_config_private_get_translated_string (path); break;
	}
    OUTPUT:
	RETVAL
    CLEANUP:
	g_free (RETVAL);

=for apidoc

Returns a boolean indicating whether the default was used and the actual value.

=cut
void
get_string_with_default (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_string_with_default = 0
	Gnome2::Config::get_translated_string_with_default = 1
	Gnome2::Config::Private::get_string_with_default = 2
	Gnome2::Config::Private::get_translated_string_with_default = 3
    PREINIT:
	char *retval;
	gboolean def;
    PPCODE:
	switch (ix) {
		case 0: retval = gnome_config_get_string_with_default (path, &def); break;
		case 1: retval = gnome_config_get_translated_string_with_default (path, &def); break;
		case 2: retval = gnome_config_private_get_string_with_default (path, &def); break;
		case 3: retval = gnome_config_private_get_translated_string_with_default (path, &def); break;
	}

	EXTEND (sp, 1);
	PUSHs (sv_2mortal (newSVuv (def)));
	if (retval != NULL)
		XPUSHs (sv_2mortal (newSVpv (retval, PL_na)));

	g_free (retval);

int
get_int (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_int = 0
	Gnome2::Config::Private::get_int = 1
    CODE:
	switch (ix) {
		case 0: RETVAL = gnome_config_get_int (path); break;
		case 1: RETVAL = gnome_config_private_get_int (path); break;
	}
    OUTPUT:
	RETVAL

=for apidoc

Returns a boolean indicating whether the default was used and the actual value.

=cut
void
get_int_with_default (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_int_with_default = 0
	Gnome2::Config::Private::get_int_with_default = 1
    PREINIT:
	int retval;
	gboolean def;
    PPCODE:
	switch (ix) {
		case 0: retval = gnome_config_get_int_with_default (path, &def); break;
		case 1: retval = gnome_config_private_get_int_with_default (path, &def); break;
	}

	EXTEND (sp, 2);
	PUSHs (sv_2mortal (newSVuv (def)));
	PUSHs (sv_2mortal (newSViv (retval)));

gdouble
get_float (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_float = 0
	Gnome2::Config::Private::get_float = 1
    CODE:
	switch (ix) {
		case 0: RETVAL = gnome_config_get_float (path); break;
		case 1: RETVAL = gnome_config_private_get_float (path); break;
	}
    OUTPUT:
	RETVAL

=for apidoc

Returns a boolean indicating whether the default was used and the actual value.

=cut
# FIXME: seems to return integers instead of floats.
void
get_float_with_default (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_float_with_default = 0
	Gnome2::Config::Private::get_float_with_default = 1
    PREINIT:
	gdouble retval;
	gboolean def;
    PPCODE:
	switch (ix) {
		case 0: retval = gnome_config_get_float_with_default (path, &def); break;
		case 1: retval = gnome_config_private_get_float_with_default (path, &def); break;
	}

	EXTEND (sp, 2);
	PUSHs (sv_2mortal (newSVuv (def)));
	PUSHs (sv_2mortal (newSVnv (retval)));

gboolean
get_bool (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_bool = 0
	Gnome2::Config::Private::get_bool = 1
    CODE:
	switch (ix) {
		case 0: RETVAL = gnome_config_get_bool (path); break;
		case 1: RETVAL = gnome_config_private_get_bool (path); break;
	}
    OUTPUT:
	RETVAL

=for apidoc

Returns a boolean indicating whether the default was used and the actual value.

=cut
void
get_bool_with_default (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_bool_with_default = 0
	Gnome2::Config::Private::get_bool_with_default = 1
    PREINIT:
	gboolean retval;
	gboolean def;
    PPCODE:
	switch (ix) {
		case 0: retval = gnome_config_get_bool_with_default (path, &def); break;
		case 1: retval = gnome_config_private_get_bool_with_default (path, &def); break;
	}

	EXTEND (sp, 2);
	PUSHs (sv_2mortal (newSVuv (def)));
	PUSHs (sv_2mortal (newSVuv (retval)));

SV *
get_vector (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_vector = 0
	Gnome2::Config::Private::get_vector = 1
    PREINIT:
	char **argv = NULL;
	int argc, i;
	AV *array = newAV ();
    CODE:<commit_msg>initialize variables to avoid 'may be used uninitialized' warnings in functions with alias switches.  it's not likely that we'll trigger them, but it's nice to shut them up.<commit_after>/*
 * Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Header$
 */

#include "gnome2perl.h"

/* ------------------------------------------------------------------------- */

void *
SvGnomeConfigIterator (SV *object)
{
	MAGIC *mg;

	if (!object || !SvOK (object) || !SvROK (object) || !(mg = mg_find (SvRV (object), PERL_MAGIC_ext)))
		return NULL;

	return (void *) mg->mg_ptr;
}

SV *
newSVGnomeConfigIterator (const char *app_id)
{
	SV *object = (SV *) newHV ();

	sv_magic (object, 0, PERL_MAGIC_ext, (const char *) app_id, 0);

	return sv_bless (newRV_noinc (object),
	                 gv_stashpv ("Gnome2::Config::Iterator", 1));
}

/* ------------------------------------------------------------------------- */

MODULE = Gnome2::Config	PACKAGE = Gnome2::Config	PREFIX = gnome_config_

char *
get_string (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_string = 0
	Gnome2::Config::get_translated_string = 1
	Gnome2::Config::Private::get_string = 2
	Gnome2::Config::Private::get_translated_string = 3
    CODE:
	switch (ix) {
		case 0: RETVAL = gnome_config_get_string (path); break;
		case 1: RETVAL = gnome_config_get_translated_string (path); break;
		case 2: RETVAL = gnome_config_private_get_string (path); break;
		case 3: RETVAL = gnome_config_private_get_translated_string (path); break;
	}
    OUTPUT:
	RETVAL
    CLEANUP:
	g_free (RETVAL);

=for apidoc

Returns a boolean indicating whether the default was used and the actual value.

=cut
void
get_string_with_default (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_string_with_default = 0
	Gnome2::Config::get_translated_string_with_default = 1
	Gnome2::Config::Private::get_string_with_default = 2
	Gnome2::Config::Private::get_translated_string_with_default = 3
    PREINIT:
	char *retval = NULL;
	gboolean def;
    PPCODE:
	switch (ix) {
		case 0: retval = gnome_config_get_string_with_default (path, &def); break;
		case 1: retval = gnome_config_get_translated_string_with_default (path, &def); break;
		case 2: retval = gnome_config_private_get_string_with_default (path, &def); break;
		case 3: retval = gnome_config_private_get_translated_string_with_default (path, &def); break;
	}

	EXTEND (sp, 1);
	PUSHs (sv_2mortal (newSVuv (def)));
	if (retval != NULL)
		XPUSHs (sv_2mortal (newSVpv (retval, PL_na)));

	g_free (retval);

int
get_int (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_int = 0
	Gnome2::Config::Private::get_int = 1
    CODE:
	switch (ix) {
		case 0: RETVAL = gnome_config_get_int (path); break;
		case 1: RETVAL = gnome_config_private_get_int (path); break;
	}
    OUTPUT:
	RETVAL

=for apidoc

Returns a boolean indicating whether the default was used and the actual value.

=cut
void
get_int_with_default (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_int_with_default = 0
	Gnome2::Config::Private::get_int_with_default = 1
    PREINIT:
	int retval = 0;
	gboolean def;
    PPCODE:
	switch (ix) {
		case 0: retval = gnome_config_get_int_with_default (path, &def); break;
		case 1: retval = gnome_config_private_get_int_with_default (path, &def); break;
	}

	EXTEND (sp, 2);
	PUSHs (sv_2mortal (newSVuv (def)));
	PUSHs (sv_2mortal (newSViv (retval)));

gdouble
get_float (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_float = 0
	Gnome2::Config::Private::get_float = 1
    CODE:
	switch (ix) {
		case 0: RETVAL = gnome_config_get_float (path); break;
		case 1: RETVAL = gnome_config_private_get_float (path); break;
	}
    OUTPUT:
	RETVAL

=for apidoc

Returns a boolean indicating whether the default was used and the actual value.

=cut
# FIXME: seems to return integers instead of floats.
void
get_float_with_default (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_float_with_default = 0
	Gnome2::Config::Private::get_float_with_default = 1
    PREINIT:
	gdouble retval = 0.0;
	gboolean def;
    PPCODE:
	switch (ix) {
		case 0: retval = gnome_config_get_float_with_default (path, &def); break;
		case 1: retval = gnome_config_private_get_float_with_default (path, &def); break;
	}

	EXTEND (sp, 2);
	PUSHs (sv_2mortal (newSVuv (def)));
	PUSHs (sv_2mortal (newSVnv (retval)));

gboolean
get_bool (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_bool = 0
	Gnome2::Config::Private::get_bool = 1
    CODE:
	switch (ix) {
		case 0: RETVAL = gnome_config_get_bool (path); break;
		case 1: RETVAL = gnome_config_private_get_bool (path); break;
	}
    OUTPUT:
	RETVAL

=for apidoc

Returns a boolean indicating whether the default was used and the actual value.

=cut
void
get_bool_with_default (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_bool_with_default = 0
	Gnome2::Config::Private::get_bool_with_default = 1
    PREINIT:
	gboolean retval = FALSE;
	gboolean def = FALSE;
    PPCODE:
	switch (ix) {
		case 0: retval = gnome_config_get_bool_with_default (path, &def); break;
		case 1: retval = gnome_config_private_get_bool_with_default (path, &def); break;
	}

	EXTEND (sp, 2);
	PUSHs (sv_2mortal (newSVuv (def)));
	PUSHs (sv_2mortal (newSVuv (retval)));

SV *
get_vector (class, path)
	const char *path
    ALIAS:
	Gnome2::Config::get_vector = 0
	Gnome2::Config::Private::get_vector = 1
    PREINIT:
	char **argv = NULL;
	int argc, i;
	AV *array = newAV ();
    CODE:
{'fraction_non_alphanumeric': 0.128549345049223, 'fraction_numerical': 0.017167032788219024, 'mean_word_length': 4.025347506132461, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6155302', 'n_tokens_mistral': 4665, 'n_tokens_neox': 4335, 'n_words': 1265}