예제 #1
0
static c_iter
getKnownServices(cf_element root)
{
   c_iter services;
   cf_element domain;
   cf_element el;
   cf_element cmd;
   cf_data data;
   c_iter children;
   cf_attribute attr;
   struct serviceInfo *si;

   assert(root);

   services = NULL;
   if (root
       && (domain = (cf_element)cf_elementChild(root, "Domain")) )
   {
      children = cf_elementGetChilds(domain);
      while ( (el = c_iterTakeFirst(children)) != NULL)
      {
         if ( strcmp(cf_nodeGetName(cf_node(el)), "Service") == 0
              && (cmd = (cf_element)cf_elementChild(el, "Command"))
              && (data = cf_data(cf_elementChild(cmd, "#text")))
              && (si = os_malloc(sizeof(struct serviceInfo))))
         {

            si->command = cf_dataValue(data).is.String;

            attr = cf_elementAttribute(el, "name");
            if (attr)
            {
               si->name = cf_attributeValue(attr).is.String;
            }
            else
            {
               si->name = si->command;
            }

            if (!si->name || !si->command)
            {
               /* detected an invalid service configuration, report and skip */
               fprintf(stderr,
                       "Warning: detected invalid 'Service'"
                       " element (name = %s; command = %s) -> skip\n",
                       (si->name?si->name:"<null>"),
                       (si->command?si->command:"<null>"));
               os_free(si);
               si = NULL;
            }
            else
            {
               services = c_iterInsert(services, si);
            }
         }
      }
      c_iterFree(children);
   }
   return services;
}
예제 #2
0
static os_boolean
u_usrClockConfigElementAttributeStringToBoolean (
    const cf_element element,
    const char *attribName,
    os_boolean defaultValue)
{
    os_boolean value = defaultValue;
    const char *data = NULL;
    cf_attribute attrib;
    c_value attribValue;

    assert(element != NULL);

    attrib = cf_elementAttribute (element, attribName);
    if (attrib) {
        attribValue = cf_attributeValue (attrib);
        if (attribValue.kind == V_STRING) {
            data = attribValue.is.String;

            if (strcmp(data, "true") == 0) {
                value = OS_TRUE;
            } else if (strcmp(data, "false") == 0) {
                value = OS_FALSE;
            }
        }
    }

    return value;
}
예제 #3
0
파일: ospl.c 프로젝트: xrl/opensplice_dds
static void
findServiceTerminatePeriod(
    cf_element domain,
    os_time *serviceTerminatePeriod)
{
    cf_element elem;
    cf_attribute attr;
    cf_data data;
    c_value value;
    float offset, update_factor, expiry_time;

    /* Spliced uses 4 seconds by default or a value defined in the configuration file. */
    /* But the timing in ospl starts earlier. Therefore, increase the period in ospl   */
    /* with an additional 4 seconds such that it is larger than that in spliced. */

    offset = 4.0;
    (*serviceTerminatePeriod).tv_sec = offset + 4;
    (*serviceTerminatePeriod).tv_nsec = 0;

    if (domain != NULL) {
        elem = cf_element(cf_elementChild(domain, CFG_LEASE));
        if (elem) {
            elem = cf_element(cf_elementChild(elem, CFG_EXPIRYTIME));
            if (elem) {
                data = cf_data(cf_elementChild(elem, "#text"));
                if (data) {
                    value = cf_dataValue(data);
                    expiry_time = atof(value.is.String);
                }
                attr = cf_attribute(cf_elementAttribute(elem,"update_factor"));
                if (attr) {
                    value = cf_attributeValue(attr);
                    update_factor = atof(value.is.String);
                    offset += (expiry_time * update_factor);
                }
            }
        }
        elem = cf_element(cf_elementChild(domain, CFG_TERMPERIOD));
        if (elem) {
            data = cf_data(cf_elementChild(elem, "#text"));
            if (data) {
                value = cf_dataValue(data);
                /* dds2164: if '0' is defined, override any wait times, including
                 * the 4 second offset defined above.
                 */
                if(0 == atof(value.is.String))
                {
                    (*serviceTerminatePeriod).tv_sec = 0;
                    (*serviceTerminatePeriod).tv_nsec = 0;
                } else
                {
                    *serviceTerminatePeriod = os_realToTime(offset + atof(value.is.String));
                }
            }
        }
    }
}
예제 #4
0
static c_iter
getKnownApplications(cf_element root)
{
   c_iter apps;
   cf_element domain;
   cf_element el;
   cf_element cmd;
   cf_element lib;
   cf_data data;
   c_iter children;
   cf_attribute attr;
   struct applicationInfo *ai;

   assert(root);

   apps = NULL;
   if (root
       && (domain = (cf_element)cf_elementChild(root, "Domain")) )
   {
      children = cf_elementGetChilds(domain);
      while ( (el = c_iterTakeFirst(children)) != NULL)
      {
         if ( strcmp(cf_nodeGetName(cf_node(el)), "Application") == 0
              && (cmd = (cf_element)cf_elementChild(el, "Command"))
              && (data = cf_data(cf_elementChild(cmd, "#text")))
              && (ai = os_malloc(sizeof(struct applicationInfo))))
         {

            ai->command = cf_dataValue(data).is.String;

            attr = cf_elementAttribute(el, "name");
            if (attr)
            {
               ai->name = cf_attributeValue(attr).is.String;
            }
            else
            {
               ai->name = ai->command;
            }

            if ( (lib = (cf_element)cf_elementChild(el, "Library"))
                 && (data = cf_data(cf_elementChild(lib, "#text"))) )
            {
               ai->libname = cf_dataValue(data).is.String;
            }
            else
            {
               ai->libname = ai->command;
            }

            if (!ai->name || !ai->command)
            {
               /* detected an invalid application configuration, report and skip */
               fprintf(stderr,
                       "Warning: detected invalid 'Application'"
                       " element (name = %s; command = %s) -> skip\n",
                       (ai->name?ai->name:"<null>"),
                       (ai->command?ai->command:"<null>"));
               os_free(ai);
               ai = NULL;
            }
            else
            {
               apps = c_iterInsert(apps, ai);
            }
         }
      }
      c_iterFree(children);
   }
   return apps;
}