Rudiments
/home/dmuse/src/rudiments/include/rudiments/shellcommand.h
00001 // Copyright (c) 2003 David Muse
00002 // See the COPYING file for more information.
00003 
00004 #ifndef RUDIMENTS_SHELLCOMMAND_H
00005 #define RUDIMENTS_SHELLCOMMAND_H
00006 
00007 #include <rudiments/private/shellcommandincludes.h>
00008 
00009 #ifdef RUDIMENTS_NAMESPACE
00010 namespace rudiments {
00011 #endif
00012 
00013 // @cond
00014 
00015 class shellcommandprivate;
00016 
00017 // FIXME: implement this class
00018 // The shellcommand class provides methods for running commands, reading their
00019 // output or writing input to them.
00020 
00021 // wrap:
00022 //      stdlib.h - system()
00023 //      unistd.h - execve()/fexecve(),execv(),execle(),execl(),execvp(),execlp()
00024 //      stdio.h - popen(), pclose()
00025 //      not in many systems -
00026 //              spawn.h - posix spawn interface
00027 //                              posix_spawn()
00028 //                              posix_spawnp()
00029 //                              posix_spawnattr_init()
00030 //                              posix_spawnattr_destroy()
00031 //                              posix_spawnattr_getsigdefault()
00032 //                              posix_spawnattr_setsigdefault()
00033 //                              posix_spawnattr_getsigmask()
00034 //                              posix_spawnattr_setsigmask()
00035 //                              posix_spawnattr_getflags()
00036 //                              posix_spawnattr_setflags()
00037 //                              posix_spawnattr_getpgroup()
00038 //                              posix_spawnattr_setpgroup()
00039 //                              posix_spawnattr_getschedpolicy()
00040 //                              posix_spawnattr_setschedpolicy()
00041 //                              posix_spawnattr_getschedparam()
00042 //                              posix_spawnattr_setschedparam()
00043 //                              posix_spawn_file_actions_init()
00044 //                              posix_spawn_file_actions_destroy()
00045 //                              posix_spawn_file_actions_addopen()
00046 //                              posix_spawn_file_actions_addclose()
00047 //                              posix_spawn_file_actions_adddup2()
00048 class RUDIMENTS_DLLSPEC shellcommand {
00049         public:
00050                 int32_t run(const char *command);
00051                         // Runs "command".
00052 
00053                 int32_t getStandardInput();
00054                         // If run() succeeded, returns the file descriptor
00055                         // of the standard input of the command or 0 otherwise.
00056 
00057                 int32_t getStandardOutput();
00058                         // If run() succeeded, returns the file descriptor
00059                         // of the standard output of the command or 0 otherwise.
00060 
00061                 int32_t getStandardError();
00062                         // If run() succeeded, returns the file descriptor
00063                         // of the standard error of the command or 0 otherwise.
00064 
00065                 int32_t close();
00066                         // Closes the previously run command.
00067                         //
00068                         // Returns 1 on success and 0 on failure.
00069 
00070         #include <rudiments/private/shellcommand.h>
00071 };
00072 
00073 // @endcond
00074 
00075 #ifdef RUDIMENTS_NAMESPACE
00076 }
00077 #endif
00078 
00079 #endif