Exemple #1
0
uint8_t extract_query_params(char* string, uint8_t* length, KeyValueMap* map) {
    uint8_t kv_counter = 0;
    
    if ( string[0] == '?' ) {
        advance_string(string, length, 1); //get past the questionmark
        
        while ( (kv_counter != 99) && (string[0] != '\0') ) {
            uint8_t equals_position = strcspn(string, "="); //figure out where the equal sign is in the string
            string[equals_position] = '\0'; //set the equals to the string termination character
            
            char key[20],value[20];
            strncpy(key, string, equals_position); //copy key into new memory location before string gets incremented by get_value_from_string
            key[equals_position] = '\0';
            
            uint8_t length_of_value = strcspn(string, "&/");
            strncpy(value, string, length_of_value);
            value[length_of_value] = '\0';
            
            map_add_key_value_pair(map, key, value, get_value_from_string(string, length, equals_position), equals_position+1);
            
            
            //if there is another parameter, dictated by a &, then increment the counter and move it past there.
            if ( string[0] == '&' ) {
                kv_counter++;
                advance_string(string, length, 1);
            } else kv_counter = 99;
        }
    }
    return 1;
}
Exemple #2
0
int shell_addbp(char **args)
{
    if (!args[1]) return MISSING_ARGS;

    add_bp(get_value_from_string(args[1]));
    return OK;
}
Exemple #3
0
int shell_sreg(char **args)
{
    if (!args[2]) return MISSING_ARGS;

    set_a_gpr(args[1], get_value_from_string(args[2]));
    return OK;
}
Exemple #4
0
int shell_rmbp(char **args)
{
    if (args[1]) {
        rm_bp(get_value_from_string(args[1]));
    } else {
        free_bp();
    }
    return OK;
}
Exemple #5
0
int shell_dmem(char **args)
{
    if (!args[1]) return MISSING_ARGS;

    // activation du masque pour ne pas quitter lors d'un check d'adresse
    switch_exitMask();

    if (args[2]) {
        display_memory_between(get_value_from_string(args[1]), get_value_from_string(args[2]));
    } else {
        display_memory_between(get_value_from_string(args[1]), get_value_from_string(args[1]) + 15);
    }

    // on desactive le masque, les checks d'addresse sont termines
    switch_exitMask();

    return OK;
}
Exemple #6
0
int shell_run(char **args)
{
    if (args[1]) {
        run(get_value_from_string(args[1]));
    } else {
        run(get_PC_value());
    }
    return OK;
}
Exemple #7
0
int shell_dasm(char **args)
{
    if (!args[1]) {
        dasm_line(1);
    } else if (!strcmp("all", args[1])) {
        dasm_text();
        dasm_data();
        dasm_bss();
    } else {
        dasm_line(get_value_from_string(args[1]));
    }
    return OK;
}
Exemple #8
0
int shell_smem(char **args)
{
    if (!args[2]) return MISSING_ARGS;

    // activation du masque pour ne pas quitter lors d'un check d'adresse
    switch_exitMask();

    uint32_t value = get_value_from_string(args[2]);
    uint32_t nbOctets = (args[3]) ? get_value_from_string(args[3]) : 1;
    switch (nbOctets) {
    case 1:
        if (is_byte(value)) {
            set_byte(get_value_from_string(args[1]), value);
        } else {
            fprintf(stderr, "La valeur est trop grande pour rentrer sur un octet\n");
        }
        break;
    case 2:
        if (is_half_word(value)) {
            set_half_word(get_value_from_string(args[1]), value);
        } else {
            fprintf(stderr, "La valeur est trop grande pour rentrer sur un demi-mot\n");
        }
        break;
    case 4:
        set_word(get_value_from_string(args[1]), value);
        break;
    default:
        fprintf(stderr, "Le nombre d'octets à écrire est soit 1, 2 ou 4\n");
    }

    // on desactive le masque, les checks d'addresse sont termines
    switch_exitMask();

    return OK;
}