From a093aa530e6ae177496b5f9e23375529f87dfc03 Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 21 May 2007 05:11:15 +0000 Subject: [PATCH] moving this to strn_compat git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@911 9efc2488-bf62-4759-914b-345cdb29e865 --- src/ports/freebsd/Makefile | 20 ------------- src/ports/freebsd/strndup.c | 44 ----------------------------- src/ports/freebsd/strndup.h | 27 ------------------ src/ports/freebsd/strnlen.c | 56 ------------------------------------- src/ports/freebsd/strnlen.h | 26 ----------------- 5 files changed, 173 deletions(-) delete mode 100644 src/ports/freebsd/Makefile delete mode 100644 src/ports/freebsd/strndup.c delete mode 100644 src/ports/freebsd/strndup.h delete mode 100644 src/ports/freebsd/strnlen.c delete mode 100644 src/ports/freebsd/strnlen.h diff --git a/src/ports/freebsd/Makefile b/src/ports/freebsd/Makefile deleted file mode 100644 index 1398045..0000000 --- a/src/ports/freebsd/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# OSRF_LOG_PARAMS log all incoming method params at OSRF_INFO log level. -# OSRF_STRICT_PARAMS instructs the app handler to return an error if the number of method arguments -# provided to any method is not at least as large as the 'argc' setting for the method - -CFLAGS += -rdynamic -fno-strict-aliasing -fPIC - -TARGETS = strndup.o strnlen.o -HEADERS = strndup.h strnlen.h - -all: libfreebsd_str_compat.so $(TARGETS) - -libfreebsd_str_compat.so: $(TARGETS) - $(CC) -shared -W1 $(TARGETS) -o $@ - -strndup.o: strndup.c strndup.h -strnlen.o: strnlen.c strnlen.h - -clean: - /bin/rm -f *o - diff --git a/src/ports/freebsd/strndup.c b/src/ports/freebsd/strndup.c deleted file mode 100644 index 10b49fd..0000000 --- a/src/ports/freebsd/strndup.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2007 Albert Lee . - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include - -#include "strnlen.h" - -char * -strndup(const char *s, size_t n) -{ - char *ns; - - n = strnlen(s, n); - - if ((ns = (char *)malloc(n + 1))) { - ns[n] = '\0'; - return memcpy(ns, s, n); - } - - return NULL; -} diff --git a/src/ports/freebsd/strndup.h b/src/ports/freebsd/strndup.h deleted file mode 100644 index be91f5f..0000000 --- a/src/ports/freebsd/strndup.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2007 Albert Lee . - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -char *strndup(const char *s, size_t n); - diff --git a/src/ports/freebsd/strnlen.c b/src/ports/freebsd/strnlen.c deleted file mode 100644 index 81a6f17..0000000 --- a/src/ports/freebsd/strnlen.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2007 The Akuma Project - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - * $Id$ - */ - -/* - * sys/types.h is a Single Unix Specification header and defines size_t. - */ - -#include - -/* - * As per the Linux manual page: - * - * The strnlen() function returns the number of characters in the string - * pointed to by s, not including the terminating '\0' character, but at most - * maxlen. In doing this, strnlen() looks only at the first maxlen characters - * at s and never beyond s+maxlen. - * - * The strnlen() function returns strlen(s), if that is less than maxlen, or - * maxlen if there is no '\0' character among the first maxlen characters - * pointed to by s. - */ - -size_t -strnlen(const char *string, size_t maxlen) -{ - int len = 0; - - if (maxlen == 0) - return (0); - - while (*string++ && ++len < maxlen) - ; - - return (len); -} diff --git a/src/ports/freebsd/strnlen.h b/src/ports/freebsd/strnlen.h deleted file mode 100644 index 181780a..0000000 --- a/src/ports/freebsd/strnlen.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2007 The Akuma Project - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - * $Id$ - */ - -size_t strnlen(const char *, size_t); - -- 2.43.2