home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
MEMCCPY.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
772b
|
43 lines
/* from Henry Spencer's stringlib */
#include <stddef.h>
#include <string.h>
/*
* memccpy - copy bytes up to a certain char
*
* CHARBITS should be defined only if the compiler lacks "unsigned char".
* It should be a mask, e.g. 0377 for an 8-bit machine.
*/
#ifndef CHARBITS
# define UNSCHAR(c) ((unsigned char)(c))
#else
# define UNSCHAR(c) ((c)&CHARBITS)
#endif
void *
memccpy(dst, src, ucharstop, size)
void * dst;
const void * src;
int ucharstop;
size_t size;
{
register char *d;
register const char *s;
register size_t n;
register int uc;
if (size == 0)
return(NULL);
s = src;
d = dst;
uc = UNSCHAR(ucharstop);
for (n = size; n > 0; n--)
if (UNSCHAR(*d++ = *s++) == uc)
return(d);
return(NULL);
}