view lib/getsubopt.h @ 5138:965e5e2eaeac

New module 'getsubopt'.
author Bruno Haible <bruno@clisp.org>
date Fri, 06 Aug 2004 20:23:41 +0000
parents
children a48fb0e98c8c
line wrap: on
line source

/* Parse comma separate list into words.
   Copyright (C) 2004 Free Software Foundation, Inc.
   Contributed by Simon Josefsson <jas@extundo.com>, 2004.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

/* Assuming *OPTIONP is a comma separated list of elements of the form
   "token" or "token=value", getsubopt parses the first of these elements.
   If the first element refers to a "token" that is member of the given
   NULL-terminated array of tokens:
     - It replaces the comma with a NUL byte, updates *OPTIONP to point past
       the first option and the comma, sets *VALUEP to the value of the
       element (or NULL if it doesn't contain an "=" sign),
     - It returns the index of the "token" in the given array of tokens.
   Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
   For more details see the POSIX:2001 specification.
   http://www.opengroup.org/onlinepubs/009695399/functions/getsubopt.html */

#if HAVE_GETSUBOPT

/* Get getsubopt declaration.  */
#include <stdlib.h>

#else

extern int getsubopt (char **optionp, char *const *tokens, char **valuep);

#endif