Exemple #1
0
bool DlgCompareDir::FetchDir(String dir, VectorMap<String, FileInfo>& files, VectorMap<String, String>& dirs)
{
	FindFile ff;
	if(!ff.Search(AppendFileName(dir, "*")))
		return false;
	do
		if(ff.IsFile() && PatternMatchMulti(fm, ff.GetName()))
			files.Add(NormalizePathCase(ff.GetName()), FileInfo(ff.GetName(), ff.GetLength(), ff.GetLastWriteTime()));
		else if(ff.IsFolder())
			dirs.Add(NormalizePathCase(ff.GetName()), ff.GetName());
	while(ff.Next());
	return true;
}
Exemple #2
0
VectorMap<String, Value> Pdb::DataMap(const ArrayCtrl& a)
{
	VectorMap<String, Value> r;
	for(int i = 0; i < a.GetCount(); i++)
		r.Add(a.Get(i, 0), a.Get(i, 1));
	return r;
}
Exemple #3
0
int  GetClipboardFormatCode(const char *format_id)
{
	GuiLock ___;
	int x = (int)(intptr_t)format_id;
	if(x >= 0 && x < 65535)
		return x;
	String fmt = format_id;
	if(fmt == "text")
		return CF_TEXT;
	if(fmt == "wtext")
		return CF_UNICODETEXT;
	if(fmt == "dib")
		return CF_DIB;
	if(fmt == "files")
		return CF_HDROP;
	static StaticMutex m;
	Mutex::Lock __(m);
	static VectorMap<String, int> format_map;
	int f = format_map.Find(format_id);
	if(f < 0) {
		f = format_map.GetCount();
		format_map.Add(format_id,
#ifdef PLATFORM_WINCE
			::RegisterClipboardFormat(ToSystemCharset(format_id))
#else
			::RegisterClipboardFormat(format_id)
#endif
		);
	}
	return format_map[f];
}
Exemple #4
0
Vector<FaceInfo> GetAllFacesSys()
{
	VectorMap<String, FaceInfo> list;
	sList = &list;
	list.Add("STDFONT").name = "STDFONT";
	list.Top().info = 0;
#ifdef PLATFORM_WINCE
	HDC hdc = CreateDC(NULL, NULL, NULL, NULL);
	Win32_ForceFace(hdc, "Tahoma", NULL);
	Win32_ForceFace(hdc, "Tahoma", "Tahoma");
	Win32_ForceFace(hdc, "Courier New", "Tahoma");
	Win32_ForceFace(hdc, "Tahoma", "Tahoma");
	Win32_ForceFace(hdc, "Tahoma", "Tahoma");
	Win32_ForceFace(hdc, "Tahoma", "Tahoma");
#else
	HDC hdc = CreateIC("DISPLAY", NULL, NULL, NULL);
	Win32_ForceFace(hdc, "Times New Roman", "Arial");
	Win32_ForceFace(hdc, "Arial", "Arial");
	Win32_ForceFace(hdc, "Courier New", "Arial");
	Win32_ForceFace(hdc, "Symbol", "Arial");
	Win32_ForceFace(hdc, "WingDings", "Arial");
	Win32_ForceFace(hdc, "Tahoma", "Arial");
#endif
	Win32_EnumFace(hdc, NULL);
	DeleteDC(hdc);
	return list.PickValues();
}
Exemple #5
0
void benchmark_VectorMap(const Vector<T>& key, const Vector<T>& fkey, int count)
{
	StopTime();
	cout << count << " items\n";
	{
		int i;
		VectorMap<T, int> map;
		StopTime();
		for(i = 0; i < count; i++)
			map.Add(key[i], i);
		cout << "Adding done in " << StopTime() << " s\n";
		for(int j = 0; j < 2; j++) {
			for(i = 0; i < count; i++)
				if(map.Get(fkey[i]) != i) {
					cout << "ERROR !\n";
					abort();
				}
			cout << "Search done in " << StopTime() << " s\n";
		}
		for(i = 0; i < count; i++)
			map.UnlinkKey(key[i]);
		cout << "Unlinking done in " << StopTime() << " s\n";
		for(i = 0; i < count; i++)
			map.Put(key[i], i);
		cout << "Putting done in " << StopTime() << " s\n";
	}
}
Exemple #6
0
bool InvoiceList::prepare()
{
	String sqlStatement = "select r.invoice_id, r.inv_create_date, \
					(select sum(ri.item_price) from record_item ri where ri.record_id = r.id) \
					from record r \
					where r.invoice_id is not null and r.inv_create_date between '"
					 + AsString(from) + "' and '" + AsString(to) 
					 + "' order by r.inv_create_date, r.invoice_id";
	SQL.Execute(sqlStatement);
	
	bool found = false;
	while (SQL.Fetch()) {
		found = true;
		
		VectorMap<int, String> vmap;
		vmap.Add(iliInvNum, AsString(SQL[0]));
		vmap.Add(iliDate, AsString(SQL[1]));
		vmap.Add(iliTotal, fixFuckedLinuxFormating(ConvertMoney().Format(SQL[2])));
		inv_list_items.Add(vmap);
	}
	if (!found) return false;
	
	SQL & Select(SqlSum(ITEM_PRICE.Of(RECORD_ITEM))).From(RECORD_ITEM)
		.InnerJoin(RECORD).On(RECORD_ID.Of(RECORD_ITEM) == ID.Of(RECORD))
		.Where(NotNull(INVOICE_ID.Of(RECORD)) && (Between(INV_CREATE_DATE.Of(RECORD), from, to)));
	if (SQL.Fetch())
		summary_price = SQL[0];	
	
	invoiceList.Clear();
	invoiceList.Header(String("[A0> ") + String(t_("Page")) + String(" $$P"));
	
	StringBuffer buf;
	
	buf.Cat("{{1f4 ");
	formatHeader(buf);
	buf.Cat(":: ");
	formatCompanyData(buf);
	buf.Cat(":: ");
	formatItems(buf);
	buf.Cat("}}");
	
	LOG(~buf);
	invoiceList << ~buf;

	return true;
}
Exemple #7
0
VectorMap<String, String> DataMap(const ArrayCtrl& data)
{
	GuiLock __;
	
	VectorMap<String, String> m;
	for(int i = 0; i < data.GetCount(); i++)
		m.Add(data.Get(i, 0), data.Get(i, 1));
	return m;
}
Exemple #8
0
VectorMap<String, SqlColumnInfo> Describe(const SqlVal& table, Sql& cursor)
{
    VectorMap<String, SqlColumnInfo> map;
    if(cursor * SelectAll().From(table).Where(SqlBool::False()))
        for(int i = 0, n = cursor.GetColumns(); i < n; i++)
        {
            const SqlColumnInfo& sci = cursor.GetColumnInfo(i);
            map.Add(sci.name, sci);
        }
    return map;
}
Exemple #9
0
G_obj *Get(G_obj *(*widget)())
{
	static VectorMap<uintptr_t, G_obj *> wmap;
	G_obj *w = wmap.Get((uintptr_t)widget, NULL);
	if(!w) {
		w = (*widget)();
		if(GTK().gtk_widget_get_parent(w) == NULL)
			Setup(w);
		wmap.Add((uintptr_t)widget, w);
	}
	return w;
}
Exemple #10
0
String GetIncludePath(const String& s, const String& filedir)
{
	LTIMING("GetIncludePath");
	String key;
	key << s << "#" << filedir;
	int q = sIncludePath.Find(key);
	if(q >= 0)
		return sIncludePath[q];
	LTIMING("GetIncludePath 2");
	String p = GetIncludePath0(s, filedir);
	sIncludePath.Add(key, p);
	LLOG("GetIncludePath " << s << " " << filedir << ": " << p);
	return p;
}
Exemple #11
0
ValueMap Result::LoadPage(const CommitFilter& f) {
	SQLR * Select(SqlAll(RESULT),UID,CMT,BRANCH,CLIENT_ID)
	       .From(
	           Select(UID.As("FILTER"))
	           .From(COMMITS)
	           .Where(f)
	           .OrderBy(Descending(DT))
	           .Limit(f.offset, f.limit)
	           .AsTable("FILTER_TABLE")
	       )
	       .InnerJoin(COMMITS).On(SqlId("FILTER")==UID)
	       .LeftJoin(RESULT).On(CMT_UID == UID)
	       .LeftJoin(CLIENT).On(ID == CLIENT_ID)
	       .OrderBy(Descending(DT));
	VectorMap<Tuple2<String, int>,ValueMap> rows;
	SortedIndex<int> clients;
	VectorMap<String, ValueMap> commits;
	ValueArray v_clients;
	ValueMap v_commits;
	ValueMap vm;
	while (SQLR.Fetch(vm)){
		SetComputedAttributes(vm);
		String uid = vm["UID"];
		int cid = vm["CLIENT_ID"];
		rows.Add(MakeTuple(uid, cid), vm);
		clients.FindAdd(cid);
		ValueMap& commit = commits.GetAdd(uid);
		commit.Set("CMT", vm["CMT"]);
		commit.Set("BRANCH", vm["BRANCH"]);
	}
	ValueMap results;
	for(int i = 0; i<commits.GetCount() ; ++i){
		v_commits.Add(commits.GetKey(i), commits[i]);
		vm.Clear();
		for(int j = 0; j < clients.GetCount(); ++j){
			if(!IsNull(clients[j]))
				vm.Add(clients[j], rows.GetAdd(MakeTuple(commits.GetKey(i), clients[j])));
		}
		results.Add(commits.GetKey(i), vm);
	}
	for(int i = (!clients.IsEmpty() && IsNull(clients[0]))?1:0; i < clients.GetCount(); i++)
		v_clients.Add(clients[i]);
	ValueMap res;
	res.Set("RESULTS", results);
	res.Set("COMMITS", v_commits);
	res.Set("CLIENTS", v_clients);
	res.Set("ALLCLIENTS", Client::LoadAll());
	return res;
}
Exemple #12
0
void MyApp::LeftDrag(Point p, dword keyflags)
{
	String bin;
	bin.Cat((byte *)&data.color, sizeof(data.color));
	bin.Cat(data.text);
	VectorMap<String, ClipData> d;
	d.Add("MyAppData", bin);
	Append(d, data.text);
	Size sz(128, 64);
	ImageDraw iw(sz);
	iw.DrawRect(sz, Black());
	iw.Alpha().DrawRect(sz, Black());
	iw.Alpha().DrawText(0, 0, data.text, Courier(14), White());
	DoDragAndDrop(d, iw);
}
Exemple #13
0
Atom XAtom(const char *name)
{
	GuiLock __; 
	Atom x;
	INTERLOCKED {
		static VectorMap<String, int> atoms;
		int q = atoms.Get(name, Null);
		if(IsNull(q)) {
			q = XAtomRaw(name);
			atoms.Add(name, q);
		}
		x = q;
	}
	return x;
}
Exemple #14
0
void MainDlg::OnLanguage(Bar& bar )
{
	const int* languages = GetAllLanguages();
	// We have a tremendous amount of redundancy here... we'll use this as a filter.
	// Note that sometimes, the number changes, but it still comes up as 'English'.
	// This is perhaps because we don't have any translations for the other languages.
	VectorMap< String, int > oldLangs;
	for (int i = 0; languages[i] != 0; i++ )
	{
		String langName = ::GetNativeLangName( languages[ i ] );
		if ( oldLangs.Find( langName ) < 0 )
		{
			bar.Add( langName , THISBACK1( OnChangeLanguage, languages[i] ) );
			oldLangs.Add( langName, languages[i] );
		}
	}
}
Exemple #15
0
void LoadPPConfig()
{
	for(int i = 0; i < sAllMacros.GetCount(); i++)
		if(sAllMacros[i].segment_id == 0 && !sAllMacros.IsUnlinked(i))
			sAllMacros.Unlink(i);

	s_namespace_macro.Clear();
	s_namespace_end_macro.Clear();

	StringStream ss(sDefs);
	int linei = 0;
	while(!ss.IsEof()) {
		String l = ss.GetLine();
		try {
			CParser p(l);
			if(p.Char('#')) {
				if(p.Id("define")) {
					CppMacro def;
					String   id = def.Define(p.GetPtr());
					if(id.GetCount()) {
						PPMacro m;
						m.segment_id = 0;
						m.line = linei;
						m.macro = def;
						sAllMacros.Put(id, m);
						if(findarg(TrimBoth(def.body), "}", "};") >= 0)
							s_namespace_end_macro.Add(id);
						try {
							CParser p(def.body);
							if(p.Id("namespace") && p.IsId()) {
								String n = p.ReadId();
								if(p.Char('{') && p.IsEof())
									s_namespace_macro.Add(id, n);
							}
						}
						catch(CParser::Error) {}
					}
				}
			}
		}
		catch(CParser::Error) {}
		linei++;
	}
}
Exemple #16
0
PackageInfo GetPackageInfo(const String& name)
{
    String path = PackagePath(name);
    Time tm = FileGetTime(path);
    int q = sPi.Find(name);
    if(q >= 0) {
        if(path == sPi[q].path && tm == sPi[q].stamp)
            return sPi[q];
    }
    else {
        q = sPi.GetCount();
        sPi.Add(name);
    }
    PackageInfo& pi = sPi[q];
    pi.path = path;
    pi.stamp = tm;
    Package p;
    p.Load(path);
    pi.ink = p.ink;
    pi.italic = p.italic;
    pi.bold = p.bold;
    return pi;
}
Exemple #17
0
void ExtToMime::Load(const char *fn)
{
	FileIn in(fn);
	if(in)
		while(!in.IsEof()) {
			String ln = TrimLeft(TrimRight(in.GetLine()));
			if(ln[0] != '#') {
				int q = ln.Find(':');
				if(q >= 0) {
					String h = ln.Mid(0, q);
					int w = h.Find('/');
					if(w >= 0) {
						int x = ln.Find("*.", q);
						if(x >= 0) {
							String ext = ln.Mid(x + 2);
							if(ext.GetCount() && map.Find(ext) < 0)
								map.Add(ext, MAKELONG(minor.FindAdd(h.Mid(w + 1)), major.FindAdd(h.Mid(0, w))));
						}
					}
				}
			}
		}
}
Exemple #18
0
bool Speller::SetOld(const String& _data)
{
	data = _data;
	const char *s = data;
	if(s >= data.End()) {
		data.Clear();
		return false;
	}
	charset = *s++;
	s++;// reserved for prefixes
	dict = *s++;
	for(int i = 0; i < 256 - dict; i++) {
		if(s >= data.End()) {
			data.Clear();
			return false;
		}
		voc[i] = s;
		while(*s) s++;
		s++;
	}
	line.Clear();
	while(s < data.End()) {
		if(s + 8 >= data.End()) {
			data.Clear();
			return false;
		}
		int code = Peek32le(s);
		s += 4;
		int len = Peek32le(s);
		s += 4;
		Line& l = line.Add(code);
		l.begin = (const byte *)s;
		s += len;
		l.end = (const byte *)s;
	};
	return true;
}
Exemple #19
0
static void LoadIniStream(Stream& in, VectorMap<String, String>& key, const char *sfile)
{
	bool env = false;
	while(!in.IsEof()) {
		String line = in.GetLine();
		CParser p(line);
		if(p.IsId()) {
			String k = p.ReadId();
			if(p.Char('=')) {
				String h = TrimBoth((String)p.GetSpacePtr());
				if(env) {
					String hh;
					const char *s = ~h;
					while(*s) {
						if(*s == '$') {
							s++;
							if(*s == '$') {
								hh.Cat('$');
								s++;
							}
							else {
								String id;
								if (*s == '{') {
									while(*++s != '}')
										id.Cat(*s);
									s++;
								} else {
									while(iscid(*s))
										id.Cat(*s++);
								}
								hh.Cat(GetEnv(id));
							}
						}
						else
							hh.Cat(*s++);
					}
					key.Add(k, hh);
				}
				else
					key.Add(k, h);
			}
		}
		else
		if(p.Char('@')) {
			if(p.Id("include")) {
				String fn = p.GetPtr();
				if(!IsFullPath(fn) && sfile)
					fn = AppendFileName(GetFileFolder(GetFullPath(sfile)), fn);
				LoadIniFile(fn, key);
			}
			else
			if(p.Id("end"))
				return;
			else
			if(p.Id("replace-env"))
				env = true;
			else
			if(p.Id("ignore-env"))
				env = false;
		}
	}
}
Exemple #20
0
NAMESPACE_UPP

#include "SvgInternal.h"

Color SvgParser::GetTextColor(const String& color) {
    struct Svg_color {
        const char *name;
        byte r, g, b;
    } colors[] = {
        {"aliceblue", 240, 248, 255},
        {"antiquewhite", 250, 235, 215},
        {"aqua", 0, 255, 255},
        {"aquamarine", 127, 255, 212},
        {"azure", 240, 255, 255},
        {"beige", 245, 245, 220},
        {"bisque", 255, 228, 196},
        {"black", 0, 0, 0},
        {"blanchedalmond", 255, 235, 205},
        {"blue", 0, 0, 255},
        {"blueviolet", 138, 43, 226},
        {"brown", 165, 42, 42},
        {"burlywood", 222, 184, 135},
        {"cadetblue", 95, 158, 160},
        {"chartreuse", 127, 255, 0},
        {"chocolate", 210, 105, 30},
        {"coral", 255, 127, 80},
        {"cornflowerblue", 100, 149, 237},
        {"cornsilk", 255, 248, 220},
        {"crimson", 237, 164, 61},
        {"cyan", 0, 255, 255},
        {"darkblue", 0, 0, 139},
        {"darkcyan", 0, 139, 139},
        {"darkgoldenrod", 184, 134, 11},
        {"darkgray", 169, 169, 169},
        {"darkgreen", 0, 100, 0},
        {"darkkhaki", 189, 183, 107},
        {"darkmagenta", 139, 0, 139},
        {"darkolivegreen", 85, 107, 47},
        {"darkorange", 255, 140, 0},
        {"darkorchid", 153, 50, 204},
        {"darkred", 139, 0, 0},
        {"darksalmon", 233, 150, 122},
        {"darkseagreen", 143, 188, 143},
        {"darkslateblue", 72, 61, 139},
        {"darkslategray", 47, 79, 79},
        {"darkturquoise", 0, 206, 209},
        {"darkviolet", 148, 0, 211},
        {"deeppink", 255, 20, 147},
        {"deepskyblue", 0, 191, 255},
        {"dimgray", 105, 105, 105},
        {"dodgerblue", 30, 144, 255},
        {"firebrick", 178, 34, 34},
        {"floralwhite", 255, 250, 240},
        {"forestgreen", 34, 139, 34},
        {"fuchsia", 255, 0, 255},
        {"gainsboro", 220, 220, 220},
        {"ghostwhite", 248, 248, 255},
        {"gold", 255, 215, 0},
        {"goldenrod", 218, 165, 32},
        {"gray", 128, 128, 128},
        {"green", 0, 128, 0},
        {"greenyellow", 173, 255, 47},
        {"honeydew", 240, 255, 240},
        {"hotpink", 255, 105, 180},
        {"indianred", 205, 92, 92},
        {"indigo", 75, 0, 130},
        {"ivory", 255, 255, 240},
        {"khaki", 240, 230, 140},
        {"lavender", 230, 230, 250},
        {"lavenderblush", 255, 240, 245},
        {"lawngreen", 124, 252, 0},
        {"lemonchiffon", 255, 250, 205},
        {"lightblue", 173, 216, 230},
        {"lightcoral", 240, 128, 128},
        {"lightcyan", 224, 255, 255},
        {"lightgoldenrodyellow", 250, 250, 210},
        {"lightgrey", 211, 211, 211},
        {"lightgreen", 144, 238, 144},
        {"lightpink", 255, 182, 193},
        {"lightsalmon", 255, 160, 122},
        {"lightseagreen", 32, 178, 170},
        {"lightskyblue", 135, 206, 250},
        {"lightslategray", 119, 136, 153},
        {"lightsteelblue", 176, 196, 222},
        {"lightyellow", 255, 255, 224},
        {"lime", 0, 255, 0},
        {"limegreen", 50, 205, 50},
        {"linen", 250, 240, 230},
        {"magenta", 255, 0, 255},
        {"maroon", 128, 0, 0},
        {"mediumaquamarine", 102, 205, 170},
        {"mediumblue", 0, 0, 205},
        {"mediumorchid", 186, 85, 211},
        {"mediumpurple", 147, 112, 219},
        {"mediumseagreen", 60, 179, 113},
        {"mediumslateblue", 123, 104, 238},
        {"mediumspringgreen", 0, 250, 154},
        {"mediumturquoise", 72, 209, 204},
        {"mediumvioletred", 199, 21, 133},
        {"midnightblue", 25, 25, 112},
        {"mintcream", 245, 255, 250},
        {"mistyrose", 255, 228, 225},
        {"moccasin", 255, 228, 181},
        {"navajowhite", 255, 222, 173},
        {"navy", 0, 0, 128},
        {"oldlace", 253, 245, 230},
        {"olive", 128, 128, 0},
        {"olivedrab", 107, 142, 35},
        {"orange", 255, 165, 0},
        {"orangered", 255, 69, 0},
        {"orchid", 218, 112, 214},
        {"palegoldenrod", 238, 232, 170},
        {"palegreen", 152, 251, 152},
        {"paleturquoise", 175, 238, 238},
        {"palevioletred", 219, 112, 147},
        {"papayawhip", 255, 239, 213},
        {"peachpuff", 255, 218, 185},
        {"peru", 205, 133, 63},
        {"pink", 255, 192, 203},
        {"plum", 221, 160, 221},
        {"powderblue", 176, 224, 230},
        {"purple", 128, 0, 128},
        {"red", 255, 0, 0},
        {"rosybrown", 188, 143, 143},
        {"royalblue", 65, 105, 225},
        {"saddlebrown", 139, 69, 19},
        {"salmon", 250, 128, 114},
        {"sandybrown", 244, 164, 96},
        {"seagreen", 46, 139, 87},
        {"seashell", 255, 245, 238},
        {"sienna", 160, 82, 45},
        {"silver", 192, 192, 192},
        {"skyblue", 135, 206, 235},
        {"slateblue", 106, 90, 205},
        {"slategray", 112, 128, 144},
        {"snow", 255, 250, 250},
        {"springgreen", 0, 255, 127},
        {"steelblue", 70, 130, 180},
        {"tan", 210, 180, 140},
        {"teal", 0, 128, 128},
        {"thistle", 216, 191, 216},
        {"tomato", 255, 99, 71},
        {"turquoise", 64, 224, 208},
        {"violet", 238, 130, 238},
        {"wheat", 245, 222, 179},
        {"white", 255, 255, 255},
        {"whitesmoke", 245, 245, 245},
        {"yellow", 255, 255, 0},
        {"yellowgreen", 154, 205, 50},
    };

    static VectorMap<String, Color> map;
    ONCELOCK {
        for(int i = 0; i < __countof(colors); i++)
            map.Add(colors[i].name, Color(colors[i].r, colors[i].g, colors[i].b));
    }

    return map.Get(color, map.Get(ToLower(color), Null));
}
Exemple #21
0
void ScanIML(CParser& parser, Array<ImlImage>& out_images,
             VectorMap<String, String>& out_settings)
{
	String name, bid;
	bool exp = false;
	while(!parser.IsEof())
	{
		if((bid = parser.ReadId()) == "IMAGE_META")
		{
			parser.Char('(');
			if(parser.IsString())
				name = parser.ReadString();
			else
				name = parser.ReadId();
			parser.PassChar(',');
			String value = parser.ReadString();
			parser.PassChar(')');
			out_settings.Add(name, value);
			if(value == "exp")
				exp = true;
		}
		else if(bid == "IMAGE_BEGIN" && parser.Char('(') && !IsNull(name = parser.ReadId()) && parser.Char(')'))
		{
			String encoded_data;
			out_settings.GetAdd("wince_16bit", "0");
			String id;
			bool first = true;
			while((id = parser.ReadId()) == "IMAGE_SCAN" && parser.Char('('))
			{
				bool first_in_row = true;
				while(parser.IsChar('\"'))
				{
					String scan = parser.ReadOneString();
					if(!first && first_in_row)
						encoded_data.Cat('\x80');
					first_in_row = first = false;
					encoded_data.Cat(scan);
				}
				if(!parser.Char(')'))
					break;
			}
			AlphaImageInfo image;
			bool accepted = false;
			if(parser.Char('(') && parser.ReadId() == name && parser.Char(','))
				if(id == "IMAGE_END"
				&& (image.size.cx = parser.ReadInt()) > 0 && parser.Char(',')
				&& (image.size.cy = parser.ReadInt()) > 0 && parser.Char(')'))
				{
					accepted = true;
				}
				else if(id == "IMAGE_PACKED" && parser.IsChar('\"'))
				{
					String d = parser.ReadOneString();
					if(parser.Char(')'))
					{
						StringStream ss(d);
						ss % image;
						if(!ss.IsError())
							accepted = true;
					}
				}

			if(name.GetLength() >= 6 && !memcmp(name, "_java_", 6))
				accepted = false;

			if(accepted)
			{
				if(name.GetLength() >= 4 && !memcmp(name, "im__", 4))
					name = Null;

				Image m = RLEToAlpha(encoded_data, image.size);
				ImageBuffer ib(m);
				ib.SetHotSpot(image.hotspot);
				m = ib;
				ImlImage& c = out_images.Add();
				c.name = name;
				c.image = m;
				c.exp = exp;
				exp = false;
			}
		}
		else if(bid == "IMAGE_BEGIN16" && parser.Char('(') && !IsNull(name = parser.ReadId()) && parser.Char(')'))
		{ //TODO: FIX THESE!!!
			out_settings.GetAdd("wince_16bit", "1");
			String encoded_data;
			String id;
			bool first = true;
			while((id = parser.ReadId()) == "IMAGE_SCAN16" && parser.Char('(') && parser.Char('L'))
			{
				bool first_in_row = true;
				while(parser.Char('\"'))
				{
					CParser::Pos pos = parser.GetPos();
					const char *end;
					end = pos.ptr; // TODO - remove
					String scan; // TODO = GetUnicodeScan(pos.ptr, &end);
					pos.ptr = end;
					parser.SetPos(pos);
					if(!parser.Char('\"'))
						break;
					if(!first && first_in_row)
						encoded_data.Cat('\x80');
					first_in_row = first = false;
					encoded_data.Cat(scan);
				}
				if(!parser.Char(')'))
					break;
			}
			AlphaImageInfo idata;
			bool accepted = false;
			if(id == "IMAGE_END16" && parser.Char('(') && parser.ReadId() == name && parser.Char(',')
			&& (idata.size.cx = parser.ReadInt()) > 0 && parser.Char(',')
			&& (idata.size.cy = parser.ReadInt()) > 0 && parser.Char(',')
			&& !IsNull(idata.hotspot.x = parser.ReadInt()) && parser.Char(',')
			&& !IsNull(idata.hotspot.y = parser.ReadInt()) && parser.Char(')'))
			{
				accepted = true;
			}

			if(accepted)
			{
				if(name.GetLength() >= 4 && !memcmp(name, "im__", 4))
					name = Null;

				Image m = RLEToAlpha(encoded_data, idata.size);
				ImageBuffer ib(m);
				ib.SetHotSpot(idata.hotspot);
				m = ib;
				ImlImage& c = out_images.Add();
				c.name = name;
				c.image = m;
				c.exp = exp;
				exp = false;
			}
		}
		else
			break;
	}
}
Exemple #22
0
void bigmailer::onSend()
{
	const String enter = "\r\n" ;
	if (messagePage.editor.IsModified())
		messagePage.Save() ;
	// mapa de los campos
	VectorMap<String, int> fldMap ;
	for (int i = 0; i < theDefList.fields.GetCount(); i++)
		fldMap.Add(theDefList.fields[i], i) ;

	String outHTML ;

	Index<String> css ;
	VectorMap<String, String> links ;
	String path = "./" ;
 	String html = EncodeHtml(messagePage.editor.Get(), css, links, path ) ;

	outHTML <<
		"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n"
		"<html>\r\n"
		"<head>\r\n"
		"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n"
		"<style>\r\n"
		<< AsCss( css ) << "\r\n"
		<< "</style>\r\n"
	     "</head>\r\n"
		   "<body>\r\n"
		<< html << "\r\n"
		<< "</body>\r\n"
		   "</html>\r\n" ;

	Progress prog ;
	prog.Set(0, theDefList.data.GetCount()) ;
	prog.Show() ;

	theDefList.errors.Clear() ;

	String theHtml ;
	for (int row = 0; row < theDefList.data.GetCount(); row++)
	{
		String addrTo = theDefList.data[row][1] ;
		if (addrTo.IsEmpty())
		{
			theDefList.errors.Add(t_("dirección incorrecta")) ;
			continue ;
		}

		if (prog.Canceled())
			break ;


		theHtml = outHTML ;

		String s = AsString(row+1) + " / " + AsString( theDefList.data.GetCount() ) ;
		prog.SetText(s) ;

		for (int i = 0; i < theDefList.fields.GetCount(); i++)
		{
			String toFind = "[%" + theDefList.fields[i] + "%]" ;
			int from = 0 ;
			while( (from = theHtml.Find(toFind, from )) != -1)
			{
				theHtml.Remove( from, toFind.GetCount() ) ;
				theHtml.Insert( from, theDefList.data[row][ fldMap.Get(theDefList.fields[i])] ) ;
			}
		}

		prog.SetPos(row+1) ;

		SmtpMailEx mail ;

		mail.Host( theCfg.smtpServer )
				.User( theCfg.user )
				.Password( theCfg.pass )
				.From( theMsg.from )
				.ReplyTo( theMsg.from )
				.To( addrTo )
				.Subject( theMsg.subject )
				.Text( "" )
		    .Attach("MENSAJE", theHtml, "text/html; charset=utf-8") ;

		if ( ! mail.Send() )
			theDefList.errors.Add(mail.GetError()) ;
		else
			theDefList.errors.Add("OK") ;

	}

	theDefList.Save() ;
}
Exemple #23
0
static void AddPath(VectorMap<String, String>& out, String key, String path)
{
	out.Add(key, path);
	out.Add(key + "_WIN", WinPath(path));
	out.Add(key + "_UNIX", UnixPath(path));
}
Exemple #24
0
void Append(VectorMap<String, ClipData>& data, const Image& img)
{
	data.Add(ClipFmt<Image>(), ClipData(img, sImage));
	data.Add("dib", ClipData(img, sDib));
}
Exemple #25
0
Vector<String> CppBuilder::CustomStep(const String& pf, const String& package_, bool& error)
{
	String package = Nvl(package_, mainpackage);
	String path = (*pf == '.' && pf[1] != '.') ? target : SourcePath(package, pf);
	String file = GetHostPath(path);
	String ext = ToLower(GetFileExt(pf));
	if(ext == ".ext") {
		Vector<String> files;
		Vector<String> dirs;
		sGatherAllExt(files, dirs, GetFileFolder(path), "");
		
		Index<String> pkg_files;
		Package pkg;
		pkg.Load(PackagePath(package));
		for(int i = 0; i < pkg.GetCount(); i++)
			pkg_files.Add(pkg[i]);
		
		Index<String> out;
		Index<String> include_path;
		String f = LoadFile(path);
		try {
			CParser p(f);
			while(!p.IsEof()) {
				if(p.Id("files")) {
					Vector<String> e = ReadPatterns(p);
					for(int i = 0; i < files.GetCount(); i++)
						for(int j = 0; j < e.GetCount(); j++) {
							String f = files[i];
							if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0)
								out.FindAdd(f);
						}
				}
				if(p.Id("exclude")) {
					ExtExclude(p, out);
				}
				if(p.Id("include_path")) {
					Vector<String> e = ReadPatterns(p);
					for(int j = 0; j < e.GetCount(); j++) {
						String ee = e[j];
						if(ee.Find('*') >= 0)
							for(int i = 0; i < dirs.GetCount(); i++) {
								String d = dirs[i];
								if(PatternMatch(e[j], d)) {
									include_path.FindAdd(d);
								}
							}
						else
							include_path.Add(ee);
					}
				}
				if(p.Id("exclude_path")) {
					ExtExclude(p, include_path);
				}
				if(p.Id("includes")) {
					Vector<String> e = ReadPatterns(p);
					for(int i = 0; i < files.GetCount(); i++)
						for(int j = 0; j < e.GetCount(); j++) {
							String f = files[i];
							if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0)
								include_path.FindAdd(GetFileFolder(f));
						}
				}
			}
		}
		catch(CParser::Error) {
			PutConsole("Invalid .ext file");
			error = true;
			return Vector<String>();
		}
		
		for(int i = 0; i < include_path.GetCount(); i++)
			include.Add(NormalizePath(include_path[i], GetFileFolder(path)));
		
		Vector<String> o;
		for(int i = 0; i < out.GetCount(); i++)
			o.Add(SourcePath(package, out[i]));
		return o;
	}
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Array< ::CustomStep >& mv = wspc.GetPackage(i).custom;
		for(int j = 0; j < mv.GetCount(); j++) {
			const ::CustomStep& m = mv[j];
			if(MatchWhen(m.when, config.GetKeys()) && m.MatchExt(ext)) {
				VectorMap<String, String> mac;
				AddPath(mac, "PATH", file);
				AddPath(mac, "RELPATH", pf);
				AddPath(mac, "DIR", GetFileFolder(PackagePath(package)));
				AddPath(mac, "FILEDIR", GetFileFolder(file));
				AddPath(mac, "PACKAGE", package);
				mac.Add("FILE", GetFileName(file));
				mac.Add("TITLE", GetFileTitle(file));
				AddPath(mac, "EXEPATH", GetHostPath(target));
				AddPath(mac, "EXEDIR", GetHostPath(GetFileFolder(target)));
				mac.Add("EXEFILE", GetFileName(target));
				mac.Add("EXETITLE", GetFileTitle(target));
				AddPath(mac, "OUTDIR", GetHostPath(outdir));
				//BW
				AddPath(mac, "OUTDIR", GetHostPath(GetFileFolder(target)));
				AddPath(mac, "OUTFILE", GetHostPath(GetFileName(target)));
				AddPath(mac, "OUTTITLE", GetHostPath(GetFileTitle(target)));

				mac.Add("INCLUDE", Join(include, ";"));

				Vector<String> out = Cuprep(m.output, mac, include);
				bool dirty = out.IsEmpty();
				for(int i = 0; !dirty && i < out.GetCount(); i++)
					dirty = (GetFileTime(file) > GetFileTime(out[i]));
				if(dirty) {
					HdependTimeDirty();
					PutConsole(GetFileName(file));
					Vector<String> cmd = Cuprep(m.command, mac, include);
					String cmdtext;
					for(int c = 0; c < cmd.GetCount(); c++) {
						PutVerbose(cmd[c]);
						if(!Cd(cmd[c]) && !Cp(cmd[c], package, error)) {
							String ctext = cmd[c];
							const char *cm = ctext;
							if(*cm == '?')
								cm++;
							if(*ctext != '?' && Execute(cm)) {
								for(int t = 0; t < out.GetCount(); t++)
									DeleteFile(out[t]);
								PutConsole("FAILED: " + ctext);
								error = true;
								return Vector<String>();
							}
						}
					}
				}
				return out;
			}
		}
	}
	Vector<String> out;
	out.Add(path);
	return out;
}
Exemple #26
0
	virtual bool operator()(int pos, const RichPara& para)
	{
		if(!IsNull(para.format.label)) 
			reflink->Add(para.format.label, link);
		return false;
	}