Remove bits of libmissing we don't care about.

This commit is contained in:
Paul Traina 1997-09-03 08:24:28 +00:00
parent c72049e448
commit 5901e3495b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29068
17 changed files with 0 additions and 1237 deletions

View File

@ -1,494 +0,0 @@
/* alloca.c -- allocate automatically reclaimed memory
(Mostly) portable public-domain implementation -- D A Gwyn
This implementation of the PWB library alloca function,
which is used to allocate space off the run-time stack so
that it is automatically reclaimed upon procedure exit,
was inspired by discussions with J. Q. Johnson of Cornell.
J.Otto Tennant <jot@cray.com> contributed the Cray support.
There are some preprocessor constants that can
be defined when compiling for your specific system, for
improved efficiency; however, the defaults should be okay.
The general concept of this implementation is to keep
track of all alloca-allocated blocks, and reclaim any
that are found to be deeper in the stack than the current
invocation. This heuristic does not reclaim storage as
soon as it becomes invalid, but it will do so eventually.
As a special case, alloca(0) reclaims storage without
allocating any. It is a good idea to use alloca(0) in
your main control loop, etc. to force garbage collection. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef emacs
#include "blockinput.h"
#endif
/* If compiling with GCC 2, this file's not needed. */
#if !defined (__GNUC__) || __GNUC__ < 2
/* If someone has defined alloca as a macro,
there must be some other way alloca is supposed to work. */
#ifndef alloca
#ifdef emacs
#ifdef static
/* actually, only want this if static is defined as ""
-- this is for usg, in which emacs must undefine static
in order to make unexec workable
*/
#ifndef STACK_DIRECTION
you
lose
-- must know STACK_DIRECTION at compile-time
#endif /* STACK_DIRECTION undefined */
#endif /* static */
#endif /* emacs */
/* If your stack is a linked list of frames, you have to
provide an "address metric" ADDRESS_FUNCTION macro. */
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
long i00afunc ();
#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
#else
#define ADDRESS_FUNCTION(arg) &(arg)
#endif
#if __STDC__
typedef void *pointer;
#else
typedef char *pointer;
#endif
#define NULL 0
/* Different portions of Emacs need to call different versions of
malloc. The Emacs executable needs alloca to call xmalloc, because
ordinary malloc isn't protected from input signals. On the other
hand, the utilities in lib-src need alloca to call malloc; some of
them are very simple, and don't have an xmalloc routine.
Non-Emacs programs expect this to call use xmalloc.
Callers below should use malloc. */
#if 0
#ifndef emacs
#define malloc xmalloc
#endif
extern pointer malloc ();
#endif /* 0 */
/* Define STACK_DIRECTION if you know the direction of stack
growth for your system; otherwise it will be automatically
deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#ifndef STACK_DIRECTION
#define STACK_DIRECTION 0 /* Direction unknown. */
#endif
#if STACK_DIRECTION != 0
#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
#else /* STACK_DIRECTION == 0; need run-time code. */
static int stack_dir; /* 1 or -1 once known. */
#define STACK_DIR stack_dir
static void
find_stack_direction ()
{
static char *addr = NULL; /* Address of first `dummy', once known. */
auto char dummy; /* To get stack address. */
if (addr == NULL)
{ /* Initial entry. */
addr = ADDRESS_FUNCTION (dummy);
find_stack_direction (); /* Recurse once. */
}
else
{
/* Second entry. */
if (ADDRESS_FUNCTION (dummy) > addr)
stack_dir = 1; /* Stack grew upward. */
else
stack_dir = -1; /* Stack grew downward. */
}
}
#endif /* STACK_DIRECTION == 0 */
/* An "alloca header" is used to:
(a) chain together all alloca'ed blocks;
(b) keep track of stack depth.
It is very important that sizeof(header) agree with malloc
alignment chunk size. The following default should work okay. */
#ifndef ALIGN_SIZE
#define ALIGN_SIZE sizeof(double)
#endif
typedef union hdr
{
char align[ALIGN_SIZE]; /* To force sizeof(header). */
struct
{
union hdr *next; /* For chaining headers. */
char *deep; /* For stack depth measure. */
} h;
} header;
static header *last_alloca_header = NULL; /* -> last alloca header. */
/* Return a pointer to at least SIZE bytes of storage,
which will be automatically reclaimed upon exit from
the procedure that called alloca. Originally, this space
was supposed to be taken from the current stack frame of the
caller, but that method cannot be made to work for some
implementations of C, for example under Gould's UTX/32. */
pointer
alloca (size)
unsigned size;
{
auto char probe; /* Probes stack depth: */
register char *depth = ADDRESS_FUNCTION (probe);
#if STACK_DIRECTION == 0
if (STACK_DIR == 0) /* Unknown growth direction. */
find_stack_direction ();
#endif
/* Reclaim garbage, defined as all alloca'd storage that
was allocated from deeper in the stack than currently. */
{
register header *hp; /* Traverses linked list. */
#ifdef emacs
BLOCK_INPUT;
#endif
for (hp = last_alloca_header; hp != NULL;)
if ((STACK_DIR > 0 && hp->h.deep > depth)
|| (STACK_DIR < 0 && hp->h.deep < depth))
{
register header *np = hp->h.next;
free ((pointer) hp); /* Collect garbage. */
hp = np; /* -> next header. */
}
else
break; /* Rest are not deeper. */
last_alloca_header = hp; /* -> last valid storage. */
#ifdef emacs
UNBLOCK_INPUT;
#endif
}
if (size == 0)
return NULL; /* No allocation required. */
/* Allocate combined header + user data storage. */
{
register pointer new = malloc (sizeof (header) + size);
/* Address of header. */
((header *) new)->h.next = last_alloca_header;
((header *) new)->h.deep = depth;
last_alloca_header = (header *) new;
/* User storage begins just after header. */
return (pointer) ((char *) new + sizeof (header));
}
}
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
#ifdef DEBUG_I00AFUNC
#include <stdio.h>
#endif
#ifndef CRAY_STACK
#define CRAY_STACK
#ifndef CRAY2
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
struct stack_control_header
{
long shgrow:32; /* Number of times stack has grown. */
long shaseg:32; /* Size of increments to stack. */
long shhwm:32; /* High water mark of stack. */
long shsize:32; /* Current size of stack (all segments). */
};
/* The stack segment linkage control information occurs at
the high-address end of a stack segment. (The stack
grows from low addresses to high addresses.) The initial
part of the stack segment linkage control information is
0200 (octal) words. This provides for register storage
for the routine which overflows the stack. */
struct stack_segment_linkage
{
long ss[0200]; /* 0200 overflow words. */
long sssize:32; /* Number of words in this segment. */
long ssbase:32; /* Offset to stack base. */
long:32;
long sspseg:32; /* Offset to linkage control of previous
segment of stack. */
long:32;
long sstcpt:32; /* Pointer to task common address block. */
long sscsnm; /* Private control structure number for
microtasking. */
long ssusr1; /* Reserved for user. */
long ssusr2; /* Reserved for user. */
long sstpid; /* Process ID for pid based multi-tasking. */
long ssgvup; /* Pointer to multitasking thread giveup. */
long sscray[7]; /* Reserved for Cray Research. */
long ssa0;
long ssa1;
long ssa2;
long ssa3;
long ssa4;
long ssa5;
long ssa6;
long ssa7;
long sss0;
long sss1;
long sss2;
long sss3;
long sss4;
long sss5;
long sss6;
long sss7;
};
#else /* CRAY2 */
/* The following structure defines the vector of words
returned by the STKSTAT library routine. */
struct stk_stat
{
long now; /* Current total stack size. */
long maxc; /* Amount of contiguous space which would
be required to satisfy the maximum
stack demand to date. */
long high_water; /* Stack high-water mark. */
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
long hits; /* Number of internal buffer hits. */
long extends; /* Number of block extensions. */
long stko_mallocs; /* Block allocations by $STKOFEN. */
long underflows; /* Number of stack underflow calls ($STKRETN). */
long stko_free; /* Number of deallocations by $STKRETN. */
long stkm_free; /* Number of deallocations by $STKMRET. */
long segments; /* Current number of stack segments. */
long maxs; /* Maximum number of stack segments so far. */
long pad_size; /* Stack pad size. */
long current_address; /* Current stack segment address. */
long current_size; /* Current stack segment size. This
number is actually corrupted by STKSTAT to
include the fifteen word trailer area. */
long initial_address; /* Address of initial segment. */
long initial_size; /* Size of initial segment. */
};
/* The following structure describes the data structure which trails
any stack segment. I think that the description in 'asdef' is
out of date. I only describe the parts that I am sure about. */
struct stk_trailer
{
long this_address; /* Address of this block. */
long this_size; /* Size of this block (does not include
this trailer). */
long unknown2;
long unknown3;
long link; /* Address of trailer block of previous
segment. */
long unknown5;
long unknown6;
long unknown7;
long unknown8;
long unknown9;
long unknown10;
long unknown11;
long unknown12;
long unknown13;
long unknown14;
};
#endif /* CRAY2 */
#endif /* not CRAY_STACK */
#ifdef CRAY2
/* Determine a "stack measure" for an arbitrary ADDRESS.
I doubt that "lint" will like this much. */
static long
i00afunc (long *address)
{
struct stk_stat status;
struct stk_trailer *trailer;
long *block, size;
long result = 0;
/* We want to iterate through all of the segments. The first
step is to get the stack status structure. We could do this
more quickly and more directly, perhaps, by referencing the
$LM00 common block, but I know that this works. */
STKSTAT (&status);
/* Set up the iteration. */
trailer = (struct stk_trailer *) (status.current_address
+ status.current_size
- 15);
/* There must be at least one stack segment. Therefore it is
a fatal error if "trailer" is null. */
if (trailer == 0)
abort ();
/* Discard segments that do not contain our argument address. */
while (trailer != 0)
{
block = (long *) trailer->this_address;
size = trailer->this_size;
if (block == 0 || size == 0)
abort ();
trailer = (struct stk_trailer *) trailer->link;
if ((block <= address) && (address < (block + size)))
break;
}
/* Set the result to the offset in this segment and add the sizes
of all predecessor segments. */
result = address - block;
if (trailer == 0)
{
return result;
}
do
{
if (trailer->this_size <= 0)
abort ();
result += trailer->this_size;
trailer = (struct stk_trailer *) trailer->link;
}
while (trailer != 0);
/* We are done. Note that if you present a bogus address (one
not in any segment), you will get a different number back, formed
from subtracting the address of the first block. This is probably
not what you want. */
return (result);
}
#else /* not CRAY2 */
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
Determine the number of the cell within the stack,
given the address of the cell. The purpose of this
routine is to linearize, in some sense, stack addresses
for alloca. */
static long
i00afunc (long address)
{
long stkl = 0;
long size, pseg, this_segment, stack;
long result = 0;
struct stack_segment_linkage *ssptr;
/* Register B67 contains the address of the end of the
current stack segment. If you (as a subprogram) store
your registers on the stack and find that you are past
the contents of B67, you have overflowed the segment.
B67 also points to the stack segment linkage control
area, which is what we are really interested in. */
stkl = CRAY_STACKSEG_END ();
ssptr = (struct stack_segment_linkage *) stkl;
/* If one subtracts 'size' from the end of the segment,
one has the address of the first word of the segment.
If this is not the first segment, 'pseg' will be
nonzero. */
pseg = ssptr->sspseg;
size = ssptr->sssize;
this_segment = stkl - size;
/* It is possible that calling this routine itself caused
a stack overflow. Discard stack segments which do not
contain the target address. */
while (!(this_segment <= address && address <= stkl))
{
#ifdef DEBUG_I00AFUNC
fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
#endif
if (pseg == 0)
break;
stkl = stkl - pseg;
ssptr = (struct stack_segment_linkage *) stkl;
size = ssptr->sssize;
pseg = ssptr->sspseg;
this_segment = stkl - size;
}
result = address - this_segment;
/* If you subtract pseg from the current end of the stack,
you get the address of the previous stack segment's end.
This seems a little convoluted to me, but I'll bet you save
a cycle somewhere. */
while (pseg != 0)
{
#ifdef DEBUG_I00AFUNC
fprintf (stderr, "%011o %011o\n", pseg, size);
#endif
stkl = stkl - pseg;
ssptr = (struct stack_segment_linkage *) stkl;
size = ssptr->sssize;
pseg = ssptr->sspseg;
result += size;
}
return (result);
}
#endif /* not CRAY2 */
#endif /* CRAY */
#endif /* no alloca */
#endif /* not GCC version 2 */

View File

@ -1,141 +0,0 @@
/* env.c: Replacement environment handling functions.
%%% portions-copyright-cmetz
Portions of this software are Copyright 1996 by Craig Metz, All Rights
Reserved. The Inner Net License Version 2 applies to these portions of
the software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
Portions of this software are Copyright 1995 by Randall Atkinson and Dan
McDonald, All Rights Reserved. All Rights under this copyright are assigned
to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
License Agreement applies to this software.
History:
Modified by cmetz for OPIE 2.2. Changed ifdefs for libmissing.
Combined all env functions and made _findenv static.
Including headers is a good idea, though. Add more headers.
Modified at NRL for OPIE 2.0.
Originally from BSD.
*/
/*
* Copyright (c) 1987 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "opie_cfg.h"
#include <stdio.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */
#include "opie.h"
static char *_findenv FUNCTION((name, offset), register char *name AND int *offset)
{
extern char **environ;
register int len;
register char **P, *C;
for (C = name, len = 0; *C && *C != '='; ++C, ++len);
for (P = environ; *P; ++P)
if (!strncmp(*P, name, len))
if (*(C = *P + len) == '=') {
*offset = P - environ;
return (++C);
}
return (NULL);
}
#if !HAVE_GETENV
char *getenv FUNCTION((name), char *name)
{
int offset;
char *_findenv();
return (_findenv(name, &offset));
}
#endif /* !HAVE_GETENV */
#if !HAVE_SETENV
int setenv FUNCTION((name, value, rewrite), char *name AND char *value AND int rewrite)
{
extern char **environ;
static int alloced; /* if allocated space before */
register char *C;
int l_value, offset;
if (*value == '=') /* no `=' in value */
++value;
l_value = strlen(value);
if ((C = _findenv(name, &offset))) { /* find if already exists */
if (!rewrite)
return (0);
if (strlen(C) >= l_value) { /* old larger; copy over */
while (*C++ = *value++);
return (0);
}
} else { /* create new slot */
register int cnt;
register char **P;
for (P = environ, cnt = 0; *P; ++P, ++cnt);
if (alloced) { /* just increase size */
environ = (char **) realloc((char *) environ,
(u_int) (sizeof(char *) * (cnt + 2)));
if (!environ)
return (-1);
} else { /* get new space */
alloced = 1; /* copy old entries into it */
P = (char **) malloc((u_int) (sizeof(char *) *
(cnt + 2)));
if (!P)
return (-1);
strncpy(P, environ, cnt * sizeof(char *));
environ = P;
}
environ[cnt + 1] = NULL;
offset = cnt;
}
for (C = name; *C && *C != '='; ++C); /* no `=' in name */
if (!(environ[offset] = /* name + `=' + value */
malloc((u_int) ((int) (C - name) + l_value + 2))))
return (-1);
for (C = environ[offset]; (*C = *name++) && *C != '='; ++C);
for (*C++ = '='; *C++ = *value++;);
return (0);
}
#endif /* !HAVE_SETENV */
#if !HAVE_UNSETENV
VOIDRET unsetenv FUNCTION((name), char *name)
{
extern char **environ;
register char **P;
int offset;
while (_findenv(name, &offset)) /* if set multiple times */
for (P = &environ[offset];; ++P)
if (!(*P = *(P + 1)))
break;
}
#endif /* !HAVE_UNSETENV */

View File

@ -1,23 +0,0 @@
/* getcwd.c: A replacement for the getcwd function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.3.
*/
#include "opie_cfg.h"
#include "opie.h"
char *getcwd FUNCTION((c, l), char *c AND int l)
{
#if HAVE_GETWD
return getwd(c);
#else /* HAVE_INDEX */
#error Need getwd() to build a replacement getcwd()
#endif /* HAVE_INDEX */
}

View File

@ -1,67 +0,0 @@
/* getusershell.c: minimal implementation of the getusershell() and
endusershell() library routines for systems that don't have them.
%%% portions-copyright-cmetz
Portions of this software are Copyright 1996 by Craig Metz, All Rights
Reserved. The Inner Net License Version 2 applies to these portions of
the software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
Portions of this software are Copyright 1995 by Randall Atkinson and Dan
McDonald, All Rights Reserved. All Rights under this copyright are assigned
to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
License Agreement applies to this software.
History:
Modified by cmetz for OPIE 2.2. Use FUNCTION declaration et al.
Modified at NRL for OPIE 2.1. Remove trailing newlines from
/etc/shells entries. Fixed infinite loop. Fixed a bug
where second invocation on would fail.
Written at NRL for OPIE 2.0.
*/
#include "opie_cfg.h"
#include <stdio.h>
#if HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#include "opie.h"
static FILE *fh = NULL;
static char *internal[] = {"/bin/sh", "/bin/csh", NULL};
static int i = 0;
static char buffer[1024];
char *getusershell FUNCTION_NOARGS
{
char *c;
if (!fh)
fh = fopen("/etc/shells", "r");
if (fh) {
if (fgets(buffer, sizeof(buffer), fh)) {
if (c = strchr(buffer, '\n'))
*c = 0;
return buffer;
} else {
fclose(fh);
return NULL;
}
} else {
if (internal[i])
return internal[i++];
else
return NULL;
}
}
VOIDRET endusershell FUNCTION_NOARGS
{
if (fh) {
fclose(fh);
fh = NULL;
}
i = 0;
}

View File

@ -1,129 +0,0 @@
/* initgroups.c: Replacement for the initgroups() function.
%%% portions-copyright-cmetz
Portions of this software are Copyright 1996 by Craig Metz, All Rights
Reserved. The Inner Net License Version 2 applies to these portions of
the software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Modified by cmetz for OPIE 2.2. Removed useless string.
Ifdef around headers. Use FUNCTION declarations.
Not everyone has multiple groups. Work around
lack of NGROUPS.
Originally from 4.3BSD Net/2.
*/
/*
* Copyright (c) 1983 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.
*/
/*
* initgroups
*/
#include "opie_cfg.h"
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */
#include <stdio.h>
#if HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING */
#if HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <grp.h>
#include "opie.h"
struct group *getgrent();
int initgroups FUNCTION((uname, agroup), const char *uname AND int agroup)
{
#if HAVE_SETGROUPS && HAVE_GETGROUPS
#if NGROUPS
int groups[NGROUPS];
#else /* NGROUPS */
#define STARTING_NGROUPS 32
int groups[STARTING_NGROUPS];
#endif /* NGROUPS */
int ngroups;
register struct group *grp;
register int i;
/*
* If installing primary group, duplicate it;
* the first element of groups is the effective gid
* and will be overwritten when a setgid file is executed.
*/
if (agroup >= 0) {
groups[ngroups++] = agroup;
groups[ngroups++] = agroup;
}
setgrent();
while (grp = getgrent()) {
if (grp->gr_gid == agroup)
continue;
for (i = 0; grp->gr_mem[i]; i++)
if (!strcmp(grp->gr_mem[i], uname)) {
#if NGROUPS
if (ngroups == NGROUPS) {
#else /* NGROUPS */
if (ngroups == STARTING_NGROUPS) {
#endif /* NGROUPS */
fprintf(stderr, "initgroups: %s is in too many groups\n", uname);
goto toomany;
}
groups[ngroups++] = grp->gr_gid;
}
}
toomany:
endgrent();
#if NGROUPS
if (setgroups(ngroups, groups) < 0) {
perror("setgroups");
return (-1);
}
#else /* NGROUPS */
ngroups++;
do {
if ((i = setgroups(--ngroups, groups) < 0) && (i != EINVAL)) {
perror("setgroups");
return (-1);
}
} while ((i < 0) && (ngroups > 0));
#endif /* NGROUPS */
#endif /* HAVE_SETGROUPS && HAVE_GETGROUPS */
return (0);
}

View File

@ -1,25 +0,0 @@
/* strncasecmp.c: A replacement for the strncasecmp function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.2.
*/
#include "opie_cfg.h"
#include "opie.h"
int memcmp FUNCTION((s1, s2, n), unsigned char *s1 AND unsigned char *s2 AND int n)
{
while(n--) {
if (*s1 != *s2)
return (*s1 > *s2) ? 1 : -1;
s1++;
s2++;
}
return 0;
}

View File

@ -1,25 +0,0 @@
/* memcpy.c: A replacement for the memcpy function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.2.
*/
#include "opie_cfg.h"
#include "opie.h"
VOIDPTR *memcpy FUNCTION((d, s, n), unsigned char *d AND unsigned char *s AND int n)
{
#if HAVE_BCOPY
bcopy(s, d, n);
#else /* HAVE_BCOPY */
char *d2 = d;
while(n--) (*d2++) = (*s++);
#endif /* HAVE_BCOPY */
return d;
}

View File

@ -1,21 +0,0 @@
/* memcpy.c: A replacement for the memcpy function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.2.
*/
#include "opie_cfg.h"
#include "opie.h"
VOIDPTR *memset FUNCTION((d, v, n), unsigned char *d AND int v AND int n)
{
unsigned char *d2 = d;
while(n--) (*d2++) = (unsigned char)v;
return d;
}

View File

@ -1,36 +0,0 @@
/* sigaddset.c: A replacement for the sigaddset function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.2.
*/
#include "opie_cfg.h"
#ifndef _NSIG
#ifdef NSIG
#define _NSIG NSIG
#else /* NSIG */
#define _NSIG 32
#endif /* NSIG */
#endif /* _NSIG */
#include "opie.h"
int sigaddset FUNCTION((set, signum), sigset_t *set AND int signum)
{
#if sizeof(sigset_t) != sizeof(int)
Sorry, we don't currently support your system.
#else /* sizeof(sigset_t) != sizeof(int) */
if (set && (signum > 0) && (signum < _NSIG))
*set |= 1 << (signum - 1);
#endif /* sizeof(sigset_t) != sizeof(int) */
return 0;
}

View File

@ -1,23 +0,0 @@
/* sigemptyset.c: A replacement for the sigemptyset function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.2.
*/
#include "opie_cfg.h"
#include "opie.h"
int sigemptyset FUNCTION((set), sigset_t *set)
{
if (set)
memset(set, 0, sizeof(sigset_t))
return 0;
}

View File

@ -1,68 +0,0 @@
/* sigprocmask.c: A replacement for the sigprocmask() function
%%% portions-copyright-cmetz
Portions of this software are Copyright 1996 by Craig Metz, All Rights
Reserved. The Inner Net License Version 2 applies to these portions of
the software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
Portions of this software are Copyright 1995 by Randall Atkinson and Dan
McDonald, All Rights Reserved. All Rights under this copyright are assigned
to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
License Agreement applies to this software.
History:
Created by cmetz for OPIE 2.2 from popen.c. Use FUNCTION
declaration et al. Include opie.h.
*/
#include "opie_cfg.h"
#include <sys/types.h>
#if HAVE_SIGNAL_H
#include <signal.h>
#endif /* HAVE_SIGNAL_H */
#if HAVE_SYS_SIGNAL_H
#include <sys/signal.h>
#endif /* HAVE_SYS_SIGNAL_H */
#if !HAVE_SIGBLOCK || !HAVE_SIGSETMASK
Without sigblock and sigsetmask, we can't build a replacement sigprocmask.
#endif /* !HAVE_SIGBLOCK || !HAVE_SIGSETMASK */
#include "opie.h"
#ifndef sigset_t
#define sigset_t int
#endif /* sigset_t */
int sigprocmask FUNCTION((how, set, oset), int how AND sigset_t *set AND sigset_t *oset)
{
int old, new;
if (set && (set != (sigset_t *)SIG_IGN) && (set != (sigset_t *)SIG_ERR))
new = *set;
else
new = 0;
switch(how) {
case SIG_BLOCK:
old = sigblock(new);
if (oset && (oset != (sigset_t *)SIG_IGN) && (oset != (sigset_t *)SIG_ERR))
*oset = old;
return 0;
case SIG_SETMASK:
old = sigsetmask(new);
if (oset && (oset != (sigset_t *)SIG_IGN) && (oset != (sigset_t *)SIG_ERR))
*oset = old;
return 0;
case SIG_UNBLOCK:
/* not implemented */
default:
return 0;
}
}

View File

@ -1,24 +0,0 @@
/* strchr.c: A replacement for the strchr function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.3.
*/
#include "opie_cfg.h"
#include "opie.h"
char *strchr FUNCTION((s, c), char *s AND int c)
{
#if HAVE_INDEX
return index(s, c);
#else /* HAVE_INDEX */
while(*s && (*s != c)) s++;
return *s ? s : (char *)0;
#endif /* HAVE_INDEX */
}

View File

@ -1,34 +0,0 @@
/* strerror.c: A replacement for the strerror function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.2.
*/
#include "opie_cfg.h"
#include "opie.h"
char *strerror FUNCTION((errnum), int errnum)
{
#if HAVE_SYS_ERRLIST
extern char *sys_errlist[];
return sys_errlist[errnum];
#else /* NEED_STRERROR */
#if HAVE__SYS_ERRLIST
extern char *_sys_errlist[];
return sys_errlist[errnum];
#else /* HAVE__SYS_ERRLIST */
static char hexdigits[] = "0123456789abcdef";
static char buffer[] = "System error 0x42";
buffer[15] = hexdigits[(errnum >> 4) & 0x0f];
buffer[16] = hexdigits[errnum & 0x0f];
return buffer;
#endif /* HAVE__SYS_ERRLIST */
#endif /* NEED_STRERROR */
}

View File

@ -1,30 +0,0 @@
/* strncasecmp.c: A replacement for the strncasecmp function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.2.
*/
#include "opie_cfg.h"
#include "opie.h"
int strncasecmp FUNCTION((s1, s2, n), unsigned char *s1 AND unsigned char *s2 AND int n)
{
unsigned char c1, c2;
while(*s1 && *s2 && n--) {
c1 = ((*s1 >= 'A') && (*s1 <= 'Z')) ? (*s1++) + ('a' - 'A') : (*s1++);
c2 = ((*s2 >= 'A') && (*s2 <= 'Z')) ? (*s2++) + ('a' - 'A') : (*s2++);
if (c1 != c2)
return (c1 > c2) ? 1 : -1;
}
if (*s1 && !*s2)
return 1;
if (!*s1 && *s2)
return -1;
return 0;
}

View File

@ -1,25 +0,0 @@
/* strrchr.c: A replacement for the strrchr function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.3.
*/
#include "opie_cfg.h"
#include "opie.h"
char *strrchr FUNCTION((s, c), char *s AND int c)
{
#if HAVE_RINDEX
return rindex(s, c);
#else /* HAVE_RINDEX */
char *s2 = (char *)0;
while(*s) { if (*s == c) s2 = s; s++ };
return s2;
#endif /* HAVE_RINDEX */
}

View File

@ -1,30 +0,0 @@
/* sysconf.c: A (partial) replacement for the sysconf function
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Created by cmetz for OPIE 2.3.
*/
#include "opie_cfg.h"
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */
#include "opie.h"
long sysconf(int name)
{
switch(name) {
case _SC_OPEN_MAX:
#if HAVE_GETDTABLESIZE
return getdtablesize();
#else /* HAVE_GETDTABLESIZE */
#error Need getdtablesize() to build a replacement sysconf()
#endif /* HAVE_GETDTABLESIZE */
return -1;
}

View File

@ -1,42 +0,0 @@
/* uname.c: A replacement for the uname function (sort of)
%%% copyright-cmetz
This software is Copyright 1996 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
Modified by cmetz for OPIE 2.3. Ifdef around gethostname().
Created by cmetz for OPIE 2.2.
*/
#include "opie_cfg.h"
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */
#include "opie.h"
int uname FUNCTION(struct utsname *buf)
{
#if HAVE_GETHOSTNAME
char hostname[MAXHOSTNAMELEN], *c;
memset(buf, 0, sizeof(buf));
if (gethostname(hostname, sizeof(hostname)-1) < 0)
return -1;
hostname[sizeof(hostname) - 1] = 0;
if (c = strchr(hostname, '.')) {
*c = 0;
}
strncpy(buf->nodename, hostname, sizeof(buf->nodename) - 1);
return 0;
#else /* HAVE_GETHOSTNAME */
strncpy(buf->nodename, "unknown", sizeof(buf->nodename) - 1);
return 0;
#endif /* HAVE_GETHOSTNAME */
}