Ejemplo n.º 1
0
	integer ServiceApp::postMessage(ConstStrA command, const Args & args, SeqFileOutput output)
	{

		if (instance->imOwner()) return onMessage(command,args,output);

		AutoArrayStream<char, StaticAlloc<65536> > buffer;
		if (args.length() > 127) return onCommandLineError(args);
		buffer.write((char)(args.length()));
		buffer.copy(command.getFwIter());
		buffer.write(0);
		for(natural i = 0, cnt = args.length();i < cnt;i++){
			buffer.copy(WideToUtf8Reader<ConstStrW::Iterator>(args[i].getFwIter()));
			buffer.write(0);
		}
		AutoArray<byte,SmallAlloc<4096> > replybuff;
		replybuff.resize(instance->getReplyMaxSize());
		natural sz = instance->request(buffer.data(), buffer.length(), replybuff.data(), replybuff.length(), timeout);
		if (sz < sizeof(integer))
			throw ErrorMessageException(THISLOCATION,String("Invalid reply"));
		else {
			integer res = *reinterpret_cast<integer *>(replybuff.data());
			ConstStrA msg(reinterpret_cast<char *>(replybuff.data()+sizeof(integer)),sz - sizeof(integer));
			output.copy(msg.getFwIter());
			return res;
		}
	}
Ejemplo n.º 2
0
	SourceIndex::WordID getLocaseWordId(ConstStrA word)
	{
		Crc32 crc32;
		TypeConvWriter<Crc32 &, char> crc32chr(crc32);
		WideToUtf8Writer<TypeConvWriter<Crc32 &, char> &> crc32wchr(crc32chr);

		Utf8ToWideReader<ConstStrA::Iterator> wideChars(word.getFwIter());

		while (wideChars.hasItems()) crc32wchr.write(towupper(wideChars.getNext()));

		return crc32.getCrc32();
	}