{"id":23465845,"url":"https://github.com/vokungahrotlaas/scplib","last_synced_at":"2025-04-12T16:55:24.953Z","repository":{"id":111506491,"uuid":"318216883","full_name":"VokunGahrotLaas/scplib","owner":"VokunGahrotLaas","description":"C multipurpose library (it's bad don't use it)","archived":false,"fork":false,"pushed_at":"2021-08-06T18:35:54.000Z","size":220,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-16T03:19:58.036Z","etag":null,"topics":["c","library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VokunGahrotLaas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-03T14:19:20.000Z","updated_at":"2021-12-09T01:05:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8022293-ee34-4106-9888-66350497f33a","html_url":"https://github.com/VokunGahrotLaas/scplib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VokunGahrotLaas%2Fscplib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VokunGahrotLaas%2Fscplib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VokunGahrotLaas%2Fscplib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VokunGahrotLaas%2Fscplib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VokunGahrotLaas","download_url":"https://codeload.github.com/VokunGahrotLaas/scplib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248601505,"owners_count":21131609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","library"],"created_at":"2024-12-24T11:40:04.154Z","updated_at":"2025-04-12T16:55:24.911Z","avatar_url":"https://github.com/VokunGahrotLaas.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scplib\nC multipurpose library. \\\nThis library only contains headers, no `.c` to compile. \\\nCompatible with stdc versions from c99 to c2X with flags like `-Wall -Wextra -Wconversion -Werror`. \\\nFor `-Wpedantic` you must define `SCP_PEPANTIC` (`-D` or `#define`) to disable some functionalities like lambdas. \\\n(if someone knows how to detect pedantic with the preprocessor directly, dm me please)\n\n## Credits\n* [Write A Hash Table](https://github.com/jamesroutley/write-a-hash-table) by [jamesroutley](https://github.com/jamesroutley/)\n\n## Makefile\n\n### Tests\nTests are located in the `tests/` folder and can be runned from the makefile with `make run_test_\u003cname\u003e`. \\\n(remove `run_` to just compile without running) \\\nTo enable pedantic mode use `make run_strict_test_\u003cname\u003e`. \\\nTo run all tests (not advised) use `make run_tests` or `make run_strict_tests` \\\nTo clean all compiled tests use `make mrproper`.\n\n### Installation\nRun `make install` as root, it will copy the `scp/` folder in your `/usr/includes/`. \\\nAs said in the intro no `.c` to compile, this is a header only library. \\\nFor this reason you must define SCP_IMPLEMENTATION in __one and only one__ of the translation units (usualy the main.c file). \\\nYou can thus include the lib directly as follows:\n```c\n#define SCP_IMPLEMENTATION\n#include \u003cscp/containers/hashmap.h\u003e\n```\nOr add -DSCP_IMPLEMENTATION to the compiler arguments.\n\n## Docs (short)\n* __utils.h__: everithing that is inside the `utils/` folder\n* __utils/__:\n\t* __macros.h__: utility macros\n\t\t* `__attribute__((\u003cattribute\u003e))` as `scpAttribute_\u003cattribute\u003e`\n\t\t* `scpNoreturn` is definied as `_Noreturn` normally or `scpAttribute_noreturn` with c99 and under\n\t\t* `scpBool`, `scpTrue` and `scpFalse`, macros for `_Bool`, `1` and `0`\n\t\t* `#X` as `SCP_TO_STRING_NX(X)` and `SCP_TO_STRING(X)`\n\t\t* `a##b` as `SCP_CONCAT_NX(a, b)` and `SCP_CONCAT(a, b)`\n\t\t* lambda functions with `SCP_LAMBDA(return_type, body)` (not pedantic, disable with `-DSCP_PEDANTIC`)\n\t\t* swaping contents of variables with `SCP_SWAP(type, a, b)`\n\t\t* function typedefs as `scpFunc_\u003cfunction\u003e`\n\t* __string.h__: utility functions for strings\n\t\t* `char* scpString_to_lower(char* str)`: change str to lowercase, returns str\n\t\t* `char* scpString_to_upper(char* str)`: change str to uppercase, returns str\n\t\t* `char* scpString_new_lower(const char* str)`: change str to lowercase, returns a new string (must be free'd)\n\t\t* `char* scpString_new_upper(const char* str)`: change str to uppercase, returns a new string (must be free'd)\n\t* __io.h__: utility functions for input/output\n\t\t* `scpBool scpIO_flush_buffer(FILE* stream, char* buffer)`: utility for fgets, will check if the used inputed a line bigger than the cappacity of the buffer and if not it will replace the newline character '\\n' with a null character '\\0', otherwise it will empty the buffer until a newline is uncountered, returns `scpTrue` if it emptied the buffer, `scpFalse` otherwise.\n\t* __print.h__: functions of type `scpFunc_print`\n\t* __fprint.h__: functions of type `scpFunc_fprint`\n\t* __copy.h__: functions of type `scpFunc_copy`\n\t* __clone.h__: functions of type `scpFunc_clone`\n\t* __hash.h__: functions of type `scpFunc_hash`\n\t* __cmp.h__: functions of type `scpFunc_cmp`\n* __maths.h__: everithing that is inside the `maths/` folder\n* __maths/__: general maths utility functions\n\t* __binpow.h__: integers binary exponanciation\n\t\t* `scpMaths_binpow_(i|il|ill|u|ul|ull)` for individual function\n\t\t* `scpMaths_binpow` `_Generic` with type deduced from the first argument\n\t* __primes.h__: prime numbers generation\n\t\t* `scpPrimes_array`: scpArray in which the prime numbers are stored\n\t\t* `scpPrimes_gen(n)`: generates prime numbers until n\n\t\t* `scpPrimes_next(n)`: returns the first prime number after n\n* __containers/__: OOP wrappers for data structures\n\t* __array.h__: OOP wrapper for an array as `scpArray`\n\t\t* `struct scpArray`: array's struct\n\t\t\t* `struct scpArrayType* .type`: pointer to virtual functions\n\t\t\t* `void* .data`: pointer to the raw array\n\t\t\t* `size_t .count`: number of elements in the array\n\t\t\t* `size_t .size`: size of one element (as given by `sizeof`)\n\t\t* `scpArray`: `struct scpArrayType` instance, virtual table of array\n\t\t\t* `struct scpArray* .new(size_t count, size_t size)`: creates a new instance of `struct scpArray`, cf. `.count` and `.size` for info on parameters\n\t\t\t* `void .delete(struct scpArray* array)`: deletes the array\n\t\t\t* `void .resize(struct scpArray* array, size_t count)`: assigns a new count to the array\n\t\t\t* `void* .at(struct scpArray* array, size_t index)`: returns a pointer to the index-th element of the array\n\t\t\t* for `copy`, `fcopy`, `clone`, `fclone`, `map`, `map_index`, `print` and `fprint` cf. __utils.h__\n\t* __vector.h__: OOP wrapper for a dynamic array as `scpVector`\n\t\t* `struct scpVector`: vector's struct\n\t\t\t* `struct scpVectorType* .type`: pointer to virtual functions\n\t\t\t* `void* .data`: pointer to the raw vector\n\t\t\t* `size_t .count`: number of elements in the vector\n\t\t\t* `size_t .size`: size of one element (as given by `sizeof`)\n\t\t\t* `size_t .reserved`: number of element the vector can contain before needing to resize\n\t\t* `scpVector`: `struct scpVectorType` instance, virtual table of vector\n\t\t\t* `struct scpVector* .new(size_t count, size_t size)`: creates a new instance of `struct scpVector`, cf. `.count` and `.size` for info on parameters\n\t\t\t* `void .delete(struct scpVector* vector)`: deletes the vector\n\t\t\t* `void .resize(struct scpVector* vector, size_t count)`: assigns a new count to the vector\n\t\t\t* `void .reserve(struct scpVector* vector, size_t count)`: assigns a new reserved to the vector\n\t\t\t* `void* .at(struct scpVector* vector, size_t index)`: returns a pointer to the index-th element of the array\n\t\t\t* `void* .append(struct scpVector* vector)`: adds an element to the vector and returns a pointer to said element\n\t\t\t* `void .pop(struct scpVector* vector)`: removes the last element, throws an exception if the vector is empty\n\t\t\t* for `copy`, `fcopy`, `clone`, `fclone`, `map`, `map_index`, `print` and `fprint` cf. __utils.h__\n\t* __hashmap.h__: OOP wrapper for a hash table, mapping key-value pair as `scpHashMap`\n\t\t* `struct scpHashMap`: hashmap's struct\n\t\t\t* `.type`: pointer to virtual functions\n\t\t\t* `.base_size`: desired size for items\n\t\t\t* `.size`: reserved space for items (next prime to `.base_size`)\n\t\t\t* `.count`: number of items\n\t\t\t* `.items`: pointer to raw items\n\t\t\t* `.hash_a`: first key hashing function (scpFunc_hash)\n\t\t\t* `.hash_b`: second key hashing function (scpFunc_hash)\n\t\t\t* `.cmp`: key comparing function (scpFunc_cmp)\n\t\t* `scpHashMap`: `struct scpHashMapType` instance, virtual table of hashmap\n\t\t\t* `struct scpHashMap* .new(scpFunc_hash hash_a, scpFunc_hash hash_b, scpFunc_cmp cmp)`: creates a new instance of `struct scpHashMap`, cf. `.hash_a`, `.hash_b` and `.cmp` for info on parameters\n\t\t\t* `void .delete(struct scpHashMap* hashmap)`: deletes the hashmap\n\t\t\t* `bool .insert(struct scpHashMap* hashmap, const void* key, void* value)`: inserts or replaces a key value pair in the hashmap, returns true if the key was already in the hashtable\n\t\t\t* `bool .remove(struct scpHashMap* hashmap, const void* key)`: removes a key value pair of the hashmap, returns true if the key was in the hashtable\n\t\t\t* `void* .search(struct scpHashMap* hashmap, const void* key)`: returns the value associated to the given key\n\t* __hashset.h__: OOP wrapper for a hash table, mapping single key as `scpHashSet`\n\t\t* `struct scpHashSet`: hashset's struct\n\t\t\t* `.type`: pointer to virtual functions\n\t\t\t* `.base_size`: desired size for items\n\t\t\t* `.size`: reserved space for items (next prime to `.base_size`)\n\t\t\t* `.count`: number of items\n\t\t\t* `.items`: pointer to raw items\n\t\t\t* `.hash_a`: first key hashing function (scpFunc_hash)\n\t\t\t* `.hash_b`: second key hashing function (scpFunc_hash)\n\t\t\t* `.cmp`: key comparing function (scpFunc_cmp)\n\t\t* `scpHashSet`: `struct scpHashSetType` instance, virtual table of hashset\n\t\t\t* `struct scpHashSet* .new(scpFunc_hash hash_a, scpFunc_hash hash_b, scpFunc_cmp cmp)`: creates a new instance of `struct scpHashSet`, cf. `.hash_a`, `.hash_b` and `.cmp` for info on parameters\n\t\t\t* `void .delete(struct scpHashSet* hashset)`: deletes the hashset\n\t\t\t* `bool .insert(struct scpHashSet* hashset, const void* key)`: inserts or replaces a key in the hashset, returns true if the key was already in the hashtable\n\t\t\t* `bool .remove(struct scpHashSet* hashset, const void* key)`: removes a key of the hashset, returns true if the key was in the hashtable\n\t\t\t* `bool .search(struct scpHashSet* hashset, const void* key)`: returns true if the key was in the hashtable\n* __exceptions.h__:\n\t* `scpException_\u003cname\u003e`: individual exception functions\n\t* `SCP_EXCEPTION(exception, ...)`: calls `exeption` with `__FILE__`, `__func__` and `__LINE__` automatically\n* __int128.h__: wrapper for GNU C `__int128` (not pedantic)\n\t* typedefs and printing functions for signed and unsigned int128\n* __stream.h__: generic OOP stream for files, strings, etc...\n* __time.h__: function timing utility\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvokungahrotlaas%2Fscplib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvokungahrotlaas%2Fscplib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvokungahrotlaas%2Fscplib/lists"}