예제 #1
0
파일: gui_script.c 프로젝트: c10ud/CHDK
//-------------------------------------------------------------------
static void process_title(const char *ptr)
{
    ptr = skip_whitespace(ptr);
    int l = skip_toeol(ptr) - ptr;
    if (l >= sizeof(script_title)) l = sizeof(script_title) - 1;
    strncpy(script_title, ptr, l);
    script_title[l] = 0;
}
예제 #2
0
파일: gui_script.c 프로젝트: c10ud/CHDK
static void process_subtitle(const char *ptr)
{
    ptr = skip_whitespace(ptr);
    int l = skip_toeol(ptr) - ptr;
    if (l >= sizeof(script_title)) l = sizeof(script_title) - 1;
    sc_param *p = new_param(0);
    p->desc = malloc(l+1);
    strncpy(p->desc, ptr, l);
    p->desc[l] = 0;
    p->range_type = MENUITEM_SEPARATOR;
}
예제 #3
0
파일: gui_script.c 프로젝트: c10ud/CHDK
//-------------------------------------------------------------------
// Process one entry "@param VAR TITLE"
// RESULT: params[VAR].desc - parameter title
// RETURN VALUE: 0 if err, 1 if ok
//-------------------------------------------------------------------
static void process_param(const char *ptr)
{
    sc_param *p;
    ptr = get_name(ptr, MAX_PARAM_NAME_LEN, &p, 1);
    if (p)
    {
        ptr = skip_whitespace(ptr);
        int l = skip_toeol(ptr) - ptr;
        if (l > MAX_PARAM_NAME_LEN) l = MAX_PARAM_NAME_LEN;
        p->desc = malloc(l+1);
        strncpy(p->desc, ptr, l);
        p->desc[l] = 0;
    }
}
예제 #4
0
//-------------------------------------------------------------------
// Process one entry "@param VAR TITLE"
//      param = ptr right after descriptor (should point to var)
// RESULT: script_params[VAR] - parameter title
// RETURN VALUE: 0 if err, 1..26 = id of var
//-------------------------------------------------------------------
static int process_param(const char *param)
{
    register const char *ptr = param;
    register int n=0, l;

    ptr = skip_whitespace(ptr);
    if (ptr[0] && (ptr[0]>='a' && ptr[0]<='a'+SCRIPT_NUM_PARAMS) && (ptr[1]==' ' || ptr[1]=='\t'))
    {
        n = ptr[0]-'a';
        ptr = skip_whitespace(ptr+2);
        l = skip_toeol(ptr) - ptr;                  // get length of TITLE
        if (l > MAX_PARAM_NAME_LEN)
            l = MAX_PARAM_NAME_LEN;
        strncpy(script_params[n],ptr,l);
        script_params[n][l] = 0;
        n++;
    }
    return n; // n=1 if '@param a' was processed, n=2 for 'b' ... n=26 for 'z'. n=0 if failed.
}
예제 #5
0
//-------------------------------------------------------------------
// Process one entry "@values VAR A B C D ..."
//      param = ptr right after descriptor (should point to var)
//-------------------------------------------------------------------
static void process_values(const char *param)
{
    register const char *ptr = param;
    register int n;

    ptr = skip_whitespace(ptr);
    if (ptr[0] && (ptr[0]>='a' && ptr[0]<='a'+SCRIPT_NUM_PARAMS) && (ptr[1]==' ' || ptr[1]=='\t'))
    {
        n = ptr[0]-'a';
        ptr = skip_whitespace(ptr+2);
        int len = skip_toeol(ptr) - ptr;
        script_named_strings[n] = malloc(len+1);
        strncpy(script_named_strings[n], ptr, len);
        script_named_strings[n][len] = 0;

        const char *p = script_named_strings[n];
        int cnt = 0;
        while (*p)
        {
            p = skip_whitespace(skip_token(p));
            cnt++;
        }
        script_named_counts[n] = cnt;
        script_named_values[n] = malloc(cnt * sizeof(char*));

        p = script_named_strings[n];
        cnt = 0;
        while (*p)
        {
            script_named_values[n][cnt] = p;
            p = skip_token(p);
            if (*p)
            {
                *((char*)p) = 0;
                p = skip_whitespace(p+1);
            }
            cnt++;
        }
    } // ??? else produce error message
}
예제 #6
0
//-------------------------------------------------------------------
// Process one entry "@param VAR TITLE" to check if it exists
//      param = ptr right after descriptor (should point to var)
// RETURN VALUE: 0 if not found, 1..26 = id of var
// Used to ensure that a param loaded from an old saved paramset does
// not overwrite defaults from script
//-------------------------------------------------------------------
static int check_param(const char *param)
{
    register const char *ptr = param;
    register int n=0, l;

    ptr = skip_whitespace(ptr);
    if (ptr[0] && (ptr[0]>='a' && ptr[0]<='a'+SCRIPT_NUM_PARAMS) && (ptr[1]==' ' || ptr[1]=='\t'))
    {
        n = ptr[0]-'a';                                 // VAR
        ptr = skip_whitespace(ptr+2);                   // skip to TITLE
        l = skip_toeol(ptr) - ptr;                      // get length of TITLE
        if (l > MAX_PARAM_NAME_LEN)
            l = MAX_PARAM_NAME_LEN;
        if (l != strlen(script_params[n]))              // Check length matches existing TITLE length
            n = 0;
        else if (strncmp(ptr,script_params[n],l) != 0)  // Check that TITLE matches existing TITLE
            n = 0;
        else
            n++;
    }
    return n; // n=1 if '@param a' was processed, n=2 for 'b' ... n=26 for 'z'. n=0 if failed.
}
예제 #7
0
const char* skip_eol(const char *p)         { p = skip_toeol(p); if (*p == '\r') p++; if (*p == '\n') p++; return p; }      // Skip past end of line