Skip to content

Commit

Permalink
open: style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jscipione committed Jun 25, 2014
1 parent 807a7aa commit ade1697
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/bin/open.cpp
Expand Up @@ -18,29 +18,29 @@
#include <Mime.h>
#include <Roster.h>
#include <String.h>

#include <Url.h>


const char *kTrackerSignature = "application/x-vnd.Be-TRAK";


status_t
open_file(const char* openWith, BEntry &entry, int32 line = -1, int32 col = -1)
open_file(const char* openWith, BEntry& entry, int32 line = -1, int32 col = -1)
{
entry_ref ref;
status_t status = entry.GetRef(&ref);
if (status < B_OK)
return status;
status_t result = entry.GetRef(&ref);
if (result != B_OK)
return result;

BMessenger target(openWith ? openWith : kTrackerSignature);
BMessenger target(openWith != NULL ? openWith : kTrackerSignature);
if (!target.IsValid())
return be_roster->Launch(&ref);

BMessage message(B_REFS_RECEIVED);
message.AddRef("refs", &ref);
if (line > -1)
message.AddInt32("be:line", line);

if (col > -1)
message.AddInt32("be:column", col);

Expand All @@ -50,12 +50,12 @@ open_file(const char* openWith, BEntry &entry, int32 line = -1, int32 col = -1)


int
main(int argc, char **argv)
main(int argc, char** argv)
{
int exitcode = EXIT_SUCCESS;
const char *openWith = NULL;
int exitCode = EXIT_SUCCESS;
const char* openWith = NULL;

char *progName = argv[0];
char* progName = argv[0];
if (strrchr(progName, '/'))
progName = strrchr(progName, '/') + 1;

Expand All @@ -65,12 +65,12 @@ main(int argc, char **argv)
}

while (*++argv) {
status_t status = B_OK;
status_t result = B_OK;
argc--;

BEntry entry(*argv);
if ((status = entry.InitCheck()) == B_OK && entry.Exists()) {
status = open_file(openWith, entry);
if ((result = entry.InitCheck()) == B_OK && entry.Exists()) {
result = open_file(openWith, entry);
} else if (!strncasecmp("application/", *argv, 12)) {
// maybe it's an application-mimetype?

Expand All @@ -84,9 +84,9 @@ main(int argc, char **argv)
be_roster->GetAppList(*argv, &teams);

if (teams.IsEmpty())
status = be_roster->Launch(*argv);
result = be_roster->Launch(*argv);
else
status = B_OK;
result = B_OK;
} else if (strchr(*argv, ':')) {
// try to open it as an URI
BPrivate::Support::BUrl url(*argv);
Expand All @@ -95,7 +95,7 @@ main(int argc, char **argv)

// maybe it's "file:line" or "file:line:col"
int line = 0, col = 0, i;
status = B_ENTRY_NOT_FOUND;
result = B_ENTRY_NOT_FOUND;
// remove gcc error's last :
BString arg(*argv);
if (arg[arg.Length() - 1] == ':')
Expand All @@ -106,10 +106,10 @@ main(int argc, char **argv)
line = atoi(arg.String() + i + 1);
arg.Truncate(i);

status = entry.SetTo(arg.String());
if (status == B_OK && entry.Exists()) {
status = open_file(openWith, entry, line);
if (status == B_OK)
result = entry.SetTo(arg.String());
if (result == B_OK && entry.Exists()) {
result = open_file(openWith, entry, line);
if (result == B_OK)
continue;
}

Expand All @@ -119,20 +119,20 @@ main(int argc, char **argv)
line = atoi(arg.String() + i + 1);
arg.Truncate(i);

status = entry.SetTo(arg.String());
if (status == B_OK && entry.Exists())
status = open_file(openWith, entry, line, col);
result = entry.SetTo(arg.String());
if (result == B_OK && entry.Exists())
result = open_file(openWith, entry, line, col);
}
} else
status = B_ENTRY_NOT_FOUND;
result = B_ENTRY_NOT_FOUND;

if (status != B_OK && status != B_ALREADY_RUNNING) {
if (result != B_OK && result != B_ALREADY_RUNNING) {
fprintf(stderr, "%s: \"%s\": %s\n", progName, *argv,
strerror(status));
strerror(result));
// make sure the shell knows this
exitcode = EXIT_FAILURE;
exitCode = EXIT_FAILURE;
}
}

return exitcode;
return exitCode;
}

0 comments on commit ade1697

Please sign in to comment.