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