WvStreams
wvsystem.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 */
5#ifndef __WVSYSTEM_H
6#define __WVSYSTEM_H
7
8#include "wvsubproc.h"
9
29class WvSystem : private WvSubProc
30{
31public:
44 WvSystem(const char cmd[],
45 const char *a0 = NULL,
46 const char *a1 = NULL,
47 const char *a2 = NULL,
48 const char *a3 = NULL,
49 const char *a4 = NULL,
50 const char *a5 = NULL,
51 const char *a6 = NULL,
52 const char *a7 = NULL,
53 const char *a8 = NULL,
54 const char *a9 = NULL,
55 const char *a10 = NULL,
56 const char *a11 = NULL,
57 const char *a12 = NULL,
58 const char *a13 = NULL,
59 const char *a14 = NULL,
60 const char *a15 = NULL,
61 const char *a16 = NULL,
62 const char *a17 = NULL,
63 const char *a18 = NULL,
64 const char *a19 = NULL
65 )
66 {
67 // this function is inline so it can be a little bit less wasteful...
68 const char * const argv[] = {
69 cmd,
70 a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
71 a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
72 NULL
73 };
74 init(argv);
75 }
76
86 WvSystem(const char * const *argv)
87 { init(argv); }
88
93 virtual ~WvSystem();
94
100 int go();
101
103 WvSystem &infile(WvStringParm filename);
104
106 WvSystem &outfile(WvStringParm filename);
107
109 WvSystem &errfile(WvStringParm filename);
110
111private:
112 bool started;
113 WvString fdfiles[3]; // stdin, stdout, stderr
114
115 void init(const char * const *argv);
116 virtual int fork(int *waitfd);
117};
118
119
120#endif // __WVSYSTEM_H
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition wvstring.h:94
WvString is an implementation of a simple and efficient printable-string class.
Definition wvstring.h:330
WvSystem is a mostly-replacement for the libc system() function call, which people usually use becaus...
Definition wvsystem.h:30
WvSystem & infile(WvStringParm filename)
Redirect stdin from the given input file.
Definition wvsystem.cc:71
int go()
Explicitly start the command running and wait for it to finish.
Definition wvsystem.cc:59
virtual ~WvSystem()
Destroy the WvSystem object.
Definition wvsystem.cc:12
WvSystem & outfile(WvStringParm filename)
Redirect stdout to the given output file, which is overwritten.
Definition wvsystem.cc:78
WvSystem(const char cmd[], const char *a0=NULL, const char *a1=NULL, const char *a2=NULL, const char *a3=NULL, const char *a4=NULL, const char *a5=NULL, const char *a6=NULL, const char *a7=NULL, const char *a8=NULL, const char *a9=NULL, const char *a10=NULL, const char *a11=NULL, const char *a12=NULL, const char *a13=NULL, const char *a14=NULL, const char *a15=NULL, const char *a16=NULL, const char *a17=NULL, const char *a18=NULL, const char *a19=NULL)
Construct a WvSystem from a simple list of strings.
Definition wvsystem.h:44
WvSystem & errfile(WvStringParm filename)
Redirect stderr to the given output file, which is overwritten.
Definition wvsystem.cc:85
WvSystem(const char *const *argv)
Construct a WvSystem from an argv array.
Definition wvsystem.h:86