merge the formfield patch from ooo-build
[ooovba.git] / tools / inc / bootstrp / command.hxx
blobe499600699757cad4ba7686c016fdd7300b7852f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: command.hxx,v $
10 * $Revision: 1.6.40.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef COMMAND_HXX
32 #define COMMAND_HXX
34 #include <iostream>
36 #include <tools/stream.hxx>
37 #define STRLEN 100
38 #ifndef UNX
39 #define TMPNAME "\\command.tmp"
40 #else
41 #define TMPNAME "/tmp/command.tmp"
42 #endif
44 /** Different types of spawnable programs
46 enum ExeType
48 EXE, /// programm is a native executable
49 BAT, /// programm is a DOS-Batch
50 BTM /// programm is a 4DOS-Batch
53 #define COMMAND_NOTFOUND 0x0001
54 #define COMMAND_TOOBIG 0x0002
55 #define COMMAND_INVALID 0x0004
56 #define COMMAND_NOEXEC 0x0008
57 #define COMMAND_NOMEM 0x0010
58 #define COMMAND_UNKNOWN 0x0020
60 #ifdef WNT
61 #define COMMAND_SHELL "4nt.exe"
62 #endif
63 #ifdef OS2
64 #define COMMAND_SHELL "4os2.exe"
65 #endif
66 #ifdef UNX
67 #define COMMAND_SHELL "csh"
68 #endif
70 class CommandLine;
71 class LogWindow;
73 class CommandLine
75 friend class ChildProcess;
76 private:
77 char *CommandBuffer;
78 char *ComShell;
79 char **ppArgv;
80 BOOL bTmpWrite;
82 public:
83 CommandLine(BOOL bTmpWrite = FALSE);
84 CommandLine(const char *, BOOL bTmpWrite = FALSE);
85 CommandLine(const CommandLine&, BOOL bTmpWrite = FALSE);
86 virtual ~CommandLine();
88 int nArgc;
90 CommandLine& operator=(const CommandLine&);
91 CommandLine& operator=(const char *);
92 void BuildCommand(const char *);
93 char** GetCommand(void) { return ppArgv; }
94 void Strtokens(const char *);
95 void Print();
98 static ByteString thePath( "PATH" );
100 /** Declares and spawns a child process.
101 The spawned programm could be a native executable or a schell script.
103 class CCommand
105 private:
106 ByteString aCommandLine;
107 ByteString aCommand;
108 char *pArgv;
109 char **ppArgv;
110 ULONG nArgc;
111 int nError;
113 protected:
114 void ImplInit();
115 void Initpp( ULONG nCount, ByteString &rStr );
117 public:
118 /** Creates the process specified without spawning it
119 @param rString specifies the programm or shell scrip
121 CCommand( ByteString &rString );
123 /** Creates the process specified without spawning it
124 @param pChar specifies the programm or shell scrip
126 CCommand( const char *pChar );
128 /** Try to find the given programm in specified path
129 @param sEnv specifies the current search path, defaulted by environment
130 @param sItem specifies the system shell
131 @return the Location (when programm was found)
133 static ByteString Search( ByteString sEnv = thePath,
134 ByteString sItem = COMMAND_SHELL );
136 /** Spawns the Process
137 @return 0 when spawned without errors, otherwise a error code
139 operator int();
141 ByteString GetCommandLine_() { return aCommandLine; }
142 ByteString GetCommand() { return aCommand; }
144 char** GetCommandStr() { return ppArgv; }
147 #define COMMAND_EXECUTE_WINDOW 0x0000001
148 #define COMMAND_EXECUTE_CONSOLE 0x0000002
149 #define COMMAND_EXECUTE_HIDDEN 0x0000004
150 #define COMMAND_EXECUTE_START 0x0000008
151 #define COMMAND_EXECUTE_WAIT 0x0000010
152 #define COMMAND_EXECUTE_REMOTE 0x1000000
154 typedef ULONG CommandBits;
156 /** Allowes to spawn programms hidden, waiting etc.
157 @see CCommand
159 class CCommandd : public CCommand
161 CommandBits nFlag;
162 public:
163 CCommandd( ByteString &rString, CommandBits nBits );
164 CCommandd( const char *pChar, CommandBits nBits );
165 operator int();
168 #endif