Skip to content

Commit

Permalink
Small updates to doc and examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeDP committed Mar 27, 2018
1 parent 1cb2e43 commit a518914
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 15 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Documentation Status](https://readthedocs.org/projects/libmodule/badge/?version=latest)](http://libmodule.readthedocs.io/en/latest/?badge=latest)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

Libmodule aims to let developers easily create modular C projects in a way which is both simple and elegant.
Libmodule is a C library targeting linux aiming to let developers easily create modular C projects in a way which is both simple and elegant.
You will write less code, focusing on what really matters.

## Is this an event loop or an actor lib?
Expand All @@ -17,8 +17,7 @@ Indeed, libmodule was heavily inspired by my own actor library experience with [

## Is it portable?

No, it is not.
It uses epoll, which is linux specific.
No, it is not: it uses epoll, which is linux specific.
Moreover it heavily relies upon gcc attributes that may or may not be available for your compiler.
It is tested with both gcc and clang through [travis](https://travis-ci.org/FedeDP/libmodule).
Any patch to support other platforms is warmly welcomed though.
Expand All @@ -42,8 +41,7 @@ So I thought that writing a library to achieve those same abstractions in a clea

## Build dep and how to build

You only need cmake to build libmodule.
It does not depend upon external software.
You only need cmake to build libmodule; it does not depend upon external software.
Libmodule includes an [hashmap](https://github.com/petewarden/c_hashmap) implementation provided by Pete Warden (thank you!).
To build, you only need to issue:

Expand All @@ -56,7 +54,7 @@ If you wish to install, then you only need:

# make install

Libmodule will install a pkg-config file too. Use this to link libmodule in your projects, or use "-lmodule" flag.
Libmodule will install a pkg-config file too. Use this to link libmodule in your projects, or use "-lmodule" linker flag.
Please note that in order to test examples, there is no need to install the library.

For Archlinux users, a PKGBUILD can be found in [Extra/Arch](https://github.com/FedeDP/libmodule/tree/master/Extra/Arch) folder.
Expand Down
1 change: 1 addition & 0 deletions Samples/Easy/doggo.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <module.h>
// #include <module/module.h>
#include <unistd.h>
#include <string.h>

Expand Down
1 change: 1 addition & 0 deletions Samples/Easy/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <modules.h>
// #include <module/modules.h>

/*
* This function is automatically called before initing any module.
Expand Down
2 changes: 2 additions & 0 deletions Samples/Easy/pippo.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <module.h>
#include <modules.h>
// #include <module/module.h>
// #include <module/modules.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
Expand Down
2 changes: 2 additions & 0 deletions Samples/MultiCtx/a.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <module.h>
#include <modules.h>
// #include <module/module.h>
// #include <module/modules.h>
#include <sys/timerfd.h>
#include <unistd.h>
#include <stdint.h>
Expand Down
2 changes: 2 additions & 0 deletions Samples/MultiCtx/b.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <module.h>
#include <modules.h>
// #include <module/module.h>
// #include <module/modules.h>
#include <sys/signalfd.h>
#include <signal.h>
#include <unistd.h>
Expand Down
1 change: 1 addition & 0 deletions Samples/MultiCtx/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <modules.h>
// #include <module/modules.h>
#include <pthread.h>

static void *loop(void *param);
Expand Down
3 changes: 2 additions & 1 deletion Samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ To build these samples, use

$ make $target

where $target matches the name of the subfolder for your desired example.
where $target matches the name of the subfolder for your desired example.
Please note that libmodule's correct includes are <module/module{s}.h>. In this examples <module{s}.h> are used as rpath is forced through makefile.

## Easy example

Expand Down
1 change: 1 addition & 0 deletions Samples/SharedSrc/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <modules.h>
// #include <module/modules.h>

extern void create_modules(const char *ctx_name);
extern void destroy_modules(void);
Expand Down
2 changes: 2 additions & 0 deletions Samples/SharedSrc/mod.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <module.h>
#include <modules.h>
// #include <module/module.h>
// #include <module/modules.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
Expand Down
5 changes: 1 addition & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

### Generic

- [x] review hashmap code
- [x] split in modules.h and module.h
- [x] install public headers in "/usr/lib/module/module.h/modules.h?"
- [ ] update doc
- [x] update doc

## Test it

Expand Down
6 changes: 4 additions & 2 deletions docs/src/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
Module
======

Module API denotes libmodule interface functions that can be found in module/module.h header. |br|
It is splitted in two APIs.

.. _module_easy:

Module easy API
Expand Down Expand Up @@ -113,11 +116,10 @@ Where not specified, these functions return a :ref:`module_ret_code <module_ret_
.. _module_complex:

Module Complex API
--------------------
------------------

Complex (probably better to say less-easy) API consists of `Module easy API`_ internally used functions. |br|
Sometime you may avoid using easy API; eg: if you wish to use same source file for different modules. |br|
This behaviour is discouraged though. |br|
Again, where not specified, these functions return a :ref:`module_ret_code <module_ret_code>`.

.. c:function:: module_register(name, ctx_name, self, hook)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<br />

Modules
===========
=======

Modules API denotes all of libmodule interface functions whose name starts with \modules_. |br|
Modules API denotes libmodule interface functions that can be found in module/modules.h header. |br|
Like Module API, it has an easy, single-context API. Moreover, it has an equivalent multi-context API. |br|
All these functions but modules_pre_start() return a :ref:`module_ret_code <module_ret_code>`.

Expand Down

0 comments on commit a518914

Please sign in to comment.