efl/src/lib/ecore/ecore_exe_eo.h

126 lines
4.2 KiB
C
Raw Normal View History

#ifndef _ECORE_EXE_EO_H_
#define _ECORE_EXE_EO_H_
#ifndef _ECORE_EXE_EO_CLASS_TYPE
#define _ECORE_EXE_EO_CLASS_TYPE
/**
* @struct Ecore_Exe
* Opaque handle to manage Ecore Exe objects.
*/
typedef Eo Ecore_Exe;
#endif
#ifndef _ECORE_EXE_EO_TYPES
#define _ECORE_EXE_EO_TYPES
/** A structure which stores information on lines data from a child process.
*
* @ingroup Ecore_Exe_Event_Data
*/
typedef struct _Ecore_Exe_Event_Data_Line
{
char *line; /**< The bytes of a line of buffered data */
int size; /**< The size of the line buffer in bytes */
} Ecore_Exe_Event_Data_Line;
/** Ecore exe event data structure
*
* @ingroup Ecore_Exe
*/
typedef struct _Ecore_Exe_Event_Data
{
Efl_Object *exe; /**< The handle to the process. FIXME: should actually be
* Ecore.Exe, workaround cyclic */
void *data; /**< The raw binary data from the child process received */
int size; /**< The size of this data in bytes */
Ecore_Exe_Event_Data_Line *lines; /**< An array of line data if line buffered.
* The last one has its line member set to
* @c NULL */
} Ecore_Exe_Event_Data;
/** Flags for executing a child with its stdin and/or stdout piped back.
*
* @ingroup Ecore
*/
typedef enum
{
ECORE_EXE_NONE = 0, /**< No exe flags at all */
ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */
ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */
ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */
ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline
* and split 1 line per
* Ecore_Exe_Event_Data_Line */
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a
* newline and split 1 line per
* Ecore_Exe_Event_Data_Line */
ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */
ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */
ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */
ECORE_EXE_NOT_LEADER = 256, /**< Do not use setsid() to set the executed
* process as its own session leader */
ECORE_EXE_TERM_WITH_PARENT = 512, /**< Makes child receive SIGTERM when parent
* dies. */
ECORE_EXE_ISOLATE_IO = 1024 /**< Try and isolate stdin/out and err of the
* process so it isn't shared with the parent. */
} Ecore_Exe_Flags;
#endif
/**
* @brief Ecore.Exe is responsible for managing portable process spawning.
*
* With this module you are able to spawn, pause and quit spawned processes.
* Interaction between your process and those spawned is possible using pipes
* or signals.
*
* @ingroup Ecore_Exe
*/
#define ECORE_EXE_CLASS ecore_exe_class_get()
ecore: Rename EAPI macro to ECORE_API in Ecore library Patch from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass ```__attribute__ ((visibility ("default")))``` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as ```__atttribute__((visibility("default")))```. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
2020-09-20 06:23:26 -07:00
ECORE_API ECORE_API_WEAK const Efl_Class *ecore_exe_class_get(void) EINA_CONST;
/**
* @brief Controls the command that's executed. FIXME: May need a split/rename.
*
* @param[in] obj The object.
* @param[in] exe_cmd The command to execute.
* @param[in] flags The execution flags.
*
* @ingroup Ecore_Exe
*/
ecore: Rename EAPI macro to ECORE_API in Ecore library Patch from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass ```__attribute__ ((visibility ("default")))``` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as ```__atttribute__((visibility("default")))```. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
2020-09-20 06:23:26 -07:00
ECORE_API ECORE_API_WEAK void ecore_obj_exe_command_set(Eo *obj, const char *exe_cmd, Ecore_Exe_Flags flags);
/**
* @brief Controls the command that's executed. FIXME: May need a split/rename.
*
* @param[in] obj The object.
* @param[out] exe_cmd The command to execute.
* @param[out] flags The execution flags.
*
* @ingroup Ecore_Exe
*/
ecore: Rename EAPI macro to ECORE_API in Ecore library Patch from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass ```__attribute__ ((visibility ("default")))``` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as ```__atttribute__((visibility("default")))```. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
2020-09-20 06:23:26 -07:00
ECORE_API ECORE_API_WEAK void ecore_obj_exe_command_get(const Eo *obj, const char **exe_cmd, Ecore_Exe_Flags *flags);
ecore: Rename EAPI macro to ECORE_API in Ecore library Patch from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass ```__attribute__ ((visibility ("default")))``` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as ```__atttribute__((visibility("default")))```. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
2020-09-20 06:23:26 -07:00
ECORE_API ECORE_API_WEAK extern const Efl_Event_Description _ECORE_EXE_EVENT_DATA_GET;
/** Data received event from the child process
* @return Ecore_Exe_Event_Data
*
* @ingroup Ecore_Exe
*/
#define ECORE_EXE_EVENT_DATA_GET (&(_ECORE_EXE_EVENT_DATA_GET))
ecore: Rename EAPI macro to ECORE_API in Ecore library Patch from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass ```__attribute__ ((visibility ("default")))``` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as ```__atttribute__((visibility("default")))```. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
2020-09-20 06:23:26 -07:00
ECORE_API ECORE_API_WEAK extern const Efl_Event_Description _ECORE_EXE_EVENT_DATA_ERROR;
/** Error received event from the child process
* @return Ecore_Exe_Event_Data
*
* @ingroup Ecore_Exe
*/
#define ECORE_EXE_EVENT_DATA_ERROR (&(_ECORE_EXE_EVENT_DATA_ERROR))
#endif