Esempio n. 1
0
File: parser.c Progetto: badcodes/c
int getvalue(FILE* html,char* value)
{
    int c=0;

    int quote_non=0;
    int quote_sng=0;
    int quote_dbl=0;
    int lim=MAX_VALUE-2;

    SKIP_WS(html,c);
    switch (c)
    {
        case '\"' :
            quote_dbl=1;
            break;
        case '\'' :
            quote_sng=1;
            break;
        default :
            quote_non=1;
            *value++=c;
            if (lim--<0) break;
            break;
    }


    do
    {
        c=NEXT_CHAR(html);

        if (END_OF_VALUE(c))
            break;
        else {
            if (lim--<0) break;
            *value++=c;
            }

    } while (c!=EOF) ;
   
   if (c==EOF) goto END_OF_FILE;

    *value='\0';

   // printf("%s\n",value);
    return 1;

    END_OF_FILE:
    *value='\0';
   // printf("%s\n",value);
    return 0;
}
Esempio n. 2
0
int test_find_index_of_attibutes_mrv() { //mask_return_value
	int ret;
	char *s = " {\"hid\":\"198\",\"name\":\"Mangatewai\",\"psm\":\"16 Oct 2012\",\"psc\":\"25 Jul 2012\",\"mapref\":\"\"}";
	int i;

	i=3;
	END_OF_NAME(s,strlen(s),i);RPG_CU_FNC_CHECK
	CU_ASSERT_EQUAL( 5, i );

	i=9;
	END_OF_VALUE(s,strlen(s),i);RPG_CU_FNC_CHECK
	CU_ASSERT_EQUAL( 11, i );

	return SUCCESS;
}
Esempio n. 3
0
int read_value_from_buffer( apr_pool_t *p, char *buffer, int len, int *out_i, char **out_value ) {
    int i = *out_i;

    while( i < len && buffer[i] == ' ' ) {
        i++;
    }; //spin through the whitespace

    if ( i == len ) {
        *out_i = -1;
        return SUCCESS;
    }

    if ( buffer[i] == '"' ) {
        int ret;
        char *value = (char *)apr_palloc(p, DEFAULT_BUFFER_SIZE);

        i++;
        int start=i;
        END_OF_VALUE(buffer,len,i);
        ENSURE_INDEX_VALID;
        ret = copy_string_from_buffer( buffer, value, start, i );
        ENSURE_SUCCEEDED;
        ENSURE_INDEX_VALID;
        i=i+2;

        *out_value = value;
        *out_i = i;
        return SUCCESS;
    }

    if ( buffer[i] == 'n' ) {
        if ( ( i + 4 ) < len && !strncmp( &buffer[i], "null", 4 ) ) {
            i = i + 4;

            *out_value = NULL;
            *out_i = i;
            return SUCCESS;
        }
    }

    *out_i = -1;
    return SUCCESS;

}