예제 #1
0
static void
s_configurationValueFloat(
    s_configuration configuration,
    u_cfElement     element,
    const c_char    *tag,
    void            (* const setAction)(s_configuration config, c_float floatValue))
{
    c_iter   iter;
    u_cfData data;
    c_bool   found;
    c_float  floatValue;

    iter = u_cfElementXPath(element, tag);
    data = u_cfData(c_iterTakeFirst(iter));

    while (data != NULL) {
        found = u_cfDataFloatValue(data, &floatValue);

        if (found == TRUE) {
            setAction(configuration, floatValue);
        }
        u_cfDataFree(data);
        data = u_cfData(c_iterTakeFirst(iter));
    }
    c_iterFree(iter);
}
예제 #2
0
static void
s_configurationValueString(
    s_configuration configuration,
    u_cfElement     element,
    const char      *tag,
    void            (* const setAction)(s_configuration config, const c_char * str) )
{
    c_iter   iter;
    u_cfData data;
    c_bool   found;
    c_char *   str;

    iter = u_cfElementXPath(element, tag);
    data = u_cfData(c_iterTakeFirst(iter));

    while (data) {
        found = u_cfDataStringValue(data, &str);
        /* QAC EXPECT 2100; */
        if (found == TRUE) {
            setAction(configuration, str);
            os_free(str);
        }
        u_cfDataFree(data);
        data = u_cfData(c_iterTakeFirst(iter));
    }
    c_iterFree(iter);
}
예제 #3
0
static void
s_configurationValueULong(
    s_configuration configuration,
    u_cfElement     element,
    const char      *tag,
    void            (* const setAction)(s_configuration config, c_ulong longValue))
{
    c_iter   iter;
    u_cfData data;
    c_long   longValue;
    c_ulong  ulongValue;
    c_bool   found;

    iter = u_cfElementXPath(element, tag);
    data = u_cfData(c_iterTakeFirst(iter));
    while (data != NULL) {
        found = u_cfDataLongValue(data, &longValue);
        /* QAC EXPECT 2100; */
        if (found == TRUE) {
            if (longValue < 0) {
                longValue = -longValue;
                if (longValue < 0) {
                    longValue++;
                    longValue = -longValue;
                }
            }
            ulongValue = (c_ulong)longValue;
            setAction(configuration, ulongValue);
        }
        u_cfDataFree(data);
        data = u_cfData(c_iterTakeFirst(iter));
    }
    c_iterFree(iter);
}
예제 #4
0
static void
s_configurationValueSize(
    s_configuration configuration,
    u_cfElement     element,
    const char      *tag,
    void            (* const setAction)(s_configuration config, c_ulong ulongValue))
{
    c_iter   iter;
    u_cfData data;
    c_ulong  ulongValue;
    c_bool   found;

    iter = u_cfElementXPath(element, tag);
    data = u_cfData(c_iterTakeFirst(iter));
    while (data != NULL) {
        found = u_cfDataSizeValue(data, &ulongValue);
        /* QAC EXPECT 2100; */
        if (found == TRUE) {
            setAction(configuration, ulongValue);
        }
        u_cfDataFree(data);
        data = u_cfData(c_iterTakeFirst(iter));
    }
    c_iterFree(iter);
}
예제 #5
0
/**************************************************************
 * Private functions
 **************************************************************/
static c_bool
cfgGetCommand(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int      iterLength;
    c_bool r;
    u_cfData d;

    r = TRUE;

    iter = u_cfElementXPath(info, "Command/#text");
    iterLength = c_iterLength(iter);
    d = u_cfData(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfDataStringValue(d, &si->command);
        u_cfDataFree(d);
    } else {
        OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
            0, "One <Command> parameter expected for service %s", si->name);
        while (d != NULL) {
            u_cfDataFree(d);
            d = u_cfData(c_iterTakeFirst(iter));
        }
        r = FALSE;
    }
    c_iterFree(iter);

    return r;
}
예제 #6
0
static c_bool
cfgGetArguments(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int    iterLength;
    c_bool r;
    u_cfData d;

    r = TRUE;
    iter = u_cfElementXPath(info, "Arguments/#text");
    iterLength = c_iterLength(iter);
    d = u_cfData(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfDataStringValue(d, &si->args);
        u_cfDataFree(d);
    } else if (iterLength == 0) {
        OS_REPORT_1(OS_INFO, OSRPT_CNTXT_SPLICED, 
            0, "Taking default for <Arguments> parameter service %s", si->name);
        si->args = os_strdup("");
    } else {
        OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
            0, "One <Arguments> parameter expected for service %s", si->name);
        si->args = os_strdup("");
        while (d != NULL) {
            u_cfDataFree(d);
            d = u_cfData(c_iterTakeFirst(iter));
        }
        r = FALSE;
    }
    c_iterFree(iter);

    return r;
}
예제 #7
0
static c_bool
cfgGetSchedule(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int      iterLength;
    c_bool r;
    u_cfData d;
    c_char *str;

    r = TRUE;
    iter = u_cfElementXPath(info, "Scheduling/Class/#text");
    iterLength = c_iterLength(iter);
    d = u_cfData(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfDataStringValue(d, &str);

        if (r == TRUE) {
            if (strncmp(str, SCHED_RT, strlen(SCHED_RT)) == 0) {
                si->procAttr.schedClass = OS_SCHED_REALTIME;
            } else {
                if (strncmp(str, SCHED_TS, strlen(SCHED_TS)) == 0) {
                    si->procAttr.schedClass = OS_SCHED_TIMESHARE;
                } else {
                    if (strcmp(str, SCHED_DEF)==0) {
                        si->procAttr.schedClass = OS_SCHED_DEFAULT;
                    } else {
                        si->procAttr.schedClass = OS_SCHED_DEFAULT;
                        OS_REPORT_1(OS_WARNING, OSRPT_CNTXT_SPLICED, 
                             0, "Incorrect <Scheduling/Class> parameter for service %s -> default",
                             si->name);
                         r = TRUE;
                    }
                }
            }
            os_free(str);
        }
        u_cfDataFree(d);
    } else {
        si->procAttr.schedClass = OS_SCHED_DEFAULT;
        if (iterLength == 0) {
            OS_REPORT_1(OS_INFO, OSRPT_CNTXT_SPLICED, 
                0, "Taking default for <Scheduling/Class> parameter service %s", si->name);
        } else {
            OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
                0, "One <Scheduling/Class> parameter expected for service %s", si->name);
            r = FALSE;
        }
        while (d != NULL) {
            u_cfDataFree(d);
            d = u_cfData(c_iterTakeFirst(iter));
        }
    }
    c_iterFree(iter);

    return r;
}
예제 #8
0
static c_bool
cfgGetPriority(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int      iterLength;
    c_bool r;
    u_cfData d;
    c_long prio;

    r = TRUE;
    iter = u_cfElementXPath(info, "Scheduling/Priority/#text");
    iterLength = c_iterLength(iter);
    d = u_cfData(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfDataLongValue(d, &prio);

        if (r == TRUE) {
            si->procAttr.schedPriority = (os_int32)prio;
        } else {
            OS_REPORT_1(OS_WARNING, OSRPT_CNTXT_SPLICED, 
                0, "Incorrect <Scheduling/Priority> parameter for service %s -> default", si->name);
            r = TRUE;
        }
        u_cfDataFree(d);
    } else {
        if (iterLength == 0) {
            OS_REPORT_1(OS_INFO, OSRPT_CNTXT_SPLICED, 
                0, "Taking default for <Scheduling/Priority> parameter service %s", si->name);
        } else {
            OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
                0, "One <Scheduling/Priority> parameter expected for service %s", si->name);
            r = FALSE;
        }
        while (d != NULL) {
            u_cfDataFree(d);
            d = u_cfData(c_iterTakeFirst(iter));
        }
    }
    c_iterFree(iter);

    return r;
}
예제 #9
0
파일: u_cfData.c 프로젝트: xrl/opensplice
u_cfData
u_cfDataNew(
    u_participant participant,
    v_cfData kData)
{
    u_cfData data;

    if ((participant == NULL) || (kData == NULL)) {
        OS_REPORT(OS_ERROR, "u_cfDataNew", 0, "Illegal parameter");
        data = NULL;
    } else {
        data = u_cfData(os_malloc(U_CFDATA_SIZE));
        u_cfNodeInit(u_cfNode(data),participant,v_cfNode(kData));
    }
    return data;
}
예제 #10
0
파일: u_cfNode.c 프로젝트: osrf/opensplice
void
u_cfNodeFree (
    u_cfNode node)
{
    switch(u_cfNodeKind(node)) {
    case V_CFELEMENT:
        u_cfElementFree(u_cfElement(node));
    break;
    case V_CFATTRIBUTE:
        u_cfAttributeFree(u_cfAttribute(node));
    break;
    case V_CFDATA:
        u_cfDataFree(u_cfData(node));
    break;
    default:
    break;
    }
}
예제 #11
0
static c_bool
cfgGetRestartRule(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int iterLength;
    c_bool r;
    u_cfData d;
    c_char *str;

    r = TRUE;

    iter = u_cfElementXPath(info, "FailureAction/#text");
    iterLength = c_iterLength(iter);
    d = u_cfData(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfDataStringValue(d, &str);

        if (r == TRUE) {
#ifndef INTEGRITY
            if (strncmp(str, RR_KILL_STR, strlen(RR_KILL_STR)) == 0) {
                si->restartRule = RR_KILL;
            }
            if (strncmp(str, RR_RESTART_STR, strlen(RR_RESTART_STR)) == 0) {
                si->restartRule = RR_RESTART;
            }
            if (strncmp(str, RR_HALT_STR, strlen(RR_HALT_STR)) == 0) {
                si->restartRule = RR_HALT;
            }
#endif
            if (strncmp(str, RR_SKIP_STR, strlen(RR_SKIP_STR)) == 0) {
                si->restartRule = RR_SKIP;
            }
            if (si->restartRule == RR_NONE) {
                OS_REPORT_1(OS_WARNING, OSRPT_CNTXT_SPLICED,
                            0,
                            "Incorrect <FailureAction> parameter for service %s -> default",
                            si->name);
                si->restartRule = RR_SKIP;
            }
            os_free(str);
        }
        u_cfDataFree(d);
    } else {
        if (iterLength == 0) {
            OS_REPORT_1(OS_INFO, OSRPT_CNTXT_SPLICED, 
                0, "Taking default for <FailureAction> parameter service %s", si->name);
            si->restartRule = RR_SKIP;
        } else {
            OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
                0, "One <FailureAction> parameter expected for service %s", si->name);
            si->restartRule = RR_SKIP;
            r = FALSE;
        }
        while (d != NULL) {
            u_cfDataFree(d);
            d = u_cfData(c_iterTakeFirst(iter));
        }
    }
    c_iterFree(iter);

    return r;
}