fixing indenting style issues

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20314 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2007-03-03 15:26:57 +00:00
parent 5cb9bf4bbb
commit 96303159b3
16 changed files with 548 additions and 548 deletions
+82 -82
View File
@@ -13,8 +13,8 @@
const char * ExpanderThreadName = "ExpanderThread";
ExpanderThread::ExpanderThread (BMessage * refs_message, BMessenger * messenger)
: GenericThread(ExpanderThreadName, B_NORMAL_PRIORITY, refs_message),
ExpanderThread::ExpanderThread(BMessage * refs_message, BMessenger * messenger)
: GenericThread(ExpanderThreadName, B_NORMAL_PRIORITY, refs_message),
fWindowMessenger(messenger),
fThreadId(-1),
fStdIn(-1),
@@ -24,12 +24,12 @@ ExpanderThread::ExpanderThread (BMessage * refs_message, BMessenger * messenger)
fExpanderOutputString(),
fExpanderOutputBuffer(new char [4096])
{
SetDataStore(new BMessage (* refs_message)); // leak?
// prevents bug with B_SIMPLE_DATA
// (drag&drop messages)
SetDataStore(new BMessage(* refs_message)); // leak?
// prevents bug with B_SIMPLE_DATA
// (drag&drop messages)
}
ExpanderThread::~ExpanderThread()
ExpanderThread::~ExpanderThread()
{
delete fWindowMessenger;
delete [] fExpanderOutputBuffer;
@@ -41,64 +41,64 @@ ExpanderThread::ThreadStartup()
status_t status = B_OK;
entry_ref srcRef, destRef;
BString cmd;
if ((status = GetDataStore()->FindRef("srcRef", &srcRef))!=B_OK)
if ((status = GetDataStore()->FindRef("srcRef", &srcRef)) != B_OK)
return status;
if ((status = GetDataStore()->FindRef("destRef", &destRef))==B_OK) {
if ((status = GetDataStore()->FindRef("destRef", &destRef)) == B_OK) {
BPath path(&destRef);
chdir(path.Path());
}
if ((status = GetDataStore()->FindString("cmd", &cmd))!=B_OK)
if ((status = GetDataStore()->FindString("cmd", &cmd)) != B_OK)
return status;
BPath path(&srcRef);
BString pathString(path.Path());
pathString.CharacterEscape("\"$`", '\\');
pathString.Prepend("\"");
pathString.Append("\"");
pathString.Prepend("\"");
pathString.Append("\"");
cmd.ReplaceAll("%s", pathString.String());
int32 argc = 3;
const char ** argv = new const char * [argc + 1];
argv[0] = strdup("/bin/sh");
argv[1] = strdup("-c");
argv[2] = strdup(cmd.String());
argv[argc] = NULL;
fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr);
fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr);
delete [] argv;
if (fThreadId < 0)
return fThreadId;
resume_thread(fThreadId);
fExpanderOutput = fdopen(fStdOut, "r");
return fThreadId;
resume_thread(fThreadId);
fExpanderOutput = fdopen(fStdOut, "r");
return B_OK;
}
status_t
ExpanderThread::ExecuteUnit (void)
ExpanderThread::ExecuteUnit(void)
{
// read output from command
// send it to window
char *output_string = fgets(fExpanderOutputBuffer , 4096-1, fExpanderOutput);
char *output_string = fgets(fExpanderOutputBuffer , 4096 - 1, fExpanderOutput);
if (output_string == NULL)
return EOF;
BMessage message('outp');
message.AddString("output", output_string);
for (int32 i=0; i<5; i++) {
output_string = fgets(fExpanderOutputBuffer , 4096-1, fExpanderOutput);
if(!output_string)
for (int32 i = 0; i < 5; i++) {
output_string = fgets(fExpanderOutputBuffer , 4096 - 1, fExpanderOutput);
if (!output_string)
break;
message.AddString("output", output_string);
}
}
fWindowMessenger->SendMessage(&message);
return B_OK;
@@ -108,8 +108,8 @@ status_t
ExpanderThread::ThreadShutdown(void)
{
close(fStdIn);
close(fStdOut);
close(fStdErr);
close(fStdOut);
close(fStdErr);
return B_OK;
}
@@ -132,7 +132,7 @@ ExpanderThread::ExecuteUnitFailed(status_t status)
// explicit error - communicate error to Window
fWindowMessenger->SendMessage(new BMessage('exrr'));
}
Quit();
}
@@ -150,56 +150,56 @@ ExpanderThread::ProcessRefs(BMessage *msg)
}
thread_id
ExpanderThread::PipeCommand(int argc, const char **argv, int &in, int &out, int &err, const char **envp)
{
ExpanderThread::PipeCommand(int argc, const char **argv, int &in, int &out, int &err, const char **envp)
{
// This function written by Peter Folk <[email protected]>
// and published in the BeDevTalk FAQ
// and published in the BeDevTalk FAQ
// http://www.abisoft.com/faq/BeDevTalk_FAQ.html#FAQ-209
// Save current FDs
int old_in = dup(0);
int old_out = dup(1);
int old_err = dup(2);
int filedes[2];
/* Create new pipe FDs as stdin, stdout, stderr */
pipe(filedes); dup2(filedes[0],0); close(filedes[0]);
in=filedes[1]; // Write to in, appears on cmd's stdin
pipe(filedes); dup2(filedes[1],1); close(filedes[1]);
out=filedes[0]; // Read from out, taken from cmd's stdout
pipe(filedes); dup2(filedes[1],2); close(filedes[1]);
err=filedes[0]; // Read from err, taken from cmd's stderr
// "load" command.
thread_id ret = load_image(argc, argv, envp);
if (ret < B_OK)
return ret;
// thread ret is now suspended.
// Save current FDs
int old_in = dup(0);
int old_out = dup(1);
int old_err = dup(2);
int filedes[2];
/* Create new pipe FDs as stdin, stdout, stderr */
pipe(filedes); dup2(filedes[0], 0); close(filedes[0]);
in = filedes[1]; // Write to in, appears on cmd's stdin
pipe(filedes); dup2(filedes[1], 1); close(filedes[1]);
out = filedes[0]; // Read from out, taken from cmd's stdout
pipe(filedes); dup2(filedes[1], 2); close(filedes[1]);
err = filedes[0]; // Read from err, taken from cmd's stderr
// "load" command.
thread_id ret = load_image(argc, argv, envp);
if (ret < B_OK)
return ret;
// thread ret is now suspended.
setpgid(ret, ret);
// Restore old FDs
close(0); dup(old_in); close(old_in);
close(1); dup(old_out); close(old_out);
close(2); dup(old_err); close(old_err);
/* Theoretically I should do loads of error checking, but
the calls aren't very likely to fail, and that would
muddy up the example quite a bit. YMMV. */
// Restore old FDs
close(0); dup(old_in); close(old_in);
close(1); dup(old_out); close(old_out);
close(2); dup(old_err); close(old_err);
return ret;
}
/* Theoretically I should do loads of error checking, but
the calls aren't very likely to fail, and that would
muddy up the example quite a bit. YMMV. */
return ret;
}
status_t
ExpanderThread::SuspendExternalExpander()
ExpanderThread::SuspendExternalExpander()
{
thread_info thread_info;
status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK)
return send_signal(-fThreadId, SIGSTOP);
else
@@ -207,11 +207,11 @@ ExpanderThread::SuspendExternalExpander()
}
status_t
ExpanderThread::ResumeExternalExpander()
{
ExpanderThread::ResumeExternalExpander()
{
thread_info thread_info;
status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK)
return send_signal(-fThreadId, SIGCONT);
else
@@ -219,11 +219,11 @@ ExpanderThread::ResumeExternalExpander()
}
status_t
ExpanderThread::InterruptExternalExpander()
{
ExpanderThread::InterruptExternalExpander()
{
thread_info thread_info;
status_t status = get_thread_info (fThreadId, &thread_info);
status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK) {
status = send_signal(-fThreadId, SIGINT);
WaitOnExternalExpander();
@@ -232,11 +232,11 @@ ExpanderThread::InterruptExternalExpander()
}
status_t
ExpanderThread::WaitOnExternalExpander()
{
ExpanderThread::WaitOnExternalExpander()
{
thread_info thread_info;
status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK)
return wait_for_thread(fThreadId, &status);
else