From: caro Date: Thu, 30 Sep 2010 06:09:20 +0000 (+0000) Subject: tab-- X-Git-Tag: 2.0_alpha~194^2~559 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=238378b2be435d1255cf0c7be1e873f8fad98aee;p=framework%2Fuifw%2Fecore.git tab-- git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@52918 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h index f547f5e..a70fa21 100644 --- a/src/lib/ecore/Ecore.h +++ b/src/lib/ecore/Ecore.h @@ -107,23 +107,23 @@ extern "C" { enum _Ecore_Fd_Handler_Flags { - ECORE_FD_READ = 1, /**< Fd Read mask */ - ECORE_FD_WRITE = 2, /**< Fd Write mask */ - ECORE_FD_ERROR = 4 /**< Fd Error mask */ + ECORE_FD_READ = 1, /**< Fd Read mask */ + ECORE_FD_WRITE = 2, /**< Fd Write mask */ + ECORE_FD_ERROR = 4 /**< Fd Error mask */ }; typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags; enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */ { - ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */ - ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */ - ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */ - ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */ - ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */ - ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */ - ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */ - ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */ - ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */ + ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */ + ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */ + ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */ + ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */ + ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */ + ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */ + ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */ + ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */ + ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */ }; typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags; @@ -140,7 +140,7 @@ extern "C" { enum _Ecore_Poller_Type /* Poller types */ { - ECORE_POLLER_CORE = 0 /**< The core poller interval */ + ECORE_POLLER_CORE = 0 /**< The core poller interval */ }; typedef enum _Ecore_Poller_Type Ecore_Poller_Type; @@ -244,85 +244,85 @@ extern "C" { struct _Ecore_Event_Signal_User /** User signal event */ { - int number; /**< The signal number. Either 1 or 2 */ - void *ext_data; /**< Extension data - not used */ + int number; /**< The signal number. Either 1 or 2 */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Event_Signal_Hup /** Hup signal event */ { - void *ext_data; /**< Extension data - not used */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Event_Signal_Exit /** Exit request event */ { - unsigned int interrupt : 1; /**< Set if the exit request was an interrupt signal*/ - unsigned int quit : 1; /**< set if the exit request was a quit signal */ - unsigned int terminate : 1; /**< Set if the exit request was a terminate singal */ - void *ext_data; /**< Extension data - not used */ + unsigned int interrupt : 1; /**< Set if the exit request was an interrupt signal*/ + unsigned int quit : 1; /**< set if the exit request was a quit signal */ + unsigned int terminate : 1; /**< Set if the exit request was a terminate singal */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Event_Signal_Power /** Power event */ { - void *ext_data; /**< Extension data - not used */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Event_Signal_Realtime /** Realtime event */ { - int num; /**< The realtime signal's number */ + int num; /**< The realtime signal's number */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Exe_Event_Add /** Process add event */ { - Ecore_Exe *exe; /**< The handle to the added process */ - void *ext_data; /**< Extension data - not used */ + Ecore_Exe *exe; /**< The handle to the added process */ + void *ext_data; /**< Extension data - not used */ }; struct _Ecore_Exe_Event_Del /** Process exit event */ { - pid_t pid; /**< The process ID of the process that exited */ - int exit_code; /**< The exit code of the process */ - Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */ - int exit_signal; /** < The signal that caused the process to exit */ - unsigned int exited : 1; /** < set to 1 if the process exited of its own accord */ - unsigned int signalled : 1; /** < set to 1 id the process exited due to uncaught signal */ - void *ext_data; /**< Extension data - not used */ + pid_t pid; /**< The process ID of the process that exited */ + int exit_code; /**< The exit code of the process */ + Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */ + int exit_signal; /** < The signal that caused the process to exit */ + unsigned int exited : 1; /** < set to 1 if the process exited of its own accord */ + unsigned int signalled : 1; /** < set to 1 id the process exited due to uncaught signal */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */ { char *line; - int size; + int size; }; struct _Ecore_Exe_Event_Data /** Data from a child process event */ { - Ecore_Exe *exe; /**< The handle to the process */ - void *data; /**< the raw binary data from the child process that was received */ - int size; /**< the size of this data in bytes */ - Ecore_Exe_Event_Data_Line *lines; /**< an array of line data if line buffered, the last one has it's line member set to NULL */ + Ecore_Exe *exe; /**< The handle to the process */ + void *data; /**< the raw binary data from the child process that was received */ + int size; /**< the size of this data in bytes */ + Ecore_Exe_Event_Data_Line *lines; /**< an array of line data if line buffered, the last one has it's line member set to NULL */ }; EAPI int ecore_init(void); @@ -413,11 +413,11 @@ extern "C" { Ecore_Cb, const void *data); EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb, - Ecore_Thread_Notify_Cb, - Ecore_Cb, - Ecore_Cb, - const void *data, - Eina_Bool try_no_queue); + Ecore_Thread_Notify_Cb, + Ecore_Cb, + Ecore_Cb, + const void *data, + Eina_Bool try_no_queue); EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread); EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread); EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread *thread, const void *msg_data); @@ -463,8 +463,8 @@ extern "C" { EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, const void *data); EAPI void *ecore_animator_del(Ecore_Animator *animator); - EAPI void ecore_animator_freeze(Ecore_Animator *animator); - EAPI void ecore_animator_thaw(Ecore_Animator *animator); + EAPI void ecore_animator_freeze(Ecore_Animator *animator); + EAPI void ecore_animator_thaw(Ecore_Animator *animator); EAPI void ecore_animator_frametime_set(double frametime); EAPI double ecore_animator_frametime_get(void); diff --git a/src/lib/ecore/Ecore_Getopt.h b/src/lib/ecore/Ecore_Getopt.h index f2ea6f7..18a8459 100644 --- a/src/lib/ecore/Ecore_Getopt.h +++ b/src/lib/ecore/Ecore_Getopt.h @@ -114,15 +114,15 @@ extern "C" { Ecore_Getopt_Desc_Arg_Requirement arg_req; union { - const char *strv; - unsigned char boolv; - short shortv; - int intv; - long longv; - unsigned short ushortv; - unsigned int uintv; - unsigned long ulongv; - double doublev; + const char *strv; + unsigned char boolv; + short shortv; + int intv; + long longv; + unsigned short ushortv; + unsigned int uintv; + unsigned long ulongv; + double doublev; } def; }; @@ -144,12 +144,12 @@ extern "C" { Ecore_Getopt_Action action; /**< define how to handle it */ union { - const Ecore_Getopt_Desc_Store store; - const void *store_const; - const char *const *choices; /* NULL terminated. */ - const Ecore_Getopt_Type append_type; - const Ecore_Getopt_Desc_Callback callback; - const void *dummy; + const Ecore_Getopt_Desc_Store store; + const void *store_const; + const char *const *choices; /* NULL terminated. */ + const Ecore_Getopt_Type append_type; + const Ecore_Getopt_Desc_Callback callback; + const void *dummy; } action_param; }; @@ -166,12 +166,12 @@ extern "C" { }; #define ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, arg_requirement, default_value) \ - {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \ + {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \ {.store = {type, arg_requirement, default_value}}} #define ECORE_GETOPT_STORE(shortname, longname, help, type) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) #define ECORE_GETOPT_STORE_STR(shortname, longname, help) \ ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_STR) @@ -194,8 +194,8 @@ extern "C" { #define ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, type) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) #define ECORE_GETOPT_STORE_METAVAR_STR(shortname, longname, help, metavar) \ ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_STR) @@ -218,155 +218,155 @@ extern "C" { #define ECORE_GETOPT_STORE_DEF(shortname, longname, help, type, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \ - default_value) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \ + default_value) #define ECORE_GETOPT_STORE_DEF_STR(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_STR, \ - {.strv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_STR, \ + {.strv = default_value}) #define ECORE_GETOPT_STORE_DEF_BOOL(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_BOOL, \ - {.boolv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_BOOL, \ + {.boolv = default_value}) #define ECORE_GETOPT_STORE_DEF_SHORT(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_SHORT, \ - {.shortv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_SHORT, \ + {.shortv = default_value}) #define ECORE_GETOPT_STORE_DEF_INT(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_INT, \ - {.intv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_INT, \ + {.intv = default_value}) #define ECORE_GETOPT_STORE_DEF_LONG(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_LONG, \ - {.longv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_LONG, \ + {.longv = default_value}) #define ECORE_GETOPT_STORE_DEF_USHORT(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_USHORT, \ - {.ushortv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_USHORT, \ + {.ushortv = default_value}) #define ECORE_GETOPT_STORE_DEF_UINT(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_UINT, \ - {.uintv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_UINT, \ + {.uintv = default_value}) #define ECORE_GETOPT_STORE_DEF_ULONG(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_ULONG, \ - {.ulongv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_ULONG, \ + {.ulongv = default_value}) #define ECORE_GETOPT_STORE_DEF_DOUBLE(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_DOUBLE, \ - {.doublev = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_DOUBLE, \ + {.doublev = default_value}) #define ECORE_GETOPT_STORE_FULL_STR(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_STR, \ - arg_requirement, \ - {.strv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_STR, \ + arg_requirement, \ + {.strv = default_value}) #define ECORE_GETOPT_STORE_FULL_BOOL(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_BOOL, \ - arg_requirement, \ - {.boolv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_BOOL, \ + arg_requirement, \ + {.boolv = default_value}) #define ECORE_GETOPT_STORE_FULL_SHORT(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_SHORT, \ - arg_requirement, \ - {.shortv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_SHORT, \ + arg_requirement, \ + {.shortv = default_value}) #define ECORE_GETOPT_STORE_FULL_INT(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_INT, \ - arg_requirement, \ - {.intv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_INT, \ + arg_requirement, \ + {.intv = default_value}) #define ECORE_GETOPT_STORE_FULL_LONG(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_LONG, \ - arg_requirement, \ - {.longv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_LONG, \ + arg_requirement, \ + {.longv = default_value}) #define ECORE_GETOPT_STORE_FULL_USHORT(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_USHORT, \ - arg_requirement, \ - {.ushortv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_USHORT, \ + arg_requirement, \ + {.ushortv = default_value}) #define ECORE_GETOPT_STORE_FULL_UINT(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_UINT, \ - arg_requirement, \ - {.uintv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_UINT, \ + arg_requirement, \ + {.uintv = default_value}) #define ECORE_GETOPT_STORE_FULL_ULONG(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_ULONG, \ - arg_requirement, \ - {.ulongv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_ULONG, \ + arg_requirement, \ + {.ulongv = default_value}) #define ECORE_GETOPT_STORE_FULL_DOUBLE(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_DOUBLE, \ - arg_requirement, \ - {.doublev = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_DOUBLE, \ + arg_requirement, \ + {.doublev = default_value}) -#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \ +#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \ {.store_const = value}} -#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \ +#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \ {.dummy = NULL}} -#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \ +#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \ {.dummy = NULL}} -#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \ +#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \ {.choices = choices_array}} #define ECORE_GETOPT_CHOICE_METAVAR(shortname, longname, help, metavar, choices_array) \ - {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \ + {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \ {.choices = choices_array}} -#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \ +#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \ {.append_type = sub_type}} #define ECORE_GETOPT_APPEND_METAVAR(shortname, longname, help, metavar, type) \ - {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \ + {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \ {.append_type = type}} -#define ECORE_GETOPT_COUNT(shortname, longname, help) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \ +#define ECORE_GETOPT_COUNT(shortname, longname, help) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \ {.dummy = NULL}} #define ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, callback_func, callback_data, argument_requirement, default_value) \ - {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \ - {.callback = {callback_func, callback_data, \ - argument_requirement, default_value}}} + {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \ + {.callback = {callback_func, callback_data, \ + argument_requirement, default_value}}} #define ECORE_GETOPT_CALLBACK_NOARGS(shortname, longname, help, callback_func, callback_data) \ - ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \ - callback_func, callback_data, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO, \ - NULL) + ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \ + callback_func, callback_data, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO, \ + NULL) #define ECORE_GETOPT_CALLBACK_ARGS(shortname, longname, help, metavar, callback_func, callback_data) \ - ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, \ - callback_func, callback_data, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, \ - NULL) - -#define ECORE_GETOPT_HELP(shortname, longname) \ - {shortname, longname, "show this message.", NULL, \ - ECORE_GETOPT_ACTION_HELP, \ + ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, \ + callback_func, callback_data, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, \ + NULL) + +#define ECORE_GETOPT_HELP(shortname, longname) \ + {shortname, longname, "show this message.", NULL, \ + ECORE_GETOPT_ACTION_HELP, \ {.dummy = NULL}} -#define ECORE_GETOPT_VERSION(shortname, longname) \ - {shortname, longname, "show program version.", NULL, \ - ECORE_GETOPT_ACTION_VERSION, \ +#define ECORE_GETOPT_VERSION(shortname, longname) \ + {shortname, longname, "show program version.", NULL, \ + ECORE_GETOPT_ACTION_VERSION, \ {.dummy = NULL}} -#define ECORE_GETOPT_COPYRIGHT(shortname, longname) \ - {shortname, longname, "show copyright.", NULL, \ - ECORE_GETOPT_ACTION_COPYRIGHT, \ +#define ECORE_GETOPT_COPYRIGHT(shortname, longname) \ + {shortname, longname, "show copyright.", NULL, \ + ECORE_GETOPT_ACTION_COPYRIGHT, \ {.dummy = NULL}} -#define ECORE_GETOPT_LICENSE(shortname, longname) \ - {shortname, longname, "show license.", NULL, \ - ECORE_GETOPT_ACTION_LICENSE, \ +#define ECORE_GETOPT_LICENSE(shortname, longname) \ + {shortname, longname, "show license.", NULL, \ + ECORE_GETOPT_ACTION_LICENSE, \ {.dummy = NULL}} #define ECORE_GETOPT_SENTINEL {0, NULL, NULL, NULL, 0, {.dummy = NULL}} diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index 8f2a045..5b0789c 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -38,8 +38,8 @@ static Ecore_Version _version = { VERS_MAJ, VERS_MIN, VERS_MIC, VERS_REV }; EAPI Ecore_Version *ecore_version = &_version; -#define KEEP_MAX(Global, Local) \ - if (Global < (Local)) \ +#define KEEP_MAX(Global, Local) \ + if (Global < (Local)) \ Global = Local; static Eina_Bool _ecore_memory_statistic(void *data); @@ -95,7 +95,7 @@ ecore_init(void) /* if (strcmp(nl_langinfo(CODESET), "UTF-8")) { - WRN("Not a utf8 locale!"); + WRN("Not a utf8 locale!"); } */ #ifdef HAVE_EVIL @@ -122,8 +122,8 @@ ecore_init(void) #if HAVE_MALLINFO if (getenv("ECORE_MEM_STAT")) { - _ecore_memory_pid = getpid(); - ecore_animator_add(_ecore_memory_statistic, NULL); + _ecore_memory_pid = getpid(); + ecore_animator_add(_ecore_memory_statistic, NULL); } #endif @@ -177,12 +177,12 @@ ecore_shutdown(void) #if HAVE_MALLINFO if (getenv("ECORE_MEM_STAT")) { - _ecore_memory_statistic(NULL); + _ecore_memory_statistic(NULL); - ERR("[%i] Memory MAX total: %i, free: %i", - _ecore_memory_pid, - _ecore_memory_max_total, - _ecore_memory_max_free); + ERR("[%i] Memory MAX total: %i, free: %i", + _ecore_memory_pid, + _ecore_memory_max_total, + _ecore_memory_max_free); } #endif @@ -220,13 +220,13 @@ _ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *f ERR(" Input handle has already been freed!"); else if (m != req_m) ERR(" Input handle is wrong type\n" - " Expected: %08x - %s\n" - " Supplied: %08x - %s", - (unsigned int)req_m, _ecore_magic_string_get(req_m), - (unsigned int)m, _ecore_magic_string_get(m)); + " Expected: %08x - %s\n" + " Supplied: %08x - %s", + (unsigned int)req_m, _ecore_magic_string_get(req_m), + (unsigned int)m, _ecore_magic_string_get(m)); ERR("*** NAUGHTY PROGRAMMER!!!\n" - "*** SPANK SPANK SPANK!!!\n" - "*** Now go fix your code. Tut tut tut!"); + "*** SPANK SPANK SPANK!!!\n" + "*** Now go fix your code. Tut tut tut!"); if (getenv("ECORE_ERROR_ABORT")) abort(); } @@ -236,37 +236,37 @@ _ecore_magic_string_get(Ecore_Magic m) switch (m) { case ECORE_MAGIC_NONE: - return "None (Freed Object)"; - break; + return "None (Freed Object)"; + break; case ECORE_MAGIC_EXE: - return "Ecore_Exe (Executable)"; - break; + return "Ecore_Exe (Executable)"; + break; case ECORE_MAGIC_TIMER: - return "Ecore_Timer (Timer)"; - break; + return "Ecore_Timer (Timer)"; + break; case ECORE_MAGIC_IDLER: - return "Ecore_Idler (Idler)"; - break; + return "Ecore_Idler (Idler)"; + break; case ECORE_MAGIC_IDLE_ENTERER: - return "Ecore_Idle_Enterer (Idler Enterer)"; - break; + return "Ecore_Idle_Enterer (Idler Enterer)"; + break; case ECORE_MAGIC_IDLE_EXITER: - return "Ecore_Idle_Exiter (Idler Exiter)"; - break; + return "Ecore_Idle_Exiter (Idler Exiter)"; + break; case ECORE_MAGIC_FD_HANDLER: - return "Ecore_Fd_Handler (Fd Handler)"; - break; + return "Ecore_Fd_Handler (Fd Handler)"; + break; case ECORE_MAGIC_WIN32_HANDLER: - return "Ecore_Win32_Handler (Win32 Handler)"; - break; + return "Ecore_Win32_Handler (Win32 Handler)"; + break; case ECORE_MAGIC_EVENT_HANDLER: - return "Ecore_Event_Handler (Event Handler)"; - break; + return "Ecore_Event_Handler (Event Handler)"; + break; case ECORE_MAGIC_EVENT: - return "Ecore_Event (Event)"; - break; + return "Ecore_Event (Event)"; + break; default: - return ""; + return ""; }; } @@ -298,40 +298,40 @@ _ecore_fps_debug_init(void) _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); if (_ecore_fps_debug_fd < 0) { - unlink(buf); - _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); + unlink(buf); + _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); } if (_ecore_fps_debug_fd >= 0) { - unsigned int zero = 0; - char *buf = (char *)&zero; - ssize_t todo = sizeof(unsigned int); - - while (todo > 0) - { - ssize_t r = write(_ecore_fps_debug_fd, buf, todo); - if (r > 0) - { - todo -= r; - buf += r; - } - else if ((r < 0) && (errno == EINTR)) - continue; - else - { - ERR("could not write to file '%s' fd %d: %s", - tmp, _ecore_fps_debug_fd, strerror(errno)); - close(_ecore_fps_debug_fd); - _ecore_fps_debug_fd = -1; - return; - } - } - _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int), - PROT_READ | PROT_WRITE, - MAP_SHARED, - _ecore_fps_debug_fd, 0); - if (_ecore_fps_runtime_mmap == MAP_FAILED) - _ecore_fps_runtime_mmap = NULL; + unsigned int zero = 0; + char *buf = (char *)&zero; + ssize_t todo = sizeof(unsigned int); + + while (todo > 0) + { + ssize_t r = write(_ecore_fps_debug_fd, buf, todo); + if (r > 0) + { + todo -= r; + buf += r; + } + else if ((r < 0) && (errno == EINTR)) + continue; + else + { + ERR("could not write to file '%s' fd %d: %s", + tmp, _ecore_fps_debug_fd, strerror(errno)); + close(_ecore_fps_debug_fd); + _ecore_fps_debug_fd = -1; + return; + } + } + _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int), + PROT_READ | PROT_WRITE, + MAP_SHARED, + _ecore_fps_debug_fd, 0); + if (_ecore_fps_runtime_mmap == MAP_FAILED) + _ecore_fps_runtime_mmap = NULL; } } @@ -352,15 +352,15 @@ _ecore_fps_debug_shutdown(void) tmp = (char *)evil_tmpdir_get (); #endif /* HAVE_EVIL */ pid = (int)getpid(); - snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid); - unlink(buf); - if (_ecore_fps_runtime_mmap) - { - munmap(_ecore_fps_runtime_mmap, sizeof(int)); - _ecore_fps_runtime_mmap = NULL; - } - close(_ecore_fps_debug_fd); - _ecore_fps_debug_fd = -1; + snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid); + unlink(buf); + if (_ecore_fps_runtime_mmap) + { + munmap(_ecore_fps_runtime_mmap, sizeof(int)); + _ecore_fps_runtime_mmap = NULL; + } + close(_ecore_fps_debug_fd); + _ecore_fps_debug_fd = -1; } } @@ -370,16 +370,16 @@ _ecore_fps_debug_runtime_add(double t) if ((_ecore_fps_debug_fd >= 0) && (_ecore_fps_runtime_mmap)) { - unsigned int tm; - - tm = (unsigned int)(t * 1000000.0); - /* i know its not 100% theoretically guaranteed, but i'd say a write */ - /* of an int could be considered atomic for all practical purposes */ - /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */ - /* this can run for about 4294 seconds becore looping. if you are */ - /* doing performance testing in one run for over an hour... well */ - /* time to restart or handle a loop condition :) */ - *(_ecore_fps_runtime_mmap) += tm; + unsigned int tm; + + tm = (unsigned int)(t * 1000000.0); + /* i know its not 100% theoretically guaranteed, but i'd say a write */ + /* of an int could be considered atomic for all practical purposes */ + /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */ + /* this can run for about 4294 seconds becore looping. if you are */ + /* doing performance testing in one run for over an hour... well */ + /* time to restart or handle a loop condition :) */ + *(_ecore_fps_runtime_mmap) += tm; } } @@ -394,11 +394,11 @@ _ecore_memory_statistic(__UNUSED__ void *data) mi = mallinfo(); -#define HAS_CHANGED(Global, Local) \ - if (Global != Local) \ - { \ - Global = Local; \ - changed = EINA_TRUE; \ +#define HAS_CHANGED(Global, Local) \ + if (Global != Local) \ + { \ + Global = Local; \ + changed = EINA_TRUE; \ } HAS_CHANGED(uordblks, mi.uordblks); @@ -406,9 +406,9 @@ _ecore_memory_statistic(__UNUSED__ void *data) if (changed) ERR("[%i] Memory total: %i, free: %i", - _ecore_memory_pid, - mi.uordblks, - mi.fordblks); + _ecore_memory_pid, + mi.uordblks, + mi.fordblks); KEEP_MAX(_ecore_memory_max_total, mi.uordblks); KEEP_MAX(_ecore_memory_max_free, mi.fordblks); diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c index b5cd5ed..921071e 100644 --- a/src/lib/ecore/ecore_anim.c +++ b/src/lib/ecore/ecore_anim.c @@ -18,7 +18,7 @@ struct _Ecore_Animator void *data; Eina_Bool delete_me : 1; - Eina_Bool suspended : 1; + Eina_Bool suspended : 1; }; @@ -87,9 +87,9 @@ ecore_animator_del(Ecore_Animator *animator) { if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) { - ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, - "ecore_animator_del"); - return NULL; + ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, + "ecore_animator_del"); + return NULL; } if (animator->delete_me) return animator->data; animator->delete_me = EINA_TRUE; @@ -111,8 +111,8 @@ ecore_animator_frametime_set(double frametime) animators_frametime = frametime; if (timer) { - ecore_timer_del(timer); - timer = NULL; + ecore_timer_del(timer); + timer = NULL; } if (animators) timer = ecore_timer_add(animators_frametime, _ecore_animator, NULL); @@ -143,9 +143,9 @@ ecore_animator_freeze(Ecore_Animator *animator) { if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) { - ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, - "ecore_animator_del"); - return; + ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, + "ecore_animator_del"); + return; } if (animator->delete_me) return; animator->suspended = EINA_TRUE; @@ -164,9 +164,9 @@ ecore_animator_thaw(Ecore_Animator *animator) { if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) { - ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, - "ecore_animator_del"); - return; + ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, + "ecore_animator_del"); + return; } if (animator->delete_me) return; animator->suspended = EINA_FALSE; @@ -177,17 +177,17 @@ _ecore_animator_shutdown(void) { if (timer) { - ecore_timer_del(timer); - timer = NULL; + ecore_timer_del(timer); + timer = NULL; } while (animators) { - Ecore_Animator *animator; + Ecore_Animator *animator; - animator = animators; - animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators)); - ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); - free(animator); + animator = animators; + animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators)); + ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); + free(animator); } } @@ -198,36 +198,36 @@ _ecore_animator(void *data __UNUSED__) EINA_INLIST_FOREACH(animators, animator) { - if (!animator->delete_me && !animator->suspended) - { - if (!animator->func(animator->data)) - { - animator->delete_me = EINA_TRUE; - animators_delete_me++; - } - } + if (!animator->delete_me && !animator->suspended) + { + if (!animator->func(animator->data)) + { + animator->delete_me = EINA_TRUE; + animators_delete_me++; + } + } } if (animators_delete_me) { - Ecore_Animator *l; - for(l = animators; l;) - { - animator = l; - l = (Ecore_Animator *) EINA_INLIST_GET(l)->next; - if (animator->delete_me) - { - animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator)); - ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); - free(animator); - animators_delete_me--; - if (animators_delete_me == 0) break; - } - } + Ecore_Animator *l; + for(l = animators; l;) + { + animator = l; + l = (Ecore_Animator *) EINA_INLIST_GET(l)->next; + if (animator->delete_me) + { + animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator)); + ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); + free(animator); + animators_delete_me--; + if (animators_delete_me == 0) break; + } + } } if (!animators) { - timer = NULL; - return ECORE_CALLBACK_CANCEL; + timer = NULL; + return ECORE_CALLBACK_CANCEL; } return ECORE_CALLBACK_RENEW; } diff --git a/src/lib/ecore/ecore_events.c b/src/lib/ecore/ecore_events.c index a213a00..470838c 100644 --- a/src/lib/ecore/ecore_events.c +++ b/src/lib/ecore/ecore_events.c @@ -108,26 +108,26 @@ ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data) eh->data = (void *)data; if (type >= (event_handlers_num - 1)) { - int p_alloc_num; - - p_alloc_num = event_handlers_alloc_num; - event_handlers_num = type + 1; - if (event_handlers_num > event_handlers_alloc_num) - { - Ecore_Event_Handler **new_handlers; - int i; - - event_handlers_alloc_num = ((event_handlers_num + 16) / 16) * 16; - new_handlers = realloc(event_handlers, event_handlers_alloc_num * sizeof(Ecore_Event_Handler *)); - if (!new_handlers) - { - free(eh); - return NULL; - } - event_handlers = new_handlers; - for (i = p_alloc_num; i < event_handlers_alloc_num; i++) - event_handlers[i] = NULL; - } + int p_alloc_num; + + p_alloc_num = event_handlers_alloc_num; + event_handlers_num = type + 1; + if (event_handlers_num > event_handlers_alloc_num) + { + Ecore_Event_Handler **new_handlers; + int i; + + event_handlers_alloc_num = ((event_handlers_num + 16) / 16) * 16; + new_handlers = realloc(event_handlers, event_handlers_alloc_num * sizeof(Ecore_Event_Handler *)); + if (!new_handlers) + { + free(eh); + return NULL; + } + event_handlers = new_handlers; + for (i = p_alloc_num; i < event_handlers_alloc_num; i++) + event_handlers[i] = NULL; + } } event_handlers[type] = (Ecore_Event_Handler *) eina_inlist_append(EINA_INLIST_GET(event_handlers[type]), EINA_INLIST_GET(eh)); return eh; @@ -148,9 +148,9 @@ ecore_event_handler_del(Ecore_Event_Handler *event_handler) { if (!ECORE_MAGIC_CHECK(event_handler, ECORE_MAGIC_EVENT_HANDLER)) { - ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER, - "ecore_event_handler_del"); - return NULL; + ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER, + "ecore_event_handler_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(event_handler->delete_me, NULL); event_handler->delete_me = 1; @@ -208,8 +208,8 @@ ecore_event_del(Ecore_Event *event) { if (!ECORE_MAGIC_CHECK(event, ECORE_MAGIC_EVENT)) { - ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del"); - return NULL; + ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(event->delete_me, NULL); event->delete_me = 1; @@ -284,8 +284,8 @@ ecore_event_filter_del(Ecore_Event_Filter *ef) { if (!ECORE_MAGIC_CHECK(ef, ECORE_MAGIC_EVENT_FILTER)) { - ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del"); - return NULL; + ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(ef->delete_me, NULL); ef->delete_me = 1; @@ -344,12 +344,12 @@ _ecore_event_shutdown(void) event_current = NULL; for (i = 0; i < event_handlers_num; i++) { - while ((eh = event_handlers[i])) - { - event_handlers[i] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i])); - ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); - if (!eh->delete_me) free(eh); - } + while ((eh = event_handlers[i])) + { + event_handlers[i] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i])); + ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); + if (!eh->delete_me) free(eh); + } } EINA_LIST_FREE(event_handlers_delete_list, eh) free(eh); @@ -359,9 +359,9 @@ _ecore_event_shutdown(void) event_handlers_alloc_num = 0; while ((ef = event_filters)) { - event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters)); - ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); - free(ef); + event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters)); + ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); + free(ef); } event_filters_delete_me = 0; event_filter_current = NULL; @@ -424,10 +424,10 @@ _ecore_event_purge_deleted(void) inpurge++; while (itr) { - Ecore_Event *next = (Ecore_Event *)EINA_INLIST_GET(itr)->next; - if ((!itr->references) && (itr->delete_me)) - _ecore_event_del(itr); - itr = next; + Ecore_Event *next = (Ecore_Event *)EINA_INLIST_GET(itr)->next; + if ((!itr->references) && (itr->delete_me)) + _ecore_event_del(itr); + itr = next; } inpurge--; while (purge_events) @@ -444,82 +444,82 @@ _ecore_event_filters_apply() if (!event_filter_current) { - /* regular main loop, start from head */ - event_filter_current = event_filters; + /* regular main loop, start from head */ + event_filter_current = event_filters; } else { - /* recursive main loop, continue from where we were */ - event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; + /* recursive main loop, continue from where we were */ + event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; } while (event_filter_current) { - Ecore_Event_Filter *ef = event_filter_current; - - if (!ef->delete_me) - { - ef->references++; - - if (ef->func_start) - ef->loop_data = ef->func_start(ef->data); - - if (!event_filter_event_current) - { - /* regular main loop, start from head */ - event_filter_event_current = events; - } - else - { - /* recursive main loop, continue from where we were */ - event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; - } - - while (event_filter_event_current) - { - Ecore_Event *e = event_filter_event_current; - - if (!ef->func_filter(ef->data, ef->loop_data, - e->type, e->event)) - { - ecore_event_del(e); - } - - if (event_filter_event_current) /* may have changed in recursive main loops */ - event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; - } - if (ef->func_end) - ef->func_end(ef->data, ef->loop_data); - - ef->references--; - } - - if (event_filter_current) /* may have changed in recursive main loops */ - event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; + Ecore_Event_Filter *ef = event_filter_current; + + if (!ef->delete_me) + { + ef->references++; + + if (ef->func_start) + ef->loop_data = ef->func_start(ef->data); + + if (!event_filter_event_current) + { + /* regular main loop, start from head */ + event_filter_event_current = events; + } + else + { + /* recursive main loop, continue from where we were */ + event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; + } + + while (event_filter_event_current) + { + Ecore_Event *e = event_filter_event_current; + + if (!ef->func_filter(ef->data, ef->loop_data, + e->type, e->event)) + { + ecore_event_del(e); + } + + if (event_filter_event_current) /* may have changed in recursive main loops */ + event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; + } + if (ef->func_end) + ef->func_end(ef->data, ef->loop_data); + + ef->references--; + } + + if (event_filter_current) /* may have changed in recursive main loops */ + event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; } if (event_filters_delete_me) { - int deleted_in_use = 0; - Ecore_Event_Filter *l; - for (l = event_filters; l;) - { - Ecore_Event_Filter *ef = l; - l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->next; - if (ef->delete_me) - { - if (ef->references) - { - deleted_in_use++; - continue; - } - - event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef)); - ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); - free(ef); - } - } - if (!deleted_in_use) - event_filters_delete_me = 0; + int deleted_in_use = 0; + Ecore_Event_Filter *l; + for (l = event_filters; l;) + { + Ecore_Event_Filter *ef = l; + l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->next; + if (ef->delete_me) + { + if (ef->references) + { + deleted_in_use++; + continue; + } + + event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef)); + ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); + free(ef); + } + } + if (!deleted_in_use) + event_filters_delete_me = 0; } } void @@ -532,71 +532,71 @@ _ecore_event_call(void) if (!event_current) { - /* regular main loop, start from head */ - event_current = events; - event_handler_current = NULL; + /* regular main loop, start from head */ + event_current = events; + event_handler_current = NULL; } while (event_current) { - Ecore_Event *e = event_current; - int handle_count = 0; - - if (e->delete_me) - { - event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; - continue; - } - - ecore_raw_event_type = e->type; - ecore_raw_event_event = e->event; - e->references++; - if ((e->type >= 0) && (e->type < event_handlers_num)) - { - if (!event_handler_current) - { - /* regular main loop, start from head */ - event_handler_current = event_handlers[e->type]; - } - else - { - /* recursive main loop, continue from where we were */ - event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; - } - - while ((event_handler_current) && (!e->delete_me)) - { - Ecore_Event_Handler *eh = event_handler_current; - if (!eh->delete_me) - { - Eina_Bool ret; - - handle_count++; - - eh->references++; - ret = eh->func(eh->data, e->type, e->event); - eh->references--; - - if (!ret) - { - event_handler_current = NULL; - break; /* 0 == "call no further handlers" */ - } - } - - if (event_handler_current) /* may have changed in recursive main loops */ - event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; - } - } - /* if no handlers were set for EXIT signal - then default is */ - /* to quit the main loop */ - if ((e->type == ECORE_EVENT_SIGNAL_EXIT) && (handle_count == 0)) - ecore_main_loop_quit(); - e->references--; - e->delete_me = 1; - - if (event_current) /* may have changed in recursive main loops */ - event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; + Ecore_Event *e = event_current; + int handle_count = 0; + + if (e->delete_me) + { + event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; + continue; + } + + ecore_raw_event_type = e->type; + ecore_raw_event_event = e->event; + e->references++; + if ((e->type >= 0) && (e->type < event_handlers_num)) + { + if (!event_handler_current) + { + /* regular main loop, start from head */ + event_handler_current = event_handlers[e->type]; + } + else + { + /* recursive main loop, continue from where we were */ + event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; + } + + while ((event_handler_current) && (!e->delete_me)) + { + Ecore_Event_Handler *eh = event_handler_current; + if (!eh->delete_me) + { + Eina_Bool ret; + + handle_count++; + + eh->references++; + ret = eh->func(eh->data, e->type, e->event); + eh->references--; + + if (!ret) + { + event_handler_current = NULL; + break; /* 0 == "call no further handlers" */ + } + } + + if (event_handler_current) /* may have changed in recursive main loops */ + event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; + } + } + /* if no handlers were set for EXIT signal - then default is */ + /* to quit the main loop */ + if ((e->type == ECORE_EVENT_SIGNAL_EXIT) && (handle_count == 0)) + ecore_main_loop_quit(); + e->references--; + e->delete_me = 1; + + if (event_current) /* may have changed in recursive main loops */ + event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; } ecore_raw_event_type = ECORE_EVENT_NONE; @@ -606,13 +606,13 @@ _ecore_event_call(void) EINA_LIST_FOREACH_SAFE(event_handlers_delete_list, l, l_next, eh) { - if (eh->references) continue; + if (eh->references) continue; - event_handlers_delete_list = eina_list_remove_list(event_handlers_delete_list, l); + event_handlers_delete_list = eina_list_remove_list(event_handlers_delete_list, l); - event_handlers[eh->type] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh)); - ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); - free(eh); + event_handlers[eh->type] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh)); + ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); + free(eh); } } diff --git a/src/lib/ecore/ecore_exe.c b/src/lib/ecore/ecore_exe.c index 3f8eb06..251157c 100644 --- a/src/lib/ecore/ecore_exe.c +++ b/src/lib/ecore/ecore_exe.c @@ -97,19 +97,19 @@ struct _Ecore_Exe Ecore_Fd_Handler *error_fd_handler; /* the fd_handler to handle errors from child - if this was used, or NULL if not */ void *write_data_buf; /* a data buffer for data to write to the child - * realloced as needed for more data and flushed when the fd handler says writes are possible - */ + */ int write_data_size; /* the size in bytes of the data buffer */ int write_data_offset; /* the offset in bytes in the data buffer */ void *read_data_buf; /* data read from the child awating delivery to an event */ int read_data_size; /* data read from child in bytes */ void *error_data_buf; /* errors read from the child awating delivery to an event */ int error_data_size; /* errors read from child in bytes */ - int child_fd_write; /* fd to write TO to send data to the child */ - int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */ - int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */ - int child_fd_write_x; /* fd to write TO to send data to the child */ - int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */ - int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */ + int child_fd_write; /* fd to write TO to send data to the child */ + int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */ + int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */ + int child_fd_write_x; /* fd to write TO to send data to the child */ + int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */ + int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */ Eina_Bool close_stdin : 1; int start_bytes, end_bytes, start_lines, end_lines; /* Number of bytes/lines to auto pipe at start/end of stdout/stderr. */ @@ -183,7 +183,7 @@ _ecore_exe_check_errno(int result, const char *file, int line) if (result == -1) { - perror("*** errno reports "); + perror("*** errno reports "); /* What is currently supported - * * pipe @@ -239,8 +239,8 @@ _ecore_exe_check_errno(int result, const char *file, int line) * // Something failed, cleanup. * } */ - switch (saved_errno) - { + switch (saved_errno) + { case EACCES: case EAGAIN: case EINTR: @@ -290,7 +290,7 @@ _ecore_exe_check_errno(int result, const char *file, int line) result = 0; break; } - } + } } else /* Everything is fine. */ result = 1; @@ -369,18 +369,18 @@ ecore_exe_run(const char *exe_cmd, const void *data) pid = fork(); if (pid) { - exe = calloc(1, sizeof(Ecore_Exe)); - if (!exe) - { - kill(pid, SIGKILL); - return NULL; - } - ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); - exe->pid = pid; - exe->data = (void *)data; - exe->cmd = strdup(exe_cmd); - exes = _ecore_list2_append(exes, exe); - return exe; + exe = calloc(1, sizeof(Ecore_Exe)); + if (!exe) + { + kill(pid, SIGKILL); + return NULL; + } + ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); + exe->pid = pid; + exe->data = (void *)data; + exe->cmd = strdup(exe_cmd); + exes = _ecore_list2_append(exes, exe); + return exe; } _ecore_exe_exec_it(exe_cmd, 0); exit(127); @@ -447,247 +447,247 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data) /* Create some pipes. */ if (ok) { - E_IF_NO_ERRNO_NOLOOP(result, pipe(statusPipe), ok) - { - } + E_IF_NO_ERRNO_NOLOOP(result, pipe(statusPipe), ok) + { + } } if (ok && (flags & ECORE_EXE_PIPE_ERROR)) { - E_IF_NO_ERRNO_NOLOOP(result, pipe(errorPipe), ok) - { - exe->child_fd_error = errorPipe[0]; - exe->child_fd_error_x = errorPipe[1]; - } + E_IF_NO_ERRNO_NOLOOP(result, pipe(errorPipe), ok) + { + exe->child_fd_error = errorPipe[0]; + exe->child_fd_error_x = errorPipe[1]; + } } if (ok && (flags & ECORE_EXE_PIPE_READ)) { - E_IF_NO_ERRNO_NOLOOP(result, pipe(readPipe), ok) - { - exe->child_fd_read = readPipe[0]; - exe->child_fd_read_x = readPipe[1]; - } + E_IF_NO_ERRNO_NOLOOP(result, pipe(readPipe), ok) + { + exe->child_fd_read = readPipe[0]; + exe->child_fd_read_x = readPipe[1]; + } } if (ok && (flags & ECORE_EXE_PIPE_WRITE)) { - E_IF_NO_ERRNO_NOLOOP(result, pipe(writePipe), ok) - { - exe->child_fd_write = writePipe[1]; - exe->child_fd_write_x = writePipe[0]; - } + E_IF_NO_ERRNO_NOLOOP(result, pipe(writePipe), ok) + { + exe->child_fd_write = writePipe[1]; + exe->child_fd_write_x = writePipe[0]; + } } if (ok) { - pid_t pid = 0; - volatile int vfork_exec_errno = 0; - - /* FIXME: I should double check this. After a quick look around, this is already done, but via a more modern method. */ - /* signal(SIGPIPE, SIG_IGN); We only want EPIPE on errors */ - pid = fork(); - - if (pid == -1) - { - ERR("Failed to fork process"); - pid = 0; - } - else if (pid == 0) /* child */ - { - if (run_pri != ECORE_EXE_PRIORITY_INHERIT) - { - if ((run_pri >= -20) && (run_pri <= 19)) + pid_t pid = 0; + volatile int vfork_exec_errno = 0; + + /* FIXME: I should double check this. After a quick look around, this is already done, but via a more modern method. */ + /* signal(SIGPIPE, SIG_IGN); We only want EPIPE on errors */ + pid = fork(); + + if (pid == -1) + { + ERR("Failed to fork process"); + pid = 0; + } + else if (pid == 0) /* child */ + { + if (run_pri != ECORE_EXE_PRIORITY_INHERIT) + { + if ((run_pri >= -20) && (run_pri <= 19)) setpriority(PRIO_PROCESS, 0, run_pri); - } - /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the - * second pipe if it's open. On the other hand, there was the - * Great FD Leak Scare of '06, so let's be paranoid. */ - if (ok && (flags & ECORE_EXE_PIPE_ERROR)) - { - E_NO_ERRNO(result, close(STDERR_FILENO), ok); - E_NO_ERRNO(result, dup2(errorPipe[1], STDERR_FILENO), ok); - } - if (ok && (flags & ECORE_EXE_PIPE_READ)) - { - E_NO_ERRNO(result, close(STDOUT_FILENO), ok); - E_NO_ERRNO(result, dup2(readPipe[1], STDOUT_FILENO), ok); - } - if (ok && (flags & ECORE_EXE_PIPE_WRITE)) - { - E_NO_ERRNO(result, close(STDIN_FILENO), ok); - E_NO_ERRNO(result, dup2(writePipe[0], STDIN_FILENO), ok); - } - - if (ok) - { - /* Setup the status pipe. */ - E_NO_ERRNO(result, close(statusPipe[0]), ok); - E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) /* close on exec shows success */ - { - /* Run the actual command. */ - _ecore_exe_exec_it(exe_cmd, flags); /* no return */ - } - } - - /* Something went 'orribly wrong. */ - vfork_exec_errno = errno; - - /* Close the pipes. */ - if (flags & ECORE_EXE_PIPE_ERROR) - E_NO_ERRNO(result, close(errorPipe[1]), ok); - if (flags & ECORE_EXE_PIPE_READ) - E_NO_ERRNO(result, close(readPipe[1]), ok); - if (flags & ECORE_EXE_PIPE_WRITE) - E_NO_ERRNO(result, close(writePipe[0]), ok); - E_NO_ERRNO(result, close(statusPipe[1]), ok); - - _exit(-1); - } - else /* parent */ - { - /* Close the unused pipes. */ - E_NO_ERRNO(result, close(statusPipe[1]), ok); - - /* FIXME: after having a good look at the current e fd - * handling, investigate fcntl(dataPipe[x], F_SETSIG, ...) */ - /* FIXME: above F_SETSIG etc. - this is async SIGIO based IO - * which is also linux specific so we probably don't want to - * do this as long as select() is working fine. the only time - * we really want to think of SIGIO async IO is when it all - * actually works basically everywhere and we can turn all - * IO into DMA async activities (i.e. you do a read() then - * the read is complete not on return but when you get a - * SIGIO - the read() just starts the transfer and it is - * completed in the background by DMA (or whatever mechanism - * the kernel choses)) */ - - /* Wait for it to start executing. */ - /* FIXME: this doesn't seem very nice - we sit and block - * waiting on a child process... even though it's just - * the segment between the fork() and the exec) it just feels - * wrong */ - for (;;) - { - char buf; - - E_NO_ERRNO(result, read(statusPipe[0], &buf, 1), ok); - if (result == 0) - { - if (vfork_exec_errno != 0) - { - n = vfork_exec_errno; - ERR("Could not start \"%s\"", exe_cmd); - pid = 0; - } - break; - } - } - - /* Close the status pipe. */ - E_NO_ERRNO(result, close(statusPipe[0]), ok); - } - - if (pid) - { - /* Setup the exe structure. */ - ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); - exe->start_bytes = -1; - exe->end_bytes = -1; - exe->start_lines = -1; - exe->end_lines = -1; - exe->pid = pid; - exe->flags = flags; - exe->data = (void *)data; - if ((exe->cmd = strdup(exe_cmd))) - { - if (flags & ECORE_EXE_PIPE_ERROR) - { /* Setup the error stuff. */ - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_error, F_SETFL, - O_NONBLOCK), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_error, F_SETFD, - FD_CLOEXEC), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_error_x, F_SETFD, - FD_CLOEXEC), ok) {} - { - exe->error_fd_handler = - ecore_main_fd_handler_add(exe->child_fd_error, - ECORE_FD_READ, - _ecore_exe_data_error_handler, - exe, NULL, NULL); - if (!exe->error_fd_handler) - ok = 0; - } - } - if (ok && (flags & ECORE_EXE_PIPE_READ)) - { /* Setup the read stuff. */ - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_read, F_SETFL, - O_NONBLOCK), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_read, F_SETFD, - FD_CLOEXEC), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_read_x, F_SETFD, - FD_CLOEXEC), ok) {} - { - exe->read_fd_handler = - ecore_main_fd_handler_add(exe->child_fd_read, - ECORE_FD_READ, - _ecore_exe_data_read_handler, - exe, NULL, NULL); - if (!exe->read_fd_handler) - ok = 0; - } - } - if (ok && (flags & ECORE_EXE_PIPE_WRITE)) - { /* Setup the write stuff. */ - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_write, F_SETFL, - O_NONBLOCK), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_write, F_SETFD, - FD_CLOEXEC), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_write_x, F_SETFD, - FD_CLOEXEC), ok) {} - { - exe->write_fd_handler = - ecore_main_fd_handler_add(exe->child_fd_write, - ECORE_FD_WRITE, - _ecore_exe_data_write_handler, - exe, NULL, NULL); - if (exe->write_fd_handler) - ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); /* Nothing to write to start with. */ - else - ok = 0; - } - } - - exes = (Ecore_Exe *) eina_inlist_append(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe)); - n = 0; - } - else - ok = 0; - } - else - ok = 0; + } + /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the + * second pipe if it's open. On the other hand, there was the + * Great FD Leak Scare of '06, so let's be paranoid. */ + if (ok && (flags & ECORE_EXE_PIPE_ERROR)) + { + E_NO_ERRNO(result, close(STDERR_FILENO), ok); + E_NO_ERRNO(result, dup2(errorPipe[1], STDERR_FILENO), ok); + } + if (ok && (flags & ECORE_EXE_PIPE_READ)) + { + E_NO_ERRNO(result, close(STDOUT_FILENO), ok); + E_NO_ERRNO(result, dup2(readPipe[1], STDOUT_FILENO), ok); + } + if (ok && (flags & ECORE_EXE_PIPE_WRITE)) + { + E_NO_ERRNO(result, close(STDIN_FILENO), ok); + E_NO_ERRNO(result, dup2(writePipe[0], STDIN_FILENO), ok); + } + + if (ok) + { + /* Setup the status pipe. */ + E_NO_ERRNO(result, close(statusPipe[0]), ok); + E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) /* close on exec shows success */ + { + /* Run the actual command. */ + _ecore_exe_exec_it(exe_cmd, flags); /* no return */ + } + } + + /* Something went 'orribly wrong. */ + vfork_exec_errno = errno; + + /* Close the pipes. */ + if (flags & ECORE_EXE_PIPE_ERROR) + E_NO_ERRNO(result, close(errorPipe[1]), ok); + if (flags & ECORE_EXE_PIPE_READ) + E_NO_ERRNO(result, close(readPipe[1]), ok); + if (flags & ECORE_EXE_PIPE_WRITE) + E_NO_ERRNO(result, close(writePipe[0]), ok); + E_NO_ERRNO(result, close(statusPipe[1]), ok); + + _exit(-1); + } + else /* parent */ + { + /* Close the unused pipes. */ + E_NO_ERRNO(result, close(statusPipe[1]), ok); + + /* FIXME: after having a good look at the current e fd + * handling, investigate fcntl(dataPipe[x], F_SETSIG, ...) */ + /* FIXME: above F_SETSIG etc. - this is async SIGIO based IO + * which is also linux specific so we probably don't want to + * do this as long as select() is working fine. the only time + * we really want to think of SIGIO async IO is when it all + * actually works basically everywhere and we can turn all + * IO into DMA async activities (i.e. you do a read() then + * the read is complete not on return but when you get a + * SIGIO - the read() just starts the transfer and it is + * completed in the background by DMA (or whatever mechanism + * the kernel choses)) */ + + /* Wait for it to start executing. */ + /* FIXME: this doesn't seem very nice - we sit and block + * waiting on a child process... even though it's just + * the segment between the fork() and the exec) it just feels + * wrong */ + for (;;) + { + char buf; + + E_NO_ERRNO(result, read(statusPipe[0], &buf, 1), ok); + if (result == 0) + { + if (vfork_exec_errno != 0) + { + n = vfork_exec_errno; + ERR("Could not start \"%s\"", exe_cmd); + pid = 0; + } + break; + } + } + + /* Close the status pipe. */ + E_NO_ERRNO(result, close(statusPipe[0]), ok); + } + + if (pid) + { + /* Setup the exe structure. */ + ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); + exe->start_bytes = -1; + exe->end_bytes = -1; + exe->start_lines = -1; + exe->end_lines = -1; + exe->pid = pid; + exe->flags = flags; + exe->data = (void *)data; + if ((exe->cmd = strdup(exe_cmd))) + { + if (flags & ECORE_EXE_PIPE_ERROR) + { /* Setup the error stuff. */ + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_error, F_SETFL, + O_NONBLOCK), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_error, F_SETFD, + FD_CLOEXEC), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_error_x, F_SETFD, + FD_CLOEXEC), ok) {} + { + exe->error_fd_handler = + ecore_main_fd_handler_add(exe->child_fd_error, + ECORE_FD_READ, + _ecore_exe_data_error_handler, + exe, NULL, NULL); + if (!exe->error_fd_handler) + ok = 0; + } + } + if (ok && (flags & ECORE_EXE_PIPE_READ)) + { /* Setup the read stuff. */ + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_read, F_SETFL, + O_NONBLOCK), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_read, F_SETFD, + FD_CLOEXEC), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_read_x, F_SETFD, + FD_CLOEXEC), ok) {} + { + exe->read_fd_handler = + ecore_main_fd_handler_add(exe->child_fd_read, + ECORE_FD_READ, + _ecore_exe_data_read_handler, + exe, NULL, NULL); + if (!exe->read_fd_handler) + ok = 0; + } + } + if (ok && (flags & ECORE_EXE_PIPE_WRITE)) + { /* Setup the write stuff. */ + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_write, F_SETFL, + O_NONBLOCK), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_write, F_SETFD, + FD_CLOEXEC), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_write_x, F_SETFD, + FD_CLOEXEC), ok) {} + { + exe->write_fd_handler = + ecore_main_fd_handler_add(exe->child_fd_write, + ECORE_FD_WRITE, + _ecore_exe_data_write_handler, + exe, NULL, NULL); + if (exe->write_fd_handler) + ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); /* Nothing to write to start with. */ + else + ok = 0; + } + } + + exes = (Ecore_Exe *) eina_inlist_append(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe)); + n = 0; + } + else + ok = 0; + } + else + ok = 0; } if (!ok) { /* Something went wrong, so pull down everything. */ - if (exe->pid) ecore_exe_terminate(exe); - IF_FN_DEL(ecore_exe_free, exe); + if (exe->pid) ecore_exe_terminate(exe); + IF_FN_DEL(ecore_exe_free, exe); } else { - Ecore_Exe_Event_Add *e; - - e = _ecore_exe_event_add_new(); - e->exe = exe; - if (e) /* Send the event. */ - ecore_event_add(ECORE_EXE_EVENT_ADD, e, - _ecore_exe_event_add_free, NULL); - /* INF("Running as %d for %s.\n", exe->pid, exe->cmd); */ + Ecore_Exe_Event_Add *e; + + e = _ecore_exe_event_add_new(); + e->exe = exe; + if (e) /* Send the event. */ + ecore_event_add(ECORE_EXE_EVENT_ADD, e, + _ecore_exe_event_add_free, NULL); + /* INF("Running as %d for %s.\n", exe->pid, exe->cmd); */ } errno = n; @@ -712,9 +712,9 @@ ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, - "ecore_exe_callback_pre_free_set"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, + "ecore_exe_callback_pre_free_set"); + return; } exe->pre_free_cb = func; } @@ -739,22 +739,22 @@ ecore_exe_send(Ecore_Exe * exe, const void *data, int size) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send"); - return EINA_FALSE; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send"); + return EINA_FALSE; } if (exe->close_stdin) { - ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p", - exe, size, data); - return EINA_FALSE; + ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p", + exe, size, data); + return EINA_FALSE; } if (exe->child_fd_write == -1) { - ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! " - "Cannot send %d bytes from %p", exe, size, data); - return EINA_FALSE; + ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! " + "Cannot send %d bytes from %p", exe, size, data); + return EINA_FALSE; } buf = realloc(exe->write_data_buf, exe->write_data_size + size); @@ -781,8 +781,8 @@ ecore_exe_close_stdin(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_close_stdin"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_close_stdin"); + return; } exe->close_stdin = 1; } @@ -803,8 +803,8 @@ ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int st { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_auto_limits_set"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_auto_limits_set"); + return; } /* FIXME: sanitize the input. */ exe->start_bytes = start_bytes; @@ -869,115 +869,115 @@ ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_event_data_get"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_event_data_get"); + return NULL; } /* Sort out what sort of event we are. */ if (flags & ECORE_EXE_PIPE_READ) { - flags = ECORE_EXE_PIPE_READ; - if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED) - is_buffered = 1; + flags = ECORE_EXE_PIPE_READ; + if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED) + is_buffered = 1; } else { - flags = ECORE_EXE_PIPE_ERROR; - if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED) - is_buffered = 1; + flags = ECORE_EXE_PIPE_ERROR; + if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED) + is_buffered = 1; } /* Get the data. */ if (flags & ECORE_EXE_PIPE_READ) { - inbuf = exe->read_data_buf; - inbuf_num = exe->read_data_size; - exe->read_data_buf = NULL; - exe->read_data_size = 0; + inbuf = exe->read_data_buf; + inbuf_num = exe->read_data_size; + exe->read_data_buf = NULL; + exe->read_data_size = 0; } else { - inbuf = exe->error_data_buf; - inbuf_num = exe->error_data_size; - exe->error_data_buf = NULL; - exe->error_data_size = 0; + inbuf = exe->error_data_buf; + inbuf_num = exe->error_data_size; + exe->error_data_buf = NULL; + exe->error_data_size = 0; } e = calloc(1, sizeof(Ecore_Exe_Event_Data)); if (e) { - e->exe = exe; - e->data = inbuf; - e->size = inbuf_num; - - if (is_buffered) - { /* Deal with line buffering. */ - int max = 0; - int count = 0; - int i; - int last = 0; - char *c; - - c = (char *)inbuf; - for (i = 0; i < inbuf_num; i++) /* Find the lines. */ - { - if (inbuf[i] == '\n') - { - if (count >= max) - { - /* In testing, the lines seem to arrive in batches of 500 to 1000 lines at most, roughly speaking. */ - max += 10; /* FIXME: Maybe keep track of the largest number of lines ever sent, and add half that many instead of 10. */ - e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL termination. */ - } - /* raster said to leave the line endings as line endings, however - - * This is line buffered mode, we are not dealing with binary here, but lines. - * If we are not dealing with binary, we must be dealing with ASCII, unicode, or some other text format. - * Thus the user is most likely gonna deal with this text as strings. - * Thus the user is most likely gonna pass this data to str functions. - * rasters way - the endings are always gonna be '\n'; onefangs way - they will always be '\0' - * We are handing them the string length as a convenience. - * Thus if they really want it in raw format, they can e->lines[i].line[e->lines[i].size - 1] = '\n'; easily enough. - * In the default case, we can do this conversion quicker than the user can, as we already have the index and pointer. - * Let's make it easy on them to use these as standard C strings. - * - * onefang is proud to announce that he has just set a new personal record for the - * most over documentation of a simple assignment statement. B-) - */ - inbuf[i] = '\0'; - e->lines[count].line = c; - e->lines[count].size = i - last; - last = i + 1; - c = (char *)&inbuf[last]; - count++; - } - } - if (count == 0) /* No lines to send, cancel the event. */ - { - _ecore_exe_event_exe_data_free(NULL, e); - e = NULL; - } - else /* NULL terminate the array, so that people know where the end is. */ - { - e->lines[count].line = NULL; - e->lines[count].size = 0; - } - if (i > last) /* Partial line left over, save it for next time. */ - { - if (e) e->size = last; - if (flags & ECORE_EXE_PIPE_READ) - { - exe->read_data_size = i - last; - exe->read_data_buf = malloc(exe->read_data_size); - memcpy(exe->read_data_buf, c, exe->read_data_size); - } - else - { - exe->error_data_size = i - last; - exe->error_data_buf = malloc(exe->error_data_size); - memcpy(exe->error_data_buf, c, exe->error_data_size); - } - } - } + e->exe = exe; + e->data = inbuf; + e->size = inbuf_num; + + if (is_buffered) + { /* Deal with line buffering. */ + int max = 0; + int count = 0; + int i; + int last = 0; + char *c; + + c = (char *)inbuf; + for (i = 0; i < inbuf_num; i++) /* Find the lines. */ + { + if (inbuf[i] == '\n') + { + if (count >= max) + { + /* In testing, the lines seem to arrive in batches of 500 to 1000 lines at most, roughly speaking. */ + max += 10; /* FIXME: Maybe keep track of the largest number of lines ever sent, and add half that many instead of 10. */ + e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL termination. */ + } + /* raster said to leave the line endings as line endings, however - + * This is line buffered mode, we are not dealing with binary here, but lines. + * If we are not dealing with binary, we must be dealing with ASCII, unicode, or some other text format. + * Thus the user is most likely gonna deal with this text as strings. + * Thus the user is most likely gonna pass this data to str functions. + * rasters way - the endings are always gonna be '\n'; onefangs way - they will always be '\0' + * We are handing them the string length as a convenience. + * Thus if they really want it in raw format, they can e->lines[i].line[e->lines[i].size - 1] = '\n'; easily enough. + * In the default case, we can do this conversion quicker than the user can, as we already have the index and pointer. + * Let's make it easy on them to use these as standard C strings. + * + * onefang is proud to announce that he has just set a new personal record for the + * most over documentation of a simple assignment statement. B-) + */ + inbuf[i] = '\0'; + e->lines[count].line = c; + e->lines[count].size = i - last; + last = i + 1; + c = (char *)&inbuf[last]; + count++; + } + } + if (count == 0) /* No lines to send, cancel the event. */ + { + _ecore_exe_event_exe_data_free(NULL, e); + e = NULL; + } + else /* NULL terminate the array, so that people know where the end is. */ + { + e->lines[count].line = NULL; + e->lines[count].size = 0; + } + if (i > last) /* Partial line left over, save it for next time. */ + { + if (e) e->size = last; + if (flags & ECORE_EXE_PIPE_READ) + { + exe->read_data_size = i - last; + exe->read_data_buf = malloc(exe->read_data_size); + memcpy(exe->read_data_buf, c, exe->read_data_size); + } + else + { + exe->error_data_size = i - last; + exe->error_data_buf = malloc(exe->error_data_size); + memcpy(exe->error_data_buf, c, exe->error_data_size); + } + } + } } return e; @@ -995,8 +995,8 @@ ecore_exe_tag_set(Ecore_Exe *exe, const char *tag) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_set"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_set"); + return; } IF_FREE(exe->tag); if (tag) @@ -1022,8 +1022,8 @@ ecore_exe_tag_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_get"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_get"); + return NULL; } return exe->tag; } @@ -1048,8 +1048,8 @@ ecore_exe_free(Ecore_Exe *exe) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free"); + return NULL; } data = exe->data; @@ -1059,17 +1059,17 @@ ecore_exe_free(Ecore_Exe *exe) if (exe->doomsday_clock) { - struct _ecore_exe_dead_exe *dead; - - ecore_timer_del(exe->doomsday_clock); - exe->doomsday_clock = NULL; - dead = exe->doomsday_clock_dead; - if (dead) - { - IF_FREE(dead->cmd); - free(dead); - exe->doomsday_clock_dead = NULL; - } + struct _ecore_exe_dead_exe *dead; + + ecore_timer_del(exe->doomsday_clock); + exe->doomsday_clock = NULL; + dead = exe->doomsday_clock_dead; + if (dead) + { + IF_FREE(dead->cmd); + free(dead); + exe->doomsday_clock_dead = NULL; + } } IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler); IF_FN_DEL(ecore_main_fd_handler_del, exe->read_fd_handler); @@ -1124,8 +1124,8 @@ ecore_exe_pid_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pid_get"); - return -1; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pid_get"); + return -1; } return exe->pid; } @@ -1143,8 +1143,8 @@ ecore_exe_cmd_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_cmd_get"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_cmd_get"); + return NULL; } return exe->cmd; } @@ -1161,8 +1161,8 @@ ecore_exe_data_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); + return NULL; } return exe->data; } @@ -1178,8 +1178,8 @@ ecore_exe_flags_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); - return 0; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); + return 0; } return exe->flags; } @@ -1200,8 +1200,8 @@ ecore_exe_pause(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause"); + return; } kill(exe->pid, SIGSTOP); } @@ -1216,8 +1216,8 @@ ecore_exe_continue(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_continue"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_continue"); + return; } kill(exe->pid, SIGCONT); } @@ -1232,8 +1232,8 @@ ecore_exe_interrupt(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_interrupt"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_interrupt"); + return; } _ecore_exe_dead_attach(exe); kill(exe->pid, SIGINT); @@ -1249,8 +1249,8 @@ ecore_exe_quit(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit"); + return; } _ecore_exe_dead_attach(exe); kill(exe->pid, SIGQUIT); @@ -1266,8 +1266,8 @@ ecore_exe_terminate(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_terminate"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_terminate"); + return; } _ecore_exe_dead_attach(exe); INF("Sending TERM signal to %s (%d).", exe->cmd, exe->pid); @@ -1286,18 +1286,18 @@ ecore_exe_kill(Ecore_Exe *exe) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill"); + return; } dead = calloc(1, sizeof(struct _ecore_exe_dead_exe)); if (dead) { - dead->pid = exe->pid; - dead->cmd = strdup(exe->cmd); - IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); - exe->doomsday_clock = - ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, dead); + dead->pid = exe->pid; + dead->cmd = strdup(exe->cmd); + IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); + exe->doomsday_clock = + ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, dead); } INF("Sending KILL signal to %s (%d).", exe->cmd, exe->pid); @@ -1316,8 +1316,8 @@ ecore_exe_signal(Ecore_Exe *exe, int num) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal"); + return; } if (num == 1) kill(exe->pid, SIGUSR1); @@ -1335,8 +1335,8 @@ ecore_exe_hup(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup"); + return; } kill(exe->pid, SIGHUP); } @@ -1371,8 +1371,8 @@ _ecore_exe_is_it_alive(pid_t pid) exe = _ecore_exe_find(pid); if (exe) { - if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) - exe = NULL; + if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) + exe = NULL; } return exe; @@ -1386,26 +1386,26 @@ _ecore_exe_make_sure_its_dead(void *data) dead = data; if (dead) { - Ecore_Exe *exe = NULL; - - if ((exe = _ecore_exe_is_it_alive(dead->pid))) - { - if (dead->cmd) - INF("Sending KILL signal to allegedly dead %s (%d).", - dead->cmd, dead->pid); - else - INF("Sending KILL signal to allegedly dead PID %d.", - dead->pid); - exe->doomsday_clock = - ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, - dead); - kill(dead->pid, SIGKILL); - } - else - { - IF_FREE(dead->cmd); - free(dead); - } + Ecore_Exe *exe = NULL; + + if ((exe = _ecore_exe_is_it_alive(dead->pid))) + { + if (dead->cmd) + INF("Sending KILL signal to allegedly dead %s (%d).", + dead->cmd, dead->pid); + else + INF("Sending KILL signal to allegedly dead PID %d.", + dead->pid); + exe->doomsday_clock = + ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, + dead); + kill(dead->pid, SIGKILL); + } + else + { + IF_FREE(dead->cmd); + free(dead); + } } return ECORE_CALLBACK_CANCEL; } @@ -1418,19 +1418,19 @@ _ecore_exe_make_sure_its_really_dead(void *data) dead = data; if (dead) { - Ecore_Exe *exe = NULL; - - if ((exe = _ecore_exe_is_it_alive(dead->pid))) - { - ERR("RUN! The zombie wants to eat your brains! And your CPU!"); - if (dead->cmd) - INF("%s (%d) is not really dead.", dead->cmd, dead->pid); - else - INF("PID %d is not really dead.", dead->pid); - exe->doomsday_clock = NULL; - } - IF_FREE(dead->cmd); - free(dead); + Ecore_Exe *exe = NULL; + + if ((exe = _ecore_exe_is_it_alive(dead->pid))) + { + ERR("RUN! The zombie wants to eat your brains! And your CPU!"); + if (dead->cmd) + INF("%s (%d) is not really dead.", dead->cmd, dead->pid); + else + INF("PID %d is not really dead.", dead->pid); + exe->doomsday_clock = NULL; + } + IF_FREE(dead->cmd); + free(dead); } return ECORE_CALLBACK_CANCEL; } @@ -1458,8 +1458,8 @@ _ecore_exe_find(pid_t pid) EINA_INLIST_FOREACH(exes, exe) { - if (exe->pid == pid) - return exe; + if (exe->pid == pid) + return exe; } return NULL; } @@ -1492,76 +1492,76 @@ _ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags) */ if (!strpbrk(exe_cmd, "|&;<>()$`\\\"'*?#")) { - char *token; - char pre_command = 1; - int num_tokens = 0; - - if (!(buf = strdup(exe_cmd))) - return; - - token = strtok(buf, " \t\n\v"); - while (token) - { - if (token[0] == '~') - break; - if (pre_command) - { - if (token[0] == '[') - break; - if (strchr(token, '=')) - break; - else - pre_command = 0; - } - num_tokens++; - token = strtok(NULL, " \t\n\v"); - } - IF_FREE(buf); - if ((!token) && (num_tokens)) - { - int i = 0; - - if (!(buf = strdup(exe_cmd))) - return; - - token = strtok(buf, " \t\n\v"); - use_sh = 0; - if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *)))) - { - IF_FREE(buf); - return; - } - for (i = 0; i < num_tokens; i++) - { - if (token) - args[i] = token; - token = strtok(NULL, " \t\n\v"); - } - args[num_tokens] = NULL; - } + char *token; + char pre_command = 1; + int num_tokens = 0; + + if (!(buf = strdup(exe_cmd))) + return; + + token = strtok(buf, " \t\n\v"); + while (token) + { + if (token[0] == '~') + break; + if (pre_command) + { + if (token[0] == '[') + break; + if (strchr(token, '=')) + break; + else + pre_command = 0; + } + num_tokens++; + token = strtok(NULL, " \t\n\v"); + } + IF_FREE(buf); + if ((!token) && (num_tokens)) + { + int i = 0; + + if (!(buf = strdup(exe_cmd))) + return; + + token = strtok(buf, " \t\n\v"); + use_sh = 0; + if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *)))) + { + IF_FREE(buf); + return; + } + for (i = 0; i < num_tokens; i++) + { + if (token) + args[i] = token; + token = strtok(NULL, " \t\n\v"); + } + args[num_tokens] = NULL; + } } if (!(flags & ECORE_EXE_NOT_LEADER)) setsid(); if ((flags & ECORE_EXE_USE_SH)) { - errno = 0; - execl("/bin/sh", "/bin/sh", "-c", exe_cmd, (char *)NULL); + errno = 0; + execl("/bin/sh", "/bin/sh", "-c", exe_cmd, (char *)NULL); } else if (use_sh) - { /* We have to use a shell to run this. */ - if (!shell) - { /* Find users preferred shell. */ - shell = getenv("SHELL"); - if (!shell) - shell = "/bin/sh"; - } - errno = 0; - execl(shell, shell, "-c", exe_cmd, (char *)NULL); + { /* We have to use a shell to run this. */ + if (!shell) + { /* Find users preferred shell. */ + shell = getenv("SHELL"); + if (!shell) + shell = "/bin/sh"; + } + errno = 0; + execl(shell, shell, "-c", exe_cmd, (char *)NULL); } else - { /* We can run this directly. */ - errno = 0; - execvp(args[0], args); + { /* We can run this directly. */ + errno = 0; + execvp(args[0], args); } save_errno = errno; @@ -1583,117 +1583,117 @@ _ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler, Ecore_ /* Sort out what sort of handler we are. */ if (flags & ECORE_EXE_PIPE_READ) { - flags = ECORE_EXE_PIPE_READ; - event_type = ECORE_EXE_EVENT_DATA; - child_fd = exe->child_fd_read; + flags = ECORE_EXE_PIPE_READ; + event_type = ECORE_EXE_EVENT_DATA; + child_fd = exe->child_fd_read; } else { - flags = ECORE_EXE_PIPE_ERROR; - event_type = ECORE_EXE_EVENT_ERROR; - child_fd = exe->child_fd_error; + flags = ECORE_EXE_PIPE_ERROR; + event_type = ECORE_EXE_EVENT_ERROR; + child_fd = exe->child_fd_error; } if ((fd_handler) && (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))) { - unsigned char *inbuf; - int inbuf_num; - - /* Get any left over data from last time. */ - if (flags & ECORE_EXE_PIPE_READ) - { - inbuf = exe->read_data_buf; - inbuf_num = exe->read_data_size; - exe->read_data_buf = NULL; - exe->read_data_size = 0; - } - else - { - inbuf = exe->error_data_buf; - inbuf_num = exe->error_data_size; - exe->error_data_buf = NULL; - exe->error_data_size = 0; - } - - for (;;) - { - int num, lost_exe; - char buf[READBUFSIZ]; - - lost_exe = 0; - errno = 0; - if ((num = read(child_fd, buf, READBUFSIZ)) < 1) - /* FIXME: SPEED/SIZE TRADE OFF - add a smaller READBUFSIZE - * (currently 64k) to inbuf, use that instead of buf, and - * save ourselves a memcpy(). */ - { - lost_exe = ((errno == EIO) || - (errno == EBADF) || - (errno == EPIPE) || - (errno == EINVAL) || (errno == ENOSPC)); - if ((errno != EAGAIN) && (errno != EINTR)) - perror("_ecore_exe_generic_handler() read problem "); - } - if (num > 0) - { /* data got read. */ - inbuf = realloc(inbuf, inbuf_num + num); - memcpy(inbuf + inbuf_num, buf, num); - inbuf_num += num; - } - else - { /* No more data to read. */ - if (inbuf) - { - Ecore_Exe_Event_Data *e; - - /* Stash the data away for later. */ - if (flags & ECORE_EXE_PIPE_READ) - { - exe->read_data_buf = inbuf; - exe->read_data_size = inbuf_num; - } - else - { - exe->error_data_buf = inbuf; - exe->error_data_size = inbuf_num; - } - - if (!(exe->flags & ECORE_EXE_PIPE_AUTO)) - { - e = ecore_exe_event_data_get(exe, flags); - if (e) /* Send the event. */ + unsigned char *inbuf; + int inbuf_num; + + /* Get any left over data from last time. */ + if (flags & ECORE_EXE_PIPE_READ) + { + inbuf = exe->read_data_buf; + inbuf_num = exe->read_data_size; + exe->read_data_buf = NULL; + exe->read_data_size = 0; + } + else + { + inbuf = exe->error_data_buf; + inbuf_num = exe->error_data_size; + exe->error_data_buf = NULL; + exe->error_data_size = 0; + } + + for (;;) + { + int num, lost_exe; + char buf[READBUFSIZ]; + + lost_exe = 0; + errno = 0; + if ((num = read(child_fd, buf, READBUFSIZ)) < 1) + /* FIXME: SPEED/SIZE TRADE OFF - add a smaller READBUFSIZE + * (currently 64k) to inbuf, use that instead of buf, and + * save ourselves a memcpy(). */ + { + lost_exe = ((errno == EIO) || + (errno == EBADF) || + (errno == EPIPE) || + (errno == EINVAL) || (errno == ENOSPC)); + if ((errno != EAGAIN) && (errno != EINTR)) + perror("_ecore_exe_generic_handler() read problem "); + } + if (num > 0) + { /* data got read. */ + inbuf = realloc(inbuf, inbuf_num + num); + memcpy(inbuf + inbuf_num, buf, num); + inbuf_num += num; + } + else + { /* No more data to read. */ + if (inbuf) + { + Ecore_Exe_Event_Data *e; + + /* Stash the data away for later. */ + if (flags & ECORE_EXE_PIPE_READ) + { + exe->read_data_buf = inbuf; + exe->read_data_size = inbuf_num; + } + else + { + exe->error_data_buf = inbuf; + exe->error_data_size = inbuf_num; + } + + if (!(exe->flags & ECORE_EXE_PIPE_AUTO)) + { + e = ecore_exe_event_data_get(exe, flags); + if (e) /* Send the event. */ ecore_event_add(event_type, e, _ecore_exe_event_exe_data_free, NULL); - } - } - if (lost_exe) - { - if (flags & ECORE_EXE_PIPE_READ) - { - if (exe->read_data_size) + } + } + if (lost_exe) + { + if (flags & ECORE_EXE_PIPE_READ) + { + if (exe->read_data_size) INF("There are %d bytes left unsent from the dead exe %s.", exe->read_data_size, exe->cmd); - } - else - { - if (exe->error_data_size) + } + else + { + if (exe->error_data_size) INF("There are %d bytes left unsent from the dead exe %s.", exe->error_data_size, exe->cmd); - } - /* Thought about this a bit. If the exe has actually - * died, this won't do any harm as it must have died - * recently and the pid has not had a chance to recycle. - * It is also a paranoid catchall, coz the usual ecore_signal - * mechenism should kick in. But let's give it a good - * kick in the head anyway. - */ - ecore_exe_terminate(exe); - } - break; - } - } + } + /* Thought about this a bit. If the exe has actually + * died, this won't do any harm as it must have died + * recently and the pid has not had a chance to recycle. + * It is also a paranoid catchall, coz the usual ecore_signal + * mechenism should kick in. But let's give it a good + * kick in the head anyway. + */ + ecore_exe_terminate(exe); + } + break; + } + } } return ECORE_CALLBACK_RENEW; @@ -1703,14 +1703,14 @@ static Eina_Bool _ecore_exe_data_error_handler(void *data, Ecore_Fd_Handler *fd_handler) { return _ecore_exe_data_generic_handler(data, fd_handler, - ECORE_EXE_PIPE_ERROR); + ECORE_EXE_PIPE_ERROR); } static Eina_Bool _ecore_exe_data_read_handler(void *data, Ecore_Fd_Handler *fd_handler) { return _ecore_exe_data_generic_handler(data, fd_handler, - ECORE_EXE_PIPE_READ); + ECORE_EXE_PIPE_READ); } static Eina_Bool @@ -1721,23 +1721,23 @@ _ecore_exe_data_write_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED_ exe = data; if ((exe->write_fd_handler) && (ecore_main_fd_handler_active_get - (exe->write_fd_handler, ECORE_FD_WRITE))) + (exe->write_fd_handler, ECORE_FD_WRITE))) _ecore_exe_flush(exe); /* If we have sent all there is to send, and we need to close the pipe, then close it. */ if ((exe->close_stdin == 1) && (exe->write_data_size == exe->write_data_offset)) { - int ok = 0; - int result; - - INF("Closing stdin for %s", exe->cmd); - /* if (exe->child_fd_write != -1) E_NO_ERRNO(result, fsync(exe->child_fd_write), ok); This a) doesn't work, and b) isn't needed. */ - IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler); - if (exe->child_fd_write != -1) - E_NO_ERRNO(result, close(exe->child_fd_write), ok); - exe->child_fd_write = -1; - IF_FREE(exe->write_data_buf); + int ok = 0; + int result; + + INF("Closing stdin for %s", exe->cmd); + /* if (exe->child_fd_write != -1) E_NO_ERRNO(result, fsync(exe->child_fd_write), ok); This a) doesn't work, and b) isn't needed. */ + IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler); + if (exe->child_fd_write != -1) + E_NO_ERRNO(result, close(exe->child_fd_write), ok); + exe->child_fd_write = -1; + IF_FREE(exe->write_data_buf); } return ECORE_CALLBACK_RENEW; @@ -1755,28 +1755,28 @@ _ecore_exe_flush(Ecore_Exe *exe) return; count = write(exe->child_fd_write, - (char *)exe->write_data_buf + exe->write_data_offset, - exe->write_data_size - exe->write_data_offset); + (char *)exe->write_data_buf + exe->write_data_offset, + exe->write_data_size - exe->write_data_offset); if (count < 1) { - if (errno == EIO || errno == EBADF || errno == EPIPE || errno == EINVAL || errno == ENOSPC) /* we lost our exe! */ - { - ecore_exe_terminate(exe); - if (exe->write_fd_handler) - ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); - } + if (errno == EIO || errno == EBADF || errno == EPIPE || errno == EINVAL || errno == ENOSPC) /* we lost our exe! */ + { + ecore_exe_terminate(exe); + if (exe->write_fd_handler) + ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); + } } else { - exe->write_data_offset += count; - if (exe->write_data_offset >= exe->write_data_size) - { /* Nothing left to write, clean up. */ - exe->write_data_size = 0; - exe->write_data_offset = 0; - IF_FREE(exe->write_data_buf); - if (exe->write_fd_handler) - ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); - } + exe->write_data_offset += count; + if (exe->write_data_offset >= exe->write_data_size) + { /* Nothing left to write, clean up. */ + exe->write_data_size = 0; + exe->write_data_offset = 0; + IF_FREE(exe->write_data_buf); + if (exe->write_fd_handler) + ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); + } } } @@ -1836,11 +1836,11 @@ _ecore_exe_dead_attach(Ecore_Exe *exe) dead = calloc(1, sizeof(struct _ecore_exe_dead_exe)); if (dead) { - dead->pid = exe->pid; - dead->cmd = strdup(exe->cmd); - IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); - exe->doomsday_clock = - ecore_timer_add(10.0, _ecore_exe_make_sure_its_dead, dead); - exe->doomsday_clock_dead = dead; + dead->pid = exe->pid; + dead->cmd = strdup(exe->cmd); + IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); + exe->doomsday_clock = + ecore_timer_add(10.0, _ecore_exe_make_sure_its_dead, dead); + exe->doomsday_clock_dead = dead; } } diff --git a/src/lib/ecore/ecore_getopt.c b/src/lib/ecore/ecore_getopt.c index f00c46e..5b1c7bf 100644 --- a/src/lib/ecore/ecore_getopt.c +++ b/src/lib/ecore/ecore_getopt.c @@ -51,30 +51,30 @@ _ecore_getopt_help_print_replace_program(FILE *fp, const Ecore_Getopt *parser __ { do { - const char *d = strchr(text, '%'); - - if (!d) - { - fputs(text, fp); - break; - } - - if (fwrite(text, 1, d - text, fp) != (size_t)(d - text)) - return; - d++; - if (strncmp(d, "prog", sizeof("prog") - 1) == 0) - { - fputs(prog ? prog : "???", fp); - d += sizeof("prog") - 1; - } - else - { - if (d[0] == '%') - d++; - fputc('%', fp); - } - - text = d; + const char *d = strchr(text, '%'); + + if (!d) + { + fputs(text, fp); + break; + } + + if (fwrite(text, 1, d - text, fp) != (size_t)(d - text)) + return; + d++; + if (strncmp(d, "prog", sizeof("prog") - 1) == 0) + { + fputs(prog ? prog : "???", fp); + d += sizeof("prog") - 1; + } + else + { + if (d[0] == '%') + d++; + fputc('%', fp); + } + + text = d; } while (text[0] != '\0'); @@ -97,8 +97,8 @@ _ecore_getopt_help_usage(FILE *fp, const Ecore_Getopt *parser) if (!parser->usage) { - fprintf(fp, _("%s [options]\n"), prog); - return; + fprintf(fp, _("%s [options]\n"), prog); + return; } _ecore_getopt_help_print_replace_program(fp, parser, gettext(parser->usage)); @@ -110,75 +110,75 @@ _ecore_getopt_help_line(FILE *fp, const int base, const int total, int used, con int linebreak = 0; do { - /* process line considering spaces (new line and tabs are spaces!) */ - while ((used < total) && (len > 0)) - { - const char *space = NULL; - int i, todo; - - todo = total - used; - if (todo > len) - todo = len; - - for (i = 0; i < todo; i++) - if (isspace(text[i])) - { - space = text + i; - break; - } - - if (space) - { - i = fwrite(text, 1, i, fp); - i++; - text += i; - len -= i; - used += i; - - if (linebreak) - { - linebreak = 0; - continue; - } - - if (space[0] == '\n') - break; - else if (space[0] == '\t') - { - int c; - - used--; - c = ((used / 8) + 1) * 8; - if (c < total) - { - for (; used < c; used++) - fputc(' ', fp); - } - else - { - text--; - len++; - break; - } - } - else if (used < total) - fputc(space[0], fp); - } - else - { - i = fwrite(text, 1, i, fp); - text += i; - len -= i; - used += i; - } - linebreak = 0; - } - if (len <= 0) - break; - linebreak = 1; - fputc('\n', fp); - for (used = 0; used < base; used++) - fputc(' ', fp); + /* process line considering spaces (new line and tabs are spaces!) */ + while ((used < total) && (len > 0)) + { + const char *space = NULL; + int i, todo; + + todo = total - used; + if (todo > len) + todo = len; + + for (i = 0; i < todo; i++) + if (isspace(text[i])) + { + space = text + i; + break; + } + + if (space) + { + i = fwrite(text, 1, i, fp); + i++; + text += i; + len -= i; + used += i; + + if (linebreak) + { + linebreak = 0; + continue; + } + + if (space[0] == '\n') + break; + else if (space[0] == '\t') + { + int c; + + used--; + c = ((used / 8) + 1) * 8; + if (c < total) + { + for (; used < c; used++) + fputc(' ', fp); + } + else + { + text--; + len++; + break; + } + } + else if (used < total) + fputc(space[0], fp); + } + else + { + i = fwrite(text, 1, i, fp); + text += i; + len -= i; + used += i; + } + linebreak = 0; + } + if (len <= 0) + break; + linebreak = 1; + fputc('\n', fp); + for (used = 0; used < base; used++) + fputc(' ', fp); } while (1); @@ -207,34 +207,34 @@ _ecore_getopt_help_description(FILE *fp, const Ecore_Getopt *parser) do { - const char *d = strchr(p, '%'); - - if (!d) - { - _ecore_getopt_help_line(fp, 0, cols, used, p, strlen(p)); - break; - } - - used = _ecore_getopt_help_line(fp, 0, cols, used, p, d - p); - d++; - if (strncmp(d, "prog", sizeof("prog") - 1) == 0) - { - used = _ecore_getopt_help_line(fp, 0, cols, used, prg, prglen); - d += sizeof("prog") - 1; - } - else if (strncmp(d, "version", sizeof("version") - 1) == 0) - { - used = _ecore_getopt_help_line(fp, 0, cols, used, ver, verlen); - d += sizeof("version") - 1; - } - else - { - if (d[0] == '%') - d++; - used = _ecore_getopt_help_line(fp, 0, cols, used, "%", 1); - } - - p = d; + const char *d = strchr(p, '%'); + + if (!d) + { + _ecore_getopt_help_line(fp, 0, cols, used, p, strlen(p)); + break; + } + + used = _ecore_getopt_help_line(fp, 0, cols, used, p, d - p); + d++; + if (strncmp(d, "prog", sizeof("prog") - 1) == 0) + { + used = _ecore_getopt_help_line(fp, 0, cols, used, prg, prglen); + d += sizeof("prog") - 1; + } + else if (strncmp(d, "version", sizeof("version") - 1) == 0) + { + used = _ecore_getopt_help_line(fp, 0, cols, used, ver, verlen); + d += sizeof("version") - 1; + } + else + { + if (d[0] == '%') + d++; + used = _ecore_getopt_help_line(fp, 0, cols, used, "%", 1); + } + + p = d; } while (p[0] != '\0'); @@ -269,27 +269,27 @@ _ecore_getopt_desc_arg_requirement(const Ecore_Getopt_Desc *desc) switch (desc->action) { case ECORE_GETOPT_ACTION_STORE: - return desc->action_param.store.arg_req; + return desc->action_param.store.arg_req; case ECORE_GETOPT_ACTION_STORE_CONST: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_STORE_TRUE: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_STORE_FALSE: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_CHOICE: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; case ECORE_GETOPT_ACTION_APPEND: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; case ECORE_GETOPT_ACTION_COUNT: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_CALLBACK: - return desc->action_param.callback.arg_req; + return desc->action_param.callback.arg_req; case ECORE_GETOPT_ACTION_HELP: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_VERSION: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; default: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; } } @@ -298,25 +298,25 @@ _ecore_getopt_help_desc_setup_metavar(const Ecore_Getopt_Desc *desc, char *metav { if (desc->metavar) { - const char *txt = gettext(desc->metavar); - *metavarlen = strlen(txt); - if (*metavarlen > maxsize - 1) - *metavarlen = maxsize - 1; + const char *txt = gettext(desc->metavar); + *metavarlen = strlen(txt); + if (*metavarlen > maxsize - 1) + *metavarlen = maxsize - 1; - memcpy(metavar, txt, *metavarlen); - metavar[*metavarlen] = '\0'; + memcpy(metavar, txt, *metavarlen); + metavar[*metavarlen] = '\0'; } else if (desc->longname) { - int i; + int i; - *metavarlen = strlen(desc->longname); - if (*metavarlen > maxsize - 1) - *metavarlen = maxsize - 1; + *metavarlen = strlen(desc->longname); + if (*metavarlen > maxsize - 1) + *metavarlen = maxsize - 1; - for (i = 0; i < *metavarlen; i++) - metavar[i] = toupper(desc->longname[i]); - metavar[i] = '\0'; + for (i = 0; i < *metavarlen; i++) + metavar[i] = toupper(desc->longname[i]); + metavar[i] = '\0'; } } @@ -332,21 +332,21 @@ _ecore_getopt_help_desc_show_arg(FILE *fp, Ecore_Getopt_Desc_Arg_Requirement req if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL) { - fputc('[', fp); - used++; + fputc('[', fp); + used++; } if (requirement != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) { - fputc('=', fp); - fputs(metavar, fp); - used += metavarlen + 1; + fputc('=', fp); + fputs(metavar, fp); + used += metavarlen + 1; } if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL) { - fputc(']', fp); - used++; + fputc(']', fp); + used++; } return used; @@ -367,44 +367,44 @@ _ecore_getopt_help_desc_store(FILE *fp, const int base, const int total, int use switch (store->type) { case ECORE_GETOPT_TYPE_STR: - str = "STR"; - len = sizeof("STR") - 1; - break; + str = "STR"; + len = sizeof("STR") - 1; + break; case ECORE_GETOPT_TYPE_BOOL: - str = "BOOL"; - len = sizeof("BOOL") - 1; - break; + str = "BOOL"; + len = sizeof("BOOL") - 1; + break; case ECORE_GETOPT_TYPE_SHORT: - str = "SHORT"; - len = sizeof("SHORT") - 1; - break; + str = "SHORT"; + len = sizeof("SHORT") - 1; + break; case ECORE_GETOPT_TYPE_INT: - str = "INT"; - len = sizeof("INT") - 1; - break; + str = "INT"; + len = sizeof("INT") - 1; + break; case ECORE_GETOPT_TYPE_LONG: - str = "LONG"; - len = sizeof("LONG") - 1; - break; + str = "LONG"; + len = sizeof("LONG") - 1; + break; case ECORE_GETOPT_TYPE_USHORT: - str = "USHORT"; - len = sizeof("USHORT") - 1; - break; + str = "USHORT"; + len = sizeof("USHORT") - 1; + break; case ECORE_GETOPT_TYPE_UINT: - str = "UINT"; - len = sizeof("UINT") - 1; - break; + str = "UINT"; + len = sizeof("UINT") - 1; + break; case ECORE_GETOPT_TYPE_ULONG: - str = "ULONG"; - len = sizeof("ULONG") - 1; - break; + str = "ULONG"; + len = sizeof("ULONG") - 1; + break; case ECORE_GETOPT_TYPE_DOUBLE: - str = "DOUBLE"; - len = sizeof("DOUBLE") - 1; - break; + str = "DOUBLE"; + len = sizeof("DOUBLE") - 1; + break; default: - str = "???"; - len = sizeof("???") - 1; + str = "???"; + len = sizeof("???") - 1; } used = _ecore_getopt_help_line @@ -420,58 +420,58 @@ _ecore_getopt_help_desc_store(FILE *fp, const int base, const int total, int use switch (store->type) { case ECORE_GETOPT_TYPE_STR: - str = store->def.strv; - len = str ? strlen(str) : 0; - break; + str = store->def.strv; + len = str ? strlen(str) : 0; + break; case ECORE_GETOPT_TYPE_BOOL: - str = store->def.boolv ? "true" : "false"; - len = strlen(str); - break; + str = store->def.boolv ? "true" : "false"; + len = strlen(str); + break; case ECORE_GETOPT_TYPE_SHORT: - str = buf; - len = snprintf(buf, sizeof(buf), "%hd", store->def.shortv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%hd", store->def.shortv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_INT: - str = buf; - len = snprintf(buf, sizeof(buf), "%d", store->def.intv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%d", store->def.intv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_LONG: - str = buf; - len = snprintf(buf, sizeof(buf), "%ld", store->def.longv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%ld", store->def.longv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_USHORT: - str = buf; - len = snprintf(buf, sizeof(buf), "%hu", store->def.ushortv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%hu", store->def.ushortv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_UINT: - str = buf; - len = snprintf(buf, sizeof(buf), "%u", store->def.uintv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%u", store->def.uintv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_ULONG: - str = buf; - len = snprintf(buf, sizeof(buf), "%lu", store->def.ulongv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%lu", store->def.ulongv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_DOUBLE: - str = buf; - len = snprintf(buf, sizeof(buf), "%f", store->def.doublev); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%f", store->def.doublev); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; default: - str = "???"; - len = sizeof("???") - 1; + str = "???"; + len = sizeof("???") - 1; } used = _ecore_getopt_help_line @@ -491,8 +491,8 @@ _ecore_getopt_help_desc_choices(FILE *fp, const int base, const int total, int u if (used > 0) { - fputc('\n', fp); - used = 0; + fputc('\n', fp); + used = 0; } for (; used < base; used++) fputc(' ', fp); @@ -502,10 +502,10 @@ _ecore_getopt_help_desc_choices(FILE *fp, const int base, const int total, int u for (itr = desc->action_param.choices; *itr; itr++) { - used = _ecore_getopt_help_line - (fp, base, total, used, *itr, strlen(*itr)); - if (itr[1]) - used = _ecore_getopt_help_line(fp, base, total, used, sep, seplen); + used = _ecore_getopt_help_line + (fp, base, total, used, *itr, strlen(*itr)); + if (itr[1]) + used = _ecore_getopt_help_line(fp, base, total, used, sep, seplen); } return _ecore_getopt_help_line(fp, base, total, used, ".", 1); @@ -529,28 +529,28 @@ _ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc) if (desc->shortname) { - fputc('-', fp); - fputc(desc->shortname, fp); - used += 2; - used += _ecore_getopt_help_desc_show_arg - (fp, arg_req, metavar, metavarlen); + fputc('-', fp); + fputc(desc->shortname, fp); + used += 2; + used += _ecore_getopt_help_desc_show_arg + (fp, arg_req, metavar, metavarlen); } if (desc->shortname && desc->longname) { - fputs(", ", fp); - used += 2; + fputs(", ", fp); + used += 2; } if (desc->longname) { - int namelen = strlen(desc->longname); + int namelen = strlen(desc->longname); - fputs("--", fp); - fputs(desc->longname, fp); - used += 2 + namelen; - used += _ecore_getopt_help_desc_show_arg - (fp, arg_req, metavar, metavarlen); + fputs("--", fp); + fputs(desc->longname, fp); + used += 2 + namelen; + used += _ecore_getopt_help_desc_show_arg + (fp, arg_req, metavar, metavarlen); } if (!desc->help) @@ -558,8 +558,8 @@ _ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc) if (used + 3 >= helpcol) { - fputc('\n', fp); - used = 0; + fputc('\n', fp); + used = 0; } for (; used < helpcol; used++) @@ -571,13 +571,13 @@ _ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc) switch (desc->action) { case ECORE_GETOPT_ACTION_STORE: - _ecore_getopt_help_desc_store(fp, helpcol, cols, used, desc); - break; + _ecore_getopt_help_desc_store(fp, helpcol, cols, used, desc); + break; case ECORE_GETOPT_ACTION_CHOICE: - _ecore_getopt_help_desc_choices(fp, helpcol, cols, used, desc); - break; + _ecore_getopt_help_desc_choices(fp, helpcol, cols, used, desc); + break; default: - break; + break; } end: @@ -617,21 +617,21 @@ ecore_getopt_help(FILE *fp, const Ecore_Getopt *parser) if (argc < 1) { - ecore_app_args_get(&argc, &argv); - if ((argc > 0) && (argv[0])) - prog = argv[0]; - else - prog = parser->prog; + ecore_app_args_get(&argc, &argv); + if ((argc > 0) && (argv[0])) + prog = argv[0]; + else + prog = parser->prog; } var = getenv("COLUMNS"); if (var) { - cols = atoi(var); - if (cols < 20) - cols = 20; + cols = atoi(var); + if (cols < 20) + cols = 20; - helpcol = cols / 3; + helpcol = cols / 3; } _ecore_getopt_help_usage(fp, parser); @@ -651,20 +651,20 @@ _ecore_getopt_parse_find_long(const Ecore_Getopt *parser, const char *name) for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) { - if (!desc->longname) - continue; - - if (p) - { - if ((strncmp(name, desc->longname, len) == 0) && - (desc->longname[len] == '\0')) - return desc; - } - else - { - if (strcmp(name, desc->longname) == 0) - return desc; - } + if (!desc->longname) + continue; + + if (p) + { + if ((strncmp(name, desc->longname, len) == 0) && + (desc->longname[len] == '\0')) + return desc; + } + else + { + if (strcmp(name, desc->longname) == 0) + return desc; + } } return NULL; @@ -693,75 +693,75 @@ _ecore_getopt_parse_find_nonargs_base(const Ecore_Getopt *parser, int argc, char base = 0; while (src < argc) { - const Ecore_Getopt_Desc *desc; - Ecore_Getopt_Desc_Arg_Requirement arg_req; - char *arg = argv[src]; - - if (arg[0] != '-') - goto found_nonarg; - - if (arg[1] == '-') - { - if (arg[2] == '\0') /* explicit end of options, "--" */ - { - base = 1; - break; - } - desc = _ecore_getopt_parse_find_long(parser, arg + 2); - } - else - desc = _ecore_getopt_parse_find_short(parser, arg[1]); - - if (!desc) - { - if (arg[1] == '-') - fprintf(stderr, _("ERROR: unknown option --%s.\n"), arg + 2); - else - fprintf(stderr, _("ERROR: unknown option -%c.\n"), arg[1]); - if (parser->strict) - { - memmove(argv + dst, nonargs, used * sizeof(char *)); - return -1; - } - else - goto found_nonarg; - } - - if (src != dst) - argv[dst] = argv[src]; - src++; - dst++; - - arg_req = _ecore_getopt_desc_arg_requirement(desc); - if (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) - continue; - - if (strchr(arg, '=')) - continue; - - if ((src >= argc) || (argv[src][0] == '-')) - continue; - - if (src != dst) - argv[dst] = argv[src]; - src++; - dst++; - continue; + const Ecore_Getopt_Desc *desc; + Ecore_Getopt_Desc_Arg_Requirement arg_req; + char *arg = argv[src]; + + if (arg[0] != '-') + goto found_nonarg; + + if (arg[1] == '-') + { + if (arg[2] == '\0') /* explicit end of options, "--" */ + { + base = 1; + break; + } + desc = _ecore_getopt_parse_find_long(parser, arg + 2); + } + else + desc = _ecore_getopt_parse_find_short(parser, arg[1]); + + if (!desc) + { + if (arg[1] == '-') + fprintf(stderr, _("ERROR: unknown option --%s.\n"), arg + 2); + else + fprintf(stderr, _("ERROR: unknown option -%c.\n"), arg[1]); + if (parser->strict) + { + memmove(argv + dst, nonargs, used * sizeof(char *)); + return -1; + } + else + goto found_nonarg; + } + + if (src != dst) + argv[dst] = argv[src]; + src++; + dst++; + + arg_req = _ecore_getopt_desc_arg_requirement(desc); + if (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) + continue; + + if (strchr(arg, '=')) + continue; + + if ((src >= argc) || (argv[src][0] == '-')) + continue; + + if (src != dst) + argv[dst] = argv[src]; + src++; + dst++; + continue; found_nonarg: - nonargs[used] = arg; - used++; - src++; + nonargs[used] = arg; + used++; + src++; } if (!base) /* '--' not found */ base = dst; else { - base = dst; - if (src != dst) - argv[dst] = argv[src]; - dst++; + base = dst; + if (src != dst) + argv[dst] = argv[src]; + dst++; } memmove(argv + dst, nonargs, used * sizeof(char *)); @@ -777,8 +777,8 @@ _ecore_getopt_desc_print_error(const Ecore_Getopt_Desc *desc, const char *fmt, . if (desc->shortname) { - fputc('-', stderr); - fputc(desc->shortname, stderr); + fputc('-', stderr); + fputc(desc->shortname, stderr); } if (desc->shortname && desc->longname) @@ -786,8 +786,8 @@ _ecore_getopt_desc_print_error(const Ecore_Getopt_Desc *desc, const char *fmt, . if (desc->longname) { - fputs("--", stderr); - fputs(desc->longname, stderr); + fputs("--", stderr); + fputs(desc->longname, stderr); } fputs(": ", stderr); @@ -807,18 +807,18 @@ _ecore_getopt_parse_bool(const char *str, unsigned char *v) (strcasecmp(str, "off") == 0) ) { - *v = 0; - return 1; + *v = 0; + return 1; } else if ((strcmp(str, "1") == 0) || - (strcasecmp(str, "t") == 0) || - (strcasecmp(str, "true") == 0) || - (strcasecmp(str, "yes") == 0) || - (strcasecmp(str, "on") == 0) - ) + (strcasecmp(str, "t") == 0) || + (strcasecmp(str, "true") == 0) || + (strcasecmp(str, "yes") == 0) || + (strcasecmp(str, "on") == 0) + ) { - *v = 1; - return 1; + *v = 1; + return 1; } return 0; @@ -850,73 +850,73 @@ _ecore_getopt_parse_store(const Ecore_Getopt *parser __UNUSED__, const Ecore_Get if (!value->ptrp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } switch (store->arg_req) { case ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO: - goto use_optional; + goto use_optional; case ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL: - if (!arg_val) - goto use_optional; + if (!arg_val) + goto use_optional; case ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES: - break; + break; } switch (store->type) { case ECORE_GETOPT_TYPE_STR: - *value->strp = (char *)arg_val; - return 1; + *value->strp = (char *)arg_val; + return 1; case ECORE_GETOPT_TYPE_BOOL: - if (_ecore_getopt_parse_bool(arg_val, &b)) - { - *value->boolp = b; - return 1; - } - else - { - _ecore_getopt_desc_print_error - (desc, _("unknown boolean value %s.\n"), arg_val); - return 0; - } + if (_ecore_getopt_parse_bool(arg_val, &b)) + { + *value->boolp = b; + return 1; + } + else + { + _ecore_getopt_desc_print_error + (desc, _("unknown boolean value %s.\n"), arg_val); + return 0; + } case ECORE_GETOPT_TYPE_SHORT: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->shortp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->shortp = v; + return 1; case ECORE_GETOPT_TYPE_INT: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->intp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->intp = v; + return 1; case ECORE_GETOPT_TYPE_LONG: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->longp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->longp = v; + return 1; case ECORE_GETOPT_TYPE_USHORT: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->ushortp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->ushortp = v; + return 1; case ECORE_GETOPT_TYPE_UINT: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->uintp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->uintp = v; + return 1; case ECORE_GETOPT_TYPE_ULONG: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->ulongp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->ulongp = v; + return 1; case ECORE_GETOPT_TYPE_DOUBLE: - if (!_ecore_getopt_parse_double(arg_val, &d)) - goto error; - *value->doublep = d; - break; + if (!_ecore_getopt_parse_double(arg_val, &d)) + goto error; + *value->doublep = d; + break; } return 1; @@ -930,32 +930,32 @@ _ecore_getopt_parse_store(const Ecore_Getopt *parser __UNUSED__, const Ecore_Get switch (store->type) { case ECORE_GETOPT_TYPE_STR: - *value->strp = (char *)store->def.strv; - break; + *value->strp = (char *)store->def.strv; + break; case ECORE_GETOPT_TYPE_BOOL: - *value->boolp = store->def.boolv; - break; + *value->boolp = store->def.boolv; + break; case ECORE_GETOPT_TYPE_SHORT: - *value->shortp = store->def.shortv; - break; + *value->shortp = store->def.shortv; + break; case ECORE_GETOPT_TYPE_INT: - *value->intp = store->def.intv; - break; + *value->intp = store->def.intv; + break; case ECORE_GETOPT_TYPE_LONG: - *value->longp = store->def.longv; - break; + *value->longp = store->def.longv; + break; case ECORE_GETOPT_TYPE_USHORT: - *value->ushortp = store->def.ushortv; - break; + *value->ushortp = store->def.ushortv; + break; case ECORE_GETOPT_TYPE_UINT: - *value->uintp = store->def.uintv; - break; + *value->uintp = store->def.uintv; + break; case ECORE_GETOPT_TYPE_ULONG: - *value->ulongp = store->def.ulongv; - break; + *value->ulongp = store->def.ulongv; + break; case ECORE_GETOPT_TYPE_DOUBLE: - *value->doublep = store->def.doublev; - break; + *value->doublep = store->def.doublev; + break; } return 1; @@ -966,8 +966,8 @@ _ecore_getopt_parse_store_const(const Ecore_Getopt *parser __UNUSED__, const Eco { if (!val->ptrp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } *val->ptrp = (void *)desc->action_param.store_const; @@ -979,8 +979,8 @@ _ecore_getopt_parse_store_true(const Ecore_Getopt *parser __UNUSED__, const Ecor { if (!val->boolp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } *val->boolp = 1; return 1; @@ -991,8 +991,8 @@ _ecore_getopt_parse_store_false(const Ecore_Getopt *parser __UNUSED__, const Eco { if (!val->boolp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } *val->boolp = 0; return 1; @@ -1005,16 +1005,16 @@ _ecore_getopt_parse_choice(const Ecore_Getopt *parser __UNUSED__, const Ecore_Ge if (!val->strp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } pchoice = desc->action_param.choices; for (; *pchoice; pchoice++) if (strcmp(*pchoice, arg_val) == 0) { - *val->strp = (char *)*pchoice; - return 1; + *val->strp = (char *)*pchoice; + return 1; } _ecore_getopt_desc_print_error @@ -1023,9 +1023,9 @@ _ecore_getopt_parse_choice(const Ecore_Getopt *parser __UNUSED__, const Ecore_Ge pchoice = desc->action_param.choices; for (; *pchoice; pchoice++) { - fputs(*pchoice, stderr); - if (pchoice[1]) - fputs(", ", stderr); + fputs(*pchoice, stderr); + if (pchoice[1]) + fputs(", ", stderr); } fputs(".\n", stderr); @@ -1042,106 +1042,106 @@ _ecore_getopt_parse_append(const Ecore_Getopt *parser __UNUSED__, const Ecore_Ge if (!arg_val) { - _ecore_getopt_desc_print_error - (desc, _("missing parameter to append.\n")); - return 0; + _ecore_getopt_desc_print_error + (desc, _("missing parameter to append.\n")); + return 0; } if (!val->listp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } switch (desc->action_param.append_type) { case ECORE_GETOPT_TYPE_STR: - data = strdup(arg_val); - break; + data = strdup(arg_val); + break; case ECORE_GETOPT_TYPE_BOOL: - { - if (_ecore_getopt_parse_bool(arg_val, &b)) - { - data = malloc(sizeof(unsigned char)); - if (data) - *(unsigned char *)data = b; - } - else - { - _ecore_getopt_desc_print_error - (desc, _("unknown boolean value %s.\n"), arg_val); - return 0; - } - } - break; + { + if (_ecore_getopt_parse_bool(arg_val, &b)) + { + data = malloc(sizeof(unsigned char)); + if (data) + *(unsigned char *)data = b; + } + else + { + _ecore_getopt_desc_print_error + (desc, _("unknown boolean value %s.\n"), arg_val); + return 0; + } + } + break; case ECORE_GETOPT_TYPE_SHORT: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(short)); - if (data) - *(short *)data = (short)v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(short)); + if (data) + *(short *)data = (short)v; + } + break; case ECORE_GETOPT_TYPE_INT: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(int)); - if (data) - *(int *)data = (int)v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(int)); + if (data) + *(int *)data = (int)v; + } + break; case ECORE_GETOPT_TYPE_LONG: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(long)); - if (data) - *(long *)data = v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(long)); + if (data) + *(long *)data = v; + } + break; case ECORE_GETOPT_TYPE_USHORT: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(unsigned short)); - if (data) - *(unsigned short *)data = (unsigned short)v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(unsigned short)); + if (data) + *(unsigned short *)data = (unsigned short)v; + } + break; case ECORE_GETOPT_TYPE_UINT: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(unsigned int)); - if (data) - *(unsigned int *)data = (unsigned int)v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(unsigned int)); + if (data) + *(unsigned int *)data = (unsigned int)v; + } + break; case ECORE_GETOPT_TYPE_ULONG: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(unsigned long)); - if (data) - *(unsigned long *)data = v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(unsigned long)); + if (data) + *(unsigned long *)data = v; + } + break; case ECORE_GETOPT_TYPE_DOUBLE: - { - if (!_ecore_getopt_parse_double(arg_val, &d)) - goto error; - data = malloc(sizeof(double)); - if (data) - *(double *)data = d; - } - break; + { + if (!_ecore_getopt_parse_double(arg_val, &d)) + goto error; + data = malloc(sizeof(double)); + if (data) + *(double *)data = d; + } + break; default: - { - _ecore_getopt_desc_print_error(desc, _("could not parse value.\n")); - return 0; - } + { + _ecore_getopt_desc_print_error(desc, _("could not parse value.\n")); + return 0; + } } *val->listp = eina_list_append(*val->listp, data); @@ -1158,8 +1158,8 @@ _ecore_getopt_parse_count(const Ecore_Getopt *parser __UNUSED__, const Ecore_Get { if (!val->intp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } (*val->intp)++; @@ -1174,36 +1174,36 @@ _ecore_getopt_parse_callback(const Ecore_Getopt *parser, const Ecore_Getopt_Desc switch (cb->arg_req) { case ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO: - arg_val = cb->def; - break; + arg_val = cb->def; + break; case ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL: - if (!arg_val) - arg_val = cb->def; - break; + if (!arg_val) + arg_val = cb->def; + break; case ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES: - break; + break; } if (cb->arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) { - if ((!arg_val) || (arg_val[0] == '\0')) - { - _ecore_getopt_desc_print_error(desc, _("missing parameter.\n")); - return 0; - } - - if (!val->ptrp) - { - _ecore_getopt_desc_print_error - (desc, _("value has no pointer set.\n")); - return 0; - } + if ((!arg_val) || (arg_val[0] == '\0')) + { + _ecore_getopt_desc_print_error(desc, _("missing parameter.\n")); + return 0; + } + + if (!val->ptrp) + { + _ecore_getopt_desc_print_error + (desc, _("value has no pointer set.\n")); + return 0; + } } if (!cb->func) { - _ecore_getopt_desc_print_error(desc, _("missing callback function!\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("missing callback function!\n")); + return 0; } return cb->func(parser, desc, arg_val, (void *)cb->data, val); @@ -1225,8 +1225,8 @@ _ecore_getopt_parse_version(const Ecore_Getopt *parser, const Ecore_Getopt_Desc (*val->boolp) = 1; if (!parser->version) { - _ecore_getopt_desc_print_error(desc, _("no version was defined.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("no version was defined.\n")); + return 0; } _ecore_getopt_version(stdout, parser); return 1; @@ -1239,8 +1239,8 @@ _ecore_getopt_parse_copyright(const Ecore_Getopt *parser, const Ecore_Getopt_Des (*val->boolp) = 1; if (!parser->copyright) { - _ecore_getopt_desc_print_error(desc, _("no copyright was defined.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("no copyright was defined.\n")); + return 0; } _ecore_getopt_copyright(stdout, parser); return 1; @@ -1253,8 +1253,8 @@ _ecore_getopt_parse_license(const Ecore_Getopt *parser, const Ecore_Getopt_Desc (*val->boolp) = 1; if (!parser->license) { - _ecore_getopt_desc_print_error(desc, _("no license was defined.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("no license was defined.\n")); + return 0; } _ecore_getopt_license(stdout, parser); return 1; @@ -1266,31 +1266,31 @@ _ecore_getopt_desc_handle(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *d switch (desc->action) { case ECORE_GETOPT_ACTION_STORE: - return _ecore_getopt_parse_store(parser, desc, value, arg_val); + return _ecore_getopt_parse_store(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_STORE_CONST: - return _ecore_getopt_parse_store_const(parser, desc, value, arg_val); + return _ecore_getopt_parse_store_const(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_STORE_TRUE: - return _ecore_getopt_parse_store_true(parser, desc, value, arg_val); + return _ecore_getopt_parse_store_true(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_STORE_FALSE: - return _ecore_getopt_parse_store_false(parser, desc, value, arg_val); + return _ecore_getopt_parse_store_false(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_CHOICE: - return _ecore_getopt_parse_choice(parser, desc, value, arg_val); + return _ecore_getopt_parse_choice(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_APPEND: - return _ecore_getopt_parse_append(parser, desc, value, arg_val); + return _ecore_getopt_parse_append(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_COUNT: - return _ecore_getopt_parse_count(parser, desc, value, arg_val); + return _ecore_getopt_parse_count(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_CALLBACK: - return _ecore_getopt_parse_callback(parser, desc, value, arg_val); + return _ecore_getopt_parse_callback(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_HELP: - return _ecore_getopt_parse_help(parser, desc, value, arg_val); + return _ecore_getopt_parse_help(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_VERSION: - return _ecore_getopt_parse_version(parser, desc, value, arg_val); + return _ecore_getopt_parse_version(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_COPYRIGHT: - return _ecore_getopt_parse_copyright(parser, desc, value, arg_val); + return _ecore_getopt_parse_copyright(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_LICENSE: - return _ecore_getopt_parse_license(parser, desc, value, arg_val); + return _ecore_getopt_parse_license(parser, desc, value, arg_val); default: - return 0; + return 0; } } @@ -1307,12 +1307,12 @@ _ecore_getopt_parse_arg_long(const Ecore_Getopt *parser, Ecore_Getopt_Value *val desc = _ecore_getopt_parse_find_long(parser, arg); if (!desc) { - fprintf(stderr, _("ERROR: unknown option --%s, ignored.\n"), arg); - if (parser->strict) - return 0; + fprintf(stderr, _("ERROR: unknown option --%s, ignored.\n"), arg); + if (parser->strict) + return 0; - (*idx)++; - return 1; + (*idx)++; + return 1; } (*idx)++; @@ -1320,31 +1320,31 @@ _ecore_getopt_parse_arg_long(const Ecore_Getopt *parser, Ecore_Getopt_Value *val arg_req = _ecore_getopt_desc_arg_requirement(desc); if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) { - arg_val = strchr(arg, '='); - if (arg_val) - arg_val++; - else - { - if ((*idx < *nonargs) && (argv[*idx][0] != '-')) - { - arg_val = argv[*idx]; - (*idx)++; - } - else - arg_val = NULL; - } - - if (arg_val && arg_val[0] == '\0') - arg_val = NULL; - - if ((!arg_val) && (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) - { - fprintf - (stderr, _("ERROR: option --%s requires an argument!\n"), arg); - if (parser->strict) - return 0; - return 1; - } + arg_val = strchr(arg, '='); + if (arg_val) + arg_val++; + else + { + if ((*idx < *nonargs) && (argv[*idx][0] != '-')) + { + arg_val = argv[*idx]; + (*idx)++; + } + else + arg_val = NULL; + } + + if (arg_val && arg_val[0] == '\0') + arg_val = NULL; + + if ((!arg_val) && (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) + { + fprintf + (stderr, _("ERROR: option --%s requires an argument!\n"), arg); + if (parser->strict) + return 0; + return 1; + } } else arg_val = NULL; @@ -1364,71 +1364,71 @@ _ecore_getopt_parse_arg_short(const Ecore_Getopt *parser, Ecore_Getopt_Value *va int run = 1; while (run && (arg[0] != '\0')) { - int opt = arg[0]; - const Ecore_Getopt_Desc *desc; - Ecore_Getopt_Desc_Arg_Requirement arg_req; - const char *arg_val; - int desc_idx; - Ecore_Getopt_Value *value; - unsigned char ret; - - desc = _ecore_getopt_parse_find_short(parser, arg[0]); - if (!desc) - { - fprintf - (stderr, _("ERROR: unknown option -%c, ignored.\n"), arg[0]); - if (parser->strict) - return 0; - - arg++; - continue; - } - - arg++; - - arg_req = _ecore_getopt_desc_arg_requirement(desc); - if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) - { - (*idx)++; - run = 0; - - if (arg[0] == '=') - arg_val = arg + 1; - else if (arg[0] != '\0') - arg_val = arg; - else - { - if ((*idx < *nonargs) && (argv[*idx][0] != '-')) - { - arg_val = argv[*idx]; - (*idx)++; - } - else - arg_val = NULL; - } - - if (arg_val && arg_val[0] == '\0') - arg_val = NULL; - - if ((!arg_val) && - (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) - { - fprintf - (stderr, _("ERROR: option -%c requires an argument!\n"), - opt); - if (parser->strict) - return 0; - return 1; - } - } - else - arg_val = NULL; - - desc_idx = desc - parser->descs; - value = values + desc_idx; - ret = _ecore_getopt_desc_handle(parser, desc, value, arg_val); - if ((!ret) && parser->strict) - return 0; + int opt = arg[0]; + const Ecore_Getopt_Desc *desc; + Ecore_Getopt_Desc_Arg_Requirement arg_req; + const char *arg_val; + int desc_idx; + Ecore_Getopt_Value *value; + unsigned char ret; + + desc = _ecore_getopt_parse_find_short(parser, arg[0]); + if (!desc) + { + fprintf + (stderr, _("ERROR: unknown option -%c, ignored.\n"), arg[0]); + if (parser->strict) + return 0; + + arg++; + continue; + } + + arg++; + + arg_req = _ecore_getopt_desc_arg_requirement(desc); + if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) + { + (*idx)++; + run = 0; + + if (arg[0] == '=') + arg_val = arg + 1; + else if (arg[0] != '\0') + arg_val = arg; + else + { + if ((*idx < *nonargs) && (argv[*idx][0] != '-')) + { + arg_val = argv[*idx]; + (*idx)++; + } + else + arg_val = NULL; + } + + if (arg_val && arg_val[0] == '\0') + arg_val = NULL; + + if ((!arg_val) && + (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) + { + fprintf + (stderr, _("ERROR: option -%c requires an argument!\n"), + opt); + if (parser->strict) + return 0; + return 1; + } + } + else + arg_val = NULL; + + desc_idx = desc - parser->descs; + value = values + desc_idx; + ret = _ecore_getopt_desc_handle(parser, desc, value, arg_val); + if ((!ret) && parser->strict) + return 0; } if (run) @@ -1444,18 +1444,18 @@ _ecore_getopt_parse_arg(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, if (arg[0] != '-') { - char **dst, **src, **src_end; + char **dst, **src, **src_end; - dst = argv + *idx; - src = dst + 1; - src_end = src + *nonargs - *idx - 1; + dst = argv + *idx; + src = dst + 1; + src_end = src + *nonargs - *idx - 1; - for (; src < src_end; src++, dst++) - *dst = *src; + for (; src < src_end; src++, dst++) + *dst = *src; - *dst = arg; - (*nonargs)--; - return 1; + *dst = arg; + (*nonargs)--; + return 1; } if (arg[1] == '-') @@ -1474,11 +1474,11 @@ _ecore_getopt_parse_find_short_other(const Ecore_Getopt *parser, const Ecore_Get for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) { - if (desc == orig) - return NULL; + if (desc == orig) + return NULL; - if (c == desc->shortname) - return desc; + if (c == desc->shortname) + return desc; } return NULL; @@ -1492,11 +1492,11 @@ _ecore_getopt_parse_find_long_other(const Ecore_Getopt *parser, const Ecore_Geto for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) { - if (desc == orig) - return NULL; + if (desc == orig) + return NULL; - if (desc->longname && (strcmp(name, desc->longname) == 0)) - return desc; + if (desc->longname && (strcmp(name, desc->longname) == 0)) + return desc; } return NULL; @@ -1514,38 +1514,38 @@ ecore_getopt_parser_has_duplicates(const Ecore_Getopt *parser) for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) { if (desc->shortname) - { - const Ecore_Getopt_Desc *other; - other = _ecore_getopt_parse_find_short_other(parser, desc); - if (other) - { - _ecore_getopt_desc_print_error - (desc, "short name -%c already exists.", desc->shortname); - - if (other->longname) - fprintf(stderr, " Other is --%s.\n", other->longname); - else - fputc('\n', stderr); - return 1; - } - } + { + const Ecore_Getopt_Desc *other; + other = _ecore_getopt_parse_find_short_other(parser, desc); + if (other) + { + _ecore_getopt_desc_print_error + (desc, "short name -%c already exists.", desc->shortname); + + if (other->longname) + fprintf(stderr, " Other is --%s.\n", other->longname); + else + fputc('\n', stderr); + return 1; + } + } if (desc->longname) - { - const Ecore_Getopt_Desc *other; - other = _ecore_getopt_parse_find_long_other(parser, desc); - if (other) - { - _ecore_getopt_desc_print_error - (desc, "long name --%s already exists.", desc->longname); - - if (other->shortname) - fprintf(stderr, " Other is -%c.\n", other->shortname); - else - fputc('\n', stderr); - return 1; - } - } + { + const Ecore_Getopt_Desc *other; + other = _ecore_getopt_parse_find_long_other(parser, desc); + if (other) + { + _ecore_getopt_desc_print_error + (desc, "long name --%s already exists.", desc->longname); + + if (other->shortname) + fprintf(stderr, " Other is -%c.\n", other->shortname); + else + fputc('\n', stderr); + return 1; + } + } } return 0; } @@ -1617,13 +1617,13 @@ ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int a if (!parser) { - fputs(_("ERROR: no parser provided.\n"), stderr); - return -1; + fputs(_("ERROR: no parser provided.\n"), stderr); + return -1; } if (!values) { - fputs(_("ERROR: no values provided.\n"), stderr); - return -1; + fputs(_("ERROR: no values provided.\n"), stderr); + return -1; } if ((argc < 1) || (!argv)) @@ -1631,8 +1631,8 @@ ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int a if (argc < 1) { - fputs(_("ERROR: no arguments provided.\n"), stderr); - return -1; + fputs(_("ERROR: no arguments provided.\n"), stderr); + return -1; } if (argv[0]) @@ -1661,11 +1661,11 @@ ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int a help = _ecore_getopt_find_help(parser); if (!help) - fputc('\n', stderr); + fputc('\n', stderr); else if (help->longname) - fprintf(stderr, _(" See --%s.\n"), help->longname); + fprintf(stderr, _(" See --%s.\n"), help->longname); else - fprintf(stderr, _(" See -%c.\n"), help->shortname); + fprintf(stderr, _(" See -%c.\n"), help->shortname); } return -1; @@ -1702,8 +1702,8 @@ ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser __UNUSED__, cons if (sscanf(str, "%d:%d:%d:%d", &v->x, &v->y, &v->w, &v->h) != 4) { - fprintf(stderr, _("ERROR: incorrect geometry value '%s'\n"), str); - return 0; + fprintf(stderr, _("ERROR: incorrect geometry value '%s'\n"), str); + return 0; } return 1; @@ -1725,8 +1725,8 @@ ecore_getopt_callback_size_parse(const Ecore_Getopt *parser __UNUSED__, const Ec if (sscanf(str, "%dx%d", &v->w, &v->h) != 2) { - fprintf(stderr, _("ERROR: incorrect size value '%s'\n"), str); - return 0; + fprintf(stderr, _("ERROR: incorrect size value '%s'\n"), str); + return 0; } v->x = 0; v->y = 0; diff --git a/src/lib/ecore/ecore_glib.c b/src/lib/ecore/ecore_glib.c index 691889a..0972776 100644 --- a/src/lib/ecore/ecore_glib.c +++ b/src/lib/ecore/ecore_glib.c @@ -26,9 +26,9 @@ _ecore_glib_fds_resize(size_t size) if (!tmp) { - ERR("Could not realloc from %zu to %zu buckets.", - _ecore_glib_fds_size, size); - return EINA_FALSE; + ERR("Could not realloc from %zu to %zu buckets.", + _ecore_glib_fds_size, size); + return EINA_FALSE; } _ecore_glib_fds = tmp; @@ -51,7 +51,7 @@ _ecore_glib_context_query(GMainContext *ctx, int priority, int *p_timer) size_t size; reqfds = g_main_context_query - (ctx, priority, p_timer, _ecore_glib_fds, _ecore_glib_fds_size); + (ctx, priority, p_timer, _ecore_glib_fds, _ecore_glib_fds_size); if (reqfds <= (int)_ecore_glib_fds_size) break; size = (1 + reqfds / ECORE_GLIB_FDS_STEP) * ECORE_GLIB_FDS_STEP; @@ -62,7 +62,7 @@ _ecore_glib_context_query(GMainContext *ctx, int priority, int *p_timer) { size_t size; - size = (1 + reqfds / ECORE_GLIB_FDS_MAX_FREE) * ECORE_GLIB_FDS_MAX_FREE; + size = (1 + reqfds / ECORE_GLIB_FDS_MAX_FREE) * ECORE_GLIB_FDS_MAX_FREE; _ecore_glib_fds_resize(size); } @@ -78,14 +78,14 @@ _ecore_glib_context_poll_from(const GPollFD *pfds, int count, fd_set *rfds, fd_s for (; itr < itr_end; itr++) { if (glib_fds < itr->fd) - glib_fds = itr->fd; + glib_fds = itr->fd; if (itr->events & G_IO_IN) - FD_SET(itr->fd, rfds); + FD_SET(itr->fd, rfds); if (itr->events & G_IO_OUT) - FD_SET(itr->fd, wfds); + FD_SET(itr->fd, wfds); if (itr->events & (G_IO_HUP | G_IO_ERR)) - FD_SET(itr->fd, efds); + FD_SET(itr->fd, efds); } return glib_fds + 1; @@ -100,20 +100,20 @@ _ecore_glib_context_poll_to(GPollFD *pfds, int count, const fd_set *rfds, const { itr->revents = 0; if (FD_ISSET(itr->fd, rfds)) - { - itr->revents |= G_IO_IN; - ready--; - } + { + itr->revents |= G_IO_IN; + ready--; + } if (FD_ISSET(itr->fd, wfds)) - { - itr->revents |= G_IO_OUT; - ready--; - } + { + itr->revents |= G_IO_OUT; + ready--; + } if (FD_ISSET(itr->fd, efds)) - { - itr->revents |= G_IO_ERR; - ready--; - } + { + itr->revents |= G_IO_ERR; + ready--; + } } return ready; } @@ -172,11 +172,11 @@ _ecore_glib_select(int ecore_fds, fd_set *rfds, fd_set *wfds, fd_set *efds, stru g_mutex_lock(mutex); else { - if (!_ecore_glib_cond) - _ecore_glib_cond = g_cond_new(); + if (!_ecore_glib_cond) + _ecore_glib_cond = g_cond_new(); - while (!g_main_context_wait(ctx, _ecore_glib_cond, mutex)) - g_thread_yield(); + while (!g_main_context_wait(ctx, _ecore_glib_cond, mutex)) + g_thread_yield(); } ret = _ecore_glib_select__locked @@ -206,15 +206,15 @@ _ecore_glib_shutdown(void) if (_ecore_glib_fds) { - free(_ecore_glib_fds); - _ecore_glib_fds = NULL; + free(_ecore_glib_fds); + _ecore_glib_fds = NULL; } _ecore_glib_fds_size = 0; if (_ecore_glib_cond) { - g_cond_free(_ecore_glib_cond); - _ecore_glib_cond = NULL; + g_cond_free(_ecore_glib_cond); + _ecore_glib_cond = NULL; } #endif } diff --git a/src/lib/ecore/ecore_idle_enterer.c b/src/lib/ecore/ecore_idle_enterer.c index 52d7111..2b827ce 100644 --- a/src/lib/ecore/ecore_idle_enterer.c +++ b/src/lib/ecore/ecore_idle_enterer.c @@ -81,9 +81,9 @@ ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer) { if (!ECORE_MAGIC_CHECK(idle_enterer, ECORE_MAGIC_IDLE_ENTERER)) { - ECORE_MAGIC_FAIL(idle_enterer, ECORE_MAGIC_IDLE_ENTERER, - "ecore_idle_enterer_del"); - return NULL; + ECORE_MAGIC_FAIL(idle_enterer, ECORE_MAGIC_IDLE_ENTERER, + "ecore_idle_enterer_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_enterer->delete_me, NULL); idle_enterer->delete_me = 1; @@ -97,9 +97,9 @@ _ecore_idle_enterer_shutdown(void) Ecore_Idle_Enterer *ie; while ((ie = idle_enterers)) { - idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); + idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); } idle_enterers_delete_me = 0; idle_enterer_current = NULL; @@ -110,56 +110,56 @@ _ecore_idle_enterer_call(void) { if (!idle_enterer_current) { - /* regular main loop, start from head */ - idle_enterer_current = idle_enterers; + /* regular main loop, start from head */ + idle_enterer_current = idle_enterers; } else { - /* recursive main loop, continue from where we were */ - idle_enterer_current = - (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next; + /* recursive main loop, continue from where we were */ + idle_enterer_current = + (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next; } while (idle_enterer_current) { - Ecore_Idle_Enterer *ie = (Ecore_Idle_Enterer *)idle_enterer_current; - if (!ie->delete_me) - { - ie->references++; - if (!ie->func(ie->data)) - { - if (!ie->delete_me) ecore_idle_enterer_del(ie); - } - ie->references--; - } - if (idle_enterer_current) /* may have changed in recursive main loops */ - idle_enterer_current = - (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next; + Ecore_Idle_Enterer *ie = (Ecore_Idle_Enterer *)idle_enterer_current; + if (!ie->delete_me) + { + ie->references++; + if (!ie->func(ie->data)) + { + if (!ie->delete_me) ecore_idle_enterer_del(ie); + } + ie->references--; + } + if (idle_enterer_current) /* may have changed in recursive main loops */ + idle_enterer_current = + (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next; } if (idle_enterers_delete_me) { Ecore_Idle_Enterer *l; - int deleted_idler_enterers_in_use = 0; - - for (l = idle_enterers; l;) - { - Ecore_Idle_Enterer *ie = l; - l = (Ecore_Idle_Enterer *) EINA_INLIST_GET(l)->next; - if (ie->delete_me) - { - if (ie->references) - { - deleted_idler_enterers_in_use++; - continue; - } - - idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); - } - } - if (!deleted_idler_enterers_in_use) - idle_enterers_delete_me = 0; + int deleted_idler_enterers_in_use = 0; + + for (l = idle_enterers; l;) + { + Ecore_Idle_Enterer *ie = l; + l = (Ecore_Idle_Enterer *) EINA_INLIST_GET(l)->next; + if (ie->delete_me) + { + if (ie->references) + { + deleted_idler_enterers_in_use++; + continue; + } + + idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); + } + } + if (!deleted_idler_enterers_in_use) + idle_enterers_delete_me = 0; } } diff --git a/src/lib/ecore/ecore_idle_exiter.c b/src/lib/ecore/ecore_idle_exiter.c index a129590..d8234e3 100644 --- a/src/lib/ecore/ecore_idle_exiter.c +++ b/src/lib/ecore/ecore_idle_exiter.c @@ -57,9 +57,9 @@ ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter) { if (!ECORE_MAGIC_CHECK(idle_exiter, ECORE_MAGIC_IDLE_EXITER)) { - ECORE_MAGIC_FAIL(idle_exiter, ECORE_MAGIC_IDLE_EXITER, - "ecore_idle_exiter_del"); - return NULL; + ECORE_MAGIC_FAIL(idle_exiter, ECORE_MAGIC_IDLE_EXITER, + "ecore_idle_exiter_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_exiter->delete_me, NULL); idle_exiter->delete_me = 1; @@ -73,9 +73,9 @@ _ecore_idle_exiter_shutdown(void) Ecore_Idle_Exiter *ie; while ((ie = idle_exiters)) { - idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(idle_exiters)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); + idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(idle_exiters)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); } idle_exiters_delete_me = 0; idle_exiter_current = NULL; @@ -86,57 +86,57 @@ _ecore_idle_exiter_call(void) { if (!idle_exiter_current) { - /* regular main loop, start from head */ - idle_exiter_current = idle_exiters; + /* regular main loop, start from head */ + idle_exiter_current = idle_exiters; } else { - /* recursive main loop, continue from where we were */ - idle_exiter_current = - (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next; + /* recursive main loop, continue from where we were */ + idle_exiter_current = + (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next; } while (idle_exiter_current) { - Ecore_Idle_Exiter *ie = (Ecore_Idle_Exiter *)idle_exiter_current; - if (!ie->delete_me) - { - ie->references++; - if (!ie->func(ie->data)) - { - if (!ie->delete_me) ecore_idle_exiter_del(ie); - } - ie->references--; - } - if (idle_exiter_current) /* may have changed in recursive main loops */ - idle_exiter_current = - (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next; + Ecore_Idle_Exiter *ie = (Ecore_Idle_Exiter *)idle_exiter_current; + if (!ie->delete_me) + { + ie->references++; + if (!ie->func(ie->data)) + { + if (!ie->delete_me) ecore_idle_exiter_del(ie); + } + ie->references--; + } + if (idle_exiter_current) /* may have changed in recursive main loops */ + idle_exiter_current = + (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next; } if (idle_exiters_delete_me) { - Ecore_Idle_Exiter *l; - int deleted_idler_exiters_in_use = 0; - - for (l = idle_exiters; l;) - { - Ecore_Idle_Exiter *ie = l; - - l = (Ecore_Idle_Exiter *) EINA_INLIST_GET(l)->next; - if (ie->delete_me) - { - if (ie->references) - { - deleted_idler_exiters_in_use++; - continue; - } - - idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); - } - } - if (!deleted_idler_exiters_in_use) - idle_exiters_delete_me = 0; + Ecore_Idle_Exiter *l; + int deleted_idler_exiters_in_use = 0; + + for (l = idle_exiters; l;) + { + Ecore_Idle_Exiter *ie = l; + + l = (Ecore_Idle_Exiter *) EINA_INLIST_GET(l)->next; + if (ie->delete_me) + { + if (ie->references) + { + deleted_idler_exiters_in_use++; + continue; + } + + idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); + } + } + if (!deleted_idler_exiters_in_use) + idle_exiters_delete_me = 0; } } diff --git a/src/lib/ecore/ecore_idler.c b/src/lib/ecore/ecore_idler.c index 0fa2ddf..8f1c820 100644 --- a/src/lib/ecore/ecore_idler.c +++ b/src/lib/ecore/ecore_idler.c @@ -65,9 +65,9 @@ ecore_idler_del(Ecore_Idler *idler) { if (!ECORE_MAGIC_CHECK(idler, ECORE_MAGIC_IDLER)) { - ECORE_MAGIC_FAIL(idler, ECORE_MAGIC_IDLER, - "ecore_idler_del"); - return NULL; + ECORE_MAGIC_FAIL(idler, ECORE_MAGIC_IDLER, + "ecore_idler_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL); idler->delete_me = 1; @@ -81,9 +81,9 @@ _ecore_idler_shutdown(void) Ecore_Idler *ie; while ((ie = idlers)) { - idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); + idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); } idlers_delete_me = 0; idler_current = NULL; @@ -94,53 +94,53 @@ _ecore_idler_call(void) { if (!idler_current) { - /* regular main loop, start from head */ - idler_current = idlers; + /* regular main loop, start from head */ + idler_current = idlers; } else { - /* recursive main loop, continue from where we were */ - idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next; + /* recursive main loop, continue from where we were */ + idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next; } while (idler_current) { - Ecore_Idler *ie = (Ecore_Idler *)idler_current; - if (!ie->delete_me) - { - ie->references++; - if (!ie->func(ie->data)) - { - if (!ie->delete_me) ecore_idler_del(ie); - } - ie->references--; - } - if (idler_current) /* may have changed in recursive main loops */ - idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next; + Ecore_Idler *ie = (Ecore_Idler *)idler_current; + if (!ie->delete_me) + { + ie->references++; + if (!ie->func(ie->data)) + { + if (!ie->delete_me) ecore_idler_del(ie); + } + ie->references--; + } + if (idler_current) /* may have changed in recursive main loops */ + idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next; } if (idlers_delete_me) { - Ecore_Idler *l; - int deleted_idlers_in_use = 0; - for (l = idlers; l;) - { - Ecore_Idler *ie = l; - l = (Ecore_Idler *) EINA_INLIST_GET(l)->next; - if (ie->delete_me) - { - if (ie->references) - { - deleted_idlers_in_use++; - continue; - } + Ecore_Idler *l; + int deleted_idlers_in_use = 0; + for (l = idlers; l;) + { + Ecore_Idler *ie = l; + l = (Ecore_Idler *) EINA_INLIST_GET(l)->next; + if (ie->delete_me) + { + if (ie->references) + { + deleted_idlers_in_use++; + continue; + } - idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); - } - } - if (!deleted_idlers_in_use) - idlers_delete_me = 0; + idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); + } + } + if (!deleted_idlers_in_use) + idlers_delete_me = 0; } if (idlers) return 1; return 0; diff --git a/src/lib/ecore/ecore_job.c b/src/lib/ecore/ecore_job.c index bd50232..cd519f7 100644 --- a/src/lib/ecore/ecore_job.c +++ b/src/lib/ecore/ecore_job.c @@ -58,8 +58,8 @@ ecore_job_add(Ecore_Cb func, const void *data) job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, NULL); if (!job->event) { - free(job); - return NULL; + free(job); + return NULL; } job->func = func; job->data = (void *)data; @@ -79,9 +79,9 @@ ecore_job_del(Ecore_Job *job) if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_JOB)) { - ECORE_MAGIC_FAIL(job, ECORE_MAGIC_JOB, - "ecore_job_del"); - return NULL; + ECORE_MAGIC_FAIL(job, ECORE_MAGIC_JOB, + "ecore_job_del"); + return NULL; } data = job->data; ECORE_MAGIC_SET(job, ECORE_MAGIC_NONE); diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c index 87471c2..de507da 100644 --- a/src/lib/ecore/ecore_main.c +++ b/src/lib/ecore/ecore_main.c @@ -104,7 +104,7 @@ static void _ecore_main_loop_iterate_internal(int once_only); #ifdef _WIN32 static int _ecore_main_win32_select(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout); + fd_set *exceptfds, struct timeval *timeout); static void _ecore_main_win32_handlers_cleanup(void); #endif @@ -188,7 +188,7 @@ static inline void _ecore_main_fdh_epoll_del(Ecore_Fd_Handler *fdh) if ((epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fdh->fd, &ev) < 0) && (errno != EBADF)) { - ERR("Failed to delete epoll fd %d! (errno=%d)", fdh->fd, errno); + ERR("Failed to delete epoll fd %d! (errno=%d)", fdh->fd, errno); } } #else @@ -324,7 +324,7 @@ _ecore_main_gsource_check(GSource *source) in_main_loop--; INF("leave"); - return TRUE; /* always dispatch */ + return TRUE; /* always dispatch */ } /* like we just came out of main_loop_select in _ecore_main_select */ @@ -379,9 +379,9 @@ _ecore_main_gsource_dispatch(GSource *source, GSourceFunc callback, gpointer use INF("work"); _ecore_main_fd_handlers_call(); _ecore_main_fd_handlers_buf_call(); - while (_ecore_signal_count_get()) _ecore_signal_call(); + while (_ecore_signal_count_get()) _ecore_signal_call(); _ecore_event_call(); - _ecore_main_fd_handlers_cleanup(); + _ecore_main_fd_handlers_cleanup(); } in_main_loop--; @@ -613,9 +613,9 @@ ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func fdh->flags = flags; if (0 > _ecore_main_fdh_epoll_add(fdh)) { - ERR("Failed to add epoll fd %d (errno = %d)!", fd, errno); - free(fdh); - return NULL; + ERR("Failed to add epoll fd %d (errno = %d)!", fd, errno); + free(fdh); + return NULL; } fdh->read_active = 0; fdh->write_active = 0; @@ -677,9 +677,9 @@ ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler) { if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_del"); - return NULL; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_del"); + return NULL; } fd_handler->delete_me = 1; fd_handlers_delete_me = 1; @@ -693,9 +693,9 @@ ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler) { if (!ECORE_MAGIC_CHECK(win32_handler, ECORE_MAGIC_WIN32_HANDLER)) { - ECORE_MAGIC_FAIL(win32_handler, ECORE_MAGIC_WIN32_HANDLER, - "ecore_main_win32_handler_del"); - return NULL; + ECORE_MAGIC_FAIL(win32_handler, ECORE_MAGIC_WIN32_HANDLER, + "ecore_main_win32_handler_del"); + return NULL; } win32_handler->delete_me = 1; win32_handlers_delete_me = 1; @@ -714,9 +714,9 @@ ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_F { if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_prepare_callback_set"); - return; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_prepare_callback_set"); + return; } fd_handler->prep_func = func; fd_handler->prep_data = (void *) data; @@ -733,9 +733,9 @@ ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler) { if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_fd_get"); - return -1; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_fd_get"); + return -1; } return fd_handler->fd; } @@ -756,9 +756,9 @@ ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_ if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_active_get"); - return EINA_FALSE; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_active_get"); + return EINA_FALSE; } if ((flags & ECORE_FD_READ) && (fd_handler->read_active)) ret = EINA_TRUE; if ((flags & ECORE_FD_WRITE) && (fd_handler->write_active)) ret = EINA_TRUE; @@ -777,9 +777,9 @@ ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_ { if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_active_set"); - return; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_active_set"); + return; } fd_handler->flags = flags; if (0 > _ecore_main_fdh_epoll_modify(fd_handler)) @@ -794,19 +794,19 @@ _ecore_main_shutdown(void) if (in_main_loop) { ERR("\n" - "*** ECORE WARINING: Calling ecore_shutdown() while still in the main loop.\n" - "*** Program may crash or behave strangely now."); - return; + "*** ECORE WARINING: Calling ecore_shutdown() while still in the main loop.\n" + "*** Program may crash or behave strangely now."); + return; } while (fd_handlers) { - Ecore_Fd_Handler *fdh; + Ecore_Fd_Handler *fdh; - fdh = fd_handlers; - fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers), - EINA_INLIST_GET(fdh)); - ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE); - free(fdh); + fdh = fd_handlers; + fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers), + EINA_INLIST_GET(fdh)); + ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE); + free(fdh); } fd_handlers_delete_me = 0; fd_handler_current = NULL; @@ -814,13 +814,13 @@ _ecore_main_shutdown(void) #ifdef _WIN32 while (win32_handlers) { - Ecore_Win32_Handler *wh; + Ecore_Win32_Handler *wh; - wh = win32_handlers; - win32_handlers = (Ecore_Win32_Handler *) eina_inlist_remove(EINA_INLIST_GET(win32_handlers), - EINA_INLIST_GET(wh)); - ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE); - free(wh); + wh = win32_handlers; + win32_handlers = (Ecore_Win32_Handler *) eina_inlist_remove(EINA_INLIST_GET(win32_handlers), + EINA_INLIST_GET(wh)); + ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE); + free(wh); } win32_handlers_delete_me = 0; win32_handler_current = NULL; @@ -853,27 +853,27 @@ _ecore_main_select(double timeout) int ret; t = NULL; - if ((!finite(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity. */ + if ((!finite(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity. */ { - tv.tv_sec = 0; - tv.tv_usec = 0; - t = &tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + t = &tv; } else if (timeout > 0.0) { - int sec, usec; + int sec, usec; #ifdef FIX_HZ - timeout += (0.5 / HZ); - sec = (int)timeout; - usec = (int)((timeout - (double)sec) * 1000000); + timeout += (0.5 / HZ); + sec = (int)timeout; + usec = (int)((timeout - (double)sec) * 1000000); #else - sec = (int)timeout; - usec = (int)((timeout - (double)sec) * 1000000); + sec = (int)timeout; + usec = (int)((timeout - (double)sec) * 1000000); #endif - tv.tv_sec = sec; - tv.tv_usec = usec; - t = &tv; + tv.tv_sec = sec; + tv.tv_usec = usec; + t = &tv; } max_fd = 0; FD_ZERO(&rfds); @@ -920,8 +920,8 @@ _ecore_main_select(double timeout) if (ret < 0) { #ifndef _WIN32 - if (errno == EINTR) return -1; - else if (errno == EBADF) _ecore_main_fd_handlers_bads_rem(); + if (errno == EINTR) return -1; + else if (errno == EBADF) _ecore_main_fd_handlers_bads_rem(); #endif } if (ret > 0) @@ -931,7 +931,7 @@ _ecore_main_select(double timeout) #else /* HAVE_EPOLL */ Ecore_Fd_Handler *fdh; - EINA_INLIST_FOREACH(fd_handlers, fdh) + EINA_INLIST_FOREACH(fd_handlers, fdh) { if (!fdh->delete_me) { @@ -944,11 +944,11 @@ _ecore_main_select(double timeout) } } #endif /* HAVE_EPOLL */ - _ecore_main_fd_handlers_cleanup(); + _ecore_main_fd_handlers_cleanup(); #ifdef _WIN32 - _ecore_main_win32_handlers_cleanup(); + _ecore_main_win32_handlers_cleanup(); #endif - return 1; + return 1; } return 0; } @@ -964,34 +964,34 @@ _ecore_main_fd_handlers_bads_rem(void) ERR("Removing bad fds"); for (l = EINA_INLIST_GET(fd_handlers); l; ) { - fdh = (Ecore_Fd_Handler *) l; - l = l->next; - errno = 0; - - if ((fcntl(fdh->fd, F_GETFD) < 0) && (errno == EBADF)) - { - ERR("Found bad fd at index %d", fdh->fd); - if (fdh->flags & ECORE_FD_ERROR) - { - ERR("Fd set for error! calling user"); - fdh->references++; - if (!fdh->func(fdh->data, fdh)) - { - ERR("Fd function err returned 0, remove it"); - fdh->delete_me = 1; - fd_handlers_delete_me = 1; + fdh = (Ecore_Fd_Handler *) l; + l = l->next; + errno = 0; + + if ((fcntl(fdh->fd, F_GETFD) < 0) && (errno == EBADF)) + { + ERR("Found bad fd at index %d", fdh->fd); + if (fdh->flags & ECORE_FD_ERROR) + { + ERR("Fd set for error! calling user"); + fdh->references++; + if (!fdh->func(fdh->data, fdh)) + { + ERR("Fd function err returned 0, remove it"); + fdh->delete_me = 1; + fd_handlers_delete_me = 1; found++; - } - fdh->references--; - } - else - { - ERR("Problematic fd found at %d! setting it for delete", fdh->fd); - fdh->delete_me = 1; - fd_handlers_delete_me = 1; + } + fdh->references--; + } + else + { + ERR("Problematic fd found at %d! setting it for delete", fdh->fd); + fdh->delete_me = 1; + fd_handlers_delete_me = 1; found++; - } - } + } + } } if (found == 0) { @@ -1015,23 +1015,23 @@ _ecore_main_fd_handlers_cleanup(void) if (!fd_handlers_delete_me) return; for (l = EINA_INLIST_GET(fd_handlers); l; ) { - fdh = (Ecore_Fd_Handler *) l; - - l = l->next; - if (fdh->delete_me) - { - if (fdh->references) - { - deleted_in_use++; - continue; - } + fdh = (Ecore_Fd_Handler *) l; + + l = l->next; + if (fdh->delete_me) + { + if (fdh->references) + { + deleted_in_use++; + continue; + } - fd_handlers = (Ecore_Fd_Handler *) + fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers), EINA_INLIST_GET(fdh)); - ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE); - free(fdh); - } + ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE); + free(fdh); + } } if (!deleted_in_use) fd_handlers_delete_me = 0; } @@ -1052,11 +1052,11 @@ _ecore_main_win32_handlers_cleanup(void) l = l->next; if (wh->delete_me) { - if (wh->references) - { - deleted_in_use++; - continue; - } + if (wh->references) + { + deleted_in_use++; + continue; + } win32_handlers = (Ecore_Win32_Handler *) eina_inlist_remove(EINA_INLIST_GET(win32_handlers), @@ -1074,41 +1074,41 @@ _ecore_main_fd_handlers_call(void) { if (!fd_handler_current) { - /* regular main loop, start from head */ - fd_handler_current = fd_handlers; + /* regular main loop, start from head */ + fd_handler_current = fd_handlers; } else { - /* recursive main loop, continue from where we were */ - fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next; + /* recursive main loop, continue from where we were */ + fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next; } while (fd_handler_current) { - Ecore_Fd_Handler *fdh = fd_handler_current; - - if (!fdh->delete_me) - { - if ((fdh->read_active) || - (fdh->write_active) || - (fdh->error_active)) - { - fdh->references++; - if (!fdh->func(fdh->data, fdh)) - { - fdh->delete_me = 1; - fd_handlers_delete_me = 1; - } - fdh->references--; - - fdh->read_active = 0; - fdh->write_active = 0; - fdh->error_active = 0; - } - } - - if (fd_handler_current) /* may have changed in recursive main loops */ - fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next; + Ecore_Fd_Handler *fdh = fd_handler_current; + + if (!fdh->delete_me) + { + if ((fdh->read_active) || + (fdh->write_active) || + (fdh->error_active)) + { + fdh->references++; + if (!fdh->func(fdh->data, fdh)) + { + fdh->delete_me = 1; + fd_handlers_delete_me = 1; + } + fdh->references--; + + fdh->read_active = 0; + fdh->write_active = 0; + fdh->error_active = 0; + } + } + + if (fd_handler_current) /* may have changed in recursive main loops */ + fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next; } } @@ -1156,21 +1156,21 @@ _ecore_main_loop_iterate_internal(int once_only) if (_ecore_event_exist()) { _ecore_idle_enterer_call(); - have_event = 1; - _ecore_main_select(0.0); + have_event = 1; + _ecore_main_select(0.0); _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); - goto process_events; + goto process_events; } /* call idle enterers ... */ if (!once_only) _ecore_idle_enterer_call(); else { - have_event = have_signal = 0; + have_event = have_signal = 0; - if (_ecore_main_select(0.0) > 0) have_event = 1; - if (_ecore_signal_count_get() > 0) have_signal = 1; - if (have_signal || have_event) + if (_ecore_main_select(0.0) > 0) have_event = 1; + if (_ecore_signal_count_get() > 0) have_signal = 1; + if (have_signal || have_event) { _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); @@ -1184,26 +1184,26 @@ _ecore_main_loop_iterate_internal(int once_only) /* if there are any - jump to processing them */ if (_ecore_event_exist()) { - have_event = 1; - _ecore_main_select(0.0); + have_event = 1; + _ecore_main_select(0.0); _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); - goto process_events; + goto process_events; } if (once_only) { - _ecore_idle_enterer_call(); - in_main_loop--; + _ecore_idle_enterer_call(); + in_main_loop--; _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); - return; + return; } if (_ecore_fps_debug) { - t2 = ecore_time_get(); - if ((t1 > 0.0) && (t2 > 0.0)) - _ecore_fps_debug_runtime_add(t2 - t1); + t2 = ecore_time_get(); + if ((t1 > 0.0) && (t2 > 0.0)) + _ecore_fps_debug_runtime_add(t2 - t1); } start_loop: /* any timers re-added as a result of these are allowed to go */ @@ -1211,62 +1211,62 @@ _ecore_main_loop_iterate_internal(int once_only) if (do_quit) { _ecore_time_loop_time = ecore_time_get(); - in_main_loop--; + in_main_loop--; _ecore_timer_enable_new(); - return; + return; } if (!_ecore_event_exist()) { - /* init flags */ - have_event = have_signal = 0; - next_time = _ecore_timer_next_get(); - /* no timers */ - if (next_time < 0) - { - /* no idlers */ - if (!_ecore_idler_exist()) - { - if (_ecore_main_select(-1.0) > 0) have_event = 1; - } - /* idlers */ - else - { - for (;;) - { - if (!_ecore_idler_call()) goto start_loop; - if (_ecore_event_exist()) break; - if (_ecore_main_select(0.0) > 0) have_event = 1; - if (_ecore_signal_count_get() > 0) have_signal = 1; - if (have_event || have_signal) break; - if (_ecore_timers_exists()) goto start_loop; - if (do_quit) break; - } - } - } - /* timers */ - else - { - /* no idlers */ - if (!_ecore_idler_exist()) - { - if (_ecore_main_select(next_time) > 0) have_event = 1; - } - /* idlers */ - else - { - for (;;) - { - if (!_ecore_idler_call()) goto start_loop; - if (_ecore_event_exist()) break; - if (_ecore_main_select(0.0) > 0) have_event = 1; - if (_ecore_signal_count_get() > 0) have_signal = 1; - if (have_event || have_signal) break; - next_time = _ecore_timer_next_get(); - if (next_time <= 0) break; - if (do_quit) break; - } - } - } + /* init flags */ + have_event = have_signal = 0; + next_time = _ecore_timer_next_get(); + /* no timers */ + if (next_time < 0) + { + /* no idlers */ + if (!_ecore_idler_exist()) + { + if (_ecore_main_select(-1.0) > 0) have_event = 1; + } + /* idlers */ + else + { + for (;;) + { + if (!_ecore_idler_call()) goto start_loop; + if (_ecore_event_exist()) break; + if (_ecore_main_select(0.0) > 0) have_event = 1; + if (_ecore_signal_count_get() > 0) have_signal = 1; + if (have_event || have_signal) break; + if (_ecore_timers_exists()) goto start_loop; + if (do_quit) break; + } + } + } + /* timers */ + else + { + /* no idlers */ + if (!_ecore_idler_exist()) + { + if (_ecore_main_select(next_time) > 0) have_event = 1; + } + /* idlers */ + else + { + for (;;) + { + if (!_ecore_idler_call()) goto start_loop; + if (_ecore_event_exist()) break; + if (_ecore_main_select(0.0) > 0) have_event = 1; + if (_ecore_signal_count_get() > 0) have_signal = 1; + if (have_event || have_signal) break; + next_time = _ecore_timer_next_get(); + if (next_time <= 0) break; + if (do_quit) break; + } + } + } _ecore_time_loop_time = ecore_time_get(); } if (_ecore_fps_debug) t1 = ecore_time_get(); @@ -1292,7 +1292,7 @@ _ecore_main_loop_iterate_internal(int once_only) #ifdef _WIN32 static int _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *tv) + fd_set *exceptfds, struct timeval *tv) { HANDLE objects[MAXIMUM_WAIT_OBJECTS]; int sockets[MAXIMUM_WAIT_OBJECTS]; @@ -1315,19 +1315,19 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, network_event = 0; if (FD_ISSET(fdh->fd, readfds)) - network_event |= FD_READ; + network_event |= FD_READ; if (FD_ISSET(fdh->fd, writefds)) - network_event |= FD_WRITE; + network_event |= FD_WRITE; if (FD_ISSET(fdh->fd, exceptfds)) - network_event |= FD_OOB; + network_event |= FD_OOB; if (network_event) - { + { event = WSACreateEvent(); - WSAEventSelect(fdh->fd, event, network_event); - objects[objects_nbr] = event; - sockets[events_nbr] = fdh->fd; - events_nbr++; + WSAEventSelect(fdh->fd, event, network_event); + objects[objects_nbr] = event; + sockets[events_nbr] = fdh->fd; + events_nbr++; objects_nbr++; } } @@ -1343,8 +1343,8 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, /* Empty the queue before waiting */ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } /* Wait for any message sent or posted to this queue */ @@ -1357,7 +1357,7 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, if (timeout == 0) return 0; result = MsgWaitForMultipleObjects(objects_nbr, (const HANDLE *)objects, EINA_FALSE, - timeout, QS_ALLINPUT); + timeout, QS_ALLINPUT); FD_ZERO(readfds); FD_ZERO(writefds); @@ -1381,10 +1381,10 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, else if (result == (WAIT_OBJECT_0 + objects_nbr)) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } res = 0; } @@ -1395,31 +1395,31 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, WSAEnumNetworkEvents(sockets[result], objects[result], &network_event); if (network_event.lNetworkEvents & FD_READ) - FD_SET(sockets[result], readfds); + FD_SET(sockets[result], readfds); if (network_event.lNetworkEvents & FD_WRITE) - FD_SET(sockets[result], writefds); + FD_SET(sockets[result], writefds); if (network_event.lNetworkEvents & FD_OOB) - FD_SET(sockets[result], exceptfds); + FD_SET(sockets[result], exceptfds); res = 1; } else if ((result >= (WAIT_OBJECT_0 + events_nbr)) && (result < (WAIT_OBJECT_0 + objects_nbr))) { - if (!win32_handler_current) - { - /* regular main loop, start from head */ - win32_handler_current = win32_handlers; - } - else - { - /* recursive main loop, continue from where we were */ - win32_handler_current = (Ecore_Win32_Handler *)EINA_INLIST_GET(win32_handler_current)->next; - } - - while (win32_handler_current) - { - wh = win32_handler_current; + if (!win32_handler_current) + { + /* regular main loop, start from head */ + win32_handler_current = win32_handlers; + } + else + { + /* recursive main loop, continue from where we were */ + win32_handler_current = (Ecore_Win32_Handler *)EINA_INLIST_GET(win32_handler_current)->next; + } + + while (win32_handler_current) + { + wh = win32_handler_current; if (objects[result - WAIT_OBJECT_0] == wh->h) { diff --git a/src/lib/ecore/ecore_pipe.c b/src/lib/ecore/ecore_pipe.c index 59b9805..8a8aca5 100644 --- a/src/lib/ecore/ecore_pipe.c +++ b/src/lib/ecore/ecore_pipe.c @@ -323,8 +323,8 @@ ecore_pipe_del(Ecore_Pipe *p) if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) { - ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del"); - return NULL; + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del"); + return NULL; } if (p->fd_handler) ecore_main_fd_handler_del(p->fd_handler); if (p->fd_read != PIPE_FD_INVALID) pipe_close(p->fd_read); @@ -345,8 +345,8 @@ ecore_pipe_read_close(Ecore_Pipe *p) { if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) { - ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close"); - return; + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close"); + return; } ecore_main_fd_handler_del(p->fd_handler); p->fd_handler = NULL; @@ -365,8 +365,8 @@ ecore_pipe_write_close(Ecore_Pipe *p) { if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) { - ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write_close"); - return; + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write_close"); + return; } pipe_close(p->fd_write); p->fd_write = PIPE_FD_INVALID; @@ -390,8 +390,8 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes) if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) { - ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write"); - return EINA_FALSE; + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write"); + return EINA_FALSE; } if (p->fd_write == PIPE_FD_INVALID) return EINA_FALSE; @@ -399,34 +399,34 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes) /* First write the len into the pipe */ do { - ret = pipe_write(p->fd_write, &nbytes, sizeof(nbytes)); - if (ret == sizeof(nbytes)) - { - retry = ECORE_PIPE_WRITE_RETRY; - break; - } - else if (ret > 0) - { - /* XXX What should we do here? */ - ERR("The length of the data was not written complete" - " to the pipe"); - return EINA_FALSE; - } - else if (ret == PIPE_FD_ERROR && errno == EPIPE) - { - pipe_close(p->fd_write); - p->fd_write = PIPE_FD_INVALID; - return EINA_FALSE; - } - else if (ret == PIPE_FD_ERROR && errno == EINTR) - /* try it again */ - ; - else - { - ERR("An unhandled error (ret: %zd errno: %d)" - "occurred while writing to the pipe the length", - ret, errno); - } + ret = pipe_write(p->fd_write, &nbytes, sizeof(nbytes)); + if (ret == sizeof(nbytes)) + { + retry = ECORE_PIPE_WRITE_RETRY; + break; + } + else if (ret > 0) + { + /* XXX What should we do here? */ + ERR("The length of the data was not written complete" + " to the pipe"); + return EINA_FALSE; + } + else if (ret == PIPE_FD_ERROR && errno == EPIPE) + { + pipe_close(p->fd_write); + p->fd_write = PIPE_FD_INVALID; + return EINA_FALSE; + } + else if (ret == PIPE_FD_ERROR && errno == EINTR) + /* try it again */ + ; + else + { + ERR("An unhandled error (ret: %zd errno: %d)" + "occurred while writing to the pipe the length", + ret, errno); + } } while (retry--); @@ -435,32 +435,32 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes) /* and now pass the data to the pipe */ do { - ret = pipe_write(p->fd_write, + ret = pipe_write(p->fd_write, ((unsigned char *)buffer) + already_written, nbytes - already_written); - if (ret == (ssize_t)(nbytes - already_written)) - return EINA_TRUE; - else if (ret >= 0) - { - already_written -= ret; - continue; - } - else if (ret == PIPE_FD_ERROR && errno == EPIPE) - { - pipe_close(p->fd_write); - p->fd_write = PIPE_FD_INVALID; - return EINA_FALSE; - } - else if (ret == PIPE_FD_ERROR && errno == EINTR) - /* try it again */ - ; - else - { - ERR("An unhandled error (ret: %zd errno: %d)" - "occurred while writing to the pipe the length", - ret, errno); - } + if (ret == (ssize_t)(nbytes - already_written)) + return EINA_TRUE; + else if (ret >= 0) + { + already_written -= ret; + continue; + } + else if (ret == PIPE_FD_ERROR && errno == EPIPE) + { + pipe_close(p->fd_write); + p->fd_write = PIPE_FD_INVALID; + return EINA_FALSE; + } + else if (ret == PIPE_FD_ERROR && errno == EINTR) + /* try it again */ + ; + else + { + ERR("An unhandled error (ret: %zd errno: %d)" + "occurred while writing to the pipe the length", + ret, errno); + } } while (retry--); @@ -480,46 +480,46 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) do { - ssize_t ret; - - /* if we already have read some data we don't need to read the len - * but to finish the already started job - */ - if (p->len == 0) - { - /* read the len of the passed data */ - ret = pipe_read(p->fd_read, &p->len, sizeof(p->len)); - - /* catch the non error case first */ - if (ret == sizeof(p->len)) - ; - else if (ret > 0) - { - /* XXX What should we do here? */ - ERR("Only read %zd bytes from the pipe, although" - " we need to read %zd bytes.", ret, sizeof(p->len)); - } - else if (ret == 0) - { - p->handler((void *)p->data, NULL, 0); - pipe_close(p->fd_read); - p->fd_read = PIPE_FD_INVALID; - p->fd_handler = NULL; - return ECORE_CALLBACK_CANCEL; - } + ssize_t ret; + + /* if we already have read some data we don't need to read the len + * but to finish the already started job + */ + if (p->len == 0) + { + /* read the len of the passed data */ + ret = pipe_read(p->fd_read, &p->len, sizeof(p->len)); + + /* catch the non error case first */ + if (ret == sizeof(p->len)) + ; + else if (ret > 0) + { + /* XXX What should we do here? */ + ERR("Only read %zd bytes from the pipe, although" + " we need to read %zd bytes.", ret, sizeof(p->len)); + } + else if (ret == 0) + { + p->handler((void *)p->data, NULL, 0); + pipe_close(p->fd_read); + p->fd_read = PIPE_FD_INVALID; + p->fd_handler = NULL; + return ECORE_CALLBACK_CANCEL; + } #ifndef _WIN32 - else if ((ret == PIPE_FD_ERROR) && ((errno == EINTR) || (errno == EAGAIN))) - return ECORE_CALLBACK_RENEW; - else - { - ERR("An unhandled error (ret: %zd errno: %d)" - "occurred while reading from the pipe the length", - ret, errno); + else if ((ret == PIPE_FD_ERROR) && ((errno == EINTR) || (errno == EAGAIN))) + return ECORE_CALLBACK_RENEW; + else + { + ERR("An unhandled error (ret: %zd errno: %d)" + "occurred while reading from the pipe the length", + ret, errno); return ECORE_CALLBACK_RENEW; - } + } #else - else /* ret == PIPE_FD_ERROR is the only other case on Windows */ - { + else /* ret == PIPE_FD_ERROR is the only other case on Windows */ + { if (WSAGetLastError() != WSAEWOULDBLOCK) { p->handler((void *)p->data, NULL, 0); @@ -528,51 +528,51 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) p->fd_handler = NULL; return ECORE_CALLBACK_CANCEL; } - } + } #endif - } + } - if (!p->passed_data) - p->passed_data = malloc(p->len); + if (!p->passed_data) + p->passed_data = malloc(p->len); - /* and read the passed data */ - ret = pipe_read(p->fd_read, + /* and read the passed data */ + ret = pipe_read(p->fd_read, ((unsigned char *)p->passed_data) + p->already_read, p->len - p->already_read); - /* catch the non error case first */ - if (ret == (ssize_t)(p->len - p->already_read)) - { - p->handler((void *)p->data, p->passed_data, p->len); - free(p->passed_data); - /* reset all values to 0 */ - p->passed_data = NULL; - p->already_read = 0; - p->len = 0; - } - else if (ret >= 0) - { - p->already_read += ret; - return ECORE_CALLBACK_RENEW; - } - else if (ret == 0) - { - p->handler((void *)p->data, NULL, 0); - pipe_close(p->fd_read); - p->fd_read = PIPE_FD_INVALID; - p->fd_handler = NULL; - return ECORE_CALLBACK_CANCEL; - } + /* catch the non error case first */ + if (ret == (ssize_t)(p->len - p->already_read)) + { + p->handler((void *)p->data, p->passed_data, p->len); + free(p->passed_data); + /* reset all values to 0 */ + p->passed_data = NULL; + p->already_read = 0; + p->len = 0; + } + else if (ret >= 0) + { + p->already_read += ret; + return ECORE_CALLBACK_RENEW; + } + else if (ret == 0) + { + p->handler((void *)p->data, NULL, 0); + pipe_close(p->fd_read); + p->fd_read = PIPE_FD_INVALID; + p->fd_handler = NULL; + return ECORE_CALLBACK_CANCEL; + } #ifndef _WIN32 - else if (ret == PIPE_FD_ERROR && (errno == EINTR || errno == EAGAIN)) - return ECORE_CALLBACK_RENEW; - else - { - ERR("An unhandled error (ret: %zd errno: %d)" - "occurred while reading from the pipe the data", - ret, errno); - return ECORE_CALLBACK_RENEW; - } + else if (ret == PIPE_FD_ERROR && (errno == EINTR || errno == EAGAIN)) + return ECORE_CALLBACK_RENEW; + else + { + ERR("An unhandled error (ret: %zd errno: %d)" + "occurred while reading from the pipe the data", + ret, errno); + return ECORE_CALLBACK_RENEW; + } #else else /* ret == PIPE_FD_ERROR is the only other case on Windows */ { diff --git a/src/lib/ecore/ecore_poll.c b/src/lib/ecore/ecore_poll.c index 1467952..d5bc6ba 100644 --- a/src/lib/ecore/ecore_poll.c +++ b/src/lib/ecore/ecore_poll.c @@ -52,21 +52,21 @@ _ecore_poller_next_tick_eval(void) min_interval = -1; for (i = 0; i < 15; i++) { - if (pollers[i]) - { - min_interval = i; - break; - } + if (pollers[i]) + { + min_interval = i; + break; + } } if (min_interval < 0) { - /* no pollers */ - if (timer) - { - ecore_timer_del(timer); - timer = NULL; - } - return; + /* no pollers */ + if (timer) + { + ecore_timer_del(timer); + timer = NULL; + } + return; } interval_incr = (1 << min_interval); interval = interval_incr * poll_interval; @@ -76,28 +76,28 @@ _ecore_poller_next_tick_eval(void) * callback will adjust the timer interval at the end anyway */ if (at_tick) { - if (!timer) - timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); + if (!timer) + timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); } else { - double t; - - if (!timer) - timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); - else - { - t = ecore_time_get(); - if (interval != poll_cur_interval) - { - t -= last_tick; /* time since we last ticked */ - /* delete the timer and reset it to tick off in the new - * time interval. at the tick this will be adjusted */ - ecore_timer_del(timer); - timer = ecore_timer_add(interval - t, - _ecore_poller_cb_timer, NULL); - } - } + double t; + + if (!timer) + timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); + else + { + t = ecore_time_get(); + if (interval != poll_cur_interval) + { + t -= last_tick; /* time since we last ticked */ + /* delete the timer and reset it to tick off in the new + * time interval. at the tick this will be adjusted */ + ecore_timer_del(timer); + timer = ecore_timer_add(interval - t, + _ecore_poller_cb_timer, NULL); + } + } } poll_cur_interval = interval; } @@ -116,9 +116,9 @@ _ecore_poller_cb_timer(void *data __UNUSED__) * 7, 16 etc. up to 32768) */ for (i = 0; i < 15; i++) { - poller_counters[i] += interval_incr; - /* wrap back to 0 if we exceed out loop count for the counter */ - if (poller_counters[i] >= (1 << i)) poller_counters[i] = 0; + poller_counters[i] += interval_incr; + /* wrap back to 0 if we exceed out loop count for the counter */ + if (poller_counters[i] >= (1 << i)) poller_counters[i] = 0; } just_added_poller = 0; @@ -126,49 +126,49 @@ _ecore_poller_cb_timer(void *data __UNUSED__) poller_walking++; for (i = 0; i < 15; i++) { - /* if the counter is @ 0 - this means that counter "went off" this - * tick interval, so run all pollers hooked to that counter */ - if (poller_counters[i] == 0) - { - EINA_INLIST_FOREACH(pollers[i], poller) - { - if (!poller->delete_me) - { - if (!poller->func(poller->data)) - { - if (!poller->delete_me) - { - poller->delete_me = 1; - poller_delete_count++; - } - } - } - } - } + /* if the counter is @ 0 - this means that counter "went off" this + * tick interval, so run all pollers hooked to that counter */ + if (poller_counters[i] == 0) + { + EINA_INLIST_FOREACH(pollers[i], poller) + { + if (!poller->delete_me) + { + if (!poller->func(poller->data)) + { + if (!poller->delete_me) + { + poller->delete_me = 1; + poller_delete_count++; + } + } + } + } + } } poller_walking--; /* handle deletes afterwards */ if (poller_delete_count > 0) { - /* FIXME: walk all pollers and remove deleted ones */ - for (i = 0; i < 15; i++) - { + /* FIXME: walk all pollers and remove deleted ones */ + for (i = 0; i < 15; i++) + { for (l = pollers[i]; l;) - { + { poller = l; - l = (Ecore_Poller *) EINA_INLIST_GET(l)->next; - if (poller->delete_me) - { - pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller)); - free(poller); - poller_delete_count--; - changes++; - if (poller_delete_count <= 0) break; - } - } - if (poller_delete_count <= 0) break; - } + l = (Ecore_Poller *) EINA_INLIST_GET(l)->next; + if (poller->delete_me) + { + pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller)); + free(poller); + poller_delete_count--; + changes++; + if (poller_delete_count <= 0) break; + } + } + if (poller_delete_count <= 0) break; + } } /* if we deleted or added any pollers, then we need to re-evaluate our * minimum poll interval */ @@ -294,8 +294,8 @@ ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb ibit = -1; while (interval != 0) { - ibit++; - interval >>= 1; + ibit++; + interval >>= 1; } /* only allow up to 32768 - i.e. ibit == 15, so limit it */ if (ibit > 15) ibit = 15; @@ -433,10 +433,10 @@ _ecore_poller_shutdown(void) for (i = 0; i < 15; i++) { - while ((poller = pollers[i])) - { - pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i])); - free(poller); - } + while ((poller = pollers[i])) + { + pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i])); + free(poller); + } } } diff --git a/src/lib/ecore/ecore_private.h b/src/lib/ecore/ecore_private.h index 0edc183..5f08f8a 100644 --- a/src/lib/ecore/ecore_private.h +++ b/src/lib/ecore/ecore_private.h @@ -57,7 +57,7 @@ extern int _ecore_log_dom ; # define CLAMP(x, min, max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x))) #endif -#define EVAS_FRAME_QUEUING 1 /* for test */ +#define EVAS_FRAME_QUEUING 1 /* for test */ #define READBUFSIZ 65536 @@ -100,18 +100,18 @@ EAPI void ecore_print_warning(const char *function, const char *sparam); #undef CHECK_PARAM_POINTER_RETURN #define CHECK_PARAM_POINTER_RETURN(sparam, param, ret) \ if (!(param)) \ - { \ - ecore_print_warning(__FUNCTION__, sparam); \ - return ret; \ - } + { \ + ecore_print_warning(__FUNCTION__, sparam); \ + return ret; \ + } #undef CHECK_PARAM_POINTER #define CHECK_PARAM_POINTER(sparam, param) \ if (!(param)) \ - { \ - ecore_print_warning(__FUNCTION__, sparam); \ - return; \ - } + { \ + ecore_print_warning(__FUNCTION__, sparam); \ + return; \ + } typedef unsigned int Ecore_Magic; diff --git a/src/lib/ecore/ecore_signal.c b/src/lib/ecore/ecore_signal.c index a07a3c1..10a4711 100644 --- a/src/lib/ecore/ecore_signal.c +++ b/src/lib/ecore/ecore_signal.c @@ -102,23 +102,23 @@ _ecore_signal_shutdown(void) #ifdef SIGRTMIN for (i = 0; i < num; i++) { - _ecore_signal_callback_set(SIGRTMIN + i, (Signal_Handler) SIG_DFL); - sigrt_count[i] = 0; + _ecore_signal_callback_set(SIGRTMIN + i, (Signal_Handler) SIG_DFL); + sigrt_count[i] = 0; } if (sigrt_count) { - free((sig_atomic_t *) sigrt_count); - sigrt_count = NULL; + free((sig_atomic_t *) sigrt_count); + sigrt_count = NULL; } for (i = 0; i < MAXSIGQ; i++) { - if (sigrt_info[i]) - { - free((siginfo_t *) sigrt_info[i]); - sigrt_info[i] = NULL; - } + if (sigrt_info[i]) + { + free((siginfo_t *) sigrt_info[i]); + sigrt_info[i] = NULL; + } } #endif } @@ -149,8 +149,8 @@ _ecore_signal_init(void) for (i = 0; i < MAXSIGQ; i++) { - sigrt_info[i] = calloc(1, sizeof(siginfo_t) * num); - assert(sigrt_info[i]); + sigrt_info[i] = calloc(1, sizeof(siginfo_t) * num); + assert(sigrt_info[i]); } for (i = 0; i < num; i++) @@ -194,220 +194,220 @@ _ecore_signal_call(void) sigprocmask(SIG_BLOCK, &newset, &oldset); if (sigchld_count > MAXSIGQ) WRN("%i SIGCHLD in queue. max queue size %i. losing " - "siginfo for extra signals.", sigchld_count, MAXSIGQ); + "siginfo for extra signals.", sigchld_count, MAXSIGQ); for (n = 0; n < sigchld_count; n++) { - pid_t pid; - int status; - - while ((pid = waitpid(-1, &status, WNOHANG)) > 0) - { - Ecore_Exe_Event_Del *e; - - /* FIXME: If this process is set respawn, respawn with a suitable backoff - * period for those that need too much respawning. - */ - e = _ecore_exe_event_del_new(); - if (e) - { - if (WIFEXITED(status)) - { - e->exit_code = WEXITSTATUS(status); - e->exited = 1; - } - else if (WIFSIGNALED(status)) - { - e->exit_signal = WTERMSIG(status); - e->signalled = 1; - } - e->pid = pid; - e->exe = _ecore_exe_find(pid); - - if ((n < MAXSIGQ) && (sigchld_info[n].si_signo)) - e->data = sigchld_info[n]; /* No need to clone this. */ + pid_t pid; + int status; + + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) + { + Ecore_Exe_Event_Del *e; + + /* FIXME: If this process is set respawn, respawn with a suitable backoff + * period for those that need too much respawning. + */ + e = _ecore_exe_event_del_new(); + if (e) + { + if (WIFEXITED(status)) + { + e->exit_code = WEXITSTATUS(status); + e->exited = 1; + } + else if (WIFSIGNALED(status)) + { + e->exit_signal = WTERMSIG(status); + e->signalled = 1; + } + e->pid = pid; + e->exe = _ecore_exe_find(pid); + + if ((n < MAXSIGQ) && (sigchld_info[n].si_signo)) + e->data = sigchld_info[n]; /* No need to clone this. */ if ((e->exe) && (ecore_exe_flags_get(e->exe) & (ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR))) { - /* We want to report the Last Words of the exe, so delay this event. - * This is twice as relevant for stderr. - * There are three possibilities here - - * 1 There are no Last Words. - * 2 There are Last Words, they are not ready to be read. - * 3 There are Last Words, they are ready to be read. - * - * For 1 we don't want to delay, for 3 we want to delay. - * 2 is the problem. If we check for data now and there - * is none, then there is no way to differentiate 1 and 2. - * If we don't delay, we may loose data, but if we do delay, - * there may not be data and the exit event never gets sent. - * - * Any way you look at it, there has to be some time passed - * before the exit event gets sent. So the strategy here is - * to setup a timer event that will send the exit event after - * an arbitrary, but brief, time. - * - * This is probably paranoid, for the less paraniod, we could - * check to see for Last Words, and only delay if there are any. - * This has it's own set of problems. - */ + /* We want to report the Last Words of the exe, so delay this event. + * This is twice as relevant for stderr. + * There are three possibilities here - + * 1 There are no Last Words. + * 2 There are Last Words, they are not ready to be read. + * 3 There are Last Words, they are ready to be read. + * + * For 1 we don't want to delay, for 3 we want to delay. + * 2 is the problem. If we check for data now and there + * is none, then there is no way to differentiate 1 and 2. + * If we don't delay, we may loose data, but if we do delay, + * there may not be data and the exit event never gets sent. + * + * Any way you look at it, there has to be some time passed + * before the exit event gets sent. So the strategy here is + * to setup a timer event that will send the exit event after + * an arbitrary, but brief, time. + * + * This is probably paranoid, for the less paraniod, we could + * check to see for Last Words, and only delay if there are any. + * This has it's own set of problems. + */ Ecore_Timer *doomsday_clock; doomsday_clock = _ecore_exe_doomsday_clock_get(e->exe); IF_FN_DEL(ecore_timer_del, doomsday_clock); _ecore_exe_doomsday_clock_set(e->exe, ecore_timer_add(0.1, _ecore_signal_exe_exit_delay, e)); } - else - { - _ecore_event_add(ECORE_EXE_EVENT_DEL, e, - _ecore_exe_event_del_free, NULL); - } - } - } - sig_count--; + else + { + _ecore_event_add(ECORE_EXE_EVENT_DEL, e, + _ecore_exe_event_del_free, NULL); + } + } + } + sig_count--; } sigchld_count = 0; if (sigusr1_count > MAXSIGQ) WRN("%i SIGUSR1 in queue. max queue size %i. losing " - "siginfo for extra signals.", sigusr1_count, MAXSIGQ); + "siginfo for extra signals.", sigusr1_count, MAXSIGQ); for (n = 0; n < sigusr1_count; n++) { - Ecore_Event_Signal_User *e; + Ecore_Event_Signal_User *e; - e = _ecore_event_signal_user_new(); - if (e) - { - e->number = 1; + e = _ecore_event_signal_user_new(); + if (e) + { + e->number = 1; - if ((n < MAXSIGQ) && (sigusr1_info[n].si_signo)) - e->data = sigusr1_info[n]; + if ((n < MAXSIGQ) && (sigusr1_info[n].si_signo)) + e->data = sigusr1_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL); + } + sig_count--; } sigusr1_count = 0; if (sigusr2_count > MAXSIGQ) WRN("%i SIGUSR2 in queue. max queue size %i. losing " - "siginfo for extra signals.", sigusr2_count, MAXSIGQ); + "siginfo for extra signals.", sigusr2_count, MAXSIGQ); for (n = 0; n < sigusr2_count; n++) { - Ecore_Event_Signal_User *e; + Ecore_Event_Signal_User *e; - e = _ecore_event_signal_user_new(); - if (e) - { - e->number = 2; + e = _ecore_event_signal_user_new(); + if (e) + { + e->number = 2; - if ((n < MAXSIGQ) && (sigusr2_info[n].si_signo)) - e->data = sigusr2_info[n]; + if ((n < MAXSIGQ) && (sigusr2_info[n].si_signo)) + e->data = sigusr2_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL); + } + sig_count--; } sigusr2_count = 0; if (sighup_count > MAXSIGQ) WRN("%i SIGHUP in queue. max queue size %i. losing " - "siginfo for extra signals.", sighup_count, MAXSIGQ); + "siginfo for extra signals.", sighup_count, MAXSIGQ); for (n = 0; n < sighup_count; n++) { - Ecore_Event_Signal_Hup *e; + Ecore_Event_Signal_Hup *e; - e = _ecore_event_signal_hup_new(); - if (e) - { - if ((n < MAXSIGQ) && (sighup_info[n].si_signo)) - e->data = sighup_info[n]; + e = _ecore_event_signal_hup_new(); + if (e) + { + if ((n < MAXSIGQ) && (sighup_info[n].si_signo)) + e->data = sighup_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_HUP, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_HUP, e, NULL, NULL); + } + sig_count--; } sighup_count = 0; if (sigquit_count > MAXSIGQ) WRN("%i SIGQUIT in queue. max queue size %i. losing " - "siginfo for extra signals.", sigquit_count, MAXSIGQ); + "siginfo for extra signals.", sigquit_count, MAXSIGQ); for (n = 0; n < sigquit_count; n++) { - Ecore_Event_Signal_Exit *e; + Ecore_Event_Signal_Exit *e; - e = _ecore_event_signal_exit_new(); - if (e) - { - e->quit = 1; + e = _ecore_event_signal_exit_new(); + if (e) + { + e->quit = 1; - if ((n < MAXSIGQ) && (sigquit_info[n].si_signo)) - e->data = sigquit_info[n]; + if ((n < MAXSIGQ) && (sigquit_info[n].si_signo)) + e->data = sigquit_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); + } + sig_count--; } sigquit_count = 0; if (sigint_count > MAXSIGQ) WRN("%i SIGINT in queue. max queue size %i. losing " - "siginfo for extra signals.", sigint_count, MAXSIGQ); + "siginfo for extra signals.", sigint_count, MAXSIGQ); for (n = 0; n < sigint_count; n++) { - Ecore_Event_Signal_Exit *e; + Ecore_Event_Signal_Exit *e; - e = _ecore_event_signal_exit_new(); - if (e) - { - e->interrupt = 1; + e = _ecore_event_signal_exit_new(); + if (e) + { + e->interrupt = 1; - if ((n < MAXSIGQ) && (sigint_info[n].si_signo)) - e->data = sigint_info[n]; + if ((n < MAXSIGQ) && (sigint_info[n].si_signo)) + e->data = sigint_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); + } + sig_count--; } sigint_count = 0; if (sigterm_count > MAXSIGQ) WRN("%i SIGTERM in queue. max queue size %i. losing " - "siginfo for extra signals.", sigterm_count, MAXSIGQ); + "siginfo for extra signals.", sigterm_count, MAXSIGQ); for (n = 0; n < sigterm_count; n++) { - Ecore_Event_Signal_Exit *e; + Ecore_Event_Signal_Exit *e; - e = _ecore_event_signal_exit_new(); - if (e) - { - e->terminate = 1; + e = _ecore_event_signal_exit_new(); + if (e) + { + e->terminate = 1; - if ((n < MAXSIGQ) && (sigterm_info[n].si_signo)) - e->data = sigterm_info[n]; + if ((n < MAXSIGQ) && (sigterm_info[n].si_signo)) + e->data = sigterm_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); + } + sig_count--; } sigterm_count = 0; #ifdef SIGPWR if (sigpwr_count > MAXSIGQ) WRN("%i SIGPWR in queue. max queue size %i. losing " - "siginfo for extra signals.", sigpwr_count, MAXSIGQ); + "siginfo for extra signals.", sigpwr_count, MAXSIGQ); for (n = 0; n < sigpwr_count; n++) { - Ecore_Event_Signal_Power *e; + Ecore_Event_Signal_Power *e; - e = _ecore_event_signal_power_new(); - if (e) - { - if ((n < MAXSIGQ) && (sigpwr_info[n].si_signo)) - e->data = sigpwr_info[n]; + e = _ecore_event_signal_power_new(); + if (e) + { + if ((n < MAXSIGQ) && (sigpwr_info[n].si_signo)) + e->data = sigpwr_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_POWER, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_POWER, e, NULL, NULL); + } + sig_count--; } sigpwr_count = 0; #endif @@ -415,25 +415,25 @@ _ecore_signal_call(void) #ifdef SIGRTMIN for (i = 0; i < num; i++) { - if (sigrt_count[i] > MAXSIGQ) - WRN("%i SIGRT%i in queue. max queue size %i. losing " - "siginfo for extra signals.", i + 1, sigrt_count[i], MAXSIGQ); - for (n = 0; n < sigrt_count[i]; n++) - { - Ecore_Event_Signal_Realtime *e; - - if ((e = _ecore_event_signal_realtime_new())) - { - e->num = i; - - if ((n < MAXSIGQ) && (sigrt_info[n][i].si_signo)) - e->data = sigrt_info[n][i]; - - ecore_event_add(ECORE_EVENT_SIGNAL_REALTIME, e, NULL, NULL); - } - sig_count--; - } - sigrt_count[i] = 0; + if (sigrt_count[i] > MAXSIGQ) + WRN("%i SIGRT%i in queue. max queue size %i. losing " + "siginfo for extra signals.", i + 1, sigrt_count[i], MAXSIGQ); + for (n = 0; n < sigrt_count[i]; n++) + { + Ecore_Event_Signal_Realtime *e; + + if ((e = _ecore_event_signal_realtime_new())) + { + e->num = i; + + if ((n < MAXSIGQ) && (sigrt_info[n][i].si_signo)) + e->data = sigrt_info[n][i]; + + ecore_event_add(ECORE_EVENT_SIGNAL_REALTIME, e, NULL, NULL); + } + sig_count--; + } + sigrt_count[i] = 0; } #endif sigprocmask(SIG_SETMASK, &oldset, NULL); @@ -462,10 +462,10 @@ _ecore_signal_callback_sigchld(int sig __UNUSED__, siginfo_t *si, void *foo __UN n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigchld_info[n] = *si; - else - sigchld_info[n].si_signo = 0; + if (si) + sigchld_info[n] = *si; + else + sigchld_info[n].si_signo = 0; } sigchld_count++; @@ -479,10 +479,10 @@ _ecore_signal_callback_sigusr1(int sig __UNUSED__, siginfo_t *si, void *foo __UN n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigusr1_info[n] = *si; - else - sigusr1_info[n].si_signo = 0; + if (si) + sigusr1_info[n] = *si; + else + sigusr1_info[n].si_signo = 0; } sigusr1_count++; sig_count++; @@ -495,10 +495,10 @@ _ecore_signal_callback_sigusr2(int sig __UNUSED__, siginfo_t *si, void *foo __UN n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigusr2_info[n] = *si; - else - sigusr2_info[n].si_signo = 0; + if (si) + sigusr2_info[n] = *si; + else + sigusr2_info[n].si_signo = 0; } sigusr2_count++; sig_count++; @@ -511,10 +511,10 @@ _ecore_signal_callback_sighup(int sig __UNUSED__, siginfo_t *si, void *foo __UNU n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sighup_info[n] = *si; - else - sighup_info[n].si_signo = 0; + if (si) + sighup_info[n] = *si; + else + sighup_info[n].si_signo = 0; } sighup_count++; sig_count++; @@ -527,10 +527,10 @@ _ecore_signal_callback_sigquit(int sig __UNUSED__, siginfo_t *si, void *foo __UN n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigquit_info[n] = *si; - else - sigquit_info[n].si_signo = 0; + if (si) + sigquit_info[n] = *si; + else + sigquit_info[n].si_signo = 0; } sigquit_count++; sig_count++; @@ -543,10 +543,10 @@ _ecore_signal_callback_sigint(int sig __UNUSED__, siginfo_t *si, void *foo __UNU n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigint_info[n] = *si; - else - sigint_info[n].si_signo = 0; + if (si) + sigint_info[n] = *si; + else + sigint_info[n].si_signo = 0; } sigint_count++; sig_count++; @@ -559,10 +559,10 @@ _ecore_signal_callback_sigterm(int sig __UNUSED__, siginfo_t *si, void *foo __UN n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigterm_info[n] = *si; - else - sigterm_info[n].si_signo = 0; + if (si) + sigterm_info[n] = *si; + else + sigterm_info[n].si_signo = 0; } sigterm_count++; sig_count++; @@ -576,10 +576,10 @@ _ecore_signal_callback_sigpwr(int sig __UNUSED__, siginfo_t *si, void *foo __UNU n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigpwr_info[n] = *si; - else - sigpwr_info[n].si_signo = 0; + if (si) + sigpwr_info[n] = *si; + else + sigpwr_info[n].si_signo = 0; } sigpwr_count++; sig_count++; @@ -594,10 +594,10 @@ _ecore_signal_callback_sigrt(int sig, siginfo_t *si, void *foo __UNUSED__) n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigrt_info[n][sig - SIGRTMIN] = *si; - else - sigrt_info[n][sig - SIGRTMIN].si_signo = 0; + if (si) + sigrt_info[n][sig - SIGRTMIN] = *si; + else + sigrt_info[n][sig - SIGRTMIN].si_signo = 0; } sigrt_count[sig - SIGRTMIN]++; sig_count++; @@ -612,9 +612,9 @@ _ecore_signal_exe_exit_delay(void *data) e = data; if (e) { - _ecore_exe_doomsday_clock_set(e->exe, NULL); - _ecore_event_add(ECORE_EXE_EVENT_DEL, e, - _ecore_exe_event_del_free, NULL); + _ecore_exe_doomsday_clock_set(e->exe, NULL); + _ecore_event_add(ECORE_EXE_EVENT_DEL, e, + _ecore_exe_event_del_free, NULL); } return ECORE_CALLBACK_CANCEL; } diff --git a/src/lib/ecore/ecore_thread.c b/src/lib/ecore/ecore_thread.c index d88593c..c8a5daf 100644 --- a/src/lib/ecore/ecore_thread.c +++ b/src/lib/ecore/ecore_thread.c @@ -192,8 +192,8 @@ _ecore_short_job(Ecore_Pipe *end_pipe) pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); - if (!work->cancel) - work->u.short_run.func_blocking((void *) work->data); + if (!work->cancel) + work->u.short_run.func_blocking((void *) work->data); ecore_pipe_write(end_pipe, &work, sizeof (Ecore_Pthread_Worker *)); } @@ -220,8 +220,8 @@ _ecore_feedback_job(Ecore_Pipe *end_pipe, pthread_t thread) pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); work->self = thread; - if (!work->cancel) - work->u.feedback_run.func_heavy((Ecore_Thread *) work, (void *) work->data); + if (!work->cancel) + work->u.feedback_run.func_heavy((Ecore_Thread *) work, (void *) work->data); ecore_pipe_write(end_pipe, &work, sizeof (Ecore_Pthread_Worker *)); } @@ -586,11 +586,11 @@ ecore_thread_check(Ecore_Thread *thread) * try to use one from the pool. */ EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb func_heavy, - Ecore_Thread_Notify_Cb func_notify, - Ecore_Cb func_end, - Ecore_Cb func_cancel, - const void *data, - Eina_Bool try_no_queue) + Ecore_Thread_Notify_Cb func_notify, + Ecore_Cb func_end, + Ecore_Cb func_cancel, + const void *data, + Eina_Bool try_no_queue) { #ifdef EFL_HAVE_PTHREAD diff --git a/src/lib/ecore/ecore_timer.c b/src/lib/ecore/ecore_timer.c index a14d1a2..fd6c64e 100644 --- a/src/lib/ecore/ecore_timer.c +++ b/src/lib/ecore/ecore_timer.c @@ -83,8 +83,8 @@ ecore_timer_precision_set(double value) { if (value < 0.0) { - ERR("Precision %f less than zero, ignored", value); - return; + ERR("Precision %f less than zero, ignored", value); + return; } precision = value; } @@ -168,22 +168,22 @@ ecore_timer_del(Ecore_Timer *timer) { if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_del"); - return NULL; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_del"); + return NULL; } if (timer->frozen && !timer->references) { - void *data = timer->data; + void *data = timer->data; - suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); + suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); - if (timer->delete_me) - timers_delete_me--; + if (timer->delete_me) + timers_delete_me--; - free(timer); - return data; + free(timer); + return data; } EINA_SAFETY_ON_TRUE_RETURN_VAL(timer->delete_me, NULL); @@ -205,9 +205,9 @@ ecore_timer_interval_set(Ecore_Timer *timer, double in) { if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_interval_set"); - return; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_interval_set"); + return; } timer->in = in; } @@ -224,9 +224,9 @@ ecore_timer_interval_get(Ecore_Timer *timer) { if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_interval_get"); - return -1.0; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_interval_get"); + return -1.0; } return timer->in; @@ -245,38 +245,38 @@ ecore_timer_delay(Ecore_Timer *timer, double add) { if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_delay"); - return; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_delay"); + return; } if (timer->frozen) { - timer->pending += add; + timer->pending += add; } else { - timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); - _ecore_timer_set(timer, timer->at + add, timer->in, timer->func, timer->data); + timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); + _ecore_timer_set(timer, timer->at + add, timer->in, timer->func, timer->data); } } /** * Get the pending time regarding a timer. * - * @param timer The timer to learn from. - * @ingroup Ecore_Time_Group + * @param timer The timer to learn from. + * @ingroup Ecore_Time_Group */ EAPI double ecore_timer_pending_get(Ecore_Timer *timer) { - double now; + double now; if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_pending_get"); - return 0; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_pending_get"); + return 0; } now = ecore_time_get(); @@ -297,7 +297,7 @@ ecore_timer_freeze(Ecore_Timer *timer) if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, "ecore_timer_freeze"); return ; } @@ -323,7 +323,7 @@ ecore_timer_thaw(Ecore_Timer *timer) if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, "ecore_timer_thaw"); return ; } @@ -345,9 +345,9 @@ _ecore_timer_shutdown(void) while ((timer = timers)) { - timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers)); - ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); - free(timer); + timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers)); + ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); + free(timer); } while ((timer = suspended)) @@ -369,52 +369,52 @@ _ecore_timer_cleanup(void) if (!timers_delete_me) return; for (l = timers; l;) { - Ecore_Timer *timer = l; - - l = (Ecore_Timer *) EINA_INLIST_GET(l)->next; - if (timer->delete_me) - { - if (timer->references) - { - in_use++; - continue; - } - timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); - ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); - free(timer); - timers_delete_me--; - done++; - if (timers_delete_me == 0) return; - } + Ecore_Timer *timer = l; + + l = (Ecore_Timer *) EINA_INLIST_GET(l)->next; + if (timer->delete_me) + { + if (timer->references) + { + in_use++; + continue; + } + timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); + ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); + free(timer); + timers_delete_me--; + done++; + if (timers_delete_me == 0) return; + } } for (l = suspended; l;) { - Ecore_Timer *timer = l; - - l = (Ecore_Timer *) EINA_INLIST_GET(l)->next; - if (timer->delete_me) - { - if (timer->references) - { - in_use++; - continue; - } - suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); - ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); - free(timer); - timers_delete_me--; - done++; - if (timers_delete_me == 0) return; - } + Ecore_Timer *timer = l; + + l = (Ecore_Timer *) EINA_INLIST_GET(l)->next; + if (timer->delete_me) + { + if (timer->references) + { + in_use++; + continue; + } + suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); + ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); + free(timer); + timers_delete_me--; + done++; + if (timers_delete_me == 0) return; + } } if ((!in_use) && (timers_delete_me)) { - ERR("%d timers to delete, but they were not found!" - "Stats: todo=%d, done=%d, pending=%d, in_use=%d. " - "reset counter.", - timers_delete_me, todo, done, todo - done, in_use); - timers_delete_me = 0; + ERR("%d timers to delete, but they were not found!" + "Stats: todo=%d, done=%d, pending=%d, in_use=%d. " + "reset counter.", + timers_delete_me, todo, done, todo - done, in_use); + timers_delete_me = 0; } } @@ -513,52 +513,52 @@ _ecore_timer_call(double when) if (!timers) return 0; if (last_check > when) { - Ecore_Timer *timer; - /* User set time backwards */ - EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when); + Ecore_Timer *timer; + /* User set time backwards */ + EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when); } last_check = when; if (!timer_current) { - /* regular main loop, start from head */ - timer_current = timers; + /* regular main loop, start from head */ + timer_current = timers; } else { - /* recursive main loop, continue from where we were */ - Ecore_Timer *timer_old = timer_current; - timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; - _ecore_timer_reschedule(timer_old, when); + /* recursive main loop, continue from where we were */ + Ecore_Timer *timer_old = timer_current; + timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; + _ecore_timer_reschedule(timer_old, when); } while (timer_current) { - Ecore_Timer *timer = timer_current; - - if (timer->at > when) - { - timer_current = NULL; /* ended walk, next should restart. */ - return 0; - } - - if ((timer->just_added) || (timer->delete_me)) - { - timer_current = (Ecore_Timer*)EINA_INLIST_GET(timer_current)->next; - continue; - } - - timer->references++; - if (!timer->func(timer->data)) - { - if (!timer->delete_me) ecore_timer_del(timer); - } - timer->references--; - - if (timer_current) /* may have changed in recursive main loops */ - timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; - - _ecore_timer_reschedule(timer, when); + Ecore_Timer *timer = timer_current; + + if (timer->at > when) + { + timer_current = NULL; /* ended walk, next should restart. */ + return 0; + } + + if ((timer->just_added) || (timer->delete_me)) + { + timer_current = (Ecore_Timer*)EINA_INLIST_GET(timer_current)->next; + continue; + } + + timer->references++; + if (!timer->func(timer->data)) + { + if (!timer->delete_me) ecore_timer_del(timer); + } + timer->references--; + + if (timer_current) /* may have changed in recursive main loops */ + timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; + + _ecore_timer_reschedule(timer, when); } return 0; } @@ -578,14 +578,14 @@ _ecore_timer_set(Ecore_Timer *timer, double at, double in, Ecore_Task_Cb func, v timer->pending = 0.0; if (timers) { - EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(timers), t2) - { - if (timer->at > t2->at) - { - timers = (Ecore_Timer *) eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2)); - return; - } - } + EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(timers), t2) + { + if (timer->at > t2->at) + { + timers = (Ecore_Timer *) eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2)); + return; + } + } } timers = (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); }