diff --git a/Makefile.am b/Makefile.am index e576da6..c631895 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ if BUILD_TESTS EXTRA += tests endif -SUBDIRS = include lib $(EXTRA) +SUBDIRS = include lib man $(EXTRA) libtdatadocdir = ${prefix}/doc/libtdata libtdatadoc_DATA = \ diff --git a/configure.ac b/configure.ac index 08915d1..201f492 100644 --- a/configure.ac +++ b/configure.ac @@ -62,4 +62,5 @@ Makefile lib/libtdata.pc lib/Makefile tests/Makefile -include/Makefile]) +include/Makefile +man/Makefile]) diff --git a/include/tdata/usrtc.h b/include/tdata/usrtc.h index 0fa3c23..d962714 100644 --- a/include/tdata/usrtc.h +++ b/include/tdata/usrtc.h @@ -22,14 +22,11 @@ #define USRTC_COUNT_T_MAX ((1 << (sizeof(unsigned long)*(sizeof(char) << 1)))-1) -/*count and some misc typedefs*/ +/* count and some misc typedefs */ typedef unsigned long usrtc_count_t; typedef unsigned int usrtc_impl_id_t; -/* implementations ids, - * if you want to add some - * add the id here, don't forget to do it. - */ +/* implementation's typedefs */ #define USRTC_LIST 0 #define USRTC_BST 1 #define USRTC_REDBLACK 2 @@ -102,9 +99,14 @@ typedef struct __usrtc_functions_t { usrtc_impltype_t usrtc_type; } usrtc_functions_t; -/*basic rtc functions*/ -void usrtc_init(usrtc_t *us,int impl,usrtc_count_t maxcount,usrtc_compare_t compare); -usrtc_t *usrtc_create(int impl,usrtc_count_t maxcount,usrtc_compare_t compare); +/* basic usrtc functions */ +/* initialize usrtc core structure */ +void usrtc_init(usrtc_t *us, int impl, usrtc_count_t maxcount, + usrtc_compare_t compare); +/* allocate and initialize core structure: going to be deprecated */ +usrtc_t *usrtc_create(int impl, usrtc_count_t maxcount, + usrtc_compare_t compare); +/* destroy(free) usrtc core structure: going to be deprecated */ void usrtc_destroy(usrtc_t *us); void usrtc_convert_to(usrtc_t *us,int impl); diff --git a/man/Makefile.am b/man/Makefile.am new file mode 100644 index 0000000..e593e69 --- /dev/null +++ b/man/Makefile.am @@ -0,0 +1,2 @@ +man_MANS = usrtc_init.3 usrtc_create.3 usrtc_destroy.3 + diff --git a/man/reference-template.3 b/man/reference-template.3 new file mode 100644 index 0000000..f470f35 --- /dev/null +++ b/man/reference-template.3 @@ -0,0 +1,24 @@ +.TH @F_BLOCK@ 3 "@DoM@ @MONTH@ @YEAR@" "LIBTDATA" "Portable data structures C library manual" +.SH NAME +.br +.SH SYNOPSYS +.br +.SH DESCRIPTION +.br +.SH RETURN VALUE +.br +.SH BUGS +.br +.SH EXAMPLE +.br +.SH RATIONALE +.br +.SH SEE ALSO +.br +.SH COPYRIGHT +This software licensed under GNU LGPL v2.1 or later. See COPYING for further details. +.br +(c) Authors of libtdata. See AUTHORS for further details. +.SH AUTHOR +@GIT_NAME@ (@GIT_EMAIL@) +.br diff --git a/man/usrtc_create.3 b/man/usrtc_create.3 new file mode 120000 index 0000000..d1d20bc --- /dev/null +++ b/man/usrtc_create.3 @@ -0,0 +1 @@ +usrtc_init.3 \ No newline at end of file diff --git a/man/usrtc_destroy.3 b/man/usrtc_destroy.3 new file mode 120000 index 0000000..d1d20bc --- /dev/null +++ b/man/usrtc_destroy.3 @@ -0,0 +1 @@ +usrtc_init.3 \ No newline at end of file diff --git a/man/usrtc_init.3 b/man/usrtc_init.3 new file mode 100644 index 0000000..90ef9de --- /dev/null +++ b/man/usrtc_init.3 @@ -0,0 +1,87 @@ +.TH USRTC_INIT 3 "21 May 2019" "LIBTDATA" "Portable data structures C library manual" +.SH NAME +usrtc_init \- Initialize usrtc core structure +.br +usrtc_create \- Allocate and initialize usrtc core structure +.br +usrtc_destroy \- Destroy (free) usrtc core structure +.br +.SH SYNOPSYS +.B #include +.sp +void usrtc_init(usrtc_t *us, int impl, usrtc_count_t maxcount, usrtc_compare_t compare); + +usrtc_t *usrtc_create(int impl, usrtc_count_t maxcount, usrtc_compare_t compare); + +void usrtc_destroy(usrtc_t *us); + +typedef long (*usrtc_compare_t)(const void*, const void*); + +.br +.sp +.SH DESCRIPTION +.B usrtc_init +and +.B usrtc_create +are used to initialize a new usrtc core structure. The difference is +.B usrtc_create +will allocate +.B usrtc_t +structure via +.B malloc() +function, but +.B usrtc_init +expect already allocated structure. Argument +.B impl +is used to point the type of search data structure used for this particular usrtc core structure. Possible values are: +.br +.B * USRTC_LIST: +Linked list +.br +.B * USRTC_BST: +Binary search tree +.br +.B * USRTC_REDBLACK: +Redblack tree +.br +.B * USRTC_SPLAY: +Splay tree +.br +.B * USRTC_AVL: +AVL tree +.br +.B maxcount +argument is pointing to a max amount of the nodes within a search data structure. +.B compare +is a pointer to a compare function. +.br +.B usrtc_destroy +is used to destroy (free) usrtc core structure. This function must be used only for structures allocated via +.B usrtc_create +function. +.br +.SH RETURN VALUE +Valid pointer to a newly allocated and initialized core structure, otherwise +.B NULL. +.br +.SH BUGS +Not known yet. +.br +.SH EXAMPLE +.br +.SH RATIONALE +Using functions +.B usrtc_create +and +.B usrtc_destroy +is deprecating. +.br +.SH SEE ALSO +.br +.SH COPYRIGHT +This software licensed under GNU LGPL v2.1 or later. See COPYING for further details. +.br +(c) Authors of libtdata. See AUTHORS for further details. +.SH AUTHOR +Alexander Vdolainen (alex@vapaa.xyz) +.br