Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Split pkg_object code into its own file
Baptiste Daroussin committed 12 years ago
commit cdeaa08e03c1054aaa145ab8482ced0247a04c6b
parent 7c5e924
3 files changed +109 -84
modified libpkg/Makefile.am
@@ -24,6 +24,7 @@ libpkg_la_SOURCES= pkg.c \
			pkg_event.c \
			pkg_jobs.c \
			pkg_manifest.c \
+
			pkg_object.c \
			pkg_ports.c \
			pkg_printf.c \
			pkg_repo.c \
@@ -91,4 +92,4 @@ noinst_HEADERS= private/db_upgrades.h \

dist_man_MANS=		pkg-repository.5 \
			pkg_printf.3 \
-
			pkg_repos.3 

\ No newline at end of file
+
			pkg_repos.3
modified libpkg/pkg_config.c
@@ -371,17 +371,6 @@ pkg_config_dump(void)
	return (pkg_object_dump(config));
}

-
const char *
-
pkg_object_dump(pkg_object *o)
-
{
-
	return (ucl_object_emit(o, UCL_EMIT_CONFIG));
-
}
-

-
pkg_object *
-
pkg_object_iter(pkg_object *o, pkg_iter *it) {
-
	return (ucl_iterate_object(o, it, true));
-
}
-

static void
disable_plugins_if_static(void)
{
@@ -897,78 +886,6 @@ parsed:
	return (EPKG_OK);
}

-
void
-
pkg_object_free(pkg_object *o)
-
{
-
	ucl_object_unref(o);
-
}
-

-
const char *
-
pkg_object_key(pkg_object *o)
-
{
-
	return (ucl_object_key(o));
-
}
-

-
pkg_object *
-
pkg_object_iterate(pkg_object *o, pkg_iter *it)
-
{
-
	return (ucl_iterate_object(o, it, true));
-
}
-

-
pkg_object *
-
pkg_conf(void)
-
{
-
	return (config);
-
}
-

-
pkg_object_t
-
pkg_object_type(pkg_object *o)
-
{
-
	switch (o->type) {
-
	case UCL_OBJECT:
-
		return (PKG_OBJECT);
-
	case UCL_BOOLEAN:
-
		return (PKG_BOOL);
-
	case UCL_STRING:
-
		return (PKG_STRING);
-
	case UCL_INT:
-
		return (PKG_INT);
-
	case UCL_ARRAY:
-
		return (PKG_ARRAY);
-
	default:
-
		return (PKG_NULL);
-
	};
-

-
}
-

-
bool
-
pkg_object_bool(pkg_object *o)
-
{
-
	assert(o->type == UCL_BOOLEAN);
-

-
	return (ucl_object_toboolean(o));
-
}
-

-
const char *
-
pkg_object_string(pkg_object *o)
-
{
-
	const char *ret;
-

-
	ret = ucl_object_tostring_forced(o);
-

-
	if (ret && *ret == '\0')
-
		return (NULL);
-
	return (ret);
-
}
-

-
int64_t
-
pkg_object_int(pkg_object *o)
-
{
-
	assert(o->type == UCL_INT);
-

-
	return (ucl_object_toint(o));
-
}
-

static char *
subst_packagesite_str(const char *oldstr)
{
added libpkg/pkg_object.c
@@ -0,0 +1,107 @@
+
/*-
+
 * Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
+
 * All rights reserved.
+
 * 
+
 * Redistribution and use in source and binary forms, with or without
+
 * modification, are permitted provided that the following conditions
+
 * are met:
+
 * 1. Redistributions of source code must retain the above copyright
+
 *    notice, this list of conditions and the following disclaimer
+
 *    in this position and unchanged.
+
 * 2. Redistributions in binary form must reproduce the above copyright
+
 *    notice, this list of conditions and the following disclaimer in the
+
 *    documentation and/or other materials provided with the distribution.
+
 * 
+
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 */
+

+
#include <assert.h>
+
#include <ucl.h>
+
#include "pkg.h"
+

+
const char *
+
pkg_object_dump(pkg_object *o)
+
{
+
	return (ucl_object_emit(o, UCL_EMIT_CONFIG));
+
}
+

+
pkg_object *
+
pkg_object_iter(pkg_object *o, pkg_iter *it) {
+
	return (ucl_iterate_object(o, it, true));
+
}
+

+
void
+
pkg_object_free(pkg_object *o)
+
{
+
	ucl_object_unref(o);
+
}
+

+
const char *
+
pkg_object_key(pkg_object *o)
+
{
+
	return (ucl_object_key(o));
+
}
+

+
pkg_object *
+
pkg_object_iterate(pkg_object *o, pkg_iter *it)
+
{
+
	return (ucl_iterate_object(o, it, true));
+
}
+

+
pkg_object_t
+
pkg_object_type(pkg_object *o)
+
{
+
	switch (o->type) {
+
	case UCL_OBJECT:
+
		return (PKG_OBJECT);
+
	case UCL_BOOLEAN:
+
		return (PKG_BOOL);
+
	case UCL_STRING:
+
		return (PKG_STRING);
+
	case UCL_INT:
+
		return (PKG_INT);
+
	case UCL_ARRAY:
+
		return (PKG_ARRAY);
+
	default:
+
		return (PKG_NULL);
+
	};
+

+
}
+

+
bool
+
pkg_object_bool(pkg_object *o)
+
{
+
	assert(o->type == UCL_BOOLEAN);
+

+
	return (ucl_object_toboolean(o));
+
}
+

+
const char *
+
pkg_object_string(pkg_object *o)
+
{
+
	const char *ret;
+

+
	ret = ucl_object_tostring_forced(o);
+

+
	if (ret && *ret == '\0')
+
		return (NULL);
+
	return (ret);
+
}
+

+
int64_t
+
pkg_object_int(pkg_object *o)
+
{
+
	assert(o->type == UCL_INT);
+

+
	return (ucl_object_toint(o));
+
}
+