xref: /haiku/src/apps/expander/ExpanderThread.h (revision e326cef6202a94eeab5149052a48c05db8000eaa)
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 _EXPANDER_THREAD_H
7 #define _EXPANDER_THREAD_H
8 
9 
10 #include <Message.h>
11 #include <Volume.h>
12 #include <String.h>
13 #include <OS.h>
14 #include <FindDirectory.h>
15 
16 #include "GenericThread.h"
17 #include <stdio.h>
18 #include <stdlib.h>
19 
20 
21 extern const char* ExpanderThreadName;
22 
23 
24 class ExpanderThread : public GenericThread {
25 public:
26 								ExpanderThread(BMessage* refs_message,
27 									BMessenger* messenger);
28 								~ExpanderThread();
29 
30 			status_t			SuspendExternalExpander();
31 			status_t			ResumeExternalExpander();
32 			status_t			InterruptExternalExpander();
33 			status_t			WaitOnExternalExpander();
34 
35 			void				PushInput(BString text);
36 
37 private:
38 	virtual	status_t			ThreadStartup();
39 	virtual	status_t			ExecuteUnit();
40 	virtual	status_t			ThreadShutdown();
41 
42 	virtual	void				ThreadStartupFailed(status_t a_status);
43 	virtual	void				ExecuteUnitFailed(status_t a_status);
44 	virtual	void				ThreadShutdownFailed(status_t a_status);
45 
46 			status_t			ProcessRefs(BMessage* message);
47 
48 			thread_id			PipeCommand(int argc, const char** argv,
49 									int& in, int& out, int& err,
50 									const char** envp = (const char**)environ);
51 
52 			BMessenger*			fWindowMessenger;
53 
54 			thread_id			fThreadId;
55 			int					fStdIn;
56 			int					fStdOut;
57 			int					fStdErr;
58 			FILE*				fExpanderOutput;
59 			FILE*				fExpanderError;
60 			char				fExpanderOutputBuffer[LINE_MAX];
61 };
62 
63 
64 #endif	// _EXPANDER_THREAD_H
65