1 /*****************************************************************************/ 2 // Expander 3 // Written by Jérôme Duval 4 // 5 // ExpanderThread.h 6 // 7 // Copyright (c) 2004 OpenBeOS Project 8 // 9 // Permission is hereby granted, free of charge, to any person obtaining a 10 // copy of this software and associated documentation files (the "Software"), 11 // to deal in the Software without restriction, including without limitation 12 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 // and/or sell copies of the Software, and to permit persons to whom the 14 // Software is furnished to do so, subject to the following conditions: 15 // 16 // The above copyright notice and this permission notice shall be included 17 // in all copies or substantial portions of the Software. 18 // 19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 // DEALINGS IN THE SOFTWARE. 26 /*****************************************************************************/ 27 28 #ifndef __EXPANDERTHREAD_H__ 29 #define __EXPANDERTHREAD_H__ 30 31 #include <Message.h> 32 #include <Volume.h> 33 #include <String.h> 34 #include <OS.h> 35 #include <FindDirectory.h> 36 37 #include <GenericThread.h> 38 #include <stdio.h> 39 #include <stdlib.h> 40 41 extern const char * ExpanderThreadName; 42 43 class ExpanderThread : public GenericThread 44 { 45 public: 46 ExpanderThread(BMessage *refs_message, BMessenger *messenger); 47 ~ExpanderThread(); 48 49 status_t SuspendExternalExpander(); 50 status_t ResumeExternalExpander(); 51 status_t InterruptExternalExpander(); 52 status_t WaitOnExternalExpander(); 53 54 private: 55 56 virtual status_t ThreadStartup(); 57 virtual status_t ExecuteUnit(); 58 virtual status_t ThreadShutdown(); 59 60 virtual void ThreadStartupFailed(status_t a_status); 61 virtual void ExecuteUnitFailed(status_t a_status); 62 virtual void ThreadShutdownFailed(status_t a_status); 63 64 status_t ProcessRefs(BMessage * msg); 65 66 thread_id PipeCommand(int argc, const char **argv, 67 int & in, int & out, int & err, 68 const char **envp = (const char **) environ); 69 70 BMessenger * fWindowMessenger; 71 72 thread_id fThreadId; 73 int fStdIn; 74 int fStdOut; 75 int fStdErr; 76 FILE * fExpanderOutput; 77 BString fExpanderOutputString; 78 char * fExpanderOutputBuffer; 79 }; 80 81 #endif // __EXPANDERTHREAD_H__ 82