- add mising files to mingw library

- readd getopt (needed by dosfsck)
- reorder alphabetically

svn path=/branches/ros-amd64-bringup/; revision=37100
This commit is contained in:
Timo Kreuzer
2008-10-30 14:14:06 +00:00
parent 5a73314ad0
commit 698706d107
4 changed files with 256 additions and 5 deletions

15
reactos/lib/3rdparty/mingw/_wgetopt.c vendored Normal file
View File

@@ -0,0 +1,15 @@
/* $Id$
*/
/*
tgetopt -- POSIX-compliant implementation of getopt() with string-type-generic
semantics
This is public domain software
*/
#include <wchar.h>
#define _UNICODE
#include "getopt.c"
/* EOF */

137
reactos/lib/3rdparty/mingw/getopt.c vendored Normal file
View File

@@ -0,0 +1,137 @@
/* $Id$
*/
/*
tgetopt -- POSIX-compliant implementation of getopt() with string-type-generic
semantics
This is public domain software
*/
#include <tchar.h>
#include <string.h>
#include <stdio.h>
#include "tgetopt.h"
int _topterr = 1;
int _toptind = 1;
int _toptopt;
_TCHAR * _toptarg;
int _tgetopt(int argc, _TCHAR * const argv[], const _TCHAR * optstring)
{
static int s_nArgChar = 0;
_TCHAR * pcOptChar;
/* we're done */
if(_toptind >= argc) return -1;
/* last time we reached the end of argv[_toptind] */
if(s_nArgChar != 0 && argv[_toptind][s_nArgChar] == 0)
{
/* scan the next argument */
++ _toptind;
/* we're done */
if(_toptind >= argc) return -1;
s_nArgChar = 0;
}
/* first time we scan argv[_toptind] */
if(s_nArgChar == 0)
{
/* argument is NULL - we're done */
if(argv[_toptind] == NULL)
return (int)-1;
/* argument is empty - we're done */
else if(argv[_toptind][0] == 0)
return (int)-1;
/* argument begins with '-' */
else if(argv[_toptind][0] == _T('-'))
{
/* argument is "--" */
if(argv[_toptind][1] == _T('-'))
{
/* increment optind */
++ _toptind;
s_nArgChar = 0;
/* we're done */
return (int)-1;
}
/* argument is "-" */
else if(argv[_toptind][1] == 0)
{
/* we're done */
return (int)-1;
}
/* possible option */
else
++ s_nArgChar;
}
/* argument doesn't begin with a dash - we're done */
else
return (int)-1;
}
/* return the current character */
_toptopt = argv[_toptind][s_nArgChar];
/* advance to the next character */
++ s_nArgChar;
/* unrecognized option */
if(_toptopt == _T(':') || (pcOptChar = _tcschr(optstring, _toptopt)) == NULL)
{
/* print an error message */
if(_topterr && optstring[0] != _T(':'))
_ftprintf(stderr, _T("%s: illegal option -- %c\n"), argv[0], _toptopt);
/* return an error */
return _T('?');
}
/* the option requires an argument */
if(pcOptChar[1] == _T(':'))
{
/* we are at the end of the argument */
if(argv[_toptind][s_nArgChar] == 0)
{
/* the argument of the option is the next argument */
++ _toptind;
s_nArgChar = 0;
/* this is the last argument */
if(_toptind >= argc)
{
/* print an error message */
if(_topterr && optstring[0] != _T(':'))
{
_ftprintf
(
stderr,
_T("%s: option requires an argument -- %c\n"),
argv[0],
_toptopt
);
}
/* return an error */
return ((optstring[0] == _T(':')) ? _T(':') : _T('?'));
}
/* return the argument */
_toptarg = argv[_toptind];
++ _toptind;
}
/* the rest of the argument is the argument of the option */
else
_toptarg = argv[_toptind] + s_nArgChar;
}
/* success */
return _toptopt;
}
/* EOF */

View File

@@ -4,21 +4,30 @@
<module name="mingw_common" type="staticlibrary" isstartuplib="true" underscoresymbols="true">
<importlibrary definition="moldname-msvcrt.def" dllname="msvcrt.dll" />
<include base="mingw_common">include</include>
<file>CRT_fp10.c</file>
<file>_newmode.c</file>
<file>_wgetopt.c</file>
<file>argv.c</file>
<file>atonexit.c</file>
<file>binmode.c</file>
<file>charmax.c</file>
<file>cinitexe.c</file>
<file>CRT_fp10.c</file>
<file>crtdll.c</file>
<file>dllentry.c</file>
<file>dllmain.c</file>
<file>gccmain.c</file>
<file>getopt.c</file>
<file>gs_support.c</file>
<file>merr.c</file>
<file>mingw_helpers.c</file>
<file>natstart.c</file>
<file>_newmode.c</file>
<file>pesect.c</file>
<file>wildcard.c</file>
<file>xtxtmode.c</file>
<file>xncommod.c</file>
<file>pseudo-reloc.c</file>
<file>tlssup.c</file>
<file>wildcard.c</file>
<file>xncommod.c</file>
<file>xthdloc.c</file>
<file>xtxtmode.c</file>
</module>
<module name="mingw_main" type="staticlibrary" isstartuplib="true" allowwarnings="true">
<include base="mingw_common">include</include>

90
reactos/lib/3rdparty/mingw/tgetopt.h vendored Normal file
View File

@@ -0,0 +1,90 @@
#ifndef _GETOPT_H
#define _GETOPT_H 1
#include <tchar.h>
#ifdef _UNICODE
#define _toption _woption
#define _toptarg _woptarg
#define _toptind _woptind
#define _topterr _wopterr
#define _toptopt _woptopt
#define _tgetopt _wgetopt
#define _tgetopt_long _wgetopt_long
#define _tgetopt_long_only _wgetopt_long_only
#define _tgetopt_internal _wgetopt_internal
#else
#define _toption option
#define _toptarg optarg
#define _toptind optind
#define _topterr opterr
#define _toptopt optopt
#define _tgetopt getopt
#define _tgetopt_long getopt_long
#define _tgetopt_long_only getopt_long_only
#define _tgetopt_internal _getopt_internal
#endif
#ifdef __cplusplus
extern "C"
{
#endif
extern char *optarg;
extern int optind;
extern int opterr;
extern int optopt;
extern wchar_t *_woptarg;
extern int _woptind;
extern int _wopterr;
extern int _woptopt;
struct option
{
const char *name;
int has_arg;
int *flag;
int val;
};
struct _woption
{
const wchar_t *name;
int has_arg;
int *flag;
int val;
};
#define no_argument 0
#define required_argument 1
#define optional_argument 2
extern int getopt (int argc, char *const *argv, const char *shortopts);
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,
const char *shortopts, const struct option *longopts, int *longind);
extern int _wgetopt (int argc, wchar_t *const *argv, const wchar_t *shortopts);
extern int _wgetopt_long (int argc, wchar_t *const *argv, const wchar_t *shortopts,
const struct _woption *longopts, int *longind);
extern int _wgetopt_long_only (int argc, wchar_t *const *argv,
const wchar_t *shortopts,
const struct _woption *longopts, int *longind);
extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts, const struct option *longopts, int *longind,
int long_only);
extern int _wgetopt_internal (int argc, wchar_t *const *argv,
const wchar_t *shortopts,
const struct _woption *longopts, int *longind,
int long_only);
#ifdef __cplusplus
}
#endif
#endif /* _GETOPT_H */