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

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.5     ! paf        57:        if(s==(void*)0xCCCCcccc) {
        !            58:                strncpy(pResult, "<Uninitialized local>", max);
        !            59:                return 0;
        !            60:        }
        !            61: 
1.1       paf        62: 
                     63:        try {
                     64: #if 0
1.2       paf        65:                MessageBox(0, "test", "stop", 0);
                     66: #endif
                     67: #if 0
1.1       paf        68:                char buf[100];
                     69:                _snprintf(buf, sizeof(buf), "=!0x%p!=", s->body);
                     70:                strncpy(pResult, buf, max);
                     71: #else
1.2       paf        72:                char buf[MAX_STRING*2];
1.5     ! paf        73: #define LIMIT_LANGS 20
1.3       paf        74:                const char* body_view=CORD_to_const_char_star(pHelper, D(s->body));
                     75:                const char* langs_view=s->langs.is_not_just_lang?
                     76:                        CORD_to_const_char_star(pHelper, D(s->langs.langs))
                     77:                        : (const char*)&s->langs.langs;
                     78:                size_t body_len=strlen(body_view);
                     79:                size_t langs_len=strlen(langs_view);
                     80:                _snprintf(buf, sizeof(buf), 
                     81:                        "%.*s%s}"
1.4       paf        82:                        "{%d:%s",
1.3       paf        83:                        LIMIT_LANGS, langs_view, langs_len>LIMIT_LANGS?"...":"",
1.4       paf        84:                        body_len, body_view
1.3       paf        85:                );
                     86: 
1.2       paf        87:                strncpy(pResult, buf, max);
1.1       paf        88: #endif
                     89:        } catch(...) {
                     90:                strncpy(pResult, "!EE-ERROR!", max);
                     91:        }
                     92:        return 0;
                     93: }

E-mail: