File:  [parser3project] / win32 / development / msvcee / Attic / eeparser3.cpp
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Fri Oct 31 12:34:13 2003 UTC (22 years, 10 months ago) by paf
Branches: MAIN
CVS tags: release_3_2_1, release_3_2_0, release_3_1_6, release_3_1_5, release_3_1_4, release_3_1_3, release_3_1_2, release_3_1_1, paf_left, before_release_3_2_1, before_killing_gdome, HEAD
no message

#include <stdio.h>
#include <string.h>
#include <tchar.h>

#include "custview.h"

#include "eeparser3.h"
#include "cord/include/cord.h"

// Helper routine that converts a system time into ASCII

struct String {
	enum Language {
		L_UNSPECIFIED=0, ///< no real string has parts of this lange: it's just convinient to check when string's empty
		// these two must go before others, there are checks for >L_AS_IS
		L_CLEAN='1', ///< clean
		L_AS_IS,     ///< leave all characters intact

		L_PASS_APPENDED,
			/**<
				leave lang built into string being appended.
				just a flag, that value not stored
			*/
		L_TAINTED,  ///< tainted, untaint lang as assigned later 
		// untaint langs. assigned by ^untaint[lang]{...}
		L_FILE_SPEC, ///< file specification
		L_HTTP_HEADER,    ///< text in HTTP response header
		L_MAIL_HEADER,    ///< text in mail header
		L_URI,       ///< text in uri
		L_TABLE,     ///< ^table:set body
		L_SQL,       ///< ^table:sql body
		L_JS,        ///< JavaScript code
		L_XML,		///< ^dom:set xml
		L_HTML,      ///< HTML code (for editing)
		L_OPTIMIZE_BIT = 0x80  ///< flag, requiring cstr whitespace optimization
	};

	struct Languages {
		union {
			struct {
				Language lang:8;
				int is_not_just_lang:sizeof(CORD)*8-8;
			};
			CORD langs;
		};
	} langs;
	CORD body;
};

ADDIN_API HRESULT WINAPI AddIn_Parser3String( String* s, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t max, DWORD reserved )
{
	s=D(s);
	if(!s) {
		strncpy(pResult, "<Empty>", max);
		return 0;
	}
	if(s==(void*)0xCCCCcccc) {
		strncpy(pResult, "<Uninitialized local>", max);
		return 0;
	}


	try {
#if 0
		MessageBox(0, "test", "stop", 0);
#endif
#if 0
		char buf[100];
		_snprintf(buf, sizeof(buf), "=!0x%p!=", s->body);
		strncpy(pResult, buf, max);
#else
		char buf[MAX_STRING*2];
#define LIMIT_LANGS 20
		const char* body_view=CORD_to_const_char_star(pHelper, D(s->body));
		const char* langs_view=s->langs.is_not_just_lang?
			CORD_to_const_char_star(pHelper, D(s->langs.langs))
			: (const char*)&s->langs.langs;
		size_t body_len=strlen(body_view);
		size_t langs_len=strlen(langs_view);
		_snprintf(buf, sizeof(buf), 
			"%.*s%s}"
			"{%d:%s",
			LIMIT_LANGS, langs_view, langs_len>LIMIT_LANGS?"...":"",
			body_len, body_view
		);

		strncpy(pResult, buf, max);
#endif
	} catch(...) {
		strncpy(pResult, "!EE-ERROR!", max);
	}
	return 0;
}

E-mail: