* move structures from ecore_private.h to the corresponding source files

* add 2 internal ecore_exe functions as ecore_signak.c uses Ecore_Exe members
   no test is done in those 2 functions
 * remove standard headers from ecore_private.h



SVN revision: 44862
This commit is contained in:
Vincent Torri 2010-01-03 21:55:50 +00:00
parent 741a725889
commit a4b0afb1e4
24 changed files with 299 additions and 278 deletions

View File

@ -260,6 +260,7 @@ extern "C" {
EAPI char *ecore_exe_tag_get(Ecore_Exe *exe);
EAPI char *ecore_exe_cmd_get(Ecore_Exe *exe);
EAPI void *ecore_exe_data_get(Ecore_Exe *exe);
EAPI Ecore_Exe_Flags ecore_exe_flags_get(Ecore_Exe *exe);
EAPI void ecore_exe_pause(Ecore_Exe *exe);
EAPI void ecore_exe_continue(Ecore_Exe *exe);
EAPI void ecore_exe_interrupt(Ecore_Exe *exe);

View File

@ -11,6 +11,17 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Animator
{
EINA_INLIST;
ECORE_MAGIC;
unsigned char delete_me : 1;
int (*func) (void *data);
void *data;
};
static int _ecore_animator(void *data);
static Ecore_Timer *timer = NULL;

View File

@ -11,6 +11,41 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Event_Handler
{
EINA_INLIST;
ECORE_MAGIC;
int type;
int delete_me : 1;
int (*func) (void *data, int type, void *event);
void *data;
};
struct _Ecore_Event_Filter
{
EINA_INLIST;
ECORE_MAGIC;
int delete_me : 1;
void * (*func_start) (void *data);
int (*func_filter) (void *data, void *loop_data, int type, void *event);
void (*func_end) (void *data, void *loop_data);
void *loop_data;
void *data;
};
struct _Ecore_Event
{
EINA_INLIST;
ECORE_MAGIC;
int type;
void *event;
int delete_me : 1;
void (*func_free) (void *data, void *ev);
void *data;
};
static int events_num = 0;
static Ecore_Event *events = NULL;

View File

@ -26,6 +26,104 @@
#include "Ecore.h"
#include "ecore_private.h"
/* FIXME: Getting respawn to work
*
* There is no way that we can do anything about the internal state info of
* an external exe. The same can be said about the state of user code. User
* code in this context means the code that is using ecore_exe to manage exe's
* for it.
*
* Document that the exe must be respawnable, in other words, there is no
* state that it cannot regenerate by just killing it and starting it again.
* This includes state that the user code knows about, as the respawn is
* transparent to that code. On the other hand, maybe a respawn event might
* be useful, or maybe resend the currently non existant add event. For
* consistancy with ecore_con, an add event is good anyway.
*
* The Ecore_exe structure is reused for respawning, so that the (opaque)
* pointer held by the user remains valid. This means that the Ecore_Exe
* init and del functions may need to be split into two parts each to avoid
* duplicating code - common code part, and the rest. This implies that
* the unchanging members mentioned next should NEVER change.
*
* These structure members don't need to change -
* __list_data - we stay on the list
* ECORE_MAGIC - this is a constant
* data - passed in originally
* cmd - passed in originally
* flags - passed in originally
*
* These structure members need to change -
* tag - state that must be regenerated, zap it
* pid - it will be different
* child_fd_write - it will be different
* child_fd_read - it will be different
* child_fd_error - it will be different
* write_fd_handler - we cannot change the fd used by a handler, this changes coz the fd changes.
* read_fd_handler - we cannot change the fd used by a handler, this changes coz the fd changes.
* error_fd_handler - we cannot change the fd used by a handler, this changes coz the fd changes.
*
* Hmm, the read, write, and error buffers could be tricky.
* They are not atomic, and could be in a semi complete state.
* They fall into the "state must be regenerated" mentioned above.
* A respawn/add event should take care of it.
*
* These structure members need to change -
* write_data_buf - state that must be regenerated, zap it
* write_data_size - state that must be regenerated, zap it
* write_data_offset - state that must be regenerated, zap it
* read_data_buf - state that must be regenerated, zap it
* read_data_size - state that must be regenerated, zap it
* error_data_buf - state that must be regenerated, zap it
* error_data_size - state that must be regenerated, zap it
* close_write - state that must be regenerated, zap it
*
* There is the problem that an exe that fell over and needs respawning
* might keep falling over, keep needing to be respawned, and tie up system
* resources with the constant respawning. An exponentially increasing
* timeout (with maximum timeout) between respawns should take care of that.
* Although this is not a "contention for a resource" problem, the exe falling
* over may be, so a random element added to the timeout may help, and won't
* hurt. The user code may need to be informed that a timeout is in progress.
*/
struct _Ecore_Exe
{
EINA_INLIST;
ECORE_MAGIC;
pid_t pid;
void *data;
char *tag;
char *cmd;
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 *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 */
void *write_data_buf; /* a data buffer for data to write to the child -
* realloced as needed for more data and flushed when the fd handler says writes are possible
*/
int write_data_size; /* the size in bytes of the data buffer */
int write_data_offset; /* the offset in bytes in the data buffer */
void *read_data_buf; /* data read from the child awating delivery to an event */
int read_data_size; /* data read from child in bytes */
void *error_data_buf; /* errors read from the child awating delivery to an event */
int error_data_size; /* errors read from child in bytes */
int child_fd_write; /* fd to write TO to send data to the child */
int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */
int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */
int child_fd_write_x; /* fd to write TO to send data to the child */
int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */
int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */
int close_stdin;
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. */
void *doomsday_clock_dead; /* data for the doomsday clock */
};
/* TODO: Something to let people build a command line and does auto escaping -
*
* ecore_exe_snprintf()
@ -1027,6 +1125,23 @@ ecore_exe_data_get(Ecore_Exe *exe)
return exe->data;
}
/**
* Retrieves the flags attached to the given process handle.
* @param exe The given process handle.
* @return The flags attached to @p exe.
* @ingroup Ecore_Exe_Basic_Group
*/
EAPI Ecore_Exe_Flags
ecore_exe_flags_get(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get");
return 0;
}
return exe->flags;
}
/**
* @defgroup Ecore_Exe_Signal_Group Spawned Process Signal Functions
*
@ -1307,6 +1422,18 @@ _ecore_exe_find(pid_t pid)
return NULL;
}
Ecore_Timer *
_ecore_exe_doomsday_clock_get(Ecore_Exe *exe)
{
return exe->doomsday_clock;
}
void
_ecore_exe_doomsday_clock_set(Ecore_Exe *exe, Ecore_Timer *dc)
{
exe->doomsday_clock = dc;
}
static inline void
_ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags)
{

View File

@ -11,6 +11,17 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Idle_Enterer
{
EINA_INLIST;
ECORE_MAGIC;
int delete_me : 1;
int (*func) (void *data);
void *data;
};
static Ecore_Idle_Enterer *idle_enterers = NULL;
static int idle_enterers_delete_me = 0;

View File

@ -11,6 +11,17 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Idle_Exiter
{
EINA_INLIST;
ECORE_MAGIC;
int delete_me : 1;
int (*func) (void *data);
void *data;
};
static Ecore_Idle_Exiter *idle_exiters = NULL;
static int idle_exiters_delete_me = 0;

View File

@ -11,6 +11,17 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Idler
{
EINA_INLIST;
ECORE_MAGIC;
int delete_me : 1;
int (*func) (void *data);
void *data;
};
static Ecore_Idler *idlers = NULL;
static int idlers_delete_me = 0;

View File

@ -36,6 +36,38 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Fd_Handler
{
EINA_INLIST;
ECORE_MAGIC;
int fd;
Ecore_Fd_Handler_Flags flags;
int read_active : 1;
int write_active : 1;
int error_active : 1;
int delete_me : 1;
int (*func) (void *data, Ecore_Fd_Handler *fd_handler);
void *data;
int (*buf_func) (void *data, Ecore_Fd_Handler *fd_handler);
void *buf_data;
void (*prep_func) (void *data, Ecore_Fd_Handler *fd_handler);
void *prep_data;
};
#ifdef _WIN32
struct _Ecore_Win32_Handler
{
EINA_INLIST;
ECORE_MAGIC;
HANDLE h;
int (*func) (void *data, Ecore_Win32_Handler *win32_handler);
void *data;
int delete_me : 1;
};
#endif
static int _ecore_main_select(double timeout);
static void _ecore_main_fd_handlers_cleanup(void);
#ifndef _WIN32

View File

@ -11,6 +11,18 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Poller
{
EINA_INLIST;
ECORE_MAGIC;
int ibit;
unsigned char delete_me : 1;
int (*func) (void *data);
void *data;
};
static Ecore_Timer *timer = NULL;
static int min_interval = -1;
static int interval_incr = 0;

View File

@ -1,28 +1,6 @@
#ifndef _ECORE_PRIVATE_H
#define _ECORE_PRIVATE_H
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN
#endif
#include <Eina.h>
#ifdef EAPI
# undef EAPI
#endif
extern int _ecore_log_dom ;
#ifdef _ECORE_DEFAULT_LOG_DOM
# undef _ECORE_DEFAULT_LOG_DOM
@ -58,34 +36,6 @@ extern int _ecore_log_dom ;
# undef CRIT
#endif
#define CRIT(...) EINA_LOG_DOM_CRIT(_ECORE_DEFAULT_LOG_DOM, __VA_ARGS__)
#ifdef _WIN32
# ifdef EFL_ECORE_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_ECORE_BUILD */
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif /* ! _WIN32 */
#ifdef __GNUC__
# if __GNUC__ >= 4
// BROKEN in gcc 4 on amd64
//# pragma GCC visibility push(hidden)
# endif
#endif
#ifndef PATH_MAX
# define PATH_MAX 4096
@ -162,228 +112,6 @@ EAPI void ecore_print_warning(const char *function, const char *sparam);
typedef unsigned int Ecore_Magic;
/* FIXME: Getting respawn to work
*
* There is no way that we can do anything about the internal state info of
* an external exe. The same can be said about the state of user code. User
* code in this context means the code that is using ecore_exe to manage exe's
* for it.
*
* Document that the exe must be respawnable, in other words, there is no
* state that it cannot regenerate by just killing it and starting it again.
* This includes state that the user code knows about, as the respawn is
* transparent to that code. On the other hand, maybe a respawn event might
* be useful, or maybe resend the currently non existant add event. For
* consistancy with ecore_con, an add event is good anyway.
*
* The Ecore_exe structure is reused for respawning, so that the (opaque)
* pointer held by the user remains valid. This means that the Ecore_Exe
* init and del functions may need to be split into two parts each to avoid
* duplicating code - common code part, and the rest. This implies that
* the unchanging members mentioned next should NEVER change.
*
* These structure members don't need to change -
* __list_data - we stay on the list
* ECORE_MAGIC - this is a constant
* data - passed in originally
* cmd - passed in originally
* flags - passed in originally
*
* These structure members need to change -
* tag - state that must be regenerated, zap it
* pid - it will be different
* child_fd_write - it will be different
* child_fd_read - it will be different
* child_fd_error - it will be different
* write_fd_handler - we cannot change the fd used by a handler, this changes coz the fd changes.
* read_fd_handler - we cannot change the fd used by a handler, this changes coz the fd changes.
* error_fd_handler - we cannot change the fd used by a handler, this changes coz the fd changes.
*
* Hmm, the read, write, and error buffers could be tricky.
* They are not atomic, and could be in a semi complete state.
* They fall into the "state must be regenerated" mentioned above.
* A respawn/add event should take care of it.
*
* These structure members need to change -
* write_data_buf - state that must be regenerated, zap it
* write_data_size - state that must be regenerated, zap it
* write_data_offset - state that must be regenerated, zap it
* read_data_buf - state that must be regenerated, zap it
* read_data_size - state that must be regenerated, zap it
* error_data_buf - state that must be regenerated, zap it
* error_data_size - state that must be regenerated, zap it
* close_write - state that must be regenerated, zap it
*
* There is the problem that an exe that fell over and needs respawning
* might keep falling over, keep needing to be respawned, and tie up system
* resources with the constant respawning. An exponentially increasing
* timeout (with maximum timeout) between respawns should take care of that.
* Although this is not a "contention for a resource" problem, the exe falling
* over may be, so a random element added to the timeout may help, and won't
* hurt. The user code may need to be informed that a timeout is in progress.
*/
#ifndef _WIN32
struct _Ecore_Exe
{
EINA_INLIST;
ECORE_MAGIC;
pid_t pid;
void *data;
char *tag;
char *cmd;
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 *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 */
void *write_data_buf; /* a data buffer for data to write to the child -
* realloced as needed for more data and flushed when the fd handler says writes are possible
*/
int write_data_size; /* the size in bytes of the data buffer */
int write_data_offset; /* the offset in bytes in the data buffer */
void *read_data_buf; /* data read from the child awating delivery to an event */
int read_data_size; /* data read from child in bytes */
void *error_data_buf; /* errors read from the child awating delivery to an event */
int error_data_size; /* errors read from child in bytes */
int child_fd_write; /* fd to write TO to send data to the child */
int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */
int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */
int child_fd_write_x; /* fd to write TO to send data to the child */
int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */
int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */
int close_stdin;
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. */
void *doomsday_clock_dead; /* data for the doomsday clock */
};
#endif
struct _Ecore_Timer
{
EINA_INLIST;
ECORE_MAGIC;
double in;
double at;
double pending;
int (*func) (void *data);
void *data;
unsigned char delete_me : 1;
unsigned char just_added : 1;
unsigned char frozen : 1;
unsigned char running : 1;
};
struct _Ecore_Idler
{
EINA_INLIST;
ECORE_MAGIC;
int delete_me : 1;
int (*func) (void *data);
void *data;
};
struct _Ecore_Idle_Enterer
{
EINA_INLIST;
ECORE_MAGIC;
int delete_me : 1;
int (*func) (void *data);
void *data;
};
struct _Ecore_Idle_Exiter
{
EINA_INLIST;
ECORE_MAGIC;
int delete_me : 1;
int (*func) (void *data);
void *data;
};
struct _Ecore_Fd_Handler
{
EINA_INLIST;
ECORE_MAGIC;
int fd;
Ecore_Fd_Handler_Flags flags;
int read_active : 1;
int write_active : 1;
int error_active : 1;
int delete_me : 1;
int (*func) (void *data, Ecore_Fd_Handler *fd_handler);
void *data;
int (*buf_func) (void *data, Ecore_Fd_Handler *fd_handler);
void *buf_data;
void (*prep_func) (void *data, Ecore_Fd_Handler *fd_handler);
void *prep_data;
};
#ifdef _WIN32
struct _Ecore_Win32_Handler
{
EINA_INLIST;
ECORE_MAGIC;
HANDLE h;
int (*func) (void *data, Ecore_Win32_Handler *win32_handler);
void *data;
int delete_me : 1;
};
#endif
struct _Ecore_Event_Handler
{
EINA_INLIST;
ECORE_MAGIC;
int type;
int delete_me : 1;
int (*func) (void *data, int type, void *event);
void *data;
};
struct _Ecore_Event_Filter
{
EINA_INLIST;
ECORE_MAGIC;
int delete_me : 1;
void * (*func_start) (void *data);
int (*func_filter) (void *data, void *loop_data, int type, void *event);
void (*func_end) (void *data, void *loop_data);
void *loop_data;
void *data;
};
struct _Ecore_Event
{
EINA_INLIST;
ECORE_MAGIC;
int type;
void *event;
int delete_me : 1;
void (*func_free) (void *data, void *ev);
void *data;
};
struct _Ecore_Animator
{
EINA_INLIST;
ECORE_MAGIC;
unsigned char delete_me : 1;
int (*func) (void *data);
void *data;
};
struct _Ecore_Poller
{
EINA_INLIST;
ECORE_MAGIC;
int ibit;
unsigned char delete_me : 1;
int (*func) (void *data);
void *data;
};
EAPI void _ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname);
void _ecore_timer_shutdown(void);
@ -410,7 +138,10 @@ Ecore_Event *_ecore_event_add(int type, void *ev, void (*func_free) (void *data
void *_ecore_event_del(Ecore_Event *event);
void _ecore_event_call(void);
EAPI void *_ecore_event_signal_user_new(void);
Ecore_Timer *_ecore_exe_doomsday_clock_get(Ecore_Exe *exe);
void _ecore_exe_doomsday_clock_set(Ecore_Exe *exe, Ecore_Timer *dc);
EAPI void *_ecore_event_signal_user_new(void);
void *_ecore_event_signal_hup_new(void);
void *_ecore_event_signal_exit_new(void);
void *_ecore_event_signal_power_new(void);

View File

@ -232,7 +232,7 @@ _ecore_signal_call(void)
if ((n < MAXSIGQ) && (sigchld_info[n].si_signo))
e->data = sigchld_info[n]; /* No need to clone this. */
if ((e->exe) && (e->exe->flags & (ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR)))
if ((e->exe) && (ecore_exe_flags_get(e->exe) & (ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR)))
{
/* We want to report the Last Words of the exe, so delay this event.
* This is twice as relevant for stderr.
@ -256,8 +256,11 @@ _ecore_signal_call(void)
* check to see for Last Words, and only delay if there are any.
* This has it's own set of problems.
*/
IF_FN_DEL(ecore_timer_del, e->exe->doomsday_clock);
e->exe->doomsday_clock = ecore_timer_add(0.1, _ecore_signal_exe_exit_delay, e);
Ecore_Timer *doomsday_clock;
doomsday_clock = _ecore_exe_doomsday_clock_get(e->exe);
IF_FN_DEL(ecore_timer_del, doomsday_clock);
_ecore_exe_doomsday_clock_set(e->exe, ecore_timer_add(0.1, _ecore_signal_exe_exit_delay, e));
}
else
{
@ -615,7 +618,7 @@ _ecore_signal_exe_exit_delay(void *data)
e = data;
if (e)
{
e->exe->doomsday_clock = NULL;
_ecore_exe_doomsday_clock_set(e->exe, NULL);
_ecore_event_add(ECORE_EXE_EVENT_DEL, e,
_ecore_exe_event_del_free, NULL);
}

View File

@ -12,6 +12,24 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Timer
{
EINA_INLIST;
ECORE_MAGIC;
double in;
double at;
double pending;
int (*func) (void *data);
void *data;
unsigned char delete_me : 1;
unsigned char just_added : 1;
unsigned char frozen : 1;
unsigned char running : 1;
};
static void _ecore_timer_set(Ecore_Timer *timer, double at, double in, int (*func) (void *data), void *data);
static int timers_added = 0;

View File

@ -33,6 +33,8 @@
#endif
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
#ifdef __OpenBSD__
# include <sys/types.h>

View File

@ -31,6 +31,8 @@ void *alloca (size_t);
#endif
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
#ifdef __OpenBSD__
# include <sys/types.h>

View File

@ -52,6 +52,7 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "Ecore.h"
#include "ecore_private.h"

View File

@ -336,7 +336,7 @@ ecore_config_as_string_get(const char *key)
val = NULL;
r = NULL;
if (!(e = ecore_config_get(key)))
ERR(0, "no such property, \"%s\"...", key);
ERR("no such property, \"%s\"...", key);
else
{
switch (e->type)

View File

@ -7,6 +7,8 @@
#endif
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "Ecore.h"
#include "ecore_private.h"

View File

@ -8,6 +8,8 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "ecore_file_private.h"

View File

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "Ecore.h"
#include "ecore_private.h"

View File

@ -23,6 +23,8 @@ extern "C"
void *alloca (size_t);
#endif
#include <string.h>
#include "Ecore.h"
#include "ecore_x_private.h"
#include "Ecore_X.h"

View File

@ -7,6 +7,7 @@
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <langinfo.h>

View File

@ -6,6 +6,8 @@
# include <config.h>
#endif
#include <string.h>
#include "Ecore.h"
#include "ecore_x_private.h"
#include "Ecore_X.h"

View File

@ -10,6 +10,7 @@
# include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include "Ecore.h"

View File

@ -7,6 +7,8 @@
#endif
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "Ecore.h"
#include "ecore_x_private.h"