rllib  1
rlspawn.h
Go to the documentation of this file.
1 /***************************************************************************
2  rlspawn.h - description
3  -------------------
4  begin : Tue Jan 02 2001
5  copyright : (C) 2001 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #ifndef _RL_SPAWN_H_
17 #define _RL_SPAWN_H_
18 
19 #include "rldefine.h"
20 
21 #ifndef RLUNIX
22 //#warning This Functionality is only available under Linux/Unix
23 /*
24 http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574%28v=vs.85%29.aspx
25 http://www.tenouk.com/cpluscodesnippet/pipeandchildprocess.html
26 http://msdn.microsoft.com/en-us/library/windows/desktop/aa365780%28v=vs.85%29.aspx
27 
28 GetFileNameFromHandle
29 http://msdn.microsoft.com/en-us/library/windows/desktop/aa366789%28v=vs.85%29.aspx
30 */
31 #endif
32 
40 class rlSpawn
41 {
42 public:
43  rlSpawn();
44  virtual ~rlSpawn();
45 
52  int spawn(const char *command);
53 
58  const char *readLine();
59 
64  int getchar();
65 
71  int select(int timeout=50);
72 
79  int writeString(const char *buf);
80 
86  int write(const char *buf, int len);
87 
93  int printf(const char *format, ...);
94 
98  void printAll();
99 
103  FILE *getFilepointer();
104 
108  int sigkill();
109 
151  int readJpegBuffer(unsigned char *buffer, int maxbuffer);
152 
153  int pid;
154 
155 private:
156 #ifdef RLWIN32
157  HANDLE toChildRD;
158  HANDLE toChildWR;
159  HANDLE fromChildRD;
160  HANDLE fromChildWR;
161  HANDLE hThread;
162  HANDLE hProcess;
163 #else
164  void *toChild,*fromChild;
165 #endif
166  char line[4096]; // adjust this if the buffer is not big enough
167 };
168 
169 #endif
int select(int timeout=50)
Definition: rlspawn.cpp:456
HANDLE fromChildRD
Definition: rlspawn.h:159
FILE * getFilepointer()
Definition: rlspawn.cpp:488
HANDLE hProcess
Definition: rlspawn.h:162
int getchar()
Definition: rlspawn.cpp:355
HANDLE hThread
Definition: rlspawn.h:161
int writeString(const char *buf)
Definition: rlspawn.cpp:415
int printf(const char *format,...)
Definition: rlspawn.cpp:402
int readJpegBuffer(unsigned char *buffer, int maxbuffer)
Definition: rlspawn.cpp:526
int write(const char *buf, int len)
Definition: rlspawn.cpp:385
void printAll()
Definition: rlspawn.cpp:450
int sigkill()
Definition: rlspawn.cpp:497
const char * readLine()
Definition: rlspawn.cpp:307
rlSpawn()
Definition: rlspawn.cpp:137
char line[4096]
Definition: rlspawn.h:166
int pid
Definition: rlspawn.h:153
HANDLE fromChildWR
Definition: rlspawn.h:160
HANDLE toChildWR
Definition: rlspawn.h:158
int spawn(const char *command)
Definition: rlspawn.cpp:168
virtual ~rlSpawn()
Definition: rlspawn.cpp:153
HANDLE toChildRD
Definition: rlspawn.h:157