Пример #1
0
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));
                }
            }
        }
    }
}
Пример #2
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;
}
Пример #3
0
static const char *
u_usrClockConfigElementDataString (
    const cf_element element,
    const char *defaultValue)
{
    c_iter children;
    const char *data = defaultValue;
    c_value dataValue;
    c_ulong i;
    cf_node node;

    assert(element != NULL);

    children = cf_elementGetChilds (element);

    if (children) {
        for (i = 0; i < c_iterLength (children); i++) {
            node = c_iterObject (children, i);

            if (cf_nodeKind (node) == CF_DATA) {
                dataValue = cf_dataValue (cf_data(node));

                if (dataValue.kind == V_STRING) {
                    data = dataValue.is.String;
                }
            }
        }
        c_iterFree(children);
    }
    return data;
}
Пример #4
0
c_bool
u_userGetSPBFromEnvUri() {
    char *uri = NULL;
    c_bool spb = FALSE;
    cf_element platformConfig = NULL;
    cf_element dc = NULL;
    cf_element elemName = NULL;
    cf_element singleProcess = NULL;
    cf_data elementData = NULL;
    cf_data dataName;
    c_value value;
    cfgprs_status r;

    uri = os_getenv ("OSPL_URI");
    r = cfg_parse_ospl (uri, &platformConfig);
    if (r == CFGPRS_OK)
    {
       dc = cf_element (cf_elementChild (platformConfig, CFG_DOMAIN));
       if (dc) {
      singleProcess = cf_element(cf_elementChild(dc, CFG_SINGLEPROCESS));
      if (singleProcess != NULL) {
         elementData = cf_data(cf_elementChild(singleProcess, "#text"));
         if (elementData != NULL) {
            value = cf_dataValue(elementData);
        if (os_strncasecmp(value.is.String, "TRUE", 4) == 0) {
           /* A SingleProcess value of True implies that Heap is to be used */
          spb = TRUE;
        }
         }
      }
       }
    }
    return spb;

}
Пример #5
0
int
u_userGetDomainIdFromEnvUri() {
    char *uri = NULL;
    int domainId = 0;
    cf_element platformConfig = NULL;
    cf_element dc = NULL;
    cf_element elemName = NULL;
    cf_data dataName;
    c_value value;
    cfgprs_status r;

    uri = os_getenv ("OSPL_URI");
    r = cfg_parse_ospl (uri, &platformConfig);
    if (r == CFGPRS_OK)
    {
       dc = cf_element (cf_elementChild (platformConfig, CFG_DOMAIN));
       if (dc) {
      elemName = cf_element(cf_elementChild(dc, CFG_ID));
      if (elemName) {
         dataName = cf_data(cf_elementChild(elemName, "#text"));
         if (dataName != NULL) {
            value = cf_dataValue(dataName);
        sscanf(value.is.String, "%d", &domainId);
         }
      }
       }
    }
    return domainId;

}
Пример #6
0
static char *
findDomain(
    cf_element platformConfig,
    cf_element *domain)
{
    char *domainName = NULL;
    cf_element dc = NULL;
    cf_element elemName = NULL;
    cf_data dataName;
    c_value value;

    dc = cf_element (cf_elementChild (platformConfig, CFG_DOMAIN));
    if (dc) {
        elemName = cf_element(cf_elementChild(dc, CFG_NAME));
        if (elemName) {
            dataName = cf_data(cf_elementChild(elemName, "#text"));
            if (dataName) {
            value = cf_dataValue(dataName);
            domainName = value.is.String;
                *domain = dc;
            }
    }
    }
    return domainName;
}
Пример #7
0
static c_iter
getCPUAffinities(cf_element root)
{
   c_iter affinities = NULL;
   cf_element domain;
   cf_element cpuAffinity;
   cf_data data;

   assert(root);

   if (root
       && (domain = (cf_element)cf_elementChild(root, "Domain")) )
   {
      cpuAffinity = cf_element(cf_elementChild(domain, CFG_CPUAFFINITY));
      if (cpuAffinity != NULL)
      {
         data = cf_data(cf_elementChild(cpuAffinity, "#text"));
         if (data != NULL)
         {
            char *saveptr;
            char *next;
            char *value;
            value = cf_dataValue(data).is.String;
            next = os_strtok_r(value, ",", &saveptr);
            while ( next != NULL )
            {
               signed int corenum;
               struct cpuAffinity *newCpuAffinity;
               sscanf( next, "%d", &corenum);
               newCpuAffinity = (struct cpuAffinity *)malloc (sizeof(struct cpuAffinity));
               newCpuAffinity->cpuNumber = corenum;
               affinities = c_iterInsert(affinities, newCpuAffinity);
               next = os_strtok_r(NULL, ",", &saveptr);
            }
         }
      }
   }
   return affinities;
}
Пример #8
0
char *
u_userGetDomainNameFromEnvUri() {
    char *uri = NULL;
    char * domainName = NULL;
    cf_element platformConfig = NULL;
    cf_element dc = NULL;
    cf_element elemName = NULL;
    cf_data dataName;
    c_value value;
    cfgprs_status r;

    uri = os_getenv ("OSPL_URI");
    if ( uri != NULL )
    {
       domainName = os_strdup(uri);
    }
    else
    {
       r = cfg_parse_ospl (uri, &platformConfig);
       if (r == CFGPRS_OK)
       {
          dc = cf_element (cf_elementChild (platformConfig, CFG_DOMAIN));
          if (dc)
          {
             elemName = cf_element(cf_elementChild(dc, CFG_NAME));
             if (elemName)
             {
                dataName = cf_data(cf_elementChild(elemName, "#text"));
                if (dataName != NULL)
                {
                   value = cf_dataValue(dataName);
                   domainName = os_strdup(value.is.String);
                }
             }
          }
       }
    }
    return domainName;
}
Пример #9
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;
}
Пример #10
0
    }
    c_iterFree(attributes);
    return result;
}

static qp_result
processElementData(
        cf_data data,
        C_STRUCT(qp_parseContext) ctx)
{
    qp_result result;
    char first;

    assert(data);

    first = cf_dataValue(data).is.String[0];

    if(strcmp(cf_node(data)->name, "#text") == 0 &&
       (first == '\0'  || first == '\n' || first == '<' || first == ' '))
    {
        /* Skip comments */
        result = QP_RESULT_OK;
    } else {
        c_value xmlValue = cf_dataValue(data);
        c_value qosValue = c_fieldValue(ctx.currentField, ctx.qosSample);
        const char *actualValue = substituteConstants(xmlValue.is.String);

        if (c_imageValue(actualValue, &qosValue, ctx.currentFieldType)) {
            c_fieldAssign(ctx.currentField, ctx.qosSample, qosValue);
            result = QP_RESULT_OK;
        } else {