Examples of Codes for EFL

This page includes some Tips and Tricks for EFL, you can found here a lot of chunks of examples of nice and useful things

You can consider this page as a kind of fast reference

Chunks of codes

Exe Handler

Run an external command and set a handler (listener) to run a function when it has finished (exited), it also can know the exit code value of the command launched

#include <stdio.h>
#include <Ecore.h>

typedef struct _Handy Handy;
struct _Handy
   Ecore_Exe *gen_exe;
   Ecore_Event_Handler *handler;

static int
   // Run this just in order to demonstrate that we are not catching the events anymore (handlers deleted previously)
   ecore_exe_run("echo 'running something extra (_run_cb) for check handler' ; sleep 1 ; false", NULL);

static int
_del_cb(void *data, int type, void *event)
   Ecore_Exe_Event_Del *ev;
   Handy *hand = NULL;

   ev = event;
   hand = data;

   if (hand)
      hand->handler = NULL;
      hand->gen_exe = NULL;
      printf("handlers deleted\n");

   if (ev->exit_code == 1) // this is the return exit code by the job run before
      printf("exit code (1) returned from command\n");
      _run_cb(); // This is not needed, is just a checker of that the handler has really finished (deleted)

      printf("hand freed\n");


int main (int argc, char **argv) {


   Handy *hand = NULL;
   hand = calloc(1, sizeof(Handy));

   // Add event handler to call _del_cb when the job is finished (deleted), also pass the structure hand
   hand->handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _del_cb, hand);
   // run something, and return false in order to catch the 'error' exit code (1)
   hand->gen_exe = ecore_exe_run("echo running command ; sleep 1 ; echo command finished ; false", hand);




Last modified 4 years ago Last modified on Sep 16, 2019, 5:25:19 AM
Note: See TracWiki for help on using the wiki.