Skip to content

Commit

Permalink
Some small fixes in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeDP committed Mar 10, 2018
1 parent 5210997 commit 67397e1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions docs/src/data_structures.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Module Data Structures
======================
Libmodule Data Structures
=========================

.. code::
Expand Down
46 changes: 23 additions & 23 deletions docs/src/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,55 +31,55 @@ It enforces correct modularity too: each module must have its own source file.

.. c:macro:: m_is(state)
"Check current module's state"
Check current module's state

:param: :c:type:`enum module_states` state: state we are interested in.
:returns: false (0) if module'state is not 'state', true (1) if it is.

.. c:macro:: m_start(fd)
"Start a module by polling on fd"
Start a module by polling on fd

:param: :c:type:`int` fd: fd to be polled.
:returns: 0 if no error happened, < 0 if any error happened.

.. c:macro:: m_pause()
.. c:macro:: m_pause(void)
"Pause module's polling"
Pause module's polling

:returns: 0 if no error happened, < 0 if any error happened.

.. c:macro:: m_resume()
.. c:macro:: m_resume(void)
"Resume module's polling"
Resume module's polling

:returns: 0 if no error happened, < 0 if any error happened.

.. c:macro:: m_stop()
.. c:macro:: m_stop(void)
"Stop module's polling by closing its fd"
Stop module's polling by closing its fd

:returns: 0 if no error happened, < 0 if any error happened.

.. c:macro:: m_become(new_recv)
"Change recv callback to recv_new_recv"
Change recv callback to recv_new_recv

:param: new_recv: new module's recv; the function has suffix \recv_ concatenated with new_recv.

.. c:macro:: m_unbecome()
.. c:macro:: m_unbecome(void)
"Reset to default recv poll callback"
Reset to default recv poll callback

.. c:macro:: m_set_userdata(userdata)
"Set userdata for this module; userdata will be passed as parameter to recv callback."
Set userdata for this module; userdata will be passed as parameter to recv callback.

:param: :c:type:`const void *` userdata: module's new userdata.

.. c:macro:: m_log(fmt, ...)
"Logger for this module. Call it the same way you'd call printf"
Logger for this module. Call it the same way you'd call printf

:param: :c:type:`const char *` fmt: log's format.
:param ...: variadic argument.
Expand All @@ -92,7 +92,7 @@ Sometime you may avoid using easy API; eg: if you wish to use same source file f

.. c:function:: module_register(name, ctx_name, self, hook)
"Register a new module"
Register a new module

:param: :c:type:`const char *` name: module's name.
:param: :c:type:`const char *` ctx_name: module's context name. A new context will be created if it cannot be found.
Expand All @@ -101,61 +101,61 @@ Sometime you may avoid using easy API; eg: if you wish to use same source file f

.. c:function:: module_deregister(self)
"Deregister this module"
Deregister module

:param: :c:type:`const void **` self: pointer to module's handler. It is set to NULL after this call.

.. c:function:: module_is(self, state)
"Check current module's state"
Check current module's state

:param: :c:type:`const void *` self: pointer to module's handler.
:param: :c:type:`enum module_states` state: state we are interested in.
:returns: false (0) if module'state is not 'state', true (1) if it is.

.. c:function:: module_start(self, fd)
"Start a module by polling on fd"
Start a module by polling on fd

:param: :c:type:`const void *` self: pointer to module's handler.
:param: :c:type:`int` fd: fd to be polled.
:returns: 0 if no error happened, < 0 if any error happened.

.. c:function:: module_pause(self)
"Pause module's polling"
Pause module's polling

:param: :c:type:`const void *` self: pointer to module's handler.

.. c:function:: module_resume(self)
"Resume module's polling"
Resume module's polling

:param: :c:type:`const void *` self: pointer to module's handler.

.. c:function:: module_stop(self)
"Stop module's polling by closing its fd"
Stop module's polling by closing its fd

:param: :c:type:`const void *` self: pointer to module's handler.

.. c:macro:: module_become(self, new_recv)
"Change recv callback to new_recv"
Change recv callback to new_recv

:param: :c:type:`const void *` self: pointer to module's handler.
:param: :c:type:`recv_cb` new_recv: new module's recv.

.. c:function:: module_set_userdata(self, userdata)
"Set userdata for this module; userdata will be passed as parameter to recv callback."
Set userdata for this module; userdata will be passed as parameter to recv callback.

:param: :c:type:`const void *` self: pointer to module's handler.
:param: :c:type:`const void *` userdata: module's new userdata.

.. c:function:: module_log(self, fmt, ...)
"Module's logger"
Module's logger

:param: :c:type:`const void *` self: pointer to module's handler.
:param: :c:type:`const char *` fmt: log's format.
Expand Down
20 changes: 10 additions & 10 deletions docs/src/module_callbacks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ They are automatically declared by MODULE macro:
static void recv(message_t *msg, const void *userdata);
static void destroy(void);
.. c:function:: init()
.. c:function:: init(void)
"Initialize module"
Initialize module

:returns: FD to be polled for this module.

.. c:function:: check()
.. c:function:: check(void)
"Startup filter to check whether this module should be created and managed by libmodule"
Startup filter to check whether this module should be created and managed by libmodule

:returns: 0 if the module should be created, not-0 otherwise.

.. c:function:: evaluate()
.. c:function:: evaluate(void)
"Similar to check() function but at runtime: this function is called for each IDLE module after evey state machine update
and it should check whether a module is now ready to be start (ie: init should be called on this module)."
Similar to check() function but at runtime: this function is called for each IDLE module after evey state machine update
and it should check whether a module is now ready to be start (ie: init should be called on this module).

:returns: true (not-0) if module is now ready to be started, else 0.

.. c:function:: recv(msg, userdata)
"Poll callback"
Poll callback

:param: :c:type:`message_t *` msg: pointer to message_t struct. As of now, only fd field is used.
:param: :c:type:`const void *` userdata: pointer to userdata as set by m_set_userdata.

.. c:function:: destroy()
.. c:function:: destroy(void)
"Destroy module, called automatically at module deregistration."
Destroy module, called automatically at module deregistration. Please note that module's fd is automatically closed.
16 changes: 8 additions & 8 deletions docs/src/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ Modules easy API
Modules easy API should be used in conjunction with :ref:`module_easy`. |br|
It abstracts all of libmodule internals mechanisms to provide an easy-to-use and simple API.

.. c:macro:: modules_pre_start()
.. c:macro:: modules_pre_start(void)
"This function will be called by libmodule before creating any module.
This function will be called by libmodule before creating any module.
It can be useful to set some global state/read config that are needed to decide whether to start a module.
You only need to define this function and it will be automatically called by libmodule."
You only need to define this function and it will be automatically called by libmodule.

.. c:macro:: modules_on_error(on_error)
"Set libmodule error's callback"
Set libmodule error's callback

:param: :c:type:`error_cb` on_error: user error callback.

.. c:macro:: modules_loop()
.. c:macro:: modules_loop(void)
"Start looping on events from modules"
Start looping on events from modules

.. c:macro:: modules_quit()
.. c:macro:: modules_quit(void)
"Leave libmodule's events loop"
Leave libmodule's events loop

0 comments on commit 67397e1

Please sign in to comment.