From 2059697c29c926c3ad42efb61993baf2723f0b0e Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Thu, 3 Apr 1997 23:28:32 +0000 Subject: Initial Revision --- serverboot/strfcns.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 serverboot/strfcns.c (limited to 'serverboot/strfcns.c') diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c new file mode 100644 index 00000000..53c097ba --- /dev/null +++ b/serverboot/strfcns.c @@ -0,0 +1,117 @@ +/* + * Mach Operating System + * Copyright (c) 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * Character subroutines + */ + +#include + +#define EXPORT_BOOLEAN +#include + +/* + * Concatenate a group of strings together into a buffer. + * Return a pointer to the trailing '\0' character in + * the result string. + * The list of strings ends with a '(char *)0'. + */ +/*VARARGS1*/ +char * +strbuild(dest, va_alist) + register char * dest; + va_dcl +{ + va_list argptr; + register char * src; + register int c; + + va_start(argptr); + while ((src = va_arg(argptr, char *)) != (char *)0) { + + while ((c = *src++) != '\0') + *dest++ = c; + } + *dest = '\0'; + return (dest); +} + +/* + * Return TRUE if string 2 is a prefix of string 1. + */ +boolean_t +strprefix(s1, s2) + register char *s1, *s2; +{ + register int c; + + while ((c = *s2++) != '\0') { + if (c != *s1++) + return (FALSE); + } + return (TRUE); +} + +/* + * ovbcopy - like bcopy, but recognizes overlapping ranges and handles + * them correctly. + */ +ovbcopy(from, to, bytes) + char *from, *to; + int bytes; /* num bytes to copy */ +{ + /* Assume that bcopy copies left-to-right (low addr first). */ + if (from + bytes <= to || to + bytes <= from || to == from) + bcopy(from, to, bytes); /* non-overlapping or no-op*/ + else if (from > to) + bcopy(from, to, bytes); /* overlapping but OK */ + else { + /* to > from: overlapping, and must copy right-to-left. */ + from += bytes - 1; + to += bytes - 1; + while (bytes-- > 0) + *to-- = *from--; + } +} + +/* + * Return a pointer to the first occurence of 'c' in + * string s, or 0 if none. + */ +char * +index(s, c) + char *s; + char c; +{ + char cc; + + while ((cc = *s) != c) { + if (cc == 0) + return 0; + s++; + } + return s; +} + -- cgit v1.2.3 From 684b3d69287635f6bdd794cd7f49c6e9a6dfc1cf Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 16 Nov 1999 07:57:32 +0000 Subject: 1999-11-16 Roland McGrath * ffs_file_io.c (ffs_open_file): Use memmove instead of ovbcopy. * ext2_file_io.c (ext2_open_file): Likewise. * strfcns.c (ovbcopy): Function removed. --- serverboot/ext2_file_io.c | 2 +- serverboot/ffs_file_io.c | 2 +- serverboot/strfcns.c | 37 +++++++------------------------------ 3 files changed, 9 insertions(+), 32 deletions(-) (limited to 'serverboot/strfcns.c') diff --git a/serverboot/ext2_file_io.c b/serverboot/ext2_file_io.c index d25fd9db..d96ad576 100644 --- a/serverboot/ext2_file_io.c +++ b/serverboot/ext2_file_io.c @@ -651,7 +651,7 @@ ext2_open_file(master_device_port, path, fp) if (++nlinks > MAXSYMLINKS) RETURN (FS_SYMLINK_LOOP); - ovbcopy(cp, &namebuf[link_len], len); + memmove(&namebuf[link_len], cp, len); #ifdef IC_FASTLINK if (fp->i_ic.i_blocks == 0) { diff --git a/serverboot/ffs_file_io.c b/serverboot/ffs_file_io.c index ce67fdc8..0055c302 100644 --- a/serverboot/ffs_file_io.c +++ b/serverboot/ffs_file_io.c @@ -625,7 +625,7 @@ ffs_open_file(master_device_port, path, fp) if (++nlinks > MAXSYMLINKS) RETURN (FS_SYMLINK_LOOP); - ovbcopy(cp, &namebuf[link_len], len); + memmove (&namebuf[link_len], cp, len); #ifdef IC_FASTLINK if ((fp->i_flags & IC_FASTLINK) != 0) { diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c index 53c097ba..85e5eb83 100644 --- a/serverboot/strfcns.c +++ b/serverboot/strfcns.c @@ -1,26 +1,26 @@ -/* +/* * Mach Operating System * Copyright (c) 1991 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon + * + * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* @@ -74,28 +74,6 @@ strprefix(s1, s2) return (TRUE); } -/* - * ovbcopy - like bcopy, but recognizes overlapping ranges and handles - * them correctly. - */ -ovbcopy(from, to, bytes) - char *from, *to; - int bytes; /* num bytes to copy */ -{ - /* Assume that bcopy copies left-to-right (low addr first). */ - if (from + bytes <= to || to + bytes <= from || to == from) - bcopy(from, to, bytes); /* non-overlapping or no-op*/ - else if (from > to) - bcopy(from, to, bytes); /* overlapping but OK */ - else { - /* to > from: overlapping, and must copy right-to-left. */ - from += bytes - 1; - to += bytes - 1; - while (bytes-- > 0) - *to-- = *from--; - } -} - /* * Return a pointer to the first occurence of 'c' in * string s, or 0 if none. @@ -114,4 +92,3 @@ index(s, c) } return s; } - -- cgit v1.2.3 From f7796d16d3e37778bf200237228c68763c9a33d5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 16 Nov 1999 07:59:12 +0000 Subject: 1999-11-16 Roland McGrath * strfcns.c (index): Function removed. --- serverboot/strfcns.c | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'serverboot/strfcns.c') diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c index 85e5eb83..82a76728 100644 --- a/serverboot/strfcns.c +++ b/serverboot/strfcns.c @@ -73,22 +73,3 @@ strprefix(s1, s2) } return (TRUE); } - -/* - * Return a pointer to the first occurence of 'c' in - * string s, or 0 if none. - */ -char * -index(s, c) - char *s; - char c; -{ - char cc; - - while ((cc = *s) != c) { - if (cc == 0) - return 0; - s++; - } - return s; -} -- cgit v1.2.3 From de1fc902c7f387657d792191efb092127950c08c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 7 May 2003 13:42:14 +0000 Subject: 2003-05-07 Ognyan Kulev * strfcns.c: #include instead of . (strbuild): Use -style for handling variable argument list. * load.c: Don't #include . --- serverboot/load.c | 1 - serverboot/strfcns.c | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'serverboot/strfcns.c') diff --git a/serverboot/load.c b/serverboot/load.c index e95a64d7..aa481943 100644 --- a/serverboot/load.c +++ b/serverboot/load.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "mach-exec.h" #include "../boot/boot_script.h" diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c index 82a76728..cbead7e4 100644 --- a/serverboot/strfcns.c +++ b/serverboot/strfcns.c @@ -27,7 +27,7 @@ * Character subroutines */ -#include +#include #define EXPORT_BOOLEAN #include @@ -40,21 +40,20 @@ */ /*VARARGS1*/ char * -strbuild(dest, va_alist) - register char * dest; - va_dcl +strbuild(char *dest, ...) { va_list argptr; register char * src; register int c; - va_start(argptr); + va_start(argptr, dest); while ((src = va_arg(argptr, char *)) != (char *)0) { while ((c = *src++) != '\0') *dest++ = c; } *dest = '\0'; + va_end(argptr); return (dest); } -- cgit v1.2.3