summaryrefslogtreecommitdiff
path: root/src/lib/spy/spy_main.c
diff options
context:
space:
mode:
authorGuillaume Friloux <guillaume.friloux@gmail.com>2013-12-30 16:07:28 +0100
committerGuillaume Friloux <guillaume.friloux@gmail.com>2013-12-30 16:07:28 +0100
commit73a964e7f7b1bff93a476b92b84ad67c25f80cd0 (patch)
tree843ed502cedcfac8ef41316e093b1c1c096c4fad /src/lib/spy/spy_main.c
parent3c753c9cdb3c4f218ee42dd186fdb793fb092ed2 (diff)
Add some doc.
Diffstat (limited to '')
-rw-r--r--src/lib/spy/spy_main.c80
1 files changed, 77 insertions, 3 deletions
diff --git a/src/lib/spy/spy_main.c b/src/lib/spy/spy_main.c
index 1e512a0..d1beec6 100644
--- a/src/lib/spy/spy_main.c
+++ b/src/lib/spy/spy_main.c
@@ -3,11 +3,26 @@
3#include <fcntl.h> 3#include <fcntl.h>
4#include <unistd.h> 4#include <unistd.h>
5 5
6/**
7 * @addtogroup Lib-Spy-Functions
8 * @{
9 */
10
11/**
12 * @cond IGNORE
13 */
6static int _spy_init_count = 0; 14static int _spy_init_count = 0;
7int _spy_log_dom_global = -1; 15int _spy_log_dom_global = -1;
8 16
9int SPY_EVENT_LINE = 0; 17int SPY_EVENT_LINE = 0;
10 18/**
19 * @endcond
20 */
21
22/**
23 * @brief Create a new Spy structure.
24 * @return Pointer to newly created Spy or NULL if allocation failed.
25 */
11Spy * 26Spy *
12spy_new(void) 27spy_new(void)
13{ 28{
@@ -18,6 +33,13 @@ spy_new(void)
18 return spy; 33 return spy;
19} 34}
20 35
36/**
37 * @brief Frees a Spy structure.
38 *
39 * @param Spy structure to free.
40 *
41 * This function will also free all the associated Spy_File structures.
42 */
21void 43void
22spy_free(Spy *spy) 44spy_free(Spy *spy)
23{ 45{
@@ -30,6 +52,13 @@ spy_free(Spy *spy)
30 free(spy); 52 free(spy);
31} 53}
32 54
55/**
56 * @brief Frees a Spy_File structure.
57 *
58 * @param sf Spy_File structure to free.
59 *
60 * This function will also remove the Spy_File from the Spy list.
61 */
33void 62void
34spy_file_free(Spy_File *sf) 63spy_file_free(Spy_File *sf)
35{ 64{
@@ -52,6 +81,13 @@ spy_file_free(Spy_File *sf)
52 free(sf); 81 free(sf);
53} 82}
54 83
84/**
85 * @brief Pause spying of a file.
86 *
87 * @param sf Spy_File to pause.
88 *
89 * It doesnt stop its timer, but will block size checking.
90 */
55void 91void
56spy_file_pause(Spy_File *sf) 92spy_file_pause(Spy_File *sf)
57{ 93{
@@ -60,6 +96,13 @@ spy_file_pause(Spy_File *sf)
60 sf->poll.pause = EINA_TRUE; 96 sf->poll.pause = EINA_TRUE;
61} 97}
62 98
99/**
100 * @brief Resume spying of a file.
101 *
102 * @param sf Spy_File to resume.
103 *
104 * This function allows to resume the spying of a file that got paused.
105 */
63void 106void
64spy_file_resume(Spy_File *sf) 107spy_file_resume(Spy_File *sf)
65{ 108{
@@ -68,6 +111,15 @@ spy_file_resume(Spy_File *sf)
68 sf->poll.pause = EINA_FALSE; 111 sf->poll.pause = EINA_FALSE;
69} 112}
70 113
114/**
115 * @brief Get the Spy_File associated to a file.
116 *
117 * @param spy Spy structure to inpect.
118 * @param file File to search for.
119 * @return Spy_File structure spying the file, or NULL.
120 *
121 * This can be used to know if we are already spying a file or not
122 */
71Spy_File * 123Spy_File *
72spy_file_get(Spy *spy, const char *file) 124spy_file_get(Spy *spy, const char *file)
73{ 125{
@@ -82,6 +134,15 @@ spy_file_get(Spy *spy, const char *file)
82 return NULL; 134 return NULL;
83} 135}
84 136
137/**
138 * @brief Start to spy a file.
139 * @param spy Spy structure to attach file to.
140 * @param file File to start spying.
141 * @return Pointer to newly allocated Spy_File structure.
142 *
143 * This function will add a timer that will periodically look for changes
144 * on the file, and report every new line inserted into it.
145 */
85Spy_File * 146Spy_File *
86spy_file_new(Spy *spy, const char *file) 147spy_file_new(Spy *spy, const char *file)
87{ 148{
@@ -138,7 +199,10 @@ free_sf:
138 return NULL; 199 return NULL;
139} 200}
140 201
141 202/**
203 * @brief Initialize spy and all it's required submodules.
204 * @return 1 or greater on success, 0 otherwise.
205 */
142int 206int
143spy_init(void) 207spy_init(void)
144{ 208{
@@ -176,7 +240,13 @@ shutdown_eina:
176 return --_spy_init_count; 240 return --_spy_init_count;
177} 241}
178 242
179 243/**
244 * @brief Shutdown spy and all it's submodules if possible.
245 *
246 * @return 0 if spy shuts down, greater than 0 otherwise.
247 * This function shuts down all things set up in spy_init()
248 * and cleans up its memory.
249 */
180int 250int
181spy_shutdown(void) 251spy_shutdown(void)
182{ 252{
@@ -195,3 +265,7 @@ spy_shutdown(void)
195 eina_shutdown(); 265 eina_shutdown();
196 return _spy_init_count; 266 return _spy_init_count;
197} 267}
268
269/**
270 * @}
271 */