Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

spawn.h

Go to the documentation of this file.
00001 /*  Inti: Integrated Foundation Classes
00002  *  Copyright (C) 2003 The Inti Development Team.
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00021 
00022 #ifndef INTI_G_SPAWN_H
00023 #define INTI_G_SPAWN_H
00024 
00025 #ifndef INTI_STACK_OBJECT_H
00026 #include <inti/stackobject.h>
00027 #endif
00028 
00029 #ifndef INTI_SLOT_H
00030 #include <inti/slot.h>
00031 #endif
00032 
00033 #ifndef __G_SPAWN_H__
00034 #include <glib/gspawn.h>
00035 #endif
00036 
00037 #ifndef _CPP_VECTOR
00038 #include <vector>
00039 #endif
00040 
00041 namespace Inti {
00042 
00043 namespace G {
00044 
00045 class Error;
00046 class SpawnData;
00047 class SpawnAsyncData;
00048 class SpawnSyncData;
00049 
00052 
00053 enum SpawnFlags
00054 {
00055         SPAWN_LEAVE_DESCRIPTORS_OPEN = G_SPAWN_LEAVE_DESCRIPTORS_OPEN,
00059 
00060         SPAWN_DO_NOT_REAP_CHILD = G_SPAWN_DO_NOT_REAP_CHILD,
00063 
00064         SPAWN_SEARCH_PATH = G_SPAWN_SEARCH_PATH,
00066 
00067         SPAWN_STDOUT_TO_DEV_NULL = G_SPAWN_STDOUT_TO_DEV_NULL,
00070 
00071         SPAWN_STDERR_TO_DEV_NULL = G_SPAWN_STDERR_TO_DEV_NULL,
00073 
00074         SPAWN_CHILD_INHERITS_STDIN = G_SPAWN_CHILD_INHERITS_STDIN,
00077 
00078         SPAWN_FILE_AND_ARGV_ZERO = G_SPAWN_FILE_AND_ARGV_ZERO
00082 };
00083 
00085 
00086 typedef unsigned int SpawnFlagsField;
00087 
00105 
00106 class Spawn : public StackObject
00107 {
00108         Spawn(const Spawn&);
00109         Spawn& operator=(const Spawn&);
00110 
00111         SpawnData *data_;
00112 
00113 protected:
00116 
00117         Spawn();
00119 
00123 
00124         const char* get_working_directory() const;
00126 
00127         char** get_argv() const;
00129 
00130         char** get_envp() const;
00132 
00133         GSpawnFlags get_flags() const;
00135 
00139 
00140         void set_arguments(const std::vector<std::string>& argv, SpawnFlagsField flags);
00144 
00145         void set_arguments(const std::string& command_line, G::Error *error);
00151 
00153 
00154 public:
00155         typedef Slot0<void> ChildSetupSlot;
00166 
00169 
00170         ~Spawn();
00172 
00176 
00177         void set_working_directory(const std::string& working_directory);
00182 
00183         void set_enviroment(std::vector<std::string>& envp);
00190 
00192 };
00193 
00287 
00288 class SpawnAsync : public Spawn
00289 {
00290         SpawnAsync(const SpawnAsync&);
00291         SpawnAsync& operator=(const SpawnAsync&);
00292 
00293         SpawnAsyncData *data_;
00294 
00295 public:
00298 
00299         SpawnAsync(const std::vector<std::string>& argv, SpawnFlagsField flags = 0);
00308 
00309         SpawnAsync(const std::string& command_line, G::Error *error);
00321 
00322         ~SpawnAsync();
00324 
00328 
00329         int process_id() const;
00331 
00335 
00336         bool execute(G::Error *error, const ChildSetupSlot *slot = 0);
00342 
00343         void set_standard_input(int& standard_input);
00346 
00347         void set_standard_output(int& standard_output);
00350 
00351         void set_standard_error(int& standard_error);
00354 
00356 };
00357 
00394 
00395 class SpawnSync : public Spawn
00396 {
00397         SpawnSync(const SpawnSync&);
00398         SpawnSync& operator=(const SpawnSync&);
00399 
00400         SpawnSyncData *data_;
00401 
00402 public:
00405 
00406         SpawnSync(const std::vector<std::string>& argv, SpawnFlagsField flags = 0);
00415 
00416         SpawnSync(const std::string& command_line, G::Error *error);
00428 
00429         ~SpawnSync();
00431 
00435 
00436         int exit_status() const;
00439 
00440         std::string standard_output() const;
00443 
00444         std::string standard_error() const;
00447 
00451 
00452         bool execute(G::Error *error, const ChildSetupSlot *slot = 0);
00458 
00460 };
00461 
00462 } // namespace G
00463 
00464 } // namespace Inti
00465 
00466 #endif // INTI_G_SPAWN_H
00467 
Main Page - Footer


Generated on Sun Sep 14 20:08:04 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002