Jnxlibc

Powerful, light, feature-rich C library

View the Project on GitHub AlexsJones/jnxlibc

jnxlibc

Build Status License Dev

A modern C library that provides a useful self contained API that has built in testing and just works. Covering a range of boilerplate code areas and low level networking; jnxlibc provides both a reliable systems library and tool for learning.

Latest release

Key features

Documentation & Examples

Installation

Dependencies

GCC
CMake

Currently supported platforms: Linux distributions/OS X

Default install location

git clone git@github.com:AlexsJones/jnxlibc jnxlibc && cd jnxlibc
cmake .
make
sudo make install

Custom install location

git clone git@github.com:AlexsJones/jnxlibc jnxlibc && cd jnxlibc
cmake . -DCMAKE_INSTALL_PREFIX=/Users/alexjo/Projects/jnxlibc/build/ 
make
sudo make install

Use -ljnxc when building your project for shared library Use -ljnxcs for static library

Flags

-DRELEASE (Sets library for release mode optimisations)

Examples

Sending message over network

jnx_socket *udp_sock = jnx_socket_udp_create(AF_INET);
jnx_socket_udp_send(udp_sock,"host","port","message",strlen("message"));
jnx_socket_close(udp_sock);

Using a binary tree

jnx_btree *tree = jnx_btree_create(sizeof(int),callback_func);
//insertion
int i;
for(i=0;i<10;++i) {
  void *next = (void*)(guids[i]);
  jnx_btree_add(tree,next,next);
}
//get keys
jnx_list *keys = jnx_list_create();
jnx_btree_keys(tree,keys);

while(keys->head) {
  char *a_key = keys->head->data;
  void *val = jnx_btree_lookup(tree,(void*)a_key);
  jnx_btree_remove(tree,a_key,NULL,NULL);
  keys->head = keys->head->next_node;
}
jnx_list_destroy(&keys);
jnx_btree_destroy(&tree);

Manipulating data from a hashmap with thread safety

void *value = jnx_hash_get_ts(hashmap,"Key");
jnx_hash_put_ts(hashmap,"Key",update_value);

Using signals and slots

typedef void local_slot(jnx_signal *s);

jnx_signal *s = jnx_signal_create();
jnx_signal_connect(s,local_slot);
jnx_signal_call(s,NULL);
jnx_signal_destroy(&s);