summaryrefslogtreecommitdiff
path: root/legacy/ecore/src
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2010-09-30 06:09:20 +0000
committerVincent Torri <vincent.torri@gmail.com>2010-09-30 06:09:20 +0000
commit16263f52cc03ca65151ad8804506415ae4381ccf (patch)
treeb518d6e5e902ba7e9599a1f97b103eb367b1f2bd /legacy/ecore/src
parent0aaad2d41ec39444306f619606918e6290634183 (diff)
tab--
SVN revision: 52918
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore/Ecore.h98
-rw-r--r--legacy/ecore/src/lib/ecore/Ecore_Getopt.h248
-rw-r--r--legacy/ecore/src/lib/ecore/ecore.c190
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_anim.c86
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_events.c344
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_exe.c1246
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_getopt.c1410
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_glib.c58
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_idle_enterer.c90
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_idle_exiter.c94
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_idler.c84
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_job.c10
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_main.c468
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_pipe.c268
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_poll.c152
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_private.h18
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_signal.c406
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_thread.c18
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_timer.c230
19 files changed, 2759 insertions, 2759 deletions
diff --git a/legacy/ecore/src/lib/ecore/Ecore.h b/legacy/ecore/src/lib/ecore/Ecore.h
index f547f5e47e..a70fa21bfb 100644
--- a/legacy/ecore/src/lib/ecore/Ecore.h
+++ b/legacy/ecore/src/lib/ecore/Ecore.h
@@ -107,23 +107,23 @@ extern "C" {
107 107
108 enum _Ecore_Fd_Handler_Flags 108 enum _Ecore_Fd_Handler_Flags
109 { 109 {
110 ECORE_FD_READ = 1, /**< Fd Read mask */ 110 ECORE_FD_READ = 1, /**< Fd Read mask */
111 ECORE_FD_WRITE = 2, /**< Fd Write mask */ 111 ECORE_FD_WRITE = 2, /**< Fd Write mask */
112 ECORE_FD_ERROR = 4 /**< Fd Error mask */ 112 ECORE_FD_ERROR = 4 /**< Fd Error mask */
113 }; 113 };
114 typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags; 114 typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
115 115
116 enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */ 116 enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */
117 { 117 {
118 ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */ 118 ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */
119 ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */ 119 ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */
120 ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */ 120 ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */
121 ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */ 121 ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */
122 ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */ 122 ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */
123 ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */ 123 ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */
124 ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */ 124 ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */
125 ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */ 125 ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */
126 ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */ 126 ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */
127 }; 127 };
128 typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags; 128 typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags;
129 129
@@ -140,7 +140,7 @@ extern "C" {
140 140
141 enum _Ecore_Poller_Type /* Poller types */ 141 enum _Ecore_Poller_Type /* Poller types */
142 { 142 {
143 ECORE_POLLER_CORE = 0 /**< The core poller interval */ 143 ECORE_POLLER_CORE = 0 /**< The core poller interval */
144 }; 144 };
145 typedef enum _Ecore_Poller_Type Ecore_Poller_Type; 145 typedef enum _Ecore_Poller_Type Ecore_Poller_Type;
146 146
@@ -244,85 +244,85 @@ extern "C" {
244 244
245 struct _Ecore_Event_Signal_User /** User signal event */ 245 struct _Ecore_Event_Signal_User /** User signal event */
246 { 246 {
247 int number; /**< The signal number. Either 1 or 2 */ 247 int number; /**< The signal number. Either 1 or 2 */
248 void *ext_data; /**< Extension data - not used */ 248 void *ext_data; /**< Extension data - not used */
249 249
250#ifndef _WIN32 250#ifndef _WIN32
251 siginfo_t data; /**< Signal info */ 251 siginfo_t data; /**< Signal info */
252#endif 252#endif
253 }; 253 };
254 254
255 struct _Ecore_Event_Signal_Hup /** Hup signal event */ 255 struct _Ecore_Event_Signal_Hup /** Hup signal event */
256 { 256 {
257 void *ext_data; /**< Extension data - not used */ 257 void *ext_data; /**< Extension data - not used */
258 258
259#ifndef _WIN32 259#ifndef _WIN32
260 siginfo_t data; /**< Signal info */ 260 siginfo_t data; /**< Signal info */
261#endif 261#endif
262 }; 262 };
263 263
264 struct _Ecore_Event_Signal_Exit /** Exit request event */ 264 struct _Ecore_Event_Signal_Exit /** Exit request event */
265 { 265 {
266 unsigned int interrupt : 1; /**< Set if the exit request was an interrupt signal*/ 266 unsigned int interrupt : 1; /**< Set if the exit request was an interrupt signal*/
267 unsigned int quit : 1; /**< set if the exit request was a quit signal */ 267 unsigned int quit : 1; /**< set if the exit request was a quit signal */
268 unsigned int terminate : 1; /**< Set if the exit request was a terminate singal */ 268 unsigned int terminate : 1; /**< Set if the exit request was a terminate singal */
269 void *ext_data; /**< Extension data - not used */ 269 void *ext_data; /**< Extension data - not used */
270 270
271#ifndef _WIN32 271#ifndef _WIN32
272 siginfo_t data; /**< Signal info */ 272 siginfo_t data; /**< Signal info */
273#endif 273#endif
274 }; 274 };
275 275
276 struct _Ecore_Event_Signal_Power /** Power event */ 276 struct _Ecore_Event_Signal_Power /** Power event */
277 { 277 {
278 void *ext_data; /**< Extension data - not used */ 278 void *ext_data; /**< Extension data - not used */
279 279
280#ifndef _WIN32 280#ifndef _WIN32
281 siginfo_t data; /**< Signal info */ 281 siginfo_t data; /**< Signal info */
282#endif 282#endif
283 }; 283 };
284 284
285 struct _Ecore_Event_Signal_Realtime /** Realtime event */ 285 struct _Ecore_Event_Signal_Realtime /** Realtime event */
286 { 286 {
287 int num; /**< The realtime signal's number */ 287 int num; /**< The realtime signal's number */
288 288
289#ifndef _WIN32 289#ifndef _WIN32
290 siginfo_t data; /**< Signal info */ 290 siginfo_t data; /**< Signal info */
291#endif 291#endif
292 }; 292 };
293 293
294 struct _Ecore_Exe_Event_Add /** Process add event */ 294 struct _Ecore_Exe_Event_Add /** Process add event */
295 { 295 {
296 Ecore_Exe *exe; /**< The handle to the added process */ 296 Ecore_Exe *exe; /**< The handle to the added process */
297 void *ext_data; /**< Extension data - not used */ 297 void *ext_data; /**< Extension data - not used */
298 }; 298 };
299 299
300 struct _Ecore_Exe_Event_Del /** Process exit event */ 300 struct _Ecore_Exe_Event_Del /** Process exit event */
301 { 301 {
302 pid_t pid; /**< The process ID of the process that exited */ 302 pid_t pid; /**< The process ID of the process that exited */
303 int exit_code; /**< The exit code of the process */ 303 int exit_code; /**< The exit code of the process */
304 Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */ 304 Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */
305 int exit_signal; /** < The signal that caused the process to exit */ 305 int exit_signal; /** < The signal that caused the process to exit */
306 unsigned int exited : 1; /** < set to 1 if the process exited of its own accord */ 306 unsigned int exited : 1; /** < set to 1 if the process exited of its own accord */
307 unsigned int signalled : 1; /** < set to 1 id the process exited due to uncaught signal */ 307 unsigned int signalled : 1; /** < set to 1 id the process exited due to uncaught signal */
308 void *ext_data; /**< Extension data - not used */ 308 void *ext_data; /**< Extension data - not used */
309#ifndef _WIN32 309#ifndef _WIN32
310 siginfo_t data; /**< Signal info */ 310 siginfo_t data; /**< Signal info */
311#endif 311#endif
312 }; 312 };
313 313
314 struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */ 314 struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */
315 { 315 {
316 char *line; 316 char *line;
317 int size; 317 int size;
318 }; 318 };
319 319
320 struct _Ecore_Exe_Event_Data /** Data from a child process event */ 320 struct _Ecore_Exe_Event_Data /** Data from a child process event */
321 { 321 {
322 Ecore_Exe *exe; /**< The handle to the process */ 322 Ecore_Exe *exe; /**< The handle to the process */
323 void *data; /**< the raw binary data from the child process that was received */ 323 void *data; /**< the raw binary data from the child process that was received */
324 int size; /**< the size of this data in bytes */ 324 int size; /**< the size of this data in bytes */
325 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 */ 325 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 */
326 }; 326 };
327 327
328 EAPI int ecore_init(void); 328 EAPI int ecore_init(void);
@@ -413,11 +413,11 @@ extern "C" {
413 Ecore_Cb, 413 Ecore_Cb,
414 const void *data); 414 const void *data);
415 EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb, 415 EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb,
416 Ecore_Thread_Notify_Cb, 416 Ecore_Thread_Notify_Cb,
417 Ecore_Cb, 417 Ecore_Cb,
418 Ecore_Cb, 418 Ecore_Cb,
419 const void *data, 419 const void *data,
420 Eina_Bool try_no_queue); 420 Eina_Bool try_no_queue);
421 EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread); 421 EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread);
422 EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread); 422 EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread);
423 EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread *thread, const void *msg_data); 423 EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread *thread, const void *msg_data);
@@ -463,8 +463,8 @@ extern "C" {
463 463
464 EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, const void *data); 464 EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, const void *data);
465 EAPI void *ecore_animator_del(Ecore_Animator *animator); 465 EAPI void *ecore_animator_del(Ecore_Animator *animator);
466 EAPI void ecore_animator_freeze(Ecore_Animator *animator); 466 EAPI void ecore_animator_freeze(Ecore_Animator *animator);
467 EAPI void ecore_animator_thaw(Ecore_Animator *animator); 467 EAPI void ecore_animator_thaw(Ecore_Animator *animator);
468 EAPI void ecore_animator_frametime_set(double frametime); 468 EAPI void ecore_animator_frametime_set(double frametime);
469 EAPI double ecore_animator_frametime_get(void); 469 EAPI double ecore_animator_frametime_get(void);
470 470
diff --git a/legacy/ecore/src/lib/ecore/Ecore_Getopt.h b/legacy/ecore/src/lib/ecore/Ecore_Getopt.h
index f2ea6f7077..18a8459bfc 100644
--- a/legacy/ecore/src/lib/ecore/Ecore_Getopt.h
+++ b/legacy/ecore/src/lib/ecore/Ecore_Getopt.h
@@ -114,15 +114,15 @@ extern "C" {
114 Ecore_Getopt_Desc_Arg_Requirement arg_req; 114 Ecore_Getopt_Desc_Arg_Requirement arg_req;
115 union 115 union
116 { 116 {
117 const char *strv; 117 const char *strv;
118 unsigned char boolv; 118 unsigned char boolv;
119 short shortv; 119 short shortv;
120 int intv; 120 int intv;
121 long longv; 121 long longv;
122 unsigned short ushortv; 122 unsigned short ushortv;
123 unsigned int uintv; 123 unsigned int uintv;
124 unsigned long ulongv; 124 unsigned long ulongv;
125 double doublev; 125 double doublev;
126 } def; 126 } def;
127 }; 127 };
128 128
@@ -144,12 +144,12 @@ extern "C" {
144 Ecore_Getopt_Action action; /**< define how to handle it */ 144 Ecore_Getopt_Action action; /**< define how to handle it */
145 union 145 union
146 { 146 {
147 const Ecore_Getopt_Desc_Store store; 147 const Ecore_Getopt_Desc_Store store;
148 const void *store_const; 148 const void *store_const;
149 const char *const *choices; /* NULL terminated. */ 149 const char *const *choices; /* NULL terminated. */
150 const Ecore_Getopt_Type append_type; 150 const Ecore_Getopt_Type append_type;
151 const Ecore_Getopt_Desc_Callback callback; 151 const Ecore_Getopt_Desc_Callback callback;
152 const void *dummy; 152 const void *dummy;
153 } action_param; 153 } action_param;
154 }; 154 };
155 155
@@ -166,12 +166,12 @@ extern "C" {
166 }; 166 };
167 167
168#define ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, arg_requirement, default_value) \ 168#define ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, arg_requirement, default_value) \
169 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \ 169 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \
170 {.store = {type, arg_requirement, default_value}}} 170 {.store = {type, arg_requirement, default_value}}}
171 171
172#define ECORE_GETOPT_STORE(shortname, longname, help, type) \ 172#define ECORE_GETOPT_STORE(shortname, longname, help, type) \
173 ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ 173 ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
174 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) 174 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {})
175 175
176#define ECORE_GETOPT_STORE_STR(shortname, longname, help) \ 176#define ECORE_GETOPT_STORE_STR(shortname, longname, help) \
177 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_STR) 177 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_STR)
@@ -194,8 +194,8 @@ extern "C" {
194 194
195 195
196#define ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, type) \ 196#define ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, type) \
197 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \ 197 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \
198 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) 198 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {})
199 199
200#define ECORE_GETOPT_STORE_METAVAR_STR(shortname, longname, help, metavar) \ 200#define ECORE_GETOPT_STORE_METAVAR_STR(shortname, longname, help, metavar) \
201 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_STR) 201 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_STR)
@@ -218,155 +218,155 @@ extern "C" {
218 218
219 219
220#define ECORE_GETOPT_STORE_DEF(shortname, longname, help, type, default_value) \ 220#define ECORE_GETOPT_STORE_DEF(shortname, longname, help, type, default_value) \
221 ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ 221 ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
222 ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \ 222 ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \
223 default_value) 223 default_value)
224 224
225#define ECORE_GETOPT_STORE_DEF_STR(shortname, longname, help, default_value) \ 225#define ECORE_GETOPT_STORE_DEF_STR(shortname, longname, help, default_value) \
226 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 226 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
227 ECORE_GETOPT_TYPE_STR, \ 227 ECORE_GETOPT_TYPE_STR, \
228 {.strv = default_value}) 228 {.strv = default_value})
229#define ECORE_GETOPT_STORE_DEF_BOOL(shortname, longname, help, default_value) \ 229#define ECORE_GETOPT_STORE_DEF_BOOL(shortname, longname, help, default_value) \
230 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 230 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
231 ECORE_GETOPT_TYPE_BOOL, \ 231 ECORE_GETOPT_TYPE_BOOL, \
232 {.boolv = default_value}) 232 {.boolv = default_value})
233#define ECORE_GETOPT_STORE_DEF_SHORT(shortname, longname, help, default_value) \ 233#define ECORE_GETOPT_STORE_DEF_SHORT(shortname, longname, help, default_value) \
234 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 234 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
235 ECORE_GETOPT_TYPE_SHORT, \ 235 ECORE_GETOPT_TYPE_SHORT, \
236 {.shortv = default_value}) 236 {.shortv = default_value})
237#define ECORE_GETOPT_STORE_DEF_INT(shortname, longname, help, default_value) \ 237#define ECORE_GETOPT_STORE_DEF_INT(shortname, longname, help, default_value) \
238 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 238 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
239 ECORE_GETOPT_TYPE_INT, \ 239 ECORE_GETOPT_TYPE_INT, \
240 {.intv = default_value}) 240 {.intv = default_value})
241#define ECORE_GETOPT_STORE_DEF_LONG(shortname, longname, help, default_value) \ 241#define ECORE_GETOPT_STORE_DEF_LONG(shortname, longname, help, default_value) \
242 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 242 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
243 ECORE_GETOPT_TYPE_LONG, \ 243 ECORE_GETOPT_TYPE_LONG, \
244 {.longv = default_value}) 244 {.longv = default_value})
245#define ECORE_GETOPT_STORE_DEF_USHORT(shortname, longname, help, default_value) \ 245#define ECORE_GETOPT_STORE_DEF_USHORT(shortname, longname, help, default_value) \
246 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 246 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
247 ECORE_GETOPT_TYPE_USHORT, \ 247 ECORE_GETOPT_TYPE_USHORT, \
248 {.ushortv = default_value}) 248 {.ushortv = default_value})
249#define ECORE_GETOPT_STORE_DEF_UINT(shortname, longname, help, default_value) \ 249#define ECORE_GETOPT_STORE_DEF_UINT(shortname, longname, help, default_value) \
250 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 250 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
251 ECORE_GETOPT_TYPE_UINT, \ 251 ECORE_GETOPT_TYPE_UINT, \
252 {.uintv = default_value}) 252 {.uintv = default_value})
253#define ECORE_GETOPT_STORE_DEF_ULONG(shortname, longname, help, default_value) \ 253#define ECORE_GETOPT_STORE_DEF_ULONG(shortname, longname, help, default_value) \
254 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 254 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
255 ECORE_GETOPT_TYPE_ULONG, \ 255 ECORE_GETOPT_TYPE_ULONG, \
256 {.ulongv = default_value}) 256 {.ulongv = default_value})
257#define ECORE_GETOPT_STORE_DEF_DOUBLE(shortname, longname, help, default_value) \ 257#define ECORE_GETOPT_STORE_DEF_DOUBLE(shortname, longname, help, default_value) \
258 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ 258 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
259 ECORE_GETOPT_TYPE_DOUBLE, \ 259 ECORE_GETOPT_TYPE_DOUBLE, \
260 {.doublev = default_value}) 260 {.doublev = default_value})
261 261
262#define ECORE_GETOPT_STORE_FULL_STR(shortname, longname, help, metavar, arg_requirement, default_value) \ 262#define ECORE_GETOPT_STORE_FULL_STR(shortname, longname, help, metavar, arg_requirement, default_value) \
263 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 263 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
264 ECORE_GETOPT_TYPE_STR, \ 264 ECORE_GETOPT_TYPE_STR, \
265 arg_requirement, \ 265 arg_requirement, \
266 {.strv = default_value}) 266 {.strv = default_value})
267#define ECORE_GETOPT_STORE_FULL_BOOL(shortname, longname, help, metavar, arg_requirement, default_value) \ 267#define ECORE_GETOPT_STORE_FULL_BOOL(shortname, longname, help, metavar, arg_requirement, default_value) \
268 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 268 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
269 ECORE_GETOPT_TYPE_BOOL, \ 269 ECORE_GETOPT_TYPE_BOOL, \
270 arg_requirement, \ 270 arg_requirement, \
271 {.boolv = default_value}) 271 {.boolv = default_value})
272#define ECORE_GETOPT_STORE_FULL_SHORT(shortname, longname, help, metavar, arg_requirement, default_value) \ 272#define ECORE_GETOPT_STORE_FULL_SHORT(shortname, longname, help, metavar, arg_requirement, default_value) \
273 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 273 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
274 ECORE_GETOPT_TYPE_SHORT, \ 274 ECORE_GETOPT_TYPE_SHORT, \
275 arg_requirement, \ 275 arg_requirement, \
276 {.shortv = default_value}) 276 {.shortv = default_value})
277#define ECORE_GETOPT_STORE_FULL_INT(shortname, longname, help, metavar, arg_requirement, default_value) \ 277#define ECORE_GETOPT_STORE_FULL_INT(shortname, longname, help, metavar, arg_requirement, default_value) \
278 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 278 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
279 ECORE_GETOPT_TYPE_INT, \ 279 ECORE_GETOPT_TYPE_INT, \
280 arg_requirement, \ 280 arg_requirement, \
281 {.intv = default_value}) 281 {.intv = default_value})
282#define ECORE_GETOPT_STORE_FULL_LONG(shortname, longname, help, metavar, arg_requirement, default_value) \ 282#define ECORE_GETOPT_STORE_FULL_LONG(shortname, longname, help, metavar, arg_requirement, default_value) \
283 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 283 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
284 ECORE_GETOPT_TYPE_LONG, \ 284 ECORE_GETOPT_TYPE_LONG, \
285 arg_requirement, \ 285 arg_requirement, \
286 {.longv = default_value}) 286 {.longv = default_value})
287#define ECORE_GETOPT_STORE_FULL_USHORT(shortname, longname, help, metavar, arg_requirement, default_value) \ 287#define ECORE_GETOPT_STORE_FULL_USHORT(shortname, longname, help, metavar, arg_requirement, default_value) \
288 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 288 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
289 ECORE_GETOPT_TYPE_USHORT, \ 289 ECORE_GETOPT_TYPE_USHORT, \
290 arg_requirement, \ 290 arg_requirement, \
291 {.ushortv = default_value}) 291 {.ushortv = default_value})
292#define ECORE_GETOPT_STORE_FULL_UINT(shortname, longname, help, metavar, arg_requirement, default_value) \ 292#define ECORE_GETOPT_STORE_FULL_UINT(shortname, longname, help, metavar, arg_requirement, default_value) \
293 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 293 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
294 ECORE_GETOPT_TYPE_UINT, \ 294 ECORE_GETOPT_TYPE_UINT, \
295 arg_requirement, \ 295 arg_requirement, \
296 {.uintv = default_value}) 296 {.uintv = default_value})
297#define ECORE_GETOPT_STORE_FULL_ULONG(shortname, longname, help, metavar, arg_requirement, default_value) \ 297#define ECORE_GETOPT_STORE_FULL_ULONG(shortname, longname, help, metavar, arg_requirement, default_value) \
298 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 298 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
299 ECORE_GETOPT_TYPE_ULONG, \ 299 ECORE_GETOPT_TYPE_ULONG, \
300 arg_requirement, \ 300 arg_requirement, \
301 {.ulongv = default_value}) 301 {.ulongv = default_value})
302#define ECORE_GETOPT_STORE_FULL_DOUBLE(shortname, longname, help, metavar, arg_requirement, default_value) \ 302#define ECORE_GETOPT_STORE_FULL_DOUBLE(shortname, longname, help, metavar, arg_requirement, default_value) \
303 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ 303 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
304 ECORE_GETOPT_TYPE_DOUBLE, \ 304 ECORE_GETOPT_TYPE_DOUBLE, \
305 arg_requirement, \ 305 arg_requirement, \
306 {.doublev = default_value}) 306 {.doublev = default_value})
307 307
308#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value) \ 308#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value) \
309 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \ 309 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \
310 {.store_const = value}} 310 {.store_const = value}}
311#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help) \ 311#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help) \
312 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \ 312 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \
313 {.dummy = NULL}} 313 {.dummy = NULL}}
314#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help) \ 314#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help) \
315 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \ 315 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \
316 {.dummy = NULL}} 316 {.dummy = NULL}}
317 317
318#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array) \ 318#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array) \
319 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \ 319 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \
320 {.choices = choices_array}} 320 {.choices = choices_array}}
321#define ECORE_GETOPT_CHOICE_METAVAR(shortname, longname, help, metavar, choices_array) \ 321#define ECORE_GETOPT_CHOICE_METAVAR(shortname, longname, help, metavar, choices_array) \
322 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \ 322 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \
323 {.choices = choices_array}} 323 {.choices = choices_array}}
324 324
325 325
326#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type) \ 326#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type) \
327 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \ 327 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \
328 {.append_type = sub_type}} 328 {.append_type = sub_type}}
329#define ECORE_GETOPT_APPEND_METAVAR(shortname, longname, help, metavar, type) \ 329#define ECORE_GETOPT_APPEND_METAVAR(shortname, longname, help, metavar, type) \
330 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \ 330 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \
331 {.append_type = type}} 331 {.append_type = type}}
332 332
333#define ECORE_GETOPT_COUNT(shortname, longname, help) \ 333#define ECORE_GETOPT_COUNT(shortname, longname, help) \
334 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \ 334 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \
335 {.dummy = NULL}} 335 {.dummy = NULL}}
336 336
337#define ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, callback_func, callback_data, argument_requirement, default_value) \ 337#define ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, callback_func, callback_data, argument_requirement, default_value) \
338 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \ 338 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \
339 {.callback = {callback_func, callback_data, \ 339 {.callback = {callback_func, callback_data, \
340 argument_requirement, default_value}}} 340 argument_requirement, default_value}}}
341#define ECORE_GETOPT_CALLBACK_NOARGS(shortname, longname, help, callback_func, callback_data) \ 341#define ECORE_GETOPT_CALLBACK_NOARGS(shortname, longname, help, callback_func, callback_data) \
342 ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \ 342 ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \
343 callback_func, callback_data, \ 343 callback_func, callback_data, \
344 ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO, \ 344 ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO, \
345 NULL) 345 NULL)
346#define ECORE_GETOPT_CALLBACK_ARGS(shortname, longname, help, metavar, callback_func, callback_data) \ 346#define ECORE_GETOPT_CALLBACK_ARGS(shortname, longname, help, metavar, callback_func, callback_data) \
347 ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, \ 347 ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, \
348 callback_func, callback_data, \ 348 callback_func, callback_data, \
349 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, \ 349 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, \
350 NULL) 350 NULL)
351 351
352#define ECORE_GETOPT_HELP(shortname, longname) \ 352#define ECORE_GETOPT_HELP(shortname, longname) \
353 {shortname, longname, "show this message.", NULL, \ 353 {shortname, longname, "show this message.", NULL, \
354 ECORE_GETOPT_ACTION_HELP, \ 354 ECORE_GETOPT_ACTION_HELP, \
355 {.dummy = NULL}} 355 {.dummy = NULL}}
356 356
357#define ECORE_GETOPT_VERSION(shortname, longname) \ 357#define ECORE_GETOPT_VERSION(shortname, longname) \
358 {shortname, longname, "show program version.", NULL, \ 358 {shortname, longname, "show program version.", NULL, \
359 ECORE_GETOPT_ACTION_VERSION, \ 359 ECORE_GETOPT_ACTION_VERSION, \
360 {.dummy = NULL}} 360 {.dummy = NULL}}
361 361
362#define ECORE_GETOPT_COPYRIGHT(shortname, longname) \ 362#define ECORE_GETOPT_COPYRIGHT(shortname, longname) \
363 {shortname, longname, "show copyright.", NULL, \ 363 {shortname, longname, "show copyright.", NULL, \
364 ECORE_GETOPT_ACTION_COPYRIGHT, \ 364 ECORE_GETOPT_ACTION_COPYRIGHT, \
365 {.dummy = NULL}} 365 {.dummy = NULL}}
366 366
367#define ECORE_GETOPT_LICENSE(shortname, longname) \ 367#define ECORE_GETOPT_LICENSE(shortname, longname) \
368 {shortname, longname, "show license.", NULL, \ 368 {shortname, longname, "show license.", NULL, \
369 ECORE_GETOPT_ACTION_LICENSE, \ 369 ECORE_GETOPT_ACTION_LICENSE, \
370 {.dummy = NULL}} 370 {.dummy = NULL}}
371 371
372#define ECORE_GETOPT_SENTINEL {0, NULL, NULL, NULL, 0, {.dummy = NULL}} 372#define ECORE_GETOPT_SENTINEL {0, NULL, NULL, NULL, 0, {.dummy = NULL}}
diff --git a/legacy/ecore/src/lib/ecore/ecore.c b/legacy/ecore/src/lib/ecore/ecore.c
index 8f2a045f72..5b0789c029 100644
--- a/legacy/ecore/src/lib/ecore/ecore.c
+++ b/legacy/ecore/src/lib/ecore/ecore.c
@@ -38,8 +38,8 @@
38static Ecore_Version _version = { VERS_MAJ, VERS_MIN, VERS_MIC, VERS_REV }; 38static Ecore_Version _version = { VERS_MAJ, VERS_MIN, VERS_MIC, VERS_REV };
39EAPI Ecore_Version *ecore_version = &_version; 39EAPI Ecore_Version *ecore_version = &_version;
40 40
41#define KEEP_MAX(Global, Local) \ 41#define KEEP_MAX(Global, Local) \
42 if (Global < (Local)) \ 42 if (Global < (Local)) \
43 Global = Local; 43 Global = Local;
44 44
45static Eina_Bool _ecore_memory_statistic(void *data); 45static Eina_Bool _ecore_memory_statistic(void *data);
@@ -95,7 +95,7 @@ ecore_init(void)
95 /* 95 /*
96 if (strcmp(nl_langinfo(CODESET), "UTF-8")) 96 if (strcmp(nl_langinfo(CODESET), "UTF-8"))
97 { 97 {
98 WRN("Not a utf8 locale!"); 98 WRN("Not a utf8 locale!");
99 } 99 }
100 */ 100 */
101#ifdef HAVE_EVIL 101#ifdef HAVE_EVIL
@@ -122,8 +122,8 @@ ecore_init(void)
122#if HAVE_MALLINFO 122#if HAVE_MALLINFO
123 if (getenv("ECORE_MEM_STAT")) 123 if (getenv("ECORE_MEM_STAT"))
124 { 124 {
125 _ecore_memory_pid = getpid(); 125 _ecore_memory_pid = getpid();
126 ecore_animator_add(_ecore_memory_statistic, NULL); 126 ecore_animator_add(_ecore_memory_statistic, NULL);
127 } 127 }
128#endif 128#endif
129 129
@@ -177,12 +177,12 @@ ecore_shutdown(void)
177#if HAVE_MALLINFO 177#if HAVE_MALLINFO
178 if (getenv("ECORE_MEM_STAT")) 178 if (getenv("ECORE_MEM_STAT"))
179 { 179 {
180 _ecore_memory_statistic(NULL); 180 _ecore_memory_statistic(NULL);
181 181
182 ERR("[%i] Memory MAX total: %i, free: %i", 182 ERR("[%i] Memory MAX total: %i, free: %i",
183 _ecore_memory_pid, 183 _ecore_memory_pid,
184 _ecore_memory_max_total, 184 _ecore_memory_max_total,
185 _ecore_memory_max_free); 185 _ecore_memory_max_free);
186 } 186 }
187#endif 187#endif
188 188
@@ -220,13 +220,13 @@ _ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *f
220 ERR(" Input handle has already been freed!"); 220 ERR(" Input handle has already been freed!");
221 else if (m != req_m) 221 else if (m != req_m)
222 ERR(" Input handle is wrong type\n" 222 ERR(" Input handle is wrong type\n"
223 " Expected: %08x - %s\n" 223 " Expected: %08x - %s\n"
224 " Supplied: %08x - %s", 224 " Supplied: %08x - %s",
225 (unsigned int)req_m, _ecore_magic_string_get(req_m), 225 (unsigned int)req_m, _ecore_magic_string_get(req_m),
226 (unsigned int)m, _ecore_magic_string_get(m)); 226 (unsigned int)m, _ecore_magic_string_get(m));
227 ERR("*** NAUGHTY PROGRAMMER!!!\n" 227 ERR("*** NAUGHTY PROGRAMMER!!!\n"
228 "*** SPANK SPANK SPANK!!!\n" 228 "*** SPANK SPANK SPANK!!!\n"
229 "*** Now go fix your code. Tut tut tut!"); 229 "*** Now go fix your code. Tut tut tut!");
230 if (getenv("ECORE_ERROR_ABORT")) abort(); 230 if (getenv("ECORE_ERROR_ABORT")) abort();
231} 231}
232 232
@@ -236,37 +236,37 @@ _ecore_magic_string_get(Ecore_Magic m)
236 switch (m) 236 switch (m)
237 { 237 {
238 case ECORE_MAGIC_NONE: 238 case ECORE_MAGIC_NONE:
239 return "None (Freed Object)"; 239 return "None (Freed Object)";
240 break; 240 break;
241 case ECORE_MAGIC_EXE: 241 case ECORE_MAGIC_EXE:
242 return "Ecore_Exe (Executable)"; 242 return "Ecore_Exe (Executable)";
243 break; 243 break;
244 case ECORE_MAGIC_TIMER: 244 case ECORE_MAGIC_TIMER:
245 return "Ecore_Timer (Timer)"; 245 return "Ecore_Timer (Timer)";
246 break; 246 break;
247 case ECORE_MAGIC_IDLER: 247 case ECORE_MAGIC_IDLER:
248 return "Ecore_Idler (Idler)"; 248 return "Ecore_Idler (Idler)";
249 break; 249 break;
250 case ECORE_MAGIC_IDLE_ENTERER: 250 case ECORE_MAGIC_IDLE_ENTERER:
251 return "Ecore_Idle_Enterer (Idler Enterer)"; 251 return "Ecore_Idle_Enterer (Idler Enterer)";
252 break; 252 break;
253 case ECORE_MAGIC_IDLE_EXITER: 253 case ECORE_MAGIC_IDLE_EXITER:
254 return "Ecore_Idle_Exiter (Idler Exiter)"; 254 return "Ecore_Idle_Exiter (Idler Exiter)";
255 break; 255 break;
256 case ECORE_MAGIC_FD_HANDLER: 256 case ECORE_MAGIC_FD_HANDLER:
257 return "Ecore_Fd_Handler (Fd Handler)"; 257 return "Ecore_Fd_Handler (Fd Handler)";
258 break; 258 break;
259 case ECORE_MAGIC_WIN32_HANDLER: 259 case ECORE_MAGIC_WIN32_HANDLER:
260 return "Ecore_Win32_Handler (Win32 Handler)"; 260 return "Ecore_Win32_Handler (Win32 Handler)";
261 break; 261 break;
262 case ECORE_MAGIC_EVENT_HANDLER: 262 case ECORE_MAGIC_EVENT_HANDLER:
263 return "Ecore_Event_Handler (Event Handler)"; 263 return "Ecore_Event_Handler (Event Handler)";
264 break; 264 break;
265 case ECORE_MAGIC_EVENT: 265 case ECORE_MAGIC_EVENT:
266 return "Ecore_Event (Event)"; 266 return "Ecore_Event (Event)";
267 break; 267 break;
268 default: 268 default:
269 return "<UNKNOWN>"; 269 return "<UNKNOWN>";
270 }; 270 };
271} 271}
272 272
@@ -298,40 +298,40 @@ _ecore_fps_debug_init(void)
298 _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); 298 _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
299 if (_ecore_fps_debug_fd < 0) 299 if (_ecore_fps_debug_fd < 0)
300 { 300 {
301 unlink(buf); 301 unlink(buf);
302 _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); 302 _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
303 } 303 }
304 if (_ecore_fps_debug_fd >= 0) 304 if (_ecore_fps_debug_fd >= 0)
305 { 305 {
306 unsigned int zero = 0; 306 unsigned int zero = 0;
307 char *buf = (char *)&zero; 307 char *buf = (char *)&zero;
308 ssize_t todo = sizeof(unsigned int); 308 ssize_t todo = sizeof(unsigned int);
309 309
310 while (todo > 0) 310 while (todo > 0)
311 { 311 {
312 ssize_t r = write(_ecore_fps_debug_fd, buf, todo); 312 ssize_t r = write(_ecore_fps_debug_fd, buf, todo);
313 if (r > 0) 313 if (r > 0)
314 { 314 {
315 todo -= r; 315 todo -= r;
316 buf += r; 316 buf += r;
317 } 317 }
318 else if ((r < 0) && (errno == EINTR)) 318 else if ((r < 0) && (errno == EINTR))
319 continue; 319 continue;
320 else 320 else
321 { 321 {
322 ERR("could not write to file '%s' fd %d: %s", 322 ERR("could not write to file '%s' fd %d: %s",
323 tmp, _ecore_fps_debug_fd, strerror(errno)); 323 tmp, _ecore_fps_debug_fd, strerror(errno));
324 close(_ecore_fps_debug_fd); 324 close(_ecore_fps_debug_fd);
325 _ecore_fps_debug_fd = -1; 325 _ecore_fps_debug_fd = -1;
326 return; 326 return;
327 } 327 }
328 } 328 }
329 _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int), 329 _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int),
330 PROT_READ | PROT_WRITE, 330 PROT_READ | PROT_WRITE,
331 MAP_SHARED, 331 MAP_SHARED,
332 _ecore_fps_debug_fd, 0); 332 _ecore_fps_debug_fd, 0);
333 if (_ecore_fps_runtime_mmap == MAP_FAILED) 333 if (_ecore_fps_runtime_mmap == MAP_FAILED)
334 _ecore_fps_runtime_mmap = NULL; 334 _ecore_fps_runtime_mmap = NULL;
335 } 335 }
336} 336}
337 337
@@ -352,15 +352,15 @@ _ecore_fps_debug_shutdown(void)
352 tmp = (char *)evil_tmpdir_get (); 352 tmp = (char *)evil_tmpdir_get ();
353#endif /* HAVE_EVIL */ 353#endif /* HAVE_EVIL */
354 pid = (int)getpid(); 354 pid = (int)getpid();
355 snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid); 355 snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid);
356 unlink(buf); 356 unlink(buf);
357 if (_ecore_fps_runtime_mmap) 357 if (_ecore_fps_runtime_mmap)
358 { 358 {
359 munmap(_ecore_fps_runtime_mmap, sizeof(int)); 359 munmap(_ecore_fps_runtime_mmap, sizeof(int));
360 _ecore_fps_runtime_mmap = NULL; 360 _ecore_fps_runtime_mmap = NULL;
361 } 361 }
362 close(_ecore_fps_debug_fd); 362 close(_ecore_fps_debug_fd);
363 _ecore_fps_debug_fd = -1; 363 _ecore_fps_debug_fd = -1;
364 } 364 }
365} 365}
366 366
@@ -370,16 +370,16 @@ _ecore_fps_debug_runtime_add(double t)
370 if ((_ecore_fps_debug_fd >= 0) && 370 if ((_ecore_fps_debug_fd >= 0) &&
371 (_ecore_fps_runtime_mmap)) 371 (_ecore_fps_runtime_mmap))
372 { 372 {
373 unsigned int tm; 373 unsigned int tm;
374 374
375 tm = (unsigned int)(t * 1000000.0); 375 tm = (unsigned int)(t * 1000000.0);
376 /* i know its not 100% theoretically guaranteed, but i'd say a write */ 376 /* i know its not 100% theoretically guaranteed, but i'd say a write */
377 /* of an int could be considered atomic for all practical purposes */ 377 /* of an int could be considered atomic for all practical purposes */
378 /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */ 378 /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */
379 /* this can run for about 4294 seconds becore looping. if you are */ 379 /* this can run for about 4294 seconds becore looping. if you are */
380 /* doing performance testing in one run for over an hour... well */ 380 /* doing performance testing in one run for over an hour... well */
381 /* time to restart or handle a loop condition :) */ 381 /* time to restart or handle a loop condition :) */
382 *(_ecore_fps_runtime_mmap) += tm; 382 *(_ecore_fps_runtime_mmap) += tm;
383 } 383 }
384} 384}
385 385
@@ -394,11 +394,11 @@ _ecore_memory_statistic(__UNUSED__ void *data)
394 394
395 mi = mallinfo(); 395 mi = mallinfo();
396 396
397#define HAS_CHANGED(Global, Local) \ 397#define HAS_CHANGED(Global, Local) \
398 if (Global != Local) \ 398 if (Global != Local) \
399 { \ 399 { \
400 Global = Local; \ 400 Global = Local; \
401 changed = EINA_TRUE; \ 401 changed = EINA_TRUE; \
402 } 402 }
403 403
404 HAS_CHANGED(uordblks, mi.uordblks); 404 HAS_CHANGED(uordblks, mi.uordblks);
@@ -406,9 +406,9 @@ _ecore_memory_statistic(__UNUSED__ void *data)
406 406
407 if (changed) 407 if (changed)
408 ERR("[%i] Memory total: %i, free: %i", 408 ERR("[%i] Memory total: %i, free: %i",
409 _ecore_memory_pid, 409 _ecore_memory_pid,
410 mi.uordblks, 410 mi.uordblks,
411 mi.fordblks); 411 mi.fordblks);
412 412
413 KEEP_MAX(_ecore_memory_max_total, mi.uordblks); 413 KEEP_MAX(_ecore_memory_max_total, mi.uordblks);
414 KEEP_MAX(_ecore_memory_max_free, mi.fordblks); 414 KEEP_MAX(_ecore_memory_max_free, mi.fordblks);
diff --git a/legacy/ecore/src/lib/ecore/ecore_anim.c b/legacy/ecore/src/lib/ecore/ecore_anim.c
index b5cd5edfea..921071e347 100644
--- a/legacy/ecore/src/lib/ecore/ecore_anim.c
+++ b/legacy/ecore/src/lib/ecore/ecore_anim.c
@@ -18,7 +18,7 @@ struct _Ecore_Animator
18 void *data; 18 void *data;
19 19
20 Eina_Bool delete_me : 1; 20 Eina_Bool delete_me : 1;
21 Eina_Bool suspended : 1; 21 Eina_Bool suspended : 1;
22}; 22};
23 23
24 24
@@ -87,9 +87,9 @@ ecore_animator_del(Ecore_Animator *animator)
87{ 87{
88 if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) 88 if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR))
89 { 89 {
90 ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, 90 ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
91 "ecore_animator_del"); 91 "ecore_animator_del");
92 return NULL; 92 return NULL;
93 } 93 }
94 if (animator->delete_me) return animator->data; 94 if (animator->delete_me) return animator->data;
95 animator->delete_me = EINA_TRUE; 95 animator->delete_me = EINA_TRUE;
@@ -111,8 +111,8 @@ ecore_animator_frametime_set(double frametime)
111 animators_frametime = frametime; 111 animators_frametime = frametime;
112 if (timer) 112 if (timer)
113 { 113 {
114 ecore_timer_del(timer); 114 ecore_timer_del(timer);
115 timer = NULL; 115 timer = NULL;
116 } 116 }
117 if (animators) 117 if (animators)
118 timer = ecore_timer_add(animators_frametime, _ecore_animator, NULL); 118 timer = ecore_timer_add(animators_frametime, _ecore_animator, NULL);
@@ -143,9 +143,9 @@ ecore_animator_freeze(Ecore_Animator *animator)
143{ 143{
144 if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) 144 if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR))
145 { 145 {
146 ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, 146 ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
147 "ecore_animator_del"); 147 "ecore_animator_del");
148 return; 148 return;
149 } 149 }
150 if (animator->delete_me) return; 150 if (animator->delete_me) return;
151 animator->suspended = EINA_TRUE; 151 animator->suspended = EINA_TRUE;
@@ -164,9 +164,9 @@ ecore_animator_thaw(Ecore_Animator *animator)
164{ 164{
165 if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) 165 if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR))
166 { 166 {
167 ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, 167 ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
168 "ecore_animator_del"); 168 "ecore_animator_del");
169 return; 169 return;
170 } 170 }
171 if (animator->delete_me) return; 171 if (animator->delete_me) return;
172 animator->suspended = EINA_FALSE; 172 animator->suspended = EINA_FALSE;
@@ -177,17 +177,17 @@ _ecore_animator_shutdown(void)
177{ 177{
178 if (timer) 178 if (timer)
179 { 179 {
180 ecore_timer_del(timer); 180 ecore_timer_del(timer);
181 timer = NULL; 181 timer = NULL;
182 } 182 }
183 while (animators) 183 while (animators)
184 { 184 {
185 Ecore_Animator *animator; 185 Ecore_Animator *animator;
186 186
187 animator = animators; 187 animator = animators;
188 animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators)); 188 animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators));
189 ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); 189 ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
190 free(animator); 190 free(animator);
191 } 191 }
192} 192}
193 193
@@ -198,36 +198,36 @@ _ecore_animator(void *data __UNUSED__)
198 198
199 EINA_INLIST_FOREACH(animators, animator) 199 EINA_INLIST_FOREACH(animators, animator)
200 { 200 {
201 if (!animator->delete_me && !animator->suspended) 201 if (!animator->delete_me && !animator->suspended)
202 { 202 {
203 if (!animator->func(animator->data)) 203 if (!animator->func(animator->data))
204 { 204 {
205 animator->delete_me = EINA_TRUE; 205 animator->delete_me = EINA_TRUE;
206 animators_delete_me++; 206 animators_delete_me++;
207 } 207 }
208 } 208 }
209 } 209 }
210 if (animators_delete_me) 210 if (animators_delete_me)
211 { 211 {
212 Ecore_Animator *l; 212 Ecore_Animator *l;
213 for(l = animators; l;) 213 for(l = animators; l;)
214 { 214 {
215 animator = l; 215 animator = l;
216 l = (Ecore_Animator *) EINA_INLIST_GET(l)->next; 216 l = (Ecore_Animator *) EINA_INLIST_GET(l)->next;
217 if (animator->delete_me) 217 if (animator->delete_me)
218 { 218 {
219 animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator)); 219 animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator));
220 ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); 220 ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
221 free(animator); 221 free(animator);
222 animators_delete_me--; 222 animators_delete_me--;
223 if (animators_delete_me == 0) break; 223 if (animators_delete_me == 0) break;
224 } 224 }
225 } 225 }
226 } 226 }
227 if (!animators) 227 if (!animators)
228 { 228 {
229 timer = NULL; 229 timer = NULL;
230 return ECORE_CALLBACK_CANCEL; 230 return ECORE_CALLBACK_CANCEL;
231 } 231 }
232 return ECORE_CALLBACK_RENEW; 232 return ECORE_CALLBACK_RENEW;
233} 233}
diff --git a/legacy/ecore/src/lib/ecore/ecore_events.c b/legacy/ecore/src/lib/ecore/ecore_events.c
index a213a007ea..470838cb9a 100644
--- a/legacy/ecore/src/lib/ecore/ecore_events.c
+++ b/legacy/ecore/src/lib/ecore/ecore_events.c
@@ -108,26 +108,26 @@ ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data)
108 eh->data = (void *)data; 108 eh->data = (void *)data;
109 if (type >= (event_handlers_num - 1)) 109 if (type >= (event_handlers_num - 1))
110 { 110 {
111 int p_alloc_num; 111 int p_alloc_num;
112 112
113 p_alloc_num = event_handlers_alloc_num; 113 p_alloc_num = event_handlers_alloc_num;
114 event_handlers_num = type + 1; 114 event_handlers_num = type + 1;
115 if (event_handlers_num > event_handlers_alloc_num) 115 if (event_handlers_num > event_handlers_alloc_num)
116 { 116 {
117 Ecore_Event_Handler **new_handlers; 117 Ecore_Event_Handler **new_handlers;
118 int i; 118 int i;
119 119
120 event_handlers_alloc_num = ((event_handlers_num + 16) / 16) * 16; 120 event_handlers_alloc_num = ((event_handlers_num + 16) / 16) * 16;
121 new_handlers = realloc(event_handlers, event_handlers_alloc_num * sizeof(Ecore_Event_Handler *)); 121 new_handlers = realloc(event_handlers, event_handlers_alloc_num * sizeof(Ecore_Event_Handler *));
122 if (!new_handlers) 122 if (!new_handlers)
123 { 123 {
124 free(eh); 124 free(eh);
125 return NULL; 125 return NULL;
126 } 126 }
127 event_handlers = new_handlers; 127 event_handlers = new_handlers;
128 for (i = p_alloc_num; i < event_handlers_alloc_num; i++) 128 for (i = p_alloc_num; i < event_handlers_alloc_num; i++)
129 event_handlers[i] = NULL; 129 event_handlers[i] = NULL;
130 } 130 }
131 } 131 }
132 event_handlers[type] = (Ecore_Event_Handler *) eina_inlist_append(EINA_INLIST_GET(event_handlers[type]), EINA_INLIST_GET(eh)); 132 event_handlers[type] = (Ecore_Event_Handler *) eina_inlist_append(EINA_INLIST_GET(event_handlers[type]), EINA_INLIST_GET(eh));
133 return eh; 133 return eh;
@@ -148,9 +148,9 @@ ecore_event_handler_del(Ecore_Event_Handler *event_handler)
148{ 148{
149 if (!ECORE_MAGIC_CHECK(event_handler, ECORE_MAGIC_EVENT_HANDLER)) 149 if (!ECORE_MAGIC_CHECK(event_handler, ECORE_MAGIC_EVENT_HANDLER))
150 { 150 {
151 ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER, 151 ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER,
152 "ecore_event_handler_del"); 152 "ecore_event_handler_del");
153 return NULL; 153 return NULL;
154 } 154 }
155 EINA_SAFETY_ON_TRUE_RETURN_VAL(event_handler->delete_me, NULL); 155 EINA_SAFETY_ON_TRUE_RETURN_VAL(event_handler->delete_me, NULL);
156 event_handler->delete_me = 1; 156 event_handler->delete_me = 1;
@@ -208,8 +208,8 @@ ecore_event_del(Ecore_Event *event)
208{ 208{
209 if (!ECORE_MAGIC_CHECK(event, ECORE_MAGIC_EVENT)) 209 if (!ECORE_MAGIC_CHECK(event, ECORE_MAGIC_EVENT))
210 { 210 {
211 ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del"); 211 ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del");
212 return NULL; 212 return NULL;
213 } 213 }
214 EINA_SAFETY_ON_TRUE_RETURN_VAL(event->delete_me, NULL); 214 EINA_SAFETY_ON_TRUE_RETURN_VAL(event->delete_me, NULL);
215 event->delete_me = 1; 215 event->delete_me = 1;
@@ -284,8 +284,8 @@ ecore_event_filter_del(Ecore_Event_Filter *ef)
284{ 284{
285 if (!ECORE_MAGIC_CHECK(ef, ECORE_MAGIC_EVENT_FILTER)) 285 if (!ECORE_MAGIC_CHECK(ef, ECORE_MAGIC_EVENT_FILTER))
286 { 286 {
287 ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del"); 287 ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del");
288 return NULL; 288 return NULL;
289 } 289 }
290 EINA_SAFETY_ON_TRUE_RETURN_VAL(ef->delete_me, NULL); 290 EINA_SAFETY_ON_TRUE_RETURN_VAL(ef->delete_me, NULL);
291 ef->delete_me = 1; 291 ef->delete_me = 1;
@@ -344,12 +344,12 @@ _ecore_event_shutdown(void)
344 event_current = NULL; 344 event_current = NULL;
345 for (i = 0; i < event_handlers_num; i++) 345 for (i = 0; i < event_handlers_num; i++)
346 { 346 {
347 while ((eh = event_handlers[i])) 347 while ((eh = event_handlers[i]))
348 { 348 {
349 event_handlers[i] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i])); 349 event_handlers[i] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i]));
350 ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); 350 ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
351 if (!eh->delete_me) free(eh); 351 if (!eh->delete_me) free(eh);
352 } 352 }
353 } 353 }
354 EINA_LIST_FREE(event_handlers_delete_list, eh) 354 EINA_LIST_FREE(event_handlers_delete_list, eh)
355 free(eh); 355 free(eh);
@@ -359,9 +359,9 @@ _ecore_event_shutdown(void)
359 event_handlers_alloc_num = 0; 359 event_handlers_alloc_num = 0;
360 while ((ef = event_filters)) 360 while ((ef = event_filters))
361 { 361 {
362 event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters)); 362 event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters));
363 ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); 363 ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
364 free(ef); 364 free(ef);
365 } 365 }
366 event_filters_delete_me = 0; 366 event_filters_delete_me = 0;
367 event_filter_current = NULL; 367 event_filter_current = NULL;
@@ -424,10 +424,10 @@ _ecore_event_purge_deleted(void)
424 inpurge++; 424 inpurge++;
425 while (itr) 425 while (itr)
426 { 426 {
427 Ecore_Event *next = (Ecore_Event *)EINA_INLIST_GET(itr)->next; 427 Ecore_Event *next = (Ecore_Event *)EINA_INLIST_GET(itr)->next;
428 if ((!itr->references) && (itr->delete_me)) 428 if ((!itr->references) && (itr->delete_me))
429 _ecore_event_del(itr); 429 _ecore_event_del(itr);
430 itr = next; 430 itr = next;
431 } 431 }
432 inpurge--; 432 inpurge--;
433 while (purge_events) 433 while (purge_events)
@@ -444,82 +444,82 @@ _ecore_event_filters_apply()
444 444
445 if (!event_filter_current) 445 if (!event_filter_current)
446 { 446 {
447 /* regular main loop, start from head */ 447 /* regular main loop, start from head */
448 event_filter_current = event_filters; 448 event_filter_current = event_filters;
449 } 449 }
450 else 450 else
451 { 451 {
452 /* recursive main loop, continue from where we were */ 452 /* recursive main loop, continue from where we were */
453 event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; 453 event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next;
454 } 454 }
455 455
456 while (event_filter_current) 456 while (event_filter_current)
457 { 457 {
458 Ecore_Event_Filter *ef = event_filter_current; 458 Ecore_Event_Filter *ef = event_filter_current;
459 459
460 if (!ef->delete_me) 460 if (!ef->delete_me)
461 { 461 {
462 ef->references++; 462 ef->references++;
463 463
464 if (ef->func_start) 464 if (ef->func_start)
465 ef->loop_data = ef->func_start(ef->data); 465 ef->loop_data = ef->func_start(ef->data);
466 466
467 if (!event_filter_event_current) 467 if (!event_filter_event_current)
468 { 468 {
469 /* regular main loop, start from head */ 469 /* regular main loop, start from head */
470 event_filter_event_current = events; 470 event_filter_event_current = events;
471 } 471 }
472 else 472 else
473 { 473 {
474 /* recursive main loop, continue from where we were */ 474 /* recursive main loop, continue from where we were */
475 event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; 475 event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next;
476 } 476 }
477 477
478 while (event_filter_event_current) 478 while (event_filter_event_current)
479 { 479 {
480 Ecore_Event *e = event_filter_event_current; 480 Ecore_Event *e = event_filter_event_current;
481 481
482 if (!ef->func_filter(ef->data, ef->loop_data, 482 if (!ef->func_filter(ef->data, ef->loop_data,
483 e->type, e->event)) 483 e->type, e->event))
484 { 484 {
485 ecore_event_del(e); 485 ecore_event_del(e);
486 } 486 }
487 487
488 if (event_filter_event_current) /* may have changed in recursive main loops */ 488 if (event_filter_event_current) /* may have changed in recursive main loops */
489 event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; 489 event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next;
490 } 490 }
491 if (ef->func_end) 491 if (ef->func_end)
492 ef->func_end(ef->data, ef->loop_data); 492 ef->func_end(ef->data, ef->loop_data);
493 493
494 ef->references--; 494 ef->references--;
495 } 495 }
496 496
497 if (event_filter_current) /* may have changed in recursive main loops */ 497 if (event_filter_current) /* may have changed in recursive main loops */
498 event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; 498 event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next;
499 } 499 }
500 if (event_filters_delete_me) 500 if (event_filters_delete_me)
501 { 501 {
502 int deleted_in_use = 0; 502 int deleted_in_use = 0;
503 Ecore_Event_Filter *l; 503 Ecore_Event_Filter *l;
504 for (l = event_filters; l;) 504 for (l = event_filters; l;)
505 { 505 {
506 Ecore_Event_Filter *ef = l; 506 Ecore_Event_Filter *ef = l;
507 l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->next; 507 l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->next;
508 if (ef->delete_me) 508 if (ef->delete_me)
509 { 509 {
510 if (ef->references) 510 if (ef->references)
511 { 511 {
512 deleted_in_use++; 512 deleted_in_use++;
513 continue; 513 continue;
514 } 514 }
515 515
516 event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef)); 516 event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
517 ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); 517 ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
518 free(ef); 518 free(ef);
519 } 519 }
520 } 520 }
521 if (!deleted_in_use) 521 if (!deleted_in_use)
522 event_filters_delete_me = 0; 522 event_filters_delete_me = 0;
523 } 523 }
524} 524}
525void 525void
@@ -532,71 +532,71 @@ _ecore_event_call(void)
532 532
533 if (!event_current) 533 if (!event_current)
534 { 534 {
535 /* regular main loop, start from head */ 535 /* regular main loop, start from head */
536 event_current = events; 536 event_current = events;
537 event_handler_current = NULL; 537 event_handler_current = NULL;
538 } 538 }
539 539
540 while (event_current) 540 while (event_current)
541 { 541 {
542 Ecore_Event *e = event_current; 542 Ecore_Event *e = event_current;
543 int handle_count = 0; 543 int handle_count = 0;
544 544
545 if (e->delete_me) 545 if (e->delete_me)
546 { 546 {
547 event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; 547 event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next;
548 continue; 548 continue;
549 } 549 }
550 550
551 ecore_raw_event_type = e->type; 551 ecore_raw_event_type = e->type;
552 ecore_raw_event_event = e->event; 552 ecore_raw_event_event = e->event;
553 e->references++; 553 e->references++;
554 if ((e->type >= 0) && (e->type < event_handlers_num)) 554 if ((e->type >= 0) && (e->type < event_handlers_num))
555 { 555 {
556 if (!event_handler_current) 556 if (!event_handler_current)
557 { 557 {
558 /* regular main loop, start from head */ 558 /* regular main loop, start from head */
559 event_handler_current = event_handlers[e->type]; 559 event_handler_current = event_handlers[e->type];
560 } 560 }
561 else 561 else
562 { 562 {
563 /* recursive main loop, continue from where we were */ 563 /* recursive main loop, continue from where we were */
564 event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; 564 event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next;
565 } 565 }
566 566
567 while ((event_handler_current) && (!e->delete_me)) 567 while ((event_handler_current) && (!e->delete_me))
568 { 568 {
569 Ecore_Event_Handler *eh = event_handler_current; 569 Ecore_Event_Handler *eh = event_handler_current;
570 if (!eh->delete_me) 570 if (!eh->delete_me)
571 { 571 {
572 Eina_Bool ret; 572 Eina_Bool ret;
573 573
574 handle_count++; 574 handle_count++;
575 575
576 eh->references++; 576 eh->references++;
577 ret = eh->func(eh->data, e->type, e->event); 577 ret = eh->func(eh->data, e->type, e->event);
578 eh->references--; 578 eh->references--;
579 579
580 if (!ret) 580 if (!ret)
581 { 581 {
582 event_handler_current = NULL; 582 event_handler_current = NULL;
583 break; /* 0 == "call no further handlers" */ 583 break; /* 0 == "call no further handlers" */
584 } 584 }
585 } 585 }
586 586
587 if (event_handler_current) /* may have changed in recursive main loops */ 587 if (event_handler_current) /* may have changed in recursive main loops */
588 event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; 588 event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next;
589 } 589 }
590 } 590 }
591 /* if no handlers were set for EXIT signal - then default is */ 591 /* if no handlers were set for EXIT signal - then default is */
592 /* to quit the main loop */ 592 /* to quit the main loop */
593 if ((e->type == ECORE_EVENT_SIGNAL_EXIT) && (handle_count == 0)) 593 if ((e->type == ECORE_EVENT_SIGNAL_EXIT) && (handle_count == 0))
594 ecore_main_loop_quit(); 594 ecore_main_loop_quit();
595 e->references--; 595 e->references--;
596 e->delete_me = 1; 596 e->delete_me = 1;
597 597
598 if (event_current) /* may have changed in recursive main loops */ 598 if (event_current) /* may have changed in recursive main loops */
599 event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; 599 event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next;
600 } 600 }
601 601
602 ecore_raw_event_type = ECORE_EVENT_NONE; 602 ecore_raw_event_type = ECORE_EVENT_NONE;
@@ -606,13 +606,13 @@ _ecore_event_call(void)
606 606
607 EINA_LIST_FOREACH_SAFE(event_handlers_delete_list, l, l_next, eh) 607 EINA_LIST_FOREACH_SAFE(event_handlers_delete_list, l, l_next, eh)
608 { 608 {
609 if (eh->references) continue; 609 if (eh->references) continue;
610 610
611 event_handlers_delete_list = eina_list_remove_list(event_handlers_delete_list, l); 611 event_handlers_delete_list = eina_list_remove_list(event_handlers_delete_list, l);
612 612
613 event_handlers[eh->type] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh)); 613 event_handlers[eh->type] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh));
614 ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); 614 ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
615 free(eh); 615 free(eh);
616 } 616 }
617} 617}
618 618
diff --git a/legacy/ecore/src/lib/ecore/ecore_exe.c b/legacy/ecore/src/lib/ecore/ecore_exe.c
index 3f8eb06ee9..251157c621 100644
--- a/legacy/ecore/src/lib/ecore/ecore_exe.c
+++ b/legacy/ecore/src/lib/ecore/ecore_exe.c
@@ -97,19 +97,19 @@ struct _Ecore_Exe
97 Ecore_Fd_Handler *error_fd_handler; /* the fd_handler to handle errors from child - if this was used, or NULL if not */ 97 Ecore_Fd_Handler *error_fd_handler; /* the fd_handler to handle errors from child - if this was used, or NULL if not */
98 void *write_data_buf; /* a data buffer for data to write to the child - 98 void *write_data_buf; /* a data buffer for data to write to the child -
99 * realloced as needed for more data and flushed when the fd handler says writes are possible 99 * realloced as needed for more data and flushed when the fd handler says writes are possible
100 */ 100 */
101 int write_data_size; /* the size in bytes of the data buffer */ 101 int write_data_size; /* the size in bytes of the data buffer */
102 int write_data_offset; /* the offset in bytes in the data buffer */ 102 int write_data_offset; /* the offset in bytes in the data buffer */
103 void *read_data_buf; /* data read from the child awating delivery to an event */ 103 void *read_data_buf; /* data read from the child awating delivery to an event */
104 int read_data_size; /* data read from child in bytes */ 104 int read_data_size; /* data read from child in bytes */
105 void *error_data_buf; /* errors read from the child awating delivery to an event */ 105 void *error_data_buf; /* errors read from the child awating delivery to an event */
106 int error_data_size; /* errors read from child in bytes */ 106 int error_data_size; /* errors read from child in bytes */
107 int child_fd_write; /* fd to write TO to send data to the child */ 107 int child_fd_write; /* fd to write TO to send data to the child */
108 int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */ 108 int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */
109 int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */ 109 int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */
110 int child_fd_write_x; /* fd to write TO to send data to the child */ 110 int child_fd_write_x; /* fd to write TO to send data to the child */
111 int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */ 111 int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */
112 int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */ 112 int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */
113 Eina_Bool close_stdin : 1; 113 Eina_Bool close_stdin : 1;
114 114
115 int start_bytes, end_bytes, start_lines, end_lines; /* Number of bytes/lines to auto pipe at start/end of stdout/stderr. */ 115 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)
183 183
184 if (result == -1) 184 if (result == -1)
185 { 185 {
186 perror("*** errno reports "); 186 perror("*** errno reports ");
187/* What is currently supported - 187/* What is currently supported -
188 * 188 *
189 * pipe 189 * pipe
@@ -239,8 +239,8 @@ _ecore_exe_check_errno(int result, const char *file, int line)
239 * // Something failed, cleanup. 239 * // Something failed, cleanup.
240 * } 240 * }
241 */ 241 */
242 switch (saved_errno) 242 switch (saved_errno)
243 { 243 {
244 case EACCES: 244 case EACCES:
245 case EAGAIN: 245 case EAGAIN:
246 case EINTR: 246 case EINTR:
@@ -290,7 +290,7 @@ _ecore_exe_check_errno(int result, const char *file, int line)
290 result = 0; 290 result = 0;
291 break; 291 break;
292 } 292 }
293 } 293 }
294 } 294 }
295 else /* Everything is fine. */ 295 else /* Everything is fine. */
296 result = 1; 296 result = 1;
@@ -369,18 +369,18 @@ ecore_exe_run(const char *exe_cmd, const void *data)
369 pid = fork(); 369 pid = fork();
370 if (pid) 370 if (pid)
371 { 371 {
372 exe = calloc(1, sizeof(Ecore_Exe)); 372 exe = calloc(1, sizeof(Ecore_Exe));
373 if (!exe) 373 if (!exe)
374 { 374 {
375 kill(pid, SIGKILL); 375 kill(pid, SIGKILL);
376 return NULL; 376 return NULL;
377 } 377 }
378 ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); 378 ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE);
379 exe->pid = pid; 379 exe->pid = pid;
380 exe->data = (void *)data; 380 exe->data = (void *)data;
381 exe->cmd = strdup(exe_cmd); 381 exe->cmd = strdup(exe_cmd);
382 exes = _ecore_list2_append(exes, exe); 382 exes = _ecore_list2_append(exes, exe);
383 return exe; 383 return exe;
384 } 384 }
385 _ecore_exe_exec_it(exe_cmd, 0); 385 _ecore_exe_exec_it(exe_cmd, 0);
386 exit(127); 386 exit(127);
@@ -447,247 +447,247 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data)
447 /* Create some pipes. */ 447 /* Create some pipes. */
448 if (ok) 448 if (ok)
449 { 449 {
450 E_IF_NO_ERRNO_NOLOOP(result, pipe(statusPipe), ok) 450 E_IF_NO_ERRNO_NOLOOP(result, pipe(statusPipe), ok)
451 { 451 {
452 } 452 }
453 } 453 }
454 if (ok && (flags & ECORE_EXE_PIPE_ERROR)) 454 if (ok && (flags & ECORE_EXE_PIPE_ERROR))
455 { 455 {
456 E_IF_NO_ERRNO_NOLOOP(result, pipe(errorPipe), ok) 456 E_IF_NO_ERRNO_NOLOOP(result, pipe(errorPipe), ok)
457 { 457 {
458 exe->child_fd_error = errorPipe[0]; 458 exe->child_fd_error = errorPipe[0];
459 exe->child_fd_error_x = errorPipe[1]; 459 exe->child_fd_error_x = errorPipe[1];
460 } 460 }
461 } 461 }
462 if (ok && (flags & ECORE_EXE_PIPE_READ)) 462 if (ok && (flags & ECORE_EXE_PIPE_READ))
463 { 463 {
464 E_IF_NO_ERRNO_NOLOOP(result, pipe(readPipe), ok) 464 E_IF_NO_ERRNO_NOLOOP(result, pipe(readPipe), ok)
465 { 465 {
466 exe->child_fd_read = readPipe[0]; 466 exe->child_fd_read = readPipe[0];
467 exe->child_fd_read_x = readPipe[1]; 467 exe->child_fd_read_x = readPipe[1];
468 } 468 }
469 } 469 }
470 if (ok && (flags & ECORE_EXE_PIPE_WRITE)) 470 if (ok && (flags & ECORE_EXE_PIPE_WRITE))
471 { 471 {
472 E_IF_NO_ERRNO_NOLOOP(result, pipe(writePipe), ok) 472 E_IF_NO_ERRNO_NOLOOP(result, pipe(writePipe), ok)
473 { 473 {
474 exe->child_fd_write = writePipe[1]; 474 exe->child_fd_write = writePipe[1];
475 exe->child_fd_write_x = writePipe[0]; 475 exe->child_fd_write_x = writePipe[0];
476 } 476 }
477 } 477 }
478 if (ok) 478 if (ok)
479 { 479 {
480 pid_t pid = 0; 480 pid_t pid = 0;
481 volatile int vfork_exec_errno = 0; 481 volatile int vfork_exec_errno = 0;
482 482
483 /* FIXME: I should double check this. After a quick look around, this is already done, but via a more modern method. */ 483 /* FIXME: I should double check this. After a quick look around, this is already done, but via a more modern method. */
484 /* signal(SIGPIPE, SIG_IGN); We only want EPIPE on errors */ 484 /* signal(SIGPIPE, SIG_IGN); We only want EPIPE on errors */
485 pid = fork(); 485 pid = fork();
486 486
487 if (pid == -1) 487 if (pid == -1)
488 { 488 {
489 ERR("Failed to fork process"); 489 ERR("Failed to fork process");
490 pid = 0; 490 pid = 0;
491 } 491 }
492 else if (pid == 0) /* child */ 492 else if (pid == 0) /* child */
493 { 493 {
494 if (run_pri != ECORE_EXE_PRIORITY_INHERIT) 494 if (run_pri != ECORE_EXE_PRIORITY_INHERIT)
495 { 495 {
496 if ((run_pri >= -20) && (run_pri <= 19)) 496 if ((run_pri >= -20) && (run_pri <= 19))
497 setpriority(PRIO_PROCESS, 0, run_pri); 497 setpriority(PRIO_PROCESS, 0, run_pri);
498 } 498 }
499 /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the 499 /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the
500 * second pipe if it's open. On the other hand, there was the 500 * second pipe if it's open. On the other hand, there was the
501 * Great FD Leak Scare of '06, so let's be paranoid. */ 501 * Great FD Leak Scare of '06, so let's be paranoid. */
502 if (ok && (flags & ECORE_EXE_PIPE_ERROR)) 502 if (ok && (flags & ECORE_EXE_PIPE_ERROR))
503 { 503 {
504 E_NO_ERRNO(result, close(STDERR_FILENO), ok); 504 E_NO_ERRNO(result, close(STDERR_FILENO), ok);
505 E_NO_ERRNO(result, dup2(errorPipe[1], STDERR_FILENO), ok); 505 E_NO_ERRNO(result, dup2(errorPipe[1], STDERR_FILENO), ok);
506 } 506 }
507 if (ok && (flags & ECORE_EXE_PIPE_READ)) 507 if (ok && (flags & ECORE_EXE_PIPE_READ))
508 { 508 {
509 E_NO_ERRNO(result, close(STDOUT_FILENO), ok); 509 E_NO_ERRNO(result, close(STDOUT_FILENO), ok);
510 E_NO_ERRNO(result, dup2(readPipe[1], STDOUT_FILENO), ok); 510 E_NO_ERRNO(result, dup2(readPipe[1], STDOUT_FILENO), ok);
511 } 511 }
512 if (ok && (flags & ECORE_EXE_PIPE_WRITE)) 512 if (ok && (flags & ECORE_EXE_PIPE_WRITE))
513 { 513 {
514 E_NO_ERRNO(result, close(STDIN_FILENO), ok); 514 E_NO_ERRNO(result, close(STDIN_FILENO), ok);
515 E_NO_ERRNO(result, dup2(writePipe[0], STDIN_FILENO), ok); 515 E_NO_ERRNO(result, dup2(writePipe[0], STDIN_FILENO), ok);
516 } 516 }
517 517
518 if (ok) 518 if (ok)
519 { 519 {
520 /* Setup the status pipe. */ 520 /* Setup the status pipe. */
521 E_NO_ERRNO(result, close(statusPipe[0]), ok); 521 E_NO_ERRNO(result, close(statusPipe[0]), ok);
522 E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) /* close on exec shows success */ 522 E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) /* close on exec shows success */
523 { 523 {
524 /* Run the actual command. */ 524 /* Run the actual command. */
525 _ecore_exe_exec_it(exe_cmd, flags); /* no return */ 525 _ecore_exe_exec_it(exe_cmd, flags); /* no return */
526 } 526 }
527 } 527 }
528 528
529 /* Something went 'orribly wrong. */ 529 /* Something went 'orribly wrong. */
530 vfork_exec_errno = errno; 530 vfork_exec_errno = errno;
531 531
532 /* Close the pipes. */ 532 /* Close the pipes. */
533 if (flags & ECORE_EXE_PIPE_ERROR) 533 if (flags & ECORE_EXE_PIPE_ERROR)
534 E_NO_ERRNO(result, close(errorPipe[1]), ok); 534 E_NO_ERRNO(result, close(errorPipe[1]), ok);
535 if (flags & ECORE_EXE_PIPE_READ) 535 if (flags & ECORE_EXE_PIPE_READ)
536 E_NO_ERRNO(result, close(readPipe[1]), ok); 536 E_NO_ERRNO(result, close(readPipe[1]), ok);
537 if (flags & ECORE_EXE_PIPE_WRITE) 537 if (flags & ECORE_EXE_PIPE_WRITE)
538 E_NO_ERRNO(result, close(writePipe[0]), ok); 538 E_NO_ERRNO(result, close(writePipe[0]), ok);
539 E_NO_ERRNO(result, close(statusPipe[1]), ok); 539 E_NO_ERRNO(result, close(statusPipe[1]), ok);
540 540
541 _exit(-1); 541 _exit(-1);
542 } 542 }
543 else /* parent */ 543 else /* parent */
544 { 544 {
545 /* Close the unused pipes. */ 545 /* Close the unused pipes. */
546 E_NO_ERRNO(result, close(statusPipe[1]), ok); 546 E_NO_ERRNO(result, close(statusPipe[1]), ok);
547 547
548 /* FIXME: after having a good look at the current e fd 548 /* FIXME: after having a good look at the current e fd
549 * handling, investigate fcntl(dataPipe[x], F_SETSIG, ...) */ 549 * handling, investigate fcntl(dataPipe[x], F_SETSIG, ...) */
550 /* FIXME: above F_SETSIG etc. - this is async SIGIO based IO 550 /* FIXME: above F_SETSIG etc. - this is async SIGIO based IO
551 * which is also linux specific so we probably don't want to 551 * which is also linux specific so we probably don't want to
552 * do this as long as select() is working fine. the only time 552 * do this as long as select() is working fine. the only time
553 * we really want to think of SIGIO async IO is when it all 553 * we really want to think of SIGIO async IO is when it all
554 * actually works basically everywhere and we can turn all 554 * actually works basically everywhere and we can turn all
555 * IO into DMA async activities (i.e. you do a read() then 555 * IO into DMA async activities (i.e. you do a read() then
556 * the read is complete not on return but when you get a 556 * the read is complete not on return but when you get a
557 * SIGIO - the read() just starts the transfer and it is 557 * SIGIO - the read() just starts the transfer and it is
558 * completed in the background by DMA (or whatever mechanism 558 * completed in the background by DMA (or whatever mechanism
559 * the kernel choses)) */ 559 * the kernel choses)) */
560 560
561 /* Wait for it to start executing. */ 561 /* Wait for it to start executing. */
562 /* FIXME: this doesn't seem very nice - we sit and block 562 /* FIXME: this doesn't seem very nice - we sit and block
563 * waiting on a child process... even though it's just 563 * waiting on a child process... even though it's just
564 * the segment between the fork() and the exec) it just feels 564 * the segment between the fork() and the exec) it just feels
565 * wrong */ 565 * wrong */
566 for (;;) 566 for (;;)
567 { 567 {
568 char buf; 568 char buf;
569 569
570 E_NO_ERRNO(result, read(statusPipe[0], &buf, 1), ok); 570 E_NO_ERRNO(result, read(statusPipe[0], &buf, 1), ok);
571 if (result == 0) 571 if (result == 0)
572 { 572 {
573 if (vfork_exec_errno != 0) 573 if (vfork_exec_errno != 0)
574 { 574 {
575 n = vfork_exec_errno; 575 n = vfork_exec_errno;
576 ERR("Could not start \"%s\"", exe_cmd); 576 ERR("Could not start \"%s\"", exe_cmd);
577 pid = 0; 577 pid = 0;
578 } 578 }
579 break; 579 break;
580 } 580 }
581 } 581 }
582 582
583 /* Close the status pipe. */ 583 /* Close the status pipe. */
584 E_NO_ERRNO(result, close(statusPipe[0]), ok); 584 E_NO_ERRNO(result, close(statusPipe[0]), ok);
585 } 585 }
586 586
587 if (pid) 587 if (pid)
588 { 588 {
589 /* Setup the exe structure. */ 589 /* Setup the exe structure. */
590 ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); 590 ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE);
591 exe->start_bytes = -1; 591 exe->start_bytes = -1;
592 exe->end_bytes = -1; 592 exe->end_bytes = -1;
593 exe->start_lines = -1; 593 exe->start_lines = -1;
594 exe->end_lines = -1; 594 exe->end_lines = -1;
595 exe->pid = pid; 595 exe->pid = pid;
596 exe->flags = flags; 596 exe->flags = flags;
597 exe->data = (void *)data; 597 exe->data = (void *)data;
598 if ((exe->cmd = strdup(exe_cmd))) 598 if ((exe->cmd = strdup(exe_cmd)))
599 { 599 {
600 if (flags & ECORE_EXE_PIPE_ERROR) 600 if (flags & ECORE_EXE_PIPE_ERROR)
601 { /* Setup the error stuff. */ 601 { /* Setup the error stuff. */
602 E_IF_NO_ERRNO(result, 602 E_IF_NO_ERRNO(result,
603 fcntl(exe->child_fd_error, F_SETFL, 603 fcntl(exe->child_fd_error, F_SETFL,
604 O_NONBLOCK), ok) {} 604 O_NONBLOCK), ok) {}
605 E_IF_NO_ERRNO(result, 605 E_IF_NO_ERRNO(result,
606 fcntl(exe->child_fd_error, F_SETFD, 606 fcntl(exe->child_fd_error, F_SETFD,
607 FD_CLOEXEC), ok) {} 607 FD_CLOEXEC), ok) {}
608 E_IF_NO_ERRNO(result, 608 E_IF_NO_ERRNO(result,
609 fcntl(exe->child_fd_error_x, F_SETFD, 609 fcntl(exe->child_fd_error_x, F_SETFD,
610 FD_CLOEXEC), ok) {} 610 FD_CLOEXEC), ok) {}
611 { 611 {
612 exe->error_fd_handler = 612 exe->error_fd_handler =
613 ecore_main_fd_handler_add(exe->child_fd_error, 613 ecore_main_fd_handler_add(exe->child_fd_error,
614 ECORE_FD_READ, 614 ECORE_FD_READ,
615 _ecore_exe_data_error_handler, 615 _ecore_exe_data_error_handler,
616 exe, NULL, NULL); 616 exe, NULL, NULL);
617 if (!exe->error_fd_handler) 617 if (!exe->error_fd_handler)
618 ok = 0; 618 ok = 0;
619 } 619 }
620 } 620 }
621 if (ok && (flags & ECORE_EXE_PIPE_READ)) 621 if (ok && (flags & ECORE_EXE_PIPE_READ))
622 { /* Setup the read stuff. */ 622 { /* Setup the read stuff. */
623 E_IF_NO_ERRNO(result, 623 E_IF_NO_ERRNO(result,
624 fcntl(exe->child_fd_read, F_SETFL, 624 fcntl(exe->child_fd_read, F_SETFL,
625 O_NONBLOCK), ok) {} 625 O_NONBLOCK), ok) {}
626 E_IF_NO_ERRNO(result, 626 E_IF_NO_ERRNO(result,
627 fcntl(exe->child_fd_read, F_SETFD, 627 fcntl(exe->child_fd_read, F_SETFD,
628 FD_CLOEXEC), ok) {} 628 FD_CLOEXEC), ok) {}
629 E_IF_NO_ERRNO(result, 629 E_IF_NO_ERRNO(result,
630 fcntl(exe->child_fd_read_x, F_SETFD, 630 fcntl(exe->child_fd_read_x, F_SETFD,
631 FD_CLOEXEC), ok) {} 631 FD_CLOEXEC), ok) {}
632 { 632 {
633 exe->read_fd_handler = 633 exe->read_fd_handler =
634 ecore_main_fd_handler_add(exe->child_fd_read, 634 ecore_main_fd_handler_add(exe->child_fd_read,
635 ECORE_FD_READ, 635 ECORE_FD_READ,
636 _ecore_exe_data_read_handler, 636 _ecore_exe_data_read_handler,
637 exe, NULL, NULL); 637 exe, NULL, NULL);
638 if (!exe->read_fd_handler) 638 if (!exe->read_fd_handler)
639 ok = 0; 639 ok = 0;
640 } 640 }
641 } 641 }
642 if (ok && (flags & ECORE_EXE_PIPE_WRITE)) 642 if (ok && (flags & ECORE_EXE_PIPE_WRITE))
643 { /* Setup the write stuff. */ 643 { /* Setup the write stuff. */
644 E_IF_NO_ERRNO(result, 644 E_IF_NO_ERRNO(result,
645 fcntl(exe->child_fd_write, F_SETFL, 645 fcntl(exe->child_fd_write, F_SETFL,
646 O_NONBLOCK), ok) {} 646 O_NONBLOCK), ok) {}
647 E_IF_NO_ERRNO(result, 647 E_IF_NO_ERRNO(result,
648 fcntl(exe->child_fd_write, F_SETFD, 648 fcntl(exe->child_fd_write, F_SETFD,
649 FD_CLOEXEC), ok) {} 649 FD_CLOEXEC), ok) {}
650 E_IF_NO_ERRNO(result, 650 E_IF_NO_ERRNO(result,
651 fcntl(exe->child_fd_write_x, F_SETFD, 651 fcntl(exe->child_fd_write_x, F_SETFD,
652 FD_CLOEXEC), ok) {} 652 FD_CLOEXEC), ok) {}
653 { 653 {
654 exe->write_fd_handler = 654 exe->write_fd_handler =
655 ecore_main_fd_handler_add(exe->child_fd_write, 655 ecore_main_fd_handler_add(exe->child_fd_write,
656 ECORE_FD_WRITE, 656 ECORE_FD_WRITE,
657 _ecore_exe_data_write_handler, 657 _ecore_exe_data_write_handler,
658 exe, NULL, NULL); 658 exe, NULL, NULL);
659 if (exe->write_fd_handler) 659 if (exe->write_fd_handler)
660 ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); /* Nothing to write to start with. */ 660 ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); /* Nothing to write to start with. */
661 else 661 else
662 ok = 0; 662 ok = 0;
663 } 663 }
664 } 664 }
665 665
666 exes = (Ecore_Exe *) eina_inlist_append(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe)); 666 exes = (Ecore_Exe *) eina_inlist_append(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe));
667 n = 0; 667 n = 0;
668 } 668 }
669 else 669 else
670 ok = 0; 670 ok = 0;
671 } 671 }
672 else 672 else
673 ok = 0; 673 ok = 0;
674 } 674 }
675 675
676 if (!ok) 676 if (!ok)
677 { /* Something went wrong, so pull down everything. */ 677 { /* Something went wrong, so pull down everything. */
678 if (exe->pid) ecore_exe_terminate(exe); 678 if (exe->pid) ecore_exe_terminate(exe);
679 IF_FN_DEL(ecore_exe_free, exe); 679 IF_FN_DEL(ecore_exe_free, exe);
680 } 680 }
681 else 681 else
682 { 682 {
683 Ecore_Exe_Event_Add *e; 683 Ecore_Exe_Event_Add *e;
684 684
685 e = _ecore_exe_event_add_new(); 685 e = _ecore_exe_event_add_new();
686 e->exe = exe; 686 e->exe = exe;
687 if (e) /* Send the event. */ 687 if (e) /* Send the event. */
688 ecore_event_add(ECORE_EXE_EVENT_ADD, e, 688 ecore_event_add(ECORE_EXE_EVENT_ADD, e,
689 _ecore_exe_event_add_free, NULL); 689 _ecore_exe_event_add_free, NULL);
690 /* INF("Running as %d for %s.\n", exe->pid, exe->cmd); */ 690 /* INF("Running as %d for %s.\n", exe->pid, exe->cmd); */
691 } 691 }
692 692
693 errno = n; 693 errno = n;
@@ -712,9 +712,9 @@ ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func)
712{ 712{
713 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 713 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
714 { 714 {
715 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, 715 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
716 "ecore_exe_callback_pre_free_set"); 716 "ecore_exe_callback_pre_free_set");
717 return; 717 return;
718 } 718 }
719 exe->pre_free_cb = func; 719 exe->pre_free_cb = func;
720} 720}
@@ -739,22 +739,22 @@ ecore_exe_send(Ecore_Exe * exe, const void *data, int size)
739 739
740 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 740 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
741 { 741 {
742 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send"); 742 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send");
743 return EINA_FALSE; 743 return EINA_FALSE;
744 } 744 }
745 745
746 if (exe->close_stdin) 746 if (exe->close_stdin)
747 { 747 {
748 ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p", 748 ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p",
749 exe, size, data); 749 exe, size, data);
750 return EINA_FALSE; 750 return EINA_FALSE;
751 } 751 }
752 752
753 if (exe->child_fd_write == -1) 753 if (exe->child_fd_write == -1)
754 { 754 {
755 ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! " 755 ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! "
756 "Cannot send %d bytes from %p", exe, size, data); 756 "Cannot send %d bytes from %p", exe, size, data);
757 return EINA_FALSE; 757 return EINA_FALSE;
758 } 758 }
759 759
760 buf = realloc(exe->write_data_buf, exe->write_data_size + size); 760 buf = realloc(exe->write_data_buf, exe->write_data_size + size);
@@ -781,8 +781,8 @@ ecore_exe_close_stdin(Ecore_Exe *exe)
781{ 781{
782 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 782 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
783 { 783 {
784 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_close_stdin"); 784 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_close_stdin");
785 return; 785 return;
786 } 786 }
787 exe->close_stdin = 1; 787 exe->close_stdin = 1;
788} 788}
@@ -803,8 +803,8 @@ ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int st
803{ 803{
804 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 804 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
805 { 805 {
806 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_auto_limits_set"); 806 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_auto_limits_set");
807 return; 807 return;
808 } 808 }
809 /* FIXME: sanitize the input. */ 809 /* FIXME: sanitize the input. */
810 exe->start_bytes = start_bytes; 810 exe->start_bytes = start_bytes;
@@ -869,115 +869,115 @@ ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags)
869 869
870 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 870 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
871 { 871 {
872 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_event_data_get"); 872 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_event_data_get");
873 return NULL; 873 return NULL;
874 } 874 }
875 875
876 /* Sort out what sort of event we are. */ 876 /* Sort out what sort of event we are. */
877 if (flags & ECORE_EXE_PIPE_READ) 877 if (flags & ECORE_EXE_PIPE_READ)
878 { 878 {
879 flags = ECORE_EXE_PIPE_READ; 879 flags = ECORE_EXE_PIPE_READ;
880 if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED) 880 if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED)
881 is_buffered = 1; 881 is_buffered = 1;
882 } 882 }
883 else 883 else
884 { 884 {
885 flags = ECORE_EXE_PIPE_ERROR; 885 flags = ECORE_EXE_PIPE_ERROR;
886 if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED) 886 if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED)
887 is_buffered = 1; 887 is_buffered = 1;
888 } 888 }
889 889
890 /* Get the data. */ 890 /* Get the data. */
891 if (flags & ECORE_EXE_PIPE_READ) 891 if (flags & ECORE_EXE_PIPE_READ)
892 { 892 {
893 inbuf = exe->read_data_buf; 893 inbuf = exe->read_data_buf;
894 inbuf_num = exe->read_data_size; 894 inbuf_num = exe->read_data_size;
895 exe->read_data_buf = NULL; 895 exe->read_data_buf = NULL;
896 exe->read_data_size = 0; 896 exe->read_data_size = 0;
897 } 897 }
898 else 898 else
899 { 899 {
900 inbuf = exe->error_data_buf; 900 inbuf = exe->error_data_buf;
901 inbuf_num = exe->error_data_size; 901 inbuf_num = exe->error_data_size;
902 exe->error_data_buf = NULL; 902 exe->error_data_buf = NULL;
903 exe->error_data_size = 0; 903 exe->error_data_size = 0;
904 } 904 }
905 905
906 e = calloc(1, sizeof(Ecore_Exe_Event_Data)); 906 e = calloc(1, sizeof(Ecore_Exe_Event_Data));
907 if (e) 907 if (e)
908 { 908 {
909 e->exe = exe; 909 e->exe = exe;
910 e->data = inbuf; 910 e->data = inbuf;
911 e->size = inbuf_num; 911 e->size = inbuf_num;
912 912
913 if (is_buffered) 913 if (is_buffered)
914 { /* Deal with line buffering. */ 914 { /* Deal with line buffering. */
915 int max = 0; 915 int max = 0;
916 int count = 0; 916 int count = 0;
917 int i; 917 int i;
918 int last = 0; 918 int last = 0;
919 char *c; 919 char *c;
920 920
921 c = (char *)inbuf; 921 c = (char *)inbuf;
922 for (i = 0; i < inbuf_num; i++) /* Find the lines. */ 922 for (i = 0; i < inbuf_num; i++) /* Find the lines. */
923 { 923 {
924 if (inbuf[i] == '\n') 924 if (inbuf[i] == '\n')
925 { 925 {
926 if (count >= max) 926 if (count >= max)
927 { 927 {
928 /* In testing, the lines seem to arrive in batches of 500 to 1000 lines at most, roughly speaking. */ 928 /* In testing, the lines seem to arrive in batches of 500 to 1000 lines at most, roughly speaking. */
929 max += 10; /* FIXME: Maybe keep track of the largest number of lines ever sent, and add half that many instead of 10. */ 929 max += 10; /* FIXME: Maybe keep track of the largest number of lines ever sent, and add half that many instead of 10. */
930 e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL termination. */ 930 e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL termination. */
931 } 931 }
932 /* raster said to leave the line endings as line endings, however - 932 /* raster said to leave the line endings as line endings, however -
933 * This is line buffered mode, we are not dealing with binary here, but lines. 933 * This is line buffered mode, we are not dealing with binary here, but lines.
934 * If we are not dealing with binary, we must be dealing with ASCII, unicode, or some other text format. 934 * If we are not dealing with binary, we must be dealing with ASCII, unicode, or some other text format.
935 * Thus the user is most likely gonna deal with this text as strings. 935 * Thus the user is most likely gonna deal with this text as strings.
936 * Thus the user is most likely gonna pass this data to str functions. 936 * Thus the user is most likely gonna pass this data to str functions.
937 * rasters way - the endings are always gonna be '\n'; onefangs way - they will always be '\0' 937 * rasters way - the endings are always gonna be '\n'; onefangs way - they will always be '\0'
938 * We are handing them the string length as a convenience. 938 * We are handing them the string length as a convenience.
939 * Thus if they really want it in raw format, they can e->lines[i].line[e->lines[i].size - 1] = '\n'; easily enough. 939 * Thus if they really want it in raw format, they can e->lines[i].line[e->lines[i].size - 1] = '\n'; easily enough.
940 * In the default case, we can do this conversion quicker than the user can, as we already have the index and pointer. 940 * In the default case, we can do this conversion quicker than the user can, as we already have the index and pointer.
941 * Let's make it easy on them to use these as standard C strings. 941 * Let's make it easy on them to use these as standard C strings.
942 * 942 *
943 * onefang is proud to announce that he has just set a new personal record for the 943 * onefang is proud to announce that he has just set a new personal record for the
944 * most over documentation of a simple assignment statement. B-) 944 * most over documentation of a simple assignment statement. B-)
945 */ 945 */
946 inbuf[i] = '\0'; 946 inbuf[i] = '\0';
947 e->lines[count].line = c; 947 e->lines[count].line = c;
948 e->lines[count].size = i - last; 948 e->lines[count].size = i - last;
949 last = i + 1; 949 last = i + 1;
950 c = (char *)&inbuf[last]; 950 c = (char *)&inbuf[last];
951 count++; 951 count++;
952 } 952 }
953 } 953 }
954 if (count == 0) /* No lines to send, cancel the event. */ 954 if (count == 0) /* No lines to send, cancel the event. */
955 { 955 {
956 _ecore_exe_event_exe_data_free(NULL, e); 956 _ecore_exe_event_exe_data_free(NULL, e);
957 e = NULL; 957 e = NULL;
958 } 958 }
959 else /* NULL terminate the array, so that people know where the end is. */ 959 else /* NULL terminate the array, so that people know where the end is. */
960 { 960 {
961 e->lines[count].line = NULL; 961 e->lines[count].line = NULL;
962 e->lines[count].size = 0; 962 e->lines[count].size = 0;
963 } 963 }
964 if (i > last) /* Partial line left over, save it for next time. */ 964 if (i > last) /* Partial line left over, save it for next time. */
965 { 965 {
966 if (e) e->size = last; 966 if (e) e->size = last;
967 if (flags & ECORE_EXE_PIPE_READ) 967 if (flags & ECORE_EXE_PIPE_READ)
968 { 968 {
969 exe->read_data_size = i - last; 969 exe->read_data_size = i - last;
970 exe->read_data_buf = malloc(exe->read_data_size); 970 exe->read_data_buf = malloc(exe->read_data_size);
971 memcpy(exe->read_data_buf, c, exe->read_data_size); 971 memcpy(exe->read_data_buf, c, exe->read_data_size);
972 } 972 }
973 else 973 else
974 { 974 {
975 exe->error_data_size = i - last; 975 exe->error_data_size = i - last;
976 exe->error_data_buf = malloc(exe->error_data_size); 976 exe->error_data_buf = malloc(exe->error_data_size);
977 memcpy(exe->error_data_buf, c, exe->error_data_size); 977 memcpy(exe->error_data_buf, c, exe->error_data_size);
978 } 978 }
979 } 979 }
980 } 980 }
981 } 981 }
982 982
983 return e; 983 return e;
@@ -995,8 +995,8 @@ ecore_exe_tag_set(Ecore_Exe *exe, const char *tag)
995{ 995{
996 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 996 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
997 { 997 {
998 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_set"); 998 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_set");
999 return; 999 return;
1000 } 1000 }
1001 IF_FREE(exe->tag); 1001 IF_FREE(exe->tag);
1002 if (tag) 1002 if (tag)
@@ -1022,8 +1022,8 @@ ecore_exe_tag_get(const Ecore_Exe *exe)
1022{ 1022{
1023 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1023 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1024 { 1024 {
1025 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_get"); 1025 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_get");
1026 return NULL; 1026 return NULL;
1027 } 1027 }
1028 return exe->tag; 1028 return exe->tag;
1029} 1029}
@@ -1048,8 +1048,8 @@ ecore_exe_free(Ecore_Exe *exe)
1048 1048
1049 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1049 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1050 { 1050 {
1051 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free"); 1051 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free");
1052 return NULL; 1052 return NULL;
1053 } 1053 }
1054 1054
1055 data = exe->data; 1055 data = exe->data;
@@ -1059,17 +1059,17 @@ ecore_exe_free(Ecore_Exe *exe)
1059 1059
1060 if (exe->doomsday_clock) 1060 if (exe->doomsday_clock)
1061 { 1061 {
1062 struct _ecore_exe_dead_exe *dead; 1062 struct _ecore_exe_dead_exe *dead;
1063 1063
1064 ecore_timer_del(exe->doomsday_clock); 1064 ecore_timer_del(exe->doomsday_clock);
1065 exe->doomsday_clock = NULL; 1065 exe->doomsday_clock = NULL;
1066 dead = exe->doomsday_clock_dead; 1066 dead = exe->doomsday_clock_dead;
1067 if (dead) 1067 if (dead)
1068 { 1068 {
1069 IF_FREE(dead->cmd); 1069 IF_FREE(dead->cmd);
1070 free(dead); 1070 free(dead);
1071 exe->doomsday_clock_dead = NULL; 1071 exe->doomsday_clock_dead = NULL;
1072 } 1072 }
1073 } 1073 }
1074 IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler); 1074 IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler);
1075 IF_FN_DEL(ecore_main_fd_handler_del, exe->read_fd_handler); 1075 IF_FN_DEL(ecore_main_fd_handler_del, exe->read_fd_handler);
@@ -1124,8 +1124,8 @@ ecore_exe_pid_get(const Ecore_Exe *exe)
1124{ 1124{
1125 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1125 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1126 { 1126 {
1127 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pid_get"); 1127 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pid_get");
1128 return -1; 1128 return -1;
1129 } 1129 }
1130 return exe->pid; 1130 return exe->pid;
1131} 1131}
@@ -1143,8 +1143,8 @@ ecore_exe_cmd_get(const Ecore_Exe *exe)
1143{ 1143{
1144 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1144 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1145 { 1145 {
1146 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_cmd_get"); 1146 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_cmd_get");
1147 return NULL; 1147 return NULL;
1148 } 1148 }
1149 return exe->cmd; 1149 return exe->cmd;
1150} 1150}
@@ -1161,8 +1161,8 @@ ecore_exe_data_get(const Ecore_Exe *exe)
1161{ 1161{
1162 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1162 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1163 { 1163 {
1164 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); 1164 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get");
1165 return NULL; 1165 return NULL;
1166 } 1166 }
1167 return exe->data; 1167 return exe->data;
1168} 1168}
@@ -1178,8 +1178,8 @@ ecore_exe_flags_get(const Ecore_Exe *exe)
1178{ 1178{
1179 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1179 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1180 { 1180 {
1181 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); 1181 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get");
1182 return 0; 1182 return 0;
1183 } 1183 }
1184 return exe->flags; 1184 return exe->flags;
1185} 1185}
@@ -1200,8 +1200,8 @@ ecore_exe_pause(Ecore_Exe *exe)
1200{ 1200{
1201 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1201 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1202 { 1202 {
1203 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause"); 1203 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause");
1204 return; 1204 return;
1205 } 1205 }
1206 kill(exe->pid, SIGSTOP); 1206 kill(exe->pid, SIGSTOP);
1207} 1207}
@@ -1216,8 +1216,8 @@ ecore_exe_continue(Ecore_Exe *exe)
1216{ 1216{
1217 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1217 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1218 { 1218 {
1219 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_continue"); 1219 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_continue");
1220 return; 1220 return;
1221 } 1221 }
1222 kill(exe->pid, SIGCONT); 1222 kill(exe->pid, SIGCONT);
1223} 1223}
@@ -1232,8 +1232,8 @@ ecore_exe_interrupt(Ecore_Exe *exe)
1232{ 1232{
1233 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1233 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1234 { 1234 {
1235 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_interrupt"); 1235 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_interrupt");
1236 return; 1236 return;
1237 } 1237 }
1238 _ecore_exe_dead_attach(exe); 1238 _ecore_exe_dead_attach(exe);
1239 kill(exe->pid, SIGINT); 1239 kill(exe->pid, SIGINT);
@@ -1249,8 +1249,8 @@ ecore_exe_quit(Ecore_Exe *exe)
1249{ 1249{
1250 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1250 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1251 { 1251 {
1252 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit"); 1252 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit");
1253 return; 1253 return;
1254 } 1254 }
1255 _ecore_exe_dead_attach(exe); 1255 _ecore_exe_dead_attach(exe);
1256 kill(exe->pid, SIGQUIT); 1256 kill(exe->pid, SIGQUIT);
@@ -1266,8 +1266,8 @@ ecore_exe_terminate(Ecore_Exe *exe)
1266{ 1266{
1267 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1267 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1268 { 1268 {
1269 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_terminate"); 1269 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_terminate");
1270 return; 1270 return;
1271 } 1271 }
1272 _ecore_exe_dead_attach(exe); 1272 _ecore_exe_dead_attach(exe);
1273 INF("Sending TERM signal to %s (%d).", exe->cmd, exe->pid); 1273 INF("Sending TERM signal to %s (%d).", exe->cmd, exe->pid);
@@ -1286,18 +1286,18 @@ ecore_exe_kill(Ecore_Exe *exe)
1286 1286
1287 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1287 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1288 { 1288 {
1289 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill"); 1289 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill");
1290 return; 1290 return;
1291 } 1291 }
1292 1292
1293 dead = calloc(1, sizeof(struct _ecore_exe_dead_exe)); 1293 dead = calloc(1, sizeof(struct _ecore_exe_dead_exe));
1294 if (dead) 1294 if (dead)
1295 { 1295 {
1296 dead->pid = exe->pid; 1296 dead->pid = exe->pid;
1297 dead->cmd = strdup(exe->cmd); 1297 dead->cmd = strdup(exe->cmd);
1298 IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); 1298 IF_FN_DEL(ecore_timer_del, exe->doomsday_clock);
1299 exe->doomsday_clock = 1299 exe->doomsday_clock =
1300 ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, dead); 1300 ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, dead);
1301 } 1301 }
1302 1302
1303 INF("Sending KILL signal to %s (%d).", exe->cmd, exe->pid); 1303 INF("Sending KILL signal to %s (%d).", exe->cmd, exe->pid);
@@ -1316,8 +1316,8 @@ ecore_exe_signal(Ecore_Exe *exe, int num)
1316{ 1316{
1317 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1317 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1318 { 1318 {
1319 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal"); 1319 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal");
1320 return; 1320 return;
1321 } 1321 }
1322 if (num == 1) 1322 if (num == 1)
1323 kill(exe->pid, SIGUSR1); 1323 kill(exe->pid, SIGUSR1);
@@ -1335,8 +1335,8 @@ ecore_exe_hup(Ecore_Exe *exe)
1335{ 1335{
1336 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1336 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1337 { 1337 {
1338 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup"); 1338 ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup");
1339 return; 1339 return;
1340 } 1340 }
1341 kill(exe->pid, SIGHUP); 1341 kill(exe->pid, SIGHUP);
1342} 1342}
@@ -1371,8 +1371,8 @@ _ecore_exe_is_it_alive(pid_t pid)
1371 exe = _ecore_exe_find(pid); 1371 exe = _ecore_exe_find(pid);
1372 if (exe) 1372 if (exe)
1373 { 1373 {
1374 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) 1374 if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
1375 exe = NULL; 1375 exe = NULL;
1376 } 1376 }
1377 1377
1378 return exe; 1378 return exe;
@@ -1386,26 +1386,26 @@ _ecore_exe_make_sure_its_dead(void *data)
1386 dead = data; 1386 dead = data;
1387 if (dead) 1387 if (dead)
1388 { 1388 {
1389 Ecore_Exe *exe = NULL; 1389 Ecore_Exe *exe = NULL;
1390 1390
1391 if ((exe = _ecore_exe_is_it_alive(dead->pid))) 1391 if ((exe = _ecore_exe_is_it_alive(dead->pid)))
1392 { 1392 {
1393 if (dead->cmd) 1393 if (dead->cmd)
1394 INF("Sending KILL signal to allegedly dead %s (%d).", 1394 INF("Sending KILL signal to allegedly dead %s (%d).",
1395 dead->cmd, dead->pid); 1395 dead->cmd, dead->pid);
1396 else 1396 else
1397 INF("Sending KILL signal to allegedly dead PID %d.", 1397 INF("Sending KILL signal to allegedly dead PID %d.",
1398 dead->pid); 1398 dead->pid);
1399 exe->doomsday_clock = 1399 exe->doomsday_clock =
1400 ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, 1400 ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead,
1401 dead); 1401 dead);
1402 kill(dead->pid, SIGKILL); 1402 kill(dead->pid, SIGKILL);
1403 } 1403 }
1404 else 1404 else
1405 { 1405 {
1406 IF_FREE(dead->cmd); 1406 IF_FREE(dead->cmd);
1407 free(dead); 1407 free(dead);
1408 } 1408 }
1409 } 1409 }
1410 return ECORE_CALLBACK_CANCEL; 1410 return ECORE_CALLBACK_CANCEL;
1411} 1411}
@@ -1418,19 +1418,19 @@ _ecore_exe_make_sure_its_really_dead(void *data)
1418 dead = data; 1418 dead = data;
1419 if (dead) 1419 if (dead)
1420 { 1420 {
1421 Ecore_Exe *exe = NULL; 1421 Ecore_Exe *exe = NULL;
1422 1422
1423 if ((exe = _ecore_exe_is_it_alive(dead->pid))) 1423 if ((exe = _ecore_exe_is_it_alive(dead->pid)))
1424 { 1424 {
1425 ERR("RUN! The zombie wants to eat your brains! And your CPU!"); 1425 ERR("RUN! The zombie wants to eat your brains! And your CPU!");
1426 if (dead->cmd) 1426 if (dead->cmd)
1427 INF("%s (%d) is not really dead.", dead->cmd, dead->pid); 1427 INF("%s (%d) is not really dead.", dead->cmd, dead->pid);
1428 else 1428 else
1429 INF("PID %d is not really dead.", dead->pid); 1429 INF("PID %d is not really dead.", dead->pid);
1430 exe->doomsday_clock = NULL; 1430 exe->doomsday_clock = NULL;
1431 } 1431 }
1432 IF_FREE(dead->cmd); 1432 IF_FREE(dead->cmd);
1433 free(dead); 1433 free(dead);
1434 } 1434 }
1435 return ECORE_CALLBACK_CANCEL; 1435 return ECORE_CALLBACK_CANCEL;
1436} 1436}
@@ -1458,8 +1458,8 @@ _ecore_exe_find(pid_t pid)
1458 1458
1459 EINA_INLIST_FOREACH(exes, exe) 1459 EINA_INLIST_FOREACH(exes, exe)
1460 { 1460 {
1461 if (exe->pid == pid) 1461 if (exe->pid == pid)
1462 return exe; 1462 return exe;
1463 } 1463 }
1464 return NULL; 1464 return NULL;
1465} 1465}
@@ -1492,76 +1492,76 @@ _ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags)
1492 */ 1492 */
1493 if (!strpbrk(exe_cmd, "|&;<>()$`\\\"'*?#")) 1493 if (!strpbrk(exe_cmd, "|&;<>()$`\\\"'*?#"))
1494 { 1494 {
1495 char *token; 1495 char *token;
1496 char pre_command = 1; 1496 char pre_command = 1;
1497 int num_tokens = 0; 1497 int num_tokens = 0;
1498 1498
1499 if (!(buf = strdup(exe_cmd))) 1499 if (!(buf = strdup(exe_cmd)))
1500 return; 1500 return;
1501 1501
1502 token = strtok(buf, " \t\n\v"); 1502 token = strtok(buf, " \t\n\v");
1503 while (token) 1503 while (token)
1504 { 1504 {
1505 if (token[0] == '~') 1505 if (token[0] == '~')
1506 break; 1506 break;
1507 if (pre_command) 1507 if (pre_command)
1508 { 1508 {
1509 if (token[0] == '[') 1509 if (token[0] == '[')
1510 break; 1510 break;
1511 if (strchr(token, '=')) 1511 if (strchr(token, '='))
1512 break; 1512 break;
1513 else 1513 else
1514 pre_command = 0; 1514 pre_command = 0;
1515 } 1515 }
1516 num_tokens++; 1516 num_tokens++;
1517 token = strtok(NULL, " \t\n\v"); 1517 token = strtok(NULL, " \t\n\v");
1518 } 1518 }
1519 IF_FREE(buf); 1519 IF_FREE(buf);
1520 if ((!token) && (num_tokens)) 1520 if ((!token) && (num_tokens))
1521 { 1521 {
1522 int i = 0; 1522 int i = 0;
1523 1523
1524 if (!(buf = strdup(exe_cmd))) 1524 if (!(buf = strdup(exe_cmd)))
1525 return; 1525 return;
1526 1526
1527 token = strtok(buf, " \t\n\v"); 1527 token = strtok(buf, " \t\n\v");
1528 use_sh = 0; 1528 use_sh = 0;
1529 if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *)))) 1529 if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *))))
1530 { 1530 {
1531 IF_FREE(buf); 1531 IF_FREE(buf);
1532 return; 1532 return;
1533 } 1533 }
1534 for (i = 0; i < num_tokens; i++) 1534 for (i = 0; i < num_tokens; i++)
1535 { 1535 {
1536 if (token) 1536 if (token)
1537 args[i] = token; 1537 args[i] = token;
1538 token = strtok(NULL, " \t\n\v"); 1538 token = strtok(NULL, " \t\n\v");
1539 } 1539 }
1540 args[num_tokens] = NULL; 1540 args[num_tokens] = NULL;
1541 } 1541 }
1542 } 1542 }
1543 1543
1544 if (!(flags & ECORE_EXE_NOT_LEADER)) setsid(); 1544 if (!(flags & ECORE_EXE_NOT_LEADER)) setsid();
1545 if ((flags & ECORE_EXE_USE_SH)) 1545 if ((flags & ECORE_EXE_USE_SH))
1546 { 1546 {
1547 errno = 0; 1547 errno = 0;
1548 execl("/bin/sh", "/bin/sh", "-c", exe_cmd, (char *)NULL); 1548 execl("/bin/sh", "/bin/sh", "-c", exe_cmd, (char *)NULL);
1549 } 1549 }
1550 else if (use_sh) 1550 else if (use_sh)
1551 { /* We have to use a shell to run this. */ 1551 { /* We have to use a shell to run this. */
1552 if (!shell) 1552 if (!shell)
1553 { /* Find users preferred shell. */ 1553 { /* Find users preferred shell. */
1554 shell = getenv("SHELL"); 1554 shell = getenv("SHELL");
1555 if (!shell) 1555 if (!shell)
1556 shell = "/bin/sh"; 1556 shell = "/bin/sh";
1557 } 1557 }
1558 errno = 0; 1558 errno = 0;
1559 execl(shell, shell, "-c", exe_cmd, (char *)NULL); 1559 execl(shell, shell, "-c", exe_cmd, (char *)NULL);
1560 } 1560 }
1561 else 1561 else
1562 { /* We can run this directly. */ 1562 { /* We can run this directly. */
1563 errno = 0; 1563 errno = 0;
1564 execvp(args[0], args); 1564 execvp(args[0], args);
1565 } 1565 }
1566 1566
1567 save_errno = errno; 1567 save_errno = errno;
@@ -1583,117 +1583,117 @@ _ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler, Ecore_
1583 /* Sort out what sort of handler we are. */ 1583 /* Sort out what sort of handler we are. */
1584 if (flags & ECORE_EXE_PIPE_READ) 1584 if (flags & ECORE_EXE_PIPE_READ)
1585 { 1585 {
1586 flags = ECORE_EXE_PIPE_READ; 1586 flags = ECORE_EXE_PIPE_READ;
1587 event_type = ECORE_EXE_EVENT_DATA; 1587 event_type = ECORE_EXE_EVENT_DATA;
1588 child_fd = exe->child_fd_read; 1588 child_fd = exe->child_fd_read;
1589 } 1589 }
1590 else 1590 else
1591 { 1591 {
1592 flags = ECORE_EXE_PIPE_ERROR; 1592 flags = ECORE_EXE_PIPE_ERROR;
1593 event_type = ECORE_EXE_EVENT_ERROR; 1593 event_type = ECORE_EXE_EVENT_ERROR;
1594 child_fd = exe->child_fd_error; 1594 child_fd = exe->child_fd_error;
1595 } 1595 }
1596 1596
1597 if ((fd_handler) 1597 if ((fd_handler)
1598 && (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))) 1598 && (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)))
1599 { 1599 {
1600 unsigned char *inbuf; 1600 unsigned char *inbuf;
1601 int inbuf_num; 1601 int inbuf_num;
1602 1602
1603 /* Get any left over data from last time. */ 1603 /* Get any left over data from last time. */
1604 if (flags & ECORE_EXE_PIPE_READ) 1604 if (flags & ECORE_EXE_PIPE_READ)
1605 { 1605 {
1606 inbuf = exe->read_data_buf; 1606 inbuf = exe->read_data_buf;
1607 inbuf_num = exe->read_data_size; 1607 inbuf_num = exe->read_data_size;
1608 exe->read_data_buf = NULL; 1608 exe->read_data_buf = NULL;
1609 exe->read_data_size = 0; 1609 exe->read_data_size = 0;
1610 } 1610 }
1611 else 1611 else
1612 { 1612 {
1613 inbuf = exe->error_data_buf; 1613 inbuf = exe->error_data_buf;
1614 inbuf_num = exe->error_data_size; 1614 inbuf_num = exe->error_data_size;
1615 exe->error_data_buf = NULL; 1615 exe->error_data_buf = NULL;
1616 exe->error_data_size = 0; 1616 exe->error_data_size = 0;
1617 } 1617 }
1618 1618
1619 for (;;) 1619 for (;;)
1620 { 1620 {
1621 int num, lost_exe; 1621 int num, lost_exe;
1622 char buf[READBUFSIZ]; 1622 char buf[READBUFSIZ];
1623 1623
1624 lost_exe = 0; 1624 lost_exe = 0;
1625 errno = 0; 1625 errno = 0;
1626 if ((num = read(child_fd, buf, READBUFSIZ)) < 1) 1626 if ((num = read(child_fd, buf, READBUFSIZ)) < 1)
1627 /* FIXME: SPEED/SIZE TRADE OFF - add a smaller READBUFSIZE 1627 /* FIXME: SPEED/SIZE TRADE OFF - add a smaller READBUFSIZE
1628 * (currently 64k) to inbuf, use that instead of buf, and 1628 * (currently 64k) to inbuf, use that instead of buf, and
1629 * save ourselves a memcpy(). */ 1629 * save ourselves a memcpy(). */
1630 { 1630 {
1631 lost_exe = ((errno == EIO) || 1631 lost_exe = ((errno == EIO) ||
1632 (errno == EBADF) || 1632 (errno == EBADF) ||
1633 (errno == EPIPE) || 1633 (errno == EPIPE) ||
1634 (errno == EINVAL) || (errno == ENOSPC)); 1634 (errno == EINVAL) || (errno == ENOSPC));
1635 if ((errno != EAGAIN) && (errno != EINTR)) 1635 if ((errno != EAGAIN) && (errno != EINTR))
1636 perror("_ecore_exe_generic_handler() read problem "); 1636 perror("_ecore_exe_generic_handler() read problem ");
1637 } 1637 }
1638 if (num > 0) 1638 if (num > 0)
1639 { /* data got read. */ 1639 { /* data got read. */
1640 inbuf = realloc(inbuf, inbuf_num + num); 1640 inbuf = realloc(inbuf, inbuf_num + num);
1641 memcpy(inbuf + inbuf_num, buf, num); 1641 memcpy(inbuf + inbuf_num, buf, num);
1642 inbuf_num += num; 1642 inbuf_num += num;
1643 } 1643 }
1644 else 1644 else
1645 { /* No more data to read. */ 1645 { /* No more data to read. */
1646 if (inbuf) 1646 if (inbuf)
1647 { 1647 {
1648 Ecore_Exe_Event_Data *e; 1648 Ecore_Exe_Event_Data *e;
1649 1649
1650 /* Stash the data away for later. */ 1650 /* Stash the data away for later. */
1651 if (flags & ECORE_EXE_PIPE_READ) 1651 if (flags & ECORE_EXE_PIPE_READ)
1652 { 1652 {
1653 exe->read_data_buf = inbuf; 1653 exe->read_data_buf = inbuf;
1654 exe->read_data_size = inbuf_num; 1654 exe->read_data_size = inbuf_num;
1655 } 1655 }
1656 else 1656 else
1657 { 1657 {
1658 exe->error_data_buf = inbuf; 1658 exe->error_data_buf = inbuf;
1659 exe->error_data_size = inbuf_num; 1659 exe->error_data_size = inbuf_num;
1660 } 1660 }
1661 1661
1662 if (!(exe->flags & ECORE_EXE_PIPE_AUTO)) 1662 if (!(exe->flags & ECORE_EXE_PIPE_AUTO))
1663 { 1663 {
1664 e = ecore_exe_event_data_get(exe, flags); 1664 e = ecore_exe_event_data_get(exe, flags);
1665 if (e) /* Send the event. */ 1665 if (e) /* Send the event. */
1666 ecore_event_add(event_type, e, 1666 ecore_event_add(event_type, e,
1667 _ecore_exe_event_exe_data_free, 1667 _ecore_exe_event_exe_data_free,
1668 NULL); 1668 NULL);
1669 } 1669 }
1670 } 1670 }
1671 if (lost_exe) 1671 if (lost_exe)
1672 { 1672 {
1673 if (flags & ECORE_EXE_PIPE_READ) 1673 if (flags & ECORE_EXE_PIPE_READ)
1674 { 1674 {
1675 if (exe->read_data_size) 1675 if (exe->read_data_size)
1676 INF("There are %d bytes left unsent from the dead exe %s.", 1676 INF("There are %d bytes left unsent from the dead exe %s.",
1677 exe->read_data_size, exe->cmd); 1677 exe->read_data_size, exe->cmd);
1678 } 1678 }
1679 else 1679 else
1680 { 1680 {
1681 if (exe->error_data_size) 1681 if (exe->error_data_size)
1682 INF("There are %d bytes left unsent from the dead exe %s.", 1682 INF("There are %d bytes left unsent from the dead exe %s.",
1683 exe->error_data_size, exe->cmd); 1683 exe->error_data_size, exe->cmd);
1684 } 1684 }
1685 /* Thought about this a bit. If the exe has actually 1685 /* Thought about this a bit. If the exe has actually
1686 * died, this won't do any harm as it must have died 1686 * died, this won't do any harm as it must have died
1687 * recently and the pid has not had a chance to recycle. 1687 * recently and the pid has not had a chance to recycle.
1688 * It is also a paranoid catchall, coz the usual ecore_signal 1688 * It is also a paranoid catchall, coz the usual ecore_signal
1689 * mechenism should kick in. But let's give it a good 1689 * mechenism should kick in. But let's give it a good
1690 * kick in the head anyway. 1690 * kick in the head anyway.
1691 */ 1691 */
1692 ecore_exe_terminate(exe); 1692 ecore_exe_terminate(exe);
1693 } 1693 }
1694 break; 1694 break;
1695 } 1695 }
1696 } 1696 }
1697 } 1697 }
1698 1698
1699 return ECORE_CALLBACK_RENEW; 1699 return ECORE_CALLBACK_RENEW;
@@ -1703,14 +1703,14 @@ static Eina_Bool
1703_ecore_exe_data_error_handler(void *data, Ecore_Fd_Handler *fd_handler) 1703_ecore_exe_data_error_handler(void *data, Ecore_Fd_Handler *fd_handler)
1704{ 1704{
1705 return _ecore_exe_data_generic_handler(data, fd_handler, 1705 return _ecore_exe_data_generic_handler(data, fd_handler,
1706 ECORE_EXE_PIPE_ERROR); 1706 ECORE_EXE_PIPE_ERROR);
1707} 1707}
1708 1708
1709static Eina_Bool 1709static Eina_Bool
1710_ecore_exe_data_read_handler(void *data, Ecore_Fd_Handler *fd_handler) 1710_ecore_exe_data_read_handler(void *data, Ecore_Fd_Handler *fd_handler)
1711{ 1711{
1712 return _ecore_exe_data_generic_handler(data, fd_handler, 1712 return _ecore_exe_data_generic_handler(data, fd_handler,
1713 ECORE_EXE_PIPE_READ); 1713 ECORE_EXE_PIPE_READ);
1714} 1714}
1715 1715
1716static Eina_Bool 1716static Eina_Bool
@@ -1721,23 +1721,23 @@ _ecore_exe_data_write_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED_
1721 exe = data; 1721 exe = data;
1722 if ((exe->write_fd_handler) && 1722 if ((exe->write_fd_handler) &&
1723 (ecore_main_fd_handler_active_get 1723 (ecore_main_fd_handler_active_get
1724 (exe->write_fd_handler, ECORE_FD_WRITE))) 1724 (exe->write_fd_handler, ECORE_FD_WRITE)))
1725 _ecore_exe_flush(exe); 1725 _ecore_exe_flush(exe);
1726 1726
1727 /* If we have sent all there is to send, and we need to close the pipe, then close it. */ 1727 /* If we have sent all there is to send, and we need to close the pipe, then close it. */
1728 if ((exe->close_stdin == 1) 1728 if ((exe->close_stdin == 1)
1729 && (exe->write_data_size == exe->write_data_offset)) 1729 && (exe->write_data_size == exe->write_data_offset))
1730 { 1730 {
1731 int ok = 0; 1731 int ok = 0;
1732 int result; 1732 int result;
1733 1733
1734 INF("Closing stdin for %s", exe->cmd); 1734 INF("Closing stdin for %s", exe->cmd);
1735 /* 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. */ 1735 /* 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. */
1736 IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler); 1736 IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler);
1737 if (exe->child_fd_write != -1) 1737 if (exe->child_fd_write != -1)
1738 E_NO_ERRNO(result, close(exe->child_fd_write), ok); 1738 E_NO_ERRNO(result, close(exe->child_fd_write), ok);
1739 exe->child_fd_write = -1; 1739 exe->child_fd_write = -1;
1740 IF_FREE(exe->write_data_buf); 1740 IF_FREE(exe->write_data_buf);
1741 } 1741 }
1742 1742
1743 return ECORE_CALLBACK_RENEW; 1743 return ECORE_CALLBACK_RENEW;
@@ -1755,28 +1755,28 @@ _ecore_exe_flush(Ecore_Exe *exe)
1755 return; 1755 return;
1756 1756
1757 count = write(exe->child_fd_write, 1757 count = write(exe->child_fd_write,
1758 (char *)exe->write_data_buf + exe->write_data_offset, 1758 (char *)exe->write_data_buf + exe->write_data_offset,
1759 exe->write_data_size - exe->write_data_offset); 1759 exe->write_data_size - exe->write_data_offset);
1760 if (count < 1) 1760 if (count < 1)
1761 { 1761 {
1762 if (errno == EIO || errno == EBADF || errno == EPIPE || errno == EINVAL || errno == ENOSPC) /* we lost our exe! */ 1762 if (errno == EIO || errno == EBADF || errno == EPIPE || errno == EINVAL || errno == ENOSPC) /* we lost our exe! */
1763 { 1763 {
1764 ecore_exe_terminate(exe); 1764 ecore_exe_terminate(exe);
1765 if (exe->write_fd_handler) 1765 if (exe->write_fd_handler)
1766 ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); 1766 ecore_main_fd_handler_active_set(exe->write_fd_handler, 0);
1767 } 1767 }
1768 } 1768 }
1769 else 1769 else
1770 { 1770 {
1771 exe->write_data_offset += count; 1771 exe->write_data_offset += count;
1772 if (exe->write_data_offset >= exe->write_data_size) 1772 if (exe->write_data_offset >= exe->write_data_size)
1773 { /* Nothing left to write, clean up. */ 1773 { /* Nothing left to write, clean up. */
1774 exe->write_data_size = 0; 1774 exe->write_data_size = 0;
1775 exe->write_data_offset = 0; 1775 exe->write_data_offset = 0;
1776 IF_FREE(exe->write_data_buf); 1776 IF_FREE(exe->write_data_buf);
1777 if (exe->write_fd_handler) 1777 if (exe->write_fd_handler)
1778 ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); 1778 ecore_main_fd_handler_active_set(exe->write_fd_handler, 0);
1779 } 1779 }
1780 } 1780 }
1781} 1781}
1782 1782
@@ -1836,11 +1836,11 @@ _ecore_exe_dead_attach(Ecore_Exe *exe)
1836 dead = calloc(1, sizeof(struct _ecore_exe_dead_exe)); 1836 dead = calloc(1, sizeof(struct _ecore_exe_dead_exe));
1837 if (dead) 1837 if (dead)
1838 { 1838 {
1839 dead->pid = exe->pid; 1839 dead->pid = exe->pid;
1840 dead->cmd = strdup(exe->cmd); 1840 dead->cmd = strdup(exe->cmd);
1841 IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); 1841 IF_FN_DEL(ecore_timer_del, exe->doomsday_clock);
1842 exe->doomsday_clock = 1842 exe->doomsday_clock =
1843 ecore_timer_add(10.0, _ecore_exe_make_sure_its_dead, dead); 1843 ecore_timer_add(10.0, _ecore_exe_make_sure_its_dead, dead);
1844 exe->doomsday_clock_dead = dead; 1844 exe->doomsday_clock_dead = dead;
1845 } 1845 }
1846} 1846}
diff --git a/legacy/ecore/src/lib/ecore/ecore_getopt.c b/legacy/ecore/src/lib/ecore/ecore_getopt.c
index f00c46e513..5b1c7bf9ea 100644
--- a/legacy/ecore/src/lib/ecore/ecore_getopt.c
+++ b/legacy/ecore/src/lib/ecore/ecore_getopt.c
@@ -51,30 +51,30 @@ _ecore_getopt_help_print_replace_program(FILE *fp, const Ecore_Getopt *parser __
51{ 51{
52 do 52 do
53 { 53 {
54 const char *d = strchr(text, '%'); 54 const char *d = strchr(text, '%');
55 55
56 if (!d) 56 if (!d)
57 { 57 {
58 fputs(text, fp); 58 fputs(text, fp);
59 break; 59 break;
60 } 60 }
61 61
62 if (fwrite(text, 1, d - text, fp) != (size_t)(d - text)) 62 if (fwrite(text, 1, d - text, fp) != (size_t)(d - text))
63 return; 63 return;
64 d++; 64 d++;
65 if (strncmp(d, "prog", sizeof("prog") - 1) == 0) 65 if (strncmp(d, "prog", sizeof("prog") - 1) == 0)
66 { 66 {
67 fputs(prog ? prog : "???", fp); 67 fputs(prog ? prog : "???", fp);
68 d += sizeof("prog") - 1; 68 d += sizeof("prog") - 1;
69 } 69 }
70 else 70 else
71 { 71 {
72 if (d[0] == '%') 72 if (d[0] == '%')
73 d++; 73 d++;
74 fputc('%', fp); 74 fputc('%', fp);
75 } 75 }
76 76
77 text = d; 77 text = d;
78 } 78 }
79 while (text[0] != '\0'); 79 while (text[0] != '\0');
80 80
@@ -97,8 +97,8 @@ _ecore_getopt_help_usage(FILE *fp, const Ecore_Getopt *parser)
97 97
98 if (!parser->usage) 98 if (!parser->usage)
99 { 99 {
100 fprintf(fp, _("%s [options]\n"), prog); 100 fprintf(fp, _("%s [options]\n"), prog);
101 return; 101 return;
102 } 102 }
103 103
104 _ecore_getopt_help_print_replace_program(fp, parser, gettext(parser->usage)); 104 _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
110 int linebreak = 0; 110 int linebreak = 0;
111 do 111 do
112 { 112 {
113 /* process line considering spaces (new line and tabs are spaces!) */ 113 /* process line considering spaces (new line and tabs are spaces!) */
114 while ((used < total) && (len > 0)) 114 while ((used < total) && (len > 0))
115 { 115 {
116 const char *space = NULL; 116 const char *space = NULL;
117 int i, todo; 117 int i, todo;
118 118
119 todo = total - used; 119 todo = total - used;
120 if (todo > len) 120 if (todo > len)
121 todo = len; 121 todo = len;
122 122
123 for (i = 0; i < todo; i++) 123 for (i = 0; i < todo; i++)
124 if (isspace(text[i])) 124 if (isspace(text[i]))
125 { 125 {
126 space = text + i; 126 space = text + i;
127 break; 127 break;
128 } 128 }
129 129
130 if (space) 130 if (space)
131 { 131 {
132 i = fwrite(text, 1, i, fp); 132 i = fwrite(text, 1, i, fp);
133 i++; 133 i++;
134 text += i; 134 text += i;
135 len -= i; 135 len -= i;
136 used += i; 136 used += i;
137 137
138 if (linebreak) 138 if (linebreak)
139 { 139 {
140 linebreak = 0; 140 linebreak = 0;
141 continue; 141 continue;
142 } 142 }
143 143
144 if (space[0] == '\n') 144 if (space[0] == '\n')
145 break; 145 break;
146 else if (space[0] == '\t') 146 else if (space[0] == '\t')
147 { 147 {
148 int c; 148 int c;
149 149
150 used--; 150 used--;
151 c = ((used / 8) + 1) * 8; 151 c = ((used / 8) + 1) * 8;
152 if (c < total) 152 if (c < total)
153 { 153 {
154 for (; used < c; used++) 154 for (; used < c; used++)
155 fputc(' ', fp); 155 fputc(' ', fp);
156 } 156 }
157 else 157 else
158 { 158 {
159 text--; 159 text--;
160 len++; 160 len++;
161 break; 161 break;
162 } 162 }
163 } 163 }
164 else if (used < total) 164 else if (used < total)
165 fputc(space[0], fp); 165 fputc(space[0], fp);
166 } 166 }
167 else 167 else
168 { 168 {
169 i = fwrite(text, 1, i, fp); 169 i = fwrite(text, 1, i, fp);
170 text += i; 170 text += i;
171 len -= i; 171 len -= i;
172 used += i; 172 used += i;
173 } 173 }
174 linebreak = 0; 174 linebreak = 0;
175 } 175 }
176 if (len <= 0) 176 if (len <= 0)
177 break; 177 break;
178 linebreak = 1; 178 linebreak = 1;
179 fputc('\n', fp); 179 fputc('\n', fp);
180 for (used = 0; used < base; used++) 180 for (used = 0; used < base; used++)
181 fputc(' ', fp); 181 fputc(' ', fp);
182 } 182 }
183 while (1); 183 while (1);
184 184
@@ -207,34 +207,34 @@ _ecore_getopt_help_description(FILE *fp, const Ecore_Getopt *parser)
207 207
208 do 208 do
209 { 209 {
210 const char *d = strchr(p, '%'); 210 const char *d = strchr(p, '%');
211 211
212 if (!d) 212 if (!d)
213 { 213 {
214 _ecore_getopt_help_line(fp, 0, cols, used, p, strlen(p)); 214 _ecore_getopt_help_line(fp, 0, cols, used, p, strlen(p));
215 break; 215 break;
216 } 216 }
217 217
218 used = _ecore_getopt_help_line(fp, 0, cols, used, p, d - p); 218 used = _ecore_getopt_help_line(fp, 0, cols, used, p, d - p);
219 d++; 219 d++;
220 if (strncmp(d, "prog", sizeof("prog") - 1) == 0) 220 if (strncmp(d, "prog", sizeof("prog") - 1) == 0)
221 { 221 {
222 used = _ecore_getopt_help_line(fp, 0, cols, used, prg, prglen); 222 used = _ecore_getopt_help_line(fp, 0, cols, used, prg, prglen);
223 d += sizeof("prog") - 1; 223 d += sizeof("prog") - 1;
224 } 224 }
225 else if (strncmp(d, "version", sizeof("version") - 1) == 0) 225 else if (strncmp(d, "version", sizeof("version") - 1) == 0)
226 { 226 {
227 used = _ecore_getopt_help_line(fp, 0, cols, used, ver, verlen); 227 used = _ecore_getopt_help_line(fp, 0, cols, used, ver, verlen);
228 d += sizeof("version") - 1; 228 d += sizeof("version") - 1;
229 } 229 }
230 else 230 else
231 { 231 {
232 if (d[0] == '%') 232 if (d[0] == '%')
233 d++; 233 d++;
234 used = _ecore_getopt_help_line(fp, 0, cols, used, "%", 1); 234 used = _ecore_getopt_help_line(fp, 0, cols, used, "%", 1);
235 } 235 }
236 236
237 p = d; 237 p = d;
238 } 238 }
239 while (p[0] != '\0'); 239 while (p[0] != '\0');
240 240
@@ -269,27 +269,27 @@ _ecore_getopt_desc_arg_requirement(const Ecore_Getopt_Desc *desc)
269 switch (desc->action) 269 switch (desc->action)
270 { 270 {
271 case ECORE_GETOPT_ACTION_STORE: 271 case ECORE_GETOPT_ACTION_STORE:
272 return desc->action_param.store.arg_req; 272 return desc->action_param.store.arg_req;
273 case ECORE_GETOPT_ACTION_STORE_CONST: 273 case ECORE_GETOPT_ACTION_STORE_CONST:
274 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; 274 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
275 case ECORE_GETOPT_ACTION_STORE_TRUE: 275 case ECORE_GETOPT_ACTION_STORE_TRUE:
276 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; 276 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
277 case ECORE_GETOPT_ACTION_STORE_FALSE: 277 case ECORE_GETOPT_ACTION_STORE_FALSE:
278 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; 278 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
279 case ECORE_GETOPT_ACTION_CHOICE: 279 case ECORE_GETOPT_ACTION_CHOICE:
280 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; 280 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES;
281 case ECORE_GETOPT_ACTION_APPEND: 281 case ECORE_GETOPT_ACTION_APPEND:
282 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; 282 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES;
283 case ECORE_GETOPT_ACTION_COUNT: 283 case ECORE_GETOPT_ACTION_COUNT:
284 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; 284 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
285 case ECORE_GETOPT_ACTION_CALLBACK: 285 case ECORE_GETOPT_ACTION_CALLBACK:
286 return desc->action_param.callback.arg_req; 286 return desc->action_param.callback.arg_req;
287 case ECORE_GETOPT_ACTION_HELP: 287 case ECORE_GETOPT_ACTION_HELP:
288 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; 288 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
289 case ECORE_GETOPT_ACTION_VERSION: 289 case ECORE_GETOPT_ACTION_VERSION:
290 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; 290 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
291 default: 291 default:
292 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; 292 return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
293 } 293 }
294} 294}
295 295
@@ -298,25 +298,25 @@ _ecore_getopt_help_desc_setup_metavar(const Ecore_Getopt_Desc *desc, char *metav
298{ 298{
299 if (desc->metavar) 299 if (desc->metavar)
300 { 300 {
301 const char *txt = gettext(desc->metavar); 301 const char *txt = gettext(desc->metavar);
302 *metavarlen = strlen(txt); 302 *metavarlen = strlen(txt);
303 if (*metavarlen > maxsize - 1) 303 if (*metavarlen > maxsize - 1)
304 *metavarlen = maxsize - 1; 304 *metavarlen = maxsize - 1;
305 305
306 memcpy(metavar, txt, *metavarlen); 306 memcpy(metavar, txt, *metavarlen);
307 metavar[*metavarlen] = '\0'; 307 metavar[*metavarlen] = '\0';
308 } 308 }
309 else if (desc->longname) 309 else if (desc->longname)
310 { 310 {
311 int i; 311 int i;
312 312
313 *metavarlen = strlen(desc->longname); 313 *metavarlen = strlen(desc->longname);
314 if (*metavarlen > maxsize - 1) 314 if (*metavarlen > maxsize - 1)
315 *metavarlen = maxsize - 1; 315 *metavarlen = maxsize - 1;
316 316
317 for (i = 0; i < *metavarlen; i++) 317 for (i = 0; i < *metavarlen; i++)
318 metavar[i] = toupper(desc->longname[i]); 318 metavar[i] = toupper(desc->longname[i]);
319 metavar[i] = '\0'; 319 metavar[i] = '\0';
320 } 320 }
321} 321}
322 322
@@ -332,21 +332,21 @@ _ecore_getopt_help_desc_show_arg(FILE *fp, Ecore_Getopt_Desc_Arg_Requirement req
332 332
333 if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL) 333 if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL)
334 { 334 {
335 fputc('[', fp); 335 fputc('[', fp);
336 used++; 336 used++;
337 } 337 }
338 338
339 if (requirement != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) 339 if (requirement != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
340 { 340 {
341 fputc('=', fp); 341 fputc('=', fp);
342 fputs(metavar, fp); 342 fputs(metavar, fp);
343 used += metavarlen + 1; 343 used += metavarlen + 1;
344 } 344 }
345 345
346 if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL) 346 if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL)
347 { 347 {
348 fputc(']', fp); 348 fputc(']', fp);
349 used++; 349 used++;
350 } 350 }
351 351
352 return used; 352 return used;
@@ -367,44 +367,44 @@ _ecore_getopt_help_desc_store(FILE *fp, const int base, const int total, int use
367 switch (store->type) 367 switch (store->type)
368 { 368 {
369 case ECORE_GETOPT_TYPE_STR: 369 case ECORE_GETOPT_TYPE_STR:
370 str = "STR"; 370 str = "STR";
371 len = sizeof("STR") - 1; 371 len = sizeof("STR") - 1;
372 break; 372 break;
373 case ECORE_GETOPT_TYPE_BOOL: 373 case ECORE_GETOPT_TYPE_BOOL:
374 str = "BOOL"; 374 str = "BOOL";
375 len = sizeof("BOOL") - 1; 375 len = sizeof("BOOL") - 1;
376 break; 376 break;
377 case ECORE_GETOPT_TYPE_SHORT: 377 case ECORE_GETOPT_TYPE_SHORT:
378 str = "SHORT"; 378 str = "SHORT";
379 len = sizeof("SHORT") - 1; 379 len = sizeof("SHORT") - 1;
380 break; 380 break;
381 case ECORE_GETOPT_TYPE_INT: 381 case ECORE_GETOPT_TYPE_INT:
382 str = "INT"; 382 str = "INT";
383 len = sizeof("INT") - 1; 383 len = sizeof("INT") - 1;
384 break; 384 break;
385 case ECORE_GETOPT_TYPE_LONG: 385 case ECORE_GETOPT_TYPE_LONG:
386 str = "LONG"; 386 str = "LONG";
387 len = sizeof("LONG") - 1; 387 len = sizeof("LONG") - 1;
388 break; 388 break;
389 case ECORE_GETOPT_TYPE_USHORT: 389 case ECORE_GETOPT_TYPE_USHORT:
390 str = "USHORT"; 390 str = "USHORT";
391 len = sizeof("USHORT") - 1; 391 len = sizeof("USHORT") - 1;
392 break; 392 break;
393 case ECORE_GETOPT_TYPE_UINT: 393 case ECORE_GETOPT_TYPE_UINT:
394 str = "UINT"; 394 str = "UINT";
395 len = sizeof("UINT") - 1; 395 len = sizeof("UINT") - 1;
396 break; 396 break;
397 case ECORE_GETOPT_TYPE_ULONG: 397 case ECORE_GETOPT_TYPE_ULONG:
398 str = "ULONG"; 398 str = "ULONG";
399 len = sizeof("ULONG") - 1; 399 len = sizeof("ULONG") - 1;
400 break; 400 break;
401 case ECORE_GETOPT_TYPE_DOUBLE: 401 case ECORE_GETOPT_TYPE_DOUBLE:
402 str = "DOUBLE"; 402 str = "DOUBLE";
403 len = sizeof("DOUBLE") - 1; 403 len = sizeof("DOUBLE") - 1;
404 break; 404 break;
405 default: 405 default:
406 str = "???"; 406 str = "???";
407 len = sizeof("???") - 1; 407 len = sizeof("???") - 1;
408 } 408 }
409 409
410 used = _ecore_getopt_help_line 410 used = _ecore_getopt_help_line
@@ -420,58 +420,58 @@ _ecore_getopt_help_desc_store(FILE *fp, const int base, const int total, int use
420 switch (store->type) 420 switch (store->type)
421 { 421 {
422 case ECORE_GETOPT_TYPE_STR: 422 case ECORE_GETOPT_TYPE_STR:
423 str = store->def.strv; 423 str = store->def.strv;
424 len = str ? strlen(str) : 0; 424 len = str ? strlen(str) : 0;
425 break; 425 break;
426 case ECORE_GETOPT_TYPE_BOOL: 426 case ECORE_GETOPT_TYPE_BOOL:
427 str = store->def.boolv ? "true" : "false"; 427 str = store->def.boolv ? "true" : "false";
428 len = strlen(str); 428 len = strlen(str);
429 break; 429 break;
430 case ECORE_GETOPT_TYPE_SHORT: 430 case ECORE_GETOPT_TYPE_SHORT:
431 str = buf; 431 str = buf;
432 len = snprintf(buf, sizeof(buf), "%hd", store->def.shortv); 432 len = snprintf(buf, sizeof(buf), "%hd", store->def.shortv);
433 if (len > sizeof(buf) - 1) 433 if (len > sizeof(buf) - 1)
434 len = sizeof(buf) - 1; 434 len = sizeof(buf) - 1;
435 break; 435 break;
436 case ECORE_GETOPT_TYPE_INT: 436 case ECORE_GETOPT_TYPE_INT:
437 str = buf; 437 str = buf;
438 len = snprintf(buf, sizeof(buf), "%d", store->def.intv); 438 len = snprintf(buf, sizeof(buf), "%d", store->def.intv);
439 if (len > sizeof(buf) - 1) 439 if (len > sizeof(buf) - 1)
440 len = sizeof(buf) - 1; 440 len = sizeof(buf) - 1;
441 break; 441 break;
442 case ECORE_GETOPT_TYPE_LONG: 442 case ECORE_GETOPT_TYPE_LONG:
443 str = buf; 443 str = buf;
444 len = snprintf(buf, sizeof(buf), "%ld", store->def.longv); 444 len = snprintf(buf, sizeof(buf), "%ld", store->def.longv);
445 if (len > sizeof(buf) - 1) 445 if (len > sizeof(buf) - 1)
446 len = sizeof(buf) - 1; 446 len = sizeof(buf) - 1;
447 break; 447 break;
448 case ECORE_GETOPT_TYPE_USHORT: 448 case ECORE_GETOPT_TYPE_USHORT:
449 str = buf; 449 str = buf;
450 len = snprintf(buf, sizeof(buf), "%hu", store->def.ushortv); 450 len = snprintf(buf, sizeof(buf), "%hu", store->def.ushortv);
451 if (len > sizeof(buf) - 1) 451 if (len > sizeof(buf) - 1)
452 len = sizeof(buf) - 1; 452 len = sizeof(buf) - 1;
453 break; 453 break;
454 case ECORE_GETOPT_TYPE_UINT: 454 case ECORE_GETOPT_TYPE_UINT:
455 str = buf; 455 str = buf;
456 len = snprintf(buf, sizeof(buf), "%u", store->def.uintv); 456 len = snprintf(buf, sizeof(buf), "%u", store->def.uintv);
457 if (len > sizeof(buf) - 1) 457 if (len > sizeof(buf) - 1)
458 len = sizeof(buf) - 1; 458 len = sizeof(buf) - 1;
459 break; 459 break;
460 case ECORE_GETOPT_TYPE_ULONG: 460 case ECORE_GETOPT_TYPE_ULONG:
461 str = buf; 461 str = buf;
462 len = snprintf(buf, sizeof(buf), "%lu", store->def.ulongv); 462 len = snprintf(buf, sizeof(buf), "%lu", store->def.ulongv);
463 if (len > sizeof(buf) - 1) 463 if (len > sizeof(buf) - 1)
464 len = sizeof(buf) - 1; 464 len = sizeof(buf) - 1;
465 break; 465 break;
466 case ECORE_GETOPT_TYPE_DOUBLE: 466 case ECORE_GETOPT_TYPE_DOUBLE:
467 str = buf; 467 str = buf;
468 len = snprintf(buf, sizeof(buf), "%f", store->def.doublev); 468 len = snprintf(buf, sizeof(buf), "%f", store->def.doublev);
469 if (len > sizeof(buf) - 1) 469 if (len > sizeof(buf) - 1)
470 len = sizeof(buf) - 1; 470 len = sizeof(buf) - 1;
471 break; 471 break;
472 default: 472 default:
473 str = "???"; 473 str = "???";
474 len = sizeof("???") - 1; 474 len = sizeof("???") - 1;
475 } 475 }
476 476
477 used = _ecore_getopt_help_line 477 used = _ecore_getopt_help_line
@@ -491,8 +491,8 @@ _ecore_getopt_help_desc_choices(FILE *fp, const int base, const int total, int u
491 491
492 if (used > 0) 492 if (used > 0)
493 { 493 {
494 fputc('\n', fp); 494 fputc('\n', fp);
495 used = 0; 495 used = 0;
496 } 496 }
497 for (; used < base; used++) 497 for (; used < base; used++)
498 fputc(' ', fp); 498 fputc(' ', fp);
@@ -502,10 +502,10 @@ _ecore_getopt_help_desc_choices(FILE *fp, const int base, const int total, int u
502 502
503 for (itr = desc->action_param.choices; *itr; itr++) 503 for (itr = desc->action_param.choices; *itr; itr++)
504 { 504 {
505 used = _ecore_getopt_help_line 505 used = _ecore_getopt_help_line
506 (fp, base, total, used, *itr, strlen(*itr)); 506 (fp, base, total, used, *itr, strlen(*itr));
507 if (itr[1]) 507 if (itr[1])
508 used = _ecore_getopt_help_line(fp, base, total, used, sep, seplen); 508 used = _ecore_getopt_help_line(fp, base, total, used, sep, seplen);
509 } 509 }
510 510
511 return _ecore_getopt_help_line(fp, base, total, used, ".", 1); 511 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)
529 529
530 if (desc->shortname) 530 if (desc->shortname)
531 { 531 {
532 fputc('-', fp); 532 fputc('-', fp);
533 fputc(desc->shortname, fp); 533 fputc(desc->shortname, fp);
534 used += 2; 534 used += 2;
535 used += _ecore_getopt_help_desc_show_arg 535 used += _ecore_getopt_help_desc_show_arg
536 (fp, arg_req, metavar, metavarlen); 536 (fp, arg_req, metavar, metavarlen);
537 } 537 }
538 538
539 if (desc->shortname && desc->longname) 539 if (desc->shortname && desc->longname)
540 { 540 {
541 fputs(", ", fp); 541 fputs(", ", fp);
542 used += 2; 542 used += 2;
543 } 543 }
544 544
545 if (desc->longname) 545 if (desc->longname)
546 { 546 {
547 int namelen = strlen(desc->longname); 547 int namelen = strlen(desc->longname);
548 548
549 fputs("--", fp); 549 fputs("--", fp);
550 fputs(desc->longname, fp); 550 fputs(desc->longname, fp);
551 used += 2 + namelen; 551 used += 2 + namelen;
552 used += _ecore_getopt_help_desc_show_arg 552 used += _ecore_getopt_help_desc_show_arg
553 (fp, arg_req, metavar, metavarlen); 553 (fp, arg_req, metavar, metavarlen);
554 } 554 }
555 555
556 if (!desc->help) 556 if (!desc->help)
@@ -558,8 +558,8 @@ _ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc)
558 558
559 if (used + 3 >= helpcol) 559 if (used + 3 >= helpcol)
560 { 560 {
561 fputc('\n', fp); 561 fputc('\n', fp);
562 used = 0; 562 used = 0;
563 } 563 }
564 564
565 for (; used < helpcol; used++) 565 for (; used < helpcol; used++)
@@ -571,13 +571,13 @@ _ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc)
571 switch (desc->action) 571 switch (desc->action)
572 { 572 {
573 case ECORE_GETOPT_ACTION_STORE: 573 case ECORE_GETOPT_ACTION_STORE:
574 _ecore_getopt_help_desc_store(fp, helpcol, cols, used, desc); 574 _ecore_getopt_help_desc_store(fp, helpcol, cols, used, desc);
575 break; 575 break;
576 case ECORE_GETOPT_ACTION_CHOICE: 576 case ECORE_GETOPT_ACTION_CHOICE:
577 _ecore_getopt_help_desc_choices(fp, helpcol, cols, used, desc); 577 _ecore_getopt_help_desc_choices(fp, helpcol, cols, used, desc);
578 break; 578 break;
579 default: 579 default:
580 break; 580 break;
581 } 581 }
582 582
583 end: 583 end:
@@ -617,21 +617,21 @@ ecore_getopt_help(FILE *fp, const Ecore_Getopt *parser)
617 617
618 if (argc < 1) 618 if (argc < 1)
619 { 619 {
620 ecore_app_args_get(&argc, &argv); 620 ecore_app_args_get(&argc, &argv);
621 if ((argc > 0) && (argv[0])) 621 if ((argc > 0) && (argv[0]))
622 prog = argv[0]; 622 prog = argv[0];
623 else 623 else
624 prog = parser->prog; 624 prog = parser->prog;
625 } 625 }
626 626
627 var = getenv("COLUMNS"); 627 var = getenv("COLUMNS");
628 if (var) 628 if (var)
629 { 629 {
630 cols = atoi(var); 630 cols = atoi(var);
631 if (cols < 20) 631 if (cols < 20)
632 cols = 20; 632 cols = 20;
633 633
634 helpcol = cols / 3; 634 helpcol = cols / 3;
635 } 635 }
636 636
637 _ecore_getopt_help_usage(fp, parser); 637 _ecore_getopt_help_usage(fp, parser);
@@ -651,20 +651,20 @@ _ecore_getopt_parse_find_long(const Ecore_Getopt *parser, const char *name)
651 651
652 for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) 652 for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
653 { 653 {
654 if (!desc->longname) 654 if (!desc->longname)
655 continue; 655 continue;
656 656
657 if (p) 657 if (p)
658 { 658 {
659 if ((strncmp(name, desc->longname, len) == 0) && 659 if ((strncmp(name, desc->longname, len) == 0) &&
660 (desc->longname[len] == '\0')) 660 (desc->longname[len] == '\0'))
661 return desc; 661 return desc;
662 } 662 }
663 else 663 else
664 { 664 {
665 if (strcmp(name, desc->longname) == 0) 665 if (strcmp(name, desc->longname) == 0)
666 return desc; 666 return desc;
667 } 667 }
668 } 668 }
669 669
670 return NULL; 670 return NULL;
@@ -693,75 +693,75 @@ _ecore_getopt_parse_find_nonargs_base(const Ecore_Getopt *parser, int argc, char
693 base = 0; 693 base = 0;
694 while (src < argc) 694 while (src < argc)
695 { 695 {
696 const Ecore_Getopt_Desc *desc; 696 const Ecore_Getopt_Desc *desc;
697 Ecore_Getopt_Desc_Arg_Requirement arg_req; 697 Ecore_Getopt_Desc_Arg_Requirement arg_req;
698 char *arg = argv[src]; 698 char *arg = argv[src];
699 699
700 if (arg[0] != '-') 700 if (arg[0] != '-')
701 goto found_nonarg; 701 goto found_nonarg;
702 702
703 if (arg[1] == '-') 703 if (arg[1] == '-')
704 { 704 {
705 if (arg[2] == '\0') /* explicit end of options, "--" */ 705 if (arg[2] == '\0') /* explicit end of options, "--" */
706 { 706 {
707 base = 1; 707 base = 1;
708 break; 708 break;
709 } 709 }
710 desc = _ecore_getopt_parse_find_long(parser, arg + 2); 710 desc = _ecore_getopt_parse_find_long(parser, arg + 2);
711 } 711 }
712 else 712 else
713 desc = _ecore_getopt_parse_find_short(parser, arg[1]); 713 desc = _ecore_getopt_parse_find_short(parser, arg[1]);
714 714
715 if (!desc) 715 if (!desc)
716 { 716 {
717 if (arg[1] == '-') 717 if (arg[1] == '-')
718 fprintf(stderr, _("ERROR: unknown option --%s.\n"), arg + 2); 718 fprintf(stderr, _("ERROR: unknown option --%s.\n"), arg + 2);
719 else 719 else
720 fprintf(stderr, _("ERROR: unknown option -%c.\n"), arg[1]); 720 fprintf(stderr, _("ERROR: unknown option -%c.\n"), arg[1]);
721 if (parser->strict) 721 if (parser->strict)
722 { 722 {
723 memmove(argv + dst, nonargs, used * sizeof(char *)); 723 memmove(argv + dst, nonargs, used * sizeof(char *));
724 return -1; 724 return -1;
725 } 725 }
726 else 726 else
727 goto found_nonarg; 727 goto found_nonarg;
728 } 728 }
729 729
730 if (src != dst) 730 if (src != dst)
731 argv[dst] = argv[src]; 731 argv[dst] = argv[src];
732 src++; 732 src++;
733 dst++; 733 dst++;
734 734
735 arg_req = _ecore_getopt_desc_arg_requirement(desc); 735 arg_req = _ecore_getopt_desc_arg_requirement(desc);
736 if (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) 736 if (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
737 continue; 737 continue;
738 738
739 if (strchr(arg, '=')) 739 if (strchr(arg, '='))
740 continue; 740 continue;
741 741
742 if ((src >= argc) || (argv[src][0] == '-')) 742 if ((src >= argc) || (argv[src][0] == '-'))
743 continue; 743 continue;
744 744
745 if (src != dst) 745 if (src != dst)
746 argv[dst] = argv[src]; 746 argv[dst] = argv[src];
747 src++; 747 src++;
748 dst++; 748 dst++;
749 continue; 749 continue;
750 750
751 found_nonarg: 751 found_nonarg:
752 nonargs[used] = arg; 752 nonargs[used] = arg;
753 used++; 753 used++;
754 src++; 754 src++;
755 } 755 }
756 756
757 if (!base) /* '--' not found */ 757 if (!base) /* '--' not found */
758 base = dst; 758 base = dst;
759 else 759 else
760 { 760 {
761 base = dst; 761 base = dst;
762 if (src != dst) 762 if (src != dst)
763 argv[dst] = argv[src]; 763 argv[dst] = argv[src];
764 dst++; 764 dst++;
765 } 765 }
766 766
767 memmove(argv + dst, nonargs, used * sizeof(char *)); 767 memmove(argv + dst, nonargs, used * sizeof(char *));
@@ -777,8 +777,8 @@ _ecore_getopt_desc_print_error(const Ecore_Getopt_Desc *desc, const char *fmt, .
777 777
778 if (desc->shortname) 778 if (desc->shortname)