Lhogho  0.0.027
Functions
param_parsers.c File Reference

Functions

RESULT name_parser (const TCHAR *parameter_name, const TCHAR *parameter_optipons, test_case_info *test_case_params)
 Parse name pameter.
RESULT cmd_parser (const TCHAR *parameter_name, const TCHAR *parameter_optipons, test_case_info *test_case_params)
 Parse commands for compiler.
RESULT extract_string (const TCHAR *parameter_optipons, TCHAR **extracted_value)
 Extracts a string to space form parameter buffer.

Function Documentation

RESULT name_parser ( const TCHAR *  parameter_name,
const TCHAR *  parameter_optipons,
test_case_info test_case_params 
)
Parameters:
parameter_namename of the parameter to parse
parameter_optiponsthe text passed for parsing
test_case_paramspalce where extracted name will be stored
Returns:
RESULT code (see error.h)

Exract the name of the test case.

{
    /* if this is not parameter that can be handled here */
    if (m_strcmp(parameter_name, TEXT("name")))
    {
        return ERR_INVALID_ARG;
    }

    return extract_string(parameter_optipons, &test_case_params->test_name);
}
RESULT cmd_parser ( const TCHAR *  parameter_name,
const TCHAR *  parameter_optipons,
test_case_info test_case_params 
)
Parameters:
parameter_namename of the parameter to parse
parameter_optiponsthe text passed for parsing
test_case_paramspalce where extracted comand options will be stored
Returns:
RESULT code (see error.h)

Exract the name of the test case.

{
    /* if this is not parameter that can be handled here */
    if (m_strcmp(parameter_name, TEXT("cmd")))
    {
        return ERR_INVALID_ARG;
    }

    return extract_string(parameter_optipons, &test_case_params->command_line_param);
}
RESULT extract_string ( const TCHAR *  parameter_optipons,
TCHAR **  extracted_value 
)
Parameters:
parameter_optiponsinput string
extracted_valueresult value. Memory is allocated for it
Returns:
RESULT code (see error.h)

Exract the the data to the first space. If space is between " " it is ecraned. Allocate memory for result string

{
    UINT32      start = 0;
    UINT32      end = 0;
    BOOL        escape_spaces = FALSE;

    while (parameter_optipons[start] && m_isspace(parameter_optipons[start]))
        ++start;
    
    if (parameter_optipons[start] == SPACE_ESC_SYMBOL)
    {
        ++start;
        escape_spaces = TRUE;
    }
    end = start;

    while (parameter_optipons[end] && 
           !((escape_spaces && parameter_optipons[end] == SPACE_ESC_SYMBOL) ||
             (!escape_spaces && m_isspace(parameter_optipons[end]))))
        ++end;

    return m_strndup(extracted_value, parameter_optipons + start, end - start);
}

[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Tue Feb 7 2012