static void hexencodemap(void)
{
    static const char sHexChars[] = "0123456789ABCDEF";
    int i;
    char hexEncode1[256];
    char hexEncode2[256];
    for (i = 0; i < 256; ++i) {
        hexEncode1[i] = sHexChars[i >> 4];
        hexEncode2[i] = sHexChars[i & 0x0f];
    }

    char_array_to_c(hexEncode1, sizeof(hexEncode1), "gsHexEncodeMap1");
    char_array_to_c(hexEncode2, sizeof(hexEncode2), "gsHexEncodeMap2");
}
static void urlencodemap(void)
{
    uint32_t i;
    char urlEncodeMap[256];

    /* 0 means unsafe */
    for (i = 0; i < 256; ++i) {
        urlEncodeMap[i] = 0;
    }

    /* upper case */
    for (i = 'A'; i <= 'Z' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    /* lower case */
    for (i = 'a'; i <= 'z' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    /* numbers */
    for (i = '0'; i <= '9' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    /* safe chars */
    urlEncodeMap[(int)'.'] = '.';
    urlEncodeMap[(int)'-'] = '-';
    urlEncodeMap[(int)'_'] = '_';
    /* space is special */
    urlEncodeMap[(int)' '] = '+';

    char_array_to_c(urlEncodeMap, sizeof(urlEncodeMap), "gsUrlEncodeMap");
}
static void jsencodemap(void)
{
    int i;
    char jsEncodeMap[256];

    /* set everything to "as is" */
    for (i = 0; i < 256; ++i) {
        jsEncodeMap[i] = 0;
    }

    /* chars that need hex escaping */
    for (i = 0; i < 32; ++i) {
        jsEncodeMap[i] = 'A';
    }
    for (i = 127; i < 256; ++i) {
        jsEncodeMap[i] = 'A';
    }

    /* items that have special escaping */
    jsEncodeMap[0x08] = 'b';
    jsEncodeMap[0x09] = 't';
    jsEncodeMap[0x0a] = 'n';
    jsEncodeMap[0x0b] = 'v';
    jsEncodeMap[0x0c] = 'f';
    jsEncodeMap[0x0d] = 'r';
    jsEncodeMap[0x5c] = '\\';  /* blackslash gets escaped */
    jsEncodeMap[0x22] = '"';   /* dquote gets escaped */
    jsEncodeMap[0x27] = '\'';  /* squote gets escaped */

    char_array_to_c(jsEncodeMap, sizeof(jsEncodeMap), "gsJavascriptEncodeMap");
}
Example #4
0
void urlencodemap()
{
    uint32_t i;
    char urlEncodeMap[256];

    // 0 means unsafe
    for (i = 0; i < 256; ++i) {
        urlEncodeMap[i] = 0;
    }

    // upper case
    for (i = 'A'; i <= 'Z' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    // lower case
    for (i = 'a'; i <= 'z' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    // numbers
    for (i = '0'; i <= '9' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    // safe chars
    urlEncodeMap[(int)'.'] = '.';
    urlEncodeMap[(int)'-'] = '-';
    urlEncodeMap[(int)'_'] = '_';
    // space is special
    urlEncodeMap[(int)' '] = '+';

    char_array_to_c(urlEncodeMap, 256, "gsUrlEncodeMap");
};
Example #5
0
void hexencodemap_char()
{
    static const unsigned char sHexChars[] = "0123456789ABCDEF";
    int i;
    unsigned char e1[256];
    unsigned char e2[256];

    for (i = 0;i < 256; ++i) {
        e1[i] = 0;
        e2[i] = 0;
    }

    for (i = 0; i < 256; ++i) {
        e1[i] = sHexChars[i >> 4];
        e2[i] = sHexChars[i &  0x0f];
    }

    char_array_to_c((char*)e1, 256, "gsHexEncodeC1");
    char_array_to_c((char*)e2, 256, "gsHexEncodeC2");
}
Example #6
0
static void modp_toupper_map(void)
{
    size_t i = 0;
    char map[256];
    for (i = 0; i < sizeof(map); ++i) {
        if (i >= 'a' && i <= 'z') {
            map[i] = (char)(i - 32);
        } else {
            map[i] = (char)(i);
        }
    }

    char_array_to_c(map, sizeof(map), "gsToUpperMap");
}
Example #7
0
static void modp_toprint_map(void)
{
    size_t i = 0;
    char map[256];
    for (i = 0; i < sizeof(map); ++i) {
        if (i < 32 || i > 126) {
            map[i] = '?';
        } else {
            map[i] = (char) i;
        }
    }

    char_array_to_c(map, sizeof(map), "gsToPrintMap");
}
Example #8
0
static void modp_tolower_map(void)
{
    size_t i = 0;
    char map[256];
    for (i = 0; i < sizeof(map); ++i) {
        if (i >= 'A' && i <= 'Z') {
            map[i] = (char)(i + 32);
        } else {
            map[i] = (char)i;
        }
    }

    char_array_to_c(map, sizeof(map), "gsToLowerMap");
}
static void urlencodeminmap(void)
{
    int i;
    char urlEncodeMap[256];
    const char safechar[] = {'_', '.', '-', '~',
                             '!', '$', '(', ')', '*', ',', ';',
                             ':', '@', '/', '?'};

    int imax = sizeof(safechar);

    /* 0 means unsafe */
    for (i = 0; i < 256; ++i) {
        urlEncodeMap[i] = 0;
    }

    /* upper case */
    for (i = 'A'; i <= 'Z' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    /* lower case */
    for (i = 'a'; i <= 'z' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    /* numbers */
    for (i = '0'; i <= '9' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }

    /* space */
    urlEncodeMap[(int)' '] = '+';

    for (i = 0; i < imax; ++i) {
        urlEncodeMap[(int)(safechar[i])] = safechar[i];
    }


    char_array_to_c(urlEncodeMap, sizeof(urlEncodeMap), "gsUrlEncodeMinMap");
}
Example #10
0
void urlencodeminmap()
{
    int i;
    char urlEncodeMap[256];

    // 0 means unsafe
    for (i = 0; i < 256; ++i) {
        urlEncodeMap[i] = 0;
    }

    // upper case
    for (i = 'A'; i <= 'Z' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    // lower case
    for (i = 'a'; i <= 'z' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }
    // numbers
    for (i = '0'; i <= '9' ; ++i) {
        urlEncodeMap[i] = (char) i;
    }

    // space
    urlEncodeMap[(int)' '] = '+';
    const char safechar[] = {'_', '.', '-', '~',
                             '!', '$', '(', ')', '*', ',', ';',
                             ':', '@', '/', '?'};

    int imax = sizeof(safechar);
    for (i = 0; i < imax; ++i) {
        urlEncodeMap[(int)(safechar[i])] = safechar[i];
    }


    char_array_to_c(urlEncodeMap, 256, "gsUrlEncodeMinMap");
};