Fix nasty formatting.

SVN revision: 44988
This commit is contained in:
Christopher Michael 2010-01-08 19:49:05 +00:00
parent fb539519ca
commit ecb57ac1b8
2 changed files with 127 additions and 152 deletions

View File

@ -16,51 +16,49 @@ struct _Ecore_Event_Handler
{ {
EINA_INLIST; EINA_INLIST;
ECORE_MAGIC; ECORE_MAGIC;
int type; int type;
int delete_me : 1; int delete_me : 1;
int (*func) (void *data, int type, void *event); int (*func) (void *data, int type, void *event);
void *data; void *data;
}; };
struct _Ecore_Event_Filter struct _Ecore_Event_Filter
{ {
EINA_INLIST; EINA_INLIST;
ECORE_MAGIC; ECORE_MAGIC;
int delete_me : 1; int delete_me : 1;
void * (*func_start) (void *data); void *(*func_start) (void *data);
int (*func_filter) (void *data, void *loop_data, int type, void *event); int (*func_filter) (void *data, void *loop_data, int type, void *event);
void (*func_end) (void *data, void *loop_data); void (*func_end) (void *data, void *loop_data);
void *loop_data; void *loop_data;
void *data; void *data;
}; };
struct _Ecore_Event struct _Ecore_Event
{ {
EINA_INLIST; EINA_INLIST;
ECORE_MAGIC; ECORE_MAGIC;
int type; int type;
void *event; void *event;
int delete_me : 1; int delete_me : 1;
void (*func_free) (void *data, void *ev); void (*func_free) (void *data, void *ev);
void *data; void *data;
}; };
static int events_num = 0; static int events_num = 0;
static Ecore_Event *events = NULL; static Ecore_Event *events = NULL;
static Ecore_Event_Handler **event_handlers = NULL; static Ecore_Event_Handler **event_handlers = NULL;
static int event_handlers_num = 0; static int event_handlers_num = 0;
static int event_handlers_alloc_num = 0; static int event_handlers_alloc_num = 0;
static Eina_List *event_handlers_delete_list = NULL; static Eina_List *event_handlers_delete_list = NULL;
static Ecore_Event_Filter *event_filters = NULL; static Ecore_Event_Filter *event_filters = NULL;
static int event_filters_delete_me = 0; static int event_filters_delete_me = 0;
static int event_id_max = ECORE_EVENT_COUNT;
static int event_id_max = ECORE_EVENT_COUNT; static int ecore_raw_event_type = ECORE_EVENT_NONE;
static void *ecore_raw_event_event = NULL;
static int ecore_raw_event_type = ECORE_EVENT_NONE;
static void *ecore_raw_event_event = NULL;
/** /**

View File

@ -92,35 +92,34 @@ struct _Ecore_Exe
{ {
EINA_INLIST; EINA_INLIST;
ECORE_MAGIC; ECORE_MAGIC;
pid_t pid; pid_t pid;
void *data; void *data;
char *tag; char *tag, *cmd;
char *cmd;
Ecore_Exe_Flags flags; Ecore_Exe_Flags flags;
Ecore_Fd_Handler *write_fd_handler; /* the fd_handler to handle write to child - if this was used, or NULL if not */ Ecore_Fd_Handler *write_fd_handler; /* the fd_handler to handle write to child - if this was used, or NULL if not */
Ecore_Fd_Handler *read_fd_handler; /* the fd_handler to handle read from child - if this was used, or NULL if not */ Ecore_Fd_Handler *read_fd_handler; /* the fd_handler to handle read from child - if this was used, or NULL if not */
Ecore_Fd_Handler *error_fd_handler; /* the fd_handler to handle errors from child - if this was used, or NULL if not */ Ecore_Fd_Handler *error_fd_handler; /* the fd_handler to handle errors from child - if this was used, or NULL if not */
void *write_data_buf; /* a data buffer for data to write to the child - void *write_data_buf; /* a data buffer for data to write to the child -
* realloced as needed for more data and flushed when the fd handler says writes are possible * realloced as needed for more data and flushed when the fd handler says writes are possible
*/ */
int write_data_size; /* the size in bytes of the data buffer */ int write_data_size; /* the size in bytes of the data buffer */
int write_data_offset; /* the offset in bytes in the data buffer */ int write_data_offset; /* the offset in bytes in the data buffer */
void *read_data_buf; /* data read from the child awating delivery to an event */ void *read_data_buf; /* data read from the child awating delivery to an event */
int read_data_size; /* data read from child in bytes */ int read_data_size; /* data read from child in bytes */
void *error_data_buf; /* errors read from the child awating delivery to an event */ void *error_data_buf; /* errors read from the child awating delivery to an event */
int error_data_size; /* errors read from child in bytes */ int error_data_size; /* errors read from child in bytes */
int child_fd_write; /* fd to write TO to send data to the child */ int child_fd_write; /* fd to write TO to send data to the child */
int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */ int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */
int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */ int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */
int child_fd_write_x; /* fd to write TO to send data to the child */ int child_fd_write_x; /* fd to write TO to send data to the child */
int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */ int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */
int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */ int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */
int close_stdin; int close_stdin;
int start_bytes, end_bytes, start_lines, end_lines; /* Number of bytes/lines to auto pipe at start/end of stdout/stderr. */ int start_bytes, end_bytes, start_lines, end_lines; /* Number of bytes/lines to auto pipe at start/end of stdout/stderr. */
Ecore_Timer *doomsday_clock; /* The Timer of Death. Muahahahaha. */ Ecore_Timer *doomsday_clock; /* The Timer of Death. Muahahahaha. */
void *doomsday_clock_dead; /* data for the doomsday clock */ void *doomsday_clock_dead; /* data for the doomsday clock */
void (*pre_free_cb)(void *data, const Ecore_Exe *exe); void (*pre_free_cb)(void *data, const Ecore_Exe *exe);
}; };
@ -140,33 +139,23 @@ struct _Ecore_Exe
struct _ecore_exe_dead_exe struct _ecore_exe_dead_exe
{ {
pid_t pid; pid_t pid;
char *cmd; char *cmd;
}; };
static inline void _ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags); static inline void _ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags);
static int _ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler, Ecore_Exe_Flags flags);
static int _ecore_exe_data_generic_handler(void *data, static int _ecore_exe_data_error_handler(void *data, Ecore_Fd_Handler *fd_handler);
Ecore_Fd_Handler * static int _ecore_exe_data_read_handler(void *data, Ecore_Fd_Handler *fd_handler);
fd_handler, static int _ecore_exe_data_write_handler(void *data, Ecore_Fd_Handler *fd_handler);
Ecore_Exe_Flags flags); static void _ecore_exe_flush(Ecore_Exe * exe);
static int _ecore_exe_data_error_handler(void *data, static void _ecore_exe_event_exe_data_free(void *data __UNUSED__, void *ev);
Ecore_Fd_Handler * static Ecore_Exe *_ecore_exe_is_it_alive(pid_t pid);
fd_handler); static int _ecore_exe_make_sure_its_dead(void *data);
static int _ecore_exe_data_read_handler(void *data, static int _ecore_exe_make_sure_its_really_dead(void *data);
Ecore_Fd_Handler * fd_handler);
static int _ecore_exe_data_write_handler(void *data,
Ecore_Fd_Handler *
fd_handler);
static void _ecore_exe_flush(Ecore_Exe * exe);
static void _ecore_exe_event_exe_data_free(void *data __UNUSED__,
void *ev);
static Ecore_Exe *_ecore_exe_is_it_alive(pid_t pid);
static int _ecore_exe_make_sure_its_dead(void *data);
static int _ecore_exe_make_sure_its_really_dead(void *data);
static Ecore_Exe_Event_Add *_ecore_exe_event_add_new(void); static Ecore_Exe_Event_Add *_ecore_exe_event_add_new(void);
static void _ecore_exe_event_add_free(void *data, void *ev); static void _ecore_exe_event_add_free(void *data, void *ev);
static void _ecore_exe_dead_attach(Ecore_Exe *exe); static void _ecore_exe_dead_attach(Ecore_Exe *exe);
EAPI int ECORE_EXE_EVENT_ADD = 0; EAPI int ECORE_EXE_EVENT_ADD = 0;
EAPI int ECORE_EXE_EVENT_DEL = 0; EAPI int ECORE_EXE_EVENT_DEL = 0;
@ -179,7 +168,7 @@ static const char *shell = NULL;
/* FIXME: This errno checking stuff should be put elsewhere for everybody to use. /* FIXME: This errno checking stuff should be put elsewhere for everybody to use.
* For now it lives here though, just to make testing easier. * For now it lives here though, just to make testing easier.
*/ */
static int _ecore_exe_check_errno(int result, const char *file, int line); static int _ecore_exe_check_errno(int result, const char *file, int line);
#define E_IF_NO_ERRNO(result, foo, ok) \ #define E_IF_NO_ERRNO(result, foo, ok) \
while (((ok) = _ecore_exe_check_errno( (result) = (foo), __FILE__, __LINE__)) == -1) sleep(1); \ while (((ok) = _ecore_exe_check_errno( (result) = (foo), __FILE__, __LINE__)) == -1) sleep(1); \
@ -256,63 +245,59 @@ _ecore_exe_check_errno(int result, const char *file, int line)
*/ */
switch (saved_errno) switch (saved_errno)
{ {
case EACCES: case EACCES:
case EAGAIN: case EAGAIN:
case EINTR: case EINTR:
{ /* Not now, try later. */ { /* Not now, try later. */
ERR("*** Must try again in %s @%u.", file, line); ERR("*** Must try again in %s @%u.", file, line);
result = -1; result = -1;
break; break;
} }
case EMFILE:
case EMFILE: case ENFILE:
case ENFILE: case ENOLCK:
case ENOLCK: { /* Low on resources. */
{ /* Low on resources. */ ERR("*** Low on resources in %s @%u.", file,
ERR("*** Low on resources in %s @%u.", file, line);
line); result = 0;
result = 0; break;
break; }
} case EIO:
{ /* I/O error. */
case EIO: ERR("*** I/O error in %s @%u.", file, line);
{ /* I/O error. */ result = 0;
ERR("*** I/O error in %s @%u.", file, line); break;
result = 0; }
break; case EFAULT:
} case EBADF:
case EINVAL:
case EFAULT: case EROFS:
case EBADF: case EISDIR:
case EINVAL: case EDEADLK:
case EROFS: case EPERM:
case EISDIR: case EBUSY:
case EDEADLK: { /* Programmer fucked up. */
case EPERM: ERR("*** NAUGHTY PROGRAMMER!!!\n"
case EBUSY: "*** SPANK SPANK SPANK!!!\n"
{ /* Programmer fucked up. */ "*** Now go fix your code in %s @%u. Tut tut tut!",
ERR("*** NAUGHTY PROGRAMMER!!!\n" file, line);
"*** SPANK SPANK SPANK!!!\n" result = 0;
"*** Now go fix your code in %s @%u. Tut tut tut!", break;
file, line); }
result = 0; default:
break; { /* Unsupported errno code, please add this one. */
} ERR("*** NAUGHTY PROGRAMMER!!!\n"
"*** SPANK SPANK SPANK!!!\n"
default: "*** Unsupported errno code %d, please add this one.\n"
{ /* Unsupported errno code, please add this one. */ "*** Now go fix your code in %s @%u, from %s @%u. Tut tut tut!",
ERR("*** NAUGHTY PROGRAMMER!!!\n" saved_errno, __FILE__, __LINE__, file, line);
"*** SPANK SPANK SPANK!!!\n" result = 0;
"*** Unsupported errno code %d, please add this one.\n" break;
"*** Now go fix your code in %s @%u, from %s @%u. Tut tut tut!", }
saved_errno, __FILE__, __LINE__, file, line);
result = 0;
break;
}
} }
} }
else /* Everything is fine. */ else /* Everything is fine. */
result = 1; result = 1;
errno = saved_errno; errno = saved_errno;
return result; return result;
@ -506,9 +491,7 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data)
if (run_pri != ECORE_EXE_PRIORITY_INHERIT) if (run_pri != ECORE_EXE_PRIORITY_INHERIT)
{ {
if ((run_pri >= -20) && (run_pri <= 19)) if ((run_pri >= -20) && (run_pri <= 19))
{ setpriority(PRIO_PROCESS, 0, run_pri);
setpriority(PRIO_PROCESS, 0, run_pri);
}
} }
/* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the
* second pipe if it's open. On the other hand, there was the * second pipe if it's open. On the other hand, there was the
@ -554,7 +537,7 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data)
_exit(-1); _exit(-1);
} }
else /* parent */ else /* parent */
{ {
/* Close the unused pipes. */ /* Close the unused pipes. */
E_NO_ERRNO(result, close(statusPipe[1]), ok); E_NO_ERRNO(result, close(statusPipe[1]), ok);
@ -587,8 +570,7 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data)
if (vfork_exec_errno != 0) if (vfork_exec_errno != 0)
{ {
n = vfork_exec_errno; n = vfork_exec_errno;
ERR("Could not start \"%s\"", ERR("Could not start \"%s\"", exe_cmd);
exe_cmd);
pid = 0; pid = 0;
} }
break; break;
@ -768,8 +750,7 @@ ecore_exe_send(Ecore_Exe * exe, const void *data, int size)
if (exe->child_fd_write == -1) if (exe->child_fd_write == -1)
{ {
ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! " ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! "
"Cannot send %d bytes from %p", "Cannot send %d bytes from %p", exe, size, data);
exe, size, data);
return 0; return 0;
} }
@ -814,8 +795,7 @@ ecore_exe_close_stdin(Ecore_Exe *exe)
* @ingroup Ecore_Exe_Basic_Group * @ingroup Ecore_Exe_Basic_Group
*/ */
EAPI void EAPI void
ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines)
int start_lines, int end_lines)
{ {
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{ {
@ -979,8 +959,7 @@ ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags)
} }
if (i > last) /* Partial line left over, save it for next time. */ if (i > last) /* Partial line left over, save it for next time. */
{ {
if (e) if (e) e->size = last;
e->size = last;
if (flags & ECORE_EXE_PIPE_READ) if (flags & ECORE_EXE_PIPE_READ)
{ {
exe->read_data_size = i - last; exe->read_data_size = i - last;
@ -1465,7 +1444,7 @@ void
_ecore_exe_shutdown(void) _ecore_exe_shutdown(void)
{ {
while (exes) while (exes)
ecore_exe_free(exes); ecore_exe_free(exes);
} }
Ecore_Exe * Ecore_Exe *
@ -1589,8 +1568,7 @@ _ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags)
} }
static int static int
_ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler, _ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler, Ecore_Exe_Flags flags)
Ecore_Exe_Flags flags)
{ {
Ecore_Exe *exe; Ecore_Exe *exe;
int child_fd; int child_fd;
@ -1681,9 +1659,9 @@ _ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler,
{ {
e = ecore_exe_event_data_get(exe, flags); e = ecore_exe_event_data_get(exe, flags);
if (e) /* Send the event. */ if (e) /* Send the event. */
ecore_event_add(event_type, e, ecore_event_add(event_type, e,
_ecore_exe_event_exe_data_free, _ecore_exe_event_exe_data_free,
NULL); NULL);
} }
} }
if (lost_exe) if (lost_exe)
@ -1691,14 +1669,14 @@ _ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler,
if (flags & ECORE_EXE_PIPE_READ) if (flags & ECORE_EXE_PIPE_READ)
{ {
if (exe->read_data_size) if (exe->read_data_size)
INF("There are %d bytes left unsent from the dead exe %s.", INF("There are %d bytes left unsent from the dead exe %s.",
exe->read_data_size, exe->cmd); exe->read_data_size, exe->cmd);
} }
else else
{ {
if (exe->error_data_size) if (exe->error_data_size)
INF("There are %d bytes left unsent from the dead exe %s.", INF("There are %d bytes left unsent from the dead exe %s.",
exe->error_data_size, exe->cmd); exe->error_data_size, exe->cmd);
} }
/* Thought about this a bit. If the exe has actually /* Thought about this a bit. If the exe has actually
* died, this won't do any harm as it must have died * died, this won't do any harm as it must have died
@ -1737,11 +1715,10 @@ _ecore_exe_data_write_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED_
Ecore_Exe *exe; Ecore_Exe *exe;
exe = data; exe = data;
if ((exe->write_fd_handler) if ((exe->write_fd_handler) &&
&&
(ecore_main_fd_handler_active_get (ecore_main_fd_handler_active_get
(exe->write_fd_handler, ECORE_FD_WRITE))) (exe->write_fd_handler, ECORE_FD_WRITE)))
_ecore_exe_flush(exe); _ecore_exe_flush(exe);
/* If we have sent all there is to send, and we need to close the pipe, then close it. */ /* If we have sent all there is to send, and we need to close the pipe, then close it. */
if ((exe->close_stdin == 1) if ((exe->close_stdin == 1)
@ -1842,7 +1819,7 @@ _ecore_exe_event_del_free(void *data __UNUSED__, void *ev)
e = ev; e = ev;
if (e->exe) if (e->exe)
ecore_exe_free(e->exe); ecore_exe_free(e->exe);
free(e); free(e);
} }