diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2008-10-30 18:35:47 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2008-10-30 18:35:47 (GMT) | 
| commit | 7c7109c1a8aaedea40af4b96d4b81d6ba4496226 (patch) | |
| tree | 471709f8bccae04f492d03017a1e94d0ca48b962 /src/arch/processor.c | |
| parent | 8a30afc05eed869865ba4dc9c107119f7ec00fe4 (diff) | |
Displayed all found strings on binary loading.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@40 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/processor.c')
| -rw-r--r-- | src/arch/processor.c | 58 | 
1 files changed, 58 insertions, 0 deletions
| diff --git a/src/arch/processor.c b/src/arch/processor.c index 1afb576..17f88b3 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -24,6 +24,10 @@  #include "processor.h" +#include <regex.h> +#include <string.h> + +  #include "instruction-int.h"  #include "processor-int.h" @@ -84,6 +88,60 @@ asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, of  /******************************************************************************  *                                                                             * +*  Paramètres  : input = chaîne de caractères à traiter.                      * +*                                                                             * +*  Description : S'assure qu'une chaîne de caractère tient sur une ligne.     * +*                                                                             * +*  Retour      : Adresse de la chaîne de caractères modifiée.                 * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +char *escape_crlf_bin_string(char *input) +{ +    size_t inlen; +    regex_t preg; +    int ret; +    size_t curpos; +    regmatch_t pmatch[2]; + +    inlen = strlen(input); + +    ret = regcomp(&preg, "(\t|\n|\r)", REG_EXTENDED | REG_ICASE); +    /* TODO: ret */ + +    for (curpos = 0; regexec(&preg, &input[curpos], 2, pmatch, 0) != REG_NOMATCH; ) +    { +        inlen += 1 + 1; +        input = (char *)realloc(input, inlen * sizeof(char *)); + +        memmove(&input[curpos + pmatch[1].rm_eo + 1], &input[curpos + pmatch[1].rm_eo], inlen - 1 - curpos - pmatch[1].rm_eo); + +        switch (input[curpos + pmatch[1].rm_so]) +        { +            case '\t': +                memcpy(&input[curpos + pmatch[1].rm_so], "\\t", 2); +                break; +            case '\n': +                memcpy(&input[curpos + pmatch[1].rm_so], "\\n", 2); +                break; +            case '\r': +                memcpy(&input[curpos + pmatch[1].rm_so], "\\r", 2); +                break; +        } + +        curpos += pmatch[1].rm_eo + 1; + +    } + +    return input; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : proc   = architecture visée par la procédure.                *  *                format = format du binaire manipulé.                         *  *                instr  = instruction à traiter.                              * | 
