00001 /* $NetBSD: getopt.h,v 1.10.6.1 2008/05/18 12:30:09 yamt 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 /* Ported to HelenOS August 2008 by Tim Post <echo@echoreply.us> */ 00033 00034 #ifndef _GETOPT_H_ 00035 #define _GETOPT_H_ 00036 00037 #include <unistd.h> 00038 00039 /* 00040 * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions 00041 */ 00042 #define no_argument 0 00043 #define required_argument 1 00044 #define optional_argument 2 00045 00046 struct option { 00047 /* name of long option */ 00048 const char *name; 00049 /* 00050 * one of no_argument, required_argument, and optional_argument: 00051 * whether option takes an argument 00052 */ 00053 int has_arg; 00054 /* if not NULL, set *flag to val when option found */ 00055 int *flag; 00056 /* if flag not NULL, value to set *flag to; else return value */ 00057 int val; 00058 }; 00059 00060 /* HelenOS Port - These need to be exposed for legacy getopt() */ 00061 extern const char *optarg; 00062 extern int optind, opterr, optopt; 00063 extern int optreset; 00064 00065 int getopt_long(int, char * const *, const char *, 00066 const struct option *, int *); 00067 00068 /* HelenOS Port : Expose legacy getopt() */ 00069 int getopt(int, char * const [], const char *); 00070 00071 #endif /* !_GETOPT_H_ */