xref: /haiku/src/apps/expander/ExpanderThread.h (revision 99d027cd0238c1d86da86d7c3f4200509ccc61a6)
1 /*
2  * Copyright 2004-2010, Jérôme Duval. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  * Original code from ZipOMatic by jonas.sundstrom@kirilla.com
5  */
6 #ifndef __EXPANDERTHREAD_H__
7 #define __EXPANDERTHREAD_H__
8 
9 #include <Message.h>
10 #include <Volume.h>
11 #include <String.h>
12 #include <OS.h>
13 #include <FindDirectory.h>
14 
15 #include "GenericThread.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 
19 extern const char * ExpanderThreadName;
20 
21 class ExpanderThread : public GenericThread
22 {
23 	public:
24 		ExpanderThread(BMessage *refs_message, BMessenger *messenger);
25 		~ExpanderThread();
26 
27 		status_t SuspendExternalExpander();
28 		status_t ResumeExternalExpander();
29 		status_t InterruptExternalExpander();
30 		status_t WaitOnExternalExpander();
31 		void PushInput(BString text);
32 
33 	private:
34 
35 		virtual status_t ThreadStartup();
36 		virtual status_t ExecuteUnit();
37 		virtual status_t ThreadShutdown();
38 
39 		virtual void ThreadStartupFailed(status_t a_status);
40 		virtual void ExecuteUnitFailed(status_t a_status);
41 		virtual void ThreadShutdownFailed(status_t a_status);
42 
43 		status_t ProcessRefs(BMessage *	msg);
44 
45 		thread_id PipeCommand(int argc, const char **argv,
46 			int & in, int & out, int & err,
47 			const char **envp = (const char **) environ);
48 
49 		BMessenger * 	fWindowMessenger;
50 
51 		thread_id		fThreadId;
52 		int				fStdIn;
53 		int				fStdOut;
54 		int				fStdErr;
55 		FILE *			fExpanderOutput;
56 		FILE *			fExpanderError;
57 		char			fExpanderOutputBuffer[LINE_MAX];
58 };
59 
60 #endif // __EXPANDERTHREAD_H__
61