repo-fixing: fixup #5.
authorKrisztian Litkey <krisztian.litkey@intel.com>
Fri, 26 Oct 2012 16:24:24 +0000 (19:24 +0300)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Fri, 26 Oct 2012 16:24:24 +0000 (19:24 +0300)
39 files changed:
build-aux/gen-linkedin-loader [new file with mode: 0644]
build-aux/gen-linker-script
configure.ac
doc/plugin-developer-guide/db/Makefile.am
src/Makefile.am
src/common-func-info.c
src/common/hashtbl.h
src/common/msg.c
src/common/msg.h
src/core-func-info.c
src/core/plugin.h
src/daemon/murphy.conf
src/murphy-db/mdb/log.c
src/murphy-db/mdb/table.c
src/plugins/plugin-test.c
src/plugins/resource-native/Makefile [deleted file]
src/plugins/resource-native/plugin-resource-native.c [deleted file]
src/plugins/resource-native/resource-client.c [deleted file]
src/resource/application-class.c [deleted file]
src/resource/application-class.h [deleted file]
src/resource/attribute.c [deleted file]
src/resource/attribute.h [deleted file]
src/resource/client-api.h [deleted file]
src/resource/common-api.h [deleted file]
src/resource/config-api.h [deleted file]
src/resource/data-types.h [deleted file]
src/resource/manager-api.h [deleted file]
src/resource/murphy-resource.pc.in [deleted file]
src/resource/protocol.h [deleted file]
src/resource/resource-client.c [deleted file]
src/resource/resource-client.h [deleted file]
src/resource/resource-owner.c [deleted file]
src/resource/resource-owner.h [deleted file]
src/resource/resource-set.c [deleted file]
src/resource/resource-set.h [deleted file]
src/resource/resource.c [deleted file]
src/resource/resource.h [deleted file]
src/resource/zone.c [deleted file]
src/resource/zone.h [deleted file]

diff --git a/build-aux/gen-linkedin-loader b/build-aux/gen-linkedin-loader
new file mode 100644 (file)
index 0000000..1719dd4
--- /dev/null
@@ -0,0 +1,157 @@
+#!/bin/bash
+
+######################################################################
+# Generate helper code for making builtin DSO plugins available.
+#
+# Sometimes it is necessary to split a plugin to several source
+# files. Usually this is the case when the functionality provided
+# by the plugin is complex enough to require subdividing the plugin
+# into internal modules for the best maintainability.
+#
+# In these cases we cannot avoid making several functions and
+# variables globally available within the plugin so we cannot just
+# limit the scope of visibility by making them static. Still, we do
+# want to avoid conflicts between these symbols of different plugins.
+# To accomplish this we compile and link such plugins into shared
+# libraries (with our normal symbol visibility conventions) and then
+# link the murphy daemon against them.
+#
+# Since none of the code linked into murphy proper references
+# any of the symbols in any of these plugins without any further
+# special arrangements these plugins wouldn't be demand-loaded
+# and consequently would be unavailable when the daemon starts up.
+#
+# To overcome this every such plugin gets automatically augmented
+# by a plugin-specifig globally visible symbol and the murphy daemon
+# gets augmented by a symbol that references these plugin-specific
+# symbols. This forces the dynamic loader to load the plugins and
+# the normal builtin-plugin autoregistration mechanism takes care of
+# the rest.
+#
+# A bit too spaceship-ish, I admit... but nevertheless necessary
+# unless we want to give up the idea of builtin/linkedin plugins...
+#
+
+
+error () {
+    echo "error: $*" 1>&2
+}
+
+info () {
+    echo "$*" 1>&2
+}
+
+warning () {
+    echo "warning: $*" 1>&2
+}
+
+usage () {
+    info "usage: $0 [-p <plugin>] [-l <plugin-list>] -o <output-file>"
+    info "usage: $0 -p <plugin> -o <output-file>, or"
+    info "usage: $0 -o <output-file> <plugin-list>"
+    exit ${1:-1}
+}
+
+emit () {
+    echo "$*" >> $OUTPUT
+}
+
+emit_plugin_loader () {
+    case $OUTPUT in
+        *.c) emit "int mrp_linkedin_plugin_$1_symbol = 0;"
+             ;;
+        *.h) emit "extern int mrp_linkedin_plugin_$1_symbol;"
+             ;;
+    esac
+}
+
+emit_murphy_loader () {
+    local _p
+
+    for _p in $*; do
+        emit "#include \"linkedin-$_p-loader.h\""
+    done
+    emit ""
+    emit "void mrp_load_linkedin_plugins(void)"
+    emit "{"
+    emit "    return \\"
+    for _p in $*; do
+        emit "        mrp_linkedin_plugin_${_p}_symbol + \\"
+    done
+    emit "        0;"
+    emit "}"
+}
+
+
+OUTPUT=""
+PLUGIN=""
+PLUGIN_LIST=""
+
+#echo "*** $0 $* ***"
+
+# parse command line
+while [ -n "${1#-}" ]; do
+    case $1 in
+        -o)
+            if [ -z "$OUTPUT" ]; then
+                shift
+                OUTPUT="$1"
+            else
+                error "Multiple output files requested."
+                usage
+            fi
+            ;;
+        -p)
+            if [ -z "$PLUGIN" -a -z "$PLUGIN_LIST" ]; then
+                shift
+                PLUGIN="$1"
+            else
+                if [ -n "$PLUGIN" ]; then
+                    error "Multiple builtin plugins specified."
+                else
+                    error "Both builtin plugin and plugin list specified."
+                fi
+                usage
+            fi
+            ;;
+        -h)
+            usage 0
+            ;;
+       -q)
+           QUIET="yes"
+           ;;
+        -*)
+            error "Unknown option '$1'."
+            usage
+            ;;
+        *)
+            PLUGIN_LIST="$PLUGIN_LIST $1"
+            ;;
+    esac
+    shift
+done
+
+# check that we've got everything mandatory
+if [ -z "$OUTPUT" ]; then
+    error "No output file specified (use the -o option)."
+    usage
+fi
+
+if [ -z "$PLUGIN" -a -z "$PLUGIN_LIST" ]; then
+    error "Neither builtin plugin nor plugin list is specified."
+    usage
+fi
+
+if [ -n "$PLUGIN" -a -n "$PLUGIN_LIST" ]; then
+    error "Both builtin plugin and plugin list are specified."
+    usage
+fi
+
+# generate the output
+rm -f $OUTPUT
+touch $OUTPUT
+if [ -n "$PLUGIN" ]; then
+    emit_plugin_loader $PLUGIN
+else
+    emit_murphy_loader $PLUGIN_LIST
+fi
index c5dc567..bb322b4 100755 (executable)
@@ -16,6 +16,10 @@ info () {
     echo "$*" 1>&2
 }
 
+warning () {
+    echo "warning: $*" 1>&2
+}
+
 usage () {
     info "usage: $0 [-p <pattern>] [-I <ignore-list>] -o <output> <inputs>"
     exit ${1:-1}
@@ -27,7 +31,7 @@ emit () {
 
 
 # set up defaults
-PATTERN="^mrp_"                       # export everything prefixed with mrp_
+PATTERN="^mrp_|^_mrp_"                # export everything prefixed with mrp_
 IGNORE="MRP_PRINTF_LIKE,MRP_NULLTERM" # ignore these symbols/macros
 IT=","                                # ignore-list is comma-separated
 SOURCES=""                            # no default input, must be specified
@@ -78,8 +82,12 @@ if [ -z "$OUTPUT" ]; then
 fi
 
 if [ -z "$SOURCES" ]; then
-    error "No input files specified."
-    usage
+    warning "No input files, generating local-only linker script."
+    emit "{"
+    emit "    local:"
+    emit "        *;"
+    emit "};"
+    exit 0
 fi
 
 if [ -z "$PATTERN" ]; then
index 17d9c8d..415a20a 100644 (file)
@@ -428,7 +428,6 @@ AC_CONFIG_FILES([build-aux/shave
                 src/murphy-db/tests/Makefile
                 src/resolver/murphy-resolver.pc
                 src/resolver/tests/Makefile
-                src/resource/murphy-resource.pc
                 doc/Makefile
                 doc/plugin-developer-guide/Makefile
                 doc/plugin-developer-guide/db/Makefile
index 315c437..df5272a 100644 (file)
@@ -24,15 +24,9 @@ xmldir = $(MRP_DOCDIR)
 nodist_xml_DATA = $(TARGETS)
 
 
-all-am: $(TARGETS) copy_svg
+all-am: $(TARGETS)
 
 
-copy_svg:
-       for f in $(FIGURES_SVG) ; do \
-           echo "  CP    $$f" ; \
-           cp $(MRP_FIGDIR)/$$f . ; \
-       done 1>&2
-
 mql-grammar.xml: $(TOP_SRCDIR)/murphy-db/mql/mql-scanner.l \
                  $(TOP_SRCDIR)/murphy-db/mql/mql-parser.y
        $(MRP_ABNF) $+ > $@
index 5cc7387..a9beb70 100644 (file)
@@ -14,7 +14,7 @@ QUIET_GEN       = $(Q:@=@echo '  GEN   '$@;)
 LEXCOMPILE      = $(LEX) $(LFLAGS) $(AM_LFLAGS)
 YACCCOMPILE     = $(YACC) $(YFLAGS) $(AM_YFLAGS)
 
-INCLUDES        = -Imurphy-db/include
+INCLUDES        = -I$(top_builddir)/src/murphy-db/include -I$(top_builddir)
 
 ###################################
 # murphy common library
@@ -335,8 +335,7 @@ libmurphy_resolver_la_SOURCES =                     \
                resolver-func-info.c
 
 libmurphy_resolver_la_CFLAGS =                 \
-               $(AM_CFLAGS)                    \
-               $(INCLUDES)
+               $(AM_CFLAGS)
 
 libmurphy_resolver_la_LDFLAGS =                        \
                -Wl,-version-script=linker-script.resolver \
@@ -399,68 +398,6 @@ resolver/scripting/simple/simple-parser.c: \
        mv -f y.tab.h resolver/scripting/simple/simple-parser.h
        mv -f y.tab.c resolver/scripting/simple/simple-parser.c
 
-###################################
-# murphy resource library
-#
-
-lib_LTLIBRARIES += libmurphy-resource.la
-EXTRA_DIST      += resource/murphy-resource.pc
-pkgconfig_DATA  += resource/murphy-resource.pc
-
-libmurphy_resource_ladir =                     \
-               $(includedir)/murphy/resource
-
-libmurphy_resource_la_HEADERS =                        \
-               resource/data-types.h           \
-               resource/common-api.h           \
-               resource/client-api.h           \
-               resource/manager-api.h          \
-               resource/config-api.h           \
-               resource/protocol.h
-
-libmurphy_resource_la_REGULAR_SOURCES =                \
-               resource/attribute.c            \
-               resource/resource.c             \
-               resource/resource-set.c         \
-               resource/application-class.c    \
-               resource/resource-owner.c       \
-               resource/resource-client.c      \
-               resource/zone.c
-
-libmurphy_resource_la_SOURCES =                        \
-               $(libmurphy_resource_la_REGULAR_SOURCES)        \
-               resource-func-info.c
-
-libmurphy_resource_la_CFLAGS =                 \
-               $(AM_CFLAGS)                    \
-               $(INCLUDES)
-
-libmurphy_resource_la_LDFLAGS =                        \
-               -Wl,-version-script=linker-script.resource \
-               -version-info @MURPHY_VERSION_INFO@
-
-libmurphy_resource_la_LIBADD =     \
-               libmurphy-core.la   \
-               libmurphy-common.la
-
-libmurphy_resource_la_DEPENDENCIES = linker-script.resource \
-                                    libmurphy-core.la      \
-                                    libmurphy-common.la
-
-# debug file:line-function mapping generation
-resource-func-info.c: $(libmurphy_resource_la_REGULAR_SOURCES)
-       $(QUIET_GEN)$(top_builddir)/build-aux/gen-debug-table -o $@ $^
-
-clean-func-infos::
-       -rm resource-func-info.c
-
-# resource linker script generation
-linker-script.resource: $(libmurphy_resource_la_HEADERS)
-       $(QUIET_GEN)$(top_builddir)/build-aux/gen-linker-script -q -o $@ $^
-
-clean-linker-script::
-       -rm -f linker-script.resource
-
 
 ###################################
 # murphy plugins
@@ -604,43 +541,6 @@ plugin_signalling_ladir      = $(SIGNALLING_PLUGINdir)
 plugin_LTLIBRARIES    += plugin-signalling.la
 endif
 
-# native resource plugin
-PLUGIN_RESOURCE_NATIVE_REGULAR_SOURCES =                               \
-               plugins/resource-native/plugin-resource-native.c
-PLUGIN_RESOURCE_NATIVE_SOURCES =                                       \
-               $(PLUGIN_RESOURCE_NATIVE_REGULAR_SOURCES)               \
-                plugin-resource-native-func-info.c
-PLUGIN_RESOURCE_NATIVE_CFLAGS =                                                \
-               $(INCLUDES)
-PLUGIN_RESOURCE_NATIVE_LIBS =                                          \
-               libmurphy-core.la                                       \
-               libmurphy-common.la                                     \
-               murphy-db/mqi/libmqi.la                                 \
-               murphy-db/mdb/libmdb.la                                 \
-               libmurphy-resource.la
-
-plugin_resource_native_la_SOURCES = $(PLUGIN_RESOURCE_NATIVE_SOURCES)
-plugin_resource_native_la_CFLAGS  = $(PLUGIN_RESOURCE_NATIVE_CFLAGS)   \
-                                   $(MURPHY_CFLAGS) $(AM_CFLAGS)
-plugin_resource_native_la_LDFLAGS = -module -avoid-version
-plugin_resource_native_la_LIBADD  = $(PLUGIN_RESOURCE_NATIVE_LIBS)
-
-plugin_LTLIBRARIES += plugin-resource-native.la
-
-# resource-client
-bin_PROGRAMS += resource-client
-
-resource_client_SOURCES = plugins/resource-native/resource-client.c
-resource_client_CFLAGS  = $(AM_CFLAGS) $(BUILTIN_CFLAGS)
-resource_client_LDADD   = $(BUILTIN_LIBS) libmurphy-common.la
-
-# debug file:line-function mapping generation
-plugin-resource-native-func-info.c: $(PLUGIN_RESOURCE_NATIVE_REGULAR_SOURCES)
-       $(QUIET_GEN)$(top_builddir)/build-aux/gen-debug-table -o $@ $^
-
-clean-func-infos::
-       -rm plugin-resource-native-func-info.c
-
 # decision plugin
 DECISION_PLUGIN_SOURCES = plugins/decision-proto/plugin-decision.c \
                          plugins/decision-proto/decision.c          \
@@ -703,6 +603,10 @@ plugin_decision_la_CFLAGS  = $(DECISION_PLUGIN_CFLAGS) \
 plugin_decision_la_LDFLAGS = -module -avoid-version
 plugin_decision_la_LIBADD  = $(DECISION_PLUGIN_LIBS)
 
+plugin_LTLIBRARIES    += plugin-decision.la
+endif
+
+
 lib_LTLIBRARIES          += libmurphy-pep.la
 libmurphy_pep_la_SOURCES  = plugins/decision-proto/client.c \
                            plugins/decision-proto/table-common.c  \
@@ -746,7 +650,6 @@ murphyd_CFLAGS  =                   \
 murphyd_LDADD  =                       \
                $(BUILTIN_LIBS)         \
                $(LINKEDIN_PLUGINS)     \
-               libmurphy-resource.la   \
                libmurphy-resolver.la   \
                libmurphy-core.la       \
                libmurphy-common.la
index 3e4552b..7293328 100644 (file)
@@ -1,8 +1,28 @@
 #include <stdlib.h>
 #include <murphy/common/debug.h>
 
-/* common/debug.c */
+/* common/core-transport.c */
 static mrp_debug_info_t info_0[] = {
+    { .line = 17, .func = "core_resolve" },
+    { .line = 25, .func = "core_open" },
+    { .line = 31, .func = "core_close" },
+    { .line = 37, .func = "core_bind" },
+    { .line = 44, .func = "core_listen" },
+    { .line = 50, .func = "core_accept" },
+    { .line = 56, .func = "core_connect" },
+    { .line = 63, .func = "core_disconnect" },
+    { .line = 69, .func = "core_send" },
+    { .line = 75, .func = "core_sendraw" },
+    { .line = 81, .func = "core_senddata" },
+    { .line = 0, .func = NULL }
+};
+static mrp_debug_file_t file_0 = {
+    .file = "common/core-transport.c",
+    .info = info_0
+};
+
+/* common/debug.c */
+static mrp_debug_info_t info_1[] = {
     { .line = 57, .func = "free_rule_cb" },
     { .line = 65, .func = "init_rules" },
     { .line = 84, .func = "reset_rules" },
@@ -26,13 +46,13 @@ static mrp_debug_info_t info_0[] = {
     { .line = 619, .func = "flush_file_table" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_0 = {
+static mrp_debug_file_t file_1 = {
     .file = "common/debug.c",
-    .info = info_0
+    .info = info_1
 };
 
 /* common/dgram-transport.c */
-static mrp_debug_info_t info_1[] = {
+static mrp_debug_info_t info_2[] = {
     { .line = 82, .func = "parse_address" },
     { .line = 199, .func = "dgrm_resolve" },
     { .line = 249, .func = "dgrm_open" },
@@ -53,25 +73,25 @@ static mrp_debug_info_t info_1[] = {
     { .line = 692, .func = "dgrm_senddatato" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_1 = {
+static mrp_debug_file_t file_2 = {
     .file = "common/dgram-transport.c",
-    .info = info_1
+    .info = info_2
 };
 
 /* common/file-utils.c */
-static mrp_debug_info_t info_2[] = {
+static mrp_debug_info_t info_3[] = {
     { .line = 42, .func = "translate_glob" },
     { .line = 53, .func = "dirent_type" },
     { .line = 71, .func = "mrp_scan_dir" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_2 = {
+static mrp_debug_file_t file_3 = {
     .file = "common/file-utils.c",
-    .info = info_2
+    .info = info_3
 };
 
 /* common/hashtbl.c */
-static mrp_debug_info_t info_3[] = {
+static mrp_debug_info_t info_4[] = {
     { .line = 68, .func = "calc_buckets" },
     { .line = 84, .func = "mrp_htbl_create" },
     { .line = 127, .func = "mrp_htbl_destroy" },
@@ -86,13 +106,13 @@ static mrp_debug_info_t info_3[] = {
     { .line = 343, .func = "mrp_htbl_find" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_3 = {
+static mrp_debug_file_t file_4 = {
     .file = "common/hashtbl.c",
-    .info = info_3
+    .info = info_4
 };
 
 /* common/internal-transport.c */
-static mrp_debug_info_t info_4[] = {
+static mrp_debug_info_t info_5[] = {
     { .line = 75, .func = "process_queue" },
     { .line = 144, .func = "internal_initialize_table" },
     { .line = 205, .func = "internal_resolve" },
@@ -113,13 +133,13 @@ static mrp_debug_info_t info_4[] = {
     { .line = 556, .func = "internal_senddata" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_4 = {
+static mrp_debug_file_t file_5 = {
     .file = "common/internal-transport.c",
-    .info = info_4
+    .info = info_5
 };
 
 /* common/log.c */
-static mrp_debug_info_t info_5[] = {
+static mrp_debug_info_t info_6[] = {
     { .line = 43, .func = "mrp_log_parse_levels" },
     { .line = 84, .func = "mrp_log_parse_target" },
     { .line = 97, .func = "mrp_log_enable" },
@@ -131,13 +151,13 @@ static mrp_debug_info_t info_5[] = {
     { .line = 226, .func = "set_default_logging" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_5 = {
+static mrp_debug_file_t file_6 = {
     .file = "common/log.c",
-    .info = info_5
+    .info = info_6
 };
 
 /* common/mainloop.c */
-static mrp_debug_info_t info_6[] = {
+static mrp_debug_info_t info_7[] = {
     { .line = 212, .func = "add_slave_io_watch" },
     { .line = 246, .func = "slave_io_events" },
     { .line = 265, .func = "free_io_watch" },
@@ -199,13 +219,13 @@ static mrp_debug_info_t info_6[] = {
     { .line = 1545, .func = "dump_pollfds" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_6 = {
+static mrp_debug_file_t file_7 = {
     .file = "common/mainloop.c",
-    .info = info_6
+    .info = info_7
 };
 
 /* common/mm.c */
-static mrp_debug_info_t info_7[] = {
+static mrp_debug_info_t info_8[] = {
     { .line = 95, .func = "setup" },
     { .line = 122, .func = "cleanup" },
     { .line = 133, .func = "memblk_alloc" },
@@ -247,13 +267,13 @@ static mrp_debug_info_t info_7[] = {
     { .line = 970, .func = "chunk_free" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_7 = {
+static mrp_debug_file_t file_8 = {
     .file = "common/mm.c",
-    .info = info_7
+    .info = info_8
 };
 
 /* common/msg.c */
-static mrp_debug_info_t info_8[] = {
+static mrp_debug_info_t info_9[] = {
     { .line = 49, .func = "destroy_field" },
     { .line = 83, .func = "create_field" },
     { .line = 257, .func = "msg_destroy" },
@@ -294,13 +314,13 @@ static mrp_debug_info_t info_8[] = {
     { .line = 2037, .func = "mrp_msgbuf_pull" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_8 = {
+static mrp_debug_file_t file_9 = {
     .file = "common/msg.c",
-    .info = info_8
+    .info = info_9
 };
 
 /* common/stream-transport.c */
-static mrp_debug_info_t info_9[] = {
+static mrp_debug_info_t info_10[] = {
     { .line = 73, .func = "parse_address" },
     { .line = 191, .func = "strm_resolve" },
     { .line = 241, .func = "strm_open" },
@@ -318,13 +338,13 @@ static mrp_debug_info_t info_9[] = {
     { .line = 634, .func = "strm_senddata" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_9 = {
+static mrp_debug_file_t file_10 = {
     .file = "common/stream-transport.c",
-    .info = info_9
+    .info = info_10
 };
 
 /* common/transport.c */
-static mrp_debug_info_t info_10[] = {
+static mrp_debug_info_t info_11[] = {
     { .line = 47, .func = "check_request_callbacks" },
     { .line = 71, .func = "mrp_transport_register" },
     { .line = 87, .func = "mrp_transport_unregister" },
@@ -351,22 +371,22 @@ static mrp_debug_info_t info_10[] = {
     { .line = 505, .func = "recv_data" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_10 = {
+static mrp_debug_file_t file_11 = {
     .file = "common/transport.c",
-    .info = info_10
+    .info = info_11
 };
 
 /* common/utils.c */
-static mrp_debug_info_t info_11[] = {
+static mrp_debug_info_t info_12[] = {
     { .line = 45, .func = "notify_parent" },
     { .line = 58, .func = "mrp_daemonize" },
     { .line = 194, .func = "mrp_string_comp" },
     { .line = 200, .func = "mrp_string_hash" },
     { .line = 0, .func = NULL }
 };
-static mrp_debug_file_t file_11 = {
+static mrp_debug_file_t file_12 = {
     .file = "common/utils.c",
-    .info = info_11
+    .info = info_12
 };
 
 /* table of all files */
@@ -383,6 +403,7 @@ static mrp_debug_file_t *debug_files[] = {
     &file_9,
     &file_10,
     &file_11,
+    &file_12,
     NULL
 };
 
index a31a716..6dd7c05 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef __MURPHY_HASHTBL_H__
 #define __MURPHY_HASHTBL_H__
 
+#include <stdint.h>
 
 #include <murphy/common/macros.h>
 
index 8b521f1..4722caf 100644 (file)
@@ -585,6 +585,123 @@ int mrp_msg_get(mrp_msg_t *msg, ...)
 }
 
 
+int mrp_msg_iterate_get(mrp_msg_t *msg, void **it, ...)
+{
+#define HANDLE_TYPE(_type, _member)                       \
+    case MRP_MSG_FIELD_##_type:                           \
+        valp          = va_arg(ap, typeof(valp));         \
+        valp->_member = f->_member;                       \
+        break
+
+#define HANDLE_ARRAY(_type, _member)                      \
+    case MRP_MSG_FIELD_##_type:                           \
+        cntp          = va_arg(ap, typeof(cntp));         \
+        valp          = va_arg(ap, typeof(valp));         \
+        *cntp         = f->size[0];                       \
+        valp->_member = f->_member;                       \
+        break
+
+
+    mrp_msg_field_t *f;
+    mrp_msg_value_t *valp;
+    uint32_t        *cntp;
+    mrp_list_hook_t *start, *p;
+    uint16_t         tag, type;
+    int              found;
+    va_list          ap;
+
+    va_start(ap, it);
+
+    /*
+     * Okay... this might look a bit weird at first sight. This is
+     * mostly because we don't use the standard list iterating macros
+     * in the inner loop. There is a good reason for that: we want to
+     * minimise the number of times we scan the message which is just
+     * a linked list of fields. We do this by arranging the nested
+     * loops below in such a way that if the order of fields to fetch
+     * in the argument list matches the order of fields in the message
+     * we end up running the outer and inner loops in a 'phase lock'.
+     * So if the caller fetches the fields in the correct order we end
+     * up scanning the message at most once but only up to the last
+     * field to fetch.
+     */
+
+    start = (*it) ? (mrp_list_hook_t *)*it : msg->fields.next;
+
+    while ((tag = va_arg(ap, unsigned int)) != MRP_MSG_FIELD_INVALID) {
+        type  = va_arg(ap, unsigned int);
+        found = FALSE;
+
+        for (p = start; p != start->prev; p = p->next) {
+            if (p == &msg->fields)
+                continue;
+
+            f = mrp_list_entry(p, typeof(*f), hook);
+
+            if (f->tag != tag)
+                continue;
+
+            if (f->type != type)
+                goto out;
+
+            switch (type) {
+                HANDLE_TYPE(STRING, str);
+                HANDLE_TYPE(BOOL  , bln);
+                HANDLE_TYPE(UINT8 , u8 );
+                HANDLE_TYPE(SINT8 , s8 );
+                HANDLE_TYPE(UINT16, u16);
+                HANDLE_TYPE(SINT16, s16);
+                HANDLE_TYPE(UINT32, u32);
+                HANDLE_TYPE(SINT32, s32);
+                HANDLE_TYPE(UINT64, u64);
+                HANDLE_TYPE(SINT64, s64);
+                HANDLE_TYPE(DOUBLE, dbl);
+            default:
+                if (type & MRP_MSG_FIELD_ARRAY) {
+                    switch (type & ~MRP_MSG_FIELD_ARRAY) {
+                        HANDLE_ARRAY(STRING, astr);
+                        HANDLE_ARRAY(BOOL  , abln);
+                        HANDLE_ARRAY(UINT8 , au8 );
+                        HANDLE_ARRAY(SINT8 , as8 );
+                        HANDLE_ARRAY(UINT16, au16);
+                        HANDLE_ARRAY(SINT16, as16);
+                        HANDLE_ARRAY(UINT32, au32);
+                        HANDLE_ARRAY(SINT32, as32);
+                        HANDLE_ARRAY(UINT64, au64);
+                        HANDLE_ARRAY(SINT64, as64);
+                        HANDLE_ARRAY(DOUBLE, adbl);
+                    default:
+                        goto out;
+
+                    }
+                }
+                else
+                    goto out;
+            }
+
+            start = p->next;
+            found = TRUE;
+            break;
+        }
+
+        if (!found)
+            break;
+    }
+
+ out:
+    va_end(ap);
+
+    if (found)
+        *it = start;
+
+    return found;
+
+#undef HANDLE_TYPE
+#undef HANDLE_ARRAY
+
+}
+
+
 static const char *field_type_name(uint16_t type)
 {
 #define BASIC(t, n) [MRP_MSG_FIELD_##t] = n
index 078610c..7860197 100644 (file)
@@ -209,7 +209,7 @@ int mrp_msg_set(mrp_msg_t *msg, uint16_t tag, ...);
 int mrp_msg_iterate(mrp_msg_t *msg, void **it, uint16_t *tagp,
                     uint16_t *typep, mrp_msg_value_t *valp, size_t *sizep);
 
-/** Iterate through the matching fields of a message. You should not  delete
+/** Iterate through the matching fields of a message. You should not delete
  * any of the fields while iterating through the message. */
 int mrp_msg_iterate_matching(mrp_msg_t *msg, void **it, uint16_t *tagp,
                              uint16_t *typep, mrp_msg_value_t *valp,
@@ -221,6 +221,9 @@ mrp_msg_field_t *mrp_msg_find(mrp_msg_t *msg, uint16_t tag);
 /** Get the given fields (with matching tags and types) from the message. */
 int mrp_msg_get(mrp_msg_t *msg, ...) MRP_NULLTERM;
 
+/** Iterate through the message getting the given fields. */
+int mrp_msg_iterate_get(mrp_msg_t *msg, void **it, ...);
+
 /** Dump a message. */
 int mrp_msg_dump(mrp_msg_t *msg, FILE *fp);
 
index c16709a..f7ec01c 100644 (file)
@@ -48,20 +48,20 @@ static mrp_debug_file_t file_1 = {
 
 /* core/event.c */
 static mrp_debug_info_t info_2[] = {
-    { .line = 74, .func = "init_watch_lists" },
-    { .line = 86, .func = "mrp_add_event_watch" },
-    { .line = 158, .func = "delete_watch" },
-    { .line = 166, .func = "purge_deleted" },
-    { .line = 178, .func = "mrp_del_event_watch" },
-    { .line = 189, .func = "mrp_get_event_id" },
-    { .line = 217, .func = "mrp_get_event_name" },
-    { .line = 231, .func = "mrp_emit_event_msg" },
-    { .line = 276, .func = "mrp_emit_event" },
-    { .line = 298, .func = "mrp_set_events" },
-    { .line = 315, .func = "mrp_set_named_events" },
-    { .line = 336, .func = "event_count" },
-    { .line = 344, .func = "lowest_bit" },
-    { .line = 352, .func = "single_event" },
+    { .line = 45, .func = "init_watch_lists" },
+    { .line = 57, .func = "mrp_add_event_watch" },
+    { .line = 129, .func = "delete_watch" },
+    { .line = 137, .func = "purge_deleted" },
+    { .line = 149, .func = "mrp_del_event_watch" },
+    { .line = 160, .func = "mrp_get_event_id" },
+    { .line = 188, .func = "mrp_get_event_name" },
+    { .line = 202, .func = "mrp_emit_event_msg" },
+    { .line = 247, .func = "mrp_emit_event" },
+    { .line = 269, .func = "mrp_set_events" },
+    { .line = 286, .func = "mrp_set_named_events" },
+    { .line = 307, .func = "event_count" },
+    { .line = 315, .func = "lowest_bit" },
+    { .line = 323, .func = "single_event" },
     { .line = 0, .func = NULL }
 };
 static mrp_debug_file_t file_2 = {
@@ -71,23 +71,23 @@ static mrp_debug_file_t file_2 = {
 
 /* core/method.c */
 static mrp_debug_info_t info_3[] = {
-    { .line = 61, .func = "create_method_table" },
-    { .line = 79, .func = "destroy_method_table" },
-    { .line = 86, .func = "free_method" },
-    { .line = 96, .func = "alloc_method" },
-    { .line = 123, .func = "create_method_list" },
-    { .line = 151, .func = "free_method_list" },
-    { .line = 170, .func = "purge_method_list" },
-    { .line = 178, .func = "lookup_method_list" },
-    { .line = 191, .func = "check_signatures" },
-    { .line = 202, .func = "lookup_method" },
-    { .line = 232, .func = "find_method" },
-    { .line = 277, .func = "export_method" },
-    { .line = 297, .func = "remove_method" },
-    { .line = 322, .func = "mrp_export_method" },
-    { .line = 356, .func = "mrp_remove_method" },
-    { .line = 364, .func = "mrp_import_method" },
-    { .line = 404, .func = "mrp_release_method" },
+    { .line = 32, .func = "create_method_table" },
+    { .line = 50, .func = "destroy_method_table" },
+    { .line = 57, .func = "free_method" },
+    { .line = 67, .func = "alloc_method" },
+    { .line = 94, .func = "create_method_list" },
+    { .line = 122, .func = "free_method_list" },
+    { .line = 141, .func = "purge_method_list" },
+    { .line = 149, .func = "lookup_method_list" },
+    { .line = 162, .func = "check_signatures" },
+    { .line = 173, .func = "lookup_method" },
+    { .line = 203, .func = "find_method" },
+    { .line = 248, .func = "export_method" },
+    { .line = 268, .func = "remove_method" },
+    { .line = 293, .func = "mrp_export_method" },
+    { .line = 327, .func = "mrp_remove_method" },
+    { .line = 335, .func = "mrp_import_method" },
+    { .line = 375, .func = "mrp_release_method" },
     { .line = 0, .func = NULL }
 };
 static mrp_debug_file_t file_3 = {
@@ -129,31 +129,31 @@ static mrp_debug_file_t file_4 = {
 
 /* core/scripting.c */
 static mrp_debug_info_t info_5[] = {
-    { .line = 91, .func = "mrp_register_interpreter" },
-    { .line = 99, .func = "unregister_interpreter" },
-    { .line = 105, .func = "mrp_unregister_interpreter" },
-    { .line = 122, .func = "mrp_lookup_interpreter" },
-    { .line = 137, .func = "mrp_create_script" },
-    { .line = 167, .func = "mrp_destroy_script" },
-    { .line = 178, .func = "mrp_compile_script" },
-    { .line = 187, .func = "mrp_prepare_script" },
-    { .line = 196, .func = "mrp_execute_script" },
-    { .line = 205, .func = "mrp_print_value" },
-    { .line = 235, .func = "mrp_create_context_table" },
-    { .line = 261, .func = "mrp_destroy_context_table" },
-    { .line = 273, .func = "lookup_context_var" },
-    { .line = 287, .func = "mrp_declare_context_variable" },
-    { .line = 332, .func = "mrp_push_context_frame" },
-    { .line = 352, .func = "mrp_pop_context_frame" },
-    { .line = 384, .func = "get_context_id" },
-    { .line = 390, .func = "get_context_value" },
-    { .line = 413, .func = "set_context_value" },
-    { .line = 460, .func = "set_context_values" },
-    { .line = 474, .func = "mrp_get_context_id" },
-    { .line = 486, .func = "mrp_get_context_value" },
-    { .line = 493, .func = "mrp_set_context_value" },
-    { .line = 500, .func = "mrp_get_context_value_by_name" },
-    { .line = 507, .func = "mrp_set_context_value_by_name" },
+    { .line = 62, .func = "mrp_register_interpreter" },
+    { .line = 70, .func = "unregister_interpreter" },
+    { .line = 76, .func = "mrp_unregister_interpreter" },
+    { .line = 93, .func = "mrp_lookup_interpreter" },
+    { .line = 108, .func = "mrp_create_script" },
+    { .line = 138, .func = "mrp_destroy_script" },
+    { .line = 149, .func = "mrp_compile_script" },
+    { .line = 158, .func = "mrp_prepare_script" },
+    { .line = 167, .func = "mrp_execute_script" },
+    { .line = 176, .func = "mrp_print_value" },
+    { .line = 206, .func = "mrp_create_context_table" },
+    { .line = 232, .func = "mrp_destroy_context_table" },
+    { .line = 244, .func = "lookup_context_var" },
+    { .line = 258, .func = "mrp_declare_context_variable" },
+    { .line = 303, .func = "mrp_push_context_frame" },
+    { .line = 323, .func = "mrp_pop_context_frame" },
+    { .line = 355, .func = "get_context_id" },
+    { .line = 361, .func = "get_context_value" },
+    { .line = 384, .func = "set_context_value" },
+    { .line = 431, .func = "set_context_values" },
+    { .line = 445, .func = "mrp_get_context_id" },
+    { .line = 457, .func = "mrp_get_context_value" },
+    { .line = 464, .func = "mrp_set_context_value" },
+    { .line = 471, .func = "mrp_get_context_value_by_name" },
+    { .line = 478, .func = "mrp_set_context_value_by_name" },
     { .line = 0, .func = NULL }
 };
 static mrp_debug_file_t file_5 = {
index a6bf2f8..c307c13 100644 (file)
@@ -99,6 +99,12 @@ typedef struct {
 } mrp_plugin_arg_t;
 
 
+/** Macro for declaring a plugin argument table. */
+#define MRP_PLUGIN_ARGUMENTS(table, ...)     \
+    static mrp_plugin_arg_t table[] =        \
+        __VA_ARGS__                          \
+
+
 /** Convenience macros for setting up argument tables with type and defaults. */
 #define MRP_PLUGIN_ARG_STRING(name, defval)                                \
     { key: name, type: MRP_PLUGIN_ARG_TYPE_STRING, { str: defval } }
index 7ba89d5..3df1cac 100644 (file)
@@ -1,4 +1,4 @@
-# try-load-plugin console
+# try-load-plugin dbus
 try-load-plugin console        # address="tcp4:127.0.0.1:3000"
                         # address="udp4:127.0.0.1:3000"
                         # address="unxs:@/murphyd"
@@ -31,11 +31,4 @@ if plugin-exists murphydb
 #    error "Could not find mandatory plugin murphydb, giving up..."
 end
 
-# load the native resource plugin if it exists
-if plugin-exists resource-native
-    load-plugin resource-native
-else
-    info "Could not find resource-native plugin"
-end
-
 #set resolver-ruleset '/u/src/work/murphy/src/resolver/test-input'
index 31fbbd5..ef43972 100644 (file)
@@ -85,7 +85,6 @@ static inline log_t *get_last_vlog(mdb_dlist_t *);
 static tx_log_t *get_tx_log(uint32_t);
 static tbl_log_t *get_tbl_log(mdb_dlist_t *, mdb_dlist_t *, uint32_t,
                               mdb_table_t *);
-static void delete_tx_log(uint32_t);
 
 static MDB_DLIST_HEAD(tx_head);
 
@@ -142,7 +141,6 @@ mdb_log_entry_t *mdb_log_transaction_iterate(uint32_t   depth,
                                              int        delete)
 {
     typedef struct {
-        uint32_t         depth;
         mdb_dlist_t     *hhead;
         mdb_dlist_t     *chead;
         mdb_dlist_t     *hlink;
@@ -165,26 +163,19 @@ mdb_log_entry_t *mdb_log_transaction_iterate(uint32_t   depth,
     if (!depth)
         return NULL;
 
-    if ((cursor = *cursor_ptr)) {
-        if (cursor == &empty_cursor)
-            return NULL;
-
+    if ((cursor = *cursor_ptr))
         entry = &cursor->entry;
-    }
     else {
-        if (!(txlog = (tx_log_t *)get_last_vlog(&tx_head)))
-            return NULL;
-
-        if (depth > txlog->depth)
+        if (!(txlog = (tx_log_t *)get_last_vlog(&tx_head)) ||
+            depth > txlog->depth)
+        {
             return NULL;
+        }
 
         hhead = &txlog->hlink;
 
-        if (MDB_DLIST_EMPTY(*hhead)) {
-            if (delete)
-                delete_log((log_t *)txlog);
+        if (MDB_DLIST_EMPTY(*hhead))
             return NULL;
-        }
 
         tblog = MDB_LIST_RELOCATE(tbl_log_t, hlink, hhead->next);
 
@@ -198,7 +189,6 @@ mdb_log_entry_t *mdb_log_transaction_iterate(uint32_t   depth,
         else {
             entry = &cursor->entry;
 
-            cursor->depth = txlog->depth;
             cursor->hhead = hhead;
             cursor->chead = chead;
             cursor->hlink = tblog->hlink.next;
@@ -235,8 +225,6 @@ mdb_log_entry_t *mdb_log_transaction_iterate(uint32_t   depth,
 
         if (cursor->hlink == cursor->hhead) {
             if (cursor != &empty_cursor) {
-                if (delete)
-                    delete_tx_log(cursor->depth);
                 *cursor_ptr = &empty_cursor;
                 free(cursor);
             }
@@ -451,14 +439,6 @@ static tbl_log_t *get_tbl_log(mdb_dlist_t *vhead,
     return log;
 }
 
-static void delete_tx_log(uint32_t depth)
-{
-    log_t *log;
-
-    if ((log = get_last_vlog(&tx_head)) && depth == log->depth)
-        delete_log(log);
-}
-
 
 
 /*
index b521ccc..b2c11ad 100644 (file)
@@ -215,8 +215,6 @@ int mdb_table_drop(mdb_table_t *tbl)
 
     mdb_transaction_drop_table(tbl);
 
-    mdb_hash_delete(table_hash, 0,tbl->name);
-
     destroy_table(tbl);
 
     if (table_count > 1)
index 0c6316e..ea6d4d0 100644 (file)
@@ -207,15 +207,22 @@ void db_cmd_cb(mrp_console_t *c, void *user_data, int argc, char **argv)
         p += l;
         n -= l;
 
-        tx = mqi_begin_transaction();
+        if ((tx = mqi_begin_transaction()) == MQI_HANDLE_INVALID)
+            mrp_console_printf(c, "failed to create DB transaction\n");
         r = mql_exec_string(mql_result_string, buf);
 
-        if (!mql_result_is_success(r))
+        if (!mql_result_is_success(r)) {
             mrp_console_printf(c, "failed to execute DB command '%s'\n",
                                buf);
-        else
+        }
+        else {
             mrp_console_printf(c, "DB command executed OK\n");
-        mqi_commit_transaction(tx);
+            mrp_console_printf(c, "%s\n", mql_result_string_get(r));
+        }
+
+        mql_result_free(r);
+        if (mqi_commit_transaction(tx) < 0)
+            mrp_console_printf(c, "failed to commit DB transaction\n");
     }
 }
 
@@ -793,8 +800,6 @@ static int test_init(mrp_plugin_t *plugin)
 
     subscribe_events(plugin);
 
-    mqi_open();
-
     return !args[ARG_FAILINIT].bln;
 }
 
diff --git a/src/plugins/resource-native/Makefile b/src/plugins/resource-native/Makefile
deleted file mode 100644 (file)
index cfeca66..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-ifneq ($(strip $(MAKECMDGOALS)),)
-%:
-       $(MAKE) -C ../.. $(MAKECMDGOALS)
-else
-all:
-       $(MAKE) -C ../.. all
-endif
diff --git a/src/plugins/resource-native/plugin-resource-native.c b/src/plugins/resource-native/plugin-resource-native.c
deleted file mode 100644 (file)
index 85c547e..0000000
+++ /dev/null
@@ -1,1104 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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 <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <murphy/common/macros.h>
-#include <murphy/common/mm.h>
-#include <murphy/common/mainloop.h>
-#include <murphy/common/msg.h>
-#include <murphy/common/transport.h>
-#include <murphy/core/plugin.h>
-#include <murphy/core/console.h>
-#include <murphy/core/event.h>
-
-#include <murphy-db/mql.h>
-#include <murphy-db/mqi.h>
-
-#include <murphy/resource/client-api.h>
-#include <murphy/resource/config-api.h>
-#include <murphy/resource/manager-api.h>
-#include <murphy/resource/protocol.h>
-
-#define ATTRIBUTE_MAX   (sizeof(mrp_attribute_mask_t) * 8)
-
-
-
-enum {
-    RESOURCE_ERROR  = -1,
-    ATTRIBUTE_ERROR = -1,
-    RESOURCE_OK     = 0,
-    ATTRIBUTE_OK    = 0,
-    ATTRIBUTE_LAST,
-    RESOURCE_LAST,
-};
-
-
-enum {
-    ARG_CONFIG_FILE,
-    ARG_ADDRESS,
-};
-
-
-typedef struct {
-    mrp_plugin_t      *plugin;
-    mrp_event_watch_t *w;
-    mrp_sockaddr_t     saddr;
-    socklen_t          alen;
-    const char        *atyp;
-    mrp_transport_t   *listen;
-    mrp_list_hook_t    clients;
-} resource_data_t;
-
-typedef struct {
-    mrp_list_hook_t        list;
-    resource_data_t       *data;
-    uint32_t               id;
-    mrp_resource_client_t *rscli;
-    mrp_transport_t       *transp;
-} client_t;
-
-
-static void print_zones_cb(mrp_console_t *, void *, int, char **argv);
-static void print_classes_cb(mrp_console_t *, void *, int, char **argv);
-static void print_sets_cb(mrp_console_t *, void *, int, char **argv);
-static void print_owners_cb(mrp_console_t *, void *, int, char **argv);
-
-static void resource_event_handler(uint32_t, mrp_resource_set_t *, void *);
-
-
-MRP_CONSOLE_GROUP(resource_group, "resource", NULL, NULL, {
-        MRP_TOKENIZED_CMD("zones"  , print_zones_cb, FALSE,
-                          "zones", "prints zones",
-                          "prints the available zones. The data sources "
-                          "for the printout are the internal data structures "
-                          "of the resource library."),
-        MRP_TOKENIZED_CMD("classes"  , print_classes_cb, FALSE,
-                          "classes", "prints application classes",
-                          "prints the available application classes. The "
-                          "data sources for the printout are the internal "
-                          "data structures of the resource library."),
-        MRP_TOKENIZED_CMD("sets", print_sets_cb, FALSE,
-                          "sets", "prints resource sets",
-                          "prints the current resource sets for each "
-                          "application class. The data sources for the "
-                          "printout are the internal data structures of the "
-                          "resource library"),
-        MRP_TOKENIZED_CMD("owners" , print_owners_cb , TRUE,
-                          "owners", "prints resource owners",
-                          "prints for each zone the owner application class "
-                          "of each resource. The data sources for the "
-                          "printout are the internal data structures of the "
-                          "resource library")
-
-});
-
-
-static void print_zones_cb(mrp_console_t *c, void *user_data,
-                           int argc, char **argv)
-{
-    const char **zone_names;
-    int i;
-
-    MRP_UNUSED(user_data);
-    MRP_UNUSED(argc);
-    MRP_UNUSED(argv);
-
-    mrp_console_printf(c, "Zones:\n");
-
-    if ((zone_names = mrp_zone_get_all_names(0, NULL))) {
-
-        for (i = 0;  zone_names[i];  i++)
-            mrp_console_printf (c, "   %s\n", zone_names[i]);
-
-
-        mrp_free(zone_names);
-    }
-}
-
-
-static void print_classes_cb(mrp_console_t *c, void *user_data,
-                             int argc, char **argv)
-{
-    const char **class_names;
-    int i;
-
-    MRP_UNUSED(user_data);
-    MRP_UNUSED(argc);
-    MRP_UNUSED(argv);
-
-    mrp_console_printf(c, "Application classes:\n");
-
-    if ((class_names = mrp_application_class_get_all_names(0, NULL))) {
-
-        for (i = 0;  class_names[i];  i++)
-            mrp_console_printf(c, "   %s\n", class_names[i]);
-
-
-        mrp_free(class_names);
-    }
-}
-
-
-static void print_sets_cb(mrp_console_t *c, void *user_data,
-                          int argc, char **argv)
-{
-    char buf[8192];
-
-    MRP_UNUSED(user_data);
-    MRP_UNUSED(argc);
-    MRP_UNUSED(argv);
-
-    mrp_application_class_print(buf, sizeof(buf));
-
-    mrp_console_printf(c, "%s", buf);
-}
-
-
-static void print_owners_cb(mrp_console_t *c, void *user_data,
-                            int argc, char **argv)
-{
-    char buf[2048];
-
-    MRP_UNUSED(user_data);
-    MRP_UNUSED(argc);
-    MRP_UNUSED(argv);
-
-    mrp_resource_owner_print(buf, sizeof(buf));
-
-    mrp_console_printf(c, "%s", buf);
-}
-
-static int set_default_configuration(void)
-{
-    typedef struct {
-        const char     *name;
-        bool            share;
-        mrp_attr_def_t *attrs;
-    } resdef_t;
-
-    static const char *zones[] = {
-        "driver",
-        "front-passenger",
-        "rear-left-passenger",
-        "rear-right-passenger",
-        NULL
-    };
-
-    static const char *classes[] = {
-        "implicit",
-        "player",
-        "game",
-        "phone",
-        "navigator",
-        NULL
-    };
-
-    static mrp_attr_def_t audio_attrs[] = {
-        { "role", MRP_RESOURCE_RW, mqi_string , .value.string="music" },
-        {  NULL ,        0       , mqi_unknown, .value.string=NULL    }
-    };
-
-    static resdef_t  resources[] = {
-        { "audio_playback" , true , audio_attrs  },
-        { "audio_recording", true , NULL         },
-        { "video_playback" , false, NULL         },
-        { "video_recording", false, NULL         },
-        {      NULL        , false, NULL         }
-    };
-
-    const char *name;
-    resdef_t *rdef;
-    uint32_t i;
-
-    mrp_zone_definition_create(NULL);
-
-    for (i = 0;  (name = zones[i]);  i++)
-        mrp_zone_create(name, NULL);
-
-    for (i = 0;  (name = classes[i]); i++)
-        mrp_application_class_create(name, i);
-
-    for (i = 0;  (rdef = resources + i)->name;  i++) {
-        mrp_resource_definition_create(rdef->name, rdef->share, rdef->attrs,
-                                       NULL, NULL);
-    }
-
-    return 0;
-}
-
-
-static void reply_with_array(client_t *client, mrp_msg_t *msg,
-                             uint16_t tag, const char **arr)
-{
-    resource_data_t *data   = client->data;
-    mrp_plugin_t    *plugin = data->plugin;
-    uint16_t         dim;
-    bool             s;
-
-    for (dim = 0;  arr[dim];  dim++)
-        ;
-
-    s  = mrp_msg_append(msg, MRP_MSG_TAG_SINT16(RESPROTO_REQUEST_STATUS, 0));
-    s &= mrp_msg_append(msg, MRP_MSG_TAG_STRING_ARRAY(tag, dim, arr));
-
-    if (!s) {
-        mrp_log_error("%s: failed to build reply", plugin->instance);
-        return;
-    }
-
-    if (!mrp_transport_send(client->transp, msg))
-        mrp_log_error("%s: failed to send reply", plugin->instance);
-}
-
-static void reply_with_status(client_t *client, mrp_msg_t *msg, int16_t err)
-{
-    if (!mrp_msg_append(msg,MRP_MSG_TAG_SINT16(RESPROTO_REQUEST_STATUS,err)) ||
-        !mrp_transport_send(client->transp, msg))
-    {
-        resource_data_t *data   = client->data;
-        mrp_plugin_t    *plugin = data->plugin;
-
-        mrp_log_error("%s: failed to create or send reply", plugin->instance);
-    }
-}
-
-
-static bool write_attributes(mrp_msg_t *msg, mrp_attr_t *attrs)
-{
-#define PUSH(m, tag, typ, val)    \
-    mrp_msg_append(m, MRP_MSG_TAG_##typ(RESPROTO_##tag, val))
-
-    mrp_attr_t *a;
-    bool ok;
-
-    if (attrs) {
-        for (a = attrs;  a->name;  a++) {
-            if (!PUSH(msg, ATTRIBUTE_NAME, STRING, a->name))
-                return false;;
-
-            switch (a->type) {
-            case mqi_string:
-                ok = PUSH(msg, ATTRIBUTE_VALUE, STRING, a->value.string);
-                break;
-            case mqi_integer:
-                ok = PUSH(msg, ATTRIBUTE_VALUE, SINT32, a->value.integer);
-                break;
-            case mqi_unsignd:
-                ok = PUSH(msg, ATTRIBUTE_VALUE, UINT32, a->value.unsignd);
-                break;
-            case mqi_floating:
-                ok = PUSH(msg, ATTRIBUTE_VALUE, DOUBLE, a->value.floating);
-                break;
-            default:
-                ok = false;
-                break;
-            }
-
-            if (!ok)
-                return false;
-        }
-    }
-
-    if (!PUSH(msg, SECTION_END, UINT8, 0))
-        return false;
-
-    return true;
-
-#undef PUSH
-}
-
-
-static void query_resources_request(client_t *client, mrp_msg_t *req)
-{
-#define PUSH(m, tag, typ, val)    \
-    mrp_msg_append(m, MRP_MSG_TAG_##typ(RESPROTO_##tag, val))
-
-
-    resource_data_t  *data   = client->data;
-    mrp_plugin_t     *plugin = data->plugin;
-    const char      **names;
-    mrp_attr_t       *attrs;
-    mrp_attr_t        buf[ATTRIBUTE_MAX];
-    uint32_t          resid;
-
-    if (!(names = mrp_resource_definition_get_all_names(0, NULL)))
-        reply_with_status(client, req, ENOMEM);
-    else {
-        if (!PUSH(req, REQUEST_STATUS, SINT16, 0))
-            goto failed;
-        else {
-            for (resid = 0;   names[resid];   resid++) {
-                attrs = mrp_resource_definition_read_all_attributes(
-                                                    resid, ATTRIBUTE_MAX, buf);
-
-                if (!PUSH(req, RESOURCE_NAME, STRING, names[resid]) ||
-                    !write_attributes(req, attrs))
-                    goto failed;
-            }
-
-            if (!mrp_transport_send(client->transp, req))
-                mrp_log_error("%s: failed to send reply", plugin->instance);
-
-            mrp_free(names);
-        }
-    }
-
-    return;
-
- failed:
-    mrp_log_error("%s: can't build recource query reply message",
-                  plugin->instance);
-    mrp_free(names);
-
-
-#undef PUSH
-}
-
-static void query_classes_request(client_t *client, mrp_msg_t *req)
-{
-    const char **names = mrp_application_class_get_all_names(0, NULL);
-
-    if (!names)
-        reply_with_status(client, req, ENOMEM);
-    else {
-        reply_with_array(client, req, RESPROTO_CLASS_NAME, names);
-        mrp_free(names);
-    }
-}
-
-static void query_zones_request(client_t *client, mrp_msg_t *req)
-{
-    const char **names = mrp_zone_get_all_names(0, NULL);
-
-    if (!names)
-        reply_with_status(client, req, ENOMEM);
-    else {
-        reply_with_array(client, req, RESPROTO_ZONE_NAME, names);
-        mrp_free(names);
-    }
-}
-
-static int read_attribute(mrp_msg_t *req, mrp_attr_t *attr, void **pcurs)
-{
-    uint16_t tag;
-    uint16_t type;
-    size_t size;
-    mrp_msg_value_t value;
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size))
-        return ATTRIBUTE_ERROR;
-
-    if (tag == RESPROTO_SECTION_END)
-        return ATTRIBUTE_LAST;
-
-    if (tag != RESPROTO_ATTRIBUTE_NAME || type != MRP_MSG_FIELD_STRING)
-        return ATTRIBUTE_ERROR;
-
-    attr->name = value.str;
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size) ||
-        tag != RESPROTO_ATTRIBUTE_VALUE)
-        return ATTRIBUTE_ERROR;
-
-    switch (type) {
-    case MRP_MSG_FIELD_STRING:
-        attr->type = mqi_string;
-        attr->value.string = value.str;
-        break;
-    case MRP_MSG_FIELD_SINT32:
-        attr->type = mqi_integer;
-        attr->value.integer = value.s32;
-        break;
-    case MRP_MSG_FIELD_UINT32:
-        attr->type = mqi_unsignd;
-        attr->value.unsignd = value.u32;
-        break;
-    case MRP_MSG_FIELD_DOUBLE:
-        attr->type = mqi_floating;
-        attr->value.floating = value.dbl;
-        break;
-    default:
-        return ATTRIBUTE_ERROR;
-    }
-
-    {
-        char str[256];
-
-        switch (attr->type) {
-        case mqi_string:
-            snprintf(str, sizeof(str), "'%s'", attr->value.string);
-            break;
-        case mqi_integer:
-            snprintf(str, sizeof(str), "%d", attr->value.integer);
-            break;
-        case mqi_unsignd:
-            snprintf(str, sizeof(str), "%u", attr->value.unsignd);
-            break;
-        case mqi_floating:
-            snprintf(str, sizeof(str), "%.2lf", attr->value.floating);
-            break;
-        default:
-            snprintf(str, sizeof(str), "< ??? >");
-            break;
-        }
-
-        mrp_log_info("      attribute %s:%s", attr->name, str);
-    }
-
-    return ATTRIBUTE_OK;
-}
-
-
-static int read_resource(mrp_resource_set_t *rset, mrp_msg_t *req,void **pcurs)
-{
-    uint16_t        tag;
-    uint16_t        type;
-    size_t          size;
-    mrp_msg_value_t value;
-    const char     *name;
-    bool            mand;
-    bool            shared;
-    mrp_attr_t      attrs[ATTRIBUTE_MAX + 1];
-    uint32_t        i;
-    int             arst;
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size))
-        return RESOURCE_LAST;
-
-    if (tag != RESPROTO_RESOURCE_NAME || type != MRP_MSG_FIELD_STRING)
-        return RESOURCE_ERROR;
-
-    name = value.str;
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size) ||
-        tag != RESPROTO_RESOURCE_FLAGS || type != MRP_MSG_FIELD_UINT32)
-        return RESOURCE_ERROR;
-
-    mand   = (value.u32 & RESPROTO_RESFLAG_MANDATORY) ? true : false;
-    shared = (value.u32 & RESPROTO_RESFLAG_SHARED)    ? true : false;
-
-    mrp_log_info("   resource: name:'%s' %s %s", name,
-                 mand?"mandatory":"optional ", shared?"shared":"exclusive");
-
-    for (i = 0, arst = 0;    i < ATTRIBUTE_MAX && arst == 0;    i++)
-        arst = read_attribute(req, attrs + i, pcurs);
-
-    memset(attrs + i, 0, sizeof(mrp_attr_t));
-
-    if (arst > 0) {
-        if (mrp_resource_set_add_resource(rset, name, shared, attrs, mand) < 0)
-            arst = RESOURCE_ERROR;
-        else
-            arst = 0;
-    }
-
-    return arst;
-}
-
-
-static void create_resource_set_request(client_t *client, mrp_msg_t *req,
-                                        uint32_t seqno, void **pcurs)
-{
-    static uint16_t reqtyp = RESPROTO_CREATE_RESOURCE_SET;
-
-    resource_data_t    *data   = client->data;
-    mrp_plugin_t       *plugin = data->plugin;
-    mrp_resource_set_t *rset   = 0;
-    mrp_msg_t          *rpl;
-    uint32_t            flags;
-    uint32_t            priority;
-    const char         *class;
-    const char         *zone;
-    uint16_t            tag;
-    uint16_t            type;
-    size_t              size;
-    mrp_msg_value_t     value;
-    uint32_t            rsid;
-    int                 arst;
-    int32_t             status;
-    bool                auto_release;
-
-    MRP_ASSERT(client, "invalid argument");
-    MRP_ASSERT(client->rscli, "confused with data structures");
-
-    rsid = MRP_RESOURCE_ID_INVALID;
-    status = EINVAL;
-
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size) ||
-        tag != RESPROTO_RESOURCE_FLAGS || type != MRP_MSG_FIELD_UINT32)
-        goto reply;
-
-    flags = value.u32;
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size) ||
-        tag != RESPROTO_RESOURCE_PRIORITY || type != MRP_MSG_FIELD_UINT32)
-        goto reply;
-
-    priority = value.u32;
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size) ||
-        tag != RESPROTO_CLASS_NAME || type != MRP_MSG_FIELD_STRING)
-        goto reply;
-
-    class = value.str;
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size) ||
-        tag != RESPROTO_ZONE_NAME || type != MRP_MSG_FIELD_STRING)
-        goto reply;
-
-    zone = value.str;
-
-    mrp_log_info("resource-set flags:%u priority:%u class:'%s' zone:'%s'",
-                 flags, priority, class, zone);
-
-    auto_release = (flags & RESPROTO_RSETFLAG_AUTORELEASE);
-
-    rset = mrp_resource_set_create(client->rscli, auto_release, priority,
-                                   resource_event_handler, client);
-    if (!rset)
-        goto reply;
-
-    rsid = mrp_get_resource_set_id(rset);
-
-    while ((arst = read_resource(rset, req, pcurs)) == 0)
-        ;
-
-    if (arst > 0) {
-        if (mrp_application_class_add_resource_set(class,zone,rset,seqno) == 0)
-            status = 0;
-    }
-
- reply:
-    rpl = mrp_msg_create(MRP_MSG_TAG_UINT32( RESPROTO_SEQUENCE_NO    , seqno ),
-                         MRP_MSG_TAG_UINT16( RESPROTO_REQUEST_TYPE   , reqtyp),
-                         MRP_MSG_TAG_SINT16( RESPROTO_REQUEST_STATUS , status),
-                         MRP_MSG_TAG_UINT32( RESPROTO_RESOURCE_SET_ID, rsid  ),
-                         RESPROTO_MESSAGE_END                                );
-    if (!rpl || !mrp_transport_send(client->transp, rpl)) {
-        mrp_log_error("%s: failed to send reply", plugin->instance);
-        return;
-    }
-
-    mrp_msg_unref(rpl);
-
-    if (status != 0)
-        mrp_resource_set_destroy(rset);
-}
-
-static void destroy_resource_set_request(client_t *client, mrp_msg_t *req,
-                                         void **pcurs)
-{
-    uint16_t            tag;
-    uint16_t            type;
-    size_t              size;
-    mrp_msg_value_t     value;
-    uint32_t            rset_id;
-    mrp_resource_set_t *rset;
-
-    MRP_ASSERT(client, "invalid argument");
-    MRP_ASSERT(client->rscli, "confused with data structures");
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size) ||
-        tag != RESPROTO_RESOURCE_SET_ID || type != MRP_MSG_FIELD_UINT32)
-    {
-        reply_with_status(client, req, EINVAL);
-        return;
-    }
-
-    rset_id = value.u32;
-
-    if (!(rset = mrp_resource_client_find_set(client->rscli, rset_id))) {
-        reply_with_status(client, req, ENOENT);
-        return;
-    }
-
-    reply_with_status(client, req, 0);
-
-    mrp_resource_set_destroy(rset);
-}
-
-
-static void acquire_resource_set_request(client_t *client, mrp_msg_t *req,
-                                         uint32_t seqno, bool acquire,
-                                         void **pcurs)
-{
-    uint16_t            tag;
-    uint16_t            type;
-    size_t              size;
-    mrp_msg_value_t     value;
-    uint32_t            rset_id;
-    mrp_resource_set_t *rset;
-
-    MRP_ASSERT(client, "invalid argument");
-    MRP_ASSERT(client->rscli, "confused with data structures");
-
-    if (!mrp_msg_iterate(req, pcurs, &tag, &type, &value, &size) ||
-        tag != RESPROTO_RESOURCE_SET_ID || type != MRP_MSG_FIELD_UINT32)
-    {
-        reply_with_status(client, req, EINVAL);
-        return;
-    }
-
-    rset_id = value.u32;
-
-    if (!(rset = mrp_resource_client_find_set(client->rscli, rset_id))) {
-        reply_with_status(client, req, ENOENT);
-        return;
-    }
-
-    reply_with_status(client, req, 0);
-
-    if (acquire)
-        mrp_resource_set_acquire(rset, seqno);
-    else
-        mrp_resource_set_release(rset, seqno);
-}
-
-static void connection_evt(mrp_transport_t *listen, void *user_data)
-{
-    static uint32_t  id;
-
-    resource_data_t *data   = (resource_data_t *)user_data;
-    mrp_plugin_t    *plugin = data->plugin;
-    int              flags  = MRP_TRANSPORT_REUSEADDR | MRP_TRANSPORT_NONBLOCK;
-    client_t        *client = mrp_allocz(sizeof(client_t));
-    char             name[256];
-
-    if (!client) {
-        mrp_log_error("%s: Memory alloc error. Can't accept new connection",
-                      plugin->instance);
-        return;
-    }
-
-    client->data = data;
-
-    snprintf(name, sizeof(name), "client%u", (client->id = ++id));
-    client->rscli = mrp_resource_client_create(name, client);
-
-    if (!(client->transp = mrp_transport_accept(listen, client, flags))) {
-        mrp_log_error("%s: failed to accept new connection", plugin->instance);
-        mrp_resource_client_destroy(client->rscli);
-        mrp_free(client);
-        return;
-    }
-
-    mrp_list_append(&data->clients, &client->list);
-
-    mrp_log_info("%s: %s connected", plugin->instance, name);
-}
-
-static void closed_evt(mrp_transport_t *transp, int error, void *user_data)
-{
-    client_t        *client = (client_t *)user_data;
-    resource_data_t *data   = client->data;
-    mrp_plugin_t    *plugin = data->plugin;
-
-    MRP_UNUSED(transp);
-
-    if (error)
-        mrp_log_error("%s: connection error %d (%s)",
-                      plugin->instance, error, strerror(error));
-    else
-        mrp_log_info("%s: peer closed connection", plugin->instance);
-
-    mrp_resource_client_destroy(client->rscli);
-
-    mrp_list_delete(&client->list);
-    mrp_free(client);
-}
-
-
-
-static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
-                         mrp_sockaddr_t *addr, socklen_t addrlen,
-                         void *user_data)
-{
-    client_t               *client = (client_t *)user_data;
-    resource_data_t        *data   = client->data;
-    mrp_plugin_t           *plugin = data->plugin;
-    void                   *cursor = NULL;
-    uint32_t                seqno;
-    mrp_resproto_request_t  reqtyp;
-    uint16_t                tag;
-    uint16_t                type;
-    size_t                  size;
-    mrp_msg_value_t         value;
-
-
-    MRP_UNUSED(addr);
-    MRP_UNUSED(addrlen);
-
-    MRP_ASSERT(client->transp == transp, "confused with data structures");
-
-    mrp_log_info("%s: received a message", plugin->instance);
-    mrp_msg_dump(msg, stdout);
-
-
-    if (mrp_msg_iterate(msg, &cursor, &tag, &type, &value, &size) &&
-        tag == RESPROTO_SEQUENCE_NO && type == MRP_MSG_FIELD_UINT32)
-        seqno = value.u32;
-    else {
-        mrp_log_warning("%s: malformed message. Bad or missing "
-                        "sequence number", plugin->instance);
-        return;
-    }
-
-    if (mrp_msg_iterate(msg, &cursor, &tag, &type, &value, &size) &&
-        tag == RESPROTO_REQUEST_TYPE && type == MRP_MSG_FIELD_UINT16)
-        reqtyp = value.u16;
-    else {
-        mrp_log_warning("%s: malformed message. Bad or missing "
-                        "request type", plugin->instance);
-        return;
-    }
-
-    switch (reqtyp) {
-
-    case RESPROTO_QUERY_RESOURCES:
-        query_resources_request(client, msg);
-        break;
-
-    case RESPROTO_QUERY_CLASSES:
-        query_classes_request(client, msg);
-        break;
-
-    case RESPROTO_QUERY_ZONES:
-        query_zones_request(client, msg);
-        break;
-
-    case RESPROTO_CREATE_RESOURCE_SET:
-        create_resource_set_request(client, msg, seqno, &cursor);
-        break;
-
-    case RESPROTO_DESTROY_RESOURCE_SET:
-        destroy_resource_set_request(client, msg, &cursor);
-        break;
-
-    case RESPROTO_ACQUIRE_RESOURCE_SET:
-        acquire_resource_set_request(client, msg, seqno, true, &cursor);
-        break;
-
-    case RESPROTO_RELEASE_RESOURCE_SET:
-        acquire_resource_set_request(client, msg, seqno, false, &cursor);
-        break;
-
-    default:
-        mrp_log_warning("%s: unsupported request type %d",
-                        plugin->instance, reqtyp);
-        break;
-    }
-}
-
-static void recv_msg(mrp_transport_t *transp, mrp_msg_t *msg, void *user_data)
-{
-    return recvfrom_msg(transp, msg, NULL, 0, user_data);
-}
-
-
-static void resource_event_handler(uint32_t reqid, mrp_resource_set_t *rset,
-                                   void *userdata)
-{
-#define FIELD(tag, typ, val)      \
-    RESPROTO_##tag, MRP_MSG_FIELD_##typ, val
-#define PUSH(m, tag, typ, val)    \
-    mrp_msg_append(m, MRP_MSG_TAG_##typ(RESPROTO_##tag, val))
-
-    client_t           *client = (client_t *)userdata;
-    resource_data_t    *data   = client->data;
-    mrp_plugin_t       *plugin = data->plugin;
-    uint16_t            reqtyp;
-    uint16_t            state;
-    mrp_resource_mask_t grant;
-    mrp_resource_mask_t advice;
-    mrp_resource_mask_t mask;
-    mrp_resource_mask_t all;
-    mrp_msg_t          *msg;
-    mrp_resource_t     *res;
-    uint32_t            id;
-    const char         *name;
-    void               *curs;
-    mrp_attr_t          attrs[ATTRIBUTE_MAX + 1];
-
-    MRP_ASSERT(rset && client, "invalid argument");
-
-    reqtyp = RESPROTO_RESOURCES_EVENT;
-    id     = mrp_get_resource_set_id(rset);
-    grant  = mrp_get_resource_set_grant(rset);
-    advice = mrp_get_resource_set_advice(rset);
-
-    if (mrp_get_resource_set_state(rset) == mrp_resource_acquire)
-        state = RESPROTO_ACQUIRE;
-    else
-        state = RESPROTO_RELEASE;
-
-    msg = mrp_msg_create(FIELD( SEQUENCE_NO    , UINT32, reqid  ),
-                         FIELD( REQUEST_TYPE   , UINT16, reqtyp ),
-                         FIELD( RESOURCE_SET_ID, UINT32, id     ),
-                         FIELD( RESOURCE_STATE , UINT16, state  ),
-                         FIELD( RESOURCE_GRANT , UINT32, grant  ),
-                         FIELD( RESOURCE_ADVICE, UINT32, advice ),
-                         RESPROTO_MESSAGE_END                   );
-
-    if (!msg)
-        goto failed;
-
-    all = grant | advice;
-    curs = NULL;
-
-    while ((res = mrp_resource_set_iterate_resources(rset, &curs))) {
-        mask = mrp_resource_get_mask(res);
-
-        if (!(all & mask))
-            continue;
-
-        id = mrp_resource_get_id(res);
-        name = mrp_resource_get_name(res);
-
-         if (!PUSH(msg, RESOURCE_ID  , UINT32, id  ) ||
-             !PUSH(msg, RESOURCE_NAME, STRING, name)  )
-             goto failed;
-
-         if (!mrp_resource_read_all_attributes(res, ATTRIBUTE_MAX + 1, attrs))
-             goto failed;
-
-         if (!write_attributes(msg, attrs))
-                 goto failed;
-    }
-
-    if (!mrp_transport_send(client->transp, msg))
-        goto failed;
-
-    mrp_msg_unref(msg);
-
-    return;
-
-    failed:
-         mrp_log_error("%s: failed to build/send message for resource event",
-                       plugin->instance);
-         mrp_msg_unref(msg);
-
-#undef PUSH
-#undef FIELD
-}
-
-
-
-static int initiate_transport(mrp_plugin_t *plugin)
-{
-    static mrp_transport_evt_t evt = {
-        { .recvmsg = recv_msg },
-        { .recvmsgfrom = recvfrom_msg },
-        .closed = NULL,
-        .connection = NULL
-    };
-
-    mrp_context_t    *ctx   = plugin->ctx;
-    mrp_plugin_arg_t *args  = plugin->args;
-    resource_data_t  *data  = (resource_data_t *)plugin->data;
-    const char       *addr  = args[ARG_ADDRESS].str;
-    int               flags = MRP_TRANSPORT_REUSEADDR;
-    bool              stream;
-
-    data->alen = mrp_transport_resolve(NULL, addr, &data->saddr,
-                                       sizeof(data->saddr), &data->atyp);
-
-    if (data->alen <= 0) {
-        mrp_log_error("%s: failed to resolve transport arddress '%s'",
-                      plugin->instance, addr);
-        return -1;
-    }
-
-
-    if (strncmp(addr, "tcp", 3) && strncmp(addr, "unxs", 4))
-        stream = false;
-    else {
-        stream = true;
-        evt.connection = connection_evt;
-        evt.closed = closed_evt;
-    }
-
-    data->listen = mrp_transport_create(ctx->ml, data->atyp, &evt, data,flags);
-
-    if (!data->listen) {
-        mrp_log_error("%s: can't create listening transport",plugin->instance);
-        return -1;
-    }
-
-    if (!mrp_transport_bind(data->listen, &data->saddr, data->alen)) {
-        mrp_log_error("%s: can't bind to address %s", plugin->instance, addr);
-        return -1;
-    }
-
-    if (stream && !mrp_transport_listen(data->listen, 0)) {
-        mrp_log_error("%s: can't listen for connections", plugin->instance);
-        return -1;
-    }
-
-    mrp_log_info("%s: listening for connections on %s", plugin->instance,addr);
-
-    return 0;
-}
-
-
-static void event_cb(mrp_event_watch_t *w, int id, mrp_msg_t *event_data,
-                     void *user_data)
-{
-    mrp_plugin_t     *plugin = (mrp_plugin_t *)user_data;
-    mrp_plugin_arg_t *args   = plugin->args;
-    resource_data_t  *data   = (resource_data_t *)plugin->data;
-    const char       *event  = mrp_get_event_name(id);
-    const char       *cfgfile;
-
-    MRP_UNUSED(w);
-    MRP_UNUSED(event_data);
-
-
-    mrp_log_info("%s: got event 0x%x (%s):", plugin->instance, id, event);
-
-    if (data && event) {
-        if (!strcmp(event, MRP_PLUGIN_EVENT_STARTED)) {
-            cfgfile = args[ARG_CONFIG_FILE].str;
-
-            set_default_configuration();
-            mrp_log_info("%s: built-in default configuration is in use",
-                         plugin->instance);
-
-            initiate_transport(plugin);
-
-            return;
-        }
-    }
-}
-
-
-static int subscribe_events(mrp_plugin_t *plugin)
-{
-    resource_data_t  *data = (resource_data_t *)plugin->data;
-    mrp_event_mask_t  events;
-
-    mrp_set_named_events(&events,
-                         MRP_PLUGIN_EVENT_LOADED,
-                         MRP_PLUGIN_EVENT_STARTED,
-                         MRP_PLUGIN_EVENT_FAILED,
-                         MRP_PLUGIN_EVENT_STOPPING,
-                         MRP_PLUGIN_EVENT_STOPPED,
-                         MRP_PLUGIN_EVENT_UNLOADED,
-                         NULL);
-
-    data->w = mrp_add_event_watch(&events, event_cb, plugin);
-
-    return (data->w != NULL);
-}
-
-
-static void unsubscribe_events(mrp_plugin_t *plugin)
-{
-    resource_data_t *data = (resource_data_t *)plugin->data;
-
-    if (data->w) {
-        mrp_del_event_watch(data->w);
-        data->w = NULL;
-    }
-}
-
-
-
-static int resource_init(mrp_plugin_t *plugin)
-{
-    mrp_plugin_arg_t *args;
-    resource_data_t  *data;
-
-    mrp_log_info("%s() called for resource instance '%s'...", __FUNCTION__,
-                 plugin->instance);
-
-    args = plugin->args;
-    mrp_log_info(" config-file:  '%s'", args[ARG_CONFIG_FILE].str);
-
-
-    if (!(data = mrp_allocz(sizeof(*data)))) {
-        mrp_log_error("Failed to allocate private data for resource plugin "
-                      "instance %s.", plugin->instance);
-        return FALSE;
-    }
-
-    data->plugin = plugin;
-    mrp_list_init(&data->clients);
-
-    plugin->data = data;
-
-    subscribe_events(plugin);
-
-    return TRUE;
-}
-
-
-static void resource_exit(mrp_plugin_t *plugin)
-{
-    mrp_log_info("%s() called for test instance '%s'...", __FUNCTION__,
-                 plugin->instance);
-
-    unsubscribe_events(plugin);
-}
-
-
-#define RESOURCE_DESCRIPTION "Plugin to implement resource message protocol"
-#define RESOURCE_HELP        "Maybe later ..."
-#define RESOURCE_VERSION     MRP_VERSION_INT(0, 0, 1)
-#define RESOURCE_AUTHORS     "Janos Kovacs <jankovac503@gmail.com>"
-
-#define DEF_CONFIG_FILE      "/etc/murphy/resource.conf"
-#define DEF_ADDRESS          RESPROTO_DEFAULT_ADDRESS
-
-static mrp_plugin_arg_t args[] = {
-    MRP_PLUGIN_ARGIDX(ARG_CONFIG_FILE, STRING, "config-file", DEF_CONFIG_FILE),
-    MRP_PLUGIN_ARGIDX(ARG_ADDRESS    , STRING, "address"    , DEF_ADDRESS    ),
-};
-
-
-MURPHY_REGISTER_PLUGIN("resource",
-                       RESOURCE_VERSION,
-                       RESOURCE_DESCRIPTION,
-                       RESOURCE_AUTHORS,
-                       RESOURCE_HELP,
-                       MRP_SINGLETON,
-                       resource_init,
-                       resource_exit,
-                       args, MRP_ARRAY_SIZE(args),
-#if 0
-                       exports, MRP_ARRAY_SIZE(exports),
-                       imports, MRP_ARRAY_SIZE(imports),
-#else
-                       NULL, 0,
-                       NULL, 0,
-#endif
-                       &resource_group);
diff --git a/src/plugins/resource-native/resource-client.c b/src/plugins/resource-native/resource-client.c
deleted file mode 100644 (file)
index 284ffd7..0000000
+++ /dev/null
@@ -1,1611 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <strings.h>
-#include <signal.h>
-#include <ctype.h>
-#include <libgen.h>
-#include <errno.h>
-
-#include <murphy/common.h>
-#include <murphy/resource/protocol.h>
-
-#define ARRAY_MAX      1024
-#define RESOURCE_MAX   32
-#define ATTRIBUTE_MAX  32
-
-#define INVALID_ID      (~(uint32_t)0)
-#define INVALID_INDEX   (~(uint32_t)0)
-#define INVALID_SEQNO   (~(uint32_t)0)
-#define INVALID_REQUEST (~(uint16_t)0)
-
-#define GRANT           0
-#define ADVICE          1
-
-
-typedef struct {
-    uint32_t        dim;
-    const char     *elems[0];
-} string_array_t;
-
-typedef struct {
-    const char     *name;
-    char            type;       /* s:char *, i:int32_t, u:uint32_t, f:double */
-    union {
-        const char *string;
-        int32_t     integer;
-        uint32_t    unsignd;
-        double      floating;
-    };
-} attribute_t;
-
-typedef struct {
-    uint32_t       dim;
-    attribute_t    elems[0];
-} attribute_array_t;
-
-typedef struct {
-    const char        *name;
-    attribute_array_t *attrs;
-} resource_def_t;
-
-typedef struct {
-    uint32_t          dim;
-    resource_def_t    defs[0];
-} resource_def_array_t;
-
-typedef struct {
-    const char           *name;
-    mrp_mainloop_t       *ml;
-    mrp_transport_t      *transp;
-    mrp_sockaddr_t        saddr;
-    socklen_t             alen;
-    const char           *atype;
-    uint32_t              seqno;
-    bool                  prompt;
-    bool                  msgdump;
-    char *                class;
-    char *                zone;
-    char *                rsetd;
-    uint32_t              rsetf;
-    resource_def_array_t *resources;
-    string_array_t       *class_names;
-    string_array_t       *zone_names;
-    uint32_t              rset_id;
-} client_t;
-
-
-static void print_prompt(client_t *, bool);
-
-
-static void str_array_free(string_array_t *arr)
-{
-    uint32_t i;
-
-    if (arr) {
-        for (i = 0;  i < arr->dim;  i++)
-            mrp_free((void *)arr->elems[i]);
-
-        mrp_free(arr);
-    }
-}
-
-static string_array_t *str_array_dup(uint32_t dim, const char **arr)
-{
-    size_t size;
-    uint32_t i;
-    string_array_t *dup;
-
-    MRP_ASSERT(dim < ARRAY_MAX && arr, "invalid argument");
-
-    if (!dim && arr) {
-        for (dim = 0;  arr[dim];  dim++)
-            ;
-    }
-
-    size = sizeof(string_array_t) + (sizeof(const char *) * (dim + 1));
-
-    if (!(dup = mrp_allocz(size))) {
-        errno = ENOMEM;
-        return NULL;
-    }
-
-    dup->dim = dim;
-
-    for (i = 0;   i < dim;   i++) {
-        if (arr[i]) {
-            if (!(dup->elems[i] = mrp_strdup(arr[i]))) {
-                errno = ENOMEM;
-                /* probably no use for freing anything */
-                return NULL;
-            }
-        }
-    }
-
-    return dup;
-}
-
-
-static int str_array_print(string_array_t *arr, const char *hdr,
-                           const char *sep, const char *trail,
-                           char *buf, int len)
-{
-    uint32_t i;
-    int cnt;
-
-    char *p, *e;
-
-    if (!sep)
-        sep = " ";
-
-    e = (p = buf) + len;
-    cnt = 0;
-
-    if (hdr && p < e)
-        p += snprintf(p, e-p, "%s", hdr);
-
-    if (arr) {
-        for (i = 0;  i < arr->dim && p < e;  i++) {
-            p += snprintf(p, e-p, "%s'%s'", sep, arr->elems[i]);
-            cnt++;
-        }
-    }
-
-    if (!cnt && p < e)
-        p += snprintf(p, e-p, "%s<none>", sep);
-
-    if (trail && hdr && p < e)
-        p += snprintf(p, e-p, "%s", trail);
-
-    return p - buf;
-}
-
-#if 0
-static uint32_t str_array_index(string_array_t *arr, const char *member)
-{
-    uint32_t i;
-
-    if (arr && member) {
-        for (i = 0;  i < arr->dim;  i++) {
-            if (!strcmp(member, arr->elems[i]))
-                return i;
-        }
-    }
-
-    return INVALID_INDEX;
-}
-#endif
-
-static void attribute_array_free(attribute_array_t *arr)
-{
-    uint32_t i;
-    attribute_t *attr;
-
-    if (arr) {
-        for (i = 0;   i < arr->dim;   i++) {
-            attr = arr->elems + i;
-
-            mrp_free((void *)attr->name);
-
-            if (attr->type == 's')
-                mrp_free((void *)attr->string);
-        }
-        mrp_free(arr);
-    }
-}
-
-static attribute_array_t *attribute_array_dup(uint32_t dim, attribute_t *arr)
-{
-    size_t size;
-    uint32_t i;
-    attribute_t *sattr, *dattr;
-    attribute_array_t *dup;
-    int err;
-
-    MRP_ASSERT(dim < ARRAY_MAX && arr, "invalid argument");
-
-    if (!dim && arr) {
-        for (dim = 0;  arr[dim].name;  dim++)
-            ;
-    }
-
-    size = sizeof(attribute_array_t) + (sizeof(attribute_t) * (dim + 1));
-
-    if (!(dup = mrp_allocz(size))) {
-        err = ENOMEM;
-        goto failed;
-    }
-
-    dup->dim = dim;
-
-    for (i = 0;    i < dim;    i++) {
-        sattr = arr + i;
-        dattr = dup->elems + i;
-
-        if (!(dattr->name = mrp_strdup(sattr->name))) {
-            err = ENOMEM;
-            goto failed;
-        }
-
-        switch ((dattr->type = sattr->type)) {
-        case 's':
-            if (!(dattr->string = mrp_strdup(sattr->string))) {
-                err = ENOMEM;
-                goto failed;
-            }
-            break;
-        case 'i':
-            dattr->integer = sattr->integer;
-            break;
-        case 'u':
-            dattr->unsignd = sattr->unsignd;
-            break;
-        case 'f':
-            dattr->floating = sattr->floating;
-            break;
-        default:
-            errno = EINVAL;
-            goto failed;
-        }
-    }
-
-    return dup;
-
- failed:
-    attribute_array_free(dup);
-    errno = err;
-    return NULL;
-}
-
-
-static int attribute_array_print(attribute_array_t *arr, const char *hdr,
-                                 const char *sep, const char *trail,
-                                 char *buf, int len)
-{
-    attribute_t *attr;
-    uint32_t i;
-    int cnt;
-
-    char *p, *e;
-
-    if (!sep)
-        sep = " ";
-
-    e = (p = buf) + len;
-    cnt = 0;
-
-    if (hdr && p < e)
-        p += snprintf(p, e-p, "%s", hdr);
-
-    if (arr) {
-        for (i = 0;  i < arr->dim && p < e;  i++) {
-            attr = arr->elems + i;
-
-            p += snprintf(p, e-p, "%s%s:%c:", sep, attr->name, attr->type);
-
-            if (p < e) {
-                switch (attr->type) {
-                case 's':  p += snprintf(p, e-p, "'%s'", attr->string);  break;
-                case 'i':  p += snprintf(p, e-p, "%d",   attr->integer); break;
-                case 'u':  p += snprintf(p, e-p, "%u",   attr->unsignd); break;
-                case 'f':  p += snprintf(p, e-p, "%.2lf",attr->floating);break;
-                default:   p += snprintf(p, e-p, "<unknown>");           break;
-                }
-            }
-
-            cnt++;
-        }
-    }
-
-    if (!cnt && hdr && p < e)
-        p += snprintf(p, e-p, "%s<none>", sep);
-
-    if (trail && hdr && p < e)
-        p += snprintf(p, e-p, "%s", trail);
-
-    return p - buf;
-}
-
-#if 0
-static uint32_t attribute_array_index(attribute_array_t *arr,
-                                      const char *member)
-{
-    uint32_t i;
-
-    if (arr && member) {
-        for (i = 0;  i < arr->dim;  i++) {
-            if (!strcmp(member, arr->elems[i].name))
-                return i;
-        }
-    }
-
-    return INVALID_INDEX;
-}
-#endif
-
-static void resource_def_array_free(resource_def_array_t *arr)
-{
-    uint32_t i;
-    resource_def_t *def;
-
-    if (arr) {
-        for (i = 0;   i < arr->dim;   i++) {
-            def = arr->defs + i;
-
-            mrp_free((void *)def->name);
-            attribute_array_free(def->attrs);
-        }
-
-        mrp_free(arr);
-    }
-}
-
-
-static int resource_def_array_print(resource_def_array_t *arr,
-                                    const char *rhdr,
-                                    const char *rsep,
-                                    const char *rtrail,
-                                    const char *ahdr,
-                                    const char *asep,
-                                    const char *atrail,
-                                    char *buf, int len)
-{
-    resource_def_t *def;
-    uint32_t i;
-    int cnt;
-
-    char *p, *e;
-
-    if (!rsep)
-        rsep = " ";
-
-    e = (p = buf) + len;
-    cnt = 0;
-
-    if (rhdr && p < e)
-        p += snprintf(p, e-p, "%s", rhdr);
-
-    if (arr) {
-        for (i = 0;  i < arr->dim && p < e;  i++) {
-            def = arr->defs + i;
-
-            p += snprintf(p, e-p, "%s%s", rsep, def->name);
-
-            if (p < e)
-                p += attribute_array_print(def->attrs,ahdr,asep,atrail,p,e-p);
-
-            cnt++;
-        }
-    }
-
-    if (!cnt && rhdr && p < e)
-        p += snprintf(p, e-p, "%s<none>", rsep);
-
-    if (rtrail && p < e)
-        p += snprintf(p, e-p, "%s", rtrail);
-
-    return p - buf;
-}
-
-
-
-
-static bool fetch_seqno(mrp_msg_t *msg, void **pcursor, uint32_t *pseqno)
-{
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-
-    if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-        tag != RESPROTO_SEQUENCE_NO || type != MRP_MSG_FIELD_UINT32)
-    {
-        *pseqno = INVALID_SEQNO;
-        return false;
-    }
-
-    *pseqno = value.u32;
-    return true;
-}
-
-
-static bool fetch_request(mrp_msg_t *msg, void **pcursor, uint16_t *preqtype)
-{
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-
-    if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-        tag != RESPROTO_REQUEST_TYPE || type != MRP_MSG_FIELD_UINT16)
-    {
-        *preqtype = INVALID_REQUEST;
-        return false;
-    }
-
-    *preqtype = value.u16;
-    return true;
-}
-
-static bool fetch_status(mrp_msg_t *msg, void **pcursor, int *pstatus)
-{
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-
-    if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-        tag != RESPROTO_REQUEST_STATUS || type != MRP_MSG_FIELD_SINT16)
-    {
-        *pstatus = EIO;
-        return false;
-    }
-
-    *pstatus = value.s16;
-    return true;
-}
-
-static bool fetch_resource_set_id(mrp_msg_t *msg, void **pcursor,uint32_t *pid)
-{
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-
-    if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-        tag != RESPROTO_RESOURCE_SET_ID || type != MRP_MSG_FIELD_UINT32)
-    {
-        *pid = INVALID_ID;
-        return false;
-    }
-
-    *pid = value.u32;
-    return true;
-}
-
-static bool fetch_resource_set_state(mrp_msg_t *msg, void **pcursor,
-                                     mrp_resproto_state_t *pstate)
-{
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-
-    if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-        tag != RESPROTO_RESOURCE_STATE || type != MRP_MSG_FIELD_UINT16)
-    {
-        *pstate = 0;
-        return false;
-    }
-
-    *pstate = value.u16;
-    return true;
-}
-
-
-static bool fetch_resource_set_mask(mrp_msg_t *msg, void **pcursor,
-                                    int mask_type, mrp_resproto_state_t *pmask)
-{
-    uint16_t expected_tag;
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-
-    switch (mask_type) {
-    case GRANT:    expected_tag = RESPROTO_RESOURCE_GRANT;     break;
-    case ADVICE:   expected_tag = RESPROTO_RESOURCE_ADVICE;    break;
-    default:       /* don't know what to fetch */              return false;
-    }
-
-    if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-        tag != expected_tag || type != MRP_MSG_FIELD_UINT32)
-    {
-        *pmask = 0;
-        return false;
-    }
-
-    *pmask = value.u32;
-    return true;
-}
-
-static bool fetch_resource_name(mrp_msg_t *msg, void **pcursor,
-                                const char **pname)
-{
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-
-    if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-        tag != RESPROTO_RESOURCE_NAME || type != MRP_MSG_FIELD_STRING)
-    {
-        *pname = "<unknown>";
-        return false;
-    }
-
-    *pname = value.str;
-    return true;
-}
-
-
-static bool fetch_str_array(mrp_msg_t *msg, void **pcursor,
-                            uint16_t expected_tag, string_array_t **parr)
-{
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-
-    if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-        tag != expected_tag || type != MRP_MSG_FIELD_ARRAY_OF(STRING))
-    {
-        *parr = str_array_dup(0, NULL);
-        return false;
-    }
-
-    if (!(*parr = str_array_dup(size, (const char **)value.astr)))
-        return false;
-
-    return true;
-}
-
-static bool fetch_attribute_array(mrp_msg_t *msg, void **pcursor,
-                                 size_t dim, attribute_t *arr)
-{
-    attribute_t *attr;
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-    size_t i;
-
-    i = 0;
-
-    while (mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size)) {
-        if (tag == RESPROTO_SECTION_END && type == MRP_MSG_FIELD_UINT8)
-            break;
-
-        if (tag  != RESPROTO_ATTRIBUTE_NAME ||
-            type != MRP_MSG_FIELD_STRING    ||
-            i    >= dim - 1)
-        {
-            return false;
-        }
-
-        attr = arr + i++;
-        attr->name = value.str;
-
-        if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
-            tag != RESPROTO_ATTRIBUTE_VALUE)
-        {
-            return false;
-        }
-
-        switch (type) {
-        case MRP_MSG_FIELD_STRING:
-            attr->type = 's';
-            attr->string = value.str;
-            break;
-        case MRP_MSG_FIELD_SINT32:
-            attr->type = 'i';
-            attr->integer = value.s32;
-            break;
-        case MRP_MSG_FIELD_UINT32:
-            attr->type = 'u';
-            attr->unsignd = value.u32;
-            break;
-        case MRP_MSG_FIELD_DOUBLE:
-            attr->type = 'f';
-            attr->floating = value.dbl;
-            break;
-        default:
-            return false;
-        }
-    }
-
-    memset(arr + i, 0, sizeof(attribute_t));
-
-    return true;
-}
-
-
-static void resource_query_response(client_t *client, uint32_t seqno,
-                                    mrp_msg_t *msg, void **pcursor)
-{
-    int             status;
-    uint32_t        dim, i;
-    resource_def_t  rdef[RESOURCE_MAX];
-    attribute_t     attrs[ATTRIBUTE_MAX + 1];
-    resource_def_t *src, *dst;
-    resource_def_array_t *arr;
-    size_t          size;
-    char            buf[4096];
-
-    MRP_UNUSED(seqno);
-
-    if (!fetch_status(msg, pcursor, &status))
-        goto failed;
-
-    if (status != 0)
-        printf("Resource query failed (%u): %s\n", status, strerror(status));
-    else {
-        dim = 0;
-
-        while (fetch_resource_name(msg, pcursor, &rdef[dim].name)) {
-            if (!fetch_attribute_array(msg, pcursor, ATTRIBUTE_MAX+1, attrs))
-                goto failed;
-
-            if (!(rdef[dim].attrs = attribute_array_dup(0, attrs))) {
-                mrp_log_error("failed to duplicate attributes");
-                return;
-            }
-
-            dim++;
-        }
-
-        size = sizeof(resource_def_array_t) + sizeof(resource_def_t) * (dim+1);
-
-
-        resource_def_array_free(client->resources);
-
-        client->resources = arr = mrp_allocz(size);
-
-        arr->dim = dim;
-
-        for (i = 0;  i < dim;  i++) {
-            src = rdef + i;
-            dst = arr->defs + i;
-
-            dst->name  = mrp_strdup(src->name);
-            dst->attrs = src->attrs;
-        }
-
-        resource_def_array_print(client->resources,
-                                 "Resource definitions:", "\n   ", "\n",
-                                 NULL, "\n      ", NULL,
-                                 buf, sizeof(buf));
-        printf("\n%s", buf);
-
-        client->prompt = true;
-        print_prompt(client, true);
-    }
-
-    return;
-
- failed:
-    mrp_log_error("malformed reply to recource query");
-}
-
-static void class_query_response(client_t *client, uint32_t seqno,
-                                 mrp_msg_t *msg, void **pcursor)
-{
-    int status;
-    string_array_t *arr;
-    char buf[4096];
-
-    MRP_UNUSED(seqno);
-
-    if (!fetch_status(msg, pcursor, &status) || (status == 0 &&
-        !fetch_str_array(msg, pcursor, RESPROTO_CLASS_NAME, &arr)))
-    {
-        mrp_log_error("ignoring malformed response to class query");
-        return;
-    }
-
-    if (status) {
-        mrp_log_error("class query failed with error code %u", status);
-        return;
-    }
-
-    str_array_free(client->class_names);
-    client->class_names = arr;
-
-    str_array_print(arr, "Application class names:", "\n   ", "\n",
-                    buf, sizeof(buf));
-
-    printf("\n%s", buf);
-
-    client->prompt = true;
-    print_prompt(client, true);
-}
-
-static void zone_query_response(client_t *client, uint32_t seqno,
-                                mrp_msg_t *msg, void **pcursor)
-{
-    int status;
-    string_array_t *arr;
-    char buf[4096];
-
-    MRP_UNUSED(seqno);
-
-    if (!fetch_status(msg, pcursor, &status) || (status == 0 &&
-        !fetch_str_array(msg, pcursor, RESPROTO_ZONE_NAME, &arr)))
-    {
-        mrp_log_error("ignoring malformed response to zone query");
-        return;
-    }
-
-    if (status) {
-        mrp_log_error("zone query failed with error code %u", status);
-        return;
-    }
-
-    str_array_free(client->zone_names);
-    client->zone_names = arr;
-
-    str_array_print(arr, "Zone names:", "\n   ", "\n",
-                    buf, sizeof(buf));
-
-    printf("\n%s", buf);
-
-    client->prompt = true;
-    print_prompt(client, true);
-}
-
-static void create_resource_set_response(client_t *client, uint32_t seqno,
-                                         mrp_msg_t *msg, void **pcursor)
-{
-    int status;
-    uint32_t rset_id;
-
-    MRP_UNUSED(seqno);
-
-    if (!fetch_status(msg, pcursor, &status) || (status == 0 &&
-        !fetch_resource_set_id(msg, pcursor, &rset_id)))
-    {
-        mrp_log_error("ignoring malformed response to resource set creation");
-        return;
-    }
-
-    if (status) {
-        mrp_log_error("creation of resource set failed. error code %u",status);
-        return;
-    }
-
-    client->rset_id = rset_id;
-
-    printf("\nresource set %u created\n", rset_id);
-
-    client->prompt = true;
-    print_prompt(client, true);
-}
-
-static void acquire_resource_set_response(client_t *client, uint32_t seqno,
-                                          bool acquire, mrp_msg_t *msg,
-                                          void **pcursor)
-{
-    const char *op = acquire ? "acquisition" : "release";
-    int status;
-    uint32_t rset_id;
-
-    if (!fetch_resource_set_id(msg, pcursor, &rset_id) ||
-        !fetch_status(msg, pcursor, &status))
-    {
-        mrp_log_error("ignoring malformed response to resource set %s", op);
-        return;
-    }
-
-    if (status) {
-        printf("\n%s of resource set %u failed. request no %u "
-               "error code %u", op, rset_id, seqno, status);
-    }
-    else {
-        printf("\nSuccessful %s of resource set %u. request no %u\n",
-               op, rset_id, seqno);
-    }
-
-    client->prompt = true;
-
-    if (status)
-        print_prompt(client, true);
-}
-
-
-static void resource_event(client_t *client, uint32_t seqno, mrp_msg_t *msg,
-                           void **pcursor)
-{
-    uint32_t rset;
-    uint32_t grant, advice;
-    mrp_resproto_state_t state;
-    const char *str_state;
-    uint16_t tag;
-    uint16_t type;
-    mrp_msg_value_t value;
-    size_t size;
-    uint32_t resid;
-    const char *resnam;
-    attribute_t attrs[ATTRIBUTE_MAX + 1];
-    attribute_array_t *list;
-    char buf[4096];
-    uint32_t mask;
-    int cnt;
-
-    printf("\nResource event (request no %u):\n", seqno);
-
-    if (!fetch_resource_set_id(msg, pcursor, &rset) ||
-        !fetch_resource_set_state(msg, pcursor, &state) ||
-        !fetch_resource_set_mask(msg, pcursor, GRANT, &grant) ||
-        !fetch_resource_set_mask(msg, pcursor, ADVICE, &advice))
-        goto malformed;
-
-    switch (state) {
-    case RESPROTO_RELEASE:   str_state = "release";    break;
-    case RESPROTO_ACQUIRE:   str_state = "acquire";    break;
-    default:                 str_state = "<unknown>";  break;
-    }
-
-    printf("   resource-set ID  : %u\n"  , rset);
-    printf("   state            : %s\n"  , str_state);
-    printf("   grant mask       : 0x%x\n", grant);
-    printf("   advice mask      : 0x%x\n", advice);
-    printf("   resources        :");
-
-    cnt = 0;
-
-    while (mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size)) {
-        if ((tag != RESPROTO_RESOURCE_ID || type != MRP_MSG_FIELD_UINT32) ||
-            !fetch_resource_name(msg, pcursor, &resnam))
-            goto malformed;
-
-        resid = value.u32;
-        mask  = (1UL <<  resid);
-
-        if (!cnt++)
-            printf("\n");
-
-        printf("      %02u name       : %s\n", resid, resnam);
-        printf("         mask       : 0x%x\n", mask);
-        printf("         grant      : %s\n", (grant & mask)  ? "yes" : "no");
-        printf("         advice     : %savailable\n",
-               (advice & mask)  ? "" : "not ");
-
-        if (!fetch_attribute_array(msg, pcursor, ATTRIBUTE_MAX + 1, attrs))
-            goto malformed;
-
-        if (!(list = attribute_array_dup(0, attrs))) {
-            mrp_log_error("failed to duplicate attribute list");
-            exit(ENOMEM);
-        }
-
-        attribute_array_print(list, "         attributes :", " ", "\n",
-                              buf, sizeof(buf));
-        printf("%s", buf);
-
-        attribute_array_free(list);
-    }
-
-    if (!cnt)
-        printf(" <none>\n");
-
-    print_prompt(client, true);
-
-    return;
-
- malformed:
-    mrp_log_error("ignoring malformed resource event");
-}
-
-
-static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
-                         mrp_sockaddr_t *addr, socklen_t addrlen,
-                         void *user_data)
-{
-    client_t *client = (client_t *)user_data;
-    void     *cursor = NULL;
-    uint32_t  seqno;
-    uint16_t  request;
-
-    MRP_UNUSED(transp);
-    MRP_UNUSED(addr);
-    MRP_UNUSED(addrlen);
-
-    if (client->msgdump) {
-        mrp_log_info("received a message");
-        mrp_msg_dump(msg, stdout);
-    }
-
-    if (!fetch_seqno   (msg, &cursor, &seqno  ) ||
-        !fetch_request (msg, &cursor, &request)   )
-    {
-        mrp_log_error("ignoring malformed message");
-        return;
-    }
-
-    switch (request) {
-    case RESPROTO_QUERY_RESOURCES:
-        resource_query_response(client, seqno, msg, &cursor);
-        break;
-    case RESPROTO_QUERY_CLASSES:
-        class_query_response(client, seqno, msg, &cursor);
-        break;
-    case RESPROTO_QUERY_ZONES:
-        zone_query_response(client, seqno, msg, &cursor);
-        break;
-    case RESPROTO_CREATE_RESOURCE_SET:
-        create_resource_set_response(client, seqno, msg, &cursor);
-        break;
-    case RESPROTO_ACQUIRE_RESOURCE_SET:
-        acquire_resource_set_response(client, seqno, true, msg, &cursor);
-        break;
-    case RESPROTO_RELEASE_RESOURCE_SET:
-        acquire_resource_set_response(client, seqno, false, msg, &cursor);
-        break;
-    case RESPROTO_RESOURCES_EVENT:
-        resource_event(client, seqno, msg, &cursor);
-        break;
-    default:
-        mrp_log_error("ignoring unsupported request type %u", request);
-        break;
-    }
-}
-
-static void recv_msg(mrp_transport_t *t, mrp_msg_t *msg, void *user_data)
-{
-    return recvfrom_msg(t, msg, NULL, 0, user_data);
-}
-
-
-void closed_evt(mrp_transport_t *transp, int error, void *user_data)
-{
-    MRP_UNUSED(transp);
-    MRP_UNUSED(user_data);
-
-    if (error) {
-        mrp_log_error("Connection closed with error %d (%s)", error,
-                      strerror(error));
-        exit(EIO);
-    }
-    else {
-        mrp_log_info("Peer has closed the connection");
-        exit(0);
-    }
-}
-
-
-static void init_transport(client_t *client, char *addr)
-{
-    static mrp_transport_evt_t evt = {
-        { .recvmsg     = recv_msg },
-        { .recvmsgfrom = recvfrom_msg },
-        .closed        = closed_evt,
-        .connection    = NULL
-    };
-
-    client->alen = mrp_transport_resolve(NULL, addr, &client->saddr,
-                                         sizeof(client->saddr),&client->atype);
-    if (client->alen <= 0) {
-        mrp_log_error("Can't resolve transport address '%s'", addr);
-        exit(EINVAL);
-    }
-
-    client->transp = mrp_transport_create(client->ml, client->atype,
-                                          &evt, client, 0);
-
-    if (!client->transp) {
-        mrp_log_error("Failed to create transport");
-        exit(EIO);
-    }
-
-    if (!mrp_transport_connect(client->transp, &client->saddr, client->alen)) {
-        mrp_log_error("Failed to connect to '%s'", addr);
-        exit(EIO);
-    }
-}
-
-
-
-static mrp_msg_t *create_request(uint32_t seqno, mrp_resproto_request_t req)
-{
-    uint16_t   type  = req;
-    mrp_msg_t *msg;
-
-    msg = mrp_msg_create(RESPROTO_SEQUENCE_NO , MRP_MSG_FIELD_UINT32, seqno,
-                         RESPROTO_REQUEST_TYPE, MRP_MSG_FIELD_UINT16, type ,
-                         RESPROTO_MESSAGE_END                               );
-
-    if (!msg) {
-        mrp_log_error("Unable to create new message");
-        exit(ENOMEM);
-    }
-
-    return msg;
-}
-
-static void send_message(client_t *client, mrp_msg_t *msg)
-{
-    if (!mrp_transport_send(client->transp, msg)) {
-        mrp_log_error("Failed to send message");
-        exit(EIO);
-    }
-
-    mrp_msg_unref(msg);
-}
-
-static void query_resources(client_t *client)
-{
-    mrp_msg_t *req;
-
-    req = create_request(client->seqno++, RESPROTO_QUERY_RESOURCES);
-
-    send_message(client, req);
-}
-
-static void query_classes(client_t *client)
-{
-    mrp_msg_t *req;
-
-    req = create_request(client->seqno++, RESPROTO_QUERY_CLASSES);
-
-    send_message(client, req);
-}
-
-static void query_zones(client_t *client)
-{
-    mrp_msg_t *req;
-
-    req = create_request(client->seqno++, RESPROTO_QUERY_ZONES);
-
-    send_message(client, req);
-}
-
-static char *parse_attribute(mrp_msg_t *msg, char *str, char *sep)
-{
-#define PUSH_ATTRIBUTE_NAME(m, n) \
-    mrp_msg_append(m, MRP_MSG_TAG_STRING(RESPROTO_ATTRIBUTE_NAME, n))
-
-#define PUSH_ATTRIBUTE_VALUE(m, t, v) \
-    mrp_msg_append(m, MRP_MSG_TAG_##t(RESPROTO_ATTRIBUTE_VALUE, v))
-
-
-    char *p, *e, c;
-    char *name;
-    char  type;
-    char *valstr;
-    uint32_t unsignd;
-    int32_t integer;
-    double floating;
-
-
-    *sep = '\0';
-
-    if (!(p = str))
-        return NULL;
-
-    name = p;
-    while ((c = *p++)) {
-        if (c == ':') {
-            *(p-1) = '\0';
-            break;
-        }
-        if (!isalnum(c) && c != '_' && c != '-') {
-            mrp_log_error("invalid attribute name: '%s'", name);
-            return NULL;
-        }
-    }
-
-    if (!c || !(type = *p++) || (*p++ != ':')) {
-        mrp_log_error("invalid or missing resource type");
-        return NULL;
-    }
-
-    if (*p == '\"') {
-        valstr = ++p;
-        while ((c = *p++) != '\"') {
-            if (!c) {
-                mrp_log_error("bad quoted value '%s'", valstr-1);
-                return NULL;
-            }
-        }
-        *(p-1) = '\0';
-        if ((c = *p)) {
-            if (c == '/' || c == ',')
-                p++;
-            else {
-                mrp_log_error("invalid separator '%s'", p);
-                return NULL;
-            }
-        }
-    }
-    else {
-        valstr = p;
-        while ((c = *p++)) {
-            if (c == '/' || c == ',') {
-                *(p-1) = '\0';
-                break;
-            }
-            if (c < 0x20) {
-                mrp_log_error("invalid attribute value '%s'", valstr);
-                return NULL;
-            }
-        }
-    }
-
-    *sep = c;
-
-    if (!PUSH_ATTRIBUTE_NAME(msg, name))
-        goto error;
-
-    if (type == 's') {
-        if (!PUSH_ATTRIBUTE_VALUE(msg, STRING, valstr))
-            goto error;
-    }
-    else if (type == 'i') {
-        integer = strtol(valstr, &e, 10);
-
-        if (*e || e == valstr || !PUSH_ATTRIBUTE_VALUE(msg, SINT32, integer))
-            goto error;
-    }
-    else if (type == 'u') {
-        unsignd = strtoul(valstr, &e, 10);
-
-        if (*e || e == valstr || !PUSH_ATTRIBUTE_VALUE(msg, UINT32, unsignd))
-            goto error;
-    }
-    else if (type == 'f') {
-        floating = strtod(valstr, &e);
-
-        if (*e || e == valstr || !PUSH_ATTRIBUTE_VALUE(msg, DOUBLE, floating))
-            goto error;
-    }
-
-
-    return (p && *p) ? p : NULL;
-
- error:
-    mrp_log_error("failed to build resource-set creation request");
-    return NULL;
-
-#undef PUSH_ATTRIBUTE_VALUE
-#undef PUSH_ATTRIBUTE_NAME
-}
-
-bool parse_flags(char *str, uint32_t *pflags)
-{
-    typedef struct { char *str; uint32_t flags; } flagdef_t;
-
-    static flagdef_t flagdefs[] = {
-        { "M" ,    RESPROTO_RESFLAG_MANDATORY |            0            },
-        { "O" ,               0               |            0            },
-        { "S" ,    RESPROTO_RESFLAG_MANDATORY | RESPROTO_RESFLAG_SHARED },
-        { "E" ,    RESPROTO_RESFLAG_MANDATORY |            0            },
-        { "MS",    RESPROTO_RESFLAG_MANDATORY | RESPROTO_RESFLAG_SHARED },
-        { "ME",    RESPROTO_RESFLAG_MANDATORY |            0            },
-        { "OS",               0               | RESPROTO_RESFLAG_SHARED },
-        { "OE",               0               |            0            },
-        { "SM",    RESPROTO_RESFLAG_MANDATORY | RESPROTO_RESFLAG_SHARED },
-        { "SO",               0               | RESPROTO_RESFLAG_SHARED },
-        { "EM",    RESPROTO_RESFLAG_MANDATORY |            0            },
-        { "EO",               0               |            0            },
-        { NULL,               0               |            0            }
-    };
-
-    flagdef_t *fd;
-    bool success;
-
-    *pflags = RESPROTO_RESFLAG_MANDATORY;
-
-    if (!str)
-        success = true;
-    else {
-        for (success = false, fd = flagdefs;    fd->str;    fd++) {
-            if (!strcasecmp(str, fd->str)) {
-                success = true;
-                *pflags = fd->flags;
-                break;
-            }
-        }
-    }
-
-    return success;
-}
-
-static char *parse_resource(mrp_msg_t *msg, char *str, char *sep)
-{
-#define PUSH(msg, tag, typ, val) \
-    mrp_msg_append(msg, MRP_MSG_TAG_##typ(RESPROTO_##tag, val))
-
-    uint32_t flags;
-    char *name, *flgstr;
-    char *p;
-    char  c;
-
-    *sep = '\0';
-
-    if (!(p = str))
-        return NULL;
-
-    name = p;
-    flgstr = NULL;
-
-    while ((c = *p++)) {
-        if (c == ':') {
-            *(p-1) = '\0';
-            flgstr = name;
-            name = p;
-        }
-        else if (c == '/' || c == ',') {
-            *(p-1) = '\0';
-            break;
-        }
-        else if (!isalnum(c) && c != '_' && c != '-') {
-            mrp_log_error("invalid resource name: '%s'", name);
-            return NULL;
-        }
-    }
-
-    if (!parse_flags(flgstr, &flags)) {
-        mrp_log_error("invalid flag string '%s'", flgstr ? flgstr : "");
-        return NULL;
-    }
-
-    if (!PUSH(msg, RESOURCE_NAME , STRING, name ) ||
-        !PUSH(msg, RESOURCE_FLAGS, UINT32, flags)   )
-        goto failed;
-
-    if (!c)
-        p--;
-    else {
-        while ((*sep = c) == '/')
-            p = parse_attribute(msg, p, &c);
-    }
-
-    if (!PUSH(msg, SECTION_END, UINT8, 0))
-        goto failed;
-
-    return (p && *p) ? p : NULL;
-
- failed:
-    mrp_log_error("failed to build resource-set creation request");
-    *sep = '\0';
-    return NULL;
-
-#undef PUSH
-}
-
-static void create_resource_set(client_t   *client,
-                                const char *class,
-                                const char *zone,
-                                const char *def,
-                                uint32_t    flags)
-{
-#define PUSH(msg, tag, typ, val) \
-    mrp_msg_append(msg, MRP_MSG_TAG_##typ(RESPROTO_##tag, val))
-
-    char  *buf;
-    uint32_t priority = 0;
-    mrp_msg_t *req;
-    char *p;
-    char c;
-
-    /* 'def' => {m|o}{s|e}:resource_name/attr_name:{s|i|u|f}:["]value["] */
-
-    if (!client || !class || !zone || !def)
-        return;
-
-    req = create_request(client->seqno++, RESPROTO_CREATE_RESOURCE_SET);
-
-    if (!PUSH(req, RESOURCE_FLAGS   , UINT32, flags   ) ||
-        !PUSH(req, RESOURCE_PRIORITY, UINT32, priority) ||
-        !PUSH(req, CLASS_NAME       , STRING, class   ) ||
-        !PUSH(req, ZONE_NAME        , STRING, zone    )   )
-    {
-        mrp_msg_unref(req);
-    }
-    else {
-        p = buf = mrp_strdup(def);
-        c = ',';
-
-        while (c == ',')
-            p = parse_resource(req, p, &c);
-
-        if (client->msgdump)
-            mrp_msg_dump(req, stdout);
-
-        send_message(client, req);
-
-        mrp_free(buf);
-    }
-
-#undef PUSH
-}
-
-static uint32_t acquire_resource_set(client_t *client, bool acquire)
-{
-#define PUSH(msg, tag, typ, val) \
-    mrp_msg_append(msg, MRP_MSG_TAG_##typ(RESPROTO_##tag, val))
-
-    uint16_t   tag;
-    uint32_t   reqno;
-    mrp_msg_t *req;
-
-    if (!client || client->rset_id == INVALID_ID)
-        return 0;
-
-    if (acquire)
-        tag = RESPROTO_ACQUIRE_RESOURCE_SET;
-    else
-        tag = RESPROTO_RELEASE_RESOURCE_SET;
-
-    req = create_request((reqno = client->seqno++), tag);
-
-    if (!PUSH(req, RESOURCE_SET_ID, UINT32, client->rset_id))
-        mrp_msg_unref(req);
-    else {
-        if (client->msgdump)
-            mrp_msg_dump(req, stdout);
-
-        send_message(client, req);
-    }
-
-    return reqno;
-
-#undef PUSH
-}
-
-static void print_prompt(client_t *client, bool startwith_lf)
-{
-    if (client && client->prompt) {
-        printf("%s%s>", startwith_lf ? "\n":"", client->name);
-        fflush(stdout);
-    }
-}
-
-static void print_command_help(void)
-{
-    printf("\nAvailable commands:\n");
-    printf("   help\t\tprints this help\n");
-    printf("   quit\t\texits\n");
-    printf("   resources\tprints the resource definitions\n");
-    printf("   classes\tprints the application classes\n");
-    printf("   zones\tprints the zones\n");
-    printf("   acquire\tacquires the resource-set specified by command "
-           "line options\n");
-    printf("   release\treleases the resource-set specified by command "
-           "line options\n");
-}
-
-static void parse_line(client_t *client, char *buf, int len)
-{
-    char *p, *e;
-
-    if (len <= 0)
-        print_prompt(client, false);
-    else {
-        for (p = buf;  isblank(*p);  p++) ;
-        for (e = buf+len;  e > buf && isblank(*(e-1));  e--) ;
-
-        *e = '\0';
-
-        if (!strcmp(p, "help")) {
-            print_command_help();
-            print_prompt(client, true);
-        }
-        else if (!strcmp(p, "quit") || !strcmp(p, "exit")) {
-            printf("\n");
-            mrp_mainloop_quit(client->ml, 0);
-        }
-        else if (!strcmp(p, "resources")) {
-            client->prompt = false;
-            printf("   querying resource definitions\n");
-            query_resources(client);
-        }
-        else if (!strcmp(p, "classes")) {
-            client->prompt = false;
-            printf("   querying application classes\n");
-            query_classes(client);
-        }
-        else if (!strcmp(p, "zones")) {
-            client->prompt = false;
-            printf("   querying zones\n");
-            query_zones(client);
-        }
-        else if (!strcmp(p, "acquire")) {
-            if (client->rset_id == INVALID_ID) {
-                printf("   there is no resource set\n");
-                print_prompt(client, true);
-            }
-            else {
-                client->prompt = false;
-                printf("   acquiring resource set %u. request no %u\n",
-                       client->rset_id, acquire_resource_set(client, true));
-            }
-        }
-        else if (!strcmp(p, "release")) {
-            if (client->rset_id == INVALID_ID) {
-                printf("   there is no resource set\n");
-                print_prompt(client, true);
-            }
-            else {
-                client->prompt = false;
-                printf("   releasing resource set %u. request no %u\n",
-                       client->rset_id, acquire_resource_set(client, false));
-            }
-        }
-        else {
-            printf("   unsupported command\n");
-            print_prompt(client, true);
-        }
-    }
-}
-
-static void console_input(mrp_mainloop_t *ml, mrp_io_watch_t *w, int fd,
-                          mrp_io_event_t events, void *user_data)
-{
-    static char  buf[512];
-    static char *bufend = buf + (sizeof(buf) - 1);
-    static char *writep = buf;
-
-    client_t *client = (client_t *)user_data;
-    int       len;
-    char     *eol;
-
-    MRP_UNUSED(ml);
-    MRP_UNUSED(w);
-    MRP_UNUSED(events);
-
-    MRP_ASSERT(client, "invalid argument");
-    MRP_ASSERT(fd == 0, "confused with data structures");
-
-    while ((len = read(fd, writep, bufend-writep)) < 0) {
-        if (errno != EINTR) {
-            mrp_log_error("read error %d: %s", errno, strerror(errno));
-            return;
-        }
-    }
-
-    *(writep += len) = '\0';
-
-    while ((eol = strchr(buf, '\n'))) {
-        *eol++ = '\0';
-
-        parse_line(client, buf, (eol-buf)-1);
-
-        if ((len = writep - eol) <= 0) {
-            writep = buf;
-            break;
-        }
-        else {
-            memmove(buf, eol, len);
-            writep = buf + len;
-        }
-    }
-}
-
-static void sighandler(mrp_mainloop_t *ml, mrp_sighandler_t *h, int signum,
-                       void *user_data)
-{
-    client_t *client = (client_t *)user_data;
-
-    MRP_UNUSED(h);
-
-    MRP_ASSERT(client, "invalid argument");
-
-    switch (signum) {
-
-    case SIGHUP:
-    case SIGTERM:
-    case SIGINT:
-        mrp_mainloop_quit(ml, 0);
-        break;
-
-    default:
-        break;
-    }
-}
-
-static void usage(client_t *client, int exit_code)
-{
-    printf("Usage: %s [-h] [-v] [-a] [class zone resources]\n\nwhere\n"
-           "\t-h\t\tprints this help\n"
-           "\t-v\t\tverbose mode (dumps the transport messages)\n"
-           "\t-a\t\tautorelease mode\n"
-           "\tclass\t\tapplication class of the resource set\n"
-           "\tzone\t\tzone wher the resource set lives\n"
-           "\tresources\tcomma separated list of resources. Each resource is\n"
-           "\t\t\tspecified as flags:name[/attribute[/ ... ]]\n"
-           "\t\t\tflags\t\tspecified as {m|o}{s|e} where\n"
-           "\t\t\t\t\t'm' stands for mandatory,\n"
-           "\t\t\t\t\t'o' for optional,\n"
-           "\t\t\t\t\t's' for shared and\n"
-           "\t\t\t\t\t'e' for exclusive.\n"
-           "\t\t\tresource\tis the name of the resource composed of\n"
-           "\t\t\t\t\ta series of letters, digits, '_' and\n"
-           "\t\t\t\t\t'-' characters\n"
-           "\t\t\tattribute\tis defined as attr-name:type:[\"]value[\"]\n"
-           "\t\t\t\t\ttypes can be\n"
-           "\t\t\t\t\t's' - string\n"
-           "\t\t\t\t\t'i' - signed integer\n"
-           "\t\t\t\t\t'u' - unsigned integer\n"
-           "\t\t\t\t\t'f' - floating\n"
-           "\nExample:\n\n%s player driver "
-           "ms:audio_playback/role:s:\"video\",me:video_playback\n"
-           "\n", client->name, client->name);
-
-    exit(exit_code);
-}
-
-static void parse_arguments(client_t *client, int argc, char **argv)
-{
-    int opt;
-
-    while ((opt = getopt(argc, argv, "hva")) != -1) {
-        switch (opt) {
-        case 'h':
-            usage(client, 0);
-        case 'v':
-            client->msgdump = true;
-            break;
-        case 'a':
-            client->rsetf |= RESPROTO_RSETFLAG_AUTORELEASE;
-            break;
-        default:
-            usage(client, EINVAL);
-        }
-    }
-
-    if (optind + 3 == argc) {
-        client->class = argv[optind + 0];
-        client->zone  = argv[optind + 1];
-        client->rsetd = argv[optind + 2];
-    }
-    else if (optind < argc) {
-        usage(client, EINVAL);
-    }
-}
-
-
-int main(int argc, char **argv)
-{
-    client_t *client = mrp_allocz(sizeof(client_t));
-    char     *addr = RESPROTO_DEFAULT_ADDRESS;
-
-    mrp_log_set_mask(MRP_LOG_UPTO(MRP_LOG_DEBUG));
-    mrp_log_set_target(MRP_LOG_TO_STDOUT);
-
-    client->name    = mrp_strdup(basename(argv[0]));
-    client->ml      = mrp_mainloop_create();
-    client->seqno   = 1;
-    client->prompt  = false;
-    client->rset_id = INVALID_ID;
-
-    parse_arguments(client, argc, argv);
-
-    mrp_add_sighandler(client->ml, SIGHUP , sighandler, client);
-    mrp_add_sighandler(client->ml, SIGTERM, sighandler, client);
-    mrp_add_sighandler(client->ml, SIGINT , sighandler, client);
-
-    init_transport(client, addr);
-
-
-    if (!client->class || !client->zone || !client->rsetd)
-        print_prompt(client, false);
-    else {
-        create_resource_set(client, client->class, client->zone,
-                            client->rsetd, client->rsetf);
-    }
-
-    mrp_add_io_watch(client->ml, 0, MRP_IO_EVENT_IN, console_input, client);
-
-    mrp_mainloop_run(client->ml);
-
-    printf("exiting now ...\n");
-
-    mrp_transport_destroy(client->transp);
-
-    mrp_mainloop_destroy(client->ml);
-    mrp_free((void *)client->name);
-    resource_def_array_free(client->resources);
-    str_array_free(client->class_names);
-    str_array_free(client->zone_names);
-    mrp_free(client);
-}
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/application-class.c b/src/resource/application-class.c
deleted file mode 100644 (file)
index c7525fe..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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 <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <murphy/common/mm.h>
-#include <murphy/common/hashtbl.h>
-#include <murphy/common/utils.h>
-#include <murphy/common/log.h>
-
-#include <murphy/resource/manager-api.h>
-#include <murphy/resource/client-api.h>
-#include <murphy/resource/config-api.h>
-
-#include <murphy-db/mqi.h>
-
-#include "application-class.h"
-#include "resource-set.h"
-#include "resource-owner.h"
-#include "zone.h"
-
-#define CLASS_MAX        64
-#define NAME_LENGTH      24
-
-#define CLASS_NAME_IDX   0
-#define PRIORITY_IDX     1
-
-
-/*
- * sorting key bit layout
- *
- * +---------+----+----+--------+
- * | 31 - 29 | 28 | 27 | 26 - 0 |
- * +---------+----+----+--------+
- *      |      |    |       |
- *      |      |    |       +---- 0x07ffffff stamp of the last request
- *      |      |    +------------ 0x08000000 state (set if acquiring)
- *      |      +----------------- 0x10000000 usage (set if shared)
- *      +------------------------ 0xe0000000 priority (0-7)
- */
-#define MASK(b)   (((uint32_t)1 << (b)) - (uint32_t)1)
-
-#define STAMP_SHIFT     0
-#define STATE_SHIFT     (STAMP_SHIFT + MRP_KEY_STAMP_BITS)
-#define USAGE_SHIFT     (STATE_SHIFT + MRP_KEY_STATE_BITS)
-#define PRIORITY_SHIFT  (USAGE_SHIFT + MRP_KEY_USAGE_BITS)
-
-#define STAMP_MASK      MASK(MRP_KEY_STAMP_BITS)
-#define STATE_MASK      MASK(MRP_KEY_STATE_BITS)
-#define USAGE_MASK      MASK(MRP_KEY_USAGE_BITS)
-#define PRIORITY_MASK   MASK(MRP_KEY_PRIORITY_BITS)
-
-#define STAMP_KEY(p)    (((uint32_t)(p) & STAMP_MASK)    << STAMP_SHIFT)
-#define STATE_KEY(p)    (((uint32_t)(p) & STATE_MASK)    << STATE_SHIFT)
-#define USAGE_KEY(p)    (((uint32_t)(p) & USAGE_MASK)    << USAGE_SHIFT)
-#define PRIORITY_KEY(p) (((uint32_t)(p) & PRIORITY_MASK) << PRIORITY_SHIFT)
-
-typedef struct {
-    const char *class_name;
-    uint32_t    priority;
-} class_row_t;
-
-
-static MRP_LIST_HOOK(class_list);
-static mrp_htbl_t *name_hash;
-
-static void init_name_hash(void);
-static int  add_to_name_hash(mrp_application_class_t *);
-#if 0
-static void remove_from_name_hash(mrp_application_class_t *);
-#endif
-
-static mqi_handle_t get_database_table(void);
-static void insert_into_application_class_table(const char *, uint32_t);
-
-
-mrp_application_class_t *mrp_application_class_create(const char *name,
-                                                      uint32_t pri)
-{
-    mrp_application_class_t *class;
-    mrp_list_hook_t *insert_before, *clhook, *n;
-    uint32_t zone;
-
-    MRP_ASSERT(name, "invalid argument");
-
-
-    /* looping through all classes to check the uniqueness of the
-       name & priority of the new class and find the insertion point */
-    insert_before = &class_list;
-
-    mrp_list_foreach_back(&class_list, clhook, n) {
-        class = mrp_list_entry(clhook, mrp_application_class_t, list);
-
-        if (!strcasecmp(name, class->name)) {
-            mrp_log_warning("Multiple definitions for class '%s'", name);
-            return NULL;
-        }
-
-        if (pri == class->priority) {
-            mrp_log_error("Priority clash. Classes '%s' and '%s' would have "
-                          "the same priority", name, class->name);
-        }
-
-        if (pri < class->priority)
-            insert_before = &class->list;
-    }
-
-    if (!(class = mrp_allocz(sizeof(mrp_application_class_t)))) {
-        mrp_log_error("Memory alloc failure. Can't create resource class '%s'",
-                      name);
-        return NULL;
-    }
-
-    class->name = mrp_strdup(name);
-    class->priority = pri;
-
-    for (zone = 0;  zone < MRP_ZONE_MAX;  zone++)
-        mrp_list_init(&class->resource_sets[zone]);
-
-    /* list do not have insert_before function,
-       so don't be mislead by the name */
-    mrp_list_append(insert_before, &class->list);
-
-    add_to_name_hash(class);
-
-    insert_into_application_class_table(class->name, class->priority);
-
-    return class;
-}
-
-
-mrp_application_class_t *mrp_application_class_find(const char *name)
-{
-    mrp_application_class_t *class = NULL;
-
-    if (name_hash && name)
-        class = mrp_htbl_lookup(name_hash, (void *)name);
-
-    return class;
-}
-
-mrp_application_class_t *mrp_application_class_iterate_classes(void **cursor)
-{
-    mrp_list_hook_t *entry;
-
-    MRP_ASSERT(cursor, "invalid argument");
-
-    entry = (*cursor == NULL) ? class_list.prev : (mrp_list_hook_t *)*cursor;
-
-    if (entry == &class_list)
-        return NULL;
-
-    *cursor = entry->prev;
-
-    return mrp_list_entry(entry, mrp_application_class_t, list);
-}
-
-mrp_resource_set_t *
-mrp_application_class_iterate_rsets(mrp_application_class_t *class,
-                                    uint32_t                 zone,
-                                    void                   **cursor)
-{
-    mrp_list_hook_t *list, *entry;
-
-    MRP_ASSERT(class && zone < MRP_ZONE_MAX && cursor, "invalid argument");
-
-    list  = class->resource_sets + zone;
-    entry = (*cursor == NULL) ? list->prev : (mrp_list_hook_t *)*cursor;
-
-    if (entry == list)
-        return NULL;
-
-    *cursor = entry->prev;
-
-    return mrp_list_entry(entry, mrp_resource_set_t, class.list);
-}
-
-const char **mrp_application_class_get_all_names(uint32_t buflen,
-                                                 const char **buf)
-{
-    mrp_list_hook_t *entry, *n;
-    mrp_application_class_t *class;
-    bool freeit = false;
-    uint32_t i  = 0;
-
-    MRP_ASSERT(!buf || (buf && buflen > 1), "invalid argument");
-
-    if (!buf) {
-        freeit = true;
-        buflen = CLASS_MAX;
-        if (!(buf = mrp_allocz(sizeof(const char *) * buflen))) {
-            mrp_log_error("Memory alloc failure. Can't get class names");
-            return NULL;
-        }
-    }
-
-    mrp_list_foreach(&class_list, entry, n) {
-        class = mrp_list_entry(entry, mrp_application_class_t, list);
-
-        if (i >= buflen-1) {
-            if (freeit)
-                mrp_free(buf);
-            return NULL;
-        }
-
-        buf[i++] = class->name;
-    }
-
-    buf[i] = NULL;
-
-    return buf;
-}
-
-
-int mrp_application_class_add_resource_set(const char *class_name,
-                                           const char *zone_name,
-                                           mrp_resource_set_t *rset,
-                                           uint32_t reqid)
-{
-    mrp_application_class_t *class;
-    mrp_zone_t *zone;
-
-
-    MRP_ASSERT(class_name && rset && zone_name, "invalid argument");
-    MRP_ASSERT(!rset->class.ptr || !mrp_list_empty(&rset->class.list),
-               "attempt to add multiple times the same resource set");
-
-    if (!(class = mrp_application_class_find(class_name)))
-        return -1;
-
-    if (!(zone = mrp_zone_find_by_name(zone_name)))
-        return -1;
-
-    rset->class.ptr = class;
-    rset->zone = mrp_zone_get_id(zone);
-    rset->request.id = reqid;
-
-    if (rset->state == mrp_resource_no_request)
-        rset->state = mrp_resource_release;
-
-    mrp_application_class_move_resource_set(rset);
-    mrp_resource_owner_update_zone(rset->zone, rset, reqid);
-    
-    return 0;
-}
-
-void mrp_application_class_move_resource_set(mrp_resource_set_t *rset)
-{
-    mrp_application_class_t *class;
-    mrp_list_hook_t *list, *lentry, *n, *insert_before;
-    mrp_resource_set_t *rentry;
-    uint32_t key;
-    uint32_t zone;
-
-    MRP_ASSERT(rset, "invalid argument");
-
-    mrp_list_delete(&rset->class.list);
-
-    class = rset->class.ptr;
-    zone  = rset->zone;
-
-    list = insert_before = class->resource_sets + zone;
-    key  = mrp_application_class_get_sorting_key(rset);
-
-    mrp_list_foreach_back(list, lentry, n) {
-        rentry = mrp_list_entry(lentry, mrp_resource_set_t, class.list);
-
-         if (key >= mrp_application_class_get_sorting_key(rentry))
-             break;
-
-         insert_before = lentry;
-    }
-
-    mrp_list_append(insert_before, &rset->class.list);
-}
-
-uint32_t mrp_application_class_get_sorting_key(mrp_resource_set_t *rset)
-{
-    uint32_t priority;
-    uint32_t usage;
-    uint32_t state;
-    uint32_t stamp;
-    uint32_t key;
-
-    MRP_ASSERT(rset, "invalid argument");
-
-    priority = PRIORITY_KEY(rset->class.priority);
-    usage    = USAGE_KEY(rset->resource.share ? 1 : 0);
-    state    = STATE_KEY(rset->state == mrp_resource_acquire ? 1 : 0);
-    stamp    = STAMP_KEY(rset->request.stamp);
-
-    key = priority | usage | state | stamp;
-
-    return key;
-}
-
-
-int mrp_application_class_print(char *buf, int len)
-{
-#define PRINT(fmt, args...)  if (p<e) { p += snprintf(p, e-p, fmt , ##args); }
-
-    mrp_zone_t *zone;
-    mrp_application_class_t *class;
-    mrp_resource_set_t *rset;
-    mrp_list_hook_t *clen, *n;
-    mrp_list_hook_t *list, *rsen, *m;
-    uint32_t zid;
-    char *p, *e;
-    int clcnt, rscnt;
-
-    MRP_ASSERT(buf && len > 0, "invalid argument");
-
-    e = (p = buf) + len;
-    clcnt = rscnt = 0;
-
-    PRINT("Application classes:\n");
-
-    mrp_list_foreach_back(&class_list, clen, n) {
-        class = mrp_list_entry(clen, mrp_application_class_t, list);
-        PRINT("  %3u - %s\n", class->priority, class->name);
-
-        for (zid = 0;   zid < MRP_ZONE_MAX;   zid++) {
-            zone = mrp_zone_find_by_id(zid);
-            list = class->resource_sets + zid;
-
-            if (!mrp_list_empty(list)) {
-                if (!zone) {
-                    PRINT("           Resource-sets in zone %u:\n", zid);
-                }
-                else {
-                    PRINT("           Resource-sets in %s zone:", zone->name);
-                    p += mrp_zone_attribute_print(zone, p, e-p);
-                    PRINT("\n");
-                }
-
-                mrp_list_foreach_back(list, rsen, m) {
-                    rset = mrp_list_entry(rsen, mrp_resource_set_t,class.list);
-                    p += mrp_resource_set_print(rset, 13, p, e-p);
-                }
-            }
-        }
-
-        clcnt++;
-    }
-
-    if (!clcnt)
-        PRINT("   <none>\n");
-
-    return p - buf;
-
-#undef PRINT
-}
-
-
-static void init_name_hash(void)
-{
-    mrp_htbl_config_t  cfg;
-
-    if (!name_hash) {
-        cfg.nentry  = CLASS_MAX;
-        cfg.comp    = mrp_string_comp;
-        cfg.hash    = mrp_string_hash;
-        cfg.free    = NULL;
-        cfg.nbucket = cfg.nentry / 2;
-
-        name_hash = mrp_htbl_create(&cfg);
-
-        MRP_ASSERT(name_hash, "failed to make name_hash for resource classes");
-    }
-}
-
-
-static int add_to_name_hash(mrp_application_class_t *class)
-{
-    MRP_ASSERT(class && class->name, "invalid argument");
-
-    init_name_hash();
-
-    if (!mrp_htbl_insert(name_hash, (void *)class->name, class))
-        return -1;
-
-    return 0;
-}
-
-#if 0
-static void remove_from_name_hash(mrp_application_class_t *class)
-{
-    mrp_application_class_t *deleted;
-
-    if (class && class->name && name_hash) {
-        deleted = mrp_htbl_remove(name_hash, (void *)class->name, false);
-
-        MRP_ASSERT(deleted == class, "confused with data structures when "
-                   "deleting resource-class from name hash");
-
-        /* in case we were not compiled with debug enabled */
-        if (deleted != class) {
-            mrp_log_error("confused with data structures when deleting "
-                          "resource-class '%s' from name hash", class->name);
-        }
-    }
-}
-#endif
-
-
-static mqi_handle_t get_database_table(void)
-{
-    MQI_COLUMN_DEFINITION_LIST(coldefs,
-        MQI_COLUMN_DEFINITION( "name"     , MQI_VARCHAR(NAME_LENGTH) ),
-        MQI_COLUMN_DEFINITION( "priority" , MQI_UNSIGNED             )
-    );
-
-    MQI_INDEX_DEFINITION(indexdef,
-        MQI_INDEX_COLUMN("priority")
-    );
-
-    static mqi_handle_t  table = MQI_HANDLE_INVALID;
-    static char         *name  = "application_classes";
-
-    if (table == MQI_HANDLE_INVALID) {
-        mqi_open();
-
-        table = MQI_CREATE_TABLE(name, MQI_TEMPORARY, coldefs, indexdef);
-
-        if (table == MQI_HANDLE_INVALID)
-            mrp_log_error("Can't create table '%s': %s", name,strerror(errno));
-    }
-
-    return table;
-}
-
-static void insert_into_application_class_table(const char *name, uint32_t pri)
-{
-    MQI_COLUMN_SELECTION_LIST(cols,
-        MQI_COLUMN_SELECTOR(CLASS_NAME_IDX, class_row_t, class_name),
-        MQI_COLUMN_SELECTOR(PRIORITY_IDX  , class_row_t, priority  )
-    );
-
-    class_row_t   row;
-    mqi_handle_t  table   = get_database_table();
-    class_row_t  *rows[2] = {&row, NULL};
-
-    MRP_ASSERT(name, "invalid argument");
-    MRP_ASSERT(table != MQI_HANDLE_INVALID, "database problem");
-
-    row.class_name = name;
-    row.priority = pri;
-
-    if (MQI_INSERT_INTO(table, cols, rows) != 1)
-        mrp_log_error("Failed to add application class '%s' to database",name);
-}
-
-
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/application-class.h b/src/resource/application-class.h
deleted file mode 100644 (file)
index c6fff9d..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_APPLICATION_CLASS_H__
-#define __MURPHY_APPLICATION_CLASS_H__
-
-#include <murphy/common/list.h>
-
-#include "data-types.h"
-
-
-
-struct mrp_application_class_s {
-    mrp_list_hook_t  list;
-    const char      *name;
-    uint32_t         priority;
-    mrp_list_hook_t  resource_sets[MRP_ZONE_MAX];
-};
-
-mrp_application_class_t *mrp_application_class_find(const char *);
-mrp_application_class_t *mrp_application_class_iterate_classes(void **);
-mrp_resource_set_t *
-mrp_application_class_iterate_rsets(mrp_application_class_t*,uint32_t,void**);
-
-void mrp_application_class_move_resource_set(mrp_resource_set_t *);
-
-uint32_t mrp_application_class_get_sorting_key(mrp_resource_set_t *);
-
-
-#endif  /* __MURPHY_APPLICATION_CLASS_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/attribute.c b/src/resource/attribute.c
deleted file mode 100644 (file)
index 74e7a47..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <murphy/common/mm.h>
-#include <murphy/common/log.h>
-
-#include "attribute.h"
-
-
-static mrp_attr_value_t *get_attr_value_from_list(mrp_attr_t *, const char *,
-                                                  mqi_data_type_t);
-
-
-int mrp_attribute_copy_definitions(mrp_attr_def_t *from, mrp_attr_def_t *to)
-{
-    mrp_attr_def_t *s, *d;
-
-    MRP_ASSERT(to,"invalid argument");
-
-    if (from) {
-        for (s = from, d = to;   s->name;   s++, d++) {
-
-            if (!(d->name = mrp_strdup(s->name)))
-                goto no_memory;
-
-            d->access = s->access;
-
-            if ((d->type = s->type) != mqi_string)
-                d->value = s->value;
-            else {
-                if (!(d->value.string = mrp_strdup(s->value.string))) {
-                    mrp_free((void *)d->name);
-                    memset(d, 0, sizeof(*d));
-                    goto no_memory;
-                }
-            }
-        }
-    }
-
-    return 0;
-
- no_memory:
-    mrp_log_error("Memory alloc failure. Can't copy attribute definition");
-    return -1;
-}
-
-
-mrp_attr_t *mrp_attribute_get_value(uint32_t          idx,
-                                    mrp_attr_t       *value,
-                                    uint32_t          nattr,
-                                    mrp_attr_def_t   *defs,
-                                    mrp_attr_value_t *attrs)
-{
-    mrp_attr_t *vdst;
-    mrp_attr_def_t *adef;
-
-    MRP_ASSERT(!nattr || (nattr > 0 && defs && attrs), "invalid argument");
-    MRP_ASSERT(idx < nattr, "invalid argument");
-
-    if ((vdst = value) || (vdst = mrp_alloc(sizeof(mrp_attr_t)))) {
-        adef = defs + idx;
-
-        if (!(adef->access & MRP_RESOURCE_READ))
-            memset(vdst, 0, sizeof(mrp_attr_t));
-        else {
-            vdst->name  = adef->name;
-            vdst->type  = adef->type;
-            vdst->value = attrs[idx];
-        }
-    }
-
-    return vdst;
-}
-
-
-mrp_attr_t *mrp_attribute_get_all_values(uint32_t          nvalue,
-                                         mrp_attr_t       *values,
-                                         uint32_t          nattr,
-                                         mrp_attr_def_t   *defs,
-                                         mrp_attr_value_t *attrs)
-{
-    mrp_attr_def_t *adef;
-    mrp_attr_t *vdst, *vend;
-    uint32_t i;
-
-    MRP_ASSERT(!nvalue || (nvalue > 0 && values) ||
-               !nattr  || (nattr  > 0 && defs),
-               "invalid argument");
-
-    if (nvalue)
-        nvalue--;
-    else {
-        for (i = 0;  i < nattr;  i++) {
-            if (!attrs || (attrs && (defs[i].access & MRP_RESOURCE_READ)))
-                nvalue++;
-        }
-
-        if (!(values = mrp_allocz(sizeof(mrp_attr_t) * (nvalue + 1)))) {
-            mrp_log_error("Memory alloc failure. Can't get attributes");
-            return NULL;
-        }
-    }
-
-    vend = (vdst = values) + nvalue;
-
-    for (i = 0;     i < nattr && vdst < vend;    i++) {
-        adef = defs  + i;
-
-        if (!(adef->access && MRP_RESOURCE_READ))
-            continue;
-
-        vdst->name   =  adef->name;
-        vdst->type   =  adef->type;
-        vdst->value  =  attrs ? attrs[i] : adef->value;
-
-        vdst++;
-    }
-
-    memset(vdst, 0, sizeof(*vdst));
-
-    return values;
-}
-
-int mrp_attribute_set_values(mrp_attr_t      *values,
-                             uint32_t          nattr,
-                             mrp_attr_def_t   *defs,
-                             mrp_attr_value_t *attrs)
-{
-    mrp_attr_def_t *adef;
-    mrp_attr_value_t *vsrc;
-    mrp_attr_value_t *vdst;
-    uint32_t i;
-
-
-    MRP_ASSERT(!nattr || (nattr > 0 && defs && attrs),
-               "invlaid arguments");
-
-    for (i = 0;  i < nattr;  i++) {
-        adef = defs  + i;
-        vdst = attrs + i;
-
-        if (!(adef->access & MRP_RESOURCE_WRITE) ||
-            !(vsrc = get_attr_value_from_list(values, adef->name, adef->type)))
-            vsrc = &adef->value; /* default value */
-
-        if (adef->type !=  mqi_string)
-            *vdst = *vsrc;
-        else {
-            mrp_free((void *)vdst->string);
-            if (!(vdst->string = mrp_strdup(vsrc->string)))
-                return -1;
-        }
-    }
-
-    return 0;
-}
-
-
-int mrp_attribute_print(uint32_t          nattr,
-                        mrp_attr_def_t   *adefs,
-                        mrp_attr_value_t *avals,
-                        char             *buf,
-                        int               len)
-{
-#define PRINT(fmt, args...)  if (p<e) { p += snprintf(p, e-p, fmt , ##args); }
-
-    mrp_attr_def_t *adef;
-    mrp_attr_value_t *aval;
-    uint32_t i;
-    char *p, *e;
-
-    MRP_ASSERT(adefs && avals && buf && len > 0, "invalid argument");
-
-    e = (p = buf) + len;
-
-    for (i = 0;  i < nattr;  i++) {
-        adef = adefs + i;
-        aval = avals + i;
-
-        PRINT(" %s:", adef->name);
-
-        switch (adef->type) {
-        case mqi_string:    PRINT("'%s'", aval->string  );   break;
-        case mqi_integer:   PRINT("%d"  , aval->integer );   break;
-        case mqi_unsignd:   PRINT("%u"  , aval->unsignd );   break;
-        case mqi_floating:  PRINT("%lf" , aval->floating);   break;
-        default:            PRINT(" <unsupported type>" );   break;
-        }
-
-    }
-
-    return p - buf;
-
-#undef PRINT
-}
-
-
-static mrp_attr_value_t *get_attr_value_from_list(mrp_attr_t     *list,
-                                                  const char     *name,
-                                                  mqi_data_type_t type)
-{
-    mrp_attr_t *attr;
-
-    MRP_ASSERT(name, "invalid argument");
-
-    if (list) {
-        for (attr = list;   attr->name;   attr++) {
-            if (!strcasecmp(name, attr->name) && type == attr->type)
-                return &attr->value;
-        }
-    }
-
-    return NULL;
-}
-
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/attribute.h b/src/resource/attribute.h
deleted file mode 100644 (file)
index e83e23c..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_ATTRIBUTE_H__
-#define __MURPHY_ATTRIBUTE_H__
-
-#include "data-types.h"
-
-
-int mrp_attribute_copy_definitions(mrp_attr_def_t *, mrp_attr_def_t *);
-mrp_attr_t *mrp_attribute_get_value(uint32_t, mrp_attr_t *, uint32_t,
-                                    mrp_attr_def_t *, mrp_attr_value_t *);
-mrp_attr_t *mrp_attribute_get_all_values(uint32_t, mrp_attr_t *, uint32_t,
-                                         mrp_attr_def_t *, mrp_attr_value_t *);
-int mrp_attribute_set_values(mrp_attr_t *, uint32_t, mrp_attr_def_t *,
-                             mrp_attr_value_t *);
-
-int mrp_attribute_print(uint32_t, mrp_attr_def_t *, mrp_attr_value_t *,
-                        char *, int);
-
-
-#endif  /* __MURPHY_ATTRIBUTE_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/client-api.h b/src/resource/client-api.h
deleted file mode 100644 (file)
index 73762ac..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_CLIENT_API_H__
-#define __MURPHY_RESOURCE_CLIENT_API_H__
-
-#include <murphy/resource/common-api.h>
-
-mrp_resource_client_t *mrp_resource_client_create(const char *name,
-                                                  void *user_data);
-void mrp_resource_client_destroy(mrp_resource_client_t *client);
-
-mrp_resource_set_t *mrp_resource_client_find_set(mrp_resource_client_t *client,
-                                                 uint32_t resource_set_id);
-
-
-const char **mrp_zone_get_all_names(uint32_t buflen, const char **buf);
-
-const char **mrp_resource_definition_get_all_names(uint32_t buflen,
-                                                   const char **buf);
-
-mrp_attr_t *
-mrp_resource_definition_read_all_attributes(uint32_t resource_id,
-                                            uint32_t buflen,
-                                            mrp_attr_t *buf);
-
-const char **mrp_application_class_get_all_names(uint32_t buflen,
-                                                 const char **buf);
-
-int mrp_application_class_add_resource_set(const char *class_name,
-                                           const char *zone_name,
-                                           mrp_resource_set_t *resource_set,
-                                           uint32_t request_id);
-
-mrp_resource_set_t *mrp_resource_set_create(mrp_resource_client_t *client,
-                                            bool auto_release,
-                                            uint32_t priority,
-                                            mrp_resource_event_cb_t event_cb,
-                                            void *user_data);
-void mrp_resource_set_destroy(mrp_resource_set_t *resource_set);
-
-uint32_t mrp_get_resource_set_id(mrp_resource_set_t *resource_set);
-
-mrp_resource_state_t
-mrp_get_resource_set_state(mrp_resource_set_t *resource_set);
-
-mrp_resource_mask_t
-mrp_get_resource_set_grant(mrp_resource_set_t *resource_set);
-
-mrp_resource_mask_t
-mrp_get_resource_set_advice(mrp_resource_set_t *resource_set);
-
-mrp_resource_client_t *
-mrp_get_resource_set_client(mrp_resource_set_t *resource_set);
-
-
-int mrp_resource_set_add_resource(mrp_resource_set_t *resource_set,
-                                  const char *resource_name,
-                                  bool shared,
-                                  mrp_attr_t *attribute_list,
-                                  bool mandatory);
-
-mrp_attr_t *
-mrp_resource_set_read_attribute(mrp_resource_set_t *resource_set,
-                                const char *resource_name,
-                                uint32_t attribute_index,
-                                mrp_attr_t *buf);
-
-mrp_attr_t *
-mrp_resource_set_read_all_attributes(mrp_resource_set_t *resource_set,
-                                     const char *resource_name,
-                                     uint32_t buflen,
-                                     mrp_attr_t *buf);
-
-int mrp_resource_set_write_attributes(mrp_resource_set_t *resource_set,
-                                      const char *resource_name,
-                                      mrp_attr_t *attribute_list);
-
-void mrp_resource_set_acquire(mrp_resource_set_t *resource_set,
-                              uint32_t request_id);
-
-void mrp_resource_set_release(mrp_resource_set_t *resource_set,
-                              uint32_t request_id);
-
-mrp_resource_t *
-mrp_resource_set_iterate_resources(mrp_resource_set_t *resource_set,void **it);
-
-uint32_t mrp_resource_get_id(mrp_resource_t *resource);
-const char *mrp_resource_get_name(mrp_resource_t *resource);
-mrp_resource_mask_t mrp_resource_get_mask(mrp_resource_t *resource);
-bool mrp_resource_is_shared(mrp_resource_t *resource);
-
-
-#endif  /* __MURPHY_RESOURCE_CLIENT_API_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/common-api.h b/src/resource/common-api.h
deleted file mode 100644 (file)
index 4b49e2b..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_COMMON_API_H__
-#define __MURPHY_RESOURCE_COMMON_API_H__
-
-#include <murphy/resource/data-types.h>
-
-
-mrp_attr_t *mrp_resource_read_attribute(mrp_resource_t *resource,
-                                        uint32_t attribute_index,
-                                        mrp_attr_t *buf);
-mrp_attr_t *mrp_resource_read_all_attributes(mrp_resource_t *resource,
-                                             uint32_t buflen,
-                                             mrp_attr_t *buf);
-int mrp_resource_write_attributes(mrp_resource_t *resource, mrp_attr_t *attrs);
-
-
-#endif  /* __MURPHY_RESOURCE_COMMON_API_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/config-api.h b/src/resource/config-api.h
deleted file mode 100644 (file)
index d723593..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_CONFIG_API_H__
-#define __MURPHY_RESOURCE_CONFIG_API_H__
-
-#include <murphy/resource/data-types.h>
-
-int mrp_zone_definition_create(mrp_attr_def_t *attrdefs);
-uint32_t mrp_zone_create(const char *name, mrp_attr_t *attrs);
-
-mrp_application_class_t *mrp_application_class_create(const char *name,
-                                                      uint32_t priority);
-
-int mrp_application_class_print(char *buf, int len);
-
-int mrp_resource_owner_print(char *buf, int len);
-
-
-#endif  /* __MURPHY_RESOURCE_CONFIG_API_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/data-types.h b/src/resource/data-types.h
deleted file mode 100644 (file)
index 91fcc37..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_DATA_TYPES_H__
-#define __MURPHY_DATA_TYPES_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <murphy-db/mqi-types.h>
-
-#define MRP_ZONE_MAX            8
-
-#define MRP_KEY_STAMP_BITS      27
-#define MRP_KEY_STATE_BITS      1
-#define MRP_KEY_USAGE_BITS      1
-#define MRP_KEY_PRIORITY_BITS   3
-
-#define MRP_ZONE_ID_INVALID        (~(uint32_t)0)
-#define MRP_RESOURCE_ID_INVALID    (~(uint32_t)0)
-#define MRP_RESOURCE_REQNO_INVALID (~(uint32_t)0)
-
-
-
-typedef enum   mrp_resource_state_e     mrp_resource_state_t;
-typedef enum   mrp_resource_access_e    mrp_resource_access_t;
-
-typedef struct mrp_resource_client_s    mrp_resource_client_t;
-typedef union  mrp_attr_value_u         mrp_attr_value_t;
-typedef struct mrp_attr_def_s           mrp_attr_def_t;
-typedef struct mrp_attr_s               mrp_attr_t;
-typedef struct mrp_zone_def_s           mrp_zone_def_t;
-typedef struct mrp_zone_s               mrp_zone_t;
-typedef struct mrp_application_class_s  mrp_application_class_t;
-typedef struct mrp_resource_owner_s     mrp_resource_owner_t;
-typedef struct mrp_resource_set_s       mrp_resource_set_t;
-typedef struct mrp_resource_def_s       mrp_resource_def_t;
-typedef struct mrp_resource_s           mrp_resource_t;
-typedef struct mrp_resource_mgr_ftbl_s  mrp_resource_mgr_ftbl_t;
-typedef struct mrp_resource_mgr_s       mrp_resource_mgr_t;
-
-typedef uint32_t                        mrp_resource_mask_t;
-typedef uint32_t                        mrp_attribute_mask_t;
-
-
-enum mrp_resource_state_e {
-    mrp_resource_no_request = 0,
-    mrp_resource_release,
-    mrp_resource_acquire,
-};
-
-
-enum mrp_resource_access_e {
-    MRP_RESOURCE_ACCESS_NONE  = 0,
-    MRP_RESOURCE_READ  = 1,
-    MRP_RESOURCE_WRITE = 2,
-    MRP_RESOURCE_RW    = (MRP_RESOURCE_READ | MRP_RESOURCE_WRITE)
-};
-
-union mrp_attr_value_u {
-    const char  *string;
-    int32_t      integer;
-    uint32_t     unsignd;
-    double       floating;
-};
-
-struct mrp_attr_def_s {
-    const char            *name;
-    mrp_resource_access_t  access;
-    mqi_data_type_t        type;
-    mrp_attr_value_t       value;
-};
-
-struct mrp_attr_s {
-    const char      *name;
-    mqi_data_type_t  type;
-    mrp_attr_value_t value;
-};
-
-
-typedef void (*mrp_resource_event_cb_t)(uint32_t, mrp_resource_set_t *, void*);
-
-typedef void (*mrp_manager_init_func_t)(mrp_zone_t *, void *);
-typedef bool (*mrp_manager_alloc_func_t)(mrp_zone_t *,mrp_resource_t *,void*);
-typedef void (*mrp_manager_free_func_t)(mrp_zone_t *,mrp_resource_t *,void *);
-typedef bool (*mrp_manager_advice_func_t)(mrp_zone_t *,mrp_resource_t*,void *);
-typedef void (*mrp_manager_commit_func_t)(mrp_zone_t *, void *);
-
-struct mrp_resource_mgr_ftbl_s  {
-    mrp_manager_init_func_t     init;
-    mrp_manager_alloc_func_t    allocate;
-    mrp_manager_free_func_t     free;
-    mrp_manager_advice_func_t   advice;
-    mrp_manager_commit_func_t   commit;
-};
-
-
-
-#endif  /* __MURPHY_DATA_TYPES_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/manager-api.h b/src/resource/manager-api.h
deleted file mode 100644 (file)
index 60b1a07..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_MANAGER_API_H__
-#define __MURPHY_RESOURCE_MANAGER_API_H__
-
-#include <murphy/resource/common-api.h>
-
-uint32_t mrp_zone_get_id(mrp_zone_t *zone);
-const char *mrp_zone_get_name(mrp_zone_t *zone);
-mrp_attr_t *mrp_zone_read_attribute(mrp_zone_t *zone,
-                                    uint32_t attribute_index,
-                                    mrp_attr_t *buf);
-mrp_attr_t *mrp_zone_read_all_attributes(mrp_zone_t *zone,
-                                         uint32_t buflen,
-                                         mrp_attr_t *buf);
-
-
-uint32_t mrp_resource_definition_create(const char *name,
-                                        bool shareable,
-                                        mrp_attr_def_t *attrdefs,
-                                        mrp_resource_mgr_ftbl_t *manager,
-                                        void *manager_data);
-
-
-
-#endif  /* __MURPHY_RESOURCE_MANAGER_API_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/murphy-resource.pc.in b/src/resource/murphy-resource.pc.in
deleted file mode 100644 (file)
index 14eaa34..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: murphy-resource
-Description: Murphy policy framework, resource library.
-Requires: murphy-core murphy-common = @PACKAGE_VERSION@
-Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lmurphy-core -lmurphy-common -lmurphy-resource
-Cflags: -I${includedir}
diff --git a/src/resource/protocol.h b/src/resource/protocol.h
deleted file mode 100644 (file)
index 203c17c..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_PROTOCOL_H__
-#define __MURPHY_RESOURCE_PROTOCOL_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <murphy/common/msg.h>
-
-#define RESPROTO_DEFAULT_ADDRESS      "tcp4:127.0.0.1:3030"
-
-
-#define RESPROTO_BIT(n)               ((uint32_t)1 << (n))
-
-#define RESPROTO_RSETFLAG_AUTORELEASE RESPROTO_BIT(0)
-
-#define RESPROTO_RESFLAG_MANDATORY    RESPROTO_BIT(0)
-#define RESPROTO_RESFLAG_SHARED       RESPROTO_BIT(1)
-
-#define RESPROTO_TAG(x)               ((uint16_t)(x))
-
-#define RESPROTO_MESSAGE_END          MRP_MSG_FIELD_END
-#define RESPROTO_SECTION_END          RESPROTO_TAG(1)
-#define RESPROTO_ARRAY_DIMENSION      RESPROTO_TAG(2)
-#define RESPROTO_SEQUENCE_NO          RESPROTO_TAG(3)
-#define RESPROTO_REQUEST_TYPE         RESPROTO_TAG(4)
-#define RESPROTO_REQUEST_STATUS       RESPROTO_TAG(5)
-#define RESPROTO_RESOURCE_SET_ID      RESPROTO_TAG(6)
-#define RESPROTO_RESOURCE_STATE       RESPROTO_TAG(7)
-#define RESPROTO_RESOURCE_GRANT       RESPROTO_TAG(8)
-#define RESPROTO_RESOURCE_ADVICE      RESPROTO_TAG(9)
-#define RESPROTO_RESOURCE_ID          RESPROTO_TAG(10)
-#define RESPROTO_RESOURCE_NAME        RESPROTO_TAG(11)
-#define RESPROTO_RESOURCE_FLAGS       RESPROTO_TAG(12)
-#define RESPROTO_RESOURCE_PRIORITY    RESPROTO_TAG(13)
-#define RESPROTO_CLASS_NAME           RESPROTO_TAG(14)
-#define RESPROTO_ZONE_NAME            RESPROTO_TAG(15)
-#define RESPROTO_ATTRIBUTE_INDEX      RESPROTO_TAG(16)
-#define RESPROTO_ATTRIBUTE_NAME       RESPROTO_TAG(17)
-#define RESPROTO_ATTRIBUTE_VALUE      RESPROTO_TAG(18)
-
-typedef enum {
-    RESPROTO_QUERY_RESOURCES,
-    RESPROTO_QUERY_CLASSES,
-    RESPROTO_QUERY_ZONES,
-    RESPROTO_CREATE_RESOURCE_SET,
-    RESPROTO_DESTROY_RESOURCE_SET,
-    RESPROTO_ACQUIRE_RESOURCE_SET,
-    RESPROTO_RELEASE_RESOURCE_SET,
-    RESPROTO_RESOURCES_EVENT,
-} mrp_resproto_request_t;
-
-typedef enum {
-    RESPROTO_RELEASE,
-    RESPROTO_ACQUIRE,
-} mrp_resproto_state_t;
-
-
-#endif  /* __MURPHY_RESOURCE_PROTOCOL_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/resource-client.c b/src/resource/resource-client.c
deleted file mode 100644 (file)
index 3d96231..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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 <stdio.h>
-#include <string.h>
-
-#include <murphy/common/mm.h>
-#include <murphy/common/log.h>
-
-#include <resource/client-api.h>
-
-#include "resource-client.h"
-#include "resource-set.h"
-
-
-
-static MRP_LIST_HOOK(client_list);
-
-
-mrp_resource_client_t *mrp_resource_client_create(const char *name,
-                                                  void *user_data)
-{
-    mrp_resource_client_t *client;
-    const char *dup_name;
-
-    MRP_ASSERT(name, "invalid argument");
-
-    if (!(client = mrp_allocz(sizeof(*client))) ||
-        !(dup_name = mrp_strdup(name)))
-    {
-        mrp_log_error("Memory alloc failure. Can't create client '%s'", name);
-        return NULL;
-    }
-
-    client->name = dup_name;
-    client->user_data = user_data;
-    mrp_list_init(&client->resource_sets);
-
-    mrp_list_append(&client_list, &client->list);
-
-    return client;
-}
-
-void mrp_resource_client_destroy(mrp_resource_client_t *client)
-{
-    mrp_list_hook_t *entry, *n;
-    mrp_resource_set_t *rset;
-
-    if (client) {
-        mrp_list_delete(&client->list);
-
-        mrp_list_foreach(&client->resource_sets, entry, n) {
-            rset = mrp_list_entry(entry, mrp_resource_set_t, client.list);
-            mrp_resource_set_destroy(rset);
-        }
-
-        mrp_free(client);
-    }
-}
-
-
-mrp_resource_set_t *mrp_resource_client_find_set(mrp_resource_client_t *client,
-                                                 uint32_t resource_set_id)
-{
-    mrp_list_hook_t *entry, *n;
-    mrp_resource_set_t *rset;
-
-    if (client) {
-        mrp_list_foreach(&client->resource_sets, entry, n) {
-            rset = mrp_list_entry(entry, mrp_resource_set_t, client.list);
-
-            if (resource_set_id == rset->id)
-                return rset;
-        }
-    }
-
-    return NULL;
-}
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/resource-client.h b/src/resource/resource-client.h
deleted file mode 100644 (file)
index 7d8369b..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_CLIENT_H__
-#define __MURPHY_RESOURCE_CLIENT_H__
-
-#include <murphy/common/list.h>
-
-#include "data-types.h"
-
-
-struct mrp_resource_client_s {
-    mrp_list_hook_t  list;
-    const char      *name;
-    void            *user_data;
-    mrp_list_hook_t  resource_sets;
-};
-
-
-
-#endif  /* __MURPHY_RESOURCE_CLIENT_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/resource-owner.c b/src/resource/resource-owner.c
deleted file mode 100644 (file)
index fd4ed6c..0000000
+++ /dev/null
@@ -1,668 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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 <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-
-#include <murphy/common/mm.h>
-#include <murphy/common/hashtbl.h>
-#include <murphy/common/utils.h>
-#include <murphy/common/log.h>
-
-#include <murphy/resource/client-api.h>
-#include <murphy/resource/config-api.h>
-#include <murphy-db/mqi.h>
-
-#include "resource-owner.h"
-#include "application-class.h"
-#include "resource-set.h"
-#include "resource.h"
-#include "zone.h"
-
-
-#define RESOURCE_MAX        (sizeof(mrp_resource_mask_t) * 8)
-#define NAME_LENGTH          24
-
-#define ZONE_ID_IDX          0
-#define ZONE_NAME_IDX        1
-#define CLASS_NAME_IDX       2
-#define FIRST_ATTRIBUTE_IDX  3
-
-typedef struct {
-    uint32_t          zone_id;
-    const char       *zone_name;
-    const char       *class_name;
-    mrp_attr_value_t  attrs[MQI_COLUMN_MAX];
-} owner_row_t;
-
-static mrp_resource_owner_t  resource_owners[MRP_ZONE_MAX * RESOURCE_MAX];
-static mqi_handle_t          owner_tables[RESOURCE_MAX];
-
-static mrp_resource_owner_t *get_owner(uint32_t, uint32_t);
-static void reset_owners(uint32_t, mrp_resource_owner_t *);
-static bool grant_ownership(mrp_resource_owner_t *, mrp_zone_t *,
-                            mrp_application_class_t *, mrp_resource_set_t *,
-                            mrp_resource_t *);
-static bool advice_ownership(mrp_resource_owner_t *, mrp_zone_t *,
-                             mrp_application_class_t *, mrp_resource_set_t *,
-                             mrp_resource_t *);
-
-static void manager_start_transaction(mrp_zone_t *);
-static void manager_end_transaction(mrp_zone_t *);
-
-static void delete_resource_owner(mrp_zone_t *, mrp_resource_t *);
-static void insert_resource_owner(mrp_zone_t *, mrp_application_class_t *,
-                                  mrp_resource_t *);
-static void update_resource_owner(mrp_zone_t *, mrp_application_class_t *,
-                                  mrp_resource_t *);
-static void set_attr_descriptors(mqi_column_desc_t *, mrp_resource_t *);
-
-
-int mrp_resource_owner_create_database_table(mrp_resource_def_t *rdef)
-{
-    MQI_COLUMN_DEFINITION_LIST(base_coldefs,
-        MQI_COLUMN_DEFINITION( "zone_id"          , MQI_UNSIGNED             ),
-        MQI_COLUMN_DEFINITION( "zone_name"        , MQI_VARCHAR(NAME_LENGTH) ),
-        MQI_COLUMN_DEFINITION( "application_class", MQI_VARCHAR(NAME_LENGTH) )
-    );
-
-    MQI_INDEX_DEFINITION(indexdef,
-        MQI_INDEX_COLUMN( "zone_id" )
-    );
-
-    static bool initialized = false;
-
-    char name[256];
-    mqi_column_def_t  coldefs[MQI_COLUMN_MAX + 1];
-    mqi_column_def_t *col;
-    mrp_attr_def_t *atd;
-    mqi_handle_t table;
-    char c, *p;
-    size_t i,j;
-
-    if (!initialized) {
-        mqi_open();
-        for (i = 0;  i < RESOURCE_MAX;  i++)
-            owner_tables[i] = MQI_HANDLE_INVALID;
-        initialized = true;
-    }
-
-    MRP_ASSERT(sizeof(base_coldefs) < sizeof(coldefs),"too many base columns");
-    MRP_ASSERT(rdef, "invalid argument");
-    MRP_ASSERT(rdef->id < RESOURCE_MAX, "confused with data structures");
-    MRP_ASSERT(owner_tables[rdef->id] == MQI_HANDLE_INVALID,
-               "owner table already exist");
-
-    snprintf(name, sizeof(name), "%s_owner", rdef->name);
-    for (p = name; (c = *p);  p++) {
-        if (!isascii(c) || (!isalnum(c) && c != '_'))
-            *p = '_';
-    }
-
-    j = MQI_DIMENSION(base_coldefs) - 1;
-    memcpy(coldefs, base_coldefs, j * sizeof(mqi_column_def_t));
-
-    for (i = 0;  i < rdef->nattr && j < MQI_COLUMN_MAX;  i++, j++) {
-        col = coldefs + j;
-        atd = rdef->attrdefs + i;
-
-        col->name   = atd->name;
-        col->type   = atd->type;
-        col->length = (col->type == mqi_string) ? NAME_LENGTH : 0;
-        col->flags  = 0;
-    }
-
-    memset(coldefs + j, 0, sizeof(mqi_column_def_t));
-
-    table = MQI_CREATE_TABLE(name, MQI_TEMPORARY, coldefs, indexdef);
-
-    if (table == MQI_HANDLE_INVALID) {
-        mrp_log_error("Can't create table '%s': %s", name, strerror(errno));
-        return -1;
-    }
-
-    owner_tables[rdef->id] = table;
-
-    return 0;
-}
-
-
-void mrp_resource_owner_update_zone(uint32_t zoneid,
-                                    mrp_resource_set_t *reqset,
-                                    uint32_t reqid)
-{
-    typedef struct {
-        uint32_t replyid;
-        mrp_resource_set_t *rset;
-    } event_t;
-
-    mrp_resource_owner_t oldowners[RESOURCE_MAX];
-    mrp_resource_owner_t backup[RESOURCE_MAX];
-    mrp_zone_t *zone;
-    mrp_application_class_t *class;
-    mrp_resource_set_t *rset;
-    mrp_resource_t *res;
-    mrp_resource_def_t *rdef;
-    mrp_resource_mgr_ftbl_t *ftbl;
-    mrp_resource_owner_t *owner, *old;
-    mrp_resource_mask_t mask;
-    mrp_resource_mask_t mandatory;
-    mrp_resource_mask_t grant;
-    mrp_resource_mask_t advice;
-    void *clc, *rsc, *rc;
-    uint32_t rid;
-    uint32_t rcnt;
-    bool changed;
-    uint32_t replyid;
-    uint32_t nevent, maxev;
-    event_t *events, *ev, *lastev;
-
-    MRP_ASSERT(zoneid < MRP_ZONE_MAX, "invalid argument");
-
-    zone = mrp_zone_find_by_id(zoneid);
-
-    MRP_ASSERT(zone, "zone is not defined");
-
-    maxev  = mrp_get_resource_set_count();
-    nevent = 0;
-    events = mrp_alloc(sizeof(event_t) * maxev);
-
-    MRP_ASSERT(events, "Memory alloc failure. Can't update zone");
-
-    reset_owners(zoneid, oldowners);
-    manager_start_transaction(zone);
-
-
-    rcnt = mrp_resource_definition_count();
-    clc  = NULL;
-
-    while ((class = mrp_application_class_iterate_classes(&clc))) {
-        rsc = NULL;
-
-        while ((rset=mrp_application_class_iterate_rsets(class,zoneid,&rsc))) {
-            mandatory = rset->resource.mask.mandatory;
-            grant = 0;
-            advice = 0;
-            rc = NULL;
-
-            switch (rset->state) {
-
-            case mrp_resource_acquire:
-                while ((res = mrp_resource_set_iterate_resources(rset, &rc))) {
-                    rdef  = res->def;
-                    rid   = rdef->id;
-                    owner = get_owner(zoneid, rid);
-
-                    backup[rid] = *owner;
-
-                    if (grant_ownership(owner, zone, class, rset, res))
-                        grant |= ((mrp_resource_mask_t)1 << rid);
-                }
-                if ((grant & mandatory) == mandatory)
-                    advice = grant;
-                else {
-                    /* rollback, ie. restore the backed up state */
-                    rc = NULL;
-                    while ((res=mrp_resource_set_iterate_resources(rset,&rc))){
-                         rdef  = res->def;
-                         rid   = rdef->id;
-                         mask  = (mrp_resource_mask_t)1 << rid;
-                         owner = get_owner(zoneid, rid);
-                        *owner = backup[rid];
-
-                        if ((grant & mask)) {
-                            if ((ftbl = rdef->manager.ftbl) && ftbl->free)
-                                ftbl->free(zone, res, rdef->manager.userdata);
-                        }
-
-                        if (advice_ownership(owner, zone, class, rset, res))
-                            advice |= mask;
-                    }
-
-                    grant = 0;
-
-                    if ((advice & mandatory) != mandatory)
-                        advice = 0;
-                }
-                break;
-
-            case mrp_resource_release:
-                while ((res = mrp_resource_set_iterate_resources(rset, &rc))) {
-                    rdef  = res->def;
-                    rid   = rdef->id;
-                    owner = get_owner(zoneid, rid);
-
-                    if (advice_ownership(owner, zone, class, rset, res))
-                        advice |= ((mrp_resource_mask_t)1 << rid);
-                }
-                if ((advice & mandatory) != mandatory)
-                    advice = 0;
-                break;
-
-            default:
-                break;
-            }
-
-            changed = false;
-            replyid = (reqset == rset && reqid == rset->request.id) ? reqid:0;
-
-
-            if (grant != rset->resource.mask.grant) {
-                rset->resource.mask.grant = grant;
-                changed = true;
-
-                if (!grant && rset->auto_release)
-                    rset->state = mrp_resource_release;
-            }
-
-            if (advice != rset->resource.mask.advice) {
-                rset->resource.mask.advice = advice;
-                changed = true;
-            }
-
-            if ((replyid || changed) && rset->event) {
-                ev = events + nevent++;
-
-                ev->replyid = replyid;
-                ev->rset = rset;
-            }
-        } /* while rset */
-    } /* while class */
-
-    manager_end_transaction(zone);
-
-    for (lastev = (ev = events) + nevent;     ev < lastev;     ev++) {
-        rset = ev->rset;
-        rset->event(ev->replyid, rset, rset->user_data);
-    }
-
-    mrp_free(events);
-
-    for (rid = 0;  rid < rcnt;  rid++) {
-        owner = get_owner(zoneid, rid);
-        old   = oldowners + rid;
-
-        if (owner->class != old->class ||
-            owner->rset  != old->rset  ||
-            owner->res   != old->res     )
-        {
-            if (!owner->res)
-                delete_resource_owner(zone, old->res);
-            else if (!old->res)
-                insert_resource_owner(zone, owner->class, owner->res);
-            else
-                update_resource_owner(zone, owner->class, owner->res);
-        }
-    }
-}
-
-int mrp_resource_owner_print(char *buf, int len)
-{
-#define PRINT(fmt, args...)  if (p<e) { p += snprintf(p, e-p, fmt , ##args); }
-
-    mrp_zone_t *zone;
-    mrp_resource_owner_t *owner;
-    mrp_application_class_t *class;
-    mrp_resource_set_t *rset;
-    mrp_resource_t *res;
-    mrp_resource_def_t *rdef;
-    uint32_t rcnt, rid;
-    uint32_t zcnt, zid;
-    char *p, *e;
-
-    MRP_ASSERT(buf && len > 0, "invalid argument");
-
-    rcnt = mrp_resource_definition_count();
-    zcnt = mrp_zone_count();
-
-    e = (p = buf) + len;
-
-    PRINT("Resource owners:\n");
-
-    for (zid = 0;  zid < zcnt;  zid++) {
-        zone = mrp_zone_find_by_id(zid);
-
-        if (!zone) {
-            PRINT("   Zone %u:\n", zid);
-        }
-        else {
-            PRINT("   Zone %s:", zone->name);
-            p += mrp_zone_attribute_print(zone, p, e-p);
-            PRINT("\n");
-        }
-
-        for (rid = 0;   rid < rcnt;   rid++) {
-            if (!(rdef = mrp_resource_definition_find_by_id(rid)))
-                continue;
-
-            PRINT("      %-15s: ", rdef->name);
-
-            owner = get_owner(zid, rid);
-
-            if (!(class = owner->class) ||
-                !(rset  = owner->rset ) ||
-                !(res   = owner->res  )    )
-            {
-                PRINT("<nobody>");
-            }
-            else {
-                MRP_ASSERT(rdef == res->def, "confused with data structures");
-
-                PRINT("%-15s", class->name);
-
-                p += mrp_resource_attribute_print(res, p, e-p);
-            }
-
-            PRINT("\n");
-        }
-    }
-
-    return p - buf;
-
-#undef PRINT
-}
-
-
-static mrp_resource_owner_t *get_owner(uint32_t zone, uint32_t resid)
-{
-    MRP_ASSERT(zone < MRP_ZONE_MAX && resid < RESOURCE_MAX,"invalid argument");
-
-    return resource_owners + (zone * RESOURCE_MAX + resid);
-}
-
-static void reset_owners(uint32_t zone, mrp_resource_owner_t *oldowners)
-{
-    void   *ptr  = get_owner(zone, 0);
-    size_t  size = sizeof(mrp_resource_owner_t) * RESOURCE_MAX;
-
-    if (oldowners)
-        memcpy(oldowners, ptr, size);
-
-    memset(ptr, 0, size);
-}
-
-static bool grant_ownership(mrp_resource_owner_t    *owner,
-                            mrp_zone_t              *zone,
-                            mrp_application_class_t *class,
-                            mrp_resource_set_t      *rset,
-                            mrp_resource_t          *res)
-{
-    mrp_resource_def_t      *rdef = res->def;
-    mrp_resource_mgr_ftbl_t *ftbl = rdef->manager.ftbl;
-    bool                     set_owner = false;
-
-    /*
-      if (forbid_grant())
-        return false;
-     */
-
-    do { /* not a loop */
-        if (!owner->class && !owner->rset) {
-            /* nobody owns this, so grab it */
-            set_owner = true;
-            break;
-        }
-
-        if (owner->class == class && owner->rset == rset) {
-            /* we happen to already own it */
-            break;
-        }
-
-        if (owner->share) {
-            /* OK, someone else owns it bu
-               the owner is ready to share it with us */
-            owner->share = res->shared;
-            break;
-        }
-
-        return false;
-
-    } while(0);
-
-    if (ftbl && ftbl->allocate) {
-        if (!ftbl->allocate(zone, res, rdef->manager.userdata))
-            return false;
-    }
-
-    if (set_owner) {
-        owner->class = class;
-        owner->rset  = rset;
-        owner->res   = res;
-        owner->share = res->shared;
-    }
-
-    return true;
-}
-
-static bool advice_ownership(mrp_resource_owner_t    *owner,
-                             mrp_zone_t              *zone,
-                             mrp_application_class_t *class,
-                             mrp_resource_set_t      *rset,
-                             mrp_resource_t          *res)
-{
-    mrp_resource_def_t      *rdef = res->def;
-    mrp_resource_mgr_ftbl_t *ftbl = rdef->manager.ftbl;
-
-    (void)zone;
-
-    /*
-      if (forbid_grant())
-        return false;
-     */
-
-    do { /* not a loop */
-        if (!owner->class && !owner->rset)
-            /* nobody owns this */
-            break;
-
-        if (owner->share)
-            /* someone else owns it but it can be shared */
-            break;
-
-
-        if (owner->class == class) {
-            if (owner->rset->class.priority == rset->class.priority)
-                break;
-        }
-
-        return false;
-
-    } while(0);
-
-    if (ftbl && ftbl->advice) {
-        if (!ftbl->advice(zone, res, rdef->manager.userdata))
-            return false;
-    }
-
-    return true;
-}
-
-static void manager_start_transaction(mrp_zone_t *zone)
-{
-    mrp_resource_def_t *rdef;
-    mrp_resource_mgr_ftbl_t *ftbl;
-    void *cursor = NULL;
-
-    while ((rdef = mrp_resource_definition_iterate_manager(&cursor))) {
-        ftbl = rdef->manager.ftbl;
-
-        MRP_ASSERT(ftbl, "confused with data structures");
-
-        if (ftbl->init)
-            ftbl->init(zone, rdef->manager.userdata);
-    }
-}
-
-static void manager_end_transaction(mrp_zone_t *zone)
-{
-    mrp_resource_def_t *rdef;
-    mrp_resource_mgr_ftbl_t *ftbl;
-    void *cursor = NULL;
-
-    while ((rdef = mrp_resource_definition_iterate_manager(&cursor))) {
-        ftbl = rdef->manager.ftbl;
-
-        MRP_ASSERT(ftbl, "confused with data structures");
-
-        if (ftbl->commit)
-            ftbl->commit(zone, rdef->manager.userdata);
-    }
-}
-
-
-static void delete_resource_owner(mrp_zone_t *zone, mrp_resource_t *res)
-{
-    static uint32_t zone_id;
-
-    MQI_WHERE_CLAUSE(where,
-        MQI_EQUAL( MQI_COLUMN(0), MQI_UNSIGNED_VAR(zone_id) )
-    );
-
-    mrp_resource_def_t *rdef;
-    int n;
-
-    MRP_ASSERT(res, "invalid argument");
-
-    rdef = res->def;
-    zone_id = zone->id;
-
-    if ((n = MQI_DELETE(owner_tables[rdef->id], where)) != 1)
-        mrp_log_error("Could not delete resource owner");
-}
-
-static void insert_resource_owner(mrp_zone_t *zone,
-                                  mrp_application_class_t *class,
-                                  mrp_resource_t *res)
-{
-    mrp_resource_def_t *rdef = res->def;
-    uint32_t i;
-    int n;
-    owner_row_t row;
-    owner_row_t *rows[2];
-    mqi_column_desc_t cdsc[FIRST_ATTRIBUTE_IDX + MQI_COLUMN_MAX + 1];
-
-    MRP_ASSERT(FIRST_ATTRIBUTE_IDX + rdef->nattr <= MQI_COLUMN_MAX,
-               "too many attributes for a table");
-
-    row.zone_id    = zone->id;
-    row.zone_name  = zone->name;
-    row.class_name = class->name;
-    memcpy(row.attrs, res->attrs, rdef->nattr * sizeof(mrp_attr_value_t));
-
-    i = 0;
-    cdsc[i].cindex = ZONE_ID_IDX;
-    cdsc[i].offset = MQI_OFFSET(owner_row_t, zone_id);
-
-    i++;
-    cdsc[i].cindex = ZONE_NAME_IDX;
-    cdsc[i].offset = MQI_OFFSET(owner_row_t, zone_name);
-
-    i++;
-    cdsc[i].cindex = CLASS_NAME_IDX;
-    cdsc[i].offset = MQI_OFFSET(owner_row_t, class_name);
-
-    set_attr_descriptors(cdsc + (i+1), res);
-
-    rows[0] = &row;
-    rows[1] = NULL;
-
-    if ((n = MQI_INSERT_INTO(owner_tables[rdef->id], cdsc, rows)) != 1)
-        mrp_log_error("can't insert row into owner table");
-}
-
-static void update_resource_owner(mrp_zone_t *zone,
-                                  mrp_application_class_t *class,
-                                  mrp_resource_t *res)
-{
-    static uint32_t zone_id;
-
-    MQI_WHERE_CLAUSE(where,
-        MQI_EQUAL( MQI_COLUMN(0), MQI_UNSIGNED_VAR(zone_id) )
-    );
-
-    mrp_resource_def_t *rdef = res->def;
-    uint32_t i;
-    int n;
-    owner_row_t row;
-    mqi_column_desc_t cdsc[FIRST_ATTRIBUTE_IDX + MQI_COLUMN_MAX + 1];
-
-    zone_id = zone->id;
-
-    MRP_ASSERT(1 + rdef->nattr <= MQI_COLUMN_MAX,
-               "too many attributes for a table");
-
-    row.class_name = class->name;
-    memcpy(row.attrs, res->attrs, rdef->nattr * sizeof(mrp_attr_value_t));
-
-    i = 0;
-    cdsc[i].cindex = CLASS_NAME_IDX;
-    cdsc[i].offset = MQI_OFFSET(owner_row_t, class_name);
-
-    set_attr_descriptors(cdsc + (i+1), res);
-
-
-    if ((n = MQI_UPDATE(owner_tables[rdef->id], cdsc, &row, where)) != 1)
-        mrp_log_error("can't update row in owner table");
-}
-
-
-static void set_attr_descriptors(mqi_column_desc_t *cdsc, mrp_resource_t *res)
-{
-    mrp_resource_def_t *rdef = res->def;
-    uint32_t i,j;
-    int o;
-
-    for (i = j = 0;  j < rdef->nattr;  j++) {
-        switch (rdef->attrdefs[j].type) {
-        case mqi_string:   o = MQI_OFFSET(owner_row_t,attrs[j].string);  break;
-        case mqi_integer:  o = MQI_OFFSET(owner_row_t,attrs[j].integer); break;
-        case mqi_unsignd:  o = MQI_OFFSET(owner_row_t,attrs[j].unsignd); break;
-        case mqi_floating: o = MQI_OFFSET(owner_row_t,attrs[j].floating);break;
-        default:           /* skip this */                            continue;
-        }
-
-        cdsc[i].cindex = FIRST_ATTRIBUTE_IDX + j;
-        cdsc[i].offset = o;
-        i++;
-    }
-
-    cdsc[i].cindex = -1;
-    cdsc[i].offset =  1;
-}
-
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/resource-owner.h b/src/resource/resource-owner.h
deleted file mode 100644 (file)
index 991e76c..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_OWNER_H__
-#define __MURPHY_RESOURCE_OWNER_H__
-
-#include "data-types.h"
-
-
-
-struct mrp_resource_owner_s {
-    mrp_application_class_t *class;  /**< owner application class */
-    mrp_resource_set_t      *rset;   /**< owner resource set  */
-    mrp_resource_t          *res;    /**< owner resource */
-    bool                     share;  /**< do not use this  */
-};
-
-
-int  mrp_resource_owner_create_database_table(mrp_resource_def_t *);
-void mrp_resource_owner_update_zone(uint32_t, mrp_resource_set_t *, uint32_t);
-
-
-#endif  /* __MURPHY_RESOURCE_OWNER_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/resource-set.c b/src/resource/resource-set.c
deleted file mode 100644 (file)
index e88db9a..0000000
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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 <stdio.h>
-#include <string.h>
-
-#include <murphy/common/mm.h>
-#include <murphy/common/hashtbl.h>
-#include <murphy/common/utils.h>
-#include <murphy/common/log.h>
-
-#include <murphy/resource/client-api.h>
-#include <murphy/resource/common-api.h>
-
-#include "resource-set.h"
-#include "application-class.h"
-#include "resource.h"
-#include "resource-client.h"
-#include "resource-owner.h"
-
-
-#define STAMP_MAX     ((uint32_t)1 << MRP_KEY_STAMP_BITS)
-#define PRIORITY_MAX  ((uint32_t)1 << MRP_KEY_PRIORITY_BITS)
-
-static MRP_LIST_HOOK(resource_set_list);
-static uint32_t resource_set_count;
-
-static mrp_resource_t *find_resource(mrp_resource_set_t *, const char *);
-static uint32_t get_request_stamp(void);
-static const char *state_str(mrp_resource_state_t);
-
-
-uint32_t mrp_get_resource_set_count(void)
-{
-    return resource_set_count;
-}
-
-mrp_resource_set_t *mrp_resource_set_create(mrp_resource_client_t *client,
-                                            bool auto_release,
-                                            uint32_t priority,
-                                            mrp_resource_event_cb_t event_cb,
-                                            void *user_data)
-{
-    static uint32_t our_id;
-
-    mrp_resource_set_t *rset;
-
-    MRP_ASSERT(client, "invlaid argument");
-
-    if (priority >= PRIORITY_MAX)
-        priority = PRIORITY_MAX - 1;
-
-    if (!(rset = mrp_allocz(sizeof(mrp_resource_set_t))))
-        mrp_log_error("Memory alloc failure. Can't create resource set");
-    else {
-        rset->id = ++our_id;
-        rset->auto_release = auto_release;
-
-        mrp_list_init(&rset->resource.list);
-        rset->resource.share = false;
-
-        mrp_list_append(&client->resource_sets, &rset->client.list);
-        rset->client.ptr = client;
-        rset->client.reqno = MRP_RESOURCE_REQNO_INVALID;
-
-        mrp_list_init(&rset->class.list);
-        rset->class.priority = priority;
-
-        mrp_list_append(&resource_set_list, &rset->list);
-
-        rset->event = event_cb;
-        rset->user_data = user_data;
-
-        resource_set_count++;
-    }
-
-    return rset;
-}
-
-void mrp_resource_set_destroy(mrp_resource_set_t *rset)
-{
-    mrp_resource_state_t state;
-    uint32_t zoneid;
-    mrp_list_hook_t *entry, *n;
-    mrp_resource_t *res;
-
-    if (rset) {
-        state  = rset->state;
-        zoneid = rset->zone;
-
-        mrp_list_foreach(&rset->resource.list, entry, n) {
-            res = mrp_list_entry(entry, mrp_resource_t, list);
-            mrp_resource_destroy(res);
-        }
-
-        mrp_list_delete(&rset->list);
-        mrp_list_delete(&rset->client.list);
-        mrp_list_delete(&rset->class.list);
-
-        mrp_free(rset);
-
-        if (resource_set_count > 0)
-            resource_set_count--;
-
-        if (state == mrp_resource_acquire) {
-            mrp_resource_owner_update_zone(zoneid, NULL,
-                                           MRP_RESOURCE_REQNO_INVALID);
-        }
-    }
-}
-
-
-
-uint32_t mrp_get_resource_set_id(mrp_resource_set_t *rset)
-{
-    MRP_ASSERT(rset, "invalid argument");
-
-    return rset->id;
-}
-
-mrp_resource_state_t mrp_get_resource_set_state(mrp_resource_set_t *rset)
-{
-    MRP_ASSERT(rset, "invalid argument");
-
-    return rset->state;
-}
-
-mrp_resource_mask_t mrp_get_resource_set_grant(mrp_resource_set_t *rset)
-{
-    MRP_ASSERT(rset, "invalid argument");
-
-    return rset->resource.mask.grant;
-}
-
-mrp_resource_mask_t mrp_get_resource_set_advice(mrp_resource_set_t *rset)
-{
-    MRP_ASSERT(rset, "invalid argument");
-
-    return rset->resource.mask.advice;
-}
-
-mrp_resource_client_t *mrp_get_resource_set_client(mrp_resource_set_t *rset)
-{
-    MRP_ASSERT(rset, "invalid argument");
-
-    return rset->client.ptr;
-}
-
-
-mrp_resource_t *mrp_resource_set_iterate_resources(mrp_resource_set_t *rset,
-                                                   void **cursor)
-{
-    mrp_list_hook_t *list, *entry;
-
-    MRP_ASSERT(rset && cursor, "invalid argument");
-
-    list  = &rset->resource.list;
-    entry = (*cursor == NULL) ? list->next : (mrp_list_hook_t *)*cursor;
-
-    if (entry == list)
-        return NULL;
-
-    *cursor = entry->next;
-
-    return mrp_list_entry(entry, mrp_resource_t, list);
-}
-
-
-int mrp_resource_set_add_resource(mrp_resource_set_t *rset,
-                                  const char         *name,
-                                  bool                shared,
-                                  mrp_attr_t         *attrs,
-                                  bool                mandatory)
-{
-    uint32_t mask;
-    mrp_resource_t *res;
-
-    MRP_ASSERT(rset && name, "invalid argument");
-
-    if (!(res = mrp_resource_create(name, shared, attrs))) {
-        mrp_log_error("Can't add resource '%s' name to resource set %u",
-                      name, rset->id);
-        return -1;
-    }
-
-    mask = mrp_resource_get_mask(res);
-
-    rset->resource.mask.all       |= mask;
-    rset->resource.mask.mandatory |= mandatory ? mask : 0;
-    rset->resource.share          |= mrp_resource_is_shared(res);
-
-
-    mrp_list_append(&rset->resource.list, &res->list);
-
-    return 0;
-}
-
-mrp_attr_t *mrp_resource_set_read_attribute(mrp_resource_set_t *rset,
-                                            const char *resnam,
-                                            uint32_t attridx,
-                                            mrp_attr_t *buf)
-{
-    mrp_resource_t *res;
-
-    MRP_ASSERT(rset && resnam, "invalid argument");
-
-    if (!(res = find_resource(rset, resnam)))
-        return NULL;
-
-    return mrp_resource_read_attribute(res, attridx, buf);
-}
-
-mrp_attr_t *mrp_resource_set_read_all_attributes(mrp_resource_set_t *rset,
-                                                 const char *resnam,
-                                                 uint32_t buflen,
-                                                 mrp_attr_t *buf)
-{
-    mrp_resource_t *res;
-
-    MRP_ASSERT(rset && resnam, "invalid argument");
-
-    if (!(res = find_resource(rset, resnam)))
-        return NULL;
-
-    return mrp_resource_read_all_attributes(res, buflen, buf);
-}
-
-int mrp_resource_set_write_attributes(mrp_resource_set_t *rset,
-                                      const char *resnam,
-                                      mrp_attr_t *attrs)
-{
-    mrp_resource_t *res;
-
-    MRP_ASSERT(rset && resnam && attrs, "invalid argument");
-
-    if (!(res = find_resource(rset, resnam)))
-        return -1;
-
-    if (mrp_resource_write_attributes(res, attrs) < 0)
-        return -1;
-
-    return 0;
-}
-
-void mrp_resource_set_acquire(mrp_resource_set_t *rset, uint32_t reqid)
-{
-    MRP_ASSERT(rset, "invalid argument");
-
-    rset->state = mrp_resource_acquire;
-    rset->request.id = reqid;
-    rset->request.stamp = get_request_stamp();
-    
-    mrp_application_class_move_resource_set(rset);
-    mrp_resource_owner_update_zone(rset->zone, rset, reqid);
-}
-
-void mrp_resource_set_release(mrp_resource_set_t *rset, uint32_t reqid)
-{
-    MRP_ASSERT(rset, "invalid argument");
-
-    if (rset->state == mrp_resource_release) {
-        if (rset->event)
-            rset->event(reqid, rset, rset->user_data);
-    }
-    else {
-        rset->state = mrp_resource_release;
-        rset->request.id = reqid;
-        rset->request.stamp = get_request_stamp();
-
-        mrp_application_class_move_resource_set(rset);
-        mrp_resource_owner_update_zone(rset->zone, rset, reqid);
-    }
-}
-
-
-int mrp_resource_set_print(mrp_resource_set_t *rset, size_t indent,
-                           char *buf, int len)
-{
-#define PRINT(fmt, args...)  if (p<e) { p += snprintf(p, e-p, fmt , ##args); }
-
-    mrp_resource_t *res;
-    mrp_list_hook_t *resen, *n;
-    uint32_t mandatory;
-    char gap[] = "                         ";
-    char *p, *e;
-
-    MRP_ASSERT(rset && indent < sizeof(gap)-1 && buf && len > 0,
-               "invalid argument");
-
-    gap[indent] = '\0';
-
-    e = (p = buf) + len;
-
-    mandatory = rset->resource.mask.mandatory;
-
-    PRINT("%s%3u - 0x%02x/0x%02x 0x%02x/0x%02x 0x%08x %d %s %s\n",
-          gap, rset->id,
-          rset->resource.mask.all, mandatory,
-          rset->resource.mask.grant, rset->resource.mask.advice,
-          mrp_application_class_get_sorting_key(rset), rset->class.priority,
-          rset->resource.share ? "shared   ":"exclusive",
-          state_str(rset->state));
-
-    mrp_list_foreach(&rset->resource.list, resen, n) {
-        res = mrp_list_entry(resen, mrp_resource_t, list);
-        p  += mrp_resource_print(res, mandatory, indent+6, p, e-p);
-    }
-
-    return p - buf;
-
-#undef PRINT
-}
-
-static mrp_resource_t *find_resource(mrp_resource_set_t *rset,const char *name)
-{
-    mrp_list_hook_t *entry, *n;
-    mrp_resource_t *res;
-    mrp_resource_def_t *rdef;
-
-    MRP_ASSERT(rset && name, "invalid_argument");
-
-    mrp_list_foreach(&rset->resource.list, entry, n) {
-        res = mrp_list_entry(entry, mrp_resource_t, list);
-        rdef = res->def;
-
-        MRP_ASSERT(rdef, "confused with data structures");
-
-        if (!strcasecmp(name, rdef->name))
-            return res;
-    }
-
-    return NULL;
-}
-
-static uint32_t get_request_stamp(void)
-{
-    static uint32_t  stamp;
-
-    mrp_list_hook_t *entry, *n;
-    mrp_resource_set_t *rset;
-    uint32_t min;
-
-    if ((min = stamp) >= STAMP_MAX) {
-        mrp_log_info("rebasing resource set stamps");
-
-        mrp_list_foreach(&resource_set_list, entry, n) {
-            rset = mrp_list_entry(entry, mrp_resource_set_t, list);
-            if (rset->request.stamp < min)
-                min = rset->request.stamp;
-        }
-
-        stamp -= min;
-
-        mrp_list_foreach(&resource_set_list, entry, n) {
-            rset = mrp_list_entry(entry, mrp_resource_set_t, list);
-            rset->request.stamp -= min;
-        }
-    }
-
-    MRP_ASSERT(stamp < STAMP_MAX, "Request stamp overflow");
-
-    return stamp++;
-}
-
-static const char *state_str(mrp_resource_state_t state)
-{
-    switch(state) {
-    case mrp_resource_no_request:     return "no-request";
-    case mrp_resource_release:        return "release";
-    case mrp_resource_acquire:        return "acquire";
-    default:                          return "< ??? >";
-    }
-}
-
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/resource-set.h b/src/resource/resource-set.h
deleted file mode 100644 (file)
index afb45e5..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_SET_H__
-#define __MURPHY_RESOURCE_SET_H__
-
-#include <murphy/common/list.h>
-
-#include "data-types.h"
-
-
-
-struct mrp_resource_set_s {
-    mrp_list_hook_t                 list;
-    uint32_t                        id;
-    mrp_resource_state_t            state;
-    bool                            auto_release;
-    struct {
-        struct {
-            mrp_resource_mask_t all;
-            mrp_resource_mask_t mandatory;
-            mrp_resource_mask_t grant;
-            mrp_resource_mask_t advice;
-        } mask;
-        mrp_list_hook_t list;
-        bool share;
-    }                               resource;
-    struct {
-        mrp_list_hook_t list;
-        mrp_resource_client_t *ptr;
-        uint32_t reqno;
-    }                               client;
-    struct {
-        mrp_list_hook_t list;
-        mrp_application_class_t *ptr;
-        uint32_t priority;
-    }                               class;
-    uint32_t                        zone;
-    struct {
-        uint32_t id;
-        uint32_t stamp;
-    }                               request;
-    mrp_resource_event_cb_t         event;
-    void                           *user_data;
-};
-
-
-uint32_t            mrp_get_resource_set_count(void);
-int                 mrp_resource_set_print(mrp_resource_set_t *, size_t,
-                                           char *, int);
-
-
-#endif  /* __MURPHY_RESOURCE_SET_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/resource.c b/src/resource/resource.c
deleted file mode 100644 (file)
index 2d711fd..0000000
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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 <stdio.h>
-#include <string.h>
-
-#include <murphy/common/mm.h>
-#include <murphy/common/log.h>
-
-#include <murphy/resource/client-api.h>
-#include <murphy/resource/manager-api.h>
-
-#include "resource.h"
-#include "resource-owner.h"
-
-
-#define RESOURCE_MAX   (sizeof(mrp_resource_mask_t) * 8)
-#define ATTRIBUTE_MAX  (sizeof(mrp_attribute_mask_t) * 8)
-
-#define VALID_TYPE(t) ((t) == mqi_string  || \
-                       (t) == mqi_integer || \
-                       (t) == mqi_unsignd || \
-                       (t) == mqi_floating  )
-
-
-
-static uint32_t            resource_def_count;
-static mrp_resource_def_t *resource_def_table[RESOURCE_MAX];
-static MRP_LIST_HOOK(manager_list);
-
-static uint32_t add_resource_definition(const char *, bool, uint32_t,
-                                        mrp_resource_mgr_ftbl_t *, void *);
-
-#if 0
-static uint32_t find_resource_attribute_id(mrp_resource_t *, const char *);
-
-static mqi_data_type_t   get_resource_attribute_value_type(mrp_resource_t *,
-                                                           uint32_t);
-
-static mrp_attr_value_t *get_resource_attribute_default_value(mrp_resource_t*,
-                                                              uint32_t);
-#endif
-
-
-
-uint32_t mrp_resource_definition_create(const char *name, bool shareable,
-                                        mrp_attr_def_t *attrdefs,
-                                        mrp_resource_mgr_ftbl_t *manager,
-                                        void *mgrdata)
-{
-    uint32_t nattr;
-    uint32_t id;
-    mrp_resource_def_t *def;
-
-    MRP_ASSERT(name, "invalid argument");
-
-    if (mrp_resource_definition_find_by_name(name)) {
-        mrp_log_error("attmpt to redefine resource '%s'", name);
-        return MRP_RESOURCE_ID_INVALID;
-    }
-
-    for (nattr = 0;  attrdefs && attrdefs[nattr].name;  nattr++)
-        ;
-
-    id = add_resource_definition(name, shareable, nattr, manager, mgrdata);
-
-    if (id != MRP_RESOURCE_ID_INVALID) {
-        def = mrp_resource_definition_find_by_id(id);
-
-        MRP_ASSERT(def, "got confused with data structures");
-
-        if (mrp_attribute_copy_definitions(attrdefs, def->attrdefs) < 0)
-            return MRP_RESOURCE_ID_INVALID;
-
-        mrp_resource_owner_create_database_table(def);
-    }
-
-    return id;
-}
-
-uint32_t mrp_resource_definition_count(void)
-{
-    return resource_def_count;
-}
-
-mrp_resource_def_t *mrp_resource_definition_find_by_name(const char *name)
-{
-    mrp_resource_def_t *def;
-    uint32_t            i;
-
-    for (i = 0;  i < resource_def_count;  i++) {
-        def = resource_def_table[i];
-
-        if (def && !strcasecmp(name, def->name))
-            return def;
-    }
-
-    return NULL;
-}
-
-mrp_resource_def_t *mrp_resource_definition_find_by_id(uint32_t id)
-{
-    if (id < resource_def_count)
-        return resource_def_table[id];
-
-    return NULL;
-}
-
-mrp_resource_def_t *mrp_resource_definition_iterate_manager(void **cursor)
-{
-    mrp_list_hook_t *entry;
-
-    MRP_ASSERT(cursor, "invalid argument");
-
-    entry = (*cursor == NULL) ? manager_list.next : (mrp_list_hook_t *)*cursor;
-
-    if (entry == &manager_list)
-        return NULL;
-
-    *cursor = entry->next;
-
-    return mrp_list_entry(entry, mrp_resource_def_t, manager.list);
-}
-
-const char **mrp_resource_definition_get_all_names(uint32_t buflen,
-                                                   const char **buf)
-{
-    uint32_t i;
-
-    MRP_ASSERT(!buf || (buf && buflen > 1), "invlaid argument");
-
-    if (buf) {
-        if (buflen < resource_def_count + 1)
-            return NULL;
-    }
-    else {
-        buflen = resource_def_count + 1;
-        if (!(buf = mrp_allocz(sizeof(const char *) * buflen))) {
-            mrp_log_error("Memory alloc failure. Can't get resource names");
-            return NULL;
-        }
-    }
-
-    for (i = 0;  i < resource_def_count;  i++)
-        buf[i] = resource_def_table[i]->name;
-
-    buf[i] = NULL;
-
-    return buf;
-}
-
-mrp_attr_t *mrp_resource_definition_read_all_attributes(uint32_t resid,
-                                                        uint32_t buflen,
-                                                        mrp_attr_t *buf)
-{
-    mrp_resource_def_t *rdef   = mrp_resource_definition_find_by_id(resid);
-    mrp_attr_t         *retval;
-
-
-    if (!rdef)
-        retval = mrp_attribute_get_all_values(buflen, buf, 0, NULL, 0);
-    else {
-        retval = mrp_attribute_get_all_values(buflen, buf, rdef->nattr,
-                                              rdef->attrdefs, 0);
-    }
-
-    if (!retval) {
-        mrp_log_error("Memory alloc failure. Can't get all "
-                      "attributes of resource definition");
-    }
-
-    return retval;
-}
-
-
-
-mrp_resource_t *mrp_resource_create(const char *name,
-                                    bool        shared,
-                                    mrp_attr_t *attrs)
-{
-    mrp_resource_t *res = NULL;
-    mrp_resource_def_t *rdef;
-    size_t base_size;
-    size_t attr_size;
-    size_t total_size;
-    int sts;
-
-    MRP_ASSERT(name, "invalid argument");
-
-    if (!(rdef = mrp_resource_definition_find_by_name(name))) {
-        mrp_log_warning("Can't find resource definition '%s'. "
-                        "No resource created", name);
-    }
-    else {
-        base_size  = sizeof(mrp_resource_t);
-        attr_size  = sizeof(mrp_attr_value_t) * rdef->nattr;
-        total_size = base_size + attr_size;
-
-        if (!(res = mrp_allocz(total_size))) {
-            mrp_log_error("Memory alloc failure. Can't create "
-                          "resource '%s'", name);
-        }
-        else {
-            mrp_list_init(&res->list);
-
-            res->def = rdef;
-            res->shared = rdef->shareable ?  shared : false;
-
-            sts = mrp_attribute_set_values(attrs, rdef->nattr,
-                                           rdef->attrdefs, res->attrs);
-            if (sts < 0) {
-                mrp_log_error("Memory alloc failure. No '%s' "
-                              "resource created", name);
-                return NULL;
-            }
-        }
-    }
-
-    return res;
-}
-
-void mrp_resource_destroy(mrp_resource_t *res)
-{
-    mrp_resource_def_t *rdef;
-    mqi_data_type_t type;
-    uint32_t id;
-
-    if (res) {
-        rdef = res->def;
-
-        MRP_ASSERT(rdef, "invalid_argument");
-
-        mrp_list_delete(&res->list);
-
-        for (id = 0;  id < rdef->nattr;  id++) {
-            type = rdef->attrdefs[id].type;
-
-            if (type == mqi_string)
-                mrp_free((void *)res->attrs[id].string);
-        }
-
-        mrp_free(res);
-    }
-}
-
-uint32_t mrp_resource_get_id(mrp_resource_t *res)
-{
-    mrp_resource_def_t *def;
-
-    if (res) {
-        def = res->def;
-        MRP_ASSERT(def, "confused with internal data structures");
-        return def->id;
-    }
-
-    return MRP_RESOURCE_ID_INVALID;
-}
-
-const char *mrp_resource_get_name(mrp_resource_t *res)
-{
-    mrp_resource_def_t *def;
-
-    if (res) {
-        def = res->def;
-
-        MRP_ASSERT(def && def->name, "confused with internal data structures");
-
-        return def->name;
-    }
-
-    return "<unknown resource>";
-}
-
-mrp_resource_mask_t mrp_resource_get_mask(mrp_resource_t *res)
-{
-    mrp_resource_def_t *def;
-    mrp_resource_mask_t mask = 0;
-
-    if (res) {
-        def = res->def;
-
-        MRP_ASSERT(def, "confused with internal data structures");
-
-        mask = (mrp_resource_mask_t)1 << def->id;
-    }
-
-    return mask;
-}
-
-bool mrp_resource_is_shared(mrp_resource_t *res)
-{
-    if (res)
-        return res->shared;
-
-    return false;
-}
-
-mrp_attr_t *mrp_resource_read_attribute(mrp_resource_t *res,
-                                        uint32_t        idx,
-                                        mrp_attr_t     *value)
-{
-    mrp_attr_t *retval;
-    mrp_resource_def_t *rdef;
-
-    MRP_ASSERT(res, "invalid argument");
-
-    rdef = res->def;
-
-    MRP_ASSERT(rdef, "confused with data structures");
-
-    retval = mrp_attribute_get_value(idx, value, rdef->nattr,
-                                     rdef->attrdefs, res->attrs);
-
-    if (!retval) {
-        mrp_log_error("Memory alloc failure. Can't get "
-                      "resource '%s' attribute %u", rdef->name, idx);
-    }
-
-    return retval;
-}
-
-
-mrp_attr_t *mrp_resource_read_all_attributes(mrp_resource_t *res,
-                                             uint32_t nvalue,
-                                             mrp_attr_t *values)
-{
-    mrp_attr_t *retval;
-    mrp_resource_def_t *rdef;
-
-    MRP_ASSERT(res, "invalid argument");
-
-    rdef = res->def;
-
-    MRP_ASSERT(rdef, "confused with data structures");
-
-    retval = mrp_attribute_get_all_values(nvalue, values, rdef->nattr,
-                                          rdef->attrdefs, res->attrs);
-
-    if (!retval) {
-        mrp_log_error("Memory alloc failure. Can't get all "
-                      "attributes of resource '%s'", rdef->name);
-    }
-
-    return retval;
-}
-
-int mrp_resource_write_attributes(mrp_resource_t *res, mrp_attr_t *values)
-{
-    int sts;
-    mrp_resource_def_t *rdef;
-
-    MRP_ASSERT(res && values, "invalid argument");
-
-    rdef = res->def;
-
-    MRP_ASSERT(rdef, "confused with data structures");
-
-    sts = mrp_attribute_set_values(values, rdef->nattr,
-                                   rdef->attrdefs, res->attrs);
-
-    if (sts < 0) {
-        mrp_log_error("Memory alloc failure. Can't set attributes "
-                      "of resource '%s'", rdef->name);
-    }
-
-    return sts;
-}
-
-
-int mrp_resource_print(mrp_resource_t *res, uint32_t mandatory,
-                       size_t indent, char *buf, int len)
-{
-#define PRINT(fmt, args...)  if (p<e) { p += snprintf(p, e-p, fmt , ##args); }
-
-    mrp_resource_def_t *rdef;
-    char gap[] = "                         ";
-    char *p, *e;
-    uint32_t m;
-
-    MRP_ASSERT(res && indent < sizeof(gap)-1 && buf && len > 0,
-               "invalid argument");
-
-    rdef = res->def;
-
-    MRP_ASSERT(rdef, "Confused with data structures");
-
-    gap[indent] = '\0';
-
-    e = (p = buf) + len;
-    m = ((mrp_resource_mask_t)1 << rdef->id);
-
-    PRINT("%s%s: 0x%02x %s %s", gap, rdef->name, m,
-          (m & mandatory) ? "mandatory":"optional ",
-          res->shared ? "shared  ":"exlusive");
-
-    p += mrp_resource_attribute_print(res, p, e-p);
-
-    PRINT("\n");
-
-
-    return p - buf;
-
-#undef PRINT
-}
-
-int mrp_resource_attribute_print(mrp_resource_t *res, char *buf, int len)
-{
-    mrp_resource_def_t *rdef;
-
-    MRP_ASSERT(res && buf && len > 0, "invalid argument");
-
-    rdef = res->def;
-
-    MRP_ASSERT(rdef, "Confused with data structures");
-
-    return mrp_attribute_print(rdef->nattr,rdef->attrdefs,res->attrs, buf,len);
-}
-
-
-static uint32_t add_resource_definition(const char *name,
-                                        bool        shareable,
-                                        uint32_t    nattr,
-                                        mrp_resource_mgr_ftbl_t *mgrftbl,
-                                        void       *mgrdata)
-{
-    mrp_resource_def_t *def;
-    const char         *dup_name;
-    size_t              size;
-    uint32_t            id;
-
-    MRP_ASSERT(name && nattr < ATTRIBUTE_MAX, "invalid argument");
-
-    if (resource_def_count >= RESOURCE_MAX) {
-        mrp_log_error("Resource table overflow. Can't add resource '%s'",name);
-        return MRP_RESOURCE_ID_INVALID;
-    }
-
-    size = sizeof(mrp_resource_def_t) + sizeof(mrp_attr_def_t) * nattr;
-
-    if (!(def = mrp_allocz(size)) || !(dup_name = mrp_strdup(name))) {
-        mrp_log_error("Memory alloc failure. Can't add resource '%s'", name);
-        return MRP_RESOURCE_ID_INVALID;
-    }
-
-    id = resource_def_count++;
-
-    def->id        = id;
-    def->name      = dup_name;
-    def->shareable = shareable;
-    def->nattr     = nattr;
-
-    if (mgrftbl) {
-        def->manager.ftbl = mrp_alloc(sizeof(mrp_resource_mgr_ftbl_t));
-        def->manager.userdata = mgrdata;
-
-        if (def->manager.ftbl)
-            memcpy(def->manager.ftbl, mgrftbl,sizeof(mrp_resource_mgr_ftbl_t));
-        else {
-            mrp_log_error("Memory alloc failure. No manager for resource '%s'",
-                          name);
-        }
-    }
-
-    resource_def_table[id] = def;
-
-    if (!mgrftbl)
-        mrp_list_init(&def->manager.list);
-    else
-        mrp_list_append(&manager_list, &def->manager.list);
-
-    return id;
-}
-
-
-#if 0
-static uint32_t find_resource_attribute_id(mrp_resource_t *res,
-                                           const char *attrnam)
-{
-    mrp_resource_def_t *rdef;
-    mrp_attr_def_t *adef;
-    uint32_t id;
-
-    if (res && (rdef = res->def) && attrnam) {
-        for (id = 0;  id < rdef->nattr;  id++) {
-            adef = rdef->attrdefs + id;
-
-            if (!strcasecmp(attrnam, adef->name))
-                return id;
-        }
-    }
-
-    return MRP_RESOURCE_ID_INVALID;
-}
-
-static mqi_data_type_t
-get_resource_attribute_value_type(mrp_resource_t *res, uint32_t id)
-{
-    mrp_resource_def_t *rdef;
-
-    MRP_ASSERT(res, "invalid argument");
-
-    rdef = res->def;
-
-    MRP_ASSERT(rdef, "confused with data structures");
-    MRP_ASSERT(id < rdef->nattr, "invalid argument");
-
-    return rdef->attrdefs[id].type;
-}
-
-static mrp_attr_value_t *
-get_resource_attribute_default_value(mrp_resource_t *res, uint32_t id)
-{
-    mrp_resource_def_t *rdef;
-
-    MRP_ASSERT(res, "invalid argument");
-
-    rdef = res->def;
-
-    MRP_ASSERT(rdef, "confused with data structures");
-    MRP_ASSERT(id < rdef->nattr, "invalid argument");
-
-    return &rdef->attrdefs[id].value;
-}
-#endif
-
-
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/resource.h b/src/resource/resource.h
deleted file mode 100644 (file)
index e10713b..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_RESOURCE_H__
-#define __MURPHY_RESOURCE_H__
-
-#include <murphy/common/list.h>
-
-#include "attribute.h"
-
-
-struct mrp_resource_def_s {
-    uint32_t            id;
-    const char         *name;
-    bool                shareable;
-    struct {
-        mrp_list_hook_t list;
-        mrp_resource_mgr_ftbl_t *ftbl;
-        void *userdata;
-    }                   manager;
-    uint32_t            nattr;
-    mrp_attr_def_t      attrdefs[0];
-};
-
-struct mrp_resource_s {
-    mrp_list_hook_t     list;
-    mrp_resource_def_t *def;
-    bool                shared;
-    mrp_attr_value_t    attrs[0];
-};
-
-
-
-uint32_t            mrp_resource_definition_count(void);
-mrp_resource_def_t *mrp_resource_definition_find_by_name(const char *);
-mrp_resource_def_t *mrp_resource_definition_find_by_id(uint32_t);
-mrp_resource_def_t *mrp_resource_definition_iterate_manager(void **);
-
-
-mrp_resource_t     *mrp_resource_create(const char *, bool, mrp_attr_t *);
-void                mrp_resource_destroy(mrp_resource_t *);
-
-int                 mrp_resource_print(mrp_resource_t*, uint32_t,
-                                       size_t, char *, int);
-int                 mrp_resource_attribute_print(mrp_resource_t *, char *,int);
-
-
-#endif  /* __MURPHY_RESOURCE_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/zone.c b/src/resource/zone.c
deleted file mode 100644 (file)
index c95a3e4..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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 <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <murphy/common/mm.h>
-#include <murphy/common/log.h>
-
-#include <murphy/resource/manager-api.h>
-#include <murphy/resource/client-api.h>
-#include <murphy/resource/config-api.h>
-
-#include <murphy-db/mqi.h>
-
-#include "zone.h"
-
-
-#define ATTRIBUTE_MAX  32
-#define NAME_LENGTH    24
-
-#define VALID_TYPE(t) ((t) == mqi_string  || \
-                       (t) == mqi_integer || \
-                       (t) == mqi_unsignd || \
-                       (t) == mqi_floating  )
-
-
-#define ZONE_ID_IDX          0
-#define ZONE_NAME_IDX        1
-#define FIRST_ATTRIBUTE_IDX  2
-
-typedef struct {
-    uint32_t          zone_id;
-    const char       *zone_name;
-    mrp_attr_value_t  attrs[MQI_COLUMN_MAX];
-} zone_row_t;
-
-static mrp_zone_def_t *zone_def;
-static uint32_t        zone_count;
-static mrp_zone_t     *zone_table[MRP_ZONE_MAX];
-static mqi_handle_t    db_table = MQI_HANDLE_INVALID;
-
-static mqi_handle_t create_zone_table(mrp_zone_def_t *);
-static void insert_into_zone_table(mrp_zone_t *);
-static void set_attr_descriptors(mqi_column_desc_t *);
-
-
-int mrp_zone_definition_create(mrp_attr_def_t *attrdefs)
-{
-    uint32_t nattr;
-    size_t size;
-    mrp_zone_def_t *def;
-
-    for (nattr = 0;  attrdefs && attrdefs[nattr].name;  nattr++)
-        ;
-
-    size = sizeof(mrp_zone_def_t) + sizeof(mrp_attr_def_t) * nattr;
-
-    if (!(def = mrp_allocz(size))) {
-        mrp_log_error("Memory alloc failure. Can't create zone definition");
-        return -1;
-    }
-
-    def->nattr = nattr;
-    zone_def = def;
-
-    if (mrp_attribute_copy_definitions(attrdefs, def->attrdefs) < 0)
-        return -1;
-
-    db_table = create_zone_table(def);
-
-    return 0;
-}
-
-uint32_t mrp_zone_count(void)
-{
-    return zone_count;
-}
-
-uint32_t mrp_zone_create(const char *name, mrp_attr_t *attrs)
-{
-    size_t size;
-    mrp_zone_t *zone;
-    const char *dup_name;
-    int sts;
-
-    MRP_ASSERT(name, "invalid argument");
-
-    if (!zone_def) {
-        mrp_log_error("Zone definition must preceed zone creation. "
-                      "can't create zone '%s'", name);
-        return MRP_ZONE_ID_INVALID;
-    }
-
-    if (zone_count >= MRP_ZONE_MAX) {
-        mrp_log_error("Zone table overflow. Can't create zone '%s'", name);
-        return MRP_ZONE_ID_INVALID;
-    }
-
-    size = sizeof(mrp_zone_t) + sizeof(mrp_attr_def_t) * zone_def->nattr;
-
-    if (!(zone = mrp_allocz(size)) || !(dup_name = mrp_strdup(name))) {
-        mrp_log_error("Memory alloc failure. Can't create zone '%s'", name);
-        return MRP_ZONE_ID_INVALID;
-    }
-
-
-    zone->id   = zone_count++;
-    zone->name = dup_name;
-
-    sts = mrp_attribute_set_values(attrs, zone_def->nattr,
-                                   zone_def->attrdefs, zone->attrs);
-    if (sts < 0) {
-        mrp_log_error("Memory alloc failure. Can't create zone '%s'", name);
-        return MRP_ZONE_ID_INVALID;
-    }
-
-    insert_into_zone_table(zone);
-
-    zone_table[zone->id] = zone;
-
-    return zone->id;
-}
-
-mrp_zone_t *mrp_zone_find_by_id(uint32_t id)
-{
-    if (id < zone_count)
-        return zone_table[id];
-
-    return NULL;
-}
-
-mrp_zone_t *mrp_zone_find_by_name(const char *name)
-{
-    mrp_zone_t *zone;
-    uint32_t id;
-
-    for (id = 0;  id < zone_count;  id++) {
-        zone = zone_table[id];
-
-        if (!strcasecmp(name, zone->name))
-            return zone;
-    }
-
-    return NULL;
-}
-
-uint32_t mrp_zone_get_id(mrp_zone_t *zone)
-{
-    if (!zone)
-        return MRP_ZONE_ID_INVALID;
-
-    return zone->id;
-}
-
-const char *mrp_zone_get_name(mrp_zone_t *zone)
-{
-    if (!zone | !zone->name)
-        return "<unknown zone>";
-
-    return zone->name;
-}
-
-const char **mrp_zone_get_all_names(uint32_t buflen, const char **buf)
-{
-    uint32_t i;
-
-    MRP_ASSERT(!buf || (buf && buflen > 1), "invlaid argument");
-
-    if (buf) {
-        if (buflen < zone_count + 1)
-            return NULL;
-    }
-    else {
-        buflen = zone_count + 1;
-        if (!(buf = mrp_allocz(sizeof(const char *) * buflen))) {
-            mrp_log_error("Memory alloc failure. Can't get all zone names");
-            return NULL;
-        }
-    }
-
-    for (i = 0;  i < zone_count;  i++)
-        buf[i] = zone_table[i]->name;
-
-    buf[i] = NULL;
-
-    return buf;
-}
-
-
-mrp_attr_t *mrp_zone_read_attribute(mrp_zone_t *zone,
-                                    uint32_t    idx,
-                                    mrp_attr_t *value)
-{
-    mrp_attr_t *retval;
-
-    MRP_ASSERT(zone, "invalid argument");
-    MRP_ASSERT(zone_def, "no zone definition");
-
-    retval = mrp_attribute_get_value(idx, value, zone_def->nattr,
-                                     zone_def->attrdefs, zone->attrs);
-
-    if (!retval) {
-        mrp_log_error("Memory alloc failure. Can't get "
-                      "zone '%s' attribute %u", zone->name, idx);
-    }
-
-    return retval;
-}
-
-mrp_attr_t *mrp_zone_read_all_attributes(mrp_zone_t *zone,
-                                         uint32_t nvalue,
-                                         mrp_attr_t *values)
-{
-    mrp_attr_t *retval;
-
-    MRP_ASSERT(zone, "invalid argument");
-
-    retval = mrp_attribute_get_all_values(nvalue, values, zone_def->nattr,
-                                          zone_def->attrdefs, zone->attrs);
-
-    if (!retval) {
-        mrp_log_error("Memory alloc failure. Can't get all"
-                      "attributes of zone '%s'", zone->name);
-    }
-
-    return retval;
-}
-
-int mrp_zone_attribute_print(mrp_zone_t *zone, char *buf, int len)
-{
-    MRP_ASSERT(zone && buf && len > 0, "invalid argument");
-
-    return mrp_attribute_print(zone_def->nattr, zone_def->attrdefs,
-                               zone->attrs, buf,len);
-}
-
-
-static mqi_handle_t create_zone_table(mrp_zone_def_t *zdef)
-{
-    MQI_COLUMN_DEFINITION_LIST(base_coldefs,
-        MQI_COLUMN_DEFINITION( "zone_id"       , MQI_UNSIGNED             ),
-        MQI_COLUMN_DEFINITION( "zone_name"     , MQI_VARCHAR(NAME_LENGTH) )
-    );
-
-    MQI_INDEX_DEFINITION(indexdef,
-        MQI_INDEX_COLUMN("zone_id")
-    );
-
-    char *name;
-    mqi_column_def_t coldefs[MQI_COLUMN_MAX + 1];
-    mqi_column_def_t *col;
-    mrp_attr_def_t *atd;
-    mqi_handle_t table;
-    size_t i,j;
-
-    MRP_ASSERT(zdef, "invalid argument");
-    MRP_ASSERT(zdef->nattr < MQI_COLUMN_MAX, "too many zone attributes");
-    MRP_ASSERT(db_table == MQI_HANDLE_INVALID,
-               "multiple definition of zone data table");
-
-    mqi_open();
-
-    name = "zones";
-
-    j = MQI_DIMENSION(base_coldefs) - 1;
-    memcpy(coldefs, base_coldefs, j * sizeof(mqi_column_def_t));
-
-    for (i = 0;  i < zdef->nattr && j < MQI_COLUMN_MAX;  i++, j++) {
-        col = coldefs + j;
-        atd = zdef->attrdefs + i;
-
-        col->name   = atd->name;
-        col->type   = atd->type;
-        col->length = (col->type == mqi_string) ? NAME_LENGTH : 0;
-        col->flags  = 0;
-    }
-
-    memset(coldefs + j, 0, sizeof(mqi_column_def_t));
-
-    table = MQI_CREATE_TABLE(name, MQI_TEMPORARY, coldefs, indexdef);
-
-    if (table == MQI_HANDLE_INVALID)
-        mrp_log_error("Can't create table '%s': %s", name, strerror(errno));
-
-    return table;
-}
-
-static void insert_into_zone_table(mrp_zone_t *zone)
-{
-    uint32_t i;
-    int n;
-    zone_row_t row;
-    zone_row_t *rows[2];
-    mqi_column_desc_t cdsc[FIRST_ATTRIBUTE_IDX + MQI_COLUMN_MAX + 1];
-
-    MRP_ASSERT(zone_def, "no zone definition");
-    MRP_ASSERT(db_table != MQI_HANDLE_INVALID, "no zone table");
-    MRP_ASSERT(FIRST_ATTRIBUTE_IDX + zone_def->nattr <= MQI_COLUMN_MAX,
-               "too many attributes for a table");
-
-    row.zone_id    = zone->id;
-    row.zone_name  = zone->name;
-    memcpy(row.attrs, zone->attrs, zone_def->nattr * sizeof(mrp_attr_value_t));
-
-    i = 0;
-    cdsc[i].cindex = ZONE_ID_IDX;
-    cdsc[i].offset = MQI_OFFSET(zone_row_t, zone_id);
-
-    i++;
-    cdsc[i].cindex = ZONE_NAME_IDX;
-    cdsc[i].offset = MQI_OFFSET(zone_row_t, zone_name);
-
-    set_attr_descriptors(cdsc + (i+1));
-
-    rows[0] = &row;
-    rows[1] = NULL;
-
-    if ((n = MQI_INSERT_INTO(db_table, cdsc, rows)) != 1)
-        mrp_log_error("can't insert row into zone table");
-}
-
-static void set_attr_descriptors(mqi_column_desc_t *cdsc)
-{
-    uint32_t i,j;
-    int o;
-
-    for (i = j = 0;  j < zone_def->nattr;  j++) {
-        switch (zone_def->attrdefs[j].type) {
-        case mqi_string:   o = MQI_OFFSET(zone_row_t,attrs[j].string);   break;
-        case mqi_integer:  o = MQI_OFFSET(zone_row_t,attrs[j].integer);  break;
-        case mqi_unsignd:  o = MQI_OFFSET(zone_row_t,attrs[j].unsignd);  break;
-        case mqi_floating: o = MQI_OFFSET(zone_row_t,attrs[j].floating); break;
-        default:           /* skip this */                            continue;
-        }
-
-        cdsc[i].cindex = FIRST_ATTRIBUTE_IDX + j;
-        cdsc[i].offset = o;
-        i++;
-    }
-
-    cdsc[i].cindex = -1;
-    cdsc[i].offset =  1;
-}
-
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */
diff --git a/src/resource/zone.h b/src/resource/zone.h
deleted file mode 100644 (file)
index bde9cf5..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * 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.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 COPYRIGHT
- * OWNER OR CONTRIBUTORS 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.
- */
-
-#ifndef __MURPHY_ZONE_H__
-#define __MURPHY_ZONE_H__
-
-#include "attribute.h"
-
-struct mrp_zone_def_s {
-    uint32_t         nattr;
-    mrp_attr_def_t   attrdefs[0];
-};
-
-struct mrp_zone_s {
-    uint32_t          id;
-    const char       *name;
-    mrp_attr_value_t  attrs[0];
-};
-
-
-uint32_t mrp_zone_count(void);
-mrp_zone_t *mrp_zone_find_by_id(uint32_t);
-mrp_zone_t *mrp_zone_find_by_name(const char *);
-
-int mrp_zone_attribute_print(mrp_zone_t *, char *, int);
-
-
-#endif  /* __MURPHY_ZONE_H__ */
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
- */