From eef724f3d0e751fb61be907c09d553a4beab4501 Mon Sep 17 00:00:00 2001 From: fcolin Date: Mon, 21 Apr 2008 15:33:21 +0000 Subject: compilation sous WINDOWS --- tools/Makefile.win32 | 21 ++++++++------- tools/getopt.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/getopt.h | 16 +++++++++++ 3 files changed, 104 insertions(+), 9 deletions(-) create mode 100644 tools/getopt.c create mode 100644 tools/getopt.h diff --git a/tools/Makefile.win32 b/tools/Makefile.win32 index 9149241..653a6a8 100644 --- a/tools/Makefile.win32 +++ b/tools/Makefile.win32 @@ -1,7 +1,7 @@ -PCREINC = -I "C:\Users\fcolin\Documents\Projects Visual Studio\pcre-6.4\\" -PCRELIB = ..\Release\pcre.lib -IVYLIB = ..\Release\ivy.lib -EXTRALIB= -L..\Release +PCREINC = -I "..\..\pcre-7.5\\" +PCRELIB = ..\..\..\pcre\x64\Release\pcre.lib +IVYLIB = ..\ivy.lib +EXTRALIB= EXTRAINC=-I.. #PCREINC = -I "C:\Program Files\GnuWin32\include" #`pcre-config --cflags` @@ -40,14 +40,17 @@ all: commands commands: $(TARGETS) -ivyprobe.exe: ivyprobe.obj $(IVYLIB) - $(CC) $(CFLAGS) $(EXTRAINC) /Fe$@ ivyprobe.obj $(IVYLIB) wsock32.lib $(PCRELIB) $(EXTRALIB) +ivyprobe.exe: ivyprobe.obj getopt.obj $(IVYLIB) + $(CC) $(LFLAGS) /Fe$@ ivyprobe.obj getopt.obj $(IVYLIB) wsock32.lib $(PCRELIB) $(EXTRALIB) ivyprobe.obj : ivyprobe.c - $(CC) $(CFLAGS) $(REGEXP) $(PCREINC) $(EXTRAINC) /c ivyprobe.c + $(CC) $(CFLAGS) $(EXTRAINC) $(REGEXP) $(PCREINC) $(EXTRAINC) /c ivyprobe.c -ivyperf.exe: ivyperf.obj $(IVYLIB) - $(CC) $(CFLAGS) /Fe$@ ivyperf.obj $(IVYLIB) wsock32.lib $(PCRELIB) $(EXTRALIB) +ivyperf.obj : ivyperf.c + $(CC) $(CFLAGS) $(EXTRAINC) $(REGEXP) $(PCREINC) $(EXTRAINC) /c ivyperf.c + +ivyperf.exe: ivyperf.obj getopt.obj $(IVYLIB) + $(CC) $(LFLAGS) /Fe$@ ivyperf.obj getopt.obj $(IVYLIB) wsock32.lib $(PCRELIB) $(EXTRALIB) clean: diff --git a/tools/getopt.c b/tools/getopt.c new file mode 100644 index 0000000..36a9bc1 --- /dev/null +++ b/tools/getopt.c @@ -0,0 +1,76 @@ +#include +#include +#include + +int optind = 1; +char *optarg = (char *)NULL; + +int getopt (int argc, char **argv, char *optstring) +{ + int cur_option; /* Current option */ + char *cp; /* Character pointer */ + static int GetOptionPosition = 1; + + if (GetOptionPosition == 1) + { + +/* Check for out of range, correct start character and not single */ + + if ((optind >= argc) || (*argv[optind] != '-') || !argv[optind][1]) + return EOF; + + if (!strcmp (argv[optind], "--")) + return EOF; + } + +/* Get the current character from the current argument vector */ + + cur_option = argv[optind][GetOptionPosition]; + +/* Validate it */ + + if ((cur_option == ':') || + ((cp = strchr (optstring, cur_option)) == (char *)NULL)) + { + +/* Move to the next offset */ + + if (!argv[optind][++GetOptionPosition]) + { + optind++; + GetOptionPosition = 1; + } + + return '?'; + } + +/* Parameters following ? */ + + optarg = (char *)NULL; + + if (*(++cp) == ':') + { + if (argv[optind][GetOptionPosition + 1]) + optarg = &argv[optind++][GetOptionPosition + 1]; + + else if (++optind >= argc) + { + optarg = (char *)NULL; + GetOptionPosition = 1; + return '?'; + } + + else + optarg = argv[optind++]; + + GetOptionPosition = 1; + } + + else if (!argv[optind][++GetOptionPosition]) + { + GetOptionPosition = 1; + optind++; + } + + return cur_option; +} diff --git a/tools/getopt.h b/tools/getopt.h new file mode 100644 index 0000000..d52543f --- /dev/null +++ b/tools/getopt.h @@ -0,0 +1,16 @@ +#ifndef __GETOPT_H_ +#define __GETOPT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int optind ; +extern char *optarg ; +extern int getopt (int argc, char **argv, char *optstring) ; + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.1