diff --git a/LICENSE b/LICENSE index f0fa028..0ddc59e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,29 @@ -MIT License -Copyright (c) 2021 Ozan Tezcan +BSD-3-Clause -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: +Copyright 2021 Ozan Tezcan +All rights reserved. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -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. +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. Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. diff --git a/array/sc_array.h b/array/sc_array.h index 6317844..85649f9 100644 --- a/array/sc_array.h +++ b/array/sc_array.h @@ -1,26 +1,34 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ + #ifndef SC_ARRAY_H #define SC_ARRAY_H diff --git a/buffer/sc_buf.c b/buffer/sc_buf.c index 358840a..a56c600 100644 --- a/buffer/sc_buf.c +++ b/buffer/sc_buf.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_buf.h" diff --git a/buffer/sc_buf.h b/buffer/sc_buf.h index ad044d0..e8e9f8e 100644 --- a/buffer/sc_buf.h +++ b/buffer/sc_buf.h @@ -1,26 +1,34 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ + #ifndef SC_BUF_H #define SC_BUF_H diff --git a/condition/sc_cond.c b/condition/sc_cond.c index e3a279a..1d8e184 100644 --- a/condition/sc_cond.c +++ b/condition/sc_cond.c @@ -1,26 +1,34 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ + #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 700 #endif diff --git a/condition/sc_cond.h b/condition/sc_cond.h index b62558d..dabe2c1 100644 --- a/condition/sc_cond.h +++ b/condition/sc_cond.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_COND_H diff --git a/crc32/sc_crc32.c b/crc32/sc_crc32.c index cdc6ad1..7563225 100644 --- a/crc32/sc_crc32.c +++ b/crc32/sc_crc32.c @@ -1,8 +1,3 @@ -/* crc32c.c - * Copyright (C) 2013 Mark Adler - * Version 1.1 1 Aug 2013 Mark Adler - */ - /* This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages @@ -24,11 +19,15 @@ madler@alumni.caltech.edu */ -/* Version history: - 1.0 10 Feb 2013 First version - 1.1 1 Aug 2013 Correct comments on why three crc instructions in parallel - 1.2 2020 Added gcc intrinsics, fixed undefined behaviour - 1.3 2021 Added big endian support, added aarch64 crc32c support +/* + * 2013 Mark Adler + * 2020 - present Ozan Tezcan + * + * Version history: + * 1.0 10 Feb 2013 First version + * 1.1 1 Aug 2013 Correct comments on why three crc instructions in parallel + * 1.2 2020 added gcc intrinsics, fixed undefined behaviour + * 1.3 2021 Added big endian support, added aarch64 crc32c support */ #include "sc_crc32.h" diff --git a/crc32/sc_crc32.h b/crc32/sc_crc32.h index 86c3755..dba16a5 100644 --- a/crc32/sc_crc32.h +++ b/crc32/sc_crc32.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_CRC32_H diff --git a/heap/README.md b/heap/README.md index 92213b3..d1d542f 100644 --- a/heap/README.md +++ b/heap/README.md @@ -15,46 +15,44 @@ int main(int argc, char *argv[]) { - struct data - { - int priority; - char *data; - }; + struct data { + int priority; + char *data; + }; - struct data n[] = {{1, "first"}, - {4, "fourth"}, - {5, "fifth"}, - {3, "third"}, - {2, "second"}}; + struct data n[] = {{1, "first"}, + {4, "fourth"}, + {5, "fifth"}, + {3, "third"}, + {2, "second"}}; - int64_t key; - void *data; - struct sc_heap heap; + struct sc_heap_data *elem; + struct sc_heap heap; - sc_heap_init(&heap, 0); + sc_heap_init(&heap, 0); - // Min-heap usage - for (int i = 0; i < 5; i++) { - sc_heap_add(&heap, n[i].priority, n[i].data); - } + // Min-heap usage + for (int i = 0; i < 5; i++) { + sc_heap_add(&heap, n[i].priority, n[i].data); + } - while (sc_heap_pop(&heap, &key, &data)) { - printf("key = %ld, data = %s \n", key, (char *) data); - } - printf("---------------- \n"); + while ((elem = sc_heap_pop(&heap)) != NULL) { + printf("key = %d, data = %s \n", (int) elem->key, elem->data); + } + printf("---------------- \n"); - /** - * Max-heap usage, negate when adding into heap - * and negate back after pop : - */ - for (int i = 0; i < 5; i++) { - sc_heap_add(&heap, -(n[i].priority), n[i].data); - } + // Max-heap usage, negate when adding into heap and negate back after + // pop : + for (int i = 0; i < 5; i++) { + sc_heap_add(&heap, -(n[i].priority), n[i].data); + } - while (sc_heap_pop(&heap, &key, &data)) { - printf("key = %ld, data = %s \n", -key, (char *) data); - } + while ((elem = sc_heap_pop(&heap)) != NULL) { + printf("key = %d, data = %s \n", (int) elem->key, elem->data); + } - return 0; + sc_heap_term(&heap); + + return 0; } ``` \ No newline at end of file diff --git a/heap/heap_example.c b/heap/heap_example.c index 79d391a..bb09afd 100644 --- a/heap/heap_example.c +++ b/heap/heap_example.c @@ -15,8 +15,7 @@ int main() {3, "third"}, {2, "second"}}; - int64_t key; - void *data; + struct sc_heap_data *elem; struct sc_heap heap; sc_heap_init(&heap, 0); @@ -26,25 +25,22 @@ int main() sc_heap_add(&heap, n[i].priority, n[i].data); } - while (sc_heap_pop(&heap, &key, &data)) { - printf("key = %ld, data = %s \n", (long int) key, - (char *) data); + while ((elem = sc_heap_pop(&heap)) != NULL) { + printf("key = %d, data = %s \n", (int) elem->key, elem->data); } printf("---------------- \n"); - /** - * Max-heap usage, negate when adding into heap - * and negate back after pop : - */ - + // Max-heap usage, negate when adding into heap and negate back after + // pop : for (int i = 0; i < 5; i++) { sc_heap_add(&heap, -(n[i].priority), n[i].data); } - while (sc_heap_pop(&heap, &key, &data)) { - printf("key = %ld, data = %s \n", (long int) -key, - (char *) data); + while ((elem = sc_heap_pop(&heap)) != NULL) { + printf("key = %d, data = %s \n", (int) elem->key, elem->data); } + sc_heap_term(&heap); + return 0; } diff --git a/heap/heap_test.c b/heap/heap_test.c index 86ee9e7..df4dade 100644 --- a/heap/heap_test.c +++ b/heap/heap_test.c @@ -18,8 +18,8 @@ int example(void) {5, "fifth"}, {3, "third"}, {2, "second"}}; - int64_t key; - void *data; + + struct sc_heap_data *elem; struct sc_heap heap; sc_heap_init(&heap, 0); @@ -29,8 +29,8 @@ int example(void) sc_heap_add(&heap, n[i].priority, n[i].data); } - while (sc_heap_pop(&heap, &key, &data)) { - printf("key = %d, data = %s \n", (int) key, (char *) data); + while ((elem = sc_heap_pop(&heap)) != NULL) { + printf("key = %d, data = %s \n", (int) elem->key, elem->data); } printf("---------------- \n"); @@ -40,8 +40,8 @@ int example(void) sc_heap_add(&heap, -(n[i].priority), n[i].data); } - while (sc_heap_pop(&heap, &key, &data)) { - printf("key = %d, data = %s \n", (int) -key, (char *) data); + while ((elem = sc_heap_pop(&heap)) != NULL) { + printf("key = %d, data = %s \n", (int) elem->key, elem->data); } sc_heap_term(&heap); @@ -51,21 +51,20 @@ int example(void) void test1(void) { - int64_t key; - void *data; struct sc_heap heap; + struct sc_heap_data *elem; sc_heap_init(&heap, 0); sc_heap_add(&heap, 100, "test"); - sc_heap_pop(&heap, &key, &data); - assert(key == 100); - assert(strcmp("test", data) == 0); + elem = sc_heap_pop(&heap); + assert(elem->key == 100); + assert(strcmp("test", elem->data) == 0); sc_heap_term(&heap); sc_heap_add(&heap, 100, "test"); - sc_heap_pop(&heap, &key, &data); - assert(key == 100); - assert(strcmp("test", data) == 0); + elem = sc_heap_pop(&heap); + assert(elem->key == 100); + assert(strcmp("test", elem->data) == 0); sc_heap_term(&heap); assert(sc_heap_init(&heap, SIZE_MAX / 2) == false); @@ -73,8 +72,9 @@ void test1(void) for (int i = 0; i < 1000; i++) { assert(sc_heap_add(&heap, i, (void *) (uintptr_t) i) == true); - assert(sc_heap_pop(&heap, &key, &data) == true); - assert(key == (intptr_t) data); + elem = sc_heap_pop(&heap); + assert(elem != NULL); + assert(elem->key == (intptr_t) elem->data); } int64_t arr[] = {1, 0, 4, 5, 7, 9, 8, 6, 3, 2}; @@ -85,9 +85,10 @@ void test1(void) } for (int i = 0; i < 10; i++) { - assert(sc_heap_pop(&heap, &key, &data) == true); - assert(key == i); - assert((intptr_t) data == i * 2); + elem = sc_heap_pop(&heap); + assert(elem != NULL); + assert(elem->key == i); + assert((intptr_t) elem->data == i * 2); } sc_heap_term(&heap); @@ -96,17 +97,17 @@ void test1(void) void test2(void) { static const int64_t arr[] = {1, 0, 4, 5, 7, 9, 8, 6, 3, 2}; - int64_t key; - void *data; + struct sc_heap_data *elem; struct sc_heap heap; assert(sc_heap_init(&heap, 0) == true); for (int i = 0; i < 1000; i++) { assert(sc_heap_add(&heap, i, (void *) (uintptr_t) i) == true); - assert(sc_heap_pop(&heap, &key, &data) == true); - assert(key == (intptr_t) data); - assert(key == (intptr_t) i); + elem = sc_heap_pop(&heap); + assert(elem != NULL); + assert(elem->key == (intptr_t) elem->data); + assert(elem->key == (intptr_t) i); } for (int i = 0; i < 10; i++) { @@ -115,9 +116,10 @@ void test2(void) } for (int i = 0; i < 10; i++) { - assert(sc_heap_pop(&heap, &key, &data) == true); - assert(-key == 9 - i); - assert((intptr_t) data == (9 - i) * 2); + elem = sc_heap_pop(&heap); + assert(elem != NULL); + assert(-elem->key == 9 - i); + assert((intptr_t) elem->data == (9 - i) * 2); } sc_heap_term(&heap); @@ -125,19 +127,22 @@ void test2(void) void test3(void) { - int64_t key; int arr[100]; - void *data; + struct sc_heap_data *elem; struct sc_heap heap; assert(sc_heap_init(&heap, 2) == true); assert(sc_heap_add(&heap, 9, (void *) (uintptr_t) 9) == true); - assert(sc_heap_peek(&heap, &key, &data) == true); - assert(key == 9); - assert(data == (void *) (uintptr_t) 9); - assert(sc_heap_pop(&heap, &key, &data) == true); - assert(key == 9); - assert(data == (void *) (uintptr_t) 9); + + elem = sc_heap_peek(&heap); + assert(elem != NULL); + assert(elem->key == 9); + assert(elem->data == (void *) (uintptr_t) 9); + + elem = sc_heap_pop(&heap); + assert(elem != NULL); + assert(elem->key == 9); + assert(elem->data == (void *) (uintptr_t) 9); for (int i = 0; i < 100; i++) { arr[i] = i; @@ -154,13 +159,14 @@ void test3(void) } for (int i = 0; i < 100; i++) { - assert(sc_heap_pop(&heap, &key, &data) == true); - assert(key == i); - assert(data == (void *) (uintptr_t) i); + elem = sc_heap_pop(&heap); + assert(elem != NULL); + assert(elem->key == i); + assert(elem->data == (void *) (uintptr_t) i); } - assert(sc_heap_peek(&heap, &key, &data) == false); - assert(sc_heap_pop(&heap, &key, &data) == false); + assert(sc_heap_peek(&heap) == NULL); + assert(sc_heap_pop(&heap) == NULL); assert(sc_heap_size(&heap) == 0); assert(sc_heap_add(&heap, 1, NULL) == true); diff --git a/heap/sc_heap.c b/heap/sc_heap.c index e8362c1..437e459 100644 --- a/heap/sc_heap.c +++ b/heap/sc_heap.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_heap.h" @@ -100,31 +107,27 @@ bool sc_heap_add(struct sc_heap *h, int64_t key, void *data) return true; } -bool sc_heap_peek(struct sc_heap *h, int64_t *key, void **data) +struct sc_heap_data *sc_heap_peek(struct sc_heap *h) { if (h->size == 0) { - return false; + return NULL; } // Top element is always at heap->elems[1]. - *key = h->elems[1].key; - *data = h->elems[1].data; - - return true; + return &h->elems[1]; } -bool sc_heap_pop(struct sc_heap *h, int64_t *key, void **data) +struct sc_heap_data *sc_heap_pop(struct sc_heap *h) { size_t i = 1, child = 2; struct sc_heap_data last; if (h->size == 0) { - return false; + return NULL; } // Top element is always at heap->elems[1]. - *key = h->elems[1].key; - *data = h->elems[1].data; + h->elems[0] = h->elems[1]; last = h->elems[h->size--]; while (child <= h->size) { @@ -145,5 +148,5 @@ bool sc_heap_pop(struct sc_heap *h, int64_t *key, void **data) h->elems[i] = last; - return true; + return &h->elems[0]; } diff --git a/heap/sc_heap.h b/heap/sc_heap.h index 5fa76cb..d470ca0 100644 --- a/heap/sc_heap.h +++ b/heap/sc_heap.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_HEAP_H @@ -87,20 +94,18 @@ bool sc_heap_add(struct sc_heap *h, int64_t key, void *data); * Read top element without removing from the heap. * * @param h heap - * @param key [out] key - * @param data [out] data - * @return 'false' if there is no element in the heap. + * @return pointer to data holder(valid until next heap operation) + * NULL if heap is empty. */ -bool sc_heap_peek(struct sc_heap *h, int64_t *key, void **data); +struct sc_heap_data *sc_heap_peek(struct sc_heap *h); /** * Read top element and remove it from the heap. * * @param h heap - * @param key [out] key - * @param data [out] data - * @return 'false' if there is no element in the heap. + * @return pointer to data holder(valid until next heap operation) + * NULL if heap is empty. */ -bool sc_heap_pop(struct sc_heap *h, int64_t *key, void **data); +struct sc_heap_data *sc_heap_pop(struct sc_heap *h); #endif diff --git a/ini/sc_ini.c b/ini/sc_ini.c index aee713a..d8624d2 100644 --- a/ini/sc_ini.c +++ b/ini/sc_ini.c @@ -1,29 +1,35 @@ /* - * MIT License - * - * Copyright (c) 2021 Ozan Tezcan - * - * 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. + * BSD-3-Clause * * Based on : https://github.com/benhoyt/inih - * SPDX-License-Identifier: BSD-3-Clause - * Copyright (C) 2009-2020, Ben Hoyt + * Copyright (C) 2009-2020, Ben Hoyt + * 2001-present Ozan Tezcan + * + * 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. Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_ini.h" diff --git a/ini/sc_ini.h b/ini/sc_ini.h index 039157a..065c407 100644 --- a/ini/sc_ini.h +++ b/ini/sc_ini.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_INI_H diff --git a/linked-list/sc_list.c b/linked-list/sc_list.c index d4022c6..aac348a 100644 --- a/linked-list/sc_list.c +++ b/linked-list/sc_list.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_list.h" diff --git a/linked-list/sc_list.h b/linked-list/sc_list.h index e538ca1..a3fcbe9 100644 --- a/linked-list/sc_list.h +++ b/linked-list/sc_list.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_LIST_H diff --git a/logger/sc_log.c b/logger/sc_log.c index 193e15b..5d9dd43 100644 --- a/logger/sc_log.c +++ b/logger/sc_log.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef _XOPEN_SOURCE diff --git a/logger/sc_log.h b/logger/sc_log.h index ac40df9..d303eed 100644 --- a/logger/sc_log.h +++ b/logger/sc_log.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_LOG_H diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt index b213925..2be5883 100644 --- a/map/CMakeLists.txt +++ b/map/CMakeLists.txt @@ -10,6 +10,8 @@ add_library( sc_map.c sc_map.h) +add_executable(test_map sc_map.h sc_map.c map_example.c) + target_include_directories(sc_map PUBLIC ${CMAKE_CURRENT_LIST_DIR}) if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") diff --git a/map/README.md b/map/README.md index e520e87..1b610bd 100644 --- a/map/README.md +++ b/map/README.md @@ -31,8 +31,8 @@ Key and value types can be integers(32bit/64bit) or pointers only. Other types can be added but must be scalar types, not structs. This is a design decision, I don't remember when was the last time I wanted to store struct as a key or value. I use hashmap for fast look-ups and small key-value -pairs with linear probing play well with cache lines and hardware prefetcher. -If you want to use structs anyway, you need to change the code a little bit. +pairs with linear probing play well with cache lines and hardware-prefetcher. +If you want to use structs anyway, you need to change the code a little. ### Usage @@ -42,8 +42,7 @@ If you want to use structs anyway, you need to change the code a little bit. #include - -void example_str() +void example_str(void) { const char *key, *value; struct sc_map_str map; @@ -61,10 +60,11 @@ void example_str() sc_map_term_str(&map); } -void example_int_to_str() +void example_int_to_str(void) { uint32_t key; - const char *value; + const char *elem; + const char **value; struct sc_map_64s map; sc_map_init_64s(&map, 0, 0); @@ -74,23 +74,61 @@ void example_int_to_str() sc_map_put_64s(&map, 300, "atlanta"); value = sc_map_del_64s(&map, 100); - if (sc_map_found(&map)) { - printf("Deleted : %s \n", value); + if (value != NULL) { + printf("Deleted : %s \n", *value); } - sc_map_foreach (&map, key, value) { - printf("Key:[%d], Value:[%s] \n", key, value); - } + sc_map_foreach (&map, key, elem) { + printf("Key:[%d], Value:[%s] \n", key, elem); + } sc_map_term_64s(&map); } -int main(int argc, char *argv[]) +void example_errcheck(void) { - example_str(); - example_int_to_str(); + bool ret; + uint32_t *val; + struct sc_map_32 map; - return 0; + ret = sc_map_init_32(&map, 0, 0); + if (!ret) { + perror("Out of memory!"); + abort(); + } + + ret = sc_map_put_32(&map, 0, 0); + if (!ret) { + perror("Out of memory!"); + abort(); + } + + val = sc_map_get_32(&map, 0); + if (val != NULL) { + // set current value to 3 + *val = 3; + } + + val = sc_map_get_32(&map, 0); + if (val != NULL) { + printf("Read value : %u \n", *val); + } + + val = sc_map_del_32(&map, 0); + if (val != NULL) { + printf("Deleted : %u \n", *val); + } + + sc_map_term_32(&map); +} + +int main() +{ + example_errcheck(); + example_str(); + example_int_to_str(); + + return 0; } ``` diff --git a/map/map_example.c b/map/map_example.c index 3288c26..d66b7a8 100644 --- a/map/map_example.c +++ b/map/map_example.c @@ -23,7 +23,8 @@ void example_str(void) void example_int_to_str(void) { uint32_t key; - const char *value; + const char *elem; + const char **value; struct sc_map_64s map; sc_map_init_64s(&map, 0, 0); @@ -33,19 +34,57 @@ void example_int_to_str(void) sc_map_put_64s(&map, 300, "atlanta"); value = sc_map_del_64s(&map, 100); - if (sc_map_found(&map)) { - printf("Deleted : %s \n", value); + if (value != NULL) { + printf("Deleted : %s \n", *value); } - sc_map_foreach (&map, key, value) { - printf("Key:[%d], Value:[%s] \n", key, value); + sc_map_foreach (&map, key, elem) { + printf("Key:[%d], Value:[%s] \n", key, elem); } sc_map_term_64s(&map); } +void example_errcheck(void) +{ + bool ret; + uint32_t *val; + struct sc_map_32 map; + + ret = sc_map_init_32(&map, 0, 0); + if (!ret) { + perror("Out of memory!"); + abort(); + } + + ret = sc_map_put_32(&map, 0, 0); + if (!ret) { + perror("Out of memory!"); + abort(); + } + + val = sc_map_get_32(&map, 0); + if (val != NULL) { + // set current value to 3 + *val = 3; + } + + val = sc_map_get_32(&map, 0); + if (val != NULL) { + printf("Read value : %u \n", *val); + } + + val = sc_map_del_32(&map, 0); + if (val != NULL) { + printf("Deleted : %u \n", *val); + } + + sc_map_term_32(&map); +} + int main() { + example_errcheck(); example_str(); example_int_to_str(); diff --git a/map/map_test.c b/map/map_test.c index 4f1a6b4..6fb1497 100644 --- a/map/map_test.c +++ b/map/map_test.c @@ -28,6 +28,7 @@ void example_int_to_str() { uint32_t key; const char *value; + const char **ret; struct sc_map_64s map; sc_map_init_64s(&map, 0, 0); @@ -36,9 +37,9 @@ void example_int_to_str() sc_map_put_64s(&map, 200, "new york"); sc_map_put_64s(&map, 300, "atlanta"); - value = sc_map_del_64s(&map, 100); - if (sc_map_found(&map)) { - printf("Deleted : %s \n", value); + ret = sc_map_del_64s(&map, 100); + if (ret != NULL) { + printf("Deleted : %s \n", *ret); } sc_map_foreach (&map, key, value) { @@ -69,6 +70,8 @@ static char *str_random(size_t size) void test_32() { + bool rc; + uint32_t *val; struct sc_map_32 map; assert(sc_map_init_32(&map, 0, 0)); @@ -78,20 +81,20 @@ void test_32() assert(sc_map_init_32(&map, 16, 94)); - sc_map_del_32(&map, 0); - assert(sc_map_found(&map) == false); + val = sc_map_del_32(&map, 0); + assert(val == NULL); - sc_map_del_32(&map, 1); - assert(sc_map_found(&map) == false); + val = sc_map_del_32(&map, 1); + assert(val == NULL); for (int i = 0; i < 14; i++) { - sc_map_put_32(&map, i, i); - assert(!sc_map_oom(&map)); + rc = sc_map_put_32(&map, i, i); + assert(rc); } for (int i = 100; i < 200; i++) { - sc_map_del_32(&map, i); - assert(sc_map_found(&map) == false); + val = sc_map_del_32(&map, i); + assert(!val); } sc_map_clear_32(&map); @@ -104,21 +107,21 @@ void test_32() sc_map_put_32(&map, 15, 15); sc_map_put_32(&map, 46, 15); - sc_map_get_32(&map, 19); - assert(sc_map_found(&map) == false); + val = sc_map_get_32(&map, 19); + assert(!val); for (int i = 0; i < 5; i++) { sc_map_put_32(&map, (5 * i) + i, i); } - sc_map_del_32(&map, 4); - assert(sc_map_found(&map)); + val = sc_map_del_32(&map, 4); + assert(val); - sc_map_del_32(&map, 46); - assert(sc_map_found(&map)); + val = sc_map_del_32(&map, 46); + assert(val); - sc_map_del_32(&map, 15); - assert(sc_map_found(&map)); + val = sc_map_del_32(&map, 15); + assert(val); sc_map_clear_32(&map); for (int i = 1; i < 4; i++) { @@ -132,20 +135,21 @@ void test_32() sc_map_put_32(&map, 512 * i, i); } - sc_map_del_32(&map, 512); - assert(sc_map_found(&map)); + val = sc_map_del_32(&map, 512); + assert(val); - sc_map_del_32(&map, 1024); - assert(sc_map_found(&map)); + val = sc_map_del_32(&map, 1024); + assert(val); - sc_map_del_32(&map, 48); - assert(sc_map_found(&map)); + val = sc_map_del_32(&map, 48); + assert(val); sc_map_term_32(&map); } void test_64() { + uint64_t *val; struct sc_map_64 map; assert(sc_map_init_64(&map, 0, 0)); @@ -155,19 +159,19 @@ void test_64() assert(sc_map_init_64(&map, 16, 94)); - sc_map_del_64(&map, 0); - assert(!sc_map_found(&map)); + val = sc_map_del_64(&map, 0); + assert(val == NULL); - sc_map_del_64(&map, 1); - assert(!sc_map_found(&map)); + val = sc_map_del_64(&map, 1); + assert(val == NULL); for (int i = 0; i < 14; i++) { sc_map_put_64(&map, i, i); } for (int i = 100; i < 200; i++) { - sc_map_del_64(&map, i); - assert(!sc_map_found(&map)); + val = sc_map_del_64(&map, i); + assert(val == NULL); } sc_map_clear_64(&map); @@ -180,21 +184,21 @@ void test_64() sc_map_put_64(&map, 15, 15); sc_map_put_64(&map, 46, 15); - sc_map_get_64(&map, 19); - assert(!sc_map_found(&map)); + val = sc_map_get_64(&map, 19); + assert(val == NULL); for (int i = 0; i < 5; i++) { sc_map_put_64(&map, (5 * i) + i, i); } - sc_map_del_64(&map, 4); - assert(sc_map_found(&map)); + val = sc_map_del_64(&map, 4); + assert(val); - sc_map_del_64(&map, 46); - assert(sc_map_found(&map)); + val = sc_map_del_64(&map, 46); + assert(val); - sc_map_del_64(&map, 15); - assert(sc_map_found(&map)); + val = sc_map_del_64(&map, 15); + assert(val); sc_map_clear_64(&map); for (int i = 1; i < 4; i++) { @@ -208,20 +212,21 @@ void test_64() sc_map_put_64(&map, 512 * i, i); } - sc_map_del_64(&map, 512); - assert(sc_map_found(&map)); + val = sc_map_del_64(&map, 512); + assert(val); - sc_map_del_64(&map, 1024); - assert(sc_map_found(&map)); + val = sc_map_del_64(&map, 1024); + assert(val); - sc_map_del_64(&map, 48); - assert(sc_map_found(&map)); + val = sc_map_del_64(&map, 48); + assert(val); sc_map_term_64(&map); } void test_64v() { + void **val; struct sc_map_64v map; assert(sc_map_init_64v(&map, 0, 0)); @@ -230,11 +235,11 @@ void test_64v() assert(sc_map_init_64v(&map, 0, 99) == false); assert(sc_map_init_64v(&map, 16, 94)); - sc_map_del_64v(&map, 0); - assert(sc_map_found(&map) == false); + val = sc_map_del_64v(&map, 0); + assert(val == NULL); sc_map_del_64v(&map, 1); - assert(sc_map_found(&map) == false); + assert(val == NULL); for (int i = 0; i < 14; i++) { sc_map_put_64v(&map, i, NULL); @@ -242,7 +247,7 @@ void test_64v() for (int i = 100; i < 200; i++) { sc_map_del_64v(&map, i); - assert(sc_map_found(&map) == false); + assert(val == NULL); } sc_map_clear_64v(&map); @@ -250,27 +255,27 @@ void test_64v() for (int i = 0; i < 5; i++) { sc_map_put_64v(&map, i, NULL); - assert(!sc_map_found(&map)); + assert(val == NULL); } sc_map_put_64v(&map, 31, NULL); sc_map_put_64v(&map, 15, NULL); sc_map_put_64v(&map, 46, NULL); sc_map_get_64v(&map, 19); - assert(sc_map_found(&map) == false); + assert(val == NULL); for (int i = 0; i < 5; i++) { sc_map_put_64v(&map, (5 * i) + i, NULL); } sc_map_del_64v(&map, 4); - assert(sc_map_found(&map)); + assert(!val); sc_map_del_64v(&map, 46); - assert(sc_map_found(&map)); + assert(!val); sc_map_del_64v(&map, 15); - assert(sc_map_found(&map)); + assert(!val); sc_map_clear_64v(&map); for (int i = 1; i < 4; i++) { @@ -285,19 +290,20 @@ void test_64v() } sc_map_del_64v(&map, 512); - assert(sc_map_found(&map)); + assert(!val); sc_map_del_64v(&map, 1024); - assert(sc_map_found(&map)); + assert(!val); sc_map_del_64v(&map, 48); - assert(sc_map_found(&map)); + assert(!val); sc_map_term_64v(&map); } void test_64s() { + const char **val; struct sc_map_64s map; assert(sc_map_init_64s(&map, 0, 0)); @@ -306,11 +312,11 @@ void test_64s() assert(sc_map_init_64s(&map, 0, 99) == false); assert(sc_map_init_64s(&map, 16, 94)); - sc_map_del_64s(&map, 0); - assert(!sc_map_found(&map)); + val = sc_map_del_64s(&map, 0); + assert(val == NULL); sc_map_del_64s(&map, 1); - assert(!sc_map_found(&map)); + assert(val == NULL); for (int i = 0; i < 14; i++) { sc_map_put_64s(&map, i, NULL); @@ -318,7 +324,7 @@ void test_64s() for (int i = 100; i < 200; i++) { sc_map_del_64s(&map, i); - assert(!sc_map_found(&map)); + assert(val == NULL); } sc_map_clear_64s(&map); @@ -331,21 +337,21 @@ void test_64s() sc_map_put_64s(&map, 15, NULL); sc_map_put_64s(&map, 46, NULL); - sc_map_get_64s(&map, 19); - assert(sc_map_found(&map) == false); + val = sc_map_get_64s(&map, 19); + assert(val == NULL); for (int i = 0; i < 5; i++) { sc_map_put_64s(&map, (5 * i) + i, NULL); } - sc_map_del_64s(&map, 4); - assert(sc_map_found(&map)); + val = sc_map_del_64s(&map, 4); + assert(val); - sc_map_del_64s(&map, 46); - assert(sc_map_found(&map)); + val = sc_map_del_64s(&map, 46); + assert(val); - sc_map_del_64s(&map, 15); - assert(sc_map_found(&map)); + val = sc_map_del_64s(&map, 15); + assert(val); sc_map_clear_64s(&map); for (int i = 1; i < 4; i++) { @@ -359,14 +365,14 @@ void test_64s() sc_map_put_64s(&map, 512 * i, NULL); } - sc_map_del_64s(&map, 512); - assert(sc_map_found(&map)); + val = sc_map_del_64s(&map, 512); + assert(val); - sc_map_del_64s(&map, 1024); - assert(sc_map_found(&map)); + val = sc_map_del_64s(&map, 1024); + assert(val); - sc_map_del_64s(&map, 48); - assert(sc_map_found(&map)); + val = sc_map_del_64s(&map, 48); + assert(val); sc_map_term_64s(&map); } @@ -375,6 +381,7 @@ void test_str() { const char *arr = "abcdefghijklmnoprstuvyzabcdefghijklmnoprstuvyzabcdef" "ghijklmnoprstuvyz"; + const char **val; struct sc_map_str map; assert(sc_map_init_str(&map, 0, 0)); @@ -384,19 +391,19 @@ void test_str() assert(sc_map_init_str(&map, 16, 94)); - sc_map_del_str(&map, NULL); - assert(!sc_map_found(&map)); + val = sc_map_del_str(&map, NULL); + assert(val == NULL); - sc_map_del_str(&map, ""); - assert(!sc_map_found(&map)); + val = sc_map_del_str(&map, ""); + assert(val == NULL); for (int i = 0; i < 14; i++) { sc_map_put_str(&map, &arr[i], NULL); } for (int i = 15; i < 30; i++) { - sc_map_del_str(&map, &arr[i]); - assert(!sc_map_found(&map)); + val = sc_map_del_str(&map, &arr[i]); + assert(val == NULL); } sc_map_clear_str(&map); @@ -404,34 +411,34 @@ void test_str() sc_map_put_str(&map, "h", NULL); sc_map_put_str(&map, "z", NULL); - sc_map_get_str(&map, "13"); - assert(!sc_map_found(&map)); + val = sc_map_get_str(&map, "13"); + assert(val == NULL); - sc_map_get_str(&map, NULL); - assert(!sc_map_found(&map)); + val = sc_map_get_str(&map, NULL); + assert(val == NULL); - sc_map_get_str(&map, "h"); - assert(sc_map_found(&map)); + val = sc_map_get_str(&map, "h"); + assert(val); - sc_map_get_str(&map, "z"); - assert(sc_map_found(&map)); + val = sc_map_get_str(&map, "z"); + assert(val); - sc_map_get_str(&map, "x"); - assert(!sc_map_found(&map)); + val = sc_map_get_str(&map, "x"); + assert(val == NULL); sc_map_put_str(&map, NULL, NULL); - sc_map_get_str(&map, NULL); - assert(sc_map_found(&map)); + val = sc_map_get_str(&map, NULL); + assert(val); - sc_map_del_str(&map, NULL); - assert(sc_map_found(&map)); + val = sc_map_del_str(&map, NULL); + assert(val); - sc_map_del_str(&map, "h"); - assert(sc_map_found(&map)); + val = sc_map_del_str(&map, "h"); + assert(val); - sc_map_del_str(&map, "13"); - assert(!sc_map_found(&map)); + val = sc_map_del_str(&map, "13"); + assert(val == NULL); sc_map_clear_str(&map); assert(sc_map_size_str(&map) == 0); @@ -443,35 +450,35 @@ void test_str() sc_map_put_str(&map, &arr[7], NULL); sc_map_put_str(&map, &arr[9], NULL); - sc_map_get_str(&map, &arr[16]); - assert(!sc_map_found(&map)); + val = sc_map_get_str(&map, &arr[16]); + assert(val == NULL); for (int i = 0; i < 5; i++) { sc_map_put_str(&map, &arr[(5 * i) + i], NULL); } - sc_map_del_str(&map, &arr[4]); - assert(sc_map_found(&map)); + val = sc_map_del_str(&map, &arr[4]); + assert(val); - sc_map_del_str(&map, &arr[6]); - assert(sc_map_found(&map)); + val = sc_map_del_str(&map, &arr[6]); + assert(val); - sc_map_del_str(&map, &arr[15]); - assert(sc_map_found(&map)); + val = sc_map_del_str(&map, &arr[15]); + assert(val); sc_map_clear_str(&map); sc_map_put_str(&map, "h", NULL); sc_map_put_str(&map, "z", NULL); - sc_map_del_str(&map, "h"); - assert(sc_map_found(&map)); + val = sc_map_del_str(&map, "h"); + assert(val); sc_map_clear_str(&map); sc_map_put_str(&map, "h", NULL); sc_map_put_str(&map, "z", NULL); sc_map_put_str(&map, "13", NULL); - sc_map_del_str(&map, "z"); - assert(sc_map_found(&map)); + val = sc_map_del_str(&map, "z"); + assert(val); sc_map_term_str(&map); } @@ -480,6 +487,7 @@ void test_sv() { const char *arr = "abcdefghijklmnoprstuvyzabcdefghijklmnoprstuvyzabcdef" "ghijklmnoprstuvyz"; + void **val; struct sc_map_sv map; assert(sc_map_init_sv(&map, 0, 0)); @@ -488,19 +496,19 @@ void test_sv() assert(sc_map_init_sv(&map, 0, 99) == false); assert(sc_map_init_sv(&map, 16, 94)); - sc_map_del_sv(&map, NULL); - assert(!sc_map_found(&map)); + val = sc_map_del_sv(&map, NULL); + assert(val == NULL); - sc_map_del_sv(&map, ""); - assert(!sc_map_found(&map)); + val = sc_map_del_sv(&map, ""); + assert(val == NULL); for (int i = 0; i < 14; i++) { sc_map_put_sv(&map, &arr[i], NULL); } for (int i = 15; i < 30; i++) { - sc_map_del_sv(&map, &arr[i]); - assert(!sc_map_found(&map)); + val = sc_map_del_sv(&map, &arr[i]); + assert(val == NULL); } sc_map_clear_sv(&map); @@ -509,33 +517,33 @@ void test_sv() sc_map_put_sv(&map, "h", NULL); sc_map_put_sv(&map, "z", NULL); - sc_map_get_sv(&map, "13"); - assert(!sc_map_found(&map)); + val = sc_map_get_sv(&map, "13"); + assert(val == NULL); - sc_map_get_sv(&map, NULL); - assert(!sc_map_found(&map)); + val = sc_map_get_sv(&map, NULL); + assert(val == NULL); - sc_map_get_sv(&map, "h"); - assert(sc_map_found(&map)); + val = sc_map_get_sv(&map, "h"); + assert(val); - sc_map_get_sv(&map, "z"); - assert(sc_map_found(&map)); + val = sc_map_get_sv(&map, "z"); + assert(val); - sc_map_get_sv(&map, "x"); - assert(!sc_map_found(&map)); + val = sc_map_get_sv(&map, "x"); + assert(val == NULL); sc_map_put_sv(&map, NULL, NULL); - sc_map_get_sv(&map, NULL); - assert(sc_map_found(&map)); + val = sc_map_get_sv(&map, NULL); + assert(val); sc_map_del_sv(&map, NULL); - assert(sc_map_found(&map)); + assert(val); sc_map_del_sv(&map, "h"); - assert(sc_map_found(&map)); + assert(val); sc_map_del_sv(&map, "13"); - assert(!sc_map_found(&map)); + assert(val != NULL); sc_map_clear_sv(&map); assert(sc_map_size_sv(&map) == 0); @@ -547,34 +555,34 @@ void test_sv() sc_map_put_sv(&map, &arr[7], NULL); sc_map_put_sv(&map, &arr[9], NULL); - sc_map_get_sv(&map, &arr[16]); - assert(!sc_map_found(&map)); + val = sc_map_get_sv(&map, &arr[16]); + assert(val == NULL); for (int i = 0; i < 5; i++) { sc_map_put_sv(&map, &arr[(5 * i) + i], NULL); } sc_map_del_sv(&map, &arr[4]); - assert(sc_map_found(&map)); + assert(!val); sc_map_del_sv(&map, &arr[6]); - assert(sc_map_found(&map)); + assert(!val); sc_map_del_sv(&map, &arr[15]); - assert(sc_map_found(&map)); + assert(!val); sc_map_clear_sv(&map); sc_map_put_sv(&map, "h", NULL); sc_map_put_sv(&map, "z", NULL); sc_map_del_sv(&map, "h"); - assert(sc_map_found(&map)); + assert(!val); sc_map_clear_sv(&map); sc_map_put_sv(&map, "h", NULL); sc_map_put_sv(&map, "z", NULL); sc_map_put_sv(&map, "13", NULL); sc_map_del_sv(&map, "z"); - assert(sc_map_found(&map)); + assert(!val); sc_map_term_sv(&map); } @@ -583,6 +591,7 @@ void test_s64() { const char *arr = "abcdefghijklmnoprstuvyzabcdefghijklmnoprstuvyzabcdef" "ghijklmnoprstuvyz"; + uint64_t *val; struct sc_map_s64 map; assert(sc_map_init_s64(&map, 0, 0)); @@ -591,19 +600,19 @@ void test_s64() assert(sc_map_init_s64(&map, 0, 99) == false); assert(sc_map_init_s64(&map, 16, 94)); - sc_map_del_s64(&map, NULL); - assert(!sc_map_found(&map)); + val = sc_map_del_s64(&map, NULL); + assert(val == NULL); - sc_map_del_s64(&map, ""); - assert(!sc_map_found(&map)); + val = sc_map_del_s64(&map, ""); + assert(val == NULL); for (int i = 0; i < 14; i++) { sc_map_put_s64(&map, &arr[i], 0); } for (int i = 15; i < 30; i++) { - sc_map_del_s64(&map, &arr[i]); - assert(!sc_map_found(&map)); + val = sc_map_del_s64(&map, &arr[i]); + assert(val == NULL); } sc_map_clear_s64(&map); @@ -612,35 +621,34 @@ void test_s64() sc_map_put_s64(&map, "h", 0); sc_map_put_s64(&map, "z", 0); - sc_map_get_s64(&map, "13"); - assert(!sc_map_found(&map)); + val = sc_map_get_s64(&map, "13"); + assert(val == NULL); - sc_map_get_s64(&map, NULL); - assert(!sc_map_found(&map)); + val = sc_map_get_s64(&map, NULL); + assert(val == NULL); - sc_map_get_s64(&map, "h"); - assert(sc_map_found(&map)); + val = sc_map_get_s64(&map, "h"); + assert(val); - sc_map_get_s64(&map, "z"); - assert(sc_map_found(&map)); + val = sc_map_get_s64(&map, "z"); + assert(val); - sc_map_get_s64(&map, "x"); - assert(!sc_map_found(&map)); + val = sc_map_get_s64(&map, "x"); + assert(val == NULL); sc_map_put_s64(&map, NULL, 0); - assert(!sc_map_found(&map)); - sc_map_get_s64(&map, NULL); - assert(sc_map_found(&map)); + val = sc_map_get_s64(&map, NULL); + assert(val); - sc_map_del_s64(&map, NULL); - assert(sc_map_found(&map)); + val = sc_map_del_s64(&map, NULL); + assert(val); - sc_map_del_s64(&map, "h"); - assert(sc_map_found(&map)); + val = sc_map_del_s64(&map, "h"); + assert(val); - sc_map_del_s64(&map, "13"); - assert(!sc_map_found(&map)); + val = sc_map_del_s64(&map, "13"); + assert(val == NULL); sc_map_clear_s64(&map); assert(sc_map_size_s64(&map) == 0); @@ -649,88 +657,81 @@ void test_s64() } sc_map_put_s64(&map, &arr[15], 0); sc_map_put_s64(&map, &arr[7], 0); - sc_map_put_s64(&map, &arr[9], 0); + assert(sc_map_put_s64(&map, &arr[9], 0)); - assert(!sc_map_oom(&map)); - - sc_map_get_s64(&map, &arr[16]); - assert(!sc_map_found(&map)); + val = sc_map_get_s64(&map, &arr[16]); + assert(val == NULL); for (int i = 0; i < 5; i++) { - sc_map_put_s64(&map, &arr[(5 * i) + i], 0); - assert(!sc_map_oom(&map)); + assert(sc_map_put_s64(&map, &arr[(5 * i) + i], 0)); } - sc_map_del_s64(&map, &arr[4]); - assert(sc_map_found(&map)); + val = sc_map_del_s64(&map, &arr[4]); + assert(val); - sc_map_del_s64(&map, &arr[6]); - assert(sc_map_found(&map)); + val = sc_map_del_s64(&map, &arr[6]); + assert(val); - sc_map_del_s64(&map, &arr[15]); - assert(sc_map_found(&map)); + val = sc_map_del_s64(&map, &arr[15]); + assert(val); sc_map_clear_s64(&map); sc_map_put_s64(&map, "h", 0); sc_map_put_s64(&map, "z", 0); - sc_map_del_s64(&map, "h"); - assert(sc_map_found(&map)); + val = sc_map_del_s64(&map, "h"); + assert(val); sc_map_clear_s64(&map); sc_map_put_s64(&map, "h", 0); sc_map_put_s64(&map, "z", 0); sc_map_put_s64(&map, "13", 0); - sc_map_del_s64(&map, "z"); - assert(sc_map_found(&map)); + val = sc_map_del_s64(&map, "z"); + assert(val); sc_map_term_s64(&map); } void test0() { - uint64_t val; + uint64_t *val; struct sc_map_64 map; sc_map_init_64(&map, 128, 0); - sc_map_put_64(&map, 100, 100); - assert(!sc_map_oom(&map)); - assert(!sc_map_found(&map)); + assert(sc_map_put_64(&map, 100, 100)); val = sc_map_get_64(&map, 100); - assert(val == 100); - assert(sc_map_found(&map)); + assert(val); + assert(*val == 100); - val = sc_map_put_64(&map, 100, 200); - assert(sc_map_found(&map)); - assert(val == 100); + assert(sc_map_put_64(&map, 100, 200)); val = sc_map_get_64(&map, 100); - assert(val == 200); - assert(sc_map_found(&map)); + assert(val); + assert(*val == 200); val = sc_map_del_64(&map, 100); - assert(sc_map_found(&map)); - assert(val == 200); + assert(val); + assert(*val == 200); + + assert(sc_map_put_64(&map, 1, 1)); - val = sc_map_put_64(&map, 1, 1); - assert(!sc_map_found(&map)); val = sc_map_del_64(&map, 2); - assert(!sc_map_found(&map)); + assert(val == NULL); + val = sc_map_get_64(&map, 1); - assert(sc_map_found(&map)); - assert(val == 1); - val = sc_map_put_64(&map, 2, 2); - assert(!sc_map_found(&map)); + assert(val); + assert(*val == 1); + assert(sc_map_put_64(&map, 2, 2)); val = sc_map_del_64(&map, 1); - assert(sc_map_found(&map)); - assert(val == 1); + assert(val); + assert(*val == 1); val = sc_map_del_64(&map, 2); - assert(sc_map_found(&map)); - assert(val == 2); + assert(val); + assert(*val == 2); sc_map_term_64(&map); } @@ -740,7 +741,7 @@ void test1() struct sc_map_str map; char *keys[128]; char *values[128]; - const char *key, *value; + const char *key, **value, *item; for (int i = 0; i < 128; i++) { keys[i] = str_random((rand() % 64) + 32); @@ -750,11 +751,11 @@ void test1() sc_map_init_str(&map, 0, 0); sc_map_put_str(&map, "100", "200"); value = sc_map_get_str(&map, "100"); - assert(strcmp(value, "200") == 0); + assert(strcmp(*value, "200") == 0); sc_map_term_str(&map); sc_map_put_str(&map, "100", "200"); value = sc_map_get_str(&map, "100"); - assert(strcmp(value, "200") == 0); + assert(strcmp(*value, "200") == 0); sc_map_term_str(&map); assert(!sc_map_init_str(&map, 0, -1)); @@ -767,7 +768,7 @@ void test1() sc_map_term_str(&map); assert(sc_map_init_str(&map, 0, 0)); - sc_map_foreach (&map, key, value) { + sc_map_foreach (&map, key, item) { assert(false); } @@ -775,7 +776,7 @@ void test1() assert(false); } - sc_map_foreach_value (&map, value) { + sc_map_foreach_value (&map, item) { assert(false); } @@ -783,29 +784,29 @@ void test1() sc_map_put_str(&map, "key", "value2"); value = sc_map_get_str(&map, "key"); - assert(sc_map_found(&map)); - assert(strcmp(value, "value2") == 0); + assert(value); + assert(strcmp(*value, "value2") == 0); value = sc_map_del_str(&map, "key"); - assert(sc_map_found(&map)); + assert(value); value = sc_map_get_str(&map, "key"); - assert(!sc_map_found(&map)); + assert(value == NULL); sc_map_put_str(&map, "key", "value3"); value = sc_map_del_str(&map, "key"); - assert(sc_map_found(&map)); - assert(strcmp(value, "value3") == 0); - key = sc_map_del_str(&map, "key"); - assert(!sc_map_found(&map)); + assert(value); + assert(strcmp(*value, "value3") == 0); + value = sc_map_del_str(&map, "key"); + assert(!value); sc_map_put_str(&map, "key", "value"); assert(sc_map_size_str(&map) == 1); sc_map_put_str(&map, NULL, "nullvalue"); assert(sc_map_size_str(&map) == 2); value = sc_map_get_str(&map, NULL); - assert(sc_map_found(&map)); - assert(strcmp(value, "nullvalue") == 0); + assert(value); + assert(strcmp(*value, "nullvalue") == 0); sc_map_del_str(&map, NULL); - assert(sc_map_found(&map)); + assert(value); assert(sc_map_size_str(&map) == 1); sc_map_clear_str(&map); @@ -817,8 +818,8 @@ void test1() for (int i = 0; i < 100; i++) { value = sc_map_get_str(&map, keys[i]); - assert(sc_map_found(&map)); - assert(strcmp(value, values[i]) == 0); + assert(value); + assert(strcmp(*value, values[i]) == 0); } sc_map_put_str(&map, keys[0], values[101]); @@ -834,8 +835,8 @@ void test1() for (int i = 0; i < 100; i++) { value = sc_map_get_str(&map, keys[i]); - assert(sc_map_found(&map)); - assert(strcmp(value, values[i]) == 0); + assert(value); + assert(strcmp(*value, values[i]) == 0); } sc_map_term_str(&map); @@ -846,11 +847,11 @@ void test1() } bool found; - sc_map_foreach (&map, key, value) { + sc_map_foreach (&map, key, item) { found = false; for (int j = 0; j < 100; j++) { if (strcmp(key, keys[j]) == 0 && - strcmp(value, values[j]) == 0) { + strcmp(item, values[j]) == 0) { found = true; break; } @@ -869,10 +870,10 @@ void test1() assert(found); } - sc_map_foreach_value (&map, value) { + sc_map_foreach_value (&map, item) { found = false; for (int j = 0; j < 100; j++) { - if (strcmp(value, values[j]) == 0) { + if (strcmp(item, values[j]) == 0) { found = true; break; } @@ -892,7 +893,8 @@ void test2() struct sc_map_32 map; uint32_t keys[128]; uint32_t values[128]; - uint32_t key, value; + uint32_t *value; + uint32_t key, item; uint32_t random; for (int i = 0; i < 128; i++) { @@ -917,13 +919,13 @@ retry: for (int i = 0; i < 100; i++) { sc_map_put_32(&map, keys[i], values[i]); value = sc_map_get_32(&map, keys[i]); - assert(sc_map_found(&map)); - assert(value == values[i]); + assert(value); + assert(*value == values[i]); sc_map_put_32(&map, keys[i], values[i]); value = sc_map_del_32(&map, keys[i]); - assert(sc_map_found(&map)); - assert(value == values[i]); + assert(value); + assert(*value == values[i]); } for (int i = 0; i < 128; i++) { @@ -933,10 +935,10 @@ retry: assert(sc_map_size_32(&map) == 128); bool found; - sc_map_foreach (&map, key, value) { + sc_map_foreach (&map, key, item) { found = false; for (int j = 0; j < 128; j++) { - if (key == keys[j] && value == values[j]) { + if (key == keys[j] && item == values[j]) { found = true; break; } @@ -955,10 +957,10 @@ retry: assert(found); } - sc_map_foreach_value (&map, value) { + sc_map_foreach_value (&map, item) { found = false; for (int j = 0; j < 128; j++) { - if (value == values[j]) { + if (item == values[j]) { found = true; break; } @@ -974,7 +976,7 @@ void test3() struct sc_map_64 map; uint64_t keys[128]; uint64_t values[128]; - uint64_t key, value; + uint64_t key, item, *value; uint32_t random; for (int i = 0; i < 128; i++) { @@ -999,13 +1001,13 @@ retry: for (int i = 0; i < 100; i++) { sc_map_put_64(&map, keys[i], values[i]); value = sc_map_get_64(&map, keys[i]); - assert(sc_map_found(&map)); - assert(value == values[i]); + assert(value); + assert(*value == values[i]); sc_map_put_64(&map, keys[i], values[i]); value = sc_map_del_64(&map, keys[i]); - assert(sc_map_found(&map)); - assert(value == values[i]); + assert(value); + assert(*value == values[i]); } for (int i = 0; i < 128; i++) { @@ -1015,10 +1017,10 @@ retry: assert(sc_map_size_64(&map) == 128); bool found; - sc_map_foreach (&map, key, value) { + sc_map_foreach (&map, key, item) { found = false; for (int j = 0; j < 128; j++) { - if (key == keys[j] && value == values[j]) { + if (key == keys[j] && item == values[j]) { found = true; break; } @@ -1037,10 +1039,10 @@ retry: assert(found); } - sc_map_foreach_value (&map, value) { + sc_map_foreach_value (&map, item) { found = false; for (int j = 0; j < 128; j++) { - if (value == values[j]) { + if (item == values[j]) { found = true; break; } @@ -1053,21 +1055,21 @@ retry: void test4() { - const char *c; + const char **c; struct sc_map_64s map64s; assert(sc_map_init_64s(&map64s, 1, 87)); for (int i = 0; i < 100; i++) { sc_map_put_64s(&map64s, i, NULL); c = sc_map_get_64s(&map64s, i); - assert(sc_map_found(&map64s)); - assert(c == NULL); + assert(c != NULL); + assert(*c == NULL); } assert(sc_map_size_64s(&map64s) == 100); for (int i = 0; i < 100; i++) { c = sc_map_del_64s(&map64s, i); - assert(sc_map_found(&map64s)); - assert(c == NULL); + assert(c != NULL); + assert(*c == NULL); } assert(sc_map_size_64s(&map64s) == 0); sc_map_put_64s(&map64s, 3, NULL); @@ -1077,21 +1079,21 @@ void test4() sc_map_term_64s(&map64s); - const char *v; + void **v; struct sc_map_64v map64v; assert(sc_map_init_64v(&map64v, 1, 87)); for (int i = 0; i < 100; i++) { sc_map_put_64v(&map64v, i, NULL); v = sc_map_get_64v(&map64v, i); - assert(sc_map_found(&map64v)); - assert(v == NULL); + assert(v); + assert(*v == NULL); } assert(sc_map_size_64v(&map64v) == 100); for (int i = 0; i < 100; i++) { v = sc_map_del_64v(&map64v, i); - assert(sc_map_found(&map64v)); - assert(v == NULL); + assert(v); + assert(*v == NULL); } assert(sc_map_size_64v(&map64v) == 0); sc_map_put_64v(&map64v, 3, NULL); @@ -1110,19 +1112,20 @@ void test4() } struct sc_map_str mapstr; + const char **t; + assert(sc_map_init_str(&mapstr, 0, 26)); for (int i = 0; i < 64; i++) { sc_map_put_str(&mapstr, keys[i], (void *) (uintptr_t) i); } - v = sc_map_get_str(&mapstr, keys[0]); - assert(sc_map_found(&mapstr)); - assert(v == 0); + t = sc_map_get_str(&mapstr, keys[0]); + assert(t); + assert(*t == 0); assert(sc_map_size_str(&mapstr) == 64); - v = sc_map_del_str(&mapstr, keys[12]); - assert(sc_map_found(&mapstr)); - assert(v == (void *) 12); + t = sc_map_del_str(&mapstr, keys[12]); + assert(*t == (void *) 12); assert(sc_map_size_str(&mapstr) == 63); sc_map_clear_str(&mapstr); sc_map_term_str(&mapstr); @@ -1132,19 +1135,18 @@ void test4() for (int i = 0; i < 64; i++) { sc_map_put_sv(&mapsv, keys[i], (void *) (uintptr_t) i); } + v = sc_map_get_sv(&mapsv, keys[0]); - assert(sc_map_found(&mapsv)); - assert(v == 0); + assert(*v == 0); assert(sc_map_size_sv(&mapsv) == 64); v = sc_map_del_sv(&mapsv, keys[12]); - assert(sc_map_found(&mapsv)); - assert(v == (void *) 12); + assert(*v == (void *) 12); assert(sc_map_size_sv(&mapsv) == 63); sc_map_clear_sv(&mapsv); sc_map_term_sv(&mapsv); - uint64_t val; + uint64_t *val; struct sc_map_s64 maps64; assert(sc_map_init_s64(&maps64, 0, 26)); @@ -1153,13 +1155,11 @@ void test4() } val = sc_map_get_s64(&maps64, keys[0]); - assert(sc_map_found(&maps64)); - assert(val == 0); + assert(*val == 0); assert(sc_map_size_s64(&maps64) == 64); val = sc_map_del_s64(&maps64, keys[12]); - assert(sc_map_found(&maps64)); - assert(val == 12); + assert(*val == 12); assert(sc_map_size_s64(&maps64) == 63); sc_map_clear_s64(&maps64); sc_map_term_s64(&maps64); @@ -1208,7 +1208,7 @@ static void test5() static void test6() { const int count = 120000; - uint32_t val; + uint32_t *val; struct sc_map_32 map; srand(time(NULL)); @@ -1227,8 +1227,8 @@ static void test6() if (i % 7 == 0 || i % 17 == 0 || i % 79 == 0) { val = sc_map_del_32(&map, keys[i]); - assert(sc_map_found(&map)); - assert(val == values[i]); + assert(val); + assert(*val == values[i]); } } @@ -1238,8 +1238,7 @@ static void test6() } val = sc_map_get_32(&map, keys[i]); - assert(sc_map_found(&map)); - assert(val == values[i]); + assert(*val == values[i]); } sc_map_term_32(&map); @@ -1248,6 +1247,64 @@ static void test6() free(values); } +void test7() +{ + uint64_t key, value, *ret; + struct sc_map_64 map; + + sc_map_init_64(&map, 0, 0); + + sc_map_foreach (&map, key, value) { + assert(true); + } + + sc_map_foreach_key (&map, key) { + assert(true); + } + + sc_map_foreach_value (&map, value) { + (void) value; + assert(true); + } + + for (uint64_t i = 0; i < 100; i++) { + ret = sc_map_get_64(&map, i); + assert(ret == NULL); + sc_map_put_64(&map, i, i); + } + + for (uint64_t i = 0; i < 100; i++) { + ret = sc_map_get_64(&map, i); + *ret = i * 10; + } + + for (uint64_t i = 0; i < 100; i++) { + ret = sc_map_get_64(&map, i); + assert(*ret == i * 10); + } + + for (uint64_t i = 0; i < 100; i++) { + ret = sc_map_del_64(&map, i); + assert(*ret == i * 10); + } + + assert(sc_map_size_64(&map) == 0); + + sc_map_foreach (&map, key, value) { + assert(true); + } + + sc_map_foreach_key (&map, key) { + assert(true); + } + + sc_map_foreach_value (&map, value) { + assert(true); + } + + sc_map_term_64(&map); +} + #ifdef SC_HAVE_WRAP bool fail_calloc = false; @@ -1263,6 +1320,7 @@ void *__wrap_calloc(size_t n, size_t size) void fail_test_32() { + bool ret; struct sc_map_32 map; fail_calloc = true; @@ -1273,16 +1331,16 @@ void fail_test_32() fail_calloc = true; for (int i = 0; i < 20; i++) { - sc_map_put_32(&map, i, i); + ret = sc_map_put_32(&map, i, i); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_put_32(&map, 44444, 44444); for (size_t i = 0; i < SC_MAP_MAX; i++) { - sc_map_put_32(&map, i, i); + ret = sc_map_put_32(&map, i, i); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_term_32(&map); @@ -1290,6 +1348,7 @@ void fail_test_32() void fail_test_64() { + bool ret; struct sc_map_64 map; fail_calloc = true; @@ -1300,16 +1359,16 @@ void fail_test_64() fail_calloc = true; for (int i = 0; i < 20; i++) { - sc_map_put_64(&map, i, i); + ret = sc_map_put_64(&map, i, i); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_put_64(&map, 44444, 44444); for (size_t i = 0; i < SC_MAP_MAX; i++) { - sc_map_put_64(&map, i, i); + ret = sc_map_put_64(&map, i, i); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_term_64(&map); @@ -1317,6 +1376,7 @@ void fail_test_64() void fail_test_64v() { + bool ret; struct sc_map_64v map; fail_calloc = true; @@ -1327,16 +1387,16 @@ void fail_test_64v() fail_calloc = true; for (int i = 0; i < 20; i++) { - sc_map_put_64v(&map, i, NULL); + ret = sc_map_put_64v(&map, i, NULL); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_put_64v(&map, 44444, NULL); for (size_t i = 0; i < SC_MAP_MAX; i++) { - sc_map_put_64v(&map, i, NULL); + ret = sc_map_put_64v(&map, i, NULL); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_term_64v(&map); @@ -1344,6 +1404,7 @@ void fail_test_64v() void fail_test_64s() { + bool ret; struct sc_map_64s map; fail_calloc = true; @@ -1354,16 +1415,16 @@ void fail_test_64s() fail_calloc = true; for (int i = 0; i < 20; i++) { - sc_map_put_64s(&map, i, NULL); + ret = sc_map_put_64s(&map, i, NULL); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_put_64s(&map, 44444, NULL); for (size_t i = 0; i < SC_MAP_MAX; i++) { - sc_map_put_64s(&map, i, NULL); + ret = sc_map_put_64s(&map, i, NULL); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_term_64s(&map); @@ -1371,6 +1432,7 @@ void fail_test_64s() void fail_test_str() { + bool ret; struct sc_map_str map; const char *v; const char *s = "abcdefghijklmnoprstuvyz10111213141516"; @@ -1383,9 +1445,9 @@ void fail_test_str() fail_calloc = true; for (int i = 0; i < 20; i++) { - sc_map_put_str(&map, &s[i], NULL); + ret = sc_map_put_str(&map, &s[i], NULL); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_put_str(&map, &s[21], NULL); sc_map_clear_str(&map); @@ -1393,13 +1455,13 @@ void fail_test_str() for (size_t i = 0; i < SC_MAP_MAX; i++) { char *c = str_random(32); - sc_map_put_str(&map, c, NULL); - if (sc_map_oom(&map)) { + ret = sc_map_put_str(&map, c, NULL); + if (!ret) { free(c); break; } } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_foreach_key (&map, v) { @@ -1411,6 +1473,7 @@ void fail_test_str() void fail_test_sv() { + bool ret; struct sc_map_sv map; const char *v; const char *s = "abcdefghijklmnoprstuvyz10111213141516"; @@ -1423,22 +1486,22 @@ void fail_test_sv() fail_calloc = true; for (int i = 0; i < 20; i++) { - sc_map_put_sv(&map, &s[i], NULL); + ret = sc_map_put_sv(&map, &s[i], NULL); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_put_sv(&map, &s[21], NULL); sc_map_clear_sv(&map); for (size_t i = 0; i < SC_MAP_MAX; i++) { char *c = str_random(32); - sc_map_put_sv(&map, c, NULL); - if (sc_map_oom(&map)) { + ret = sc_map_put_sv(&map, c, NULL); + if (!ret) { free(c); break; } } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_foreach_key (&map, v) { @@ -1450,6 +1513,7 @@ void fail_test_sv() void fail_test_s64() { + bool ret; struct sc_map_s64 map; const char *v; const char *s = "abcdefghijklmnoprstuvyz10111213141516"; @@ -1462,22 +1526,22 @@ void fail_test_s64() fail_calloc = true; for (int i = 0; i < 20; i++) { - sc_map_put_s64(&map, &s[i], 0); + ret = sc_map_put_s64(&map, &s[i], 0); } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_put_s64(&map, &s[21], 0); sc_map_clear_s64(&map); for (size_t i = 0; i < SC_MAP_MAX; i++) { char *c = str_random(32); - sc_map_put_s64(&map, c, 0); - if (sc_map_oom(&map)) { + ret = sc_map_put_s64(&map, c, 0); + if (!ret) { free(c); break; } } - assert(sc_map_oom(&map)); + assert(!ret); fail_calloc = false; sc_map_foreach_key (&map, v) { @@ -1529,6 +1593,7 @@ int main() test4(); test5(); test6(); + test7(); test_32(); test_64(); test_64s(); diff --git a/map/sc_map.c b/map/sc_map.c index ede65e1..b20272c 100644 --- a/map/sc_map.c +++ b/map/sc_map.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_map.h" @@ -205,26 +212,20 @@ return true; \ } \ \ - V sc_map_put_##name(struct sc_map_##name *m, K key, V value) \ + bool sc_map_put_##name(struct sc_map_##name *m, K key, V value) \ { \ - V ret; \ uint32_t pos, mod, h; \ \ - m->oom = false; \ - \ if (!sc_map_remap_##name(m)) { \ - m->oom = true; \ - return 0; \ + return false; \ } \ \ if (key == 0) { \ - ret = (m->used) ? m->mem[-1].value : 0; \ - m->found = m->used; \ m->size += !m->used; \ m->used = true; \ m->mem[-1].value = value; \ \ - return ret; \ + return true; \ } \ \ mod = m->cap - 1; \ @@ -239,23 +240,20 @@ continue; \ } \ \ - m->found = m->mem[pos].key != 0; \ - ret = m->found ? m->mem[pos].value : 0; \ sc_map_assign_##name(&m->mem[pos], key, value, h); \ \ - return ret; \ + return true; \ } \ } \ \ /** NOLINTNEXTLINE */ \ - V sc_map_get_##name(struct sc_map_##name *m, K key) \ + V *sc_map_get_##name(struct sc_map_##name *m, K key) \ { \ const uint32_t mod = m->cap - 1; \ uint32_t h, pos; \ \ if (key == 0) { \ - m->found = m->used; \ - return m->used ? m->mem[-1].value : 0; \ + return m->used ? &m->mem[-1].value : NULL; \ } \ \ h = hash_fn(key); \ @@ -263,31 +261,30 @@ \ while (true) { \ if (m->mem[pos].key == 0) { \ - m->found = false; \ - return 0; \ + return NULL; \ } else if (!sc_map_cmp_##name(&m->mem[pos], key, h)) { \ pos = (pos + 1) & (mod); \ continue; \ } \ \ - m->found = true; \ - return m->mem[pos].value; \ + return &m->mem[pos].value; \ } \ } \ \ /** NOLINTNEXTLINE */ \ - V sc_map_del_##name(struct sc_map_##name *m, K key) \ + V *sc_map_del_##name(struct sc_map_##name *m, K key) \ { \ const uint32_t mod = m->cap - 1; \ uint32_t pos, prev, it, p, h; \ - V ret; \ + V *ret; /* NOLINT */ \ \ if (key == 0) { \ - m->found = m->used; \ + m->deleted = m->mem[-1].value; \ + ret = m->used ? &m->deleted : NULL; \ m->size -= m->used; \ m->used = false; \ \ - return m->found ? m->mem[-1].value : 0; \ + return ret; \ } \ \ h = hash_fn(key); \ @@ -295,16 +292,13 @@ \ while (true) { \ if (m->mem[pos].key == 0) { \ - m->found = false; \ - return 0; \ + return NULL; \ } else if (!sc_map_cmp_##name(&m->mem[pos], key, h)) { \ pos = (pos + 1) & (mod); \ continue; \ } \ \ - m->found = true; \ - ret = m->mem[pos].value; \ - \ + m->deleted = m->mem[pos].value; \ m->size--; \ m->mem[pos].key = 0; \ prev = pos; \ @@ -327,7 +321,7 @@ } \ } \ \ - return ret; \ + return &m->deleted; \ } \ } diff --git a/map/sc_map.h b/map/sc_map.h index ab368df..262a13a 100644 --- a/map/sc_map.h +++ b/map/sc_map.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_MAP_H @@ -65,16 +72,12 @@ uint32_t load_fac; \ uint32_t remap; \ bool used; \ - bool oom; \ - bool found; \ + V deleted; \ }; \ \ /** \ * Create map \ * \ - * struct sc_map_str map; \ - * sc_map_init_str(&map, 0, 0); \ - * \ * @param map map \ * @param cap initial capacity, zero is accepted \ * @param load_factor must be >25 and <95. Pass 0 for default value. \ @@ -88,9 +91,6 @@ /** \ * Destroy map. \ * \ - * struct sc_map_str map; \ - * sc_map_term_str(&map); \ - * \ * @param map map \ */ \ void sc_map_term_##name(struct sc_map_##name *map); \ @@ -98,9 +98,6 @@ /** \ * Get map element count \ * \ - * struct sc_map_str map; \ - * uint32_t count = sc_map_size_str(&map); \ - * \ * @param map map \ * @return element count \ */ \ @@ -109,9 +106,6 @@ /** \ * Clear map \ * \ - * struct sc_map_str map; \ - * sc_map_clear_str(&map); \ - * \ * @param map map \ */ \ void sc_map_clear_##name(struct sc_map_##name *map); \ @@ -119,67 +113,41 @@ /** \ * Put element to the map \ * \ - * struct sc_map_str map; \ - * sc_map_put_str(&map, "key", "value"); \ - * \ * @param map map \ * @param K key \ * @param V value \ - * @return previous value if exists \ + * @return 'false' on out of memory, otherwise 'true' \ */ \ - V sc_map_put_##name(struct sc_map_##name *map, K key, V val); \ + bool sc_map_put_##name(struct sc_map_##name *map, K key, V val); \ \ /** \ * Get element \ * \ - * bool found; \ - * char *value; \ - * struct sc_map_str map; \ - * \ - * found = sc_map_get_str(&map, "key", &value); \ - * \ * @param map map \ - * @param K key \ - * @param V pointer to put value, if key is missing, value is \ - * undefined \ - * @return 'true' if key exists, 'false' otherwise \ + * @param K key \ + * @return - pointer to current value if exists \ + * (pointer is valid until next map operation). \ + * - NULL if key does not exist \ */ \ /** NOLINTNEXTLINE */ \ - V sc_map_get_##name(struct sc_map_##name *map, K key); \ + V *sc_map_get_##name(struct sc_map_##name *map, K key); \ \ /** \ * Delete element \ * \ - * bool found; \ - * char *value; \ - * struct sc_map_str map; \ - * \ - * found = sc_map_del_str(&map, "key", &value); \ - * \ * @param map map \ - * @param K key \ - * @return current value if exists \ + * @param K key \ + * @return - pointer to current value if exists \ + * (pointer is valid until next map operation). \ + * - NULL if key does not exist \ */ \ /** NOLINTNEXTLINE */ \ - V sc_map_del_##name(struct sc_map_##name *map, K key); - -/** - * @param map map - * @return - if put operation overrides a value, returns true - * - if del operation deletes a key, returns true - */ -#define sc_map_found(map) ((map)->found) - -/** - * @param map map - * @return true if put operation failed with out of memory - */ -#define sc_map_oom(map) ((map)->oom) + V *sc_map_del_##name(struct sc_map_##name *map, K key); /** * Foreach loop * - * char *key, *value; + * const char *key, *value; * struct sc_map_str map; * * sc_map_foreach(&map, key, value) { @@ -195,7 +163,7 @@ /** * Foreach loop for keys * - * char *key; + * const char *key; * struct sc_map_str map; * * sc_map_foreach_key(&map, key) { @@ -210,7 +178,7 @@ /** * Foreach loop for values * - * char *value; + * const char *value; * struct sc_map_str map; * * sc_map_foreach_value(&map, value) { diff --git a/memory-map/sc_mmap.c b/memory-map/sc_mmap.c index c17c865..9a9f2da 100644 --- a/memory-map/sc_mmap.c +++ b/memory-map/sc_mmap.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef _XOPEN_SOURCE diff --git a/memory-map/sc_mmap.h b/memory-map/sc_mmap.h index 726a585..7006455 100644 --- a/memory-map/sc_mmap.h +++ b/memory-map/sc_mmap.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_MMAP_H diff --git a/mutex/mutex_test.c b/mutex/mutex_test.c index c61c23e..90ee87a 100644 --- a/mutex/mutex_test.c +++ b/mutex/mutex_test.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_mutex.h" diff --git a/mutex/sc_mutex.c b/mutex/sc_mutex.c index 19f9675..dcae5eb 100644 --- a/mutex/sc_mutex.c +++ b/mutex/sc_mutex.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 700 diff --git a/mutex/sc_mutex.h b/mutex/sc_mutex.h index fa900b2..8e440aa 100644 --- a/mutex/sc_mutex.h +++ b/mutex/sc_mutex.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_MUTEX_H diff --git a/option/sc_option.c b/option/sc_option.c index 89f4bab..58ccf50 100644 --- a/option/sc_option.c +++ b/option/sc_option.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_option.h" diff --git a/option/sc_option.h b/option/sc_option.h index 362f3ba..4b14e46 100644 --- a/option/sc_option.h +++ b/option/sc_option.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_OPTION_H #define SC_OPTION_H diff --git a/perf/sc_perf.c b/perf/sc_perf.c index f9409c9..29ba375 100644 --- a/perf/sc_perf.c +++ b/perf/sc_perf.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef _GNU_SOURCE diff --git a/perf/sc_perf.h b/perf/sc_perf.h index 1b6dd7e..98bde5a 100644 --- a/perf/sc_perf.h +++ b/perf/sc_perf.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_PERF_H diff --git a/queue/queue_example.c b/queue/queue_example.c index aab811d..0ae6148 100644 --- a/queue/queue_example.c +++ b/queue/queue_example.c @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) sc_queue_foreach (&queue, elem) { printf("elem = [%d] \n", elem); - } + } elem = sc_queue_del_last(&queue); printf("Last element was : [%d] \n", elem); diff --git a/queue/sc_queue.h b/queue/sc_queue.h index de3c0ea..fbd727c 100644 --- a/queue/sc_queue.h +++ b/queue/sc_queue.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_QUEUE_H diff --git a/sc/sc.c b/sc/sc.c index 84ebce2..5ca9420 100644 --- a/sc/sc.c +++ b/sc/sc.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc.h" diff --git a/sc/sc.h b/sc/sc.h index 878b7d9..fd13f22 100644 --- a/sc/sc.h +++ b/sc/sc.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_H #define SC_H diff --git a/signal/sc_signal.c b/signal/sc_signal.c index c3df71b..4b5f879 100644 --- a/signal/sc_signal.c +++ b/signal/sc_signal.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef _GNU_SOURCE @@ -486,7 +493,6 @@ int sc_signal_init() #ifdef SC_SIGNAL_TEST rc &= (sigaction(SIGUSR2, &action, NULL) == 0); #endif - rc &= (sigemptyset(&action.sa_mask) == 0); action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO; action.sa_sigaction = sc_signal_on_fatal; diff --git a/signal/sc_signal.h b/signal/sc_signal.h index f073c1c..b6ad854 100644 --- a/signal/sc_signal.h +++ b/signal/sc_signal.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_SIGNAL_H diff --git a/socket/sc_sock.c b/socket/sc_sock.c index c1e7dc4..aececec 100644 --- a/socket/sc_sock.c +++ b/socket/sc_sock.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef _XOPEN_SOURCE @@ -274,7 +281,7 @@ int sc_sock_set_rcvtimeo(struct sc_sock *s, int ms) sc_sock_errstr(s, 0); } - return rc == 0 ? SC_SOCK_OK : SC_SOCK_ERROR; + return rc; } int sc_sock_set_sndtimeo(struct sc_sock *s, int ms) @@ -294,7 +301,7 @@ int sc_sock_set_sndtimeo(struct sc_sock *s, int ms) sc_sock_errstr(s, 0); } - return rc == 0 ? SC_SOCK_OK : SC_SOCK_ERROR; + return rc; } static int sc_sock_bind_unix(struct sc_sock *s, const char *host) @@ -436,10 +443,10 @@ int sc_sock_finish_connect(struct sc_sock *s) rc = getsockopt(s->fdt.fd, SOL_SOCKET, SO_ERROR, (void *) &ret, &len); if (rc != 0 || ret != 0) { sc_sock_errstr(s, 0); - return SC_SOCK_ERROR; + return -1; } - return SC_SOCK_OK; + return 0; } static int sc_sock_connect_unix(struct sc_sock *s, const char *addr) @@ -483,13 +490,13 @@ static int sc_sock_connect_unix(struct sc_sock *s, const char *addr) goto err; } - return SC_SOCK_OK; + return 0; err: sc_sock_errstr(s, 0); sc_sock_close(s); - return SC_SOCK_ERROR; + return -1; } static int sc_sock_bind_src(struct sc_sock *s, const char *addr, @@ -520,14 +527,14 @@ static int sc_sock_bind_src(struct sc_sock *s, const char *addr, goto err; } - return SC_SOCK_OK; + return 0; gai_err: sc_sock_errstr(s, rc); - return SC_SOCK_ERROR; + return -1; err: sc_sock_errstr(s, 0); - return SC_SOCK_ERROR; + return -1; } int sc_sock_connect(struct sc_sock *s, const char *dst_addr, @@ -536,7 +543,7 @@ int sc_sock_connect(struct sc_sock *s, const char *dst_addr, { const int bf = SC_SOCK_BUF_SIZE; - int rc, rv = SC_SOCK_OK; + int rc, rv = 0; sc_sock_int fd; void *tmp; struct addrinfo *sinfo = NULL, *p; @@ -595,7 +602,7 @@ int sc_sock_connect(struct sc_sock *s, const char *dst_addr, if (src_addr || src_port) { rc = sc_sock_bind_src(s, src_addr, src_port); - if (rc != SC_SOCK_OK) { + if (rc != 0) { goto bind_error; } } @@ -604,7 +611,8 @@ int sc_sock_connect(struct sc_sock *s, const char *dst_addr, if (rc != 0) { if (!s->blocking && (sc_sock_err() == SC_EINPROGRESS || sc_sock_err() == SC_EAGAIN)) { - rv = SC_SOCK_WANT_WRITE; + errno = EAGAIN; + rv = -1; goto end; } @@ -643,11 +651,12 @@ retry: } if (err == SC_EAGAIN) { - return SC_SOCK_WANT_WRITE; + errno = EAGAIN; + return -1; } sc_sock_errstr(s, 0); - n = SC_SOCK_ERROR; + n = -1; } return n; @@ -664,7 +673,8 @@ int sc_sock_recv(struct sc_sock *s, char *buf, int len, int flags) retry: n = (int) recv(s->fdt.fd, buf, (size_t) len, flags); if (n == 0) { - return SC_SOCK_ERROR; + errno = EOF; + return -1; } else if (n == SC_ERR) { err = sc_sock_err(); if (err == SC_EINTR) { @@ -672,11 +682,12 @@ retry: } if (err == SC_EAGAIN) { - return SC_SOCK_WANT_READ; + errno = EAGAIN; + return -1; } sc_sock_errstr(s, 0); - n = SC_SOCK_ERROR; + n = -1; } return n; @@ -694,7 +705,7 @@ int sc_sock_accept(struct sc_sock *s, struct sc_sock *in) fd = accept(s->fdt.fd, NULL, NULL); if (fd == SC_INVALID) { sc_sock_errstr(s, 0); - return SC_SOCK_ERROR; + return -1; } in->fdt.fd = fd; @@ -723,13 +734,13 @@ int sc_sock_accept(struct sc_sock *s, struct sc_sock *in) goto error; } - return SC_SOCK_OK; + return 0; error: sc_sock_errstr(s, 0); sc_sock_close(in); - return SC_SOCK_ERROR; + return -1; } int sc_sock_listen(struct sc_sock *s, const char *host, const char *port) @@ -746,11 +757,11 @@ int sc_sock_listen(struct sc_sock *s, const char *host, const char *port) goto err; } - return SC_SOCK_OK; + return 0; err: sc_sock_errstr(s, 0); sc_sock_close(s); - return SC_SOCK_ERROR; + return -1; } const char *sc_sock_error(struct sc_sock *s) @@ -1196,7 +1207,7 @@ int sc_sock_poll_add(struct sc_sock_poll *p, struct sc_sock_fd *fdt, }; if ((fdt->op & events) == events) { - return SC_SOCK_OK; + return 0; } if (fdt->op == SC_SOCK_NONE) { diff --git a/socket/sc_sock.h b/socket/sc_sock.h index 7de6902..c440d09 100644 --- a/socket/sc_sock.h +++ b/socket/sc_sock.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_SOCK_H #define SC_SOCK_H @@ -55,14 +62,6 @@ typedef int sc_sock_int; #define SC_SOCK_BUF_SIZE 32768 -enum sc_sock_rc -{ - SC_SOCK_WANT_READ = -4, - SC_SOCK_WANT_WRITE = -2, - SC_SOCK_ERROR = -1, - SC_SOCK_OK = 0 -}; - enum sc_sock_ev { SC_SOCK_NONE = 0u, diff --git a/socket/sock_test.c b/socket/sock_test.c index afa649f..084bb66 100644 --- a/socket/sock_test.c +++ b/socket/sock_test.c @@ -381,7 +381,7 @@ void test1() sc_sock_init(&client, 0, false, SC_SOCK_INET); rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc != SC_SOCK_ERROR); + assert(rc != -1 || (rc == -1 && errno == EAGAIN)); sleep(2); rc = sc_sock_accept(&sock, &in); @@ -1179,7 +1179,7 @@ void sock_fail_test2() assert(sc_sock_listen(&sock, "127.0.0.1", "8080") == 0); sc_sock_init(&client, 0, false, SC_SOCK_INET); rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc != SC_SOCK_ERROR); + assert(rc != -1 || (rc == -1 && errno == EAGAIN)); sleep(2); fail_fcntl = 1; assert(sc_sock_accept(&sock, &in) == -1); @@ -1192,7 +1192,7 @@ void sock_fail_test2() assert(sc_sock_listen(&sock, "127.0.0.1", "8080") == 0); sc_sock_init(&client, 0, false, SC_SOCK_INET); rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc != SC_SOCK_ERROR); + assert(rc != -1 || (rc == -1 && errno == EAGAIN)); sleep(2); fail_setsockopt = 1; assert(sc_sock_accept(&sock, &in) == -1); @@ -1205,7 +1205,7 @@ void sock_fail_test2() assert(sc_sock_listen(&sock, "127.0.0.1", "8080") == 0); sc_sock_init(&client, 0, false, SC_SOCK_INET); rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc != SC_SOCK_ERROR); + assert(rc != -1 || (rc == -1 && errno == EAGAIN)); sleep(2); fail_setsockopt = 2; assert(sc_sock_accept(&sock, &in) == -1); @@ -1218,7 +1218,7 @@ void sock_fail_test2() assert(sc_sock_listen(&sock, "127.0.0.1", "8080") == 0); sc_sock_init(&client, 0, false, SC_SOCK_INET); rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc != SC_SOCK_ERROR); + assert(rc != -1 || (rc == -1 && errno == EAGAIN)); sleep(2); fail_setsockopt = 3; assert(sc_sock_accept(&sock, &in) == -1); @@ -1232,7 +1232,7 @@ void sock_fail_test2() sc_sock_init(&client, 0, false, SC_SOCK_UNIX); fail_setsockopt = 1; rc = sc_sock_connect(&client, "/tmp/x", "8080", NULL, NULL); - assert(rc == SC_SOCK_ERROR); + assert(rc != -1 || (rc == -1 && errno == EAGAIN)); fail_setsockopt = INT32_MAX; assert(sc_sock_term(&sock) == 0); assert(sc_sock_term(&client) == 0); @@ -1243,7 +1243,7 @@ void sock_fail_test2() sc_sock_init(&client, 0, false, SC_SOCK_UNIX); fail_setsockopt = 2; rc = sc_sock_connect(&client, "/tmp/x", "8080", NULL, NULL); - assert(rc == SC_SOCK_ERROR); + assert(rc != -1 || (rc == -1 && errno == EAGAIN)); fail_setsockopt = INT32_MAX; assert(sc_sock_term(&sock) == 0); assert(sc_sock_term(&client) == 0); @@ -1252,28 +1252,28 @@ void sock_fail_test2() sc_sock_init(&client, 0, false, SC_SOCK_INET); fail_setsockopt = 1; rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc == SC_SOCK_ERROR); + assert(rc == -1); fail_setsockopt = INT32_MAX; assert(sc_sock_term(&client) == 0); sc_sock_init(&client, 0, false, SC_SOCK_INET); fail_setsockopt = 2; rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc == SC_SOCK_ERROR); + assert(rc == -1); fail_setsockopt = INT32_MAX; assert(sc_sock_term(&client) == 0); sc_sock_init(&client, 0, false, SC_SOCK_INET); fail_setsockopt = 3; rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc == SC_SOCK_ERROR); + assert(rc == -1); fail_setsockopt = INT32_MAX; assert(sc_sock_term(&client) == 0); sc_sock_init(&client, 0, false, SC_SOCK_INET); fail_setsockopt = 4; rc = sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL); - assert(rc == SC_SOCK_ERROR); + assert(rc == -1); fail_setsockopt = INT32_MAX; assert(sc_sock_term(&client) == 0); @@ -1308,14 +1308,15 @@ void sock_fail_test3() fail_send = 1; fail_send_errno = EAGAIN; fail_send_err = -1; - assert(sc_sock_send(&client, NULL, 10, 0) == SC_SOCK_WANT_WRITE); + assert(sc_sock_send(&client, NULL, 10, 0) == -1); + assert(errno == EAGAIN); sc_sock_term(&client); sc_sock_init(&client, 0, false, SC_SOCK_INET); fail_send = 1; fail_send_err = -1; fail_send_errno = EINTR; - assert(sc_sock_send(&client, NULL, 10, 0) == SC_SOCK_ERROR); + assert(sc_sock_send(&client, NULL, 10, 0) == -1); sc_sock_term(&client); fail_send = INT32_MAX; @@ -1326,14 +1327,15 @@ void sock_fail_test3() fail_recv = 1; fail_recv_errno = EAGAIN; fail_recv_err = -1; - assert(sc_sock_recv(&client, NULL, 10, 0) == SC_SOCK_WANT_READ); + assert(sc_sock_recv(&client, NULL, 10, 0) == -1); + assert(errno == EAGAIN); sc_sock_term(&client); sc_sock_init(&client, 0, false, SC_SOCK_INET); fail_recv = 1; fail_recv_err = -1; fail_recv_errno = EINTR; - assert(sc_sock_recv(&client, NULL, 10, 0) == SC_SOCK_ERROR); + assert(sc_sock_recv(&client, NULL, 10, 0) == -1); sc_sock_term(&client); fail_recv = INT32_MAX; @@ -1343,8 +1345,9 @@ void sock_fail_test3() sc_sock_init(&client, 0, false, SC_SOCK_INET); fail_connect_err = EINPROGRESS; fail_connect = -1; - assert(sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL) == - SC_SOCK_WANT_WRITE); + assert(sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL) == -1); + assert(errno == EAGAIN); + fail_connect_err = 0; fail_connect = 0; assert(sc_sock_term(&client) == 0); @@ -1360,8 +1363,9 @@ void sock_fail_test3() sc_sock_init(&client, 0, false, SC_SOCK_INET); fail_connect_err = EAGAIN; fail_connect = -1; - assert(sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL) == - SC_SOCK_WANT_WRITE); + assert(sc_sock_connect(&client, "127.0.0.1", "8080", NULL, NULL) ==-1); + assert(errno == EAGAIN); + fail_connect_err = 0; fail_connect = 0; assert(sc_sock_term(&client) == 0); diff --git a/string/sc_str.c b/string/sc_str.c index 1a478bc..2e6edf1 100644 --- a/string/sc_str.c +++ b/string/sc_str.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_str.h" diff --git a/string/sc_str.h b/string/sc_str.h index 5fa5ac9..7f0da6e 100644 --- a/string/sc_str.h +++ b/string/sc_str.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_STR_H diff --git a/thread/sc_thread.c b/thread/sc_thread.c index 595c7bf..cc078cf 100644 --- a/thread/sc_thread.c +++ b/thread/sc_thread.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_thread.h" diff --git a/thread/sc_thread.h b/thread/sc_thread.h index b9a83d2..eb82b60 100644 --- a/thread/sc_thread.h +++ b/thread/sc_thread.h @@ -1,26 +1,34 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ + #ifndef SC_THREAD_H #define SC_THREAD_H diff --git a/time/sc_time.c b/time/sc_time.c index 11951c8..7314539 100644 --- a/time/sc_time.c +++ b/time/sc_time.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 700 diff --git a/time/sc_time.h b/time/sc_time.h index ca5de38..2219863 100644 --- a/time/sc_time.h +++ b/time/sc_time.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_TIME_H #define SC_TIME_H diff --git a/timer/sc_timer.c b/timer/sc_timer.c index 7f30b07..4cec146 100644 --- a/timer/sc_timer.c +++ b/timer/sc_timer.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_timer.h" diff --git a/timer/sc_timer.h b/timer/sc_timer.h index c2e1b9a..8ecb0af 100644 --- a/timer/sc_timer.h +++ b/timer/sc_timer.h @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef SC_TIMER_H diff --git a/uri/sc_uri.c b/uri/sc_uri.c index 57d360b..09929f0 100644 --- a/uri/sc_uri.c +++ b/uri/sc_uri.c @@ -1,25 +1,32 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "sc_uri.h" diff --git a/uri/sc_uri.h b/uri/sc_uri.h index 1cc82ca..a8c4058 100644 --- a/uri/sc_uri.h +++ b/uri/sc_uri.h @@ -1,26 +1,34 @@ /* - * MIT License + * BSD-3-Clause * - * Copyright (c) 2021 Ozan Tezcan + * Copyright 2021 Ozan Tezcan + * All rights reserved. * - * 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: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * 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. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ + #ifndef SC_URI_H #define SC_URI_H