[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.
/ libjapan Public archive

Another C general-purpose library.

License

Notifications You must be signed in to change notification settings

baAlex/libjapan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibJapan

Ubuntu CI Windows CI CodeQL scanning

A collection of frequently used features that the C language lacks: lists, hashes, trees, maths functions (vectors, matrices), between an etcetera of other utilities. My contribution to the constellation of existing general-purpose libraries.

The project born as an exercise to learn the language, since then I've been updating/refactoring it according to my needs and experience. There are some flaws to fix, designs to polish, bugs to add, and probably the library is too game-development oriented, I'm working on those aspects... any help is welcome.

Overview

Header -
buffer.h Tiny fix over realloc().
dictionary.h Linear hash map, grows dynamically between a threshold. By default uses FNV1 as hash function.
endianness.h Runtime functions to convert between little and big endianness.
image.h Support for the unknown SGI format, up to 4 channels of 8 or 16 bits, optionally with RLE compression.
list.h Double linked list. Friendly with the "fat pointer" technique.
matrix.h 4x4 matrix operations. Based on linmath.h.
sound.h Support for WAV and AU formats, with integer-samples of 8, 16, 32 bits or float-samples of 32, 64 bits. Handles U-Law and A-Law compression.
status.h A method to pass error values between functions.
string.h UTF8 and ASCII validation. Distinguishes between UTF8 units and bytes, can be used to count them.
tree.h Just a generic tree.
utilities.h Min, Max, DegToRad, and other one-liners.
vector.h 2, 3, and 4 dimensions vectors.

Work-in-progress modules:

Header -
token.h A tokenizer, as C makes string manipulation particularly hard.
configuration.h Configuration variables (cvar) a la Quake.

Compilation

Compiles lovely with Clang, GCC and MSVC ❤️.

To clone and compile the repository with:

git clone https://github.com/baAlex/libjapan.git libjapan
cd libjapan

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --config Debug

And for a release build the same procedure as above except for:

cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release

By default if CMake finds cmocka installed, a test suite is build.

Similar projects

Modern, simpler approaches:

  • stb.h, «This is a single header file with a bunch of useful utilities for getting stuff done in C/C++».
  • Tbox, «The project focuses on making C development easier and provides many modules (...), so that any developer can quickly pick it up and enjoy the productivity boost when developing in C language».
  • ZPL, «C99 cross-platform header-only library that offers powerful toolkit to accelerate your development progress».

License

Under MIT License.

Optional notes

  • File 'matrix.c' is licensed under the WTFPL license. Copyright (c) 2013 by Wolfgang 'datenwolf' Draxinger. Based on linmath.h.
  • File 'laws.c' is released under public domain. Based on code written by Steve Underwood (steveu@coppice.org): g711.h - In line A-law and u-law conversion routines.

As those two files licenses/terms can be problematic(a)(b), if desired it's safe to assume that they are re-licensed under the MIT License as specified in the file LICENSE. Is not a requirement to expose this paragraph nor the original authors, here is done as a gratitude gesture.