![]() |
![]() |
00001 /* $NetBSD: getopt.h,v 1.11 2008/04/28 20:22:54 martin Exp $ */ 00002 00003 /*- 00004 * Copyright (c) 2000 The NetBSD Foundation, Inc. 00005 * All rights reserved. 00006 * 00007 * This code is derived from software contributed to The NetBSD Foundation 00008 * by Dieter Baron and Thomas Klausner. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 00020 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00021 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00022 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 00023 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 * POSSIBILITY OF SUCH DAMAGE. 00030 */ 00031 /* 00032 * Copyright (c) 2010, Texas Instruments Incorporated 00033 * 00034 * Modification to the original source to remove some external header file 00035 * and definition dependency. Very limited testing done after the changes. 00036 */ 00037 #ifndef _GETOPT_H_ 00038 #define _GETOPT_H_ 00039 00040 //#include <sys/cdefs.h> 00041 //#include <unistd.h> 00042 00043 /* 00044 * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions 00045 */ 00046 #define no_argument 0 00047 #define required_argument 1 00048 #define optional_argument 2 00049 00050 extern char *optarg; 00051 extern int optind; 00052 00053 struct option { 00054 /* name of long option */ 00055 const char *name; 00056 /* 00057 * one of no_argument, required_argument, and optional_argument: 00058 * whether option takes an argument 00059 */ 00060 int has_arg; 00061 /* if not NULL, set *flag to val when option found */ 00062 int *flag; 00063 /* if flag not NULL, value to set *flag to; else return value */ 00064 int val; 00065 }; 00066 00067 //__BEGIN_DECLS 00068 int getopt_long(int, char * const *, const char *, 00069 const struct option *, int *); 00070 //__END_DECLS 00071 00072 #endif /* !_GETOPT_H_ */