本文整理汇总了C++中BString::MoveInto方法的典型用法代码示例。如果您正苦于以下问题:C++ BString::MoveInto方法的具体用法?C++ BString::MoveInto怎么用?C++ BString::MoveInto使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BString
的用法示例。
在下文中一共展示了BString::MoveInto方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SplitEmail
status_t SplitEmail(BString email, BString &username, BString &domain) {
status_t result = B_ERROR;
int at = email.FindFirst("@");
if (at > B_ERROR) {
email.MoveInto(username, 0, at);
email.MoveInto(domain, 1, email.Length() - 1);
result = B_OK;
};
return result;
}
示例2:
void
BAddressContactField::_PopValue(BString& str, BString& value)
{
int32 index = str.FindFirst(fDivider, 0);
printf("%s\n", str.String());
if (index == B_ERROR && str.Length() < 1) {
value.SetTo("");
return;
}
str.MoveInto(value, 0, index);
str.Remove(0,1);
}
示例3:
void
BAddressContactField::_PopValue(BString& str, BString& value)
{
int32 index = str.FindFirst(";", 0);
if (index == B_ERROR) {
fWellFormed = false;
value.SetTo("");
return;
}
str.MoveInto(value, 0, index);
str.Remove(0,1);
}
示例4: 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;
}
}
}
示例5: Submit
void ClientAgent::Submit(const char* buffer, bool clear, bool fHistoryAdd)
{
BString cmd;
if (fHistoryAdd)
cmd = fHistory->Submit(buffer);
else
cmd = buffer;
if (clear) fInput->SetText("");
if (cmd.Length() && !SlashParser(cmd.String()) && cmd[0] != '/') {
BString tmp;
// break strings up by 440 lens to ensure user doesn't lose data
while (cmd.Length() > 0) {
cmd.MoveInto(tmp, 0, Get440Len(cmd.String()));
Parser(tmp.String());
tmp = "";
}
}
}
示例6: cddbCommand
status_t
CDDBServer::Query(uint32 cddbID, const scsi_toc_toc* toc,
QueryResponseList& queryResponses)
{
if (_OpenConnection() != B_OK)
return B_ERROR;
// Convert CDDB id to hexadecimal format.
char hexCddbId[9];
sprintf(hexCddbId, "%08" B_PRIx32, cddbID);
// Assemble the Query command.
int32 numTracks = toc->last_track + 1 - toc->first_track;
BString cddbCommand("cddb query ");
cddbCommand << hexCddbId << " " << numTracks << " ";
// Add track offsets in frames.
for (int32 i = 0; i < numTracks; ++i) {
const scsi_cd_msf& start = toc->tracks[i].start.time;
uint32 startFrameOffset = start.minute * kFramesPerMinute +
start.second * kFramesPerSecond + start.frame;
cddbCommand << startFrameOffset << " ";
}
// Add total disc time in seconds. Last track is lead-out.
const scsi_cd_msf& lastTrack = toc->tracks[numTracks].start.time;
uint32 totalTimeInSeconds = lastTrack.minute * 60 + lastTrack.second;
cddbCommand << totalTimeInSeconds;
BString output;
status_t result = _SendCommand(cddbCommand, output);
if (result == B_OK) {
// Remove the header from the reply.
output.Remove(0, output.FindFirst("\r\n\r\n") + 4);
// Check status code.
BString statusCode;
output.MoveInto(statusCode, 0, 3);
if (statusCode == "210" || statusCode == "211") {
// TODO(bga): We can get around with returning the first result
// in case of multiple matches, but we most definitely need a
// better handling of inexact matches.
if (statusCode == "211")
printf("Warning : Inexact match found.\n");
// Multiple results, remove the first line and parse the others.
output.Remove(0, output.FindFirst("\r\n") + 2);
} else if (statusCode == "200") {
// Remove the first char which is a left over space.
output.Remove(0, 1);
} else if (statusCode == "202") {
// No match found.
printf("Error : CDDB entry for id %s not found.\n", hexCddbId);
return B_ENTRY_NOT_FOUND;
} else {
// Something bad happened.
if (statusCode.Trim() != "") {
printf("Error : CDDB server status code is %s.\n",
statusCode.String());
} else {
printf("Error : Could not find any status code.\n");
}
return B_ERROR;
}
// Process all entries.
bool done = false;
while (!done) {
QueryResponseData* responseData = new QueryResponseData;
output.MoveInto(responseData->category, 0, output.FindFirst(" "));
output.Remove(0, 1);
output.MoveInto(responseData->cddbID, 0, output.FindFirst(" "));
output.Remove(0, 1);
output.MoveInto(responseData->artist, 0, output.FindFirst(" / "));
output.Remove(0, 3);
output.MoveInto(responseData->title, 0, output.FindFirst("\r\n"));
output.Remove(0, 2);
queryResponses.AddItem(responseData);
if (output == "" || output == ".\r\n") {
// All returned data was processed exit the loop.
done = true;
}
}
} else {
printf("Error sending CDDB command : \"%s\".\n", cddbCommand.String());
}
_CloseConnection();
return result;
//.........这里部分代码省略.........
示例7:
status_t
BNetworkCookieJar::Unflatten(type_code, const void* buffer, ssize_t size)
{
BString flattenedCookies;
flattenedCookies.SetTo(reinterpret_cast<const char*>(buffer), size);
while (flattenedCookies.Length() > 0) {
BNetworkCookie tempCookie;
BString tempCookieLine;
int32 endOfLine = flattenedCookies.FindFirst('\n', 0);
if (endOfLine == -1)
tempCookieLine = flattenedCookies;
else {
flattenedCookies.MoveInto(tempCookieLine, 0, endOfLine);
flattenedCookies.Remove(0, 1);
}
if (tempCookieLine.Length() != 0 && tempCookieLine[0] != '#') {
for (int32 field = 0; field < 7; field++) {
BString tempString;
int32 endOfField = tempCookieLine.FindFirst('\t', 0);
if (endOfField == -1)
tempString = tempCookieLine;
else {
tempCookieLine.MoveInto(tempString, 0, endOfField);
tempCookieLine.Remove(0, 1);
}
switch (field) {
case 0:
tempCookie.SetDomain(tempString);
break;
case 1:
// TODO: Useless field ATM
break;
case 2:
tempCookie.SetPath(tempString);
break;
case 3:
tempCookie.SetSecure(tempString == "TRUE");
break;
case 4:
tempCookie.SetExpirationDate(atoi(tempString));
break;
case 5:
tempCookie.SetName(tempString);
break;
case 6:
tempCookie.SetValue(tempString);
break;
} // switch
} // for loop
AddCookie(tempCookie);
}
}
return B_OK;
}
示例8: 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
//.........这里部分代码省略.........
示例9: FindFirst
status_t
BUrl::_ParseAndSplit()
{
// proto:[//]user:[email protected]:port/path
int32 v;
BString left;
v = FindFirst(":");
if (v < 0)
return B_BAD_VALUE;
// TODO: proto and host should be lowercased.
// see http://en.wikipedia.org/wiki/URL_normalization
CopyInto(fProto, 0, v);
CopyInto(left, v + 1, Length() - v);
// TODO: RFC1738 says the // part should indicate the uri follows the
// u:[email protected]:p/path convention, so it should be used to check for special cases.
if (left.FindFirst("//") == 0)
left.RemoveFirst("//");
fFull = left;
// path part
// actually some apps handle file://[host]/path
// but I have no idea what proto it implies...
// or maybe it's just to emphasize on "localhost".
v = left.FindFirst("/");
if (v == 0 || fProto == "file") {
fPath = left;
return B_OK;
}
// some protos actually implies path if it's the only component
if ((v < 0) && (fProto == "beshare" || fProto == "irc")) {
fPath = left;
return B_OK;
}
if (v > -1) {
left.MoveInto(fPath, v+1, left.Length()-v);
left.Remove(v, 1);
}
// user:[email protected]
v = left.FindFirst("@");
if (v > -1) {
left.MoveInto(fUser, 0, v);
left.Remove(0, 1);
v = fUser.FindFirst(":");
if (v > -1) {
fUser.MoveInto(fPass, v, fUser.Length() - v);
fPass.Remove(0, 1);
}
} else if (fProto == "finger") {
// single component implies user
// see also: http://www.subir.com/lynx/lynx_help/lynx_url_support.html
fUser = left;
return B_OK;
}
// host:port
v = left.FindFirst(":");
if (v > -1) {
left.MoveInto(fPort, v + 1, left.Length() - v);
left.Remove(v, 1);
}
// not much left...
fHost = left;
return B_OK;
}
示例10: Receiver
int32 MSNConnection::Receiver(void *con) {
LOG(kProtocolName, liLow, "C[r] %lX: Receiver init", con);
MSNConnection *connection = reinterpret_cast<MSNConnection *>(con);
const uint32 kSleep = 2000000;
BMessenger **kMsgr = &connection->fSockMsgr;
int32 socket = 0;
if ( !(*kMsgr)->IsValid() ) {
LOG(kProtocolName, liLow, "C[r] %lX: Messenger wasn't valid!", connection);
return B_ERROR;
}
BMessage reply;
socket = connection->fSock;
struct fd_set read;
struct fd_set error;
int16 bytes = 0;
int32 processed = 0;
char buffer[1024];
BString commandBuff = "";
int32 kNewLineLen = strlen("\r\n");
LOG(kProtocolName, liLow, "C[r] %lX: Starting receiver loop", connection);
while ((*kMsgr)->IsValid() == true) {
FD_ZERO(&read);
FD_ZERO(&error);
FD_SET(socket, &read);
FD_SET(socket, &error);
memset(buffer, 0, sizeof(buffer));
if (select(socket + 1, &read, NULL, &error, NULL) > 0) {
if (FD_ISSET(socket, &error)) {
LOG(kProtocolName, liLow, "C[r] %lX: Got socket error", connection);
snooze(kSleep);
continue;
};
if (FD_ISSET(socket, &read)) {
bytes = recv(socket, buffer, sizeof(buffer), 0);
if (bytes > 0) {
commandBuff.Append(buffer, bytes);
processed += bytes;
} else {
if ((*kMsgr)->IsValid() == false) return B_OK;
LOG(kProtocolName, liLow, "C[r] %lX: Socket got less than 0 (or 0)",
connection);
perror("SOCKET ERROR");
BMessage msg(msnmsgCloseConnection);
msg.AddPointer("connection", con);
connection->fManMsgr.SendMessage(&msg);
connection->fState = otOffline;
return B_ERROR;
};
};
};
int32 commandLen = commandBuff.FindFirst("\r\n");
while (commandLen > 0) {
BString command = "";
int32 totalLen = commandBuff.Length();
commandBuff.MoveInto(command, 0, commandLen + kNewLineLen);
processed = totalLen - (commandLen + kNewLineLen);
Command *comm = new Command("");
comm->MakeObject(command.String());
int32 payloadLen = 0;
if (comm->ExpectsPayload(&payloadLen) == true) {
LOG(kProtocolName, liDebug, "C[r] %lX: Payload of %i, have %i bytes",
connection, payloadLen, processed);
while (processed < payloadLen) {
FD_ZERO(&read);
FD_ZERO(&error);
FD_SET(socket, &read);
FD_SET(socket, &error);
memset(buffer, 0, sizeof(buffer));
if (select(socket + 1, &read, NULL, &error, NULL) > 0) {
if (FD_ISSET(socket, &error)) {
LOG(kProtocolName, liLow, "C[r] %lX: Got socket error",
connection);
snooze(kSleep);
continue;
};
//.........这里部分代码省略.........
示例11: send
void
MessageWindow::Parser (const char *buffer)
{
if(!dChat)
{
BMessage send (M_SERVER_SEND);
AddSend (&send, "PRIVMSG ");
AddSend (&send, chatee);
AddSend (&send, " :");
AddSend (&send, buffer);
AddSend (&send, endl);
}
else if (dConnected)
{
BString outTemp (buffer);
outTemp << "\n";
if (send(acceptSocket, outTemp.String(), outTemp.Length(), 0) < 0)
{
dConnected = false;
Display ("DCC chat terminated.\n", 0);
return;
}
}
else
return;
BFont myFont (bowser_app->GetClientFont (F_TEXT));
Display ("<", &textColor, &myFont, bowser_app->GetStampState());
Display (myNick.String(), &myNickColor);
Display ("> ", 0);
BString sBuffer (buffer);
int32 place;
while ((place = FirstSingleKnownAs (sBuffer, chatee)) != B_ERROR)
{
BString tempString;
if (place)
{
sBuffer.MoveInto (tempString, 0, place);
Display (tempString.String(), 0);
}
sBuffer.MoveInto (tempString, 0, chatee.Length());
Display (tempString.String(), &nickColor);
if (atoi (autoNickTime.String()) > 0)
{
nickTimes.AddItem (new TimedNick (
chatee.String(),
system_time()));
}
}
if (sBuffer.Length())
Display (sBuffer.String(), 0);
Display ("\n", 0);
}
示例12: CountItems
void
QPopupMenu::EntryCreated(const entry_ref &ref, ino_t node)
{
BNode file;
if (file.SetTo(&ref) < B_OK)
return;
// Make sure the pop-up menu is ready for additions. Need a bunch of
// groups at the top, a divider line, and miscellaneous people added below
// the line.
int32 items = CountItems();
if (!items)
AddSeparatorItem();
// Does the file have a group attribute? OK to have none.
BString groups;
const char *kNoGroup = "NoGroup!";
file.ReadAttrString("META:group", &groups);
if (groups.Length() <= 0)
groups = kNoGroup;
// Add the e-mail address to the all people group. Then add it to all the
// group menus that it exists in (based on the comma separated list of
// groups from the People file), optionally making the group menu if it
// doesn't exist. If it's in the special NoGroup! list, then add it below
// the groups.
bool allPeopleGroupDone = false;
BMenu *groupMenu;
do {
BString group;
if (!allPeopleGroupDone) {
// Create the default group for all people, if it doesn't exist yet.
group = "All People";
allPeopleGroupDone = true;
} else {
// Break out the next group from the comma separated string.
int32 comma;
if ((comma = groups.FindFirst(',')) > 0) {
groups.MoveInto(group, 0, comma);
groups.Remove(0, 1);
} else
group.Adopt(groups);
}
// trim white spaces
int32 i = 0;
for (i = 0; isspace(group.ByteAt(i)); i++) {}
if (i)
group.Remove(0, i);
for (i = group.Length() - 1; isspace(group.ByteAt(i)); i--) {}
group.Truncate(i + 1);
groupMenu = NULL;
BMenuItem *superItem = NULL; // Corresponding item for group menu.
if (group.Length() > 0 && group != kNoGroup) {
BMenu *sub;
// Look for submenu with label == group name
for (int32 i = 0; i < items; i++) {
if ((sub = SubmenuAt(i)) != NULL) {
superItem = sub->Superitem();
if (!strcmp(superItem->Label(), group.String())) {
groupMenu = sub;
i++;
break;
}
}
}
// If no submenu, create one
if (!groupMenu) {
// Find where it should go (alphabetical)
int32 mindex = 0;
for (; mindex < fGroups; mindex++) {
if (strcmp(ItemAt(mindex)->Label(), group.String()) > 0)
break;
}
groupMenu = new BMenu(group.String());
groupMenu->SetFont(be_plain_font);
AddItem(groupMenu, mindex);
superItem = groupMenu->Superitem();
superItem->SetMessage(new BMessage(B_SIMPLE_DATA));
if (fTargetHandler)
superItem->SetTarget(fTargetHandler);
fGroups++;
}
}
BString name;
file.ReadAttrString("META:name", &name);
BString email;
file.ReadAttrString("META:email", &email);
//.........这里部分代码省略.........
示例13: link
void
BGopherRequest::_ParseInput(bool last)
{
BString line;
while (_GetLine(line) == B_OK) {
char type = GOPHER_TYPE_NONE;
BStringList fields;
line.MoveInto(&type, 0, 1);
line.Split("\t", false, fields);
if (type != GOPHER_TYPE_ENDOFPAGE
&& fields.CountStrings() < FIELD_GPFLAG)
_EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT,
"Unterminated gopher item (type '%c')", type);
BString pageTitle;
BString item;
BString title = fields.StringAt(FIELD_NAME);
BString link("gopher://");
BString user;
if (fields.CountStrings() > 3) {
link << fields.StringAt(FIELD_HOST);
if (fields.StringAt(FIELD_PORT).Length())
link << ":" << fields.StringAt(FIELD_PORT);
link << "/" << type;
//if (fields.StringAt(FIELD_SELECTOR).ByteAt(0) != '/')
// link << "/";
link << fields.StringAt(FIELD_SELECTOR);
}
_HTMLEscapeString(title);
_HTMLEscapeString(link);
switch (type) {
case GOPHER_TYPE_ENDOFPAGE:
/* end of the page */
break;
case GOPHER_TYPE_TEXTPLAIN:
item << "<a href=\"" << link << "\">"
"<span class=\"text\">" << title << "</span></a>"
"<br/>\n";
break;
case GOPHER_TYPE_BINARY:
case GOPHER_TYPE_BINHEX:
case GOPHER_TYPE_BINARCHIVE:
case GOPHER_TYPE_UUENCODED:
item << "<a href=\"" << link << "\">"
"<span class=\"binary\">" << title << "</span></a>"
"<br/>\n";
break;
case GOPHER_TYPE_DIRECTORY:
/*
* directory link
*/
item << "<a href=\"" << link << "\">"
"<span class=\"dir\">" << title << "</span></a>"
"<br/>\n";
break;
case GOPHER_TYPE_ERROR:
item << "<span class=\"error\">" << title << "</span>"
"<br/>\n";
if (fPosition == 0 && pageTitle.Length() == 0)
pageTitle << "Error: " << title;
break;
case GOPHER_TYPE_QUERY:
/* TODO: handle search better.
* For now we use an unnamed input field and accept sending ?=foo
* as it seems at least Veronica-2 ignores the = but it's unclean.
*/
item << "<form method=\"get\" action=\"" << link << "\" "
"onsubmit=\"window.location = this.action + '?' + "
"this.elements['q'].value; return false;\">"
"<span class=\"query\">"
"<label>" << title << " "
"<input id=\"q\" name=\"\" type=\"text\" align=\"right\" />"
"</label>"
"</span></form>"
"<br/>\n";
break;
case GOPHER_TYPE_TELNET:
/* telnet: links
* cf. gopher://78.80.30.202/1/ps3
* -> gopher://78.80.30.202:23/8/ps3/new -> [email protected]
*/
link = "telnet://";
user = fields.StringAt(FIELD_SELECTOR);
if (user.FindLast('/') > -1) {
user.Remove(0, user.FindLast('/'));
link << user << "@";
}
link << fields.StringAt(FIELD_HOST);
if (fields.StringAt(FIELD_PORT) != "23")
link << ":" << fields.StringAt(FIELD_PORT);
item << "<a href=\"" << link << "\">"
"<span class=\"telnet\">" << title << "</span></a>"
"<br/>\n";
break;
//.........这里部分代码省略.........
示例14: 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;
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") {
// 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, url;
if (f.ReadAt(0LL, contents.LockBuffer(size), size) < B_OK)
continue;
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()) {
args[1] = (char*)url.String();
err = be_roster->Launch("application/x-vnd.Be.URL.http", 1,
args+1);
continue;
}
}
// NetPositive Bookmark or any file with a META:url attribute
if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff,
B_PATH_NAME_LENGTH) > 0) {
err = be_roster->Launch("application/x-vnd.Be.URL.http", 1,
args+1);
continue;
}
}
}
}
示例15: cddbCommand
status_t
CDDBServer::Read(QueryResponseData* diskData, ReadResponseData* readResponse)
{
if (_OpenConnection() != B_OK)
return B_ERROR;
// Assemble the Read command.
BString cddbCommand("cddb read ");
cddbCommand << diskData->category << " " << diskData->cddbId;
BString output;
status_t result;
result = _SendCddbCommand(cddbCommand, &output);
if (result == B_OK) {
// Remove the header from the reply.
output.Remove(0, output.FindFirst("\r\n\r\n") + 4);
// Check status code.
BString statusCode;
output.MoveInto(statusCode, 0, 3);
if (statusCode == "210") {
// Remove first line and parse the others.
output.Remove(0, output.FindFirst("\r\n") + 2);
} else {
// Something bad happened.
return B_ERROR;
}
// Process all entries.
bool done = false;
while (!done) {
if (output[0] == '#') {
// Comment. Remove it.
output.Remove(0, output.FindFirst("\r\n") + 2);
continue;
}
// Extract one line to reduce the scope of processing to it.
BString line;
output.MoveInto(line, 0, output.FindFirst("\r\n"));
output.Remove(0, 2);
// Obtain prefix.
BString prefix;
line.MoveInto(prefix, 0, line.FindFirst("="));
line.Remove(0, 1);
if (prefix == "DTITLE") {
// Disk title.
BString artist;
line.MoveInto(artist, 0, line.FindFirst(" / "));
line.Remove(0, 3);
readResponse->title = line;
readResponse->artist = artist;
} else if (prefix == "DYEAR") {
// Disk year.
char* firstInvalid;
errno = 0;
uint32 year = strtoul(line.String(), &firstInvalid, 10);
if ((errno == ERANGE &&
(year == (uint32)LONG_MAX || year == (uint32)LONG_MIN))
|| (errno != 0 && year == 0)) {
// Year out of range.
printf("Year out of range: %s\n", line.String());
return B_ERROR;
}
if (firstInvalid == line.String()) {
printf("Invalid year: %s\n", line.String());
return B_ERROR;
}
readResponse->year = year;
} else if (prefix == "DGENRE") {
// Disk genre.
readResponse->genre = line;
} else if (prefix.FindFirst("TTITLE") == 0) {
// Track title.
BString index;
prefix.MoveInto(index, 6, prefix.Length() - 6);
TrackData* trackData = new TrackData;
char* firstInvalid;
errno = 0;
uint32 track = strtoul(index.String(), &firstInvalid, 10);
if ((errno == ERANGE &&
(track == (uint32)LONG_MAX || track == (uint32)LONG_MIN))
|| (errno != 0 && track == 0)) {
// Track out of range.
printf("Track out of range: %s\n", index.String());
delete trackData;
return B_ERROR;
}
if (firstInvalid == index.String()) {
printf("Invalid track: %s\n", index.String());
delete trackData;
return B_ERROR;
//.........这里部分代码省略.........