void CConfigPostHandler::optionString(const char *szName, const char *szDescription, char *szValue, size_t nSize, const char *szDefault) {
	const auto found = m_mValues.find(createOptionKey(szName));
	if (found != m_mValues.end() && found->second.compare(szDefault)!=0) {
		std::string capped(found->second);
		if (capped.length() + 1 > nSize)
			capped=capped.substr(0,nSize-1);
		m_pWriter->writeUInt(ConfigString);
		m_pWriter->writeString(szName);
		m_pWriter->writeString(capped.c_str());
	}
}
예제 #2
0
status_t RuleFilter::ProcessMailMessage
(
	BPositionIO** , BEntry* entry,
	BMessage* io_headers, BPath* io_folder, const char* 
) {
	const char *data;
	if (!attribute)
		return B_OK; //----That field doesn't exist? NO match
	
	if (io_headers->FindString(attribute,&data) < B_OK) { //--Maybe the capitalization was wrong?
		BString capped(attribute);
		capped.CapitalizeEachWord(); //----Enfore capitalization
		if (io_headers->FindString(capped.String(),&data) < B_OK) //----This time it's *really* not there
			return B_OK; //---No match
	}
	
	if (data == NULL) //--- How would this happen? No idea
		return B_OK;
	
	if (!matcher.Match(data))
		return B_OK; //-----There wasn't an error. We're just not supposed to do anything
	
	switch (do_what) {
		case Z_MOVE_TO:
			if (io_headers->ReplaceString("DESTINATION",arg) != B_OK)
				io_headers->AddString("DESTINATION",arg);
			break;
		case Z_TRASH:
			return B_MAIL_DISCARD;
		case Z_FLAG:
			{
			BString string = arg;
			BNode(entry).WriteAttrString("MAIL:filter_flags",&string);
			}
			break;
		case Z_SET_REPLY:
			BNode(entry).WriteAttr("MAIL:reply_with",B_INT32_TYPE,0,&chain_id,4);
			break;
		case Z_SET_READ:
			if (io_headers->ReplaceString("STATUS", "Read") != B_OK)
				io_headers->AddString("STATUS", "Read");
			break;			
		default:
			fprintf(stderr,"Unknown do_what: 0x%04x!\n",do_what);
	}
	
	return B_OK;
}