1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * os_process.h -- base class for OS specific calls related to creating
|
---|
4 | * process *without* (in the case of Windows) opening a
|
---|
5 | * DOS window.
|
---|
6 | *
|
---|
7 | * Nett effect is OS neutral way to support
|
---|
8 | * popen() and related functions
|
---|
9 | *
|
---|
10 | * Copyright (C) 2010 The New Zealand Digital Library Project
|
---|
11 | *
|
---|
12 | * A component of the Greenstone digital library software
|
---|
13 | * from the New Zealand Digital Library Project at the
|
---|
14 | * University of Waikato, New Zealand.
|
---|
15 | *
|
---|
16 | * This program is free software; you can redistribute it and/or modify
|
---|
17 | * it under the terms of the GNU General Public License as published by
|
---|
18 | * the Free Software Foundation; either version 2 of the License, or
|
---|
19 | * (at your option) any later version.
|
---|
20 | *
|
---|
21 | * This program is distributed in the hope that it will be useful,
|
---|
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
24 | * GNU General Public License for more details.
|
---|
25 | *
|
---|
26 | * You should have received a copy of the GNU General Public License
|
---|
27 | * along with this program; if not, write to the Free Software
|
---|
28 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
29 | *
|
---|
30 | *********************************************************************/
|
---|
31 |
|
---|
32 | #ifndef OS_PROCESS_H
|
---|
33 | #define OS_PROCESS_H
|
---|
34 |
|
---|
35 | #include <stdlib.h>
|
---|
36 |
|
---|
37 | enum OSProcessPipeMode { uniRead=0, uniWrite=1, biReadWrite=2 };
|
---|
38 | enum OSProcessWarnStatus { withoutWarning, withWarning };
|
---|
39 |
|
---|
40 | class osprocess
|
---|
41 | {
|
---|
42 |
|
---|
43 | public:
|
---|
44 | osprocess(OSProcessPipeMode mode,
|
---|
45 | char* prog_name, char* argv[]=NULL, char* envp[]=NULL);
|
---|
46 |
|
---|
47 | virtual ~osprocess();
|
---|
48 |
|
---|
49 | /* one day might want these
|
---|
50 | virtual bool end_of_pipe();
|
---|
51 | virtual bool end_of_read_pipe();
|
---|
52 | virtual bool end_of_write_pipe();
|
---|
53 | */
|
---|
54 |
|
---|
55 | virtual int write(char* buffer, const int buffer_len)=0;
|
---|
56 | virtual int read(char* buffer, const int buffer_len)=0;
|
---|
57 |
|
---|
58 | virtual void wait()=0;
|
---|
59 |
|
---|
60 | virtual bool close_write_pipe(OSProcessWarnStatus warn_status=withWarning)=0;
|
---|
61 | virtual bool close_read_pipe(OSProcessWarnStatus warn_status=withWarning)=0;
|
---|
62 | virtual bool close();
|
---|
63 |
|
---|
64 |
|
---|
65 | protected:
|
---|
66 | OSProcessPipeMode mode_;
|
---|
67 | };
|
---|
68 |
|
---|
69 | #endif
|
---|
70 |
|
---|