[Libvirt-cim] [PATCH] Make the EO parser not depend on root/ibmsd namespace

Dan Smith danms at us.ibm.com
Mon Nov 12 18:03:26 UTC 2007


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1194894184 28800
# Node ID 6f09834081cf603e73b82376f738e4384206ffc9
# Parent  cbed0b1c5f006d83a0a3a12d4f379a5a0173a31e
Make the EO parser not depend on root/ibmsd namespace

This EO parser needs some serious work.  It's not even remotely thread-safe
and it's pretty crusty.  This doesn't make it any less thread safe than
it already was, and it makes us not break things that depend on EO parsing.
I'll take a TODO to fix this up a bit sometime in the future.

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r cbed0b1c5f00 -r 6f09834081cf eo_parser.c
--- a/eo_parser.c	Fri Nov 09 15:38:44 2007 -0800
+++ b/eo_parser.c	Mon Nov 12 11:03:04 2007 -0800
@@ -35,7 +35,7 @@
 #define TEMPLATE "/tmp/tmp_eo_parse.XXXXXX"
 
 void eo_parse_restart(FILE *);
-int eo_parse_parseinstance(const CMPIBroker *, CMPIInstance **);
+int eo_parse_parseinstance(const CMPIBroker *, CMPIInstance **, const char *ns);
 
 static int write_temp(char *eo)
 {
@@ -64,6 +64,7 @@ static int write_temp(char *eo)
 
 int cu_parse_embedded_instance(const char *eo,
                                const CMPIBroker *broker,
+                               const char *ns,
                                CMPIInstance **instance)
 {
         int ret;
@@ -77,7 +78,7 @@ int cu_parse_embedded_instance(const cha
 
         fp = fdopen(fd, "r");
         eo_parse_restart(fp);
-        ret = eo_parse_parseinstance(broker, instance);
+        ret = eo_parse_parseinstance(broker, instance, ns);
 
         close(fd);
 #else
diff -r cbed0b1c5f00 -r 6f09834081cf eo_util_parser.y
--- a/eo_util_parser.y	Fri Nov 09 15:38:44 2007 -0800
+++ b/eo_util_parser.y	Mon Nov 12 11:03:04 2007 -0800
@@ -22,8 +22,9 @@ void eo_parse_error(char *);
 #define RC_EOF EOF
 
 /* DEFINE ANY GLOBAL VARS HERE */
-static CMPIBroker * _BROKER;
+static const CMPIBroker * _BROKER;
 static CMPIInstance ** _INSTANCE;
+static const char * _NAMESPACE;
 
 #ifdef EODEBUG
 #define EOTRACE(fmt, arg...) fprintf(stderr, fmt, ##arg)
@@ -31,7 +32,9 @@ static CMPIInstance ** _INSTANCE;
 #define EOTRACE(fmt, arg...)
 #endif
 
-int eo_parse_parseinstance(CMPIBroker *broker, CMPIInstance **instance);
+int eo_parse_parseinstance(const CMPIBroker *broker,
+			   CMPIInstance **instance,
+			   const char *ns);
 
 %}
 
@@ -64,7 +67,7 @@ instance:	/* empty */
 			EOTRACE("classname = %s\n",$3);
 			CMPIObjectPath *op;
 			op = CMNewObjectPath(_BROKER,
-					     "root/ibmsd",
+					     _NAMESPACE,
 					     $3,
 					     NULL);
 			*_INSTANCE = CMNewInstance(_BROKER,
@@ -125,10 +128,13 @@ property:	PROPERTYNAME '=' STRING ';'
 
 /* USER SUBROUTINE SECTION */
 
-int eo_parse_parseinstance(CMPIBroker *broker, CMPIInstance **instance)
+int eo_parse_parseinstance(const CMPIBroker *broker,
+			   CMPIInstance **instance,
+			   const char *ns)
 {
    _BROKER = broker;
    _INSTANCE = instance;
+   _NAMESPACE = ns;
 
    /* Parse the next instance */
    return(eo_parse_parse());
diff -r cbed0b1c5f00 -r 6f09834081cf libcmpiutil.h
--- a/libcmpiutil.h	Fri Nov 09 15:38:44 2007 -0800
+++ b/libcmpiutil.h	Mon Nov 12 11:03:04 2007 -0800
@@ -277,12 +277,14 @@ CMPIType cu_arg_type(const CMPIArgs *arg
  *
  * @param eo The embedded instance string
  * @param broker A pointer to the current broker
+ * @param ns The namespace for the new instance
  * @param instance A pointer to an instance pointer to hold the result
  * @returns nonzero on success
  *
  */
 int cu_parse_embedded_instance(const char *eo,
                                const CMPIBroker *broker,
+                               const char *ns,
                                CMPIInstance **instance);
 
 /**




More information about the Libvirt-cim mailing list