This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efm2.
View the commit online.
commit 618e7c05ae63a9f212c27401fd63c2b5a697fd61
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Wed Jun 5 17:48:00 2024 +0100
tidy some status code and handle initial list
---
src/shared/status_mon.c | 81 ++++++++++++++++++++++++-------------------------
1 file changed, 40 insertions(+), 41 deletions(-)
diff --git a/src/shared/status_mon.c b/src/shared/status_mon.c
index 514830e..33b342e 100644
--- a/src/shared/status_mon.c
+++ b/src/shared/status_mon.c
@@ -88,6 +88,8 @@ status_op_read(Status_Op *so)
char buf[PATH_MAX + 256];
Cmd *cmd;
long pos;
+ Eina_List *l;
+ Status_Callback *sc;
pos = ftell(so->file);
fseek(so->file, pos, SEEK_SET);
@@ -97,28 +99,22 @@ status_op_read(Status_Op *so)
if (sz < 1) continue;
buf[sz - 1] = 0; // nuke \n
- printf(" READ CMD [%s]\n", buf);
cmd = cmd_parse(buf);
- if (cmd)
- {
- Eina_List *l;
- Status_Callback *sc;
-
- cbs_walk++;
- EINA_LIST_FOREACH(cbs, l, sc) sc->cb(sc->data, so, cmd);
- cbs_walk--;
- status_callback_clean();
- cmd_free(cmd);
- }
+ if (!cmd) continue;
+ cbs_walk++;
+ EINA_LIST_FOREACH(cbs, l, sc) sc->cb(sc->data, so, cmd);
+ cbs_walk--;
+ status_callback_clean();
+ cmd_free(cmd);
}
}
static void
_file_add(const char *path)
{
- Status_Op *so;
-
- fprintf(stderr, "ADD %s\n", path);
+ Status_Op *so = status_op_find(path);
+
+ if (so) return; // it already exists - don't do anything
so = status_op_add(path);
if (so) status_op_read(so);
}
@@ -126,48 +122,39 @@ _file_add(const char *path)
static void
_file_del(const char *path)
{
- Status_Op *so;
+ Status_Op *so = status_op_find(path);
+ Eina_List *l;
+ Status_Callback *sc;
- fprintf(stderr, "DEL %s\n", path);
- so = status_op_find(path);
- if (so)
- {
- Eina_List *l;
- Status_Callback *sc;
+ if (!so) return;
- cbs_walk++;
- EINA_LIST_FOREACH(cbs, l, sc) sc->cb(sc->data, so, NULL);
- cbs_walk--;
- status_callback_clean();
- status_op_del(so);
- }
+ cbs_walk++;
+ EINA_LIST_FOREACH(cbs, l, sc) sc->cb(sc->data, so, NULL);
+ cbs_walk--;
+ status_callback_clean();
+ status_op_del(so);
}
static void
_file_mod(const char *path)
{
- Status_Op *so;
+ Status_Op *so = status_op_find(path);
- fprintf(stderr, "MOD %s\n", path);
- so = status_op_find(path);
if (so) status_op_read(so);
}
static void
_cb_mon(void *data EINA_UNUSED, Ecore_File_Monitor *em EINA_UNUSED,
Ecore_File_Event event, const char *path)
-{
- if ((event == ECORE_FILE_EVENT_CREATED_FILE)
- || (event == ECORE_FILE_EVENT_CREATED_DIRECTORY))
- _file_add(path);
- else if ((event == ECORE_FILE_EVENT_DELETED_FILE)
- || (event == ECORE_FILE_EVENT_DELETED_DIRECTORY))
- _file_del(path);
- else if (event == ECORE_FILE_EVENT_MODIFIED) _file_mod(path);
+{ // a efm ops dir event happened - deal with it
+ if (event == ECORE_FILE_EVENT_CREATED_FILE) _file_add(path);
+ else if (event == ECORE_FILE_EVENT_DELETED_FILE) _file_del(path);
+ else if (event == ECORE_FILE_EVENT_MODIFIED) _file_mod(path);
}
-void status_mon_init(void)
-{
+void
+status_mon_init(void)
+{ // for completenexx - does nothing at the moment
}
void
@@ -209,15 +196,27 @@ status_mon_callback_del(Status_Mon_Callback cb, void *data)
void
status_mon_begin(void)
{
+ Eina_Iterator *it;
+ Eina_File_Direct_Info *info;
char buf[PATH_MAX];
+ // where is the efm ops dir
eina_vpath_resolve_snprintf(buf, sizeof(buf), "(:usr.run:)/efm/ops");
ecore_file_mkpath(buf);
+ // monitor for file changes in the ops dir
mon = ecore_file_monitor_add(buf, _cb_mon, NULL);
+ // list what is there right now to begin with
+ it = eina_file_direct_ls(buf);
+ if (it)
+ {
+ EINA_ITERATOR_FOREACH(it, info) _file_add(info->path);
+ eina_iterator_free(it);
+ }
}
void status_mon_shutdown(void)
{
if (mon) ecore_file_monitor_del(mon);
mon = NULL;
+ // XXX: delete so's
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.