Source from upstream; imap-2007f.tar.gz

MD5 2126fd125ea26b73b20f01fcd5940369
This commit is contained in:
Chris
2019-01-03 04:12:17 -06:00
parent c6e9661b42
commit 22f316e36d
581 changed files with 216530 additions and 0 deletions

40
src/ansilib/memmove.c Normal file
View File

@@ -0,0 +1,40 @@
/* ========================================================================
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* ========================================================================
*/
/*
* Program: Memory move
*
* Author: Mark Crispin
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
* Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1988
* Last Edited: 30 August 2006
*/
/* Copy memory block
* Accepts: destination pointer
* source pointer
* length
* Returns: destination pointer
*/
void *memmove (void *s,void *ct,size_t n)
{
bcopy (ct,s,n); /* they should have this one */
return s;
}

49
src/ansilib/memmove2.c Normal file
View File

@@ -0,0 +1,49 @@
/* ========================================================================
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* ========================================================================
*/
/*
* Program: Memory move when no bcopy()
*
* Author: Mark Crispin
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
* Internet: MRC@CAC.Washington.EDU
*
* Date: 11 May 1989
* Last Edited: 30 August 2006
*/
/* Copy memory block
* Accepts: destination pointer
* source pointer
* length
* Returns: destination pointer
*/
void *memmove (void *s,void *ct,size_t n)
{
char *dp,*sp;
int i;
unsigned long dest = (unsigned long) s;
unsigned long src = (unsigned long) ct;
if (((dest < src) && ((dest + n) < src)) ||
((dest > src) && ((src + n) < dest))) return (void *) memcpy (s,ct,n);
dp = (char *) s;
sp = (char *) ct;
if (dest < src) for (i = 0; i < n; ++i) dp[i] = sp[i];
else if (dest > src) for (i = n - 1; i >= 0; --i) dp[i] = sp[i];
return s;
}

40
src/ansilib/memset.c Normal file
View File

@@ -0,0 +1,40 @@
/* ========================================================================
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* ========================================================================
*/
/*
* Program: Set memory
*
* Author: Mark Crispin
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
*
* Date: 11 May 1989
* Last Edited: 30 August 2006
*/
/* Set a block of memory
* Accepts: destination pointer
* value to set
* length
* Returns: destination pointer
*/
void *memset (void *s,int c,size_t n)
{
if (c) while (n) s[--n] = c; /* this way if non-zero */
else bzero (s,n); /* they should have this one */
return s;
}

40
src/ansilib/strpbrk.c Normal file
View File

@@ -0,0 +1,40 @@
/* ========================================================================
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* ========================================================================
*/
/*
* Program: String search for break character
*
* Author: Mark Crispin
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
*
* Date: 11 May 1989
* Last Edited: 30 August 2006
*/
/* Return pointer to first occurance in string of any delimiter
* Accepts: source pointer
* vector of delimiters pointer
* Returns: pointer to delimiter or NIL if not found
*/
char *strpbrk (char *cs,char *ct)
{
char *s;
/* search for delimiter until end of string */
for (; *cs; cs++) for (s = ct; *s; s++) if (*s == *cs) return cs;
return NIL; /* not found */
}

45
src/ansilib/strstr.c Normal file
View File

@@ -0,0 +1,45 @@
/* ========================================================================
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* ========================================================================
*/
/*
* Program: Substring search
*
* Author: Mark Crispin
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
*
* Date: 11 May 1989
* Last Edited: 30 August 2006
*/
/* Return pointer to first occurance in string of a substring
* Accepts: source pointer
* substring pointer
* Returns: pointer to substring in source or NIL if not found
*/
char *strstr (char *cs,char *ct)
{
char *s;
char *t;
while (cs = strchr (cs,*ct)) {/* for each occurance of the first character */
/* see if remainder of string matches */
for (s = cs + 1, t = ct + 1; *t && *s == *t; s++, t++);
if (!*t) return cs; /* if ran out of substring then have match */
cs++; /* try from next character */
}
return NIL; /* not found */
}

67
src/ansilib/strtok.c Normal file
View File

@@ -0,0 +1,67 @@
/* ========================================================================
* Copyright 1988-2007 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* ========================================================================
*/
/*
* Program: String return successive tokens
*
* Author: Mark Crispin
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
*
* Date: 11 May 1989
* Last Edited: 30 January 2007
*/
/* Find token in string
* Accepts: source pointer or NIL to use previous source
* vector of token delimiters pointer
* Returns: pointer to next token
*/
static char *state = NIL; /* string to locate tokens */
char *strtok (char *s,char *ct)
{
return strtok_r (s,ct,&state);/* jacket into reentrant routine */
}
/* Find token in string (reentrant)
* Accepts: source pointer or NIL to use previous source
* vector of token delimiters pointer
* returned state pointer
* Returns: pointer to next token
*/
char *strtok_r (char *s,char *ct,char **r)
{
char *t,*ts;
if (!s) s = *r; /* use previous token if none specified */
*r = NIL; /* default to no returned state */
if (!(s && *s)) return NIL; /* no tokens left */
/* find any leading delimiters */
do for (t = ct, ts = NIL; *t; t++) if (*t == *s) {
if (*(ts = ++s)) break; /* yes, restart search if more in string */
return NIL; /* else no more tokens */
} while (ts); /* continue until no more leading delimiters */
/* can we find a new delimiter? */
for (ts = s; *ts; ts++) for (t = ct; *t; t++) if (*t == *ts) {
*ts++ = '\0'; /* yes, tie off token at that point */
*r = ts; /* save subsequent tokens for future call */
return s; /* return our token */
}
return s; /* return final token */
}

73
src/ansilib/strtoul.c Normal file
View File

@@ -0,0 +1,73 @@
/* ========================================================================
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* ========================================================================
*/
/*
* Program: String to unsigned long
*
* Author: Mark Crispin
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
*
* Date: 14 February 1995
* Last Edited: 30 August 2006
*/
/*
* Turn a string unsigned long into the real thing
* Accepts: source string
* pointer to place to return end pointer
* base
* Returns: parsed unsigned long integer, end pointer is updated
*/
unsigned long strtoul (char *t,char **endp,int base)
{
unsigned long value = 0; /* the accumulated value */
int negative = 0; /* this a negative number? */
unsigned char c,*s = t;
if (base && (base < 2 || base > 36)) {
errno = EINVAL; /* insist upon valid base */
return value;
}
while (isspace (*s)) s++; /* skip leading whitespace */
switch (*s) { /* check for leading sign char */
case '-':
negative = 1; /* yes, negative #. fall into '+' */
case '+':
s++; /* skip the sign character */
}
if (!base) { /* base not specified? */
if (*s != '0') base = 10; /* must be decimal if doesn't start with 0 */
/* starts with 0x? */
else if (tolower (*++s) == 'x') {
base = 16; /* yes, is hex */
s++; /* skip the x */
}
else base = 8; /* ...or octal */
}
do { /* convert to numeric form if digit */
if (isdigit (*s)) c = *s - '0';
/* alphabetic conversion */
else if (isalpha (*s)) c = *s - (isupper (*s) ? 'A' : 'a') + 10;
else break; /* else no way it's valid */
if (c >= base) break; /* digit out of range for base? */
value = value * base + c; /* accumulate the digit */
} while (*++s); /* loop until non-numeric character */
if (tolower (*s) == 'l') s++; /* ignore 'l' or 'L' marker */
if (endp) *endp = s; /* save users endp to after number */
/* negate number if needed */
return negative ? -value : value;
}