EFL core migration @74576
[framework/uifw/ecore.git] / src / examples / ecore_fd_handler_example.c
index d80b290..381d101 100644 (file)
@@ -1,9 +1,10 @@
 #include <Ecore.h>
 #include <unistd.h>
 
-struct context {
-     Ecore_Fd_Handler *handler;
-     Ecore_Timer *timer;
+struct context
+{
+   Ecore_Fd_Handler *handler;
+   Ecore_Timer      *timer;
 };
 
 static void
@@ -22,20 +23,20 @@ _fd_handler_cb(void *data, Ecore_Fd_Handler *handler)
 
    if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
      {
-       printf("An error has occurred. Stop watching this fd and quit.\n");
-       ecore_main_loop_quit();
-       ctxt->handler = NULL;
-       return ECORE_CALLBACK_CANCEL;
+        printf("An error has occurred. Stop watching this fd and quit.\n");
+        ecore_main_loop_quit();
+        ctxt->handler = NULL;
+        return ECORE_CALLBACK_CANCEL;
      }
 
    fd = ecore_main_fd_handler_fd_get(handler);
    nbytes = read(fd, buf, sizeof(buf));
    if (nbytes == 0)
      {
-       printf("Nothing to read, exiting...\n");
-       ecore_main_loop_quit();
-       ctxt->handler = NULL;
-       return ECORE_CALLBACK_CANCEL;
+        printf("Nothing to read, exiting...\n");
+        ecore_main_loop_quit();
+        ctxt->handler = NULL;
+        return ECORE_CALLBACK_CANCEL;
      }
    buf[nbytes - 1] = '\0';
 
@@ -52,25 +53,26 @@ _timer_cb(void *data)
    return ECORE_CALLBACK_RENEW;
 }
 
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
 {
    struct context ctxt = {0};
 
    if (!ecore_init())
      {
-       printf("ERROR: Cannot init Ecore!\n");
-       return -1;
+        printf("ERROR: Cannot init Ecore!\n");
+        return -1;
      }
 
    ctxt.handler = ecore_main_fd_handler_add(STDIN_FILENO,
-                                           ECORE_FD_READ | ECORE_FD_ERROR,
-                                           _fd_handler_cb,
-                                           &ctxt, NULL, NULL);
+                                            ECORE_FD_READ | ECORE_FD_ERROR,
+                                            _fd_handler_cb,
+                                            &ctxt, NULL, NULL);
    ecore_main_fd_handler_prepare_callback_set(ctxt.handler, _fd_prepare_cb, &ctxt);
    ctxt.timer = ecore_timer_add(5, _timer_cb, &ctxt);
 
    printf("Starting the main loop. Type anything and hit <enter> to "
-         "activate the fd_handler callback, or CTRL+d to shutdown.\n");
+          "activate the fd_handler callback, or CTRL+d to shutdown.\n");
 
    ecore_main_loop_begin();
 
@@ -84,3 +86,4 @@ int main(int argc, char **argv)
 
    return 0;
 }
+