diff --git a/include/fsm.h b/include/fsm.h index 08cb114..92d792b 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -67,13 +67,13 @@ void fsm_journal_push_front_from_fsm (char *message); // id fro long fsm_journal_pop_back (journal *jj, char *message); // retire un évènement en fin de journal int fsm_journal_length (journal jj); // nombre d'évènements dans le journal void fsm_journal_seek (journal jj, long usec, char *message); // recherche un évènement dans le journal -void fsm_journal_publish (journal jj, char *message); // affiche tout le journal +void fsm_journal_publish (journal jj); // affiche tout le journal void fsm_journal_test (char *message); // --------------------------------------------------------------- WIP ------ // ref: sudo cat /var/log/messages // journal fsm_get_journal(); // def: fsm/dispatch call: fsm/prefer/fsm_store_restore_reset() -void fsm_journal_publication_request (char *message); // def: fsm/dispatch call: widget/dispatch; +void fsm_journal_publication_request (); // def: fsm/dispatch call: main; void fsm_journal_widget_event (char *message, int priority); // def: fsm/dispatch call: widget/dispatch; // --------------------------------------------------------------- WIP ------ diff --git a/src/fsm/dispatch.c b/src/fsm/dispatch.c index 65e25c8..5cf8f69 100644 --- a/src/fsm/dispatch.c +++ b/src/fsm/dispatch.c @@ -74,7 +74,7 @@ void fsm_init() fsm_journal_push_front (&gologos, "fsm fsm_init() end"); } -void fsm_journal_publication_request (char *message) {fsm_journal_publish (gologos, message);} +void fsm_journal_publication_request () {fsm_journal_publish (gologos);} void fsm_journal_widget_event (char *message, int priority) { if (priority > PRIORITY_0) // consider: >= instead 😄️ diff --git a/src/fsm/journal.c b/src/fsm/journal.c index 1e6566b..706fdb9 100644 --- a/src/fsm/journal.c +++ b/src/fsm/journal.c @@ -123,50 +123,25 @@ void fsm_journal_seek (journal jj, long usec, char *message) } -//------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ + // Format time, "ddd yyyy-mm-dd hh:mm:ss zzz" "%Y-%m-%d %H:%M:%S" + // https://www.man7.org/linux/man-pages/man3/strftime.3.html + // https://en.cppreference.com/w/c/io/fprintf + // https://nicolasj.developpez.com/articles/libc/string/ + // https://thelinuxcode.com/pass-string-function-c-language/ +//------------------------------------------------------------------------------ -#define __STDC_WANT_LIB_EXT1__ 1 - -void fsm_journal_publish (journal jj, char *message) +void fsm_journal_publish (journal jj) { unit *a_unit = jj.last; char buf [JOURNAL_DATE_MAX_LENGTH]; int nb = 0; while (a_unit) { - // Format time, "ddd yyyy-mm-dd hh:mm:ss zzz" "%Y-%m-%d %H:%M:%S" - // https://www.man7.org/linux/man-pages/man3/strftime.3.html - // https://en.cppreference.com/w/c/io/fprintf - // https://nicolasj.developpez.com/articles/libc/string/ - // https://thelinuxcode.com/pass-string-function-c-language/ strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm)); printf ("%s + %6ld %6d %s\n", buf, a_unit->usec, nb, a_unit->message); a_unit = a_unit->prev; nb ++; } - - struct timeval tv; - gettimeofday(&tv, NULL); - long yy_dd_mm = tv.tv_sec; -// long usec = tv.tv_usec; << how to use if (format) - - strftime(buf, sizeof(buf), "%D %T", localtime(&yy_dd_mm)); - - printf ("%s + %6d %s\n", buf, nb, message); } -// -/* -void modifyString(char *str) { - *str = ‘J‘; // Dereference to change first char -} - -int fonction_appelante() { - char myString[] = "Hello World"; - modifyString(myString); - printf("%s", myString); // Prints Jello World -} - -Because modifyString receives a pointer to the string, -it can modify the original by dereferencing. -*/ diff --git a/src/main.c b/src/main.c index 8b97397..259460f 100644 --- a/src/main.c +++ b/src/main.c @@ -145,7 +145,9 @@ int main (int argc, char **argv) int status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); - fsm_journal_publication_request ("main That'all folks ! 👋️😄️"); + fsm_journal_push_front_from_fsm ("main That'all folks ! 👋️😄️"); + fsm_journal_publication_request(); + return status; }