mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-20 05:19:21 +08:00
* libc/argz/argz_replace.c: Include buf_findstr.h.
* libc/argz/buf_findstr.c: Likewise. * libc/argz/envz_entry.c: Include buf_findstr.h. Cast return value to (char *). * libc/argz/envz_get.c: Likewise. * libc/include/sys/unistd.h: Add getopt and getsubopt declarations. * libc/stdlib/Makefile.am (LIB_SOURCES): Add getsubopt.c. * libc/stdlib/getsubopt.3: New file. * libc/stdlib/getsubopt.c: New file. * libc/sys/linux/machine/i386/socketcall.h (__sockcall_base): Change esp to ebp.
This commit is contained in:
parent
d477c5225d
commit
9b022d6db8
@ -1,3 +1,17 @@
|
|||||||
|
2002-07-19 Thomas Fitzsimmons <fitzsim@redhat.com>
|
||||||
|
|
||||||
|
* libc/argz/argz_replace.c: Include buf_findstr.h.
|
||||||
|
* libc/argz/buf_findstr.c: Likewise.
|
||||||
|
* libc/argz/envz_entry.c: Include buf_findstr.h. Cast return
|
||||||
|
value to (char *).
|
||||||
|
* libc/argz/envz_get.c: Likewise.
|
||||||
|
* libc/include/sys/unistd.h: Add getopt and getsubopt declarations.
|
||||||
|
* libc/stdlib/Makefile.am (LIB_SOURCES): Add getsubopt.c.
|
||||||
|
* libc/stdlib/getsubopt.3: New file.
|
||||||
|
* libc/stdlib/getsubopt.c: New file.
|
||||||
|
* libc/sys/linux/machine/i386/socketcall.h (__sockcall_base):
|
||||||
|
Change esp to ebp.
|
||||||
|
|
||||||
2002-07-17 Jeff Johnston <jjohnstn@redhat.com>
|
2002-07-17 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
* configure.host(stdio64_dir): New setting that is used to
|
* configure.host(stdio64_dir): New setting that is used to
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
# have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
|
# have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
|
||||||
# posix_dir "posix" to build libc/posix, "" otherwise
|
# posix_dir "posix" to build libc/posix, "" otherwise
|
||||||
# signal_dir "signal" to build libc/signal, "" otherwise
|
# signal_dir "signal" to build libc/signal, "" otherwise
|
||||||
# stdio64_dir "stdio64" to build libc/stdio64, "" otherwise
|
# stdio64_dir "stdio64" to build libc/stdio64, "" otherwise
|
||||||
# syscall_dir "syscalls" to build libc/syscalls, "" otherwise
|
# syscall_dir "syscalls" to build libc/syscalls, "" otherwise
|
||||||
# unix_dir "unix" to build libc/unix, "" otherwise
|
# unix_dir "unix" to build libc/unix, "" otherwise
|
||||||
# use_libtool flag: use libtool to build newlib?
|
# use_libtool flag: use libtool to build newlib?
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <argz.h>
|
#include <argz.h>
|
||||||
|
|
||||||
extern int buf_findstr(const char *str, char **buf, size_t *buf_len);
|
#include "buf_findstr.h"
|
||||||
|
|
||||||
error_t
|
error_t
|
||||||
argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count)
|
argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count)
|
||||||
@ -31,7 +31,7 @@ argz_replace (char **argz, size_t *argz_len, const char *str, const char *with,
|
|||||||
|
|
||||||
while(buf_len)
|
while(buf_len)
|
||||||
{
|
{
|
||||||
if(buf_findstr(str, &buf_iter, &buf_len))
|
if(_buf_findstr(str, &buf_iter, &buf_len))
|
||||||
{
|
{
|
||||||
*replace_count += 1;
|
*replace_count += 1;
|
||||||
new_argz_len += len_diff;
|
new_argz_len += len_diff;
|
||||||
@ -49,7 +49,7 @@ argz_replace (char **argz, size_t *argz_len, const char *str, const char *with,
|
|||||||
|
|
||||||
while(buf_len)
|
while(buf_len)
|
||||||
{
|
{
|
||||||
if (buf_findstr(str, &buf_iter, &buf_len))
|
if (_buf_findstr(str, &buf_iter, &buf_len))
|
||||||
{
|
{
|
||||||
/* copy everything up to, but not including str, from old argz to
|
/* copy everything up to, but not including str, from old argz to
|
||||||
new argz. */
|
new argz. */
|
||||||
|
@ -9,10 +9,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "buf_findstr.h"
|
||||||
|
|
||||||
/* Find string str in buffer buf of length buf_len. Point buf to character after string,
|
/* Find string str in buffer buf of length buf_len. Point buf to character after string,
|
||||||
or set it to NULL if end of buffer is reached. Return 1 if found, 0 if not. */
|
or set it to NULL if end of buffer is reached. Return 1 if found, 0 if not. */
|
||||||
int
|
int
|
||||||
buf_findstr(const char *str, const char **buf, size_t *buf_len)
|
_buf_findstr(const char *str, char **buf, size_t *buf_len)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
12
newlib/libc/argz/buf_findstr.h
Normal file
12
newlib/libc/argz/buf_findstr.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software
|
||||||
|
* is freely granted, provided that this notice is preserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/* Find string str in buffer buf of length buf_len. Point buf to
|
||||||
|
character after string, or set it to NULL if end of buffer is
|
||||||
|
reached. Return 1 if found, 0 if not. */
|
||||||
|
int _buf_findstr(const char *str, char **buf, size_t *buf_len);
|
@ -10,17 +10,17 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <envz.h>
|
#include <envz.h>
|
||||||
|
|
||||||
extern int buf_findstr(const char *str, char **buf, size_t *buf_len);
|
#include "buf_findstr.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
envz_entry (const char *envz, size_t envz_len, const char *name)
|
envz_entry (const char *envz, size_t envz_len, const char *name)
|
||||||
{
|
{
|
||||||
const char *buf_ptr = envz;
|
char *buf_ptr = (char *)envz;
|
||||||
size_t buf_len = envz_len;
|
size_t buf_len = envz_len;
|
||||||
|
|
||||||
while(buf_len)
|
while(buf_len)
|
||||||
{
|
{
|
||||||
if (buf_findstr(name, &buf_ptr, &buf_len))
|
if (_buf_findstr(name, &buf_ptr, &buf_len))
|
||||||
{
|
{
|
||||||
if (buf_ptr)
|
if (buf_ptr)
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ envz_entry (const char *envz, size_t envz_len, const char *name)
|
|||||||
if(*buf_ptr == '\0')
|
if(*buf_ptr == '\0')
|
||||||
buf_ptr++;
|
buf_ptr++;
|
||||||
|
|
||||||
return buf_ptr;
|
return (char *)buf_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,22 +10,22 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <envz.h>
|
#include <envz.h>
|
||||||
|
|
||||||
extern int buf_findstr(const char *str, char **buf, size_t *buf_len);
|
#include "buf_findstr.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
envz_get (const char *envz, size_t envz_len, const char *name)
|
envz_get (const char *envz, size_t envz_len, const char *name)
|
||||||
{
|
{
|
||||||
const char *buf_ptr = envz;
|
char *buf_ptr = (char *)envz;
|
||||||
size_t buf_len = envz_len;
|
size_t buf_len = envz_len;
|
||||||
|
|
||||||
while(buf_len)
|
while(buf_len)
|
||||||
{
|
{
|
||||||
if (buf_findstr(name, &buf_ptr, &buf_len))
|
if (_buf_findstr(name, &buf_ptr, &buf_len))
|
||||||
{
|
{
|
||||||
if (*buf_ptr == '=')
|
if (*buf_ptr == '=')
|
||||||
{
|
{
|
||||||
buf_ptr++;
|
buf_ptr++;
|
||||||
return buf_ptr;
|
return (char *)buf_ptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@ envz_merge (char **envz, size_t *envz_len, const char *envz2, size_t envz2_len,
|
|||||||
char *name_iter = NULL;
|
char *name_iter = NULL;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
while((entry = argz_next(envz2, envz2_len, entry)) && !retval)
|
while((entry = argz_next((char *)envz2, envz2_len, entry)) && !retval)
|
||||||
{
|
{
|
||||||
if (!override)
|
if (!override)
|
||||||
{
|
{
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__arm__) || defined(__thumb__)
|
#if (defined(__arm__) || defined(__thumb__))
|
||||||
/* ARM always has big-endian words. Within those words the byte ordering
|
/* ARM always has big-endian words. Within those words the byte ordering
|
||||||
will be big or little endian depending upon the target. */
|
will be big or little endian depending upon the target. */
|
||||||
#define __IEEE_BIG_ENDIAN
|
#define __IEEE_BIG_ENDIAN
|
||||||
|
@ -118,8 +118,16 @@ int _EXFUN(unlink, (const char *__path ));
|
|||||||
int _EXFUN(vhangup, (void ));
|
int _EXFUN(vhangup, (void ));
|
||||||
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
|
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
|
||||||
|
|
||||||
|
extern char *optarg; /* getopt(3) external variables */
|
||||||
|
extern int optind, opterr, optopt;
|
||||||
|
int getopt(int, char * const [], const char *);
|
||||||
|
extern int optreset; /* getopt(3) external variable */
|
||||||
|
|
||||||
#ifndef _POSIX_SOURCE
|
#ifndef _POSIX_SOURCE
|
||||||
pid_t _EXFUN(vfork, (void ));
|
pid_t _EXFUN(vfork, (void ));
|
||||||
|
|
||||||
|
extern char *suboptarg; /* getsubopt(3) external variable */
|
||||||
|
int getsubopt(char **, char * const *, char **);
|
||||||
#endif /* _POSIX_SOURCE */
|
#endif /* _POSIX_SOURCE */
|
||||||
|
|
||||||
/* Provide prototypes for most of the _<systemcall> names that are
|
/* Provide prototypes for most of the _<systemcall> names that are
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
@ -114,7 +116,10 @@ LIB_SOURCES = \
|
|||||||
freopen64.c \
|
freopen64.c \
|
||||||
fseeko64.c \
|
fseeko64.c \
|
||||||
fsetpos64.c \
|
fsetpos64.c \
|
||||||
|
fstat64r.c \
|
||||||
ftello64.c \
|
ftello64.c \
|
||||||
|
lseek64r.c \
|
||||||
|
open64r.c \
|
||||||
stdio64.c \
|
stdio64.c \
|
||||||
tmpfile64.c
|
tmpfile64.c
|
||||||
|
|
||||||
@ -138,7 +143,10 @@ CHEWOUT_FILES = \
|
|||||||
freopen64.def \
|
freopen64.def \
|
||||||
fseeko64.def \
|
fseeko64.def \
|
||||||
fsetpos64.def \
|
fsetpos64.def \
|
||||||
|
fstat64r.def \
|
||||||
ftello64.def \
|
ftello64.def \
|
||||||
|
lseek64r.def \
|
||||||
|
open64r.def \
|
||||||
tmpfile64.def
|
tmpfile64.def
|
||||||
|
|
||||||
|
|
||||||
@ -161,14 +169,16 @@ lib_a_LIBADD =
|
|||||||
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = fgetpos64.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = fgetpos64.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@fopen64.$(OBJEXT) freopen64.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@fopen64.$(OBJEXT) freopen64.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@fseeko64.$(OBJEXT) fsetpos64.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@fseeko64.$(OBJEXT) fsetpos64.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@ftello64.$(OBJEXT) stdio64.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@fstat64r.$(OBJEXT) ftello64.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@tmpfile64.$(OBJEXT)
|
@USE_LIBTOOL_FALSE@lseek64r.$(OBJEXT) open64r.$(OBJEXT) \
|
||||||
|
@USE_LIBTOOL_FALSE@stdio64.$(OBJEXT) tmpfile64.$(OBJEXT)
|
||||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||||
|
|
||||||
libstdio64_la_LIBADD =
|
libstdio64_la_LIBADD =
|
||||||
@USE_LIBTOOL_TRUE@libstdio64_la_OBJECTS = fgetpos64.lo fopen64.lo \
|
@USE_LIBTOOL_TRUE@libstdio64_la_OBJECTS = fgetpos64.lo fopen64.lo \
|
||||||
@USE_LIBTOOL_TRUE@freopen64.lo fseeko64.lo fsetpos64.lo ftello64.lo \
|
@USE_LIBTOOL_TRUE@freopen64.lo fseeko64.lo fsetpos64.lo fstat64r.lo \
|
||||||
@USE_LIBTOOL_TRUE@stdio64.lo tmpfile64.lo
|
@USE_LIBTOOL_TRUE@ftello64.lo lseek64r.lo open64r.lo stdio64.lo \
|
||||||
|
@USE_LIBTOOL_TRUE@tmpfile64.lo
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
@ -33,6 +33,7 @@ LIB_SOURCES = \
|
|||||||
getenv.c \
|
getenv.c \
|
||||||
getenv_r.c \
|
getenv_r.c \
|
||||||
getopt.c \
|
getopt.c \
|
||||||
|
getsubopt.c \
|
||||||
jrand48.c \
|
jrand48.c \
|
||||||
l64a.c \
|
l64a.c \
|
||||||
labs.c \
|
labs.c \
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
@ -137,6 +139,7 @@ LIB_SOURCES = \
|
|||||||
getenv.c \
|
getenv.c \
|
||||||
getenv_r.c \
|
getenv_r.c \
|
||||||
getopt.c \
|
getopt.c \
|
||||||
|
getsubopt.c \
|
||||||
jrand48.c \
|
jrand48.c \
|
||||||
l64a.c \
|
l64a.c \
|
||||||
labs.c \
|
labs.c \
|
||||||
@ -275,17 +278,18 @@ LIBS = @LIBS@
|
|||||||
@USE_LIBTOOL_FALSE@efgcvt.$(OBJEXT) environ.$(OBJEXT) envlock.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@efgcvt.$(OBJEXT) environ.$(OBJEXT) envlock.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@eprintf.$(OBJEXT) erand48.$(OBJEXT) exit.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@eprintf.$(OBJEXT) erand48.$(OBJEXT) exit.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@getenv.$(OBJEXT) getenv_r.$(OBJEXT) getopt.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@getenv.$(OBJEXT) getenv_r.$(OBJEXT) getopt.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@jrand48.$(OBJEXT) l64a.$(OBJEXT) labs.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@getsubopt.$(OBJEXT) jrand48.$(OBJEXT) l64a.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@lcong48.$(OBJEXT) ldiv.$(OBJEXT) ldtoa.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@labs.$(OBJEXT) lcong48.$(OBJEXT) ldiv.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@lrand48.$(OBJEXT) malign.$(OBJEXT) malloc.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@ldtoa.$(OBJEXT) lrand48.$(OBJEXT) malign.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@mblen.$(OBJEXT) mblen_r.$(OBJEXT) mbstowcs.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@malloc.$(OBJEXT) mblen.$(OBJEXT) mblen_r.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@mbstowcs_r.$(OBJEXT) mbtowc.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@mbstowcs.$(OBJEXT) mbstowcs_r.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@mbtowc_r.$(OBJEXT) mlock.$(OBJEXT) mprec.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@mbtowc.$(OBJEXT) mbtowc_r.$(OBJEXT) mlock.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@mrand48.$(OBJEXT) msize.$(OBJEXT) mstats.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@mprec.$(OBJEXT) mrand48.$(OBJEXT) msize.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@mtrim.$(OBJEXT) nrand48.$(OBJEXT) on_exit.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@mstats.$(OBJEXT) mtrim.$(OBJEXT) nrand48.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@putenv.$(OBJEXT) putenv_r.$(OBJEXT) rand.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@on_exit.$(OBJEXT) putenv.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@rand48.$(OBJEXT) rand_r.$(OBJEXT) realloc.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@putenv_r.$(OBJEXT) rand.$(OBJEXT) rand48.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@seed48.$(OBJEXT) setenv.$(OBJEXT) setenv_r.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@rand_r.$(OBJEXT) realloc.$(OBJEXT) seed48.$(OBJEXT) \
|
||||||
|
@USE_LIBTOOL_FALSE@setenv.$(OBJEXT) setenv_r.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@srand48.$(OBJEXT) strdup.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@srand48.$(OBJEXT) strdup.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@strdup_r.$(OBJEXT) strtod.$(OBJEXT) strtol.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@strdup_r.$(OBJEXT) strtod.$(OBJEXT) strtol.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@strtoll.$(OBJEXT) strtoll_r.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@strtoll.$(OBJEXT) strtoll_r.$(OBJEXT) \
|
||||||
@ -307,14 +311,14 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
|
|||||||
@USE_LIBTOOL_TRUE@calloc.lo div.lo drand48.lo dtoa.lo dtoastub.lo \
|
@USE_LIBTOOL_TRUE@calloc.lo div.lo drand48.lo dtoa.lo dtoastub.lo \
|
||||||
@USE_LIBTOOL_TRUE@ecvtbuf.lo efgcvt.lo environ.lo envlock.lo eprintf.lo \
|
@USE_LIBTOOL_TRUE@ecvtbuf.lo efgcvt.lo environ.lo envlock.lo eprintf.lo \
|
||||||
@USE_LIBTOOL_TRUE@erand48.lo exit.lo getenv.lo getenv_r.lo getopt.lo \
|
@USE_LIBTOOL_TRUE@erand48.lo exit.lo getenv.lo getenv_r.lo getopt.lo \
|
||||||
@USE_LIBTOOL_TRUE@jrand48.lo l64a.lo labs.lo lcong48.lo ldiv.lo \
|
@USE_LIBTOOL_TRUE@getsubopt.lo jrand48.lo l64a.lo labs.lo lcong48.lo \
|
||||||
@USE_LIBTOOL_TRUE@ldtoa.lo lrand48.lo malign.lo malloc.lo mblen.lo \
|
@USE_LIBTOOL_TRUE@ldiv.lo ldtoa.lo lrand48.lo malign.lo malloc.lo \
|
||||||
@USE_LIBTOOL_TRUE@mblen_r.lo mbstowcs.lo mbstowcs_r.lo mbtowc.lo \
|
@USE_LIBTOOL_TRUE@mblen.lo mblen_r.lo mbstowcs.lo mbstowcs_r.lo \
|
||||||
@USE_LIBTOOL_TRUE@mbtowc_r.lo mlock.lo mprec.lo mrand48.lo msize.lo \
|
@USE_LIBTOOL_TRUE@mbtowc.lo mbtowc_r.lo mlock.lo mprec.lo mrand48.lo \
|
||||||
@USE_LIBTOOL_TRUE@mstats.lo mtrim.lo nrand48.lo on_exit.lo putenv.lo \
|
@USE_LIBTOOL_TRUE@msize.lo mstats.lo mtrim.lo nrand48.lo on_exit.lo \
|
||||||
@USE_LIBTOOL_TRUE@putenv_r.lo rand.lo rand48.lo rand_r.lo realloc.lo \
|
@USE_LIBTOOL_TRUE@putenv.lo putenv_r.lo rand.lo rand48.lo rand_r.lo \
|
||||||
@USE_LIBTOOL_TRUE@seed48.lo setenv.lo setenv_r.lo srand48.lo strdup.lo \
|
@USE_LIBTOOL_TRUE@realloc.lo seed48.lo setenv.lo setenv_r.lo srand48.lo \
|
||||||
@USE_LIBTOOL_TRUE@strdup_r.lo strtod.lo strtol.lo strtoll.lo \
|
@USE_LIBTOOL_TRUE@strdup.lo strdup_r.lo strtod.lo strtol.lo strtoll.lo \
|
||||||
@USE_LIBTOOL_TRUE@strtoll_r.lo strtoul.lo strtoull.lo strtoull_r.lo \
|
@USE_LIBTOOL_TRUE@strtoll_r.lo strtoul.lo strtoull.lo strtoull_r.lo \
|
||||||
@USE_LIBTOOL_TRUE@system.lo valloc.lo wcstombs.lo wcstombs_r.lo \
|
@USE_LIBTOOL_TRUE@system.lo valloc.lo wcstombs.lo wcstombs_r.lo \
|
||||||
@USE_LIBTOOL_TRUE@wctomb.lo wctomb_r.lo
|
@USE_LIBTOOL_TRUE@wctomb.lo wctomb_r.lo
|
||||||
|
149
newlib/libc/stdlib/getsubopt.3
Normal file
149
newlib/libc/stdlib/getsubopt.3
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
.\" Copyright (c) 1990, 1991, 1993
|
||||||
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
|
.\" 3. All advertising materials mentioning features or use of this software
|
||||||
|
.\" must display the following acknowledgement:
|
||||||
|
.\" This product includes software developed by the University of
|
||||||
|
.\" California, Berkeley and its contributors.
|
||||||
|
.\" 4. Neither the name of the University nor the names of its contributors
|
||||||
|
.\" may be used to endorse or promote products derived from this software
|
||||||
|
.\" without specific prior written permission.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
.\" SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.\" @(#)getsubopt.3 8.1 (Berkeley) 6/9/93
|
||||||
|
.\" $FreeBSD: src/lib/libc/stdlib/getsubopt.3,v 1.9 2001/09/07 14:46:35 asmodai Exp $
|
||||||
|
.\"
|
||||||
|
.Dd June 9, 1993
|
||||||
|
.Dt GETSUBOPT 3
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm getsubopt
|
||||||
|
.Nd get sub options from an argument
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libc
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In unistd.h
|
||||||
|
.Vt extern char *suboptarg ;
|
||||||
|
.Ft int
|
||||||
|
.Fn getsubopt "char **optionp" "char * const *tokens" "char **valuep"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Fn getsubopt
|
||||||
|
function
|
||||||
|
parses a string containing tokens delimited by one or more tab, space or
|
||||||
|
comma
|
||||||
|
.Pq Ql \&,
|
||||||
|
characters.
|
||||||
|
It is intended for use in parsing groups of option arguments provided
|
||||||
|
as part of a utility command line.
|
||||||
|
.Pp
|
||||||
|
The argument
|
||||||
|
.Fa optionp
|
||||||
|
is a pointer to a pointer to the string.
|
||||||
|
The argument
|
||||||
|
.Fa tokens
|
||||||
|
is a pointer to a
|
||||||
|
.Dv NULL Ns -terminated
|
||||||
|
array of pointers to strings.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn getsubopt
|
||||||
|
function
|
||||||
|
returns the zero-based offset of the pointer in the
|
||||||
|
.Fa tokens
|
||||||
|
array referencing a string which matches the first token
|
||||||
|
in the string, or, \-1 if the string contains no tokens or
|
||||||
|
.Fa tokens
|
||||||
|
does not contain a matching string.
|
||||||
|
.Pp
|
||||||
|
If the token is of the form ``name=value'', the location referenced by
|
||||||
|
.Fa valuep
|
||||||
|
will be set to point to the start of the ``value'' portion of the token.
|
||||||
|
.Pp
|
||||||
|
On return from
|
||||||
|
.Fn getsubopt ,
|
||||||
|
.Fa optionp
|
||||||
|
will be set to point to the start of the next token in the string,
|
||||||
|
or the null at the end of the string if no more tokens are present.
|
||||||
|
The external variable
|
||||||
|
.Fa suboptarg
|
||||||
|
will be set to point to the start of the current token, or
|
||||||
|
.Dv NULL
|
||||||
|
if no
|
||||||
|
tokens were present.
|
||||||
|
The argument
|
||||||
|
.Fa valuep
|
||||||
|
will be set to point to the ``value'' portion of the token, or
|
||||||
|
.Dv NULL
|
||||||
|
if no ``value'' portion was present.
|
||||||
|
.Sh EXAMPLES
|
||||||
|
.Bd -literal -compact
|
||||||
|
char *tokens[] = {
|
||||||
|
#define ONE 0
|
||||||
|
"one",
|
||||||
|
#define TWO 1
|
||||||
|
"two",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
\&...
|
||||||
|
|
||||||
|
extern char *optarg, *suboptarg;
|
||||||
|
char *options, *value;
|
||||||
|
|
||||||
|
while ((ch = getopt(argc, argv, "ab:")) != \-1) {
|
||||||
|
switch(ch) {
|
||||||
|
case 'a':
|
||||||
|
/* process ``a'' option */
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
options = optarg;
|
||||||
|
while (*options) {
|
||||||
|
switch(getsubopt(&options, tokens, &value)) {
|
||||||
|
case ONE:
|
||||||
|
/* process ``one'' sub option */
|
||||||
|
break;
|
||||||
|
case TWO:
|
||||||
|
/* process ``two'' sub option */
|
||||||
|
if (!value)
|
||||||
|
error("no value for two");
|
||||||
|
i = atoi(value);
|
||||||
|
break;
|
||||||
|
case \-1:
|
||||||
|
if (suboptarg)
|
||||||
|
error("illegal sub option %s",
|
||||||
|
suboptarg);
|
||||||
|
else
|
||||||
|
error("missing sub option");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
.Ed
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr getopt 3 ,
|
||||||
|
.Xr strsep 3
|
||||||
|
.Sh HISTORY
|
||||||
|
The
|
||||||
|
.Fn getsubopt
|
||||||
|
function first appeared in
|
||||||
|
.Bx 4.4 .
|
101
newlib/libc/stdlib/getsubopt.c
Normal file
101
newlib/libc/stdlib/getsubopt.c
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 1990, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)getsubopt.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The SVID interface to getsubopt provides no way of figuring out which
|
||||||
|
* part of the suboptions list wasn't matched. This makes error messages
|
||||||
|
* tricky... The extern variable suboptarg is a pointer to the token
|
||||||
|
* which didn't match.
|
||||||
|
*/
|
||||||
|
char *suboptarg;
|
||||||
|
|
||||||
|
int
|
||||||
|
getsubopt(optionp, tokens, valuep)
|
||||||
|
char **optionp, **valuep;
|
||||||
|
char * const *tokens;
|
||||||
|
{
|
||||||
|
int cnt;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
suboptarg = *valuep = NULL;
|
||||||
|
|
||||||
|
if (!optionp || !*optionp)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
/* skip leading white-space, commas */
|
||||||
|
for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
|
||||||
|
|
||||||
|
if (!*p) {
|
||||||
|
*optionp = p;
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* save the start of the token, and skip the rest of the token. */
|
||||||
|
for (suboptarg = p;
|
||||||
|
*++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';);
|
||||||
|
|
||||||
|
if (*p) {
|
||||||
|
/*
|
||||||
|
* If there's an equals sign, set the value pointer, and
|
||||||
|
* skip over the value part of the token. Terminate the
|
||||||
|
* token.
|
||||||
|
*/
|
||||||
|
if (*p == '=') {
|
||||||
|
*p = '\0';
|
||||||
|
for (*valuep = ++p;
|
||||||
|
*p && *p != ',' && *p != ' ' && *p != '\t'; ++p);
|
||||||
|
if (*p)
|
||||||
|
*p++ = '\0';
|
||||||
|
} else
|
||||||
|
*p++ = '\0';
|
||||||
|
/* Skip any whitespace or commas after this token. */
|
||||||
|
for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set optionp for next round. */
|
||||||
|
*optionp = p;
|
||||||
|
|
||||||
|
for (cnt = 0; *tokens; ++tokens, ++cnt)
|
||||||
|
if (!strcmp(suboptarg, *tokens))
|
||||||
|
return(cnt);
|
||||||
|
return(-1);
|
||||||
|
}
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#define __sockcall_base(type, name) \
|
#define __sockcall_base(type, name) \
|
||||||
{ \
|
{ \
|
||||||
long __res; \
|
long __res; \
|
||||||
__asm__ volatile ("push %%ebx; movl %2,%%ebx; lea 8(%%esp),%%ecx; int $0x80; pop %%ebx" \
|
__asm__ volatile ("push %%ebx; movl %2,%%ebx; lea 8(%%ebp),%%ecx; int $0x80; pop %%ebx" \
|
||||||
: "=a" (__res) \
|
: "=a" (__res) \
|
||||||
: "0" (__NR_socketcall),"r" (SOCK_##name)); \
|
: "0" (__NR_socketcall),"r" (SOCK_##name)); \
|
||||||
__syscall_return(type,__res); \
|
__syscall_return(type,__res); \
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
@ -82,6 +82,8 @@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
|||||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||||
|
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||||
|
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user