当前位置: 首页>>代码示例>>C++>>正文


C++ BString::IFindFirst方法代码示例

本文整理汇总了C++中BString::IFindFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ BString::IFindFirst方法的具体用法?C++ BString::IFindFirst怎么用?C++ BString::IFindFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BString的用法示例。


在下文中一共展示了BString::IFindFirst方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ExtractXMLNode

status_t ExtractXMLNode(const BString &xml, const BString &element, const BString &attr,
	const BString &attrValue, BString &value) {
	
	status_t result = B_ERROR;
	BString temp = "<";
	temp << element;
	if ((attr.Length() > 0) && (attrValue.Length() > 0)) {
		temp << " " << attr << "=\""  << attrValue << "\"";
	};
	temp << ">";

	int32 open = xml.IFindFirst(temp);
	if (open != B_ERROR) {
		int start = open + temp.Length();
		temp = "";
		temp << "</" << element << ">";
		int32 end = xml.IFindFirst(temp, start);
		if (end != B_ERROR) {
			xml.CopyInto(value, start, end - start);
			result = B_OK;
		};
	};
	
	return result;
};
开发者ID:HaikuArchives,项目名称:IMKit,代码行数:25,代码来源:SSO.cpp

示例2: ExtractXMLChunk

status_t ExtractXMLChunk(const BString &xml, const BString &element, const BString &childElement,
	const BString &childElementValue, BString &value) {
	
	status_t result = B_ERROR;
	int32 start = B_ERROR;
	int32 offset = 0;
	BString startElement = "<";
	BString endElement = "</";
	BString child = "<";
	
	startElement << element << ">";
	endElement << element << ">";
	child << childElement << ">" << childElementValue << "</" << childElement << ">";

	while ((start = xml.IFindFirst(startElement, offset)) != B_ERROR) {
		int32 end = xml.IFindFirst(endElement, start);
		value = "";
		
		if (end != B_ERROR) {		
			xml.CopyInto(value, start, end - start);
			
			if (value.IFindFirst(child) != B_ERROR) {
				result = B_OK;
				return result;
			}
		};
		
		offset = start + startElement.Length();
	};
	
	return result;
};
开发者ID:HaikuArchives,项目名称:IMKit,代码行数:32,代码来源:SSO.cpp

示例3: To

BEmailMessage *
BEmailMessage::ForwardMessage(bool accountFromMail, bool includeAttachments)
{
	BString header = "------ Forwarded Message: ------\n";
	header << "To: " << To() << '\n';
	header << "From: " << From() << '\n';
	if (CC() != NULL) {
		// Can use CC rather than "Cc" since display only.
		header << "CC: " << CC() << '\n';
	}
	header << "Subject: " << Subject() << '\n';
	header << "Date: " << Date() << "\n\n";
	if (_text_body != NULL)
		header << _text_body->Text() << '\n';
	BEmailMessage *message = new BEmailMessage();
	message->SetBodyTextTo(header.String());

	// set the subject
	BString subject = Subject();
	if (subject.IFindFirst("fwd") == B_ERROR
		&& subject.IFindFirst("forward") == B_ERROR
		&& subject.FindFirst("FW") == B_ERROR)
		subject << " (fwd)";
	message->SetSubject(subject.String());

	if (includeAttachments) {
		for (int32 i = 0; i < CountComponents(); i++) {
			BMailComponent *cmpt = GetComponent(i);
			if (cmpt == _text_body || cmpt == NULL)
				continue;

			//---I am ashamed to have the written the code between here and the next comment
			// ... and you still managed to get it wrong ;-)), axeld.
			// we should really move this stuff into copy constructors
			// or something like that

			BMallocIO io;
			cmpt->RenderToRFC822(&io);
			BMailComponent *clone = cmpt->WhatIsThis();
			io.Seek(0, SEEK_SET);
			clone->SetToRFC822(&io, io.BufferLength(), true);
			message->AddComponent(clone);
		}
	}
	if (accountFromMail)
		message->SendViaAccountFrom(this);

	return message;
}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例4: if

bool
StringCompare(const BString &from, const BString &to, const char *mode,
			const bool &match_case)
{
	if (!mode)
	{
		debugger("NULL mode in StringCompare");
		return false;
	}
	
	if (strcmp(mode,"is") == 0)
		if (match_case)
			return from.Compare(to) == 0;
		else
			return from.ICompare(to) == 0;
	else if (strcmp(mode,"is not") == 0)
		if (match_case)
			return from.Compare(to) != 0;
		else
			return from.ICompare(to) != 0;
	else if (strcmp(mode,"contains") == 0)
		if (match_case)
			return to.FindFirst(from) >= 0;
		else
			return to.IFindFirst(from) >= 0;
	else if (strcmp(mode,"does not contain") == 0)
		if (match_case)
			return to.FindFirst(from) < 0;
		else
			return to.IFindFirst(from) < 0;
	else if (strcmp(mode,"starts with") == 0)
		if (match_case)
			return to.FindFirst(from) == 0;
		else
			return to.IFindFirst(from) == 0;
	else if (strcmp(mode,"ends with") == 0)
	{
		int32 pos;
		if (match_case)
			pos = to.FindLast(from);
		else
			pos = to.IFindLast(from);
		
		return (to.CountChars() - from.CountChars() == pos);
	}	
	
	return false;
}
开发者ID:puckipedia,项目名称:Filer,代码行数:48,代码来源:RuleRunner.cpp

示例5:

void
Emoticor::_findTokens(RunView *fTextView,BString text,int tokenstart, int16 cols ,int16 font ,int16 cols2 ,int16 font2)
{
	//******************************************
	// "Iteration is human, recursion is divine"
	//******************************************
	
	
	int32 		newindex = 0;
	BString cur;
	int i=tokenstart;
	
	while(config->FindString("face",i,&cur)==B_OK)
	//for(int i=tokenstart;i<config->numfaces;i++)
	{
		i++;	
		//if(config->FindString("face",i,&cur)!=B_OK) return;
		
		newindex=0;
		
		while(true)
		{
	 	 newindex=text.IFindFirst(cur.String(),0);
	 	 //printf("Try %d %s  -- match %d\n",i,cur->original.String(),newindex);
	 	 		
		if(newindex!=B_ERROR)
		{
			//take a walk on the left side ;)
			
			//printf("Found at %ld \n",newindex);
					
			if(newindex-1>=0)
			{
				BString left;
				text.CopyInto(left,0,newindex);
				//printf("ready to recourse! [%s]\n",left.String());
				_findTokens(fTextView,left,tokenstart+1,cols,font,cols2,font2);
			}
			
				
			text.Remove(0,newindex+cur.Length());
			
			//printf("remaning [%s] printed  [%s]\n",text.String(),cur->original.String());
					
			fTextView->Append(cur.String(),cols2,cols2,font2);
			
			if(text.Length()==0) return; //useless stack
		}
		else
		 break;
				
		}
	}
	
	fTextView->Append(text.String(),cols,cols,font);
	
}
开发者ID:HaikuArchives,项目名称:IMKit,代码行数:57,代码来源:Emoticor.cpp

示例6: count

	void
	EntryCreated(WatchedFile* file)
	{
		//ListItem* item1 = new ListItem(file->entry.name, file);
		//fListView->AddItem(item1);

		fItemCount++;
		BString count("Count: ");
		count << fItemCount;
		fCountView->SetText(count);

		const ssize_t bufferSize = 256;
		char buffer[bufferSize];
		BNode node(&file->entry);

		ssize_t readBytes;
		readBytes = node.ReadAttr("Audio:Artist", B_STRING_TYPE, 0, buffer,
			bufferSize);
		if (readBytes < 0)
			readBytes = 0;
		if (readBytes >= bufferSize)
			readBytes = bufferSize - 1;
		buffer[readBytes] = '\0';

		BString artist = (strcmp(buffer, "") == 0) ? "Unknown" : buffer;
		ListItem* artistItem = _AddSuperItem(artist, fArtistList, NULL);

		readBytes = node.ReadAttr("Audio:Album", B_STRING_TYPE, 0, buffer,
			bufferSize);
		if (readBytes < 0)
			readBytes = 0;
		buffer[readBytes] = '\0';
		BString album = (strcmp(buffer, "") == 0) ? "Unknown" : buffer;
		ListItem* albumItem = _AddSuperItem(album, fAlbumList, artistItem);

		readBytes = node.ReadAttr("Media:Title", B_STRING_TYPE, 0, buffer,
			bufferSize);
		if (readBytes < 0)
			readBytes = 0;
		buffer[readBytes] = '\0';
		BString title= (strcmp(buffer, "") == 0) ? file->entry.name
			: buffer;

		ListItem* item = new ListItem(title, file);
		file->cookie = item;
		fListView->AddUnder(item, albumItem);
		fListView->SortItemsUnder(albumItem, true, StringItemComp);

		if (fQueryString == "")
			return;
		if (title.IFindFirst(fQueryString) >= 0) {
			fListView->Expand(artistItem);
			fListView->Expand(albumItem);
		} else if (album.IFindFirst(fQueryString) >= 0) {
			fListView->Expand(artistItem);
		}
	};
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:57,代码来源:MusicCollectionWindow.cpp

示例7: mime

bool
BUrl::HasPreferredApplication() const
{
	BString appSignature = PreferredApplication();
	BMimeType mime(appSignature.String());

	if (appSignature.IFindFirst("application/") == 0
		&& mime.IsValid())
		return true;

	return false;
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例8: FirstSingleKnownAs

int32 ClientAgent::FirstSingleKnownAs(const BString& data, const BString& target) const
{
	int32 place;

	if ((place = data.IFindFirst(target)) != B_ERROR &&
		(place == 0 || isspace(data[place - 1]) || ispunct(data[place - 1])) &&
		(place + target.Length() == data.Length() || isspace(data[place + target.Length()]) ||
		 ispunct(data[place + target.Length()]) ||
		 (int)data[place + target.Length()] <= 0xa)) // null or newline
		return place;

	return B_ERROR;
}
开发者ID:HaikuArchives,项目名称:Vision,代码行数:13,代码来源:ClientAgent.cpp

示例9: LoadAliases

void VisionApp::LoadAliases(void)
{
	BPath settingsPath;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &settingsPath) < B_OK) return;
	settingsPath.Append(kAliasPathName);
	if (settingsPath.InitCheck() < B_OK) return;
	BFile file(settingsPath.Path(), B_READ_ONLY);
	if (file.InitCheck() == B_OK) {
		BString data;
		char buffer[2048];
		memset(buffer, 0, sizeof(buffer));
		while (file.Read((void*)buffer, 2048) > 0) {
			data += buffer;
			memset(buffer, 0, sizeof(buffer));
		}
		file.Unset();
		while (data.Length() > 0) {
			BString cmd, value;
			int32 idx = data.IFindFirst("\t");
			if (idx != B_ERROR) {
				data.MoveInto(cmd, 0, idx);
				data.Remove(0, 1);
			} else {
				break;
			}
			idx = data.IFindFirst("\n");
			if (idx != B_ERROR) {
				data.MoveInto(value, 0, idx);
				data.Remove(0, 1);
			} else {
				break;
			}
			fAliases[cmd.ToUpper()] = value;
		}
	}
}
开发者ID:HaikuArchives,项目名称:Vision,代码行数:36,代码来源:Vision.cpp

示例10:

_EXPORT status_t
extract_from_header(const BString& header, const BString& field,
	BString& target)
{
	int32 headerLength = header.Length();
	int32 fieldEndPos = 0;
	while (true) {
		int32 pos = header.IFindFirst(field, fieldEndPos);
		if (pos < 0)
			return B_BAD_VALUE;
		fieldEndPos = pos + field.Length();
		
		if (pos != 0 && header.ByteAt(pos - 1) != '\n')
			continue;
		if (header.ByteAt(fieldEndPos) == ':')
			break;
	}
	fieldEndPos++;

	int32 crPos = fieldEndPos;
	while (true) {
		fieldEndPos = crPos;
		crPos = header.FindFirst('\n', crPos);
		if (crPos < 0)
			crPos = headerLength;
		BString temp;
		header.CopyInto(temp, fieldEndPos, crPos - fieldEndPos);
		if (header.ByteAt(crPos - 1) == '\r') {
			temp.Truncate(temp.Length() - 1);
			temp += " ";
		}
		target += temp;
		crPos++;
		if (crPos >= headerLength)
			break;
		char nextByte = header.ByteAt(crPos);
		if (nextByte != ' ' && nextByte != '\t')
			break;
		crPos++;
	}

	size_t bufferSize = target.Length();
	char* buffer = target.LockBuffer(bufferSize);
	size_t length = rfc2047_to_utf8(&buffer, &bufferSize, bufferSize);
	target.UnlockBuffer(length);

	return B_OK;
}
开发者ID:,项目名称:,代码行数:48,代码来源:

示例11: f

void
UrlWrapper::RefsReceived(BMessage* msg)
{
	char buff[B_PATH_NAME_LENGTH];
	int32 index = 0;
	entry_ref ref;
	char* args[] = { const_cast<char*>("urlwrapper"), buff, NULL };
	status_t err;

	while (msg->FindRef("refs", index++, &ref) == B_OK) {
		BFile f(&ref, B_READ_ONLY);
		BNodeInfo ni(&f);
		BString mimetype;
		BString extension(ref.name);
		extension.Remove(0, extension.FindLast('.') + 1);
		if (f.InitCheck() == B_OK && ni.InitCheck() == B_OK) {
			ni.GetType(mimetype.LockBuffer(B_MIME_TYPE_LENGTH));
			mimetype.UnlockBuffer();

			// Internet Explorer Shortcut
			if (mimetype == "text/x-url" || extension == "url") {
				// http://filext.com/file-extension/URL
				// http://www.cyanwerks.com/file-format-url.html
				off_t size;
				if (f.GetSize(&size) < B_OK)
					continue;
				BString contents;
				BString url;
				if (f.ReadAt(0LL, contents.LockBuffer(size), size) < B_OK)
					continue;
				contents.UnlockBuffer();
				while (contents.Length()) {
					BString line;
					int32 cr = contents.FindFirst('\n');
					if (cr < 0)
						cr = contents.Length();
					//contents.MoveInto(line, 0, cr);
					contents.CopyInto(line, 0, cr);
					contents.Remove(0, cr+1);
					line.RemoveAll("\r");
					if (!line.Length())
						continue;
					if (!line.ICompare("URL=", 4)) {
						line.MoveInto(url, 4, line.Length());
						break;
					}
				}
				if (url.Length()) {
					BPrivate::Support::BUrl u(url.String());
					args[1] = (char*)u.String();
					mimetype = kURLHandlerSigBase;
					mimetype += u.Proto();
					err = be_roster->Launch(mimetype.String(), 1, args + 1);
					if (err != B_OK && err != B_ALREADY_RUNNING)
						err = be_roster->Launch(kAppSig, 1, args + 1);
					continue;
				}
			}
			if (mimetype == "text/x-webloc" || extension == "webloc") {
				// OSX url shortcuts
				// XML file + resource fork
				off_t size;
				if (f.GetSize(&size) < B_OK)
					continue;
				BString contents;
				BString url;
				if (f.ReadAt(0LL, contents.LockBuffer(size), size) < B_OK)
					continue;
				contents.UnlockBuffer();
				int state = 0;
				while (contents.Length()) {
					BString line;
					int32 cr = contents.FindFirst('\n');
					if (cr < 0)
						cr = contents.Length();
					contents.CopyInto(line, 0, cr);
					contents.Remove(0, cr+1);
					line.RemoveAll("\r");
					if (!line.Length())
						continue;
					int32 s, e;
					switch (state) {
						case 0:
							if (!line.ICompare("<?xml", 5))
								state = 1;
							break;
						case 1:
							if (!line.ICompare("<plist", 6))
								state = 2;
							break;
						case 2:
							if (!line.ICompare("<dict>", 6))
								state = 3;
							break;
						case 3:
							if (line.IFindFirst("<key>URL</key>") > -1)
								state = 4;
							break;
						case 4:
							if ((s = line.IFindFirst("<string>")) > -1
//.........这里部分代码省略.........
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:urlwrapper.cpp

示例12: num


//.........这里部分代码省略.........
				BString theNick (GetWord(data, 4));
				BString tempString ("[x] "),
							theReason (RestOfString(data, 5));
				theReason.RemoveFirst(":");
				tempString += "Away: ";
				tempString += theReason;
				tempString += '\n';

				if (fRemoteAwayMessages.find(theNick) != fRemoteAwayMessages.end())
				{
					if (fRemoteAwayMessages[theNick] == theReason)
					{
						return true;
					}
				}
				fRemoteAwayMessages[theNick] = theReason;
				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
			}
			return true;

		case RPL_USERHOST:				// 302
			{
				BString theHost (GetWord (data, 4)),
								theHostname (GetAddress (theHost.String()));
				theHost.RemoveFirst (":");

				BString tempString (RestOfString (data, 4));
				tempString.RemoveFirst (":");
				tempString.Append ("\n");
				Display (tempString.String());

				if (fGetLocalIP && (tempString.IFindFirst (fMyNick.String()) == 0))
				{
					fGetLocalIP = false;
					struct addrinfo *info;
					struct addrinfo hints;
					memset(&hints, 0, sizeof(addrinfo));
					hints.ai_family = AF_UNSPEC;
					hints.ai_socktype = SOCK_STREAM;
					hints.ai_protocol = IPPROTO_TCP;
					int result = getaddrinfo(theHostname.String(), NULL, &hints, &info);
					if (result == 0)
					{
						char addr_buf[INET6_ADDRSTRLEN];
						getnameinfo(info->ai_addr, info->ai_addrlen, addr_buf, sizeof(addr_buf),
						NULL, 0, NI_NUMERICHOST);
						fLocalip = addr_buf;
						printf("Got address: %s\n", fLocalip.String());
						freeaddrinfo(info);
						return true;
					}
				}
			}
			return true;

		case RPL_ISON:					 // 303
			{
				BString nicks (RestOfString (data, 4));
				BString onlined, offlined;

				nicks.RemoveFirst (":");

				int hasChanged (0);
开发者ID:jessicah,项目名称:Vision,代码行数:66,代码来源:ParseENums.cpp

示例13: QueryListRep

QueryEntryListCollection::QueryEntryListCollection(Model* model,
	BHandler* target, PoseList* oldPoseList)
	:	fQueryListRep(new QueryListRep(new BObjectList<BQuery>(5, true)))
{
	Rewind();
	attr_info info;
	BQuery query;

	if (!model->Node()) {
		fStatus = B_ERROR;
		return;
	}

	// read the actual query string
	fStatus = model->Node()->GetAttrInfo(kAttrQueryString, &info);
	if (fStatus != B_OK)
		return;

	BString buffer;
	if (model->Node()->ReadAttr(kAttrQueryString, B_STRING_TYPE, 0,
		buffer.LockBuffer((int32)info.size),
			(size_t)info.size) != info.size) {
		fStatus = B_ERROR;
		return;
	}

	buffer.UnlockBuffer();

	// read the extra options
	MoreOptionsStruct saveMoreOptions;
	if (ReadAttr(model->Node(), kAttrQueryMoreOptions,
			kAttrQueryMoreOptionsForeign, B_RAW_TYPE, 0, &saveMoreOptions,
			sizeof(MoreOptionsStruct),
			&MoreOptionsStruct::EndianSwap) != kReadAttrFailed) {
		fQueryListRep->fShowResultsFromTrash = saveMoreOptions.searchTrash;
	}

	fStatus = query.SetPredicate(buffer.String());

	fQueryListRep->fOldPoseList = oldPoseList;
	fQueryListRep->fDynamicDateQuery = false;

	fQueryListRep->fRefreshEveryHour = false;
	fQueryListRep->fRefreshEveryMinute = false;

	if (model->Node()->ReadAttr(kAttrDynamicDateQuery, B_BOOL_TYPE, 0,
			&fQueryListRep->fDynamicDateQuery,
			sizeof(bool)) != sizeof(bool)) {
		fQueryListRep->fDynamicDateQuery = false;
	}

	if (fQueryListRep->fDynamicDateQuery) {
		// only refresh every minute on debug builds
		fQueryListRep->fRefreshEveryMinute = buffer.IFindFirst("second") != -1
			|| buffer.IFindFirst("minute") != -1;
		fQueryListRep->fRefreshEveryHour = fQueryListRep->fRefreshEveryMinute
			|| buffer.IFindFirst("hour") != -1;

#if !DEBUG
		// don't refresh every minute unless we are running debug build
		fQueryListRep->fRefreshEveryMinute = false;
#endif
	}

	if (fStatus != B_OK)
		return;

	bool searchAllVolumes = true;
	status_t result = B_OK;

	// get volumes to perform query on
	if (model->Node()->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) {
		char* buffer = NULL;

		if ((buffer = (char*)malloc((size_t)info.size)) != NULL
			&& model->Node()->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0,
				buffer, (size_t)info.size) == info.size) {

			BMessage message;
			if (message.Unflatten(buffer) == B_OK) {
				for (int32 index = 0; ;index++) {
					ASSERT(index < 100);
					BVolume volume;
						// match a volume with the info embedded in
						// the message
					result = MatchArchivedVolume(&volume, &message, index);
					if (result == B_OK) {
						// start the query on this volume
						result = FetchOneQuery(&query, target,
							fQueryListRep->fQueryList, &volume);
						if (result != B_OK)
							continue;

						searchAllVolumes = false;
					} else if (result != B_DEV_BAD_DRIVE_NUM) {
						// if B_DEV_BAD_DRIVE_NUM, the volume just isn't
						// mounted this time around, keep looking for more
						// if other error, bail
						break;
					}
//.........这里部分代码省略.........
开发者ID:RTOSkit,项目名称:haiku,代码行数:101,代码来源:QueryPoseView.cpp

示例14: file

char *PasterPastebinCa::_Paste(entry_ref *ref)
{
	CURL *curl = curl_easy_init();
	BString postData;
	BString response;
	BString filename;
	BFile file(ref, B_READ_ONLY);
	off_t size;
	char *content;
	char *encoded;
	char *type;
	
	fErrorString = NULL;
	
	_Progress();
	
	if (!curl)
	{
		fErrorString = new BString(E"Failed to initialize curl.");
		goto end;	
	}
	
	if (file.GetSize(&size) != B_OK)
	{
		fErrorString = new BString(E"Can't read file.");
		goto end;
	}
	
	if (!(content = new char[size + 1]))
	{
		fErrorString = new BString(E"Out of memory.");
		goto end;
	}
	
	content[file.Read((void *)content, size)] = '\0';
	
	if (strlen(content) == 0)
	{
		fErrorString = new BString(E"Can't read file.");
		goto end;
	}
	
	filename = ref->name;
	for (uint8 i = 0; i < sizeof(TYPES)/20; i++)
	{
		if (filename.IFindFirst(TYPES[i][0]) != B_ERROR)
		{
			type = (char *) TYPES[i][1];
			break;
		}
	}
	
	encoded = curl_easy_escape(curl, ref->name, strlen(ref->name));
	
	postData << "name=" << encoded << "&type=" << type << "&expiry=";
	free(encoded);
	encoded = curl_easy_escape(curl, PASTE_DESCRIPTION, strlen(PASTE_DESCRIPTION));
	postData << "&description=" << encoded;
	free(encoded);
	encoded = curl_easy_escape(curl, content, strlen(content));
	postData << "&content=" << encoded;
	free(encoded);
	free(content);
	
	curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
    curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _CurlWriteFunction);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
    curl_easy_setopt(curl, CURLOPT_POST, 1);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.String());
    curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
    curl_easy_setopt(curl, CURLOPT_URL, PASTEBIN_URL);
    
    if (curl_easy_perform(curl))
    {
		fErrorString = new BString(E"Network failure.");
		goto end;
	}
	
	if (response.FindFirst("SUCCESS:") == B_ERROR)
	{
		fErrorString = new BString(E"Paste rejected.");
		goto end;
	}
	
	success = true;
	fLink = new BString;
	
	response.CopyInto(*fLink, response.FindFirst(":") + 1, 100);
	fLink->Prepend(PASTEBIN_ROOT);
	
	cout << "Server response: " << response << endl;
	
end:	
	curl_easy_cleanup(curl);
	if (!success) return (char *)fErrorString->String();
	else return (char *)fLink->String();
}
开发者ID:sevcsik,项目名称:Paste-O-Matic,代码行数:98,代码来源:PasterPastebinCa.cpp


注:本文中的BString::IFindFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。