| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 | /* Getopt for Microsoft CThis code is a modification of the Free Software Foundation, Inc.Getopt library for parsing command line argument the purpose wasto provide a Microsoft Visual C friendly derivative. This codeprovides functionality for both Unicode and Multibyte builds.Date: 02/03/2011 - Ludvik Jerabek - Initial ReleaseVersion: 1.0Comment: Supports getopt, getopt_long, and getopt_long_onlyand POSIXLY_CORRECT environment flagLicense: LGPLRevisions:02/03/2011 - Ludvik Jerabek - Initial Release02/20/2011 - Ludvik Jerabek - Fixed compiler warnings at Level 407/05/2011 - Ludvik Jerabek - Added no_argument, required_argument, optional_argument defs08/03/2011 - Ludvik Jerabek - Fixed non-argument runtime bug which caused runtime exception08/09/2011 - Ludvik Jerabek - Added code to export functions for DLL and LIB02/15/2012 - Ludvik Jerabek - Fixed _GETOPT_THROW definition missing in implementation file08/01/2012 - Ludvik Jerabek - Created separate functions for char and wchar_t characters so single dll can do both unicode and ansi10/15/2012 - Ludvik Jerabek - Modified to match latest GNU features06/19/2015 - Ludvik Jerabek - Fixed maximum option limitation caused by option_a (255) and option_w (65535) structure val variable24/10/2020 - Paul-Louis Ageneau - Removed Unicode version**DISCLAIMER**THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULARPURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THEEXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOTAPPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANYDIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANYUSE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOSTPROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ONYOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE AREEXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.*/#ifndef __GETOPT_H_	#define __GETOPT_H_	#ifdef _GETOPT_API		#undef _GETOPT_API	#endif	#if defined(EXPORTS_GETOPT) && defined(STATIC_GETOPT)		#error "The preprocessor definitions of EXPORTS_GETOPT and STATIC_GETOPT can only be used individually"	#elif defined(STATIC_GETOPT)		#pragma message("Warning static builds of getopt violate the Lesser GNU Public License")		#define _GETOPT_API	#elif defined(EXPORTS_GETOPT)		#pragma message("Exporting getopt library")		#define _GETOPT_API __declspec(dllexport)	#else		#pragma message("Importing getopt library")		#define _GETOPT_API __declspec(dllimport)	#endif	// Change behavior for C\C++	#ifdef __cplusplus		#define _BEGIN_EXTERN_C extern "C" {		#define _END_EXTERN_C }		#define _GETOPT_THROW throw()	#else		#define _BEGIN_EXTERN_C		#define _END_EXTERN_C		#define _GETOPT_THROW	#endif	// Standard GNU options	#define	null_argument		0	/*Argument Null*/	#define	no_argument			0	/*Argument Switch Only*/	#define required_argument	1	/*Argument Required*/	#define optional_argument	2	/*Argument Optional*/		// Shorter Options	#define ARG_NULL	0	/*Argument Null*/	#define ARG_NONE	0	/*Argument Switch Only*/	#define ARG_REQ		1	/*Argument Required*/	#define ARG_OPT		2	/*Argument Optional*/	#include <string.h>_BEGIN_EXTERN_C	extern _GETOPT_API int optind;	extern _GETOPT_API int opterr;	extern _GETOPT_API int optopt;	struct option_a	{		const char* name;		int has_arg;		int *flag;		int val;	};	extern _GETOPT_API char *optarg_a;	extern _GETOPT_API int getopt_a(int argc, char *const *argv, const char *optstring) _GETOPT_THROW;	extern _GETOPT_API int getopt_long_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW;	extern _GETOPT_API int getopt_long_only_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW;_END_EXTERN_C	#undef _BEGIN_EXTERN_C	#undef _END_EXTERN_C	#undef _GETOPT_THROW	#undef _GETOPT_API	#define getopt getopt_a	#define getopt_long getopt_long_a	#define getopt_long_only getopt_long_only_a	#define option option_a	#define optarg optarg_a#endif  // __GETOPT_H_
 |