Rudiments
shellcommand.h
1 // Copyright (c) 2003 David Muse
2 // See the COPYING file for more information.
3 
4 #ifndef RUDIMENTS_SHELLCOMMAND_H
5 #define RUDIMENTS_SHELLCOMMAND_H
6 
7 #include <rudiments/private/shellcommandincludes.h>
8 
9 // @cond
10 
11 class shellcommandprivate;
12 
13 // FIXME: implement this class
14 // The shellcommand class provides methods for running commands, reading their
15 // output or writing input to them.
16 
17 // wrap:
18 // stdlib.h - system()
19 // unistd.h - execve()/fexecve(),execv(),execle(),execl(),execvp(),execlp()
20 // stdio.h - popen(), pclose()
21 // not in many systems -
22 // spawn.h - posix spawn interface
23 // posix_spawn()
24 // posix_spawnp()
25 // posix_spawnattr_init()
26 // posix_spawnattr_destroy()
27 // posix_spawnattr_getsigdefault()
28 // posix_spawnattr_setsigdefault()
29 // posix_spawnattr_getsigmask()
30 // posix_spawnattr_setsigmask()
31 // posix_spawnattr_getflags()
32 // posix_spawnattr_setflags()
33 // posix_spawnattr_getpgroup()
34 // posix_spawnattr_setpgroup()
35 // posix_spawnattr_getschedpolicy()
36 // posix_spawnattr_setschedpolicy()
37 // posix_spawnattr_getschedparam()
38 // posix_spawnattr_setschedparam()
39 // posix_spawn_file_actions_init()
40 // posix_spawn_file_actions_destroy()
41 // posix_spawn_file_actions_addopen()
42 // posix_spawn_file_actions_addclose()
43 // posix_spawn_file_actions_adddup2()
44 class RUDIMENTS_DLLSPEC shellcommand {
45  public:
46  int32_t run(const char *command);
47  // Runs "command".
48 
49  int32_t getStandardInput();
50  // If run() succeeded, returns the file descriptor
51  // of the standard input of the command or 0 otherwise.
52 
53  int32_t getStandardOutput();
54  // If run() succeeded, returns the file descriptor
55  // of the standard output of the command or 0 otherwise.
56 
57  int32_t getStandardError();
58  // If run() succeeded, returns the file descriptor
59  // of the standard error of the command or 0 otherwise.
60 
61  int32_t close();
62  // Closes the previously run command.
63  //
64  // Returns 1 on success and 0 on failure.
65 
66  #include <rudiments/private/shellcommand.h>
67 };
68 
69 // @endcond
70 
71 #endif