FreeNOS
POSIXApplication.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <FreeNOS/Config.h>
19 #include <stdio.h>
20 #include "POSIXApplication.h"
21 #include "ApplicationLauncher.h"
22 
23 POSIXApplication::POSIXApplication(int argc, char **argv)
24  : Application(argc, argv)
25 {
26  setVersion(VERSION);
27 }
28 
30 {
31 }
32 
34 {
35  printf("%s", string);
36  return Success;
37 }
38 
39 int POSIXApplication::runProgram(const char *path, const char **argv)
40 {
41  ApplicationLauncher prog(path, argv);
42 
43  const ApplicationLauncher::Result result = prog.exec();
44  if (result != ApplicationLauncher::Success)
45  {
46  return -1;
47  }
48  else
49  {
50  return (int) prog.getPid();
51  }
52 }
ApplicationLauncher::getPid
const ProcessID getPid() const
Retrieve Process Identifier of the program.
Definition: ApplicationLauncher.cpp:37
POSIXApplication::output
virtual Result output(const char *string) const
Print text to output.
Definition: POSIXApplication.cpp:33
Application::setVersion
void setVersion(const String &version)
Set program version.
Definition: Application.cpp:117
POSIXApplication::~POSIXApplication
virtual ~POSIXApplication()
Class destructor.
Definition: POSIXApplication.cpp:29
Application
Generic application.
Definition: Application.h:38
Application::Success
@ Success
Definition: Application.h:55
ApplicationLauncher::Result
Result
Result code.
Definition: ApplicationLauncher.h:42
POSIXApplication.h
printf
int printf(const char *format,...)
Output a formatted string to standard output.
Definition: printf.cpp:22
POSIXApplication::runProgram
int runProgram(const char *path, const char **argv)
Runs an external program.
Definition: POSIXApplication.cpp:39
stdio.h
ApplicationLauncher::exec
Result exec()
Runs the external program.
Definition: ApplicationLauncher.cpp:47
Application::Result
Result
Result codes.
Definition: Application.h:53
ApplicationLauncher
Helper class to launch an external program.
Definition: ApplicationLauncher.h:35
ApplicationLauncher::Success
@ Success
Definition: ApplicationLauncher.h:44
ApplicationLauncher.h
POSIXApplication::POSIXApplication
POSIXApplication(int argc, char **argv)
Class constructor.
Definition: POSIXApplication.cpp:23