args.h

00001 /*  wcecompat: Windows CE C Runtime Library "compatibility" library.
00002  *
00003  *  Copyright (C) 2001-2002 Essemer Pty Ltd.  All rights reserved.
00004  *  http://www.essemer.com.au/
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 
00022 #ifndef __wcecompat__ARGS_H__
00023 #define __wcecompat__ARGS_H__
00024 
00025 
00026 #include <windows.h>
00027 
00028 
00029 // generate argc/argv from program name and lpCmdLine
00030 // returns 0 on failure, or argc on success
00031 int processCmdLine(LPTSTR lpCmdLine, char*** pArgv);
00032 
00033 
00034 enum RedirType {
00035         RT_NONE,
00036         RT_PIPE_UNSPEC,         // unspecified pipe (one of stdin, stdout, stderr, but unknown which it is)
00037         RT_PIPE_STDIN,
00038         RT_PIPE_STDOUT,         // 2>&1 >file (stderr is redirected to original stdout, stdout to file)
00039         RT_PIPE_STDERR,         // >&2 2>file (stdout is redirected to original stderr, stderr to file)
00040         RT_HANDLE,                      // >file 2>&1 (stdout is redirected to file, stderr to same file via stdout)
00041         RT_FILE,                        // >file 2>file <file
00042 };
00043 
00044 typedef struct
00045 {
00046         RedirType       redirType;
00047         int                     fd;                             // file descriptor being redirected
00048         int                     fd2;                    // file descriptor being redirected to/from (only valid if redirType==RT_HANDLE)
00049         TCHAR*          filename;               // filename associated with redirection (only valid if redirType==RT_FILE or PIPE_UNSP*)
00050         bool            append;                 // true if the file being redirected to should be appending to
00051         bool            openForRead;    // true if the file being redirected to/from should be opened for reading
00052         bool            openForWrite;   // true if the file being redirected to/from should be opened for writing
00053 } RedirArg;
00054 
00055 // get redirection arguments, ie. filenames that relate to redirection.
00056 // NULL returned for redirections that aren't specified.
00057 // Same filename may be returned for multiple redirections, such as for: >foo 2>&1
00058 // The filename buffers must be free()'d.
00059 bool getRedirArgs(LPTSTR lpCmdLine, RedirArg** redirArgs, int* numRedirArgs);
00060 
00061 bool removeRedirArgs(LPTSTR lpCmdLine);
00062 
00063 
00064 #endif // __wcecompat__ARGS_H__

Generated on Mon Jun 5 10:20:48 2006 for Intelligence.kdevelop by  doxygen 1.4.6