Annotation of win32/development/msvcee/eeparser3.cpp, revision 1.3

1.1       paf         1: #include <stdio.h>
                      2: #include <string.h>
                      3: #include <tchar.h>
                      4: 
                      5: #include "custview.h"
                      6: 
                      7: #include "eeparser3.h"
                      8: #include "cord/include/cord.h"
                      9: 
                     10: // Helper routine that converts a system time into ASCII
                     11: 
                     12: struct String {
                     13:        enum Language {
                     14:                L_UNSPECIFIED=0, ///< no real string has parts of this lange: it's just convinient to check when string's empty
                     15:                // these two must go before others, there are checks for >L_AS_IS
                     16:                L_CLEAN='1', ///< clean
                     17:                L_AS_IS,     ///< leave all characters intact
                     18: 
                     19:                L_PASS_APPENDED,
                     20:                        /**<
                     21:                                leave lang built into string being appended.
                     22:                                just a flag, that value not stored
                     23:                        */
                     24:                L_TAINTED,  ///< tainted, untaint lang as assigned later 
                     25:                // untaint langs. assigned by ^untaint[lang]{...}
                     26:                L_FILE_SPEC, ///< file specification
                     27:                L_HTTP_HEADER,    ///< text in HTTP response header
                     28:                L_MAIL_HEADER,    ///< text in mail header
                     29:                L_URI,       ///< text in uri
                     30:                L_TABLE,     ///< ^table:set body
                     31:                L_SQL,       ///< ^table:sql body
                     32:                L_JS,        ///< JavaScript code
                     33:                L_XML,          ///< ^dom:set xml
                     34:                L_HTML,      ///< HTML code (for editing)
                     35:                L_OPTIMIZE_BIT = 0x80  ///< flag, requiring cstr whitespace optimization
                     36:        };
                     37: 
1.3     ! paf        38:        struct Languages {
1.1       paf        39:                union {
                     40:                        struct {
                     41:                                Language lang:8;
                     42:                                int is_not_just_lang:sizeof(CORD)*8-8;
                     43:                        };
                     44:                        CORD langs;
                     45:                };
                     46:        } langs;
                     47:        CORD body;
                     48: };
                     49: 
                     50: ADDIN_API HRESULT WINAPI AddIn_Parser3String( String* s, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t max, DWORD reserved )
                     51: {
1.2       paf        52:        s=D(s);
                     53:        if(!s) {
                     54:                strncpy(pResult, "<Empty>", max);
1.3     ! paf        55:                return 0;
1.2       paf        56:        }
1.1       paf        57: 
                     58:        try {
                     59: #if 0
1.2       paf        60:                MessageBox(0, "test", "stop", 0);
                     61: #endif
                     62: #if 0
1.1       paf        63:                char buf[100];
                     64:                _snprintf(buf, sizeof(buf), "=!0x%p!=", s->body);
                     65:                strncpy(pResult, buf, max);
                     66: #else
1.2       paf        67:                char buf[MAX_STRING*2];
1.3     ! paf        68: #define LIMIT_BODY 30
        !            69: #define LIMIT_LANGS 10
        !            70:                const char* body_view=CORD_to_const_char_star(pHelper, D(s->body));
        !            71:                const char* langs_view=s->langs.is_not_just_lang?
        !            72:                        CORD_to_const_char_star(pHelper, D(s->langs.langs))
        !            73:                        : (const char*)&s->langs.langs;
        !            74:                size_t body_len=strlen(body_view);
        !            75:                size_t langs_len=strlen(langs_view);
        !            76:                _snprintf(buf, sizeof(buf), 
        !            77:                        "%.*s%s}"
        !            78:                        "{%d:%.*s%s",
        !            79:                        LIMIT_LANGS, langs_view, langs_len>LIMIT_LANGS?"...":"",
        !            80:                        body_len,
        !            81:                        LIMIT_BODY, body_view, body_len>LIMIT_BODY?"...":""
        !            82:                );
        !            83: 
1.2       paf        84:                strncpy(pResult, buf, max);
1.1       paf        85: #endif
                     86:        } catch(...) {
                     87:                strncpy(pResult, "!EE-ERROR!", max);
                     88:        }
                     89:        return 0;
                     90: }

E-mail: