.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 1996-2005 SAP AG-2002$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VPS99C$
.tt 2 $$$
.tt 3 $$Standard system routines$2000-03-21$
****************************************************************
.nf

.nf

.nf

    ========== licence begin  GPL
    Copyright (c) 1996-2005 SAP AG

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

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
.fo


.fo


.fo
Module  :
=========
.sp
Purpose :
.CM *-END-* purpose -------------------------------------
Define  :

#include <stdio.h>

#ifdef __cplusplus
   extern "C" char *optarg;	
   extern "C" int optind;	
   extern "C" int opterr;	
   extern "C" int optopt;	
#else
  extern char *optarg;		
  extern int optind;		
  extern int opterr;		
  extern int optopt;		
#endif

#ifdef  WIN32
#  ifdef __cplusplus
     extern "C" {
#  endif

  int	getopt(int argc, char **argv, const char *ostr);
  FILE *	popen(const char *command, const char *mode);
#  ifdef __cplusplus
     }
#  endif

#endif
.CM *-END-* define --------------------------------------
Use     :
.CM *-END-* use -----------------------------------------
Synonym :
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  :
.sp
.cp 3
Created : 1996-06-21
.sp
.cp 3
Version : 1996-06-21
.sp
.cp 3
Release :      Date : 2000-03-21
Specification:
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.sp
.CM -lll-
Code    :
/*PRETTY*/

/* got this off net.sources */
#include <string.h>
#ifndef _GETOPT_
#define _GETOPT_


#define BADCH ('?')

#endif /* _GETOPT */

/*
 * get option letter from argument vector
 */
int
	opterr = 1,		/* should error messages be printed? */
	optind = 1,		/* index into parent argv vector     */
	optopt;			/* character checked for validity    */
char
	*optarg;		/* argument associated with option */

#define EMSG	""

char *progname;			/* may also be defined elsewhere */

static void
error(char *pch)
{
	if (!opterr) {
		return;		/* without printing */
	}
	fprintf(stderr, "%s: %s: %c\n",
		(NULL != progname) ? progname : "getopt", pch, optopt);
}

int
getopt(int argc, char **argv, const char *ostr)
{
	static char *place = EMSG;	/* option letter processing */
	register char *oli;			/* option letter list index */

	if (!*place) {
		// update scanning pointer
		if (optind >= argc || *(place = argv[optind]) != '-' || !*++place) {
			return EOF;
		}
		if (*place == '-') {
			/* found "--" */
			++optind;
			return EOF;
		}
	}

	/* option letter okay? */
	if ((optopt = (int)*place++) == (int)':'
		|| !(oli = strchr(ostr, optopt))) {
		if (!*place) {
			++optind;
		}
		error("illegal option");
		return BADCH;
	}
	if (*++oli != ':') {	
		/* don't need argument */
		optarg = NULL;
		if (!*place)
			++optind;
	} else {
		/* need an argument */
		if (*place) {
			optarg = place;		/* no white space */
		} else  if (argc <= ++optind) {
			/* no arg */
			place = EMSG;
			error("option requires an argument");
			return BADCH;
		} else {
			optarg = argv[optind];		/* white space */
		}
		place = EMSG;
		++optind;
	}
	return optopt;			/* return option letter */
}

FILE *
popen(const char *command, const char *mode)
{
	return _popen(command, mode);
}

.CM *-END-* code ----------------------------------------
.SP 2
***********************************************************
