| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
Overview |
| 4 |
======== |
| 5 |
|
| 6 |
Summary |
| 7 |
------- |
| 8 |
|
| 9 |
You can use Groonga as a library. You need to use the following APIs to |
| 10 |
initialize and finalize Groonga. |
| 11 |
|
| 12 |
:c:func:`grn_init()` initializes Groonga. |
| 13 |
In contrast, :c:func:`grn_fin()` finalizes Groonga. |
| 14 |
|
| 15 |
You must call :c:func:`grn_init()` only once before you use APIs which |
| 16 |
are provided by Groonga. You must call :c:func:`grn_fin()` only once |
| 17 |
after you finish to use APIs which are provided by Groonga. |
| 18 |
|
| 19 |
Example |
| 20 |
------- |
| 21 |
|
| 22 |
Here is an example that uses Groonga as a full-text search library. |
| 23 |
|
| 24 |
.. code-block :: c |
| 25 |
|
| 26 |
grn_rc rc; |
| 27 |
/* It initializes resources used by Groonga. */ |
| 28 |
rc = grn_init(); |
| 29 |
if (rc != GRN_SUCCESS) { |
| 30 |
return EXIT_FAILURE; |
| 31 |
} |
| 32 |
/* Some Groonga API calling codes... */ |
| 33 |
/* It releases resources used by Groonga. */ |
| 34 |
grn_fin(); |
| 35 |
return EXIT_SUCCESS; |
| 36 |
|
| 37 |
Reference |
| 38 |
--------- |
| 39 |
|
| 40 |
.. c:function:: grn_rc grn_init(void) |
| 41 |
|
| 42 |
``grn_init()`` initializes resources that are used by Groonga. You |
| 43 |
must call it just once before you call other Groonga APIs. |
| 44 |
|
| 45 |
:return: ``GRN_SUCCESS`` on success, not ``GRN_SUCCESS`` on error. |
| 46 |
|
| 47 |
.. c:function:: grn_rc grn_fin(void) |
| 48 |
|
| 49 |
``grn_fin()`` releases resources that are used by Groonga. You can't |
| 50 |
call other Groonga APIs after you call ``grn_fin()``. |
| 51 |
|
| 52 |
:return: ``GRN_SUCCESS`` on success, not ``GRN_SUCCESS`` on error. |