From 07274513e984f0b5544586c74508ccd16e7dcafa Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 13 Jan 2013 17:29:19 +1000 Subject: Remove EFL, since it's been released now. --- libraries/ecore/src/lib/ecore_con/Ecore_Con.h | 1938 --------------- libraries/ecore/src/lib/ecore_con/Makefile.am | 46 - libraries/ecore/src/lib/ecore_con/Makefile.in | 935 ------- libraries/ecore/src/lib/ecore_con/ecore_con.c | 2583 -------------------- .../ecore/src/lib/ecore_con/ecore_con_alloc.c | 101 - libraries/ecore/src/lib/ecore_con/ecore_con_ares.c | 628 ----- libraries/ecore/src/lib/ecore_con/ecore_con_info.c | 449 ---- .../ecore/src/lib/ecore_con/ecore_con_local.c | 317 --- .../src/lib/ecore_con/ecore_con_local_win32.c | 754 ------ .../ecore/src/lib/ecore_con/ecore_con_private.h | 397 --- .../ecore/src/lib/ecore_con/ecore_con_socks.c | 940 ------- libraries/ecore/src/lib/ecore_con/ecore_con_ssl.c | 2113 ---------------- libraries/ecore/src/lib/ecore_con/ecore_con_url.c | 1635 ------------- 13 files changed, 12836 deletions(-) delete mode 100644 libraries/ecore/src/lib/ecore_con/Ecore_Con.h delete mode 100644 libraries/ecore/src/lib/ecore_con/Makefile.am delete mode 100644 libraries/ecore/src/lib/ecore_con/Makefile.in delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con.c delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_ares.c delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_info.c delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_local.c delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_local_win32.c delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_private.h delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_socks.c delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_ssl.c delete mode 100644 libraries/ecore/src/lib/ecore_con/ecore_con_url.c (limited to 'libraries/ecore/src/lib/ecore_con') diff --git a/libraries/ecore/src/lib/ecore_con/Ecore_Con.h b/libraries/ecore/src/lib/ecore_con/Ecore_Con.h deleted file mode 100644 index d0ca6f6..0000000 --- a/libraries/ecore/src/lib/ecore_con/Ecore_Con.h +++ /dev/null @@ -1,1938 +0,0 @@ -#ifndef _ECORE_CON_H -#define _ECORE_CON_H - -#include -#include -#ifdef _WIN32 -# include -#else -# include -#endif -#include - -#ifdef EAPI -# undef EAPI -#endif - -#ifdef _WIN32 -# ifdef EFL_ECORE_CON_BUILD -# ifdef DLL_EXPORT -# define EAPI __declspec(dllexport) -# else -# define EAPI -# endif -# else -# define EAPI __declspec(dllimport) -# endif -#else -# ifdef __GNUC__ -# if __GNUC__ >= 4 -# define EAPI __attribute__ ((visibility("default"))) -# else -# define EAPI -# endif -# else -# define EAPI -# endif -#endif - -/** - * @defgroup Ecore_Con_Group Ecore_Con - Connection functions - * - * The Ecore Connection Library ( @c Ecore_Con ) provides simple mechanisms - * for communications between programs using reliable sockets. It saves - * the programmer from having to worry about file descriptors and waiting - * for incoming connections. - * - * There are two main objects in the @c Ecore_Con library: the @c - * Ecore_Con_Server and the @c Ecore_Con_Client. - * - * The @c Ecore_Con_Server represents a server that can be connected to. - * It is used regardless of whether the program is acting as a server or - * client itself. - * - * To create a listening server call @c ecore_con_server_add(), optionally using - * an ECORE_CON_USE_* encryption type OR'ed with the type for encryption. - * - * To connect to a server, call @c ecore_con_server_connect(). Data can - * then be sent to the server using the @c ecore_con_server_send(). - * - * Functions are described in the following groupings: - * @li @ref Ecore_Con_Lib_Group - * @li @ref Ecore_Con_Server_Group - * @li @ref Ecore_Con_Client_Group - * @li @ref Ecore_Con_Url_Group - * - * Events are described in @ref Ecore_Con_Events_Group. - */ - - -/** - * @defgroup Ecore_Con_Events_Group Events - * - * @li ECORE_CON_CLIENT_ADD: Whenever a client connection is made to an - * @c Ecore_Con_Server, an event of this type is emitted, allowing the - * retrieval of the client's ip with @ref ecore_con_client_ip_get and - * associating data with the client using ecore_con_client_data_set. - * @li ECORE_CON_EVENT_CLIENT_DEL: Whenever a client connection to an - * @c Ecore_Con_Server, an event of this type is emitted. The contents of - * the data with this event are variable, but if the client object in the data - * is non-null, it must be freed with @ref ecore_con_client_del. - * @li ECORE_CON_EVENT_SERVER_ADD: Whenever a server object is created - * with @ref ecore_con_server_connect, an event of this type is emitted, - * allowing for data to be serialized and sent to the server using - * @ref ecore_con_server_send. At this point, the http handshake has - * occurred. - * @li ECORE_CON_EVENT_SERVER_DEL: Whenever a server object is destroyed, - * usually by the server connection being refused or dropped, an event of this - * type is emitted. The contents of the data with this event are variable, - * but if the server object in the data is non-null, it must be freed - * with @ref ecore_con_server_del. - * @li ECORE_CON_EVENT_CLIENT_DATA: Whenever a client connects to your server - * object and sends data, an event of this type is emitted. The data will contain both - * the size and contents of the message sent by the client. It should be noted that - * data within this object is transient, so it must be duplicated in order to be - * retained. This event will continue to occur until the client has stopped sending its - * message, so a good option for storing this data is an Eina_Strbuf. Once the message has - * been received in full, the client object must be freed with ecore_con_client_free. - * @li ECORE_CON_EVENT_SERVER_DATA: Whenever your server object connects to its destination - * and receives data, an event of this type is emitted. The data will contain both - * the size and contents of the message sent by the server. It should be noted that - * data within this object is transient, so it must be duplicated in order to be - * retained. This event will continue to occur until the server has stopped sending its - * message, so a good option for storing this data is an Eina_Strbuf. Once the message has - * been received in full, the server object must be freed with ecore_con_server_free. - * - */ - -/** - * @defgroup Ecore_Con_Buffer Buffering - * - * As Ecore_Con works on an event driven design, as data arrives, events will - * be produced containing the data that arrived. It is up to the user of - * Ecore_Con to either parse as they go, append to a file to later parse the - * whole file in one go, or append to memory to parse or handle leter. - * - * To help with this Eina has some handy API's. The Eina_Binbuf and - * Eina_Strbuf APIs, abstract dynamic buffer management and make it trivial - * to handle buffers at runtime, without having to manage them. Eina_Binbuf - * makes it possible to create, expand, reset and slice a blob of memory - - * all via API. No system calls, no pointer manipulations and no size - * calculation. - * - * Additional functions include adding content at specified byte positions in - * the buffer, escaping the inputs, find and replace strings. This provides - * extreme flexibility to play around, with a dynamic blob of memory. - * - * It is good to free it (using eina_binbuf_free()) after using it. - * - * Eina_Binbuf compliments Ecore_Con use cases, where dynamic sizes of data - * arrive from the network (think http download in chunks). Using - * Eina_Binbuf provides enough flexibility to handle data as it arrives and - * to defer its processing until desired, without having to think about - * where to store the temporary data and how to manage its size. - * - * An example of how to use these with Ecore_Con follows. - * - * @code - * #include - * #include - * #include - * - * static Eina_Bool - * data_callback(void *data, int type, void *event) - * { - * Ecore_Con_Event_Url_Data *url_data = event; - * if ( url_data->size > 0) - * { - * // append data as it arrives - don't worry where or how it gets stored. - * // Also don't worry about size, expanding, reallocing etc. - * // just keep appending - size is automatically handled. - * - * eina_binbuf_append_length(data, url_data->data, url_data->size); - * - * fprintf(stderr, "Appended %d \n", url_data->size); - * } - * return EINA_TRUE; - * } - * - * - * - * static Eina_Bool - * completion_callback(void *data, int type, void *event) - * { - * Ecore_Con_Event_Url_Complete *url_complete = event; - * printf("download completed with status code: %d\n", url_complete->status); - * - * // get the data back from Eina_Binbuf - * char *ptr = eina_binbuf_string_get(data); - * size_t size = eina_binbuf_length_get(data); - * - * // process data as required (write to file) - * fprintf(stderr, "Size of data = %d bytes\n", size); - * int fd = open("./elm.png", O_CREAT); - * write(fd, ptr, size); - * close(fd); - * - * // free it when done. - * eina_binbuf_free(data); - * - * ecore_main_loop_quit(); - * - * return EINA_TRUE; - * } - * - * - * int - * main(int argc, char **argv) - * { - * - * const char *url = "http://www.enlightenment.org/p/index/d/logo.png"; - * - * ecore_init(); - * ecore_con_init(); - * ecore_con_url_init(); - * - * - * // This is single additional line to manage dynamic network data. - * Eina_Binbuf *data = eina_binbuf_new(); - * Ecore_Con_Url *url_con = ecore_con_url_new(url); - * - * ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, - * completion_callback, - * data); - * ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, - * data_callback, - * data); - * ecore_con_url_get(url_con); - * - * ecore_main_loop_begin(); - * return 0; - * } - * @endcode - */ - -#ifdef __cplusplus -extern "C" { -#endif -#define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2 -#define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP - - -/** - * @typedef Ecore_Con_Server - * A connection handle to a server - * @ingroup Ecore_Con_Server_Group - */ -typedef struct _Ecore_Con_Server Ecore_Con_Server; - -/** - * @typedef Ecore_Con_Client - * A connection handle to a client - * @ingroup Ecore_Con_Client_Group - */ -typedef struct _Ecore_Con_Client Ecore_Con_Client; - -/** - * @typedef Ecore_Con_Socks - * An object representing a SOCKS proxy - * @ingroup Ecore_Con_Socks_Group - * @since 1.2 - */ -typedef struct Ecore_Con_Socks Ecore_Con_Socks; - -/** - * @typedef Ecore_Con_Url - * A handle to an http upload/download object - * @ingroup Ecore_Con_Url_Group - */ -typedef struct _Ecore_Con_Url Ecore_Con_Url; - - -/** - * @addtogroup Ecore_Con_Events_Group Events - * @{ - */ - -/** - * @typedef Ecore_Con_Event_Client_Add - * Used as the @p data param for the corresponding event - */ -typedef struct _Ecore_Con_Event_Client_Add Ecore_Con_Event_Client_Add; - -/** - * @typedef Ecore_Con_Event_Client_Upgrade - * Used as the @p data param for the corresponding event - * @since 1.1 - */ -typedef struct _Ecore_Con_Event_Client_Upgrade Ecore_Con_Event_Client_Upgrade; - -/** - * @typedef Ecore_Con_Event_Client_Del - * Used as the @p data param for the corresponding event - */ -typedef struct _Ecore_Con_Event_Client_Del Ecore_Con_Event_Client_Del; - -/** - * @typedef Ecore_Con_Event_Client_Error - * Used as the @p data param for the corresponding event - * @since 1.1 - */ -typedef struct _Ecore_Con_Event_Client_Error Ecore_Con_Event_Client_Error; - -/** - * @typedef Ecore_Con_Event_Server_Add - * Used as the @p data param for the corresponding event - */ -typedef struct _Ecore_Con_Event_Server_Add Ecore_Con_Event_Server_Add; - -/** - * @typedef Ecore_Con_Event_Server_Upgrade - * Used as the @p data param for the corresponding event - * @since 1.1 - */ -typedef struct _Ecore_Con_Event_Server_Upgrade Ecore_Con_Event_Server_Upgrade; - -/** - * @typedef Ecore_Con_Event_Server_Del - * Used as the @p data param for the corresponding event - */ -typedef struct _Ecore_Con_Event_Server_Del Ecore_Con_Event_Server_Del; - -/** - * @typedef Ecore_Con_Event_Server_Error - * Used as the @p data param for the corresponding event - * @since 1.1 - */ -typedef struct _Ecore_Con_Event_Server_Error Ecore_Con_Event_Server_Error; - -/** - * @typedef Ecore_Con_Event_Client_Data - * Used as the @p data param for the corresponding event - */ -typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data; - -/** - * @typedef Ecore_Con_Event_Server_Data - * Used as the @p data param for the corresponding event - */ -typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data; - -/** - * @typedef Ecore_Con_Event_Client_Write - * Used as the @p data param for the corresponding event - * @since 1.1 - */ -typedef struct _Ecore_Con_Event_Client_Write Ecore_Con_Event_Client_Write; - -/** - * @typedef Ecore_Con_Event_Server_Write - * Used as the @p data param for the corresponding event - * @since 1.1 - */ -typedef struct _Ecore_Con_Event_Server_Write Ecore_Con_Event_Server_Write; - -/** - * @typedef Ecore_Con_Event_Proxy_Bind - * Used as the @p data param for the corresponding event - * @since 1.2 - */ -typedef struct _Ecore_Con_Event_Proxy_Bind Ecore_Con_Event_Proxy_Bind; - -/** - * @typedef Ecore_Con_Event_Url_Data - * Used as the @p data param for the corresponding event - * @ingroup Ecore_Con_Url_Group - */ -typedef struct _Ecore_Con_Event_Url_Data Ecore_Con_Event_Url_Data; - -/** - * @typedef Ecore_Con_Event_Url_Complete - * Used as the @p data param for the corresponding event - * @ingroup Ecore_Con_Url_Group - */ -typedef struct _Ecore_Con_Event_Url_Complete Ecore_Con_Event_Url_Complete; - -/** - * @typedef Ecore_Con_Event_Url_Progress - * Used as the @p data param for the corresponding event - * @ingroup Ecore_Con_Url_Group - */ -typedef struct _Ecore_Con_Event_Url_Progress Ecore_Con_Event_Url_Progress; - -/** - * @struct _Ecore_Con_Event_Client_Add - * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_ADD event - */ -struct _Ecore_Con_Event_Client_Add -{ - Ecore_Con_Client *client; /** the client that connected */ -}; - -/** - * @struct _Ecore_Con_Event_Client_Upgrade - * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_UPGRADE event - * @since 1.1 - */ -struct _Ecore_Con_Event_Client_Upgrade -{ - Ecore_Con_Client *client; /** the client that completed handshake */ -}; - -/** - * @struct _Ecore_Con_Event_Client_Del - * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_DEL event - */ -struct _Ecore_Con_Event_Client_Del -{ - Ecore_Con_Client *client; /** the client that was lost */ -}; - -/** - * @struct _Ecore_Con_Event_Client_Error - * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_ERROR event - */ -struct _Ecore_Con_Event_Client_Error -{ - Ecore_Con_Client *client; /** the client for which an error occurred */ - char *error; /**< the error string describing what happened */ -}; - -/** - * @struct _Ecore_Con_Event_Server_Add - * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_ADD event - */ -struct _Ecore_Con_Event_Server_Add -{ - Ecore_Con_Server *server; /** the server that was connected to */ -}; - -/** - * @struct _Ecore_Con_Event_Server_Upgrade - * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_UPGRADE event - * @since 1.1 - */ -struct _Ecore_Con_Event_Server_Upgrade -{ - Ecore_Con_Server *server; /** the server that was connected to */ -}; - -/** - * @struct _Ecore_Con_Event_Server_Del - * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_DEL event - */ -struct _Ecore_Con_Event_Server_Del -{ - Ecore_Con_Server *server; /** the client that was lost */ -}; - -/** - * @struct _Ecore_Con_Event_Server_Error - * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_ERROR event - */ -struct _Ecore_Con_Event_Server_Error -{ - Ecore_Con_Server *server; /** the server for which an error occurred */ - char *error; /**< the error string describing what happened */ -}; - -/** - * @struct _Ecore_Con_Event_Client_Data - * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_DATA event - */ -struct _Ecore_Con_Event_Client_Data -{ - Ecore_Con_Client *client; /**< the client that connected */ - void *data; /**< the data that the client sent */ - int size; /**< the length of the data sent */ -}; - -/** - * @struct _Ecore_Con_Event_Server_Data - * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_DATA event - */ -struct _Ecore_Con_Event_Server_Data -{ - Ecore_Con_Server *server; /**< the server that was connected to */ - void *data; /**< the data that the server sent */ - int size; /**< the length of the data sent */ -}; - -/** - * @struct _Ecore_Con_Event_Client_Write - * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_WRITE event - */ -struct _Ecore_Con_Event_Client_Write -{ - Ecore_Con_Client *client; /**< the client that connected */ - int size; /**< the length of the data sent */ -}; - -/** - * @struct _Ecore_Con_Event_Server_Write - * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_WRITE event - */ -struct _Ecore_Con_Event_Server_Write -{ - Ecore_Con_Server *server; /**< the server that was connected to */ - int size; /**< the length of the data sent */ -}; - -/** - * @struct _Ecore_Con_Event_Proxy_Bind - * Used as the @p data param for the @ref ECORE_CON_EVENT_PROXY_BIND event - * @ingroup Ecore_Con_Socks_Group - * @since 1.2 - */ -struct _Ecore_Con_Event_Proxy_Bind -{ - Ecore_Con_Server *server; /**< the server object connected to the proxy */ - const char *ip; /**< the proxy-bound ip address */ - int port; /**< the proxy-bound port */ -}; - -/** - * @struct _Ecore_Con_Event_Url_Data - * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_DATA event - * @ingroup Ecore_Con_Url_Group - */ -struct _Ecore_Con_Event_Url_Data -{ - Ecore_Con_Url *url_con; /**< a pointer to the connection object */ - int size; /**< the size of the current received data (in bytes) */ - unsigned char data[1]; /**< the data received on this event */ -}; - -/** - * @struct _Ecore_Con_Event_Url_Complete - * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_COMPLETE event - * @ingroup Ecore_Con_Url_Group - */ -struct _Ecore_Con_Event_Url_Complete -{ - Ecore_Con_Url *url_con; /**< a pointer to the connection object */ - int status; /**< HTTP status code of the operation (200, 404, 401, etc.) */ -}; - -/** - * @struct _Ecore_Con_Event_Url_Progress - * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_PROGRESS event - * @ingroup Ecore_Con_Url_Group - */ -struct _Ecore_Con_Event_Url_Progress -{ - Ecore_Con_Url *url_con; /**< a pointer to the connection object */ - struct - { - double total; /**< total size of the downloading data (in bytes) */ - double now; /**< current size of the downloading data (in bytes) */ - } down; /**< download info */ - struct - { - double total; /**< total size of the uploading data (in bytes) */ - double now; /**< current size of the uploading data (in bytes) */ - } up; /**< upload info */ -}; - -/** A client has connected to the server */ -EAPI extern int ECORE_CON_EVENT_CLIENT_ADD; -/** A client has disconnected from the server */ -EAPI extern int ECORE_CON_EVENT_CLIENT_DEL; -/** A client experienced an error - * @since 1.1 - */ -EAPI extern int ECORE_CON_EVENT_CLIENT_ERROR; -/** A client connection has been upgraded to SSL - * @since 1.1 - */ -EAPI extern int ECORE_CON_EVENT_CLIENT_UPGRADE; -/** A server was created */ -EAPI extern int ECORE_CON_EVENT_SERVER_ADD; -/** A server connection was lost */ -EAPI extern int ECORE_CON_EVENT_SERVER_DEL; -/** A server experienced an error - * @since 1.1 - */ -EAPI extern int ECORE_CON_EVENT_SERVER_ERROR; -/** A server connection has been upgraded to SSL - * @since 1.1 - */ -EAPI extern int ECORE_CON_EVENT_SERVER_UPGRADE; -/** A server connection has sent data to its client - * @since 1.1 - */ -EAPI extern int ECORE_CON_EVENT_CLIENT_WRITE; -/** A server connection object has sent data - * @since 1.1 - */ -EAPI extern int ECORE_CON_EVENT_SERVER_WRITE; -/** A client connected to the server has sent data */ -EAPI extern int ECORE_CON_EVENT_CLIENT_DATA; -/** A server connection object has data */ -EAPI extern int ECORE_CON_EVENT_SERVER_DATA; -/** A server connection has successfully negotiated an ip:port binding - * @since 1.2 - */ -EAPI extern int ECORE_CON_EVENT_PROXY_BIND; -/** A URL object has data */ -EAPI extern int ECORE_CON_EVENT_URL_DATA; -/** A URL object has completed its transfer to and from the server and can be reused */ -EAPI extern int ECORE_CON_EVENT_URL_COMPLETE; -/** A URL object has made progress in its transfer */ -EAPI extern int ECORE_CON_EVENT_URL_PROGRESS; - -/** - * @} - */ - -/** - * @defgroup Ecore_Con_Lib_Group Ecore Connection Library Functions - * - * Utility functions that set up and shut down the Ecore Connection - * library. - * - * There's also ecore_con_lookup() that can be used to make simple asynchronous - * DNS lookups. - * - * A simple example of how to use these functions: - * @li @ref ecore_con_lookup_example_c - * - * @{ - */ - -/** - * @typedef Ecore_Con_Dns_Cb - * A callback type for use with @ref ecore_con_lookup. - */ -typedef void (*Ecore_Con_Dns_Cb)(const char *canonname, - const char *ip, - struct sockaddr *addr, - int addrlen, - void *data); - -/** - * @typedef Ecore_Con_Type - * @enum _Ecore_Con_Type - * Types for an ecore_con client/server object. A correct way to set this type is - * with an ECORE_CON_$TYPE, optionally OR'ed with an ECORE_CON_$USE if encryption is desired, - * and LOAD_CERT if the previously loaded certificate should be used. - * @code - * ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT - * @endcode - * @ingroup Ecore_Con_Server_Group - */ -typedef enum _Ecore_Con_Type -{ - /** Socket in ~/.ecore */ - ECORE_CON_LOCAL_USER = 0, - /** Socket in /tmp */ - ECORE_CON_LOCAL_SYSTEM = 1, - /** Abstract socket */ - ECORE_CON_LOCAL_ABSTRACT = 2, - /** Remote server using TCP */ - ECORE_CON_REMOTE_TCP = 3, - /** Remote multicast server */ - ECORE_CON_REMOTE_MCAST = 4, - /** Remote server using UDP */ - ECORE_CON_REMOTE_UDP = 5, - /** Remote broadcast using UDP */ - ECORE_CON_REMOTE_BROADCAST = 6, - /** Remote connection sending packets immediately */ - ECORE_CON_REMOTE_NODELAY = 7, - /** Remote connection sending data in large chunks - * @note Only available on Linux - * @since 1.2 - */ - ECORE_CON_REMOTE_CORK = 8, - /** Use SSL2: UNSUPPORTED. **/ - ECORE_CON_USE_SSL2 = (1 << 4), - /** Use SSL3 */ - ECORE_CON_USE_SSL3 = (1 << 5), - /** Use TLS */ - ECORE_CON_USE_TLS = (1 << 6), - /** Use both TLS and SSL3 */ - ECORE_CON_USE_MIXED = ECORE_CON_USE_SSL3 | ECORE_CON_USE_TLS, - /** Attempt to use the loaded certificate */ - ECORE_CON_LOAD_CERT = (1 << 7) -} Ecore_Con_Type; - -/** - * Initialises the Ecore_Con library. - * @return Number of times the library has been initialised without being - * shut down. - * - * @note This function already calls ecore_init() internally, so you don't need - * to call it explicitly. - */ -EAPI int ecore_con_init(void); - -/** - * Shuts down the Ecore_Con library. - * @return Number of times the library has been initialised without being - * shut down. - * @note This function already calls ecore_shutdown() internally, so you don't - * need to call it explicitly unless you called ecore_init() explicitly too. - */ -EAPI int ecore_con_shutdown(void); - -/** - * Do an asynchronous DNS lookup. - * - * @param name IP address or server name to translate. - * @param done_cb Callback to notify when done. - * @param data User data to be given to done_cb. - * @return EINA_TRUE if the request did not fail to be set up, EINA_FALSE if it - * failed. - * - * This function performs a DNS lookup on the hostname specified by @p name, - * then calls @p done_cb with the result and the @p data given as parameter. - * The result will be given to the @p done_cb as follows: - * @li @c canonname - the canonical name of the address - * @li @c ip - the resolved ip address - * @li @c addr - a pointer to the socket address - * @li @c addrlen - the length of the socket address, in bytes - * @li @c data - the data pointer given as parameter to ecore_con_lookup() - */ -EAPI Eina_Bool ecore_con_lookup(const char *name, - Ecore_Con_Dns_Cb done_cb, - const void *data); - -/** - * @} - */ - -/** - * @defgroup Ecore_Con_SSL_Group Ecore Connection SSL Functions - * - * @{ - */ -EAPI int ecore_con_ssl_available_get(void); -EAPI Eina_Bool ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr, const char *cert); -EAPI Eina_Bool ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr, const char *key_file); -EAPI Eina_Bool ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr, const char *crl_file); -EAPI Eina_Bool ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr, const char *ca_file); -EAPI void ecore_con_ssl_server_verify(Ecore_Con_Server *svr); -EAPI void ecore_con_ssl_server_verify_basic(Ecore_Con_Server *svr); -EAPI void ecore_con_ssl_server_verify_name_set(Ecore_Con_Server *svr, const char *name); -EAPI const char *ecore_con_ssl_server_verify_name_get(Ecore_Con_Server *svr); -EAPI Eina_Bool ecore_con_ssl_server_upgrade(Ecore_Con_Server *svr, Ecore_Con_Type compl_type); -EAPI Eina_Bool ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type compl_type); - -/** - * @} - */ - -EAPI Ecore_Con_Socks *ecore_con_socks4_remote_add(const char *ip, int port, const char *username); -EAPI Eina_Bool ecore_con_socks4_remote_exists(const char *ip, int port, const char *username); -EAPI void ecore_con_socks4_remote_del(const char *ip, int port, const char *username); -EAPI Ecore_Con_Socks *ecore_con_socks5_remote_add(const char *ip, int port, const char *username, const char *password); -EAPI Eina_Bool ecore_con_socks5_remote_exists(const char *ip, int port, const char *username, const char *password); -EAPI void ecore_con_socks5_remote_del(const char *ip, int port, const char *username, const char *password); -EAPI void ecore_con_socks_lookup_set(Ecore_Con_Socks *ecs, Eina_Bool enable); -EAPI Eina_Bool ecore_con_socks_lookup_get(Ecore_Con_Socks *ecs); -EAPI void ecore_con_socks_bind_set(Ecore_Con_Socks *ecs, Eina_Bool is_bind); -EAPI Eina_Bool ecore_con_socks_bind_get(Ecore_Con_Socks *ecs); -EAPI unsigned int ecore_con_socks_version_get(Ecore_Con_Socks *ecs); -EAPI void ecore_con_socks_remote_del(Ecore_Con_Socks *ecs); -EAPI void ecore_con_socks_apply_once(Ecore_Con_Socks *ecs); -EAPI void ecore_con_socks_apply_always(Ecore_Con_Socks *ecs); - -/** - * @defgroup Ecore_Con_Server_Group Ecore Connection Server Functions - * - * This group of functions is applied to an @ref Ecore_Con_Server object. It - * doesn't mean that they should be used in the server application, but on the - * server object. In fact, most of them should be used in the client - * application, when retrieving information or sending data. - * - * Setting up a server is very simple: you just need to start it with - * ecore_con_server_add() and setup some callbacks to the events - * @ref ECORE_CON_EVENT_CLIENT_ADD, @ref ECORE_CON_EVENT_CLIENT_DEL and - * @ref ECORE_CON_EVENT_CLIENT_DATA, that will be called when a client is - * communicating with the server: - * - * @code - * if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP, "127.0.0.1", 8080, NULL))) - * exit(1); - * - * ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, _add_cb, NULL); - * ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, _del_cb, NULL); - * ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, _data_cb, NULL); - * - * ecore_main_loop_begin(); - * @endcode - * - * The function ecore_con_server_connect() can be used to write a client that - * connects to a server. The resulting code will be very similar to the server - * code: - * - * @code - * if (!(svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, "127.0.0.1", 8080, NULL))) - * exit(1); - * - * ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _add_cb, NULL); - * ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _del_cb, NULL); - * ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _data_cb, NULL); - * - * ecore_main_loop_begin(); - * @endcode - * - * After these two pieces of code are executed, respectively, in the server and - * client code, the server will be up and running and the client will try to - * connect to it. The connection, with its subsequent messages being sent from - * server to client and client to server, can be represented in the following - * sequence diagram: - * - * @htmlonly - * - * Full size - * @endhtmlonly - * - * @image rtf ecore_con-client-server.png - * @image latex ecore_con-client-server.eps width=\textwidth - * - * Please notice the important difference between these two codes: the first is - * used for writing a @b server, while the second should be used for writing a - * @b client. - * - * A reference for the @c client functions can be found at @ref - * Ecore_Con_Client_Group. - * - * Examples of usage for this API can be found here: - * @li @ref ecore_con_server_simple_example_c - * @li @ref ecore_con_client_simple_example_c - * - * @{ - */ - -/** - * Creates a server to listen for connections. - * - * @param type The connection type. - * @param name Name to associate with the socket. It is used when - * generating the socket name of a Unix socket, or for - * determining what host to listen on for TCP sockets. - * @c NULL will not be accepted. - * @param port Number to identify socket. When a Unix socket is used, - * it becomes part of the socket name. When a TCP socket - * is used, it is used as the TCP port. - * @param data Data to associate with the created Ecore_Con_Server - * object. - * @return A new Ecore_Con_Server. - * - * The socket on which the server listens depends on the connection - * type: - * @li If @a type is @c ECORE_CON_LOCAL_USER, the server will listen on - * the Unix socket "~/.ecore/[name]/[port]". - * @li If @a type is @c ECORE_CON_LOCAL_SYSTEM, the server will listen - * on Unix socket "/tmp/.ecore_service|[name]|[port]". - * @li If @a type is @c ECORE_CON_REMOTE_TCP, the server will listen - * on TCP port @c port. - * - * More information about the @p type can be found at @ref _Ecore_Con_Type. - * - * The @p data parameter can be fetched later using ecore_con_server_data_get() - * or changed with ecore_con_server_data_set(). - */ -EAPI Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type, - const char *name, int port, - const void *data); - -/** - * Creates a connection to the specified server and returns an associated object. - * - * @param type The connection type. - * @param name Name used when determining what socket to connect to. - * It is used to generate the socket name when the socket - * is a Unix socket. It is used as the hostname when - * connecting with a TCP socket. - * @param port Number to identify the socket to connect to. Used when - * generating the socket name for a Unix socket, or as the - * TCP port when connecting to a TCP socket. - * @param data Data to associate with the created Ecore_Con_Server - * object. - * @return A new Ecore_Con_Server. - * - * The socket to which the connection is made depends on the connection type: - * @li If @a type is @c ECORE_CON_LOCAL_USER, the function will - * connect to the server at the Unix socket - * "~/.ecore/[name]/[port]". - * @li If @a type is @c ECORE_CON_LOCAL_SYSTEM, the function will - * connect to the server at the Unix socket - * "/tmp/.ecore_service|[name]|[port]". - * @li If @a type is @c ECORE_CON_REMOTE_TCP, the function will - * connect to the server at the TCP port "[name]:[port]". - * - * More information about the @p type can be found at @ref _Ecore_Con_Type. - * - * This function won't block. It will either succeed, or fail due to invalid - * parameters, failed memory allocation, etc., returning @c NULL on that case. - * - * However, even if this call returns a valid @ref Ecore_Con_Server, the - * connection will only be successfully completed if an event of type - * @ref ECORE_CON_EVENT_SERVER_ADD is received. If it fails to complete, an - * @ref ECORE_CON_EVENT_SERVER_DEL will be received. - * - * The @p data parameter can be fetched later using ecore_con_server_data_get() - * or changed with ecore_con_server_data_set(). - */ -EAPI Ecore_Con_Server *ecore_con_server_connect(Ecore_Con_Type type, - const char *name, int port, - const void *data); -/** - * Closes the connection and frees the given server. - * - * @param svr The given server. - * @return Data associated with the server when it was created. - * - * All the clients connected to this server will be disconnected. - * - * @see ecore_con_server_add, ecore_con_server_connect - */ -EAPI void * ecore_con_server_del(Ecore_Con_Server *svr); - -/** - * Retrieves the data associated with the given server. - * - * @param svr The given server. - * @return The associated data. - * - * @see ecore_con_server_data_set() - */ -EAPI void * ecore_con_server_data_get(Ecore_Con_Server *svr); -/** - * Sets the data associated with the given server. - * - * @param svr The given server. - * @param data The data to associate with @p svr - * @return The previously associated data, if any. - * - * @see ecore_con_server_data_get() - */ -EAPI void * ecore_con_server_data_set(Ecore_Con_Server *svr, - void *data); -/** - * Retrieves whether the given server is currently connected. - * - * @param svr The given server. - * @return #EINA_TRUE if the server is connected. #EINA_FALSE otherwise. - */ -EAPI Eina_Bool ecore_con_server_connected_get(Ecore_Con_Server *svr); -/** - * Retrieves the current list of clients. - * - * @param svr The given server. - * @return The list of clients on this server. - * - * Each node in the returned list points to an @ref Ecore_Con_Client. This list - * cannot be modified or freed. It can also change if new clients are connected - * or disconnected, and will become invalid when the server is deleted/freed. - */ -EAPI const Eina_List * ecore_con_server_clients_get(Ecore_Con_Server *svr); - -/** - * Retrieves the name of server. - * - * @param svr The given server. - * @return The name of the server. - * - * The name returned is the name used to connect on this server. - */ -EAPI const char * ecore_con_server_name_get(Ecore_Con_Server *svr); - -/** - * Retrieves the server port in use. - * - * @param svr The given server. - * @return The server port in use. - * - * The port where the server is listening for connections. - */ -EAPI int ecore_con_server_port_get(Ecore_Con_Server *svr); -/** - * @brief Check how long a server has been connected - * - * @param svr The server to check - * @return The total time, in seconds, that the server has been - * connected/running - * - * This function is used to find out the time that has been elapsed since - * ecore_con_server_add() succeeded. - */ -EAPI double ecore_con_server_uptime_get(Ecore_Con_Server *svr); -/** - * Sends the given data to the given server. - * - * @param svr The given server. - * @param data The given data. - * @param size Length of the data, in bytes, to send. - * @return The number of bytes sent. @c 0 will be returned if there is an - * error. - * - * This function will send the given data to the server as soon as the program - * is back to the main loop. Thus, this function returns immediately - * (non-blocking). If the data needs to be sent @b now, call - * ecore_con_server_flush() after this one. - * - * @see ecore_con_client_send() - * @see ecore_con_server_flush() - */ -EAPI int ecore_con_server_send(Ecore_Con_Server *svr, - const void *data, - int size); -/** - * Sets a limit on the number of clients that can be handled concurrently - * by the given server, and a policy on what to do if excess clients try to - * connect. - * - * @param svr The given server. - * @param client_limit The maximum number of clients to handle - * concurrently. -1 means unlimited (default). 0 - * effectively disables the server. - * @param reject_excess_clients Set to 1 to automatically disconnect - * excess clients as soon as they connect if you are - * already handling client_limit clients. Set to 0 - * (default) to just hold off on the "accept()" - * system call until the number of active clients - * drops. This causes the kernel to queue up to 4096 - * connections (or your kernel's limit, whichever is - * lower). - * - * Beware that if you set this once ecore is already running, you may - * already have pending CLIENT_ADD events in your event queue. Those - * clients have already connected and will not be affected by this call. - * Only clients subsequently trying to connect will be affected. - */ -EAPI void ecore_con_server_client_limit_set(Ecore_Con_Server *svr, - int client_limit, - char reject_excess_clients); -/** - * Gets the IP address of a server that has been connected to. - * - * @param svr The given server. - * @return A pointer to an internal string that contains the IP address of - * the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation. - * This string should not be modified or trusted to stay valid after - * deletion for the @p svr object. If no IP is known NULL is returned. - */ -EAPI const char * ecore_con_server_ip_get(Ecore_Con_Server *svr); -/** - * Flushes all pending data to the given server. - * - * @param svr The given server. - * - * This function will block until all data is sent to the server. - * - * @see ecore_con_server_send() - * @see ecore_con_client_flush() - */ -EAPI void ecore_con_server_flush(Ecore_Con_Server *svr); -/** - * Set the default time after which an inactive client will be disconnected - * - * @param svr The server object - * @param timeout The timeout, in seconds, to disconnect after - * - * This function is used by the server to set the default idle timeout on - * clients. If the any of the clients becomes idle for a time higher than this - * value, it will be disconnected. A value of < 1 disables the idle timeout. - * - * This timeout is not affected by the one set by - * ecore_con_client_timeout_set(). A client will be disconnected whenever the - * client or the server timeout is reached. That means, the lower timeout value - * will be used for that client if ecore_con_client_timeout_set() is used on it. - * - * @see ecore_con_server_timeout_get() - * @see ecore_con_client_timeout_set() - */ -EAPI void ecore_con_server_timeout_set(Ecore_Con_Server *svr, double timeout); -/** - * Get the default time after which an inactive client will be disconnected - * - * @param svr The server object - * @return The timeout, in seconds, to disconnect after - * - * This function is used to get the idle timeout for clients. A value of < 1 - * means the idle timeout is disabled. - * - * @see ecore_con_server_timeout_set() - * @see ecore_con_client_timeout_get() - */ -EAPI double ecore_con_server_timeout_get(Ecore_Con_Server *svr); - -/** - * Get the fd that the server is connected to - * - * @param svr The server object - * @return The fd, or -1 on failure - * - * This function returns the fd which is used by the underlying server connection. - * It should not be tampered with unless you REALLY know what you are doing. - * @note This function is only valid for servers created with ecore_con_server_connect() - * @warning Seriously. Don't use this unless you know what you are doing. - * @since 1.1 - */ -EAPI int ecore_con_server_fd_get(Ecore_Con_Server *svr); - -/** - * Get the fd that the client is connected to - * - * @param cl The client object - * @return The fd, or -1 on failure - * - * This function returns the fd which is used by the underlying client connection. - * It should not be tampered with unless you REALLY know what you are doing. - * @since 1.1 - */ -EAPI int ecore_con_client_fd_get(Ecore_Con_Client *cl); -/** - * @} - */ - -/** - * @defgroup Ecore_Con_Client_Group Ecore Connection Client Functions - * - * Functions to communicate with and/or set options on a client. - * - * This set of functions, as explained in @ref Ecore_Con_Server_Group, is used - * to send data to a client, or to set options and get information about this - * client. Most of them should be used on the server, applied on the client - * object. - * - * If you need to implement a client, the way to connect to a server is - * described in @ref Ecore_Con_Server_Group. - * - * An example of usage of these functions can be found at: - * @li @ref ecore_con_client_simple_example_c - * - * @{ - */ - -/** - * Sends the given data to the given client. - * - * @param cl The given client. - * @param data The given data. - * @param size Length of the data, in bytes, to send. - * @return The number of bytes sent. @c 0 will be returned if there is an - * error. - * - * This function will send the given data to the client as soon as the program - * is back to the main loop. Thus, this function returns immediately - * (non-blocking). If the data needs to be sent @b now, call - * ecore_con_client_flush() after this one. - * - * @see ecore_con_server_send() - * @see ecore_con_client_flush() - */ -EAPI int ecore_con_client_send(Ecore_Con_Client *cl, - const void *data, - int size); -/** - * Retrieves the server representing the socket the client has - * connected to. - * - * @param cl The given client. - * @return The server that the client connected to. - */ -EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl); -/** - * Closes the connection and frees memory allocated to the given client. - * - * @param cl The given client. - * @return Data associated with the client. - */ -EAPI void * ecore_con_client_del(Ecore_Con_Client *cl); -/** - * Sets the data associated with the given client to @p data. - * - * @param cl The given client. - * @param data What to set the data to. - */ -EAPI void ecore_con_client_data_set(Ecore_Con_Client *cl, - const void *data); -/** - * Retrieves the data associated with the given client. - * - * @param cl The given client. - * @return The data associated with @p cl. - */ -EAPI void * ecore_con_client_data_get(Ecore_Con_Client *cl); - -/** - * Gets the IP address of a client that has connected. - * - * @param cl The given client. - * @return A pointer to an internal string that contains the IP address of - * the connected client in the form "XXX.YYY.ZZZ.AAA" IP notation. - * - * The returned string should not be modified, freed or trusted to stay valid - * after deletion for the @p cl object. If no IP is known NULL is returned. - */ -EAPI const char * ecore_con_client_ip_get(Ecore_Con_Client *cl); -/** - * Flushes all pending data to the given client. - * - * @param cl The given client. - * - * This function will block until all data is sent to the server. - * - * @see ecore_con_client_send() - * @see ecore_con_server_flush() - */ -EAPI void ecore_con_client_flush(Ecore_Con_Client *cl); -/** - * @brief Check how long a client has been connected - * - * @param cl The client to check - * @return The total time, in seconds, that the client has been connected to - * the server - * - * This function is used to find out how long a client has been connected for. - */ -EAPI double ecore_con_client_uptime_get(Ecore_Con_Client *cl); -/** - * Get the default time after which the client will be disconnected when - * inactive - * - * @param cl The client object - * @return The timeout, in seconds, to disconnect after - * - * This function is used to get the idle timeout for a client. A value of < 1 - * means the idle timeout is disabled. - * - * @see ecore_con_client_timeout_set() - */ -EAPI double ecore_con_client_timeout_get(Ecore_Con_Client *cl); -/** - * Set the time after which the client will be disconnected when inactive - * - * @param cl The client object - * @param timeout The timeout, in seconds, to disconnect after - * - * This function is used by the server to set the idle timeout on a specific - * client. If the client becomes idle for a time higher than this value, it will - * be disconnected. A value of < 1 disables the idle timeout. - * - * This timeout is not affected by the one set by - * ecore_con_server_timeout_set(). A client will be disconnected whenever the - * client or the server timeout is reached. That means, the lower timeout value - * will be used for that client if ecore_con_server_timeout_set() is used on the - * server. - * - * @see ecore_con_client_timeout_get() - * @see ecore_con_server_timeout_set() - */ -EAPI void ecore_con_client_timeout_set(Ecore_Con_Client *cl, double timeout); -/** - * Returns whether the client is still connected - * - * @param cl The given client. - * @return #EINA_TRUE if connected, else EINA_FALSE - */ -EAPI Eina_Bool ecore_con_client_connected_get(Ecore_Con_Client *cl); -/** - * @brief Return the port that the client has connected to - * - * @param cl The client - * @return The port that @p cl has connected to, or -1 on error - * Use this function to return the port on which a given client has connected. - */ -EAPI int ecore_con_client_port_get(Ecore_Con_Client *cl); - - - -/** - * @} - */ - -/** - * @defgroup Ecore_Con_Url_Group Ecore URL Connection Functions - * - * Utility functions that set up, use and shut down the Ecore URL - * Connection library. - * - * These functions are a shortcut to make it easy to perform http requests - * (POST, GET, etc). - * - * Brief usage: - * 1. Create an Ecore_Con_Url object with ecore_con_url_new(url); - * 2. Register to receive the #ECORE_CON_EVENT_URL_COMPLETE event - * (and optionally the #ECORE_CON_EVENT_URL_DATA and - * #ECORE_CON_EVENT_URL_PROGRESS event to receive - * the response, e.g. for HTTP/FTP downloads) - * 3. Perform the operation with ecore_con_url_get(...); - * - * Note that it is good to reuse @ref Ecore_Con_Url objects wherever possible, - * but bear in mind that each one can only perform one operation at a time. You - * need to wait for the #ECORE_CON_EVENT_URL_COMPLETE event before re-using or - * destroying the object. - * - * If it's necessary to change the @ref Ecore_Con_Url object url, use - * ecore_con_url_url_set(). - * - * Simple Usage 1 (HTTP GET): - * @code - * ecore_con_url_url_set(url_con, "http://www.google.com"); - * ecore_con_url_get(url_con); - * @endcode - * - * Simple usage 2 (HTTP POST): - * @code - * ecore_con_url_url_set(url_con, "http://www.example.com/post_handler.cgi"); - * ecore_con_url_post(url_con, data, data_length, "multipart/form-data"); - * @endcode - * - * Simple Usage 3 (FTP download): - * @code - * fd = creat(filename, 0644) - * ecore_con_url_url_set(url_con, "ftp://ftp.example.com/pub/myfile"); - * ecore_con_url_fd_set(url_con, fd); - * ecore_con_url_get(url_con); - * @endcode - * - * Simple Usage 4 (FTP upload as ftp://ftp.example.com/file): - * @code - * ecore_con_url_url_set(url_con, "ftp://ftp.example.com"); - * ecore_con_url_ftp_upload(url_con, "/tmp/file", "user", "pass", NULL); - * @endcode - * - * Simple Usage 5 (FTP upload as ftp://ftp.example.com/dir/file): - * @code - * ecore_con_url_url_set(url_con, "ftp://ftp.example.com"); - * ecore_con_url_ftp_upload(url_con, "/tmp/file", "user", "pass","dir"); - * @endcode - * - * These are complete examples for the API: - * @li @ref ecore_con_url_download_example.c "Downloading a file" - * @li @ref ecore_con_url_headers_example.c "Setting many options for the - * connection" - * - * @{ - */ - -/** - * @typedef Ecore_Con_Url_Time - * @enum _Ecore_Con_Url_Time - * The type of condition to use when making an HTTP request dependent on time, - * so that headers such as "If-Modified-Since" are used. - */ -typedef enum _Ecore_Con_Url_Time -{ - /** - * Do not place time restrictions on the HTTP requests. - */ - ECORE_CON_URL_TIME_NONE = 0, - /** - * Add the "If-Modified-Since" HTTP header, so that the request is performed - * by the server only if the target has been modified since the time value - * passed to it in the request. - */ - ECORE_CON_URL_TIME_IFMODSINCE, - /** - * Add the "If-Unmodified-Since" HTTP header, so that the request is - * performed by the server only if the target has NOT been modified since - * the time value passed to it in the request. - */ - ECORE_CON_URL_TIME_IFUNMODSINCE -} Ecore_Con_Url_Time; - -/** - * @typedef Ecore_Con_Url_Http_Version - * @enum _Ecore_Con_Url_Http_Version - * The http version to use - * @since 1.2 - */ -typedef enum _Ecore_Con_Url_Http_Version -{ - /** - * HTTP version 1.0 - * @since 1.2 - */ - ECORE_CON_URL_HTTP_VERSION_1_0, - /** - * HTTP version 1.1 (default) - * @since 1.2 - */ - ECORE_CON_URL_HTTP_VERSION_1_1 -} Ecore_Con_Url_Http_Version; - -/** - * Change the HTTP version used for the request - * @param version The version to be used - * @return EINA_TRUE on success, EINA_FALSE on failure to change version - * @since 1.2 - * @see ecore_con_url_pipeline_get() - */ -EAPI Eina_Bool ecore_con_url_http_version_set(Ecore_Con_Url *url_con, Ecore_Con_Url_Http_Version version); - -/** - * Initialises the Ecore_Con_Url library. - * @return Number of times the library has been initialised without being - * shut down. - * - * @note This function doesn't call ecore_con_init(). You still need to call it - * explicitly before calling this one. - */ -EAPI int ecore_con_url_init(void); - -/** - * Shuts down the Ecore_Con_Url library. - * @return Number of calls that still uses Ecore_Con_Url - * - * @note This function doesn't call ecore_con_shutdown(). You still need to call - * it explicitly after calling this one. - */ -EAPI int ecore_con_url_shutdown(void); - -/** - * Enable or disable HTTP 1.1 pipelining. - * @param enable EINA_TRUE will turn it on, EINA_FALSE will disable it. - * - * Pipelining allows to send one request after another one, without having to - * wait for the reply of the first request. The respective replies are received - * in the order that the requests were sent. - * - * Enabling this feature will be valid for all requests done using @c - * ecore_con_url. - * - * See http://en.wikipedia.org/wiki/HTTP_pipelining for more info. - * - * @see ecore_con_url_pipeline_get() - */ -EAPI void ecore_con_url_pipeline_set(Eina_Bool enable); -/** - * Is HTTP 1.1 pipelining enable ? - * @return EINA_TRUE if it is enable. - * - * @see ecore_con_url_pipeline_set() - */ -EAPI Eina_Bool ecore_con_url_pipeline_get(void); - -/** - * Creates and initializes a new Ecore_Con_Url connection object. - * - * @param url URL that will receive requests. Can be changed using - * ecore_con_url_url_set. - * - * @return NULL on error, a new Ecore_Con_Url on success. - * - * Creates and initializes a new Ecore_Con_Url connection object that can be - * used for sending requests. - * - * @see ecore_con_url_custom_new() - * @see ecore_con_url_url_set() - */ -EAPI Ecore_Con_Url * ecore_con_url_new(const char *url); -/** - * Creates a custom connection object. - * - * @param url URL that will receive requests - * @param custom_request Custom request (e.g. GET, POST, HEAD, PUT, etc) - * - * @return NULL on error, a new Ecore_Con_Url on success. - * - * Creates and initializes a new Ecore_Con_Url for a custom request (e.g. HEAD, - * SUBSCRIBE and other obscure HTTP requests). This object should be used like - * one created with ecore_con_url_new(). - * - * @see ecore_con_url_new() - * @see ecore_con_url_url_set() - */ -EAPI Ecore_Con_Url * ecore_con_url_custom_new(const char *url, - const char *custom_request); -/** - * Destroys a Ecore_Con_Url connection object. - * - * @param url_con Connection object to free. - * - * @see ecore_con_url_new() - */ -EAPI void ecore_con_url_free(Ecore_Con_Url *url_con); -/** - * Sets the URL to send the request to. - * - * @param url_con Connection object through which the request will be sent. - * @param url URL that will receive the request - * - * @return EINA_TRUE on success, EINA_FALSE on error. - * - */ -EAPI Eina_Bool ecore_con_url_url_set(Ecore_Con_Url *url_con, - const char *url); -/** - * Gets the URL to send the request to. - * - * @param url_con Connection object through which the request will be sent. - * @return URL that will receive the request, NULL on failure. URL is stringshared. - * @since 1.1 - */ -EAPI const char *ecore_con_url_url_get(Ecore_Con_Url *url_con); -/** - * Associates data with a connection object. - * - * @param url_con Connection object to associate data. - * @param data Data to be set. - * - * Associates data with a connection object, which can be retrieved later with - * ecore_con_url_data_get()). - * - * @see ecore_con_url_data_get() - */ -EAPI void ecore_con_url_data_set(Ecore_Con_Url *url_con, - void *data); -/** - * Retrieves data associated with a Ecore_Con_Url connection object. - * - * @param url_con Connection object to retrieve data from. - * - * @return Data associated with the given object. - * - * Retrieves data associated with a Ecore_Con_Url connection object (previously - * set with ecore_con_url_data_set()). - * - * @see ecore_con_url_data_set() - */ -EAPI void * ecore_con_url_data_get(Ecore_Con_Url *url_con); -/** - * Adds an additional header to the request connection object. - * - * @param url_con Connection object - * @param key Header key - * @param value Header value - * - * Adds an additional header (User-Agent, Content-Type, etc.) to the request - * connection object. This addition will be valid for only one - * ecore_con_url_get() or ecore_con_url_post() call. - * - * Some functions like ecore_con_url_time() also add headers to the request. - * - * @see ecore_con_url_get() - * @see ecore_con_url_post() - * @see ecore_con_url_additional_headers_clear() - */ -EAPI void ecore_con_url_additional_header_add(Ecore_Con_Url *url_con, - const char *key, - const char *value); -/** - * Cleans additional headers. - * - * @param url_con Connection object to clean additional headers. - * - * Cleans additional headers associated with a connection object (previously - * added with ecore_con_url_additional_header_add()). - * - * @see ecore_con_url_additional_header_add() - * @see ecore_con_url_get() - * @see ecore_con_url_post() - */ -EAPI void ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con); -/** - * Retrieves headers from last request sent. - * - * @param url_con Connection object to retrieve response headers from. - * - * Retrieves a list containing the response headers. This function should be - * used after an ECORE_CON_EVENT_URL_COMPLETE event (headers should normally be - * ready at that time). - * - * @return List of response headers. This list must not be modified by the user. - */ -EAPI const Eina_List * ecore_con_url_response_headers_get(Ecore_Con_Url *url_con); -/** - * Setup a file for receiving response data. - * - * @param url_con Connection object to set file - * @param fd File descriptor associated with the file. A negative value will - * unset any previously set fd. - * - * Sets up a file to have response data written into. Note that - * ECORE_CON_EVENT_URL_DATA events will not be emitted if a file has been set to - * receive the response data. - * - * This call can be used to easily setup a file where the downloaded data will - * be saved. - */ -EAPI void ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd); -/** - * Retrieves the number of bytes received. - * - * Retrieves the number of bytes received on the last request of the given - * connection object. - * - * @param url_con Connection object which the request was sent on. - * - * @return Number of bytes received on request. - * - * @see ecore_con_url_get() - * @see ecore_con_url_post() - */ -EAPI int ecore_con_url_received_bytes_get(Ecore_Con_Url *url_con); -/** - * Sets url_con to use http auth, with given username and password, "safely" or not. - * - * @param url_con Connection object to perform a request on, previously created - * with ecore_con_url_new() or ecore_con_url_custom_new(). - * @param username Username to use in authentication - * @param password Password to use in authentication - * @param safe Whether to use "safer" methods (eg, NOT http basic auth) - * - * @return #EINA_TRUE on success, #EINA_FALSE on error. - * - * ATTENTION: requires libcurl >= 7.19.1 to work, otherwise will always return 0. - */ -EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, - const char *username, - const char *password, - Eina_Bool safe); -/** - * Sends a get request. - * - * @param url_con Connection object to perform a request on, previously created - * - * @return #EINA_TRUE on success, #EINA_FALSE on error. - * - * The request is performed immediately, but you need to setup event handlers - * for #ECORE_CON_EVENT_URL_DATA, #ECORE_CON_EVENT_URL_COMPLETE or - * #ECORE_CON_EVENT_URL_PROGRESS to get more information about its result. - * - * @see ecore_con_url_custom_new() - * @see ecore_con_url_additional_headers_clear() - * @see ecore_con_url_additional_header_add() - * @see ecore_con_url_data_set() - * @see ecore_con_url_data_get() - * @see ecore_con_url_response_headers_get() - * @see ecore_con_url_time() - * @see ecore_con_url_post() - */ -EAPI Eina_Bool ecore_con_url_get(Ecore_Con_Url *url_con); -/** - * Sends a post request. - * - * @param url_con Connection object to perform a request on, previously created - * with ecore_con_url_new() or ecore_con_url_custom_new(). - * @param data Payload (data sent on the request). Can be @c NULL. - * @param length Payload length. If @c -1, rely on automatic length - * calculation via @c strlen() on @p data. - * @param content_type Content type of the payload (e.g. text/xml). Can be @c - * NULL. - * - * @return #EINA_TRUE on success, #EINA_FALSE on error. - * - * The request starts immediately, but you need to setup event handlers - * for #ECORE_CON_EVENT_URL_DATA, #ECORE_CON_EVENT_URL_COMPLETE or - * #ECORE_CON_EVENT_URL_PROGRESS to get more information about its result. - * - * This call won't block your main loop. - * - * @see ecore_con_url_custom_new() - * @see ecore_con_url_additional_headers_clear() - * @see ecore_con_url_additional_header_add() - * @see ecore_con_url_data_set() - * @see ecore_con_url_data_get() - * @see ecore_con_url_response_headers_get() - * @see ecore_con_url_time() - * @see ecore_con_url_get() - */ -EAPI Eina_Bool ecore_con_url_post(Ecore_Con_Url *url_con, - const void *data, long length, - const char *content_type); -/** - * Sets whether HTTP requests should be conditional, dependent on - * modification time. - * - * @param url_con Ecore_Con_Url to act upon. - * @param time_condition Condition to use for HTTP requests. - * @param timestamp Time since 1 Jan 1970 to use in the condition. - * - * This function may set the header "If-Modified-Since" or - * "If-Unmodified-Since", depending on the value of @p time_condition, with the - * value @p timestamp. - * - * @sa ecore_con_url_get() - * @sa ecore_con_url_post() - */ -EAPI void ecore_con_url_time(Ecore_Con_Url *url_con, - Ecore_Con_Url_Time time_condition, - double timestamp); - -/** - * @brief Uploads a file to an ftp site. - * @param url_con The Ecore_Con_Url object to send with - * @param filename The path to the file to send - * @param user The username to log in with - * @param pass The password to log in with - * @param upload_dir The directory to which the file should be uploaded - * @return #EINA_TRUE on success, else #EINA_FALSE. - * Upload @p filename to an ftp server set in @p url_con using @p user - * and @p pass to directory @p upload_dir - */ -EAPI Eina_Bool ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, - const char *filename, - const char *user, - const char *pass, - const char *upload_dir); -/** - * Toggle libcurl's verbose output. - * - * @param url_con Ecore_Con_Url instance which will be acted upon. - * @param verbose Whether or not to enable libcurl's verbose output. - * - * If @p verbose is @c EINA_TRUE, libcurl will output a lot of verbose - * information about its operations, which is useful for - * debugging. The verbose information will be sent to stderr. - */ -EAPI void ecore_con_url_verbose_set(Ecore_Con_Url *url_con, - Eina_Bool verbose); -/** - * Enable or disable EPSV extension - * @return FIXME: To be more documented. - */ -EAPI void ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, - Eina_Bool use_epsv); - -/** - * Enables the cookie engine for subsequent HTTP requests. - * - * @param url_con Ecore_Con_Url instance which will be acted upon. - * - * After this function is called, cookies set by the server in HTTP responses - * will be parsed and stored, as well as sent back to the server in new HTTP - * requests. - * - * @note Even though this function is called @c ecore_con_url_cookies_init(), - * there is no symmetrical shutdown operation. - */ -EAPI void ecore_con_url_cookies_init(Ecore_Con_Url *url_con); -/** - * Controls whether session cookies from previous sessions shall be loaded. - * - * @param url_con Ecore_Con_Url instance which will be acted upon. - * @param ignore If @c EINA_TRUE, ignore session cookies when loading cookies - * from files. If @c EINA_FALSE, all cookies will be loaded. - * - * Session cookies are cookies with no expire date set, which usually means - * they are removed after the current session is closed. - * - * By default, when Ecore_Con_Url loads cookies from a file, all cookies are - * loaded, including session cookies, which, most of the time, were supposed - * to be loaded and valid only for that session. - * - * If @p ignore is set to @c EINA_TRUE, when Ecore_Con_Url loads cookies from - * the files passed to @c ecore_con_url_cookies_file_add(), session cookies - * will not be loaded. - * - * @see ecore_con_url_cookies_file_add() - */ -EAPI void ecore_con_url_cookies_ignore_old_session_set(Ecore_Con_Url *url_con, - Eina_Bool ignore); -/** - * Clears currently loaded cookies. - * @param url_con Ecore_Con_Url instance which will be acted upon. - * - * The cleared cookies are removed and will not be sent in subsequent HTTP - * requests, nor will they be written to the cookiejar file set via - * @c ecore_con_url_cookies_jar_file_set(). - * - * @note This function will initialize the cookie engine if it has not been - * initialized yet. - * @note The cookie files set by ecore_con_url_cookies_file_add() aren't loaded - * immediately, just when the request is started. Thus, if you ask to - * clear the cookies, but has a file already set by that function, the - * cookies will then be loaded and you will have old cookies set. In order - * to don't have any old cookie set, you need to don't call - * ecore_con_url_cookies_file_add() ever on the @p url_con handler, and - * call this function to clear any cookie set by a previous request on - * this handler. - * - * @see ecore_con_url_cookies_session_clear() - * @see ecore_con_url_cookies_ignore_old_session_set() - */ -EAPI void ecore_con_url_cookies_clear(Ecore_Con_Url *url_con); -/** - * Clears currently loaded session cookies. - * - * @param url_con Ecore_Con_Url instance which will be acted upon. - * - * Session cookies are cookies with no expire date set, which usually means - * they are removed after the current session is closed. - * - * The cleared cookies are removed and will not be sent in subsequent HTTP - * requests, nor will they be written to the cookiejar file set via - * @c ecore_con_url_cookies_jar_file_set(). - * - * @note This function will initialize the cookie engine if it has not been - * initialized yet. - * @note The cookie files set by ecore_con_url_cookies_file_add() aren't loaded - * immediately, just when the request is started. Thus, if you ask to - * clear the session cookies, but has a file already set by that function, - * the session cookies will then be loaded and you will have old cookies - * set. In order to don't have any old session cookie set, you need to - * don't call ecore_con_url_cookies_file_add() ever on the @p url_con - * handler, and call this function to clear any session cookie set by a - * previous request on this handler. An easier way to don't use old - * session cookies is by using the function - * ecore_con_url_cookies_ignore_old_session_set(). - * - * @see ecore_con_url_cookies_clear() - * @see ecore_con_url_cookies_ignore_old_session_set() - */ -EAPI void ecore_con_url_cookies_session_clear(Ecore_Con_Url *url_con); -/** - * Adds a file to the list of files from which to load cookies. - * - * @param url_con Ecore_Con_Url instance which will be acted upon. - * @param file_name Name of the file that will be added to the list. - * - * Files must contain cookies defined according to two possible formats: - * - * @li HTTP-style header ("Set-Cookie: ..."). - * @li Netscape/Mozilla cookie data format. - * - * Cookies will only be @b read from this file. If you want to save cookies to a - * file, use ecore_con_url_cookies_jar_file_set(). Also notice that this - * function supports the both types of cookie file cited above, while - * ecore_con_url_cookies_jar_file_set() will save only in the Netscape/Mozilla's - * format. - * - * Please notice that the file will not be read immediately, but rather added - * to a list of files that will be loaded and parsed at a later time. - * - * @note This function will initialize the cookie engine if it has not been - * initialized yet. - * - * @see ecore_con_url_cookies_ignore_old_session_set() - * @see ecore_con_url_cookies_jar_file_set() - */ -EAPI void ecore_con_url_cookies_file_add(Ecore_Con_Url *url_con, - const char * const file_name); -/** - * Sets the name of the file to which all current cookies will be written when - * either cookies are flushed or Ecore_Con is shut down. - * - * @param url_con Ecore_Con_Url instance which will be acted upon. - * @param cookiejar_file File to which the cookies will be written. - * - * @return @c EINA_TRUE is the file name has been set successfully, - * @c EINA_FALSE otherwise. - * - * Cookies are written following Netscape/Mozilla's data format, also known as - * cookie-jar. - * - * Cookies will only be @b saved to this file. If you need to read cookies from - * a file, use ecore_con_url_cookies_file_add() instead. - * - * @note This function will initialize the cookie engine if it has not been - * initialized yet. - * - * @see ecore_con_url_cookies_jar_write() - */ -EAPI Eina_Bool ecore_con_url_cookies_jar_file_set(Ecore_Con_Url *url_con, - const char * const cookiejar_file); -/** - * Writes all current cookies to the cookie jar immediately. - * - * @param url_con Ecore_Con_Url instance which will be acted upon. - * - * A cookie-jar file must have been previously set by - * @c ecore_con_url_jar_file_set, otherwise nothing will be done. - * - * @note This function will initialize the cookie engine if it has not been - * initialized yet. - * - * @see ecore_con_url_cookies_jar_file_set() - */ -EAPI void ecore_con_url_cookies_jar_write(Ecore_Con_Url *url_con); - -EAPI void ecore_con_url_ssl_verify_peer_set(Ecore_Con_Url *url_con, - Eina_Bool verify); -EAPI int ecore_con_url_ssl_ca_set(Ecore_Con_Url *url_con, - const char *ca_path); - -/** - * Set HTTP proxy to use. - * - * The parameter should be a char * to a zero terminated string holding - * the host name or dotted IP address. To specify port number in this string, - * append :[port] to the end of the host name. - * The proxy string may be prefixed with [protocol]:// since any such prefix - * will be ignored. - * The proxy's port number may optionally be specified with the separate option. - * If not specified, libcurl will default to using port 1080 for proxies. - * - * @param url_con Connection object that will use the proxy. - * @param proxy Porxy string or @c NULL to disable - * - * @return #EINA_TRUE on success, #EINA_FALSE on error. - * @since 1.2 - */ -EAPI Eina_Bool ecore_con_url_proxy_set(Ecore_Con_Url *url_con, const char *proxy); - -/** - * Set zero terminated username to use for proxy. - * - * if socks protocol is used for proxy, protocol should be socks5 and above. - * - * @param url_con Connection object that will use the proxy. - * @param username Username string. - * - * @return #EINA_TRUE on success, #EINA_FALSE on error. - * - * @see ecore_con_url_proxy_set() - * - * @since 1.2 - */ -EAPI Eina_Bool ecore_con_url_proxy_username_set(Ecore_Con_Url *url_con, const char *username); - -/** - * Set zero terminated password to use for proxy. - * - * if socks protocol is used for proxy, protocol should be socks5 and above. - * - * @param url_con Connection object that will use the proxy. - * @param password Password string. - * - * @return #EINA_TRUE on success, #EINA_FALSE on error. - * - * @see ecore_con_url_proxy_set() - * - * @since 1.2 - */ -EAPI Eina_Bool ecore_con_url_proxy_password_set(Ecore_Con_Url *url_con, const char *password); - -/** - * Set timeout in seconds. - * - * the maximum time in seconds that you allow the ecore con url transfer - * operation to take. Normally, name lookups can take a considerable time - * and limiting operations to less than a few minutes risk aborting perfectly - * normal operations. - * - * @param url_con Connection object that will use the timeout. - * @param timeout time in seconds. - * - * @see ecore_con_url_cookies_jar_file_set() - * - * @since 1.2 - */ -EAPI void ecore_con_url_timeout_set(Ecore_Con_Url *url_con, double timeout); - -/** - * Get the returned HTTP STATUS code - * - * This is used to, at any time, try to return the status code for a transmission. - * @param url_con Connection object - * @return A valid HTTP STATUS code, or 0 on failure - * - * @since 1.2 - */ -EAPI int ecore_con_url_status_code_get(Ecore_Con_Url *url_con); -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libraries/ecore/src/lib/ecore_con/Makefile.am b/libraries/ecore/src/lib/ecore_con/Makefile.am deleted file mode 100644 index 929b30e..0000000 --- a/libraries/ecore/src/lib/ecore_con/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = \ --I$(top_builddir)/src/lib/ecore \ --I$(top_builddir)/src/lib/ecore_con \ --I$(top_srcdir)/src/lib/ecore \ --I$(top_srcdir)/src/lib/ecore_con \ -@EFL_ECORE_CON_BUILD@ \ -@SSL_CFLAGS@ \ -@CURL_CFLAGS@ \ -@EINA_CFLAGS@ \ -@TLS_CFLAGS@ \ -@CARES_CFLAGS@ \ -@WIN32_CPPFLAGS@ - -lib_LTLIBRARIES = libecore_con.la -includes_HEADERS = Ecore_Con.h -includesdir = $(includedir)/ecore-@VMAJ@ - -libecore_con_la_SOURCES = \ -ecore_con.c \ -ecore_con_socks.c \ -ecore_con_ssl.c \ -ecore_con_url.c \ -ecore_con_alloc.c - -if ECORE_HAVE_WIN32 -libecore_con_la_SOURCES += ecore_con_local_win32.c -else -libecore_con_la_SOURCES += ecore_con_local.c -endif - -if HAVE_CARES -libecore_con_la_SOURCES += ecore_con_ares.c -else -libecore_con_la_SOURCES += ecore_con_info.c -endif - -libecore_con_la_CFLAGS = @WIN32_CFLAGS@ -libecore_con_la_LIBADD = \ -$(top_builddir)/src/lib/ecore/libecore.la \ -@SSL_LIBS@ @CURL_LIBS@ @EINA_LIBS@ @TLS_LIBS@ @CARES_LIBS@ @WIN32_LIBS@ - -libecore_con_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ - -EXTRA_DIST = ecore_con_private.h diff --git a/libraries/ecore/src/lib/ecore_con/Makefile.in b/libraries/ecore/src/lib/ecore_con/Makefile.in deleted file mode 100644 index c35b08e..0000000 --- a/libraries/ecore/src/lib/ecore_con/Makefile.in +++ /dev/null @@ -1,935 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@ECORE_HAVE_WIN32_TRUE@am__append_1 = ecore_con_local_win32.c -@ECORE_HAVE_WIN32_FALSE@am__append_2 = ecore_con_local.c -@HAVE_CARES_TRUE@am__append_3 = ecore_con_ares.c -@HAVE_CARES_FALSE@am__append_4 = ecore_con_info.c -subdir = src/lib/ecore_con -DIST_COMMON = $(includes_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \ - $(top_srcdir)/m4/ac_path_generic.m4 \ - $(top_srcdir)/m4/check_x_extension.m4 \ - $(top_srcdir)/m4/ecore_check_module.m4 \ - $(top_srcdir)/m4/ecore_check_options.m4 \ - $(top_srcdir)/m4/efl_compiler_flag.m4 \ - $(top_srcdir)/m4/efl_doxygen.m4 \ - $(top_srcdir)/m4/efl_examples.m4 \ - $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ - $(top_srcdir)/m4/efl_threads.m4 $(top_srcdir)/m4/gettext.m4 \ - $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)" -LTLIBRARIES = $(lib_LTLIBRARIES) -libecore_con_la_DEPENDENCIES = \ - $(top_builddir)/src/lib/ecore/libecore.la -am__libecore_con_la_SOURCES_DIST = ecore_con.c ecore_con_socks.c \ - ecore_con_ssl.c ecore_con_url.c ecore_con_alloc.c \ - ecore_con_local_win32.c ecore_con_local.c ecore_con_ares.c \ - ecore_con_info.c -@ECORE_HAVE_WIN32_TRUE@am__objects_1 = libecore_con_la-ecore_con_local_win32.lo -@ECORE_HAVE_WIN32_FALSE@am__objects_2 = \ -@ECORE_HAVE_WIN32_FALSE@ libecore_con_la-ecore_con_local.lo -@HAVE_CARES_TRUE@am__objects_3 = libecore_con_la-ecore_con_ares.lo -@HAVE_CARES_FALSE@am__objects_4 = libecore_con_la-ecore_con_info.lo -am_libecore_con_la_OBJECTS = libecore_con_la-ecore_con.lo \ - libecore_con_la-ecore_con_socks.lo \ - libecore_con_la-ecore_con_ssl.lo \ - libecore_con_la-ecore_con_url.lo \ - libecore_con_la-ecore_con_alloc.lo $(am__objects_1) \ - $(am__objects_2) $(am__objects_3) $(am__objects_4) -libecore_con_la_OBJECTS = $(am_libecore_con_la_OBJECTS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) -am__v_lt_0 = --silent -libecore_con_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(libecore_con_la_CFLAGS) $(CFLAGS) $(libecore_con_la_LDFLAGS) \ - $(LDFLAGS) -o $@ -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_$(V)) -am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) -am__v_CC_0 = @echo " CC " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_$(V)) -am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CCLD_0 = @echo " CCLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libecore_con_la_SOURCES) -DIST_SOURCES = $(am__libecore_con_la_SOURCES_DIST) -HEADERS = $(includes_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AS = @AS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CARES_CFLAGS = @CARES_CFLAGS@ -CARES_LIBS = @CARES_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CHECK_CFLAGS = @CHECK_CFLAGS@ -CHECK_LIBS = @CHECK_LIBS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CURL_CFLAGS = @CURL_CFLAGS@ -CURL_LIBS = @CURL_LIBS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@ -DIRECTFB_LIBS = @DIRECTFB_LIBS@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -ECORE_XCB_CFLAGS = @ECORE_XCB_CFLAGS@ -ECORE_XCB_LIBS = @ECORE_XCB_LIBS@ -EFL_ECORE_BUILD = @EFL_ECORE_BUILD@ -EFL_ECORE_CON_BUILD = @EFL_ECORE_CON_BUILD@ -EFL_ECORE_EVAS_BUILD = @EFL_ECORE_EVAS_BUILD@ -EFL_ECORE_FILE_BUILD = @EFL_ECORE_FILE_BUILD@ -EFL_ECORE_IMF_BUILD = @EFL_ECORE_IMF_BUILD@ -EFL_ECORE_IMF_EVAS_BUILD = @EFL_ECORE_IMF_EVAS_BUILD@ -EFL_ECORE_INPUT_BUILD = @EFL_ECORE_INPUT_BUILD@ -EFL_ECORE_INPUT_EVAS_BUILD = @EFL_ECORE_INPUT_EVAS_BUILD@ -EFL_ECORE_IPC_BUILD = @EFL_ECORE_IPC_BUILD@ -EFL_ECORE_PSL1GHT_BUILD = @EFL_ECORE_PSL1GHT_BUILD@ -EFL_ECORE_SDL_BUILD = @EFL_ECORE_SDL_BUILD@ -EFL_ECORE_WIN32_BUILD = @EFL_ECORE_WIN32_BUILD@ -EFL_ECORE_WINCE_BUILD = @EFL_ECORE_WINCE_BUILD@ -EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@ -EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@ -EGREP = @EGREP@ -EINA_CFLAGS = @EINA_CFLAGS@ -EINA_LIBS = @EINA_LIBS@ -ESCAPE_CFLAGS = @ESCAPE_CFLAGS@ -ESCAPE_LIBS = @ESCAPE_LIBS@ -EVAS_CFLAGS = @EVAS_CFLAGS@ -EVAS_LIBS = @EVAS_LIBS@ -EVIL_CFLAGS = @EVIL_CFLAGS@ -EVIL_LIBS = @EVIL_LIBS@ -EXEEXT = @EXEEXT@ -EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ -EXOTIC_LIBS = @EXOTIC_LIBS@ -FGREP = @FGREP@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_LIBS = @GLIB_LIBS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -KEYSYMDEFS = @KEYSYMDEFS@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJC = @OBJC@ -OBJCDEPMODE = @OBJCDEPMODE@ -OBJCFLAGS = @OBJCFLAGS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ -PIXMAN_LIBS = @PIXMAN_LIBS@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POSUB = @POSUB@ -RANLIB = @RANLIB@ -SCIM_CFLAGS = @SCIM_CFLAGS@ -SCIM_LIBS = @SCIM_LIBS@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ -SDL_LIBS = @SDL_LIBS@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -SHM_OPEN_LIBS = @SHM_OPEN_LIBS@ -SSL_CFLAGS = @SSL_CFLAGS@ -SSL_LIBS = @SSL_LIBS@ -STRIP = @STRIP@ -TLS2_CFLAGS = @TLS2_CFLAGS@ -TLS2_LIBS = @TLS2_LIBS@ -TLS_CFLAGS = @TLS_CFLAGS@ -TLS_LIBS = @TLS_LIBS@ -TSLIB_CFLAGS = @TSLIB_CFLAGS@ -TSLIB_LIBS = @TSLIB_LIBS@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -VMAJ = @VMAJ@ -WAYLAND_CFLAGS = @WAYLAND_CFLAGS@ -WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@ -WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@ -WAYLAND_LIBS = @WAYLAND_LIBS@ -WIN32_CFLAGS = @WIN32_CFLAGS@ -WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ -WIN32_LIBS = @WIN32_LIBS@ -XCB_COMPOSITE_CFLAGS = @XCB_COMPOSITE_CFLAGS@ -XCB_COMPOSITE_LIBS = @XCB_COMPOSITE_LIBS@ -XCB_CURSOR_CFLAGS = @XCB_CURSOR_CFLAGS@ -XCB_CURSOR_LIBS = @XCB_CURSOR_LIBS@ -XCB_DAMAGE_CFLAGS = @XCB_DAMAGE_CFLAGS@ -XCB_DAMAGE_LIBS = @XCB_DAMAGE_LIBS@ -XCB_DPMS_CFLAGS = @XCB_DPMS_CFLAGS@ -XCB_DPMS_LIBS = @XCB_DPMS_LIBS@ -XCB_RANDR_CFLAGS = @XCB_RANDR_CFLAGS@ -XCB_RANDR_LIBS = @XCB_RANDR_LIBS@ -XCB_RENDER_CFLAGS = @XCB_RENDER_CFLAGS@ -XCB_RENDER_LIBS = @XCB_RENDER_LIBS@ -XCB_SCREENSAVER_CFLAGS = @XCB_SCREENSAVER_CFLAGS@ -XCB_SCREENSAVER_LIBS = @XCB_SCREENSAVER_LIBS@ -XCB_SHAPE_CFLAGS = @XCB_SHAPE_CFLAGS@ -XCB_SHAPE_LIBS = @XCB_SHAPE_LIBS@ -XCB_SYNC_CFLAGS = @XCB_SYNC_CFLAGS@ -XCB_SYNC_LIBS = @XCB_SYNC_LIBS@ -XCB_X11_CFLAGS = @XCB_X11_CFLAGS@ -XCB_X11_LIBS = @XCB_X11_LIBS@ -XCB_XFIXES_CFLAGS = @XCB_XFIXES_CFLAGS@ -XCB_XFIXES_LIBS = @XCB_XFIXES_LIBS@ -XCB_XGESTURE_CFLAGS = @XCB_XGESTURE_CFLAGS@ -XCB_XGESTURE_LIBS = @XCB_XGESTURE_LIBS@ -XCB_XINERAMA_CFLAGS = @XCB_XINERAMA_CFLAGS@ -XCB_XINERAMA_LIBS = @XCB_XINERAMA_LIBS@ -XCB_XINPUT_CFLAGS = @XCB_XINPUT_CFLAGS@ -XCB_XINPUT_LIBS = @XCB_XINPUT_LIBS@ -XCB_XPRINT_CFLAGS = @XCB_XPRINT_CFLAGS@ -XCB_XPRINT_LIBS = @XCB_XPRINT_LIBS@ -XCB_XTEST_CFLAGS = @XCB_XTEST_CFLAGS@ -XCB_XTEST_LIBS = @XCB_XTEST_LIBS@ -XCOMPOSITE_CFLAGS = @XCOMPOSITE_CFLAGS@ -XCOMPOSITE_LIBS = @XCOMPOSITE_LIBS@ -XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@ -XDAMAGE_LIBS = @XDAMAGE_LIBS@ -XDPMS_CFLAGS = @XDPMS_CFLAGS@ -XDPMS_LIBS = @XDPMS_LIBS@ -XFIXES_CFLAGS = @XFIXES_CFLAGS@ -XFIXES_LIBS = @XFIXES_LIBS@ -XGESTURE_CFLAGS = @XGESTURE_CFLAGS@ -XGESTURE_LIBS = @XGESTURE_LIBS@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -XI2_CFLAGS = @XI2_CFLAGS@ -XI2_LIBS = @XI2_LIBS@ -XINERAMA_CFLAGS = @XINERAMA_CFLAGS@ -XINERAMA_LIBS = @XINERAMA_LIBS@ -XKB_CFLAGS = @XKB_CFLAGS@ -XKB_LIBS = @XKB_LIBS@ -XMKMF = @XMKMF@ -XPRINT_CFLAGS = @XPRINT_CFLAGS@ -XPRINT_LIBS = @XPRINT_LIBS@ -XRANDR_CFLAGS = @XRANDR_CFLAGS@ -XRANDR_LIBS = @XRANDR_LIBS@ -XRENDER_CFLAGS = @XRENDER_CFLAGS@ -XRENDER_LIBS = @XRENDER_LIBS@ -XSS_CFLAGS = @XSS_CFLAGS@ -XSS_LIBS = @XSS_LIBS@ -XTEST_CFLAGS = @XTEST_CFLAGS@ -XTEST_LIBS = @XTEST_LIBS@ -X_CFLAGS = @X_CFLAGS@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_LIBS = @X_LIBS@ -X_PRE_LIBS = @X_PRE_LIBS@ -Xcursor_cflags = @Xcursor_cflags@ -Xcursor_libs = @Xcursor_libs@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_OBJC = @ac_ct_OBJC@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -cocoa_ldflags = @cocoa_ldflags@ -datadir = @datadir@ -datarootdir = @datarootdir@ -dlopen_libs = @dlopen_libs@ -docdir = @docdir@ -dvidir = @dvidir@ -ecore_cocoa_cflags = @ecore_cocoa_cflags@ -ecore_cocoa_libs = @ecore_cocoa_libs@ -ecore_con_cflags = @ecore_con_cflags@ -ecore_con_libs = @ecore_con_libs@ -ecore_directfb_cflags = @ecore_directfb_cflags@ -ecore_directfb_libs = @ecore_directfb_libs@ -ecore_evas_cflags = @ecore_evas_cflags@ -ecore_evas_libs = @ecore_evas_libs@ -ecore_fb_cflags = @ecore_fb_cflags@ -ecore_fb_libs = @ecore_fb_libs@ -ecore_file_cflags = @ecore_file_cflags@ -ecore_file_libs = @ecore_file_libs@ -ecore_imf_cflags = @ecore_imf_cflags@ -ecore_imf_evas_cflags = @ecore_imf_evas_cflags@ -ecore_imf_evas_libs = @ecore_imf_evas_libs@ -ecore_imf_libs = @ecore_imf_libs@ -ecore_imf_scim_cflags = @ecore_imf_scim_cflags@ -ecore_imf_scim_libs = @ecore_imf_scim_libs@ -ecore_imf_xim_cflags = @ecore_imf_xim_cflags@ -ecore_imf_xim_libs = @ecore_imf_xim_libs@ -ecore_input_cflags = @ecore_input_cflags@ -ecore_input_evas_cflags = @ecore_input_evas_cflags@ -ecore_input_evas_libs = @ecore_input_evas_libs@ -ecore_input_libs = @ecore_input_libs@ -ecore_ipc_cflags = @ecore_ipc_cflags@ -ecore_ipc_libs = @ecore_ipc_libs@ -ecore_psl1ght_cflags = @ecore_psl1ght_cflags@ -ecore_psl1ght_libs = @ecore_psl1ght_libs@ -ecore_sdl_cflags = @ecore_sdl_cflags@ -ecore_sdl_libs = @ecore_sdl_libs@ -ecore_wayland_cflags = @ecore_wayland_cflags@ -ecore_wayland_libs = @ecore_wayland_libs@ -ecore_win32_cflags = @ecore_win32_cflags@ -ecore_win32_libs = @ecore_win32_libs@ -ecore_wince_cflags = @ecore_wince_cflags@ -ecore_wince_libs = @ecore_wince_libs@ -ecore_x_cflags = @ecore_x_cflags@ -ecore_x_libs = @ecore_x_libs@ -ecore_x_libs_private = @ecore_x_libs_private@ -efl_doxygen = @efl_doxygen@ -efl_have_doxygen = @efl_have_doxygen@ -exec_prefix = @exec_prefix@ -have_ecore_x_xcb_define = @have_ecore_x_xcb_define@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ -lt_enable_auto_import = @lt_enable_auto_import@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -pkgconfig_requires_private = @pkgconfig_requires_private@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -release_info = @release_info@ -requirements_ecore = @requirements_ecore@ -requirements_ecore_cocoa = @requirements_ecore_cocoa@ -requirements_ecore_con = @requirements_ecore_con@ -requirements_ecore_directfb = @requirements_ecore_directfb@ -requirements_ecore_evas = @requirements_ecore_evas@ -requirements_ecore_fb = @requirements_ecore_fb@ -requirements_ecore_file = @requirements_ecore_file@ -requirements_ecore_imf = @requirements_ecore_imf@ -requirements_ecore_imf_evas = @requirements_ecore_imf_evas@ -requirements_ecore_imf_scim = @requirements_ecore_imf_scim@ -requirements_ecore_imf_xim = @requirements_ecore_imf_xim@ -requirements_ecore_input = @requirements_ecore_input@ -requirements_ecore_input_evas = @requirements_ecore_input_evas@ -requirements_ecore_ipc = @requirements_ecore_ipc@ -requirements_ecore_psl1ght = @requirements_ecore_psl1ght@ -requirements_ecore_sdl = @requirements_ecore_sdl@ -requirements_ecore_wayland = @requirements_ecore_wayland@ -requirements_ecore_win32 = @requirements_ecore_win32@ -requirements_ecore_wince = @requirements_ecore_wince@ -requirements_ecore_x = @requirements_ecore_x@ -rt_libs = @rt_libs@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -version_info = @version_info@ -x_cflags = @x_cflags@ -x_includes = @x_includes@ -x_libs = @x_libs@ -MAINTAINERCLEANFILES = Makefile.in -AM_CPPFLAGS = \ --I$(top_builddir)/src/lib/ecore \ --I$(top_builddir)/src/lib/ecore_con \ --I$(top_srcdir)/src/lib/ecore \ --I$(top_srcdir)/src/lib/ecore_con \ -@EFL_ECORE_CON_BUILD@ \ -@SSL_CFLAGS@ \ -@CURL_CFLAGS@ \ -@EINA_CFLAGS@ \ -@TLS_CFLAGS@ \ -@CARES_CFLAGS@ \ -@WIN32_CPPFLAGS@ - -lib_LTLIBRARIES = libecore_con.la -includes_HEADERS = Ecore_Con.h -includesdir = $(includedir)/ecore-@VMAJ@ -libecore_con_la_SOURCES = ecore_con.c ecore_con_socks.c \ - ecore_con_ssl.c ecore_con_url.c ecore_con_alloc.c \ - $(am__append_1) $(am__append_2) $(am__append_3) \ - $(am__append_4) -libecore_con_la_CFLAGS = @WIN32_CFLAGS@ -libecore_con_la_LIBADD = \ -$(top_builddir)/src/lib/ecore/libecore.la \ -@SSL_LIBS@ @CURL_LIBS@ @EINA_LIBS@ @TLS_LIBS@ @CARES_LIBS@ @WIN32_LIBS@ - -libecore_con_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ -EXTRA_DIST = ecore_con_private.h -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/ecore_con/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/lib/ecore_con/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ - } - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done -libecore_con.la: $(libecore_con_la_OBJECTS) $(libecore_con_la_DEPENDENCIES) - $(AM_V_CCLD)$(libecore_con_la_LINK) -rpath $(libdir) $(libecore_con_la_OBJECTS) $(libecore_con_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con_alloc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con_ares.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con_info.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con_local.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con_local_win32.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con_socks.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con_ssl.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libecore_con_la-ecore_con_url.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -libecore_con_la-ecore_con.lo: ecore_con.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con.Tpo -c -o libecore_con_la-ecore_con.lo `test -f 'ecore_con.c' || echo '$(srcdir)/'`ecore_con.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con.Tpo $(DEPDIR)/libecore_con_la-ecore_con.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con.c' object='libecore_con_la-ecore_con.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con.lo `test -f 'ecore_con.c' || echo '$(srcdir)/'`ecore_con.c - -libecore_con_la-ecore_con_socks.lo: ecore_con_socks.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con_socks.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con_socks.Tpo -c -o libecore_con_la-ecore_con_socks.lo `test -f 'ecore_con_socks.c' || echo '$(srcdir)/'`ecore_con_socks.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con_socks.Tpo $(DEPDIR)/libecore_con_la-ecore_con_socks.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con_socks.c' object='libecore_con_la-ecore_con_socks.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con_socks.lo `test -f 'ecore_con_socks.c' || echo '$(srcdir)/'`ecore_con_socks.c - -libecore_con_la-ecore_con_ssl.lo: ecore_con_ssl.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con_ssl.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con_ssl.Tpo -c -o libecore_con_la-ecore_con_ssl.lo `test -f 'ecore_con_ssl.c' || echo '$(srcdir)/'`ecore_con_ssl.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con_ssl.Tpo $(DEPDIR)/libecore_con_la-ecore_con_ssl.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con_ssl.c' object='libecore_con_la-ecore_con_ssl.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con_ssl.lo `test -f 'ecore_con_ssl.c' || echo '$(srcdir)/'`ecore_con_ssl.c - -libecore_con_la-ecore_con_url.lo: ecore_con_url.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con_url.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con_url.Tpo -c -o libecore_con_la-ecore_con_url.lo `test -f 'ecore_con_url.c' || echo '$(srcdir)/'`ecore_con_url.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con_url.Tpo $(DEPDIR)/libecore_con_la-ecore_con_url.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con_url.c' object='libecore_con_la-ecore_con_url.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con_url.lo `test -f 'ecore_con_url.c' || echo '$(srcdir)/'`ecore_con_url.c - -libecore_con_la-ecore_con_alloc.lo: ecore_con_alloc.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con_alloc.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con_alloc.Tpo -c -o libecore_con_la-ecore_con_alloc.lo `test -f 'ecore_con_alloc.c' || echo '$(srcdir)/'`ecore_con_alloc.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con_alloc.Tpo $(DEPDIR)/libecore_con_la-ecore_con_alloc.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con_alloc.c' object='libecore_con_la-ecore_con_alloc.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con_alloc.lo `test -f 'ecore_con_alloc.c' || echo '$(srcdir)/'`ecore_con_alloc.c - -libecore_con_la-ecore_con_local_win32.lo: ecore_con_local_win32.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con_local_win32.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con_local_win32.Tpo -c -o libecore_con_la-ecore_con_local_win32.lo `test -f 'ecore_con_local_win32.c' || echo '$(srcdir)/'`ecore_con_local_win32.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con_local_win32.Tpo $(DEPDIR)/libecore_con_la-ecore_con_local_win32.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con_local_win32.c' object='libecore_con_la-ecore_con_local_win32.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con_local_win32.lo `test -f 'ecore_con_local_win32.c' || echo '$(srcdir)/'`ecore_con_local_win32.c - -libecore_con_la-ecore_con_local.lo: ecore_con_local.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con_local.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con_local.Tpo -c -o libecore_con_la-ecore_con_local.lo `test -f 'ecore_con_local.c' || echo '$(srcdir)/'`ecore_con_local.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con_local.Tpo $(DEPDIR)/libecore_con_la-ecore_con_local.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con_local.c' object='libecore_con_la-ecore_con_local.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con_local.lo `test -f 'ecore_con_local.c' || echo '$(srcdir)/'`ecore_con_local.c - -libecore_con_la-ecore_con_ares.lo: ecore_con_ares.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con_ares.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con_ares.Tpo -c -o libecore_con_la-ecore_con_ares.lo `test -f 'ecore_con_ares.c' || echo '$(srcdir)/'`ecore_con_ares.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con_ares.Tpo $(DEPDIR)/libecore_con_la-ecore_con_ares.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con_ares.c' object='libecore_con_la-ecore_con_ares.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con_ares.lo `test -f 'ecore_con_ares.c' || echo '$(srcdir)/'`ecore_con_ares.c - -libecore_con_la-ecore_con_info.lo: ecore_con_info.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -MT libecore_con_la-ecore_con_info.lo -MD -MP -MF $(DEPDIR)/libecore_con_la-ecore_con_info.Tpo -c -o libecore_con_la-ecore_con_info.lo `test -f 'ecore_con_info.c' || echo '$(srcdir)/'`ecore_con_info.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libecore_con_la-ecore_con_info.Tpo $(DEPDIR)/libecore_con_la-ecore_con_info.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ecore_con_info.c' object='libecore_con_la-ecore_con_info.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libecore_con_la_CFLAGS) $(CFLAGS) -c -o libecore_con_la-ecore_con_info.lo `test -f 'ecore_con_info.c' || echo '$(srcdir)/'`ecore_con_info.c - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-includesHEADERS: $(includes_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(includesdir)" || $(MKDIR_P) "$(DESTDIR)$(includesdir)" - @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includesdir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(includesdir)" || exit $$?; \ - done - -uninstall-includesHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(includesdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(includesdir)" && rm -f $$files - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) -clean: clean-am - -clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-includesHEADERS - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-libLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-includesHEADERS uninstall-libLTLIBRARIES - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libLTLIBRARIES clean-libtool ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-includesHEADERS install-info \ - install-info-am install-libLTLIBRARIES install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-includesHEADERS \ - uninstall-libLTLIBRARIES - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con.c b/libraries/ecore/src/lib/ecore_con/ecore_con.c deleted file mode 100644 index fe83478..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con.c +++ /dev/null @@ -1,2583 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_NETINET_TCP_H -# include -#endif - -#ifdef HAVE_NETINET_IN_H -# include -#endif - -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - -#ifdef HAVE_SYS_UN_H -# include -#endif - -#ifdef HAVE_WS2TCPIP_H -# include -#endif - -#ifdef HAVE_EVIL -# include -#endif - -#include "Ecore.h" -#include "ecore_private.h" -#include "Ecore_Con.h" -#include "ecore_con_private.h" - -static Eina_Bool _ecore_con_client_timer(Ecore_Con_Client *cl); -static void _ecore_con_cl_timer_update(Ecore_Con_Client *cl); -static Eina_Bool _ecore_con_server_timer(Ecore_Con_Server *svr); -static void _ecore_con_server_timer_update(Ecore_Con_Server *svr); - -static void _ecore_con_cb_tcp_connect(void *data, - Ecore_Con_Info *info); -static void _ecore_con_cb_udp_connect(void *data, - Ecore_Con_Info *info); -static void _ecore_con_cb_tcp_listen(void *data, - Ecore_Con_Info *info); -static void _ecore_con_cb_udp_listen(void *data, - Ecore_Con_Info *info); - -static void _ecore_con_server_free(Ecore_Con_Server *svr); -static void _ecore_con_client_free(Ecore_Con_Client *cl); - -static void _ecore_con_cl_read(Ecore_Con_Server *svr); -static Eina_Bool _ecore_con_svr_tcp_handler(void *data, - Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_cl_handler(void *data, - Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_cl_udp_handler(void *data, - Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_svr_udp_handler(void *data, - Ecore_Fd_Handler *fd_handler); - -static void _ecore_con_svr_cl_read(Ecore_Con_Client *cl); -static Eina_Bool _ecore_con_svr_cl_handler(void *data, - Ecore_Fd_Handler *fd_handler); - -static void _ecore_con_server_flush(Ecore_Con_Server *svr); -static void _ecore_con_client_flush(Ecore_Con_Client *cl); - -static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr, - void *ev); -static void _ecore_con_event_client_del_free(Ecore_Con_Server *svr, - void *ev); -static void _ecore_con_event_client_data_free(Ecore_Con_Server *svr, - void *ev); -static void _ecore_con_event_server_add_free(void *data, - void *ev); -static void _ecore_con_event_server_del_free(void *data, - void *ev); -static void _ecore_con_event_server_data_free(void *data, - void *ev); -static void _ecore_con_event_server_error_free(void *data, - Ecore_Con_Event_Server_Error *e); -static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr, - Ecore_Con_Event_Client_Error *e); -static void _ecore_con_event_server_write_free(void *data, - Ecore_Con_Event_Server_Write *e); -static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr, - Ecore_Con_Event_Client_Write *e); - -static void _ecore_con_lookup_done(void *data, - Ecore_Con_Info *infos); - -static const char * _ecore_con_pretty_ip(struct sockaddr *client_addr); - - -void -_ecore_con_client_kill(Ecore_Con_Client *cl) -{ - if (cl->delete_me) - DBG("Multi kill request for client %p", cl); - else - { - ecore_con_event_client_del(cl); - if (cl->buf) return; - } - INF("Lost client %s", (cl->ip) ? cl->ip : ""); - if (cl->fd_handler) - ecore_main_fd_handler_del(cl->fd_handler); - - cl->fd_handler = NULL; -} - -void -_ecore_con_server_kill(Ecore_Con_Server *svr) -{ - if (svr->delete_me) - DBG("Multi kill request for svr %p", svr); - else - ecore_con_event_server_del(svr); - - if (svr->fd_handler) - ecore_main_fd_handler_del(svr->fd_handler); - - svr->fd_handler = NULL; -} - -#define _ecore_con_server_kill(svr) do { \ - DBG("KILL %p", (svr)); \ - _ecore_con_server_kill((svr)); \ -} while (0) - -#define _ecore_con_client_kill(cl) do { \ - DBG("KILL %p", (cl)); \ - _ecore_con_client_kill((cl)); \ -} while (0) - -EAPI int ECORE_CON_EVENT_CLIENT_ADD = 0; -EAPI int ECORE_CON_EVENT_CLIENT_DEL = 0; -EAPI int ECORE_CON_EVENT_SERVER_ADD = 0; -EAPI int ECORE_CON_EVENT_SERVER_DEL = 0; -EAPI int ECORE_CON_EVENT_CLIENT_DATA = 0; -EAPI int ECORE_CON_EVENT_SERVER_DATA = 0; -EAPI int ECORE_CON_EVENT_CLIENT_WRITE = 0; -EAPI int ECORE_CON_EVENT_SERVER_WRITE = 0; -EAPI int ECORE_CON_EVENT_CLIENT_ERROR = 0; -EAPI int ECORE_CON_EVENT_SERVER_ERROR = 0; -EAPI int ECORE_CON_EVENT_PROXY_BIND = 0; - -static Eina_List *servers = NULL; -static int _ecore_con_init_count = 0; -static int _ecore_con_event_count = 0; -int _ecore_con_log_dom = -1; -Ecore_Con_Socks *_ecore_con_proxy_once = NULL; -Ecore_Con_Socks *_ecore_con_proxy_global = NULL; - -EAPI int -ecore_con_init(void) -{ - if (++_ecore_con_init_count != 1) - return _ecore_con_init_count; - -#ifdef HAVE_EVIL - if (!evil_init()) - return --_ecore_con_init_count; - -#endif - - if (!ecore_init()) - return --_ecore_con_init_count; - - _ecore_con_log_dom = eina_log_domain_register - ("ecore_con", ECORE_CON_DEFAULT_LOG_COLOR); - if (_ecore_con_log_dom < 0) - { - EINA_LOG_ERR("Impossible to create a log domain for Ecore Con."); - ecore_shutdown(); - return --_ecore_con_init_count; - } - - ecore_con_mempool_init(); - - ECORE_CON_EVENT_CLIENT_ADD = ecore_event_type_new(); - ECORE_CON_EVENT_CLIENT_DEL = ecore_event_type_new(); - ECORE_CON_EVENT_SERVER_ADD = ecore_event_type_new(); - ECORE_CON_EVENT_SERVER_DEL = ecore_event_type_new(); - ECORE_CON_EVENT_CLIENT_DATA = ecore_event_type_new(); - ECORE_CON_EVENT_SERVER_DATA = ecore_event_type_new(); - ECORE_CON_EVENT_CLIENT_WRITE = ecore_event_type_new(); - ECORE_CON_EVENT_SERVER_WRITE = ecore_event_type_new(); - ECORE_CON_EVENT_CLIENT_ERROR = ecore_event_type_new(); - ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new(); - ECORE_CON_EVENT_PROXY_BIND = ecore_event_type_new(); - - - eina_magic_string_set(ECORE_MAGIC_CON_SERVER, "Ecore_Con_Server"); - eina_magic_string_set(ECORE_MAGIC_CON_CLIENT, "Ecore_Con_Server"); - eina_magic_string_set(ECORE_MAGIC_CON_URL, "Ecore_Con_Url"); - - /* TODO Remember return value, if it fails, use gethostbyname() */ - ecore_con_socks_init(); - ecore_con_ssl_init(); - ecore_con_info_init(); - - return _ecore_con_init_count; -} - -EAPI int -ecore_con_shutdown(void) -{ - Eina_List *l, *l2; - Ecore_Con_Server *svr; - - if (--_ecore_con_init_count != 0) - return _ecore_con_init_count; - - EINA_LIST_FOREACH_SAFE(servers, l, l2, svr) - { - Ecore_Con_Event_Server_Add *ev; - - svr->delete_me = EINA_TRUE; - INF("svr %p is dead", svr); - /* some pointer hacks here to prevent double frees if people are being stupid */ - EINA_LIST_FREE(svr->event_count, ev) - ev->server = NULL; - _ecore_con_server_free(svr); - } - - ecore_con_socks_shutdown(); - if (!_ecore_con_event_count) ecore_con_mempool_shutdown(); - - ecore_con_info_shutdown(); - ecore_con_ssl_shutdown(); - eina_log_domain_unregister(_ecore_con_log_dom); - _ecore_con_log_dom = -1; - ecore_shutdown(); -#ifdef HAVE_EVIL - evil_shutdown(); -#endif - - return _ecore_con_init_count; -} - -EAPI Eina_Bool -ecore_con_lookup(const char *name, - Ecore_Con_Dns_Cb done_cb, - const void *data) -{ - Ecore_Con_Server *svr; - Ecore_Con_Lookup *lk; - struct addrinfo hints; - - if (!name || !done_cb) - return EINA_FALSE; - - svr = calloc(1, sizeof(Ecore_Con_Server)); - if (!svr) - return EINA_FALSE; - - lk = malloc(sizeof (Ecore_Con_Lookup)); - if (!lk) - { - free(svr); - return EINA_FALSE; - } - - lk->done_cb = done_cb; - lk->data = data; - - svr->name = strdup(name); - if (!svr->name) - goto on_error; - - svr->type = ECORE_CON_REMOTE_TCP; - svr->port = 1025; - svr->data = lk; - svr->created = EINA_TRUE; - svr->reject_excess_clients = EINA_FALSE; - svr->client_limit = -1; - svr->clients = NULL; - svr->ppid = getpid(); - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_CANONNAME; - hints.ai_protocol = IPPROTO_TCP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - if (ecore_con_info_get(svr, _ecore_con_lookup_done, svr, - &hints)) - return EINA_TRUE; - - free(svr->name); -on_error: - free(lk); - free(svr); - return EINA_FALSE; -} - -/** - * @addtogroup Ecore_Con_Server_Group Ecore Connection Server Functions - * - * Functions that operate on Ecore server objects. - * - * @{ - */ - -/** - * @example ecore_con_server_example.c - * Shows how to write a simple server using the Ecore_Con library. - */ - -EAPI Ecore_Con_Server * -ecore_con_server_add(Ecore_Con_Type compl_type, - const char *name, - int port, - const void *data) -{ - Ecore_Con_Server *svr; - Ecore_Con_Type type; - - if (port < 0 || !name) - return NULL; /* local user socket: FILE: ~/.ecore/[name]/[port] */ - - /* local system socket: FILE: /tmp/.ecore_service|[name]|[port] */ - /* remote system socket: TCP/IP: [name]:[port] */ - svr = calloc(1, sizeof(Ecore_Con_Server)); - if (!svr) - return NULL; - - svr->name = strdup(name); - if (!svr->name) - goto error; - - svr->type = compl_type; - svr->port = port; - svr->data = (void *)data; - svr->created = EINA_TRUE; - svr->use_cert = (compl_type & ECORE_CON_SSL & ECORE_CON_LOAD_CERT) == ECORE_CON_LOAD_CERT; - svr->reject_excess_clients = EINA_FALSE; - svr->client_limit = -1; - svr->clients = NULL; - svr->ppid = getpid(); - if (ecore_con_ssl_server_prepare(svr, compl_type & ECORE_CON_SSL)) - goto error; - - type = compl_type & ECORE_CON_TYPE; - - if ((type == ECORE_CON_LOCAL_USER) || - (type == ECORE_CON_LOCAL_SYSTEM) || - (type == ECORE_CON_LOCAL_ABSTRACT)) - /* Local */ -#ifdef _WIN32 - if (!ecore_con_local_listen(svr)) - goto error; -#else - if (!ecore_con_local_listen(svr, _ecore_con_svr_tcp_handler, svr)) - goto error; -#endif - - if ((type == ECORE_CON_REMOTE_TCP) || - (type == ECORE_CON_REMOTE_NODELAY) || - (type == ECORE_CON_REMOTE_CORK)) - { - /* TCP */ - if (!ecore_con_info_tcp_listen(svr, _ecore_con_cb_tcp_listen, - svr)) - goto error; - } - else if ((type == ECORE_CON_REMOTE_MCAST) || - (type == ECORE_CON_REMOTE_UDP)) - /* UDP and MCAST */ - if (!ecore_con_info_udp_listen(svr, _ecore_con_cb_udp_listen, - svr)) - goto error; - - servers = eina_list_append(servers, svr); - ECORE_MAGIC_SET(svr, ECORE_MAGIC_CON_SERVER); - - return svr; - -error: - if (svr->name) - free(svr->name); - - if (svr->path) - free(svr->path); - - - if (svr->fd_handler) - ecore_main_fd_handler_del(svr->fd_handler); - - if (svr->fd > 0) - close(svr->fd); - - if (svr->buf) - eina_binbuf_free(svr->buf); - - if (svr->ip) - eina_stringshare_del(svr->ip); - - ecore_con_ssl_server_shutdown(svr); - free(svr); - return NULL; -} - -EAPI Ecore_Con_Server * -ecore_con_server_connect(Ecore_Con_Type compl_type, - const char *name, - int port, - const void *data) -{ - Ecore_Con_Server *svr; - Ecore_Con_Type type; - - if ((!name) || (!name[0])) - return NULL; - /* local user socket: FILE: ~/.ecore/[name]/[port] */ - /* local system socket: FILE: /tmp/.ecore_service|[name]|[port] */ - /* remote system socket: TCP/IP: [name]:[port] */ - svr = calloc(1, sizeof(Ecore_Con_Server)); - if (!svr) - return NULL; - - svr->name = strdup(name); - if (!svr->name) - goto error; - - svr->type = compl_type; - svr->port = port; - svr->data = (void *)data; - svr->created = EINA_FALSE; - svr->use_cert = (compl_type & ECORE_CON_SSL & ECORE_CON_LOAD_CERT) == ECORE_CON_LOAD_CERT; - svr->reject_excess_clients = EINA_FALSE; - svr->clients = NULL; - svr->client_limit = -1; - - type = compl_type & ECORE_CON_TYPE; - - if (type > ECORE_CON_LOCAL_ABSTRACT) - { - /* never use proxies on local connections */ - if (_ecore_con_proxy_once) - svr->ecs = _ecore_con_proxy_once; - else if (_ecore_con_proxy_global) - svr->ecs = _ecore_con_proxy_global; - _ecore_con_proxy_once = NULL; - if (svr->ecs) - { - if ((!svr->ecs->lookup) && - (!ecore_con_lookup(svr->name, (Ecore_Con_Dns_Cb)ecore_con_socks_dns_cb, svr))) - goto error; - if (svr->ecs->lookup) - svr->ecs_state = ECORE_CON_PROXY_STATE_RESOLVED; - } - } - if (ecore_con_ssl_server_prepare(svr, compl_type & ECORE_CON_SSL)) - goto error; - - if (((type == ECORE_CON_REMOTE_TCP) || - (type == ECORE_CON_REMOTE_NODELAY) || - (type == ECORE_CON_REMOTE_CORK) || - (type == ECORE_CON_REMOTE_UDP) || - (type == ECORE_CON_REMOTE_BROADCAST)) && - (port < 0)) - goto error; - - if ((type == ECORE_CON_LOCAL_USER) || - (type == ECORE_CON_LOCAL_SYSTEM) || - (type == ECORE_CON_LOCAL_ABSTRACT)) - /* Local */ -#ifdef _WIN32 - if (!ecore_con_local_connect(svr, _ecore_con_cl_handler)) - goto error; -#else - if (!ecore_con_local_connect(svr, _ecore_con_cl_handler, svr)) - goto error; -#endif - - if ((type == ECORE_CON_REMOTE_TCP) || - (type == ECORE_CON_REMOTE_NODELAY) || - (type == ECORE_CON_REMOTE_CORK)) - { - /* TCP */ - if (!ecore_con_info_tcp_connect(svr, _ecore_con_cb_tcp_connect, - svr)) - goto error; - } - else if ((type == ECORE_CON_REMOTE_UDP) || - (type == ECORE_CON_REMOTE_BROADCAST)) - /* UDP and MCAST */ - if (!ecore_con_info_udp_connect(svr, _ecore_con_cb_udp_connect, - svr)) - goto error; - - servers = eina_list_append(servers, svr); - ECORE_MAGIC_SET(svr, ECORE_MAGIC_CON_SERVER); - - return svr; - -error: - if (svr->name) - free(svr->name); - - if (svr->path) - free(svr->path); - - if (svr->fd_handler) - ecore_main_fd_handler_del(svr->fd_handler); - - if (svr->fd > 0) - close(svr->fd); - - ecore_con_ssl_server_shutdown(svr); - free(svr); - return NULL; -} - -EAPI void -ecore_con_server_timeout_set(Ecore_Con_Server *svr, - double timeout) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_timeout_set"); - return; - } - - if (svr->created) - svr->client_disconnect_time = timeout; - else - svr->disconnect_time = timeout; -} - -EAPI double -ecore_con_server_timeout_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_timeout_get"); - return 0; - } - - return svr->created ? svr->client_disconnect_time : svr->disconnect_time; -} - -EAPI void * -ecore_con_server_del(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_del"); - return NULL; - } - - if (svr->delete_me) - return NULL; - - _ecore_con_server_kill(svr); - return svr->data; -} - -EAPI void * -ecore_con_server_data_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_data_get"); - return NULL; - } - - return svr->data; -} - -EAPI void * -ecore_con_server_data_set(Ecore_Con_Server *svr, - void *data) -{ - void *ret = NULL; - - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_data_get"); - return NULL; - } - - ret = svr->data; - svr->data = data; - return ret; -} - -EAPI Eina_Bool -ecore_con_server_connected_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_connected_get"); - return EINA_FALSE; - } - - if (svr->connecting) - return EINA_FALSE; - - return EINA_TRUE; -} - -EAPI const Eina_List * -ecore_con_server_clients_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, - "ecore_con_server_clients_get"); - return NULL; - } - - return svr->clients; -} - -EAPI const char * -ecore_con_server_name_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, - "ecore_con_server_name_get"); - return NULL; - } - - return svr->name; -} - -EAPI int -ecore_con_server_port_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, - "ecore_con_server_port_get"); - return -1; - } - return svr->port; -} - -EAPI int -ecore_con_server_send(Ecore_Con_Server *svr, - const void *data, - int size) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_send"); - return 0; - } - - EINA_SAFETY_ON_TRUE_RETURN_VAL(svr->delete_me, 0); - - EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); - - EINA_SAFETY_ON_TRUE_RETURN_VAL(size < 1, 0); - - if (svr->fd_handler) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE); - - if (!svr->buf) - { - svr->buf = eina_binbuf_new(); - EINA_SAFETY_ON_NULL_RETURN_VAL(svr->buf, 0); -#ifdef TCP_CORK - if ((svr->fd >= 0) && ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_CORK)) - { - int state = 1; - if (setsockopt(svr->fd, IPPROTO_TCP, TCP_CORK, (char *)&state, sizeof(int)) < 0) - /* realistically this isn't anything serious so we can just log and continue */ - ERR("corking failed! %s", strerror(errno)); - } -#endif - } - eina_binbuf_append_length(svr->buf, data, size); - - return size; -} - -EAPI void -ecore_con_server_client_limit_set(Ecore_Con_Server *svr, - int client_limit, - char reject_excess_clients) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, - "ecore_con_server_client_limit_set"); - return; - } - - svr->client_limit = client_limit; - svr->reject_excess_clients = reject_excess_clients; -} - -EAPI const char * -ecore_con_server_ip_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_ip_get"); - return NULL; - } - - return svr->ip; -} - -EAPI double -ecore_con_server_uptime_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_uptime_get"); - return -1; - } - - return ecore_time_get() - svr->start_time; -} - -EAPI void -ecore_con_server_flush(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_flush"); - return; - } - - _ecore_con_server_flush(svr); -} - -/** - * @} - */ - -/** - * @addtogroup Ecore_Con_Client_Group Ecore Connection Client Functions - * - * Functions that operate on Ecore connection client objects. - * - * @{ - */ - -/** - * @example ecore_con_client_example.c - * Shows how to write a simple client that connects to the example server. - */ - -EAPI int -ecore_con_client_send(Ecore_Con_Client *cl, - const void *data, - int size) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_send"); - return 0; - } - - EINA_SAFETY_ON_TRUE_RETURN_VAL(cl->delete_me, 0); - - EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); - - EINA_SAFETY_ON_TRUE_RETURN_VAL(size < 1, 0); - - if (cl->fd_handler) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE); - - if (cl->host_server && ((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP)) - sendto(cl->host_server->fd, data, size, 0, (struct sockaddr *)cl->client_addr, - cl->client_addr_len); - else if (!cl->buf) - { - cl->buf = eina_binbuf_new(); - EINA_SAFETY_ON_NULL_RETURN_VAL(cl->buf, 0); -#ifdef TCP_CORK - if ((cl->fd >= 0) && ((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_CORK)) - { - int state = 1; - if (setsockopt(cl->fd, IPPROTO_TCP, TCP_CORK, (char *)&state, sizeof(int)) < 0) - /* realistically this isn't anything serious so we can just log and continue */ - ERR("corking failed! %s", strerror(errno)); - } -#endif - } - eina_binbuf_append_length(cl->buf, data, size); - - return size; -} - -EAPI Ecore_Con_Server * -ecore_con_client_server_get(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, - "ecore_con_client_server_get"); - return NULL; - } - - return cl->host_server; -} - -EAPI Eina_Bool -ecore_con_client_connected_get(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, - "ecore_con_client_connected_get"); - return EINA_FALSE; - } - - return !cl->delete_me; -} - -EAPI void -ecore_con_client_timeout_set(Ecore_Con_Client *cl, - double timeout) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, - "ecore_con_client_timeout_set"); - return; - } - - cl->disconnect_time = timeout; - - _ecore_con_cl_timer_update(cl); -} - -EAPI double -ecore_con_client_timeout_get(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_timeout_get"); - return 0; - } - - return cl->disconnect_time; -} - -EAPI void * -ecore_con_client_del(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_del"); - return NULL; - } - - _ecore_con_client_kill(cl); - return cl->data; -} - -EAPI void -ecore_con_client_data_set(Ecore_Con_Client *cl, - const void *data) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_data_set"); - return; - } - - cl->data = (void *)data; -} - -EAPI void * -ecore_con_client_data_get(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_data_get"); - return NULL; - } - - return cl->data; -} - -EAPI const char * -ecore_con_client_ip_get(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_ip_get"); - return NULL; - } - if (!cl->ip) - cl->ip = _ecore_con_pretty_ip(cl->client_addr); - - return cl->ip; -} - -EAPI int -ecore_con_client_port_get(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_port_get"); - return -1; - } - if (cl->client_addr->sa_family == AF_INET) - return ((struct sockaddr_in*)cl->client_addr)->sin_port; -#ifdef HAVE_IPV6 - return ((struct sockaddr_in6*)cl->client_addr)->sin6_port; -#else - return -1; -#endif -} - -EAPI double -ecore_con_client_uptime_get(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_uptime_get"); - return -1; - } - - return ecore_time_get() - cl->start_time; -} - -EAPI void -ecore_con_client_flush(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_flush"); - return; - } - - _ecore_con_client_flush(cl); -} - -EAPI int -ecore_con_server_fd_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__); - return -1; - } - if (svr->created) return -1; - return ecore_main_fd_handler_fd_get(svr->fd_handler); -} - -EAPI int -ecore_con_client_fd_get(Ecore_Con_Client *cl) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, __func__); - return -1; - } - return ecore_main_fd_handler_fd_get(cl->fd_handler); -} - -/** - * @} - */ - -void -ecore_con_event_proxy_bind(Ecore_Con_Server *svr) -{ - Ecore_Con_Event_Proxy_Bind *e; - int ev = ECORE_CON_EVENT_PROXY_BIND; - - e = ecore_con_event_proxy_bind_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - svr->event_count = eina_list_append(svr->event_count, e); - _ecore_con_server_timer_update(svr); - e->server = svr; - e->ip = svr->proxyip; - e->port = svr->proxyport; - ecore_event_add(ev, e, - _ecore_con_event_server_add_free, NULL); - _ecore_con_event_count++; -} - -void -ecore_con_event_server_add(Ecore_Con_Server *svr) -{ - /* we got our server! */ - Ecore_Con_Event_Server_Add *e; - int ev = ECORE_CON_EVENT_SERVER_ADD; - - e = ecore_con_event_server_add_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - svr->connecting = EINA_FALSE; - svr->start_time = ecore_time_get(); - svr->event_count = eina_list_append(svr->event_count, e); - _ecore_con_server_timer_update(svr); - e->server = svr; - if (svr->upgrade) ev = ECORE_CON_EVENT_SERVER_UPGRADE; - ecore_event_add(ev, e, - _ecore_con_event_server_add_free, NULL); - _ecore_con_event_count++; -} - -void -ecore_con_event_server_del(Ecore_Con_Server *svr) -{ - Ecore_Con_Event_Server_Del *e; - - svr->delete_me = EINA_TRUE; - INF("svr %p is dead", svr); - e = ecore_con_event_server_del_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - svr->event_count = eina_list_append(svr->event_count, e); - _ecore_con_server_timer_update(svr); - e->server = svr; - if (svr->ecs) - { - svr->ecs_state = svr->ecs->lookup ? ECORE_CON_PROXY_STATE_RESOLVED : ECORE_CON_PROXY_STATE_DONE; - eina_stringshare_replace(&svr->proxyip, NULL); - svr->proxyport = 0; - } - ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e, - _ecore_con_event_server_del_free, NULL); - _ecore_con_event_count++; -} - -void -ecore_con_event_server_write(Ecore_Con_Server *svr, int num) -{ - Ecore_Con_Event_Server_Write *e; - - e = ecore_con_event_server_write_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - INF("Wrote %d bytes", num); - svr->event_count = eina_list_append(svr->event_count, e); - e->server = svr; - e->size = num; - ecore_event_add(ECORE_CON_EVENT_SERVER_WRITE, e, - (Ecore_End_Cb)_ecore_con_event_server_write_free, NULL); - _ecore_con_event_count++; -} - -void -ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num, Eina_Bool duplicate) -{ - Ecore_Con_Event_Server_Data *e; - - e = ecore_con_event_server_data_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - svr->event_count = eina_list_append(svr->event_count, e); - _ecore_con_server_timer_update(svr); - e->server = svr; - if (duplicate) - { - e->data = malloc(num); - if (!e->data) - { - ERR("server data allocation failure !"); - _ecore_con_event_server_data_free(NULL, e); - return; - } - memcpy(e->data, buf, num); - } - else - e->data = buf; - e->size = num; - ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e, - _ecore_con_event_server_data_free, NULL); - _ecore_con_event_count++; -} - -void -ecore_con_event_client_add(Ecore_Con_Client *cl) -{ - Ecore_Con_Event_Client_Add *e; - int ev = ECORE_CON_EVENT_CLIENT_ADD; - - e = ecore_con_event_client_add_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - cl->event_count = eina_list_append(cl->event_count, e); - cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e); - _ecore_con_cl_timer_update(cl); - e->client = cl; - if (cl->upgrade) ev = ECORE_CON_EVENT_CLIENT_UPGRADE; - ecore_event_add(ev, e, - (Ecore_End_Cb)_ecore_con_event_client_add_free, cl->host_server); - _ecore_con_event_count++; -} - -void -ecore_con_event_client_del(Ecore_Con_Client *cl) -{ - Ecore_Con_Event_Client_Del *e; - - if (!cl) return; - cl->delete_me = EINA_TRUE; - INF("cl %p is dead", cl); - e = ecore_con_event_client_del_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - cl->event_count = eina_list_append(cl->event_count, e); - - cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e); - _ecore_con_cl_timer_update(cl); - e->client = cl; - ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, - (Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server); - _ecore_con_event_count++; -} - -void -ecore_con_event_client_write(Ecore_Con_Client *cl, int num) -{ - Ecore_Con_Event_Client_Write *e; - - e = ecore_con_event_client_write_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - cl->event_count = eina_list_append(cl->event_count, e); - cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e); - e->client = cl; - e->size = num; - ecore_event_add(ECORE_CON_EVENT_CLIENT_WRITE, e, - (Ecore_End_Cb)_ecore_con_event_client_write_free, cl->host_server); - _ecore_con_event_count++; -} - -void -ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate) -{ - Ecore_Con_Event_Client_Data *e; - - e = ecore_con_event_client_data_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - cl->event_count = eina_list_append(cl->event_count, e); - cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e); - _ecore_con_cl_timer_update(cl); - e->client = cl; - if (duplicate) - { - e->data = malloc(num); - if (!e->data) - { - ERR("client data allocation failure !"); - _ecore_con_event_client_data_free(cl->host_server, e); - return; - } - memcpy(e->data, buf, num); - } - else - e->data = buf; - e->size = num; - ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e, - (Ecore_End_Cb)_ecore_con_event_client_data_free, cl->host_server); - _ecore_con_event_count++; -} - - -void -ecore_con_server_infos_del(Ecore_Con_Server *svr, void *info) -{ - svr->infos = eina_list_remove(svr->infos, info); -} - -void -_ecore_con_event_server_error(Ecore_Con_Server *svr, char *error, Eina_Bool duplicate) -{ - Ecore_Con_Event_Server_Error *e; - - e = ecore_con_event_server_error_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - e->server = svr; - e->error = duplicate ? strdup(error) : error; - ERR("%s", error); - svr->event_count = eina_list_append(svr->event_count, e); - ecore_event_add(ECORE_CON_EVENT_SERVER_ERROR, e, (Ecore_End_Cb)_ecore_con_event_server_error_free, NULL); - _ecore_con_event_count++; -} - -void -ecore_con_event_client_error(Ecore_Con_Client *cl, const char *error) -{ - Ecore_Con_Event_Client_Error *e; - - e = ecore_con_event_client_error_alloc(); - EINA_SAFETY_ON_NULL_RETURN(e); - - e->client = cl; - e->error = strdup(error); - ERR("%s", error); - cl->event_count = eina_list_append(cl->event_count, e); - cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e); - ecore_event_add(ECORE_CON_EVENT_CLIENT_ERROR, e, (Ecore_End_Cb)_ecore_con_event_client_error_free, cl->host_server); - _ecore_con_event_count++; -} - -static void -_ecore_con_server_free(Ecore_Con_Server *svr) -{ - Ecore_Con_Client *cl; - double t_start, t; - - if (svr->event_count) return; - - while (svr->infos) - { - ecore_con_info_data_clear(svr->infos->data); - svr->infos = eina_list_remove_list(svr->infos, svr->infos); - } - - t_start = ecore_time_get(); - while (svr->buf && (!svr->delete_me)) - { - _ecore_con_server_flush(svr); - t = ecore_time_get(); - if ((t - t_start) > 0.5) - { - WRN("ECORE_CON: EEK - stuck in _ecore_con_server_free() trying\n" - " to flush data out from the server, and have been for\n" - " %1.1f seconds. This is taking too long. Aborting flush.", - (t - t_start)); - break; - } - } - -#ifdef _WIN32 - ecore_con_local_win32_server_del(svr); -#endif - if (svr->event_count) return; - ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE); - - if (svr->buf) - eina_binbuf_free(svr->buf); - - EINA_LIST_FREE(svr->clients, cl) - { - Ecore_Con_Event_Server_Add *ev; - - /* some pointer hacks here to prevent double frees if people are being stupid */ - EINA_LIST_FREE(cl->event_count, ev) - ev->server = NULL; - cl->delete_me = EINA_TRUE; - INF("cl %p is dead", cl); - _ecore_con_client_free(cl); - } - if ((svr->created) && (svr->path) && (svr->ppid == getpid())) - unlink(svr->path); - - ecore_con_ssl_server_shutdown(svr); - free(svr->name); - - free(svr->path); - - eina_stringshare_del(svr->ip); - eina_stringshare_del(svr->verify_name); - - if (svr->ecs_buf) eina_binbuf_free(svr->ecs_buf); - if (svr->ecs_recvbuf) eina_binbuf_free(svr->ecs_recvbuf); - - if (svr->fd_handler) - ecore_main_fd_handler_del(svr->fd_handler); - - if (svr->fd > 0) - close(svr->fd); - - if (svr->until_deletion) - ecore_timer_del(svr->until_deletion); - - servers = eina_list_remove(servers, svr); - svr->data = NULL; - free(svr); -} - -static void -_ecore_con_client_free(Ecore_Con_Client *cl) -{ - double t_start, t; - - if (cl->event_count) return; - - t_start = ecore_time_get(); - while ((cl->buf) && (!cl->delete_me)) - { - _ecore_con_client_flush(cl); - t = ecore_time_get(); - if ((t - t_start) > 0.5) - { - WRN("EEK - stuck in _ecore_con_client_free() trying\n" - " to flush data out from the client, and have been for\n" - " %1.1f seconds. This is taking too long. Aborting flush.", - (t - t_start)); - break; - } - } - -#ifdef _WIN32 - ecore_con_local_win32_client_del(cl); -#endif - - if (cl->event_count) return; - ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE); - - if (cl->buf) eina_binbuf_free(cl->buf); - - if (cl->host_server->type & ECORE_CON_SSL) - ecore_con_ssl_client_shutdown(cl); - - if (cl->fd_handler) - ecore_main_fd_handler_del(cl->fd_handler); - - if (cl->fd > 0) - close(cl->fd); - - free(cl->client_addr); - cl->client_addr = NULL; - - if (cl->until_deletion) - ecore_timer_del(cl->until_deletion); - - eina_stringshare_del(cl->ip); - cl->data = NULL; - free(cl); - return; -} - -static Eina_Bool -_ecore_con_server_timer(Ecore_Con_Server *svr) -{ - ecore_con_server_del(svr); - - svr->until_deletion = NULL; - return ECORE_CALLBACK_CANCEL; -} - -static void -_ecore_con_server_timer_update(Ecore_Con_Server *svr) -{ - if (svr->disconnect_time) - { - if (svr->disconnect_time > 0) - { - if (svr->until_deletion) - ecore_timer_interval_set(svr->until_deletion, svr->disconnect_time); - else - svr->until_deletion = ecore_timer_add(svr->disconnect_time, (Ecore_Task_Cb)_ecore_con_server_timer, svr); - } - else if (svr->until_deletion) - { - ecore_timer_del(svr->until_deletion); - svr->until_deletion = NULL; - } - } - else - { - if (svr->until_deletion) - { - ecore_timer_del(svr->until_deletion); - svr->until_deletion = NULL; - } - } -} - -static Eina_Bool -_ecore_con_client_timer(Ecore_Con_Client *cl) -{ - ecore_con_client_del(cl); - - cl->until_deletion = NULL; - return ECORE_CALLBACK_CANCEL; -} - -static void -_ecore_con_cl_timer_update(Ecore_Con_Client *cl) -{ - if (cl->disconnect_time) - { - if (cl->disconnect_time > 0) - { - if (cl->until_deletion) - ecore_timer_interval_set(cl->until_deletion, cl->disconnect_time); - else - cl->until_deletion = ecore_timer_add(cl->disconnect_time, (Ecore_Task_Cb)_ecore_con_client_timer, cl); - } - else if (cl->until_deletion) - { - ecore_timer_del(cl->until_deletion); - cl->until_deletion = NULL; - } - } - else - { - if (cl->host_server->client_disconnect_time > 0) - { - if (cl->until_deletion) - ecore_timer_interval_set(cl->until_deletion, cl->host_server->client_disconnect_time); - else - cl->until_deletion = ecore_timer_add(cl->host_server->client_disconnect_time, (Ecore_Task_Cb)_ecore_con_client_timer, cl); - } - else if (cl->until_deletion) - { - ecore_timer_del(cl->until_deletion); - cl->until_deletion = NULL; - } - } -} - -static void -_ecore_con_cb_tcp_listen(void *data, - Ecore_Con_Info *net_info) -{ - Ecore_Con_Server *svr; - struct linger lin; - const char *memerr = NULL; - - svr = data; - - errno = 0; - if (!net_info) /* error message has already been handled */ - goto error; - - svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype, - net_info->info.ai_protocol); - if (svr->fd < 0) goto error; - if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error; - if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error; - - lin.l_onoff = 1; - lin.l_linger = 0; - if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin, - sizeof(struct linger)) < 0) - goto error; - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY) - { -#ifdef HAVE_NETINET_TCP_H - int flag = 1; - - if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, - sizeof(int)) < 0) -#endif - { - goto error; - } - } - - if (bind(svr->fd, net_info->info.ai_addr, net_info->info.ai_addrlen) < 0) - goto error; - - if (listen(svr->fd, 4096) < 0) goto error; - - svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, - _ecore_con_svr_tcp_handler, svr, NULL, NULL); - if (!svr->fd_handler) - { - memerr = "Memory allocation failure"; - goto error; - } - - return; - -error: - if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno)); - ecore_con_ssl_server_shutdown(svr); - _ecore_con_server_kill(svr); -} - -static void -_ecore_con_cb_udp_listen(void *data, - Ecore_Con_Info *net_info) -{ - Ecore_Con_Server *svr; - Ecore_Con_Type type; - struct ip_mreq mreq; -#ifdef HAVE_IPV6 - struct ipv6_mreq mreq6; -#endif - const int on = 1; - const char *memerr = NULL; - - svr = data; - type = svr->type; - type &= ECORE_CON_TYPE; - - errno = 0; - if (!net_info) /* error message has already been handled */ - goto error; - - svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype, - net_info->info.ai_protocol); - if (svr->fd < 0) goto error; - - if (type == ECORE_CON_REMOTE_MCAST) - { - if (net_info->info.ai_family == AF_INET) - { - if (!inet_pton(net_info->info.ai_family, net_info->ip, - &mreq.imr_multiaddr)) - goto error; - - mreq.imr_interface.s_addr = htonl(INADDR_ANY); - if (setsockopt(svr->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, - (const void *)&mreq, sizeof(mreq)) != 0) - goto error; - } -#ifdef HAVE_IPV6 - else if (net_info->info.ai_family == AF_INET6) - { - if (!inet_pton(net_info->info.ai_family, net_info->ip, - &mreq6.ipv6mr_multiaddr)) - goto error; - mreq6.ipv6mr_interface = htonl(INADDR_ANY); - if (setsockopt(svr->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, - (const void *)&mreq6, sizeof(mreq6)) != 0) - goto error; - } -#endif - } - - if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) != 0) - goto error; - if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error; - if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error; - - if (bind(svr->fd, net_info->info.ai_addr, net_info->info.ai_addrlen) < 0) - goto error; - - svr->fd_handler = - ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, - _ecore_con_svr_udp_handler, svr, NULL, NULL); - if (!svr->fd_handler) - { - memerr = "Memory allocation failure"; - goto error; - } - - svr->ip = eina_stringshare_add(net_info->ip); - - return; - -error: - if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno)); - ecore_con_ssl_server_shutdown(svr); - _ecore_con_server_kill(svr); -} - -static void -_ecore_con_cb_tcp_connect(void *data, - Ecore_Con_Info *net_info) -{ - Ecore_Con_Server *svr; - int res; - int curstate = 0; - const char *memerr = NULL; - - svr = data; - - errno = 0; - if (!net_info) /* error message has already been handled */ - goto error; - - svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype, - net_info->info.ai_protocol); - if (svr->fd < 0) goto error; - - if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error; - if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error; - - if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, sizeof(curstate)) < 0) - goto error; - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY) - { -#ifdef HAVE_NETINET_TCP_H - int flag = 1; - - if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)) < 0) -#endif - { - goto error; - } - } - - res = connect(svr->fd, net_info->info.ai_addr, net_info->info.ai_addrlen); -#ifdef _WIN32 - if (res == SOCKET_ERROR) - { - if (WSAGetLastError() != WSAEINPROGRESS) - { - char *err; - err = evil_format_message(WSAGetLastError()); - _ecore_con_event_server_error(svr, err, EINA_FALSE); - ecore_con_ssl_server_shutdown(svr); - _ecore_con_server_kill(svr); - return; - } - -#else - if (res < 0) - { - if (errno != EINPROGRESS) goto error; -#endif - svr->connecting = EINA_TRUE; - svr->fd_handler = - ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ | ECORE_FD_WRITE, - _ecore_con_cl_handler, svr, NULL, NULL); - } - else - svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, - _ecore_con_cl_handler, svr, NULL, NULL); - - if (svr->type & ECORE_CON_SSL) - { - svr->handshaking = EINA_TRUE; - svr->ssl_state = ECORE_CON_SSL_STATE_INIT; - DBG("%s ssl handshake", svr->ecs_state ? "Queuing" : "Beginning"); - if ((!svr->ecs_state) && ecore_con_ssl_server_init(svr)) - goto error; - } - - if (!svr->fd_handler) - { - memerr = "Memory allocation failure"; - goto error; - } - - if ((!svr->ecs) || (svr->ecs->lookup)) - svr->ip = eina_stringshare_add(net_info->ip); - - return; - -error: - if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno)); - ecore_con_ssl_server_shutdown(svr); - _ecore_con_server_kill(svr); -} - -static void -_ecore_con_cb_udp_connect(void *data, - Ecore_Con_Info *net_info) -{ - Ecore_Con_Server *svr; - int curstate = 0; - int broadcast = 1; - const char *memerr = NULL; - svr = data; - - errno = 0; - if (!net_info) /* error message has already been handled */ - goto error; - - svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype, - net_info->info.ai_protocol); - if (svr->fd < 0) goto error; - if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error; - if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error; - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_BROADCAST) - { - if (setsockopt(svr->fd, SOL_SOCKET, SO_BROADCAST, - (const void *)&broadcast, - sizeof(broadcast)) < 0) - { - goto error; - } - } - if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, - (const void *)&curstate, sizeof(curstate)) < 0) - goto error; - - if (connect(svr->fd, net_info->info.ai_addr, net_info->info.ai_addrlen) < 0) - goto error; - - svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ | ECORE_FD_WRITE, - _ecore_con_cl_udp_handler, svr, NULL, NULL); - - if (!svr->fd_handler) - { - memerr = "Memory allocation failure"; - goto error; - } - - if ((!svr->ecs) || (svr->ecs->lookup)) - svr->ip = eina_stringshare_add(net_info->ip); - - return; - -error: - if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno)); - ecore_con_ssl_server_shutdown(svr); - _ecore_con_server_kill(svr); -} - -static Ecore_Con_State -svr_try_connect_plain(Ecore_Con_Server *svr) -{ - int res; - int so_err = 0; - socklen_t size = sizeof(int); - - res = getsockopt(svr->fd, SOL_SOCKET, SO_ERROR, (void *)&so_err, &size); -#ifdef _WIN32 - if (res == SOCKET_ERROR) - so_err = WSAGetLastError(); - - if ((so_err == WSAEINPROGRESS) && !svr->delete_me) - return ECORE_CON_INPROGRESS; - -#else - if (res < 0) - so_err = errno; - - if ((so_err == EINPROGRESS) && !svr->delete_me) - return ECORE_CON_INPROGRESS; - -#endif - - if (so_err) - { - /* we lost our server! */ - ecore_con_event_server_error(svr, strerror(so_err)); - ERR("Connection lost: %s", strerror(so_err)); - _ecore_con_server_kill(svr); - return ECORE_CON_DISCONNECTED; - } - - if ((!svr->delete_me) && (!svr->handshaking) && svr->connecting) - { - if (svr->ecs) - { - if (ecore_con_socks_svr_init(svr)) - return ECORE_CON_INPROGRESS; - } - else - ecore_con_event_server_add(svr); - } - - if (svr->fd_handler && (!svr->buf)) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); - - if (!svr->delete_me) - return ECORE_CON_CONNECTED; - else - return ECORE_CON_DISCONNECTED; -} - -static const char * -_ecore_con_pretty_ip(struct sockaddr *client_addr) -{ -#ifndef HAVE_IPV6 - char ipbuf[INET_ADDRSTRLEN + 1]; -#else - char ipbuf[INET6_ADDRSTRLEN + 1]; -#endif - int family = client_addr->sa_family; - void *src; - - switch(family) - { - case AF_INET: - src = &(((struct sockaddr_in *)client_addr)->sin_addr); - break; -#ifdef HAVE_IPV6 - case AF_INET6: - src = &(((struct sockaddr_in6 *)client_addr)->sin6_addr); - - if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)src)) - { - family = AF_INET; - src = (char*)src + 12; - } - break; -#endif - default: - return eina_stringshare_add("0.0.0.0"); - } - - if (!inet_ntop(family, src, ipbuf, sizeof(ipbuf))) - return eina_stringshare_add("0.0.0.0"); - - ipbuf[sizeof(ipbuf) - 1] = 0; - return eina_stringshare_add(ipbuf); -} - -static Eina_Bool -_ecore_con_svr_tcp_handler(void *data, - Ecore_Fd_Handler *fd_handler __UNUSED__) -{ - Ecore_Con_Server *svr; - Ecore_Con_Client *cl = NULL; - unsigned char client_addr[256]; - unsigned int client_addr_len; - const char *clerr = NULL; - - svr = data; - if (svr->delete_me) - return ECORE_CALLBACK_RENEW; - - if (svr->delete_me) - return ECORE_CALLBACK_RENEW; - - if ((svr->client_limit >= 0) && (!svr->reject_excess_clients) && - (svr->client_count >= (unsigned int)svr->client_limit)) - return ECORE_CALLBACK_RENEW; - - /* a new client */ - - cl = calloc(1, sizeof(Ecore_Con_Client)); - if (!cl) - { - ecore_con_event_server_error(svr, "Memory allocation failure when attempting to add a new client"); - return ECORE_CALLBACK_RENEW; - } - cl->host_server = svr; - - client_addr_len = sizeof(client_addr); - memset(&client_addr, 0, client_addr_len); - cl->fd = accept(svr->fd, (struct sockaddr *)&client_addr, (socklen_t *)&client_addr_len); - if (cl->fd < 0) goto error; - if ((svr->client_limit >= 0) && (svr->reject_excess_clients) && - (svr->client_count >= (unsigned int)svr->client_limit)) - { - clerr = "Maximum client limit reached"; - goto error; - } - - if (fcntl(cl->fd, F_SETFL, O_NONBLOCK) < 0) goto error; - if (fcntl(cl->fd, F_SETFD, FD_CLOEXEC) < 0) goto error; - cl->fd_handler = ecore_main_fd_handler_add(cl->fd, ECORE_FD_READ, - _ecore_con_svr_cl_handler, cl, NULL, NULL); - if (!cl->fd_handler) goto error; - ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT); - - if ((!svr->upgrade) && (svr->type & ECORE_CON_SSL)) - { - cl->handshaking = EINA_TRUE; - cl->ssl_state = ECORE_CON_SSL_STATE_INIT; - if (ecore_con_ssl_client_init(cl)) - goto error; - } - - cl->client_addr = malloc(client_addr_len); - if (!cl->client_addr) - { - clerr = "Memory allocation failure when attempting to add a new client"; - goto error; - } - cl->client_addr_len = client_addr_len; - memcpy(cl->client_addr, &client_addr, client_addr_len); - - svr->clients = eina_list_append(svr->clients, cl); - svr->client_count++; - - if ((!cl->delete_me) && (!cl->handshaking)) - ecore_con_event_client_add(cl); - - return ECORE_CALLBACK_RENEW; - -error: - if (cl->fd_handler) ecore_main_fd_handler_del(cl->fd_handler); - if (cl->fd >= 0) close(cl->fd); - free(cl); - if (clerr || errno) ecore_con_event_server_error(svr, clerr ?: strerror(errno)); - return ECORE_CALLBACK_RENEW; -} - -static void -_ecore_con_cl_read(Ecore_Con_Server *svr) -{ - int num = 0; - Eina_Bool lost_server = EINA_TRUE; - unsigned char buf[READBUFSIZ]; - - DBG("svr=%p", svr); - - /* only possible with non-ssl connections */ - if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED)) - return; - - if (svr->handshaking && (!svr->ecs_state)) - { - DBG("Continuing ssl handshake"); - if (!ecore_con_ssl_server_init(svr)) - lost_server = EINA_FALSE; - _ecore_con_server_timer_update(svr); - } - - if (svr->ecs_state || !(svr->type & ECORE_CON_SSL)) - { - errno = 0; - num = read(svr->fd, buf, sizeof(buf)); - /* 0 is not a valid return value for a tcp socket */ - if ((num > 0) || ((num < 0) && (errno == EAGAIN))) - lost_server = EINA_FALSE; - else if (num < 0) - ecore_con_event_server_error(svr, strerror(errno)); - } - else - { - num = ecore_con_ssl_server_read(svr, buf, sizeof(buf)); - /* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */ - if (num >= 0) - lost_server = EINA_FALSE; - } - - if ((!svr->delete_me) && (num > 0)) - { - if (svr->ecs_state) - ecore_con_socks_read(svr, buf, num); - else - ecore_con_event_server_data(svr, buf, num, EINA_TRUE); - } - - if (lost_server) - _ecore_con_server_kill(svr); -} - -static Eina_Bool -_ecore_con_cl_handler(void *data, - Ecore_Fd_Handler *fd_handler) -{ - Ecore_Con_Server *svr; - Eina_Bool want_read, want_write; - - svr = data; - if (svr->delete_me) - return ECORE_CALLBACK_RENEW; - - if (svr->delete_me) - return ECORE_CALLBACK_RENEW; - - want_read = ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ); - want_write = ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE); - - if ((!svr->ecs_state) && svr->handshaking && (want_read || want_write)) - { - DBG("Continuing ssl handshake: preparing to %s...", want_read ? "read" : "write"); -#ifdef ISCOMFITOR - if (want_read) - { - char buf[READBUFSIZ]; - ssize_t len; - len = recv(svr->fd, buf, sizeof(buf), MSG_DONTWAIT | MSG_PEEK); - DBG("%zu bytes in buffer", len); - } -#endif - if (ecore_con_ssl_server_init(svr)) - { - ERR("ssl handshaking failed!"); - svr->handshaking = EINA_FALSE; - } - else if (!svr->ssl_state) - ecore_con_event_server_add(svr); - return ECORE_CALLBACK_RENEW; - } - if (svr->ecs && svr->ecs_state && (svr->ecs_state < ECORE_CON_PROXY_STATE_READ) && (!svr->ecs_buf)) - { - if (svr->ecs_state < ECORE_CON_PROXY_STATE_INIT) - { - INF("PROXY STATE++"); - svr->ecs_state++; - } - if (ecore_con_socks_svr_init(svr)) return ECORE_CALLBACK_RENEW; - } - if (want_read) - _ecore_con_cl_read(svr); - else if (want_write) /* only possible with non-ssl connections */ - { - if (svr->connecting && (!svr_try_connect_plain(svr)) && (!svr->ecs_state)) - return ECORE_CALLBACK_RENEW; - - _ecore_con_server_flush(svr); - } - - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool -_ecore_con_cl_udp_handler(void *data, - Ecore_Fd_Handler *fd_handler) -{ - unsigned char buf[READBUFSIZ]; - int num; - Ecore_Con_Server *svr; - Eina_Bool want_read, want_write; - - want_read = ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ); - want_write = ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE); - - svr = data; - if (svr->delete_me || svr->delete_me || ((!want_read) && (!want_write))) - return ECORE_CALLBACK_RENEW; - - if (want_write) - { - _ecore_con_server_flush(svr); - return ECORE_CALLBACK_RENEW; - } - - num = read(svr->fd, buf, READBUFSIZ); - - if ((!svr->delete_me) && (num > 0)) - ecore_con_event_server_data(svr, buf, num, EINA_TRUE); - - if (num < 0 && (errno != EAGAIN) && (errno != EINTR)) - { - ecore_con_event_server_error(svr, strerror(errno)); - _ecore_con_server_kill(svr); - } - - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool -_ecore_con_svr_udp_handler(void *data, - Ecore_Fd_Handler *fd_handler) -{ - unsigned char buf[READBUFSIZ]; - unsigned char client_addr[256]; - socklen_t client_addr_len = sizeof(client_addr); - int num; - Ecore_Con_Server *svr; - Ecore_Con_Client *cl = NULL; - - svr = data; - - if (svr->delete_me) - return ECORE_CALLBACK_RENEW; - - if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) - { - _ecore_con_client_flush(cl); - return ECORE_CALLBACK_RENEW; - } - - if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) - return ECORE_CALLBACK_RENEW; - -#ifdef _WIN32 - num = fcntl(svr->fd, F_SETFL, O_NONBLOCK); - if (num >= 0) - num = recvfrom(svr->fd, (char *)buf, sizeof(buf), 0, - (struct sockaddr *)&client_addr, - &client_addr_len); - -#else - num = recvfrom(svr->fd, buf, sizeof(buf), MSG_DONTWAIT, - (struct sockaddr *)&client_addr, - &client_addr_len); -#endif - - if (num < 0 && (errno != EAGAIN) && (errno != EINTR)) - { - ecore_con_event_server_error(svr, strerror(errno)); - if (!svr->delete_me) - ecore_con_event_client_del(NULL); - _ecore_con_server_kill(svr); - return ECORE_CALLBACK_CANCEL; - } - - -/* Create a new client for use in the client data event */ - cl = calloc(1, sizeof(Ecore_Con_Client)); - EINA_SAFETY_ON_NULL_RETURN_VAL(cl, ECORE_CALLBACK_RENEW); - - cl->host_server = svr; - cl->client_addr = malloc(client_addr_len); - if (!cl->client_addr) - { - free(cl); - return ECORE_CALLBACK_RENEW; - } - cl->client_addr_len = client_addr_len; - - memcpy(cl->client_addr, &client_addr, client_addr_len); - ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT); - svr->clients = eina_list_append(svr->clients, cl); - svr->client_count++; - - ecore_con_event_client_add(cl); - ecore_con_event_client_data(cl, buf, num, EINA_TRUE); - - return ECORE_CALLBACK_RENEW; -} - -static void -_ecore_con_svr_cl_read(Ecore_Con_Client *cl) -{ - int num = 0; - Eina_Bool lost_client = EINA_TRUE; - unsigned char buf[READBUFSIZ]; - - DBG("cl=%p", cl); - - if (cl->handshaking) - { - /* add an extra handshake attempt just before read, even though - * read also attempts to handshake, to try to finish sooner - */ - if (ecore_con_ssl_client_init(cl)) - lost_client = EINA_FALSE; - - _ecore_con_cl_timer_update(cl); - } - - if (!(cl->host_server->type & ECORE_CON_SSL) || (!cl->upgrade)) - { - num = read(cl->fd, buf, sizeof(buf)); - /* 0 is not a valid return value for a tcp socket */ - if ((num > 0) || ((num < 0) && ((errno == EAGAIN) || (errno == EINTR)))) - lost_client = EINA_FALSE; - else if (num < 0) - ecore_con_event_client_error(cl, strerror(errno)); - } - else - { - num = ecore_con_ssl_client_read(cl, buf, sizeof(buf)); - /* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */ - if (num >= 0) - lost_client = EINA_FALSE; - } - - if ((!cl->delete_me) && (num > 0)) - ecore_con_event_client_data(cl, buf, num, EINA_TRUE); - - if (lost_client) _ecore_con_client_kill(cl); -} - -static Eina_Bool -_ecore_con_svr_cl_handler(void *data, - Ecore_Fd_Handler *fd_handler) -{ - Ecore_Con_Client *cl; - - cl = data; - if (cl->delete_me) - return ECORE_CALLBACK_RENEW; - - if (cl->handshaking && ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ | ECORE_FD_WRITE)) - { - if (ecore_con_ssl_client_init(cl)) - { - ERR("ssl handshaking failed!"); - _ecore_con_client_kill(cl); - return ECORE_CALLBACK_RENEW; - } - else if (!cl->ssl_state) - ecore_con_event_client_add(cl); - } - else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) - _ecore_con_svr_cl_read(cl); - - else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) - _ecore_con_client_flush(cl); - - return ECORE_CALLBACK_RENEW; -} - -static void -_ecore_con_server_flush(Ecore_Con_Server *svr) -{ - int count, num; - size_t buf_len, buf_offset; - const void *buf; - - DBG("(svr=%p,buf=%p)", svr, svr->buf); -#ifdef _WIN32 - if (ecore_con_local_win32_server_flush(svr)) - return; -#endif - - if ((!svr->buf) && (!svr->ecs_buf) && svr->fd_handler) - { - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); - return; - } - - buf = svr->buf ? eina_binbuf_string_get(svr->buf) : eina_binbuf_string_get(svr->ecs_buf); - buf_len = svr->buf ? eina_binbuf_length_get(svr->buf) : eina_binbuf_length_get(svr->ecs_buf); - buf_offset = svr->buf ? svr->write_buf_offset : svr->ecs_buf_offset; - num = buf_len - buf_offset; - - /* check whether we need to write anything at all. - * we must not write zero bytes with SSL_write() since it - * causes undefined behaviour - */ - /* we thank Tommy[D] for needing to check negative buffer sizes - * here because his system is amazing. - */ - if (num <= 0) return; - - if ((!svr->ecs_state) && svr->handshaking) - { - DBG("Continuing ssl handshake"); - if (ecore_con_ssl_server_init(svr)) - _ecore_con_server_kill(svr); - _ecore_con_server_timer_update(svr); - return; - } - - if (svr->ecs_state || (!(svr->type & ECORE_CON_SSL))) - count = write(svr->fd, buf + buf_offset, num); - else - count = ecore_con_ssl_server_write(svr, buf + buf_offset, num); - - if (count < 0) - { - if ((errno != EAGAIN) && (errno != EINTR)) - { - ecore_con_event_server_error(svr, strerror(errno)); - _ecore_con_server_kill(svr); - } - return; - } - - if (count && (!svr->ecs_state)) ecore_con_event_server_write(svr, count); - if (svr->ecs_buf) - buf_offset = svr->ecs_buf_offset += count; - else - buf_offset = svr->write_buf_offset += count; - if (buf_offset >= buf_len) - { - if (svr->ecs_buf) - { - svr->ecs_buf_offset = 0; - eina_binbuf_free(svr->ecs_buf); - svr->ecs_buf = NULL; - INF("PROXY STATE++"); - svr->ecs_state++; - } - else - { - svr->write_buf_offset = 0; - eina_binbuf_free(svr->buf); - svr->buf = NULL; -#ifdef TCP_CORK - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_CORK) - { - int state = 0; - if (setsockopt(svr->fd, IPPROTO_TCP, TCP_CORK, (char *)&state, sizeof(int)) < 0) - /* realistically this isn't anything serious so we can just log and continue */ - ERR("uncorking failed! %s", strerror(errno)); - } -#endif - } - if (svr->fd_handler) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); - } - else if ((count < num) && svr->fd_handler) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); -} - -static void -_ecore_con_client_flush(Ecore_Con_Client *cl) -{ - int num = 0, count = 0; - -#ifdef _WIN32 - if (ecore_con_local_win32_client_flush(cl)) - return; -#endif - - if (!cl->buf && cl->fd_handler) - { - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); - return; - } - - if (cl->handshaking) - { - if (ecore_con_ssl_client_init(cl)) - count = -1; - - _ecore_con_cl_timer_update(cl); - } - - if (!count) - { - num = eina_binbuf_length_get(cl->buf) - cl->buf_offset; - if (num <= 0) return; - if (!(cl->host_server->type & ECORE_CON_SSL) || (!cl->upgrade)) - count = write(cl->fd, eina_binbuf_string_get(cl->buf) + cl->buf_offset, num); - else - count = ecore_con_ssl_client_write(cl, eina_binbuf_string_get(cl->buf) + cl->buf_offset, num); - } - - if (count < 0) - { - if ((errno != EAGAIN) && (errno != EINTR) && (!cl->delete_me)) - { - ecore_con_event_client_error(cl, strerror(errno)); - _ecore_con_client_kill(cl); - } - - return; - } - - if (count) ecore_con_event_client_write(cl, count); - cl->buf_offset += count, num -= count; - if (cl->buf_offset >= eina_binbuf_length_get(cl->buf)) - { - cl->buf_offset = 0; - eina_binbuf_free(cl->buf); - cl->buf = NULL; -#ifdef TCP_CORK - if ((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_CORK) - { - int state = 0; - if (setsockopt(cl->fd, IPPROTO_TCP, TCP_CORK, (char *)&state, sizeof(int)) < 0) - /* realistically this isn't anything serious so we can just log and continue */ - ERR("uncorking failed! %s", strerror(errno)); - } -#endif - if (cl->fd_handler) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); - } - else if (cl->fd_handler && (num >= 0)) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_WRITE); -} - -static void -_ecore_con_event_client_add_free(Ecore_Con_Server *svr, - void *ev) -{ - Ecore_Con_Event_Client_Add *e; - - e = ev; - if (e->client) - { - e->client->event_count = eina_list_remove(e->client->event_count, e); - if (e->client->host_server) - { - e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev); - if ((!svr->event_count) && (svr->delete_me)) - _ecore_con_server_free(svr); - } - if ((!e->client->event_count) && (e->client->delete_me)) - ecore_con_client_del(e->client); - } - - ecore_con_event_client_add_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_event_client_del_free(Ecore_Con_Server *svr, - void *ev) -{ - Ecore_Con_Event_Client_Del *e; - - e = ev; - if (e->client) - { - e->client->event_count = eina_list_remove(e->client->event_count, e); - if (e->client->host_server) - { - e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev); - if ((!svr->event_count) && (svr->delete_me)) - _ecore_con_server_free(svr); - } - if (!e->client->event_count) - ecore_con_client_del(e->client); - } - ecore_con_event_client_del_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_event_client_write_free(Ecore_Con_Server *svr, - Ecore_Con_Event_Client_Write *e) -{ - if (e->client) - { - e->client->event_count = eina_list_remove(e->client->event_count, e); - if (e->client->host_server) - { - e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, e); - if ((!svr->event_count) && (svr->delete_me)) - _ecore_con_server_free(svr); - } - if (((!e->client->event_count) && (e->client->delete_me)) || - ((e->client->host_server && - ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP || - (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST)))) - ecore_con_client_del(e->client); - } - ecore_con_event_client_write_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_event_client_data_free(Ecore_Con_Server *svr, - void *ev) -{ - Ecore_Con_Event_Client_Data *e; - - e = ev; - if (e->client) - { - e->client->event_count = eina_list_remove(e->client->event_count, e); - if (e->client->host_server) - { - e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev); - } - if ((!svr->event_count) && (svr->delete_me)) - _ecore_con_server_free(svr); - if (((!e->client->event_count) && (e->client->delete_me)) || - ((e->client->host_server && - ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP || - (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST)))) - ecore_con_client_del(e->client); - } - free(e->data); - ecore_con_event_client_data_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_event_server_add_free(void *data __UNUSED__, - void *ev) -{ - Ecore_Con_Event_Server_Add *e; - - e = ev; - if (e->server) - { - e->server->event_count = eina_list_remove(e->server->event_count, ev); - if ((!e->server->event_count) && (e->server->delete_me)) - _ecore_con_server_free(e->server); - } - ecore_con_event_server_add_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_event_server_del_free(void *data __UNUSED__, - void *ev) -{ - Ecore_Con_Event_Server_Del *e; - - e = ev; - if (e->server) - { - e->server->event_count = eina_list_remove(e->server->event_count, ev); - if (!e->server->event_count) - _ecore_con_server_free(e->server); - } - ecore_con_event_server_del_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_event_server_write_free(void *data __UNUSED__, - Ecore_Con_Event_Server_Write *e) -{ - if (e->server) - { - e->server->event_count = eina_list_remove(e->server->event_count, e); - if ((!e->server->event_count) && (e->server->delete_me)) - _ecore_con_server_free(e->server); - } - - ecore_con_event_server_write_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_event_server_data_free(void *data __UNUSED__, - void *ev) -{ - Ecore_Con_Event_Server_Data *e; - - e = ev; - if (e->server) - { - e->server->event_count = eina_list_remove(e->server->event_count, ev); - if ((!e->server->event_count) && (e->server->delete_me)) - _ecore_con_server_free(e->server); - } - - free(e->data); - ecore_con_event_server_data_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - - -static void -_ecore_con_event_server_error_free(void *data __UNUSED__, Ecore_Con_Event_Server_Error *e) -{ - if (e->server) - { - e->server->event_count = eina_list_remove(e->server->event_count, e); - if ((!e->server->event_count) && (e->server->delete_me)) - _ecore_con_server_free(e->server); - } - free(e->error); - ecore_con_event_server_error_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_event_client_error_free(Ecore_Con_Server *svr, Ecore_Con_Event_Client_Error *e) -{ - if (e->client) - { - e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, e); - if ((!e->client->event_count) && (e->client->delete_me)) - _ecore_con_client_free(e->client); - if (e->client->host_server) - { - e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, e); - if ((!svr->event_count) && (svr->delete_me)) - _ecore_con_server_free(svr); - } - } - free(e->error); - ecore_con_event_client_error_free(e); - _ecore_con_event_count--; - if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) - ecore_con_mempool_shutdown(); -} - -static void -_ecore_con_lookup_done(void *data, - Ecore_Con_Info *infos) -{ - Ecore_Con_Server *svr; - Ecore_Con_Lookup *lk; - - svr = data; - lk = svr->data; - - if (infos) - lk->done_cb(infos->info.ai_canonname, infos->ip, - infos->info.ai_addr, infos->info.ai_addrlen, - (void *)lk->data); - else - lk->done_cb(NULL, NULL, NULL, 0, (void *)lk->data); - - free(svr->name); - free(lk); - free(svr); -} - diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c b/libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c deleted file mode 100644 index d922f20..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c +++ /dev/null @@ -1,101 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "Ecore.h" -#include "ecore_private.h" -#include "Ecore_Con.h" -#include "ecore_con_private.h" - -typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool; -struct _Ecore_Con_Mempool -{ - const char *name; - Eina_Mempool *mp; - size_t size; -}; - -#define GENERIC_ALLOC_FREE(TYPE, Type) \ - Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \ - \ - TYPE * \ - Type##_alloc(void) \ - { \ - return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \ - } \ - \ - void \ - Type##_free(TYPE *e) \ - { \ - eina_mempool_free(Type##_mp.mp, e); \ - } - -GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Add, ecore_con_event_client_add); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Del, ecore_con_event_client_del); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Write, ecore_con_event_client_write); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Data, ecore_con_event_client_data); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Error, ecore_con_event_server_error); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Error, ecore_con_event_client_error); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Add, ecore_con_event_server_add); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Del, ecore_con_event_server_del); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Write, ecore_con_event_server_write); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Data, ecore_con_event_server_data); -GENERIC_ALLOC_FREE(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind); - -static Ecore_Con_Mempool *mempool_array[] = { - &ecore_con_event_client_add_mp, - &ecore_con_event_client_del_mp, - &ecore_con_event_client_write_mp, - &ecore_con_event_client_data_mp, - &ecore_con_event_server_error_mp, - &ecore_con_event_client_error_mp, - &ecore_con_event_server_add_mp, - &ecore_con_event_server_del_mp, - &ecore_con_event_server_write_mp, - &ecore_con_event_server_data_mp, - &ecore_con_event_proxy_bind_mp -}; - -void -ecore_con_mempool_init(void) -{ - const char *choice; - unsigned int i; - - choice = getenv("EINA_MEMPOOL"); - if (!choice || !choice[0]) - choice = "chained_mempool"; - - for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i) - { - retry: - mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 64); - if (!mempool_array[i]->mp) - { - if (strcmp(choice, "pass_through") != 0) - { - ERR("Falling back to pass through ! Previously tried '%s' mempool.", choice); - choice = "pass_through"; - goto retry; - } - else - { - ERR("Impossible to allocate mempool '%s' !", choice); - return ; - } - } - } -} - -void -ecore_con_mempool_shutdown(void) -{ - unsigned int i; - - for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i) - { - eina_mempool_del(mempool_array[i]->mp); - mempool_array[i]->mp = NULL; - } -} - diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_ares.c b/libraries/ecore/src/lib/ecore_con/ecore_con_ares.c deleted file mode 100644 index 5dfe70b..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_ares.c +++ /dev/null @@ -1,628 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -/* - * This version of ecore_con_info use c-ares to provide asynchronous dns lookup. - * - * Note: It doesn't fork nor does it use libc getaddrinfo. - * http://c-ares.haxx.se/docs.html - */ - -#include -#include - -#ifdef HAVE_NETINET_IN_H -# include -#endif - -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#include - -#include "Ecore.h" -#include "Ecore_Con.h" -#include "ecore_con_private.h" - -typedef struct _Ecore_Con_FD Ecore_Con_FD; -typedef struct _Ecore_Con_CAres Ecore_Con_CAres; - -struct _Ecore_Con_FD -{ - Ecore_Fd_Handler *handler; - Ecore_Timer *timer; - int fd; -}; - -struct _Ecore_Con_CAres -{ - Ecore_Con_Server *svr; - Ecore_Con_Info_Cb done_cb; - void *data; - struct addrinfo hints; - Ecore_Con_Info *result; - - union { - struct in_addr v4; -#ifdef HAVE_IPV6 - struct in6_addr v6; -#endif - } addr; - - Eina_Bool byaddr : 1; - Eina_Bool isv6 : 1; -}; - -static ares_channel info_channel; -static int info_init = 0; -static Eina_List *info_fds = NULL; - -static void _ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg, - int status, - int timeouts, - char *node, - char *service); -static void _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg, - int status, - int timeouts, - struct hostent *hostent); -static Eina_Bool _ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf, - Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_info_cares_timeout_cb(void *data); - -static void -_ecore_con_info_cares_state_cb(void *data, - ares_socket_t fd, - int readable, - int writable); -static int -_ecore_con_info_fds_search(const Ecore_Con_FD *fd1, - const Ecore_Con_FD *fd2); - -int -ecore_con_info_init(void) -{ - struct ares_options opts; - - if (!info_init) - { - if (ares_library_init(ARES_LIB_INIT_ALL)) - return 0; - - opts.lookups = "fb"; /* hosts file then dns */ - opts.sock_state_cb = _ecore_con_info_cares_state_cb; - - if (ares_init_options(&info_channel, &opts, - ARES_OPT_LOOKUPS | ARES_OPT_SOCK_STATE_CB) != ARES_SUCCESS) - { - ares_library_cleanup(); - return 0; - } - } - - info_init++; - return info_init; -} - -int -ecore_con_info_shutdown(void) -{ - info_init--; - if (info_init == 0) - { - /* Cancel all ongoing request */ - ares_cancel(info_channel); - ares_destroy(info_channel); - - /* Shutdown ares */ - ares_library_cleanup(); - } - - return info_init; -} - -int -ecore_con_info_tcp_connect(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); -#ifdef HAVE_IPV6 - hints.ai_family = AF_INET6; -#else - hints.ai_family = AF_INET; -#endif - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_CANONNAME; - hints.ai_protocol = IPPROTO_TCP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -int -ecore_con_info_tcp_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); -#ifdef HAVE_IPV6 - hints.ai_family = AF_INET6; -#else - hints.ai_family = AF_INET; -#endif - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - hints.ai_protocol = IPPROTO_TCP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -int -ecore_con_info_udp_connect(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); -#ifdef HAVE_IPV6 - hints.ai_family = AF_INET6; -#else - hints.ai_family = AF_INET; -#endif - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_CANONNAME; - hints.ai_protocol = IPPROTO_UDP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -int -ecore_con_info_udp_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); -#ifdef HAVE_IPV6 - hints.ai_family = AF_INET6; -#else - hints.ai_family = AF_INET; -#endif - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE; - hints.ai_protocol = IPPROTO_UDP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -int -ecore_con_info_mcast_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); -#ifdef HAVE_IPV6 - hints.ai_family = AF_INET6; -#else - hints.ai_family = AF_INET; -#endif - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = 0; - hints.ai_protocol = IPPROTO_UDP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -static Eina_Bool -_ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg, - int addrtype, - const char *name, - struct sockaddr *addr, - int addrlen) -{ - int length = 0; - - if (name) - length = strlen(name) + 1; - else - length = 1; - - arg->result = malloc(sizeof(Ecore_Con_Info) + length); - if (!arg->result) - return EINA_FALSE; - - /* FIXME: What to do when hint is not set ? */ - arg->result->info.ai_flags = arg->hints.ai_flags; - arg->result->info.ai_socktype = arg->hints.ai_socktype; - arg->result->info.ai_protocol = arg->hints.ai_protocol; - - arg->result->info.ai_family = addrtype; - arg->result->info.ai_addrlen = addrlen; - arg->result->info.ai_addr = addr; - arg->result->info.ai_canonname = (char *)(arg->result + 1); - - if (!name) - *arg->result->info.ai_canonname = '\0'; - else - strcpy(arg->result->info.ai_canonname, name); - - arg->result->info.ai_next = NULL; - - ares_getnameinfo( - info_channel, addr, addrlen, - ARES_NI_NUMERICSERV | ARES_NI_NUMERICHOST | - ARES_NI_LOOKUPSERVICE | ARES_NI_LOOKUPHOST, - (ares_nameinfo_callback)_ecore_con_info_ares_nameinfo, arg); - - return EINA_TRUE; -} - -EAPI int -ecore_con_info_get(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data, - struct addrinfo *hints) -{ - Ecore_Con_CAres *cares; -#ifdef HAVE_IPV6 - int ai_family = AF_INET6; -#else - int ai_family = AF_INET; -#endif - - cares = calloc(1, sizeof(Ecore_Con_CAres)); - if (!cares) - return 0; - - cares->svr = svr; - cares->done_cb = done_cb; - cares->data = data; - - if (hints) - { - ai_family = hints->ai_family; - memcpy(&cares->hints, hints, sizeof(struct addrinfo)); - } - - if (inet_pton(AF_INET, svr->ecs ? svr->ecs->ip : svr->name, &cares->addr.v4) == 1) - { - cares->byaddr = EINA_TRUE; - cares->isv6 = EINA_FALSE; - ares_gethostbyaddr(info_channel, &cares->addr.v4, - sizeof(cares->addr.v4), - AF_INET, - (ares_host_callback)_ecore_con_info_ares_host_cb, - cares); - } -#ifdef HAVE_IPV6 - else if (inet_pton(AF_INET6, svr->ecs ? svr->ecs->ip : svr->name, &cares->addr.v6) == 1) - { - cares->byaddr = EINA_TRUE; - cares->isv6 = EINA_TRUE; - ares_gethostbyaddr(info_channel, &cares->addr.v6, - sizeof(cares->addr.v6), - AF_INET6, - (ares_host_callback)_ecore_con_info_ares_host_cb, - cares); - } -#endif - else - { - cares->byaddr = EINA_FALSE; - ares_gethostbyname(info_channel, svr->ecs ? svr->ecs->ip : svr->name, ai_family, - (ares_host_callback)_ecore_con_info_ares_host_cb, - cares); - } - - svr->infos = eina_list_append(svr->infos, cares); - return 1; -} - -void -ecore_con_info_data_clear(void *info) -{ - Ecore_Con_CAres *cares = info; - if (cares) cares->data = NULL; -} - -static Eina_Bool -_ecore_con_info_cares_timeout_cb(void *data __UNUSED__) -{ - ares_process_fd(info_channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD); - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool -_ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf, - Ecore_Fd_Handler *fd_handler) -{ - ares_socket_t read_fd, write_fd; - - read_fd = write_fd = ARES_SOCKET_BAD; - - if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) - read_fd = ecf->fd; - if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) - write_fd = ecf->fd; - - ares_process_fd(info_channel, read_fd, write_fd); - - return ECORE_CALLBACK_RENEW; -} - -static int -_ecore_con_info_fds_search(const Ecore_Con_FD *fd1, - const Ecore_Con_FD *fd2) -{ - return fd1->fd - fd2->fd; -} - -static void -_ecore_con_info_cares_state_cb(void *data __UNUSED__, - ares_socket_t fd, - int readable, - int writable) -{ - int flags = 0; - Ecore_Con_FD *search = NULL, *ecf = NULL; - - search = eina_list_search_unsorted(info_fds, - (Eina_Compare_Cb)_ecore_con_info_fds_search, &ecf); - - if (!(readable | writable)) - { - ares_process_fd(info_channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD); - if (search) - { - info_fds = eina_list_remove(info_fds, search); - ecore_timer_del(search->timer); - ecore_main_fd_handler_del(search->handler); - free(search); - } - return; - } - - if (!search) - { - search = malloc(sizeof(Ecore_Con_FD)); - EINA_SAFETY_ON_NULL_RETURN(search); - - search->fd = fd; - search->handler = ecore_main_fd_handler_add(fd, ECORE_FD_WRITE | ECORE_FD_READ, - (Ecore_Fd_Cb)_ecore_con_info_cares_fd_cb, search, NULL, NULL); - /* c-ares default timeout is 5 seconds */ - search->timer = ecore_timer_add(5, _ecore_con_info_cares_timeout_cb, NULL); - info_fds = eina_list_append(info_fds, search); - } - - if (readable) flags |= ECORE_FD_READ; - if (writable) flags |= ECORE_FD_WRITE; - ecore_main_fd_handler_active_set(search->handler, flags); -} - -static void -_ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg, - int status, - int timeouts __UNUSED__, - struct hostent *hostent) -{ - struct sockaddr *addr; - int addrlen; - - /* Found something ? */ - switch (status) - { - case ARES_SUCCESS: - if (!hostent->h_addr_list[0]) - { - ERR("No IP found"); - goto on_error; - } - - switch (hostent->h_addrtype) - { - case AF_INET: - { - struct sockaddr_in *addri; - - addrlen = sizeof(struct sockaddr_in); - addri = malloc(addrlen); - - if (!addri) - goto on_mem_error; - - addri->sin_family = AF_INET; - addri->sin_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port); - - memcpy(&addri->sin_addr.s_addr, - hostent->h_addr_list[0], sizeof(struct in_addr)); - - addr = (struct sockaddr *)addri; - break; - } -#ifdef HAVE_IPV6 - case AF_INET6: - { - struct sockaddr_in6 *addri6; - - addrlen = sizeof(struct sockaddr_in6); - addri6 = malloc(addrlen); - - if (!addri6) - goto on_mem_error; - - addri6->sin6_family = AF_INET6; - addri6->sin6_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port); - addri6->sin6_flowinfo = 0; - addri6->sin6_scope_id = 0; - - memcpy(&addri6->sin6_addr.s6_addr, - hostent->h_addr_list[0], sizeof(struct in6_addr)); - - addr = (struct sockaddr *)addri6; - break; - } -#endif - default: - ERR("Unknown addrtype %i", hostent->h_addrtype); - goto on_error; - } - - if (!_ecore_con_info_ares_getnameinfo(arg, hostent->h_addrtype, - hostent->h_name, - addr, addrlen)) - goto on_error; - - break; - - case ARES_ENOTFOUND: /* address notfound */ - if (arg->byaddr) - { -#ifdef HAVE_IPV6 - /* This happen when host doesn't have a reverse. */ - if (arg->isv6) - { - struct sockaddr_in6 *addri6; - - addrlen = sizeof(struct sockaddr_in6); - addri6 = malloc(addrlen); - - if (!addri6) - goto on_mem_error; - - addri6->sin6_family = AF_INET6; - addri6->sin6_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port); - addri6->sin6_flowinfo = 0; - addri6->sin6_scope_id = 0; - - memcpy(&addri6->sin6_addr.s6_addr, - &arg->addr.v6, sizeof(struct in6_addr)); - - addr = (struct sockaddr *)addri6; - } - else -#endif - { - struct sockaddr_in *addri; - - addrlen = sizeof(struct sockaddr_in); - addri = malloc(addrlen); - - if (!addri) - goto on_mem_error; - - addri->sin_family = AF_INET; - addri->sin_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port); - - memcpy(&addri->sin_addr.s_addr, - &arg->addr.v4, sizeof(struct in_addr)); - - addr = (struct sockaddr *)addri; - } - - if (!_ecore_con_info_ares_getnameinfo(arg, -#ifdef HAVE_IPV6 - arg->isv6 ? AF_INET6 : -#endif - AF_INET, - NULL, addr, - addrlen)) - goto on_error; - - break; - } - - case ARES_ENOTIMP: /* unknown family */ - case ARES_EBADNAME: /* not a valid internet address */ - case ARES_ENOMEM: /* not enough memory */ - case ARES_EDESTRUCTION: /* request canceled, shuting down */ - case ARES_ENODATA: /* no data returned */ - case ARES_ECONNREFUSED: /* connection refused */ - case ARES_ETIMEOUT: /* connection timed out */ - ecore_con_event_server_error(arg->svr, ares_strerror(status)); - goto on_error; - - default: - ERR("Unknown status returned by c-ares: %i assuming error", status); - ecore_con_event_server_error(arg->svr, ares_strerror(status)); - goto on_error; - } - - return; - -on_mem_error: - ERR("Not enough memory"); - -on_error: - if (arg->data) - { - ecore_con_server_infos_del(arg->data, arg); - arg->done_cb(arg->data, NULL); - } - free(arg); -} - -static void -_ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg, - int status, - int timeouts __UNUSED__, - char *node, - char *service) -{ - switch (status) - { - case ARES_SUCCESS: - if (node) - strcpy(arg->result->ip, node); - else - *arg->result->ip = '\0'; - - if (service) - strcpy(arg->result->service, service); - else - *arg->result->service = '\0'; - - if (arg->data) arg->done_cb(arg->data, arg->result); - break; - - case ARES_ENOTIMP: - case ARES_ENOTFOUND: - case ARES_ENOMEM: - case ARES_EDESTRUCTION: - case ARES_EBADFLAGS: - ecore_con_event_server_error(arg->svr, ares_strerror(status)); - if (arg->data) arg->done_cb(arg->data, NULL); - break; - } - - free(arg->result->info.ai_addr); - free(arg->result); - if (arg->data) ecore_con_server_infos_del(arg->data, arg); - free(arg); -} - diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_info.c b/libraries/ecore/src/lib/ecore_con/ecore_con_info.c deleted file mode 100644 index fdcf0b9..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_info.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * getaddrinfo with callback - * - * man getaddrinfo - * - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifdef HAVE_ALLOCA_H -# include -#elif defined __GNUC__ -# define alloca __builtin_alloca -#elif defined _AIX -# define alloca __alloca -#elif defined _MSC_VER -# include -# define alloca _alloca -#else -# include -# ifdef __cplusplus -extern "C" -# endif -void *alloca(size_t); -#endif - -#include -#include -#include -#include -#ifdef __OpenBSD__ -# include -#endif - -#ifdef HAVE_NETINET_IN_H -# include -#endif - -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#ifdef HAVE_ARPA_NAMESER_H -# include -#endif - -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - -#ifdef HAVE_NETDB_H -# include -#endif - -#include - -#include "Ecore.h" -#include "ecore_private.h" -#include "ecore_con_private.h" - -typedef struct _CB_Data CB_Data; - -struct _CB_Data -{ - EINA_INLIST; - Ecore_Con_Info_Cb cb_done; - void *data; - Ecore_Fd_Handler *fdh; - pid_t pid; - Ecore_Event_Handler *handler; - int fd2; -}; - -static void _ecore_con_info_readdata(CB_Data *cbdata); -static void _ecore_con_info_slave_free(CB_Data *cbdata); -static Eina_Bool _ecore_con_info_data_handler(void *data, - Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_info_exit_handler(void *data, - int type __UNUSED__, - void *event); - -static int info_init = 0; -static CB_Data *info_slaves = NULL; - -int -ecore_con_info_init(void) -{ - info_init++; - return info_init; -} - -int -ecore_con_info_shutdown(void) -{ - info_init--; - if (info_init == 0) - while (info_slaves) _ecore_con_info_slave_free(info_slaves); - - return info_init; -} - -int -ecore_con_info_tcp_connect(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_CANONNAME; - hints.ai_protocol = IPPROTO_TCP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -int -ecore_con_info_tcp_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - hints.ai_protocol = IPPROTO_TCP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -int -ecore_con_info_udp_connect(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_CANONNAME; - hints.ai_protocol = IPPROTO_UDP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -int -ecore_con_info_udp_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE; - hints.ai_protocol = IPPROTO_UDP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -int -ecore_con_info_mcast_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data) -{ - struct addrinfo hints; - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = 0; - hints.ai_protocol = IPPROTO_UDP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - return ecore_con_info_get(svr, done_cb, data, &hints); -} - -EAPI int -ecore_con_info_get(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data, - struct addrinfo *hints) -{ - CB_Data *cbdata; - int fd[2]; - - if (pipe(fd) < 0) - { - ecore_con_event_server_error(svr, strerror(errno)); - return 0; - } - - cbdata = calloc(1, sizeof(CB_Data)); - if (!cbdata) - { - close(fd[0]); - close(fd[1]); - return 0; - } - - cbdata->cb_done = done_cb; - cbdata->data = data; - cbdata->fd2 = fd[1]; - if (!(cbdata->fdh = ecore_main_fd_handler_add(fd[0], ECORE_FD_READ, - _ecore_con_info_data_handler, - cbdata, - NULL, NULL))) - { - ecore_con_event_server_error(svr, "Memory allocation failure"); - free(cbdata); - close(fd[0]); - close(fd[1]); - return 0; - } - - if ((cbdata->pid = fork()) == 0) - { - Ecore_Con_Info *container; - struct addrinfo *result = NULL; - char service[NI_MAXSERV] = {0}; - char hbuf[NI_MAXHOST] = {0}; - char sbuf[NI_MAXSERV] = {0}; - unsigned char *tosend = NULL; - int tosend_len; - int canonname_len = 0; - - eina_convert_itoa(svr->ecs ? svr->ecs->port : svr->port, service); - /* CHILD */ - if (!getaddrinfo(svr->ecs ? svr->ecs->ip : svr->name, service, hints, &result) && result) - { - if (result->ai_canonname) - canonname_len = strlen(result->ai_canonname) + 1; - - tosend_len = sizeof(Ecore_Con_Info) + result->ai_addrlen + - canonname_len; - - tosend = alloca(tosend_len); - memset(tosend, 0, tosend_len); - - container = (Ecore_Con_Info *)tosend; - container->size = tosend_len; - - memcpy(&container->info, - result, - sizeof(struct addrinfo)); - memcpy(tosend + sizeof(Ecore_Con_Info), - result->ai_addr, - result->ai_addrlen); - if (result->ai_canonname) /* FIXME: else... */ - memcpy(tosend + sizeof(Ecore_Con_Info) + result->ai_addrlen, - result->ai_canonname, - canonname_len); - - if (!getnameinfo(result->ai_addr, result->ai_addrlen, - hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), - NI_NUMERICHOST | NI_NUMERICSERV)) - { - memcpy(container->ip, hbuf, sizeof(container->ip)); - memcpy(container->service, sbuf, sizeof(container->service)); - } - - if (write(fd[1], tosend, tosend_len) < 0) perror("write"); - } - - if (result) - freeaddrinfo(result); - - if (write(fd[1], "", 1) < 0) perror("write"); - close(fd[1]); -#if defined(__USE_ISOC99) && !defined(__UCLIBC__) - _Exit(0); -#else - _exit(0); -#endif - } - - /* PARENT */ - cbdata->handler = - ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _ecore_con_info_exit_handler, - cbdata); - close(fd[1]); - if (!cbdata->handler) - { - ecore_main_fd_handler_del(cbdata->fdh); - free(cbdata); - close(fd[0]); - return 0; - } - - info_slaves = (CB_Data *)eina_inlist_append(EINA_INLIST_GET( - info_slaves), - EINA_INLIST_GET(cbdata)); - svr->infos = eina_list_append(svr->infos, cbdata); - return 1; -} - -void -ecore_con_info_data_clear(void *info) -{ - CB_Data *cbdata = info; - cbdata->data = NULL; -} - -static void -_ecore_con_info_readdata(CB_Data *cbdata) -{ - Ecore_Con_Info container; - Ecore_Con_Info *recv_info; - unsigned char *torecv; - int torecv_len; - - ssize_t size; - - size = read(ecore_main_fd_handler_fd_get(cbdata->fdh), &container, - sizeof(Ecore_Con_Info)); - if (size == sizeof(Ecore_Con_Info)) - { - torecv_len = container.size; - torecv = malloc(torecv_len); - - memcpy(torecv, &container, sizeof(Ecore_Con_Info)); - - size = read(ecore_main_fd_handler_fd_get(cbdata->fdh), - torecv + sizeof(Ecore_Con_Info), - torecv_len - sizeof(Ecore_Con_Info)); - if ((size > 0) && - ((size_t)size == torecv_len - sizeof(Ecore_Con_Info))) - { - recv_info = (Ecore_Con_Info *)torecv; - - recv_info->info.ai_addr = - (struct sockaddr *)(torecv + sizeof(Ecore_Con_Info)); - if ((size_t)torecv_len != - (sizeof(Ecore_Con_Info) + recv_info->info.ai_addrlen)) - recv_info->info.ai_canonname = (char *) - (torecv + sizeof(Ecore_Con_Info) + recv_info->info.ai_addrlen); - else - recv_info->info.ai_canonname = NULL; - - recv_info->info.ai_next = NULL; - - if (cbdata->data) - { - cbdata->cb_done(cbdata->data, recv_info); - ecore_con_server_infos_del(cbdata->data, cbdata); - } - - free(torecv); - } - else - { - if (cbdata->data) - { - cbdata->cb_done(cbdata->data, NULL); - ecore_con_server_infos_del(cbdata->data, cbdata); - } - } - } - else - { - if (cbdata->data) - { - ecore_con_event_server_error(cbdata->data, strerror(errno)); - cbdata->cb_done(cbdata->data, NULL); - ecore_con_server_infos_del(cbdata->data, cbdata); - } - } - - cbdata->cb_done = NULL; -} - -static void -_ecore_con_info_slave_free(CB_Data *cbdata) -{ - info_slaves = (CB_Data *)eina_inlist_remove(EINA_INLIST_GET(info_slaves), - EINA_INLIST_GET(cbdata)); - ecore_main_fd_handler_del(cbdata->fdh); - ecore_event_handler_del(cbdata->handler); - close(ecore_main_fd_handler_fd_get(cbdata->fdh)); - if (cbdata->data) ecore_con_server_infos_del(cbdata->data, cbdata); - free(cbdata); -} - -static Eina_Bool -_ecore_con_info_data_handler(void *data, - Ecore_Fd_Handler *fd_handler) -{ - CB_Data *cbdata; - - cbdata = data; - if (cbdata->cb_done) - { - if (ecore_main_fd_handler_active_get(fd_handler, - ECORE_FD_READ)) - _ecore_con_info_readdata(cbdata); - else - { - if (cbdata->data) - { - cbdata->cb_done(cbdata->data, NULL); - cbdata->cb_done = NULL; - ecore_con_server_infos_del(cbdata->data, cbdata); - } - } - } - - _ecore_con_info_slave_free(cbdata); - return ECORE_CALLBACK_CANCEL; -} - -static Eina_Bool -_ecore_con_info_exit_handler(void *data, - int type __UNUSED__, - void *event) -{ - CB_Data *cbdata; - Ecore_Exe_Event_Del *ev; - - ev = event; - cbdata = data; - if (cbdata->pid != ev->pid) - return ECORE_CALLBACK_RENEW; - - return ECORE_CALLBACK_CANCEL; /* FIXME: Woot ??? */ - _ecore_con_info_slave_free(cbdata); - return ECORE_CALLBACK_CANCEL; -} - diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_local.c b/libraries/ecore/src/lib/ecore_con/ecore_con_local.c deleted file mode 100644 index f02cc1f..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_local.c +++ /dev/null @@ -1,317 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - -#ifdef HAVE_SYS_UN_H -# include -#endif - -#ifdef HAVE_WS2TCPIP_H -# include -#endif - -#include -#include - -#include "Ecore_Con.h" -#include "ecore_con_private.h" - -#define LENGTH_OF_SOCKADDR_UN(s) (strlen((s)->sun_path) + \ - (size_t)(((struct sockaddr_un *)NULL)-> \ - sun_path)) -#define LENGTH_OF_ABSTRACT_SOCKADDR_UN(s, path) (strlen(path) + 1 + \ - (size_t)(((struct sockaddr_un \ - *)NULL)->sun_path)) - -static int _ecore_con_local_init_count = 0; - -int -ecore_con_local_init(void) -{ - if (++_ecore_con_local_init_count != 1) - return _ecore_con_local_init_count; - - return _ecore_con_local_init_count; -} - -int -ecore_con_local_shutdown(void) -{ - if (--_ecore_con_local_init_count != 0) - return _ecore_con_local_init_count; - - return _ecore_con_local_init_count; -} - -int -ecore_con_local_connect(Ecore_Con_Server *svr, - Eina_Bool (*cb_done)(void *data, Ecore_Fd_Handler *fd_handler), - void *data __UNUSED__) -{ -#ifndef HAVE_LOCAL_SOCKETS - return 0; -#else - char buf[4096]; - struct sockaddr_un socket_unix; - int curstate = 0; - const char *homedir; - int socket_unix_len; - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER) - { - homedir = getenv("HOME"); - if (!homedir) - homedir = getenv("TMP"); - - if (!homedir) - homedir = "/tmp"; - - snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", homedir, svr->name, - svr->port); - } - else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM) - { - if (svr->port < 0) - { - if (svr->name[0] == '/') - strncpy(buf, svr->name, sizeof(buf)); - else - snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s", svr->name); - } - else - { - if (svr->name[0] == - '/') - snprintf(buf, sizeof(buf), "%s|%i", svr->name, - svr->port); - else - snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s|%i", - svr->name, - svr->port); - } - } - else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - strncpy(buf, svr->name, - sizeof(buf)); - - svr->fd = socket(AF_UNIX, SOCK_STREAM, 0); - if (svr->fd < 0) - return 0; - - if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) - return 0; - - if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) - return 0; - - if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, - sizeof(curstate)) < 0) - return 0; - - socket_unix.sun_family = AF_UNIX; - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - { -#ifdef HAVE_ABSTRACT_SOCKETS - /* copy name insto sun_path, prefixed by null to indicate abstract namespace */ - snprintf(socket_unix.sun_path, sizeof(socket_unix.sun_path), ".%s", - svr->name); - socket_unix.sun_path[0] = '\0'; - socket_unix_len = LENGTH_OF_ABSTRACT_SOCKADDR_UN(&socket_unix, - svr->name); -#else - WRN("Your system does not support abstract sockets!"); - return 0; -#endif - } - else - { - strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); - socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); - } - - if (connect(svr->fd, (struct sockaddr *)&socket_unix, - socket_unix_len) < 0) - return 0; - - svr->path = strdup(buf); - if (!svr->path) - return 0; - - if (svr->type & ECORE_CON_SSL) - ecore_con_ssl_server_init(svr); - - svr->fd_handler = - ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, - cb_done, svr, NULL, NULL); - if (!svr->fd_handler) - return 0; - - if (!svr->delete_me) ecore_con_event_server_add(svr); - - return 1; -#endif -} - -int -ecore_con_local_listen( - Ecore_Con_Server *svr, - Eina_Bool (* - cb_listen)(void *data, - Ecore_Fd_Handler * - fd_handler), - void *data - __UNUSED__) -{ -#ifdef HAVE_LOCAL_SOCKETS - char buf[4096]; - struct sockaddr_un socket_unix; - struct linger lin; - mode_t pmode; - const char *homedir; - struct stat st; - mode_t mask; - int socket_unix_len; - - mask = S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH; - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER) - { - homedir = getenv("HOME"); - if (!homedir) - homedir = getenv("TMP"); - - if (!homedir) - homedir = "/tmp"; - - mask = S_IRUSR | S_IWUSR | S_IXUSR; - snprintf(buf, sizeof(buf), "%s/.ecore", homedir); - if (stat(buf, &st) < 0) - mkdir(buf, mask); - - snprintf(buf, sizeof(buf), "%s/.ecore/%s", homedir, svr->name); - if (stat(buf, &st) < 0) - mkdir(buf, mask); - - snprintf(buf, - sizeof(buf), - "%s/.ecore/%s/%i", - homedir, - svr->name, - svr->port); - mask = S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH; - } - else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM) - { - mask = 0; - if (svr->name[0] == '/') - { - if (svr->port >= 0) - snprintf(buf, - sizeof(buf), - "%s|%i", - svr->name, - svr->port); - else - snprintf(buf, - sizeof(buf), - "%s", - svr->name); - } - else - snprintf(buf, - sizeof(buf), - "/tmp/.ecore_service|%s|%i", - svr->name, - svr->port); - } - else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - strncpy(buf, svr->name, - sizeof(buf)); - - pmode = umask(mask); -start: - svr->fd = socket(AF_UNIX, SOCK_STREAM, 0); - if (svr->fd < 0) - goto error_umask; - - if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) - goto error_umask; - - if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) - goto error_umask; - - lin.l_onoff = 1; - lin.l_linger = 0; - if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin, - sizeof(struct linger)) < 0) - goto error_umask; - - socket_unix.sun_family = AF_UNIX; - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - { -#ifdef HAVE_ABSTRACT_SOCKETS - /* . is a placeholder */ - snprintf(socket_unix.sun_path, sizeof(socket_unix.sun_path), ".%s", - svr->name); - /* first char null indicates abstract namespace */ - socket_unix.sun_path[0] = '\0'; - socket_unix_len = LENGTH_OF_ABSTRACT_SOCKADDR_UN(&socket_unix, - svr->name); -#else - ERR("Your system does not support abstract sockets!"); - goto error_umask; -#endif - } - else - { - strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); - socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); - } - - if (bind(svr->fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) - { - if ((((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER) || - ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM)) && - (connect(svr->fd, (struct sockaddr *)&socket_unix, - socket_unix_len) < 0) && - (unlink(buf) >= 0)) - goto start; - else - goto error_umask; - } - - if (listen(svr->fd, 4096) < 0) - goto error_umask; - - svr->path = strdup(buf); - if (!svr->path) - goto error_umask; - - svr->fd_handler = - ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, - cb_listen, svr, NULL, NULL); - umask(pmode); - if (!svr->fd_handler) - goto error; - - return 1; - -error_umask: - umask(pmode); -error: -#endif /* HAVE_LOCAL_SOCKETS */ - return 0; -} - diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_local_win32.c b/libraries/ecore/src/lib/ecore_con/ecore_con_local_win32.c deleted file mode 100644 index 2b7e5c5..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_local_win32.c +++ /dev/null @@ -1,754 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include -#include - -#include "Ecore_Con.h" -#include "ecore_con_private.h" - -#define BUFSIZE 512 - - -static int _ecore_con_local_init_count = 0; - -int -ecore_con_local_init(void) -{ - if (++_ecore_con_local_init_count != 1) - return _ecore_con_local_init_count; - - return _ecore_con_local_init_count; -} - -int -ecore_con_local_shutdown(void) -{ - if (--_ecore_con_local_init_count != 0) - return _ecore_con_local_init_count; - - return _ecore_con_local_init_count; -} - - -static Eina_Bool -_ecore_con_local_win32_server_read_client_handler(void *data, Ecore_Win32_Handler *wh) -{ - Ecore_Con_Client *cl; - void *buf; - DWORD n; - Eina_Bool broken_pipe = EINA_FALSE; - - cl = (Ecore_Con_Client *)data; - - if (!ResetEvent(cl->host_server->event_read)) - return ECORE_CALLBACK_RENEW; - - buf = malloc(cl->host_server->nbr_bytes); - if (!buf) - return ECORE_CALLBACK_RENEW; - - if (ReadFile(cl->host_server->pipe, buf, cl->host_server->nbr_bytes, &n, NULL)) - { - if (!cl->delete_me) - ecore_con_event_client_data(cl, buf, cl->host_server->nbr_bytes, EINA_FALSE); - cl->host_server->want_write = 1; - } - else - { - if (GetLastError() == ERROR_BROKEN_PIPE) - broken_pipe = EINA_TRUE; - } - - if (broken_pipe) - { -#if 0 - char *msg; - - msg = evil_last_error_get(); - if (msg) - { - ecore_con_event_client_error(cl, msg); - free(msg); - } -#endif - _ecore_con_client_kill(cl); - return ECORE_CALLBACK_CANCEL; - } - - if (cl->host_server->want_write) - ecore_con_local_win32_client_flush(cl); - - ecore_main_win32_handler_del(wh); - - return ECORE_CALLBACK_DONE; -} - -static Eina_Bool -_ecore_con_local_win32_server_peek_client_handler(void *data, Ecore_Win32_Handler *wh) -{ - Ecore_Con_Client *cl; -#if 0 - char *msg; -#endif - - cl = (Ecore_Con_Client *)data; - - if (!ResetEvent(cl->host_server->event_peek)) - return ECORE_CALLBACK_RENEW; - -#if 0 - msg = evil_last_error_get(); - if (msg) - { - ecore_con_event_server_error(cl->host_server, msg); - free(msg); - } -#endif - _ecore_con_server_kill(cl->host_server); - return ECORE_CALLBACK_CANCEL; - - ecore_main_win32_handler_del(wh); - - return ECORE_CALLBACK_DONE; -} - -static Eina_Bool -_ecore_con_local_win32_client_peek_server_handler(void *data, Ecore_Win32_Handler *wh) -{ - Ecore_Con_Server *svr; -#if 0 - char *msg; -#endif - - svr = (Ecore_Con_Server *)data; - - if (!ResetEvent(svr->event_peek)) - return ECORE_CALLBACK_RENEW; -#if 0 - msg = evil_last_error_get(); - if (msg) - { - ecore_con_event_server_error(svr, msg); - free(msg); - } -#endif - _ecore_con_server_kill(svr); - return ECORE_CALLBACK_CANCEL; - - ecore_main_win32_handler_del(wh); - - return ECORE_CALLBACK_DONE; -} - -static Eina_Bool -_ecore_con_local_win32_client_read_server_handler(void *data, Ecore_Win32_Handler *wh) -{ - Ecore_Con_Server *svr; - void *buf; - DWORD n; - Eina_Bool broken_pipe = EINA_FALSE; - - svr = (Ecore_Con_Server *)data; - - if (!ResetEvent(svr->event_read)) - return ECORE_CALLBACK_RENEW; - - buf = malloc(svr->nbr_bytes); - if (!buf) - return ECORE_CALLBACK_RENEW; - - if (ReadFile(svr->pipe, buf, svr->nbr_bytes, &n, NULL)) - { - if (!svr->delete_me) - ecore_con_event_server_data(svr, buf, svr->nbr_bytes, EINA_FALSE); - svr->want_write = 1; - } - else - { - if (GetLastError() == ERROR_BROKEN_PIPE) - broken_pipe = EINA_TRUE; - } - - if (broken_pipe) - { -#if 0 - char *msg; - - msg = evil_last_error_get(); - if (msg) - { - ecore_con_event_server_error(svr, msg); - free(msg); - } -#endif - _ecore_con_server_kill(svr); - return ECORE_CALLBACK_CANCEL; - } - - if (svr->want_write) - ecore_con_local_win32_server_flush(svr); - - ecore_main_win32_handler_del(wh); - - return ECORE_CALLBACK_DONE; -} - -/* thread to read data sent by the server to the client */ -static unsigned int __stdcall -_ecore_con_local_win32_client_read_server_thread(void *data) -{ - Ecore_Con_Server *svr; - DWORD nbr_bytes = 0; - - svr = (Ecore_Con_Server *)data; - - svr->read_stopped = EINA_FALSE; - - while (!svr->read_stop) - { - if (PeekNamedPipe(svr->pipe, NULL, 0, NULL, &nbr_bytes, NULL)) - { - if (nbr_bytes <= 0) - continue; - - svr->nbr_bytes = nbr_bytes; - if (!SetEvent(svr->event_read)) - continue; - } - else - { - if (GetLastError() == ERROR_BROKEN_PIPE) - { - if (!SetEvent(svr->event_peek)) - continue; - break; - } - } - } - - printf(" ### %s\n", __FUNCTION__); - svr->read_stopped = EINA_TRUE; - _endthreadex(0); - return 0; -} - -/* thread to read data sent by the client to the server */ -static unsigned int __stdcall -_ecore_con_local_win32_server_read_client_thread(void *data) -{ - Ecore_Con_Client *cl; - DWORD nbr_bytes = 0; - - cl = (Ecore_Con_Client *)data; - - cl->host_server->read_stopped = EINA_FALSE; - - while (!cl->host_server->read_stop) - { - if (PeekNamedPipe(cl->host_server->pipe, NULL, 0, NULL, &nbr_bytes, NULL)) - { - if (nbr_bytes <= 0) - continue; - - cl->host_server->nbr_bytes = nbr_bytes; - if (!SetEvent(cl->host_server->event_read)) - continue; - } - else - { - if (GetLastError() == ERROR_BROKEN_PIPE) - { - if (!SetEvent(cl->host_server->event_peek)) - continue; - break; - } - } - } - - printf(" ### %s\n", __FUNCTION__); - cl->host_server->read_stopped = EINA_TRUE; - _endthreadex(0); - return 0; -} - -static Eina_Bool -_ecore_con_local_win32_client_add(void *data, Ecore_Win32_Handler *wh) -{ - Ecore_Con_Client *cl = NULL; - Ecore_Con_Server *svr; - Ecore_Win32_Handler *handler_read; - Ecore_Win32_Handler *handler_peek; - - svr = (Ecore_Con_Server *)data; - - if (!svr->pipe) - return ECORE_CALLBACK_CANCEL; - - if (svr->delete_me) - return ECORE_CALLBACK_CANCEL; - - if ((svr->client_limit >= 0) && (!svr->reject_excess_clients) && - (svr->client_count >= (unsigned int)svr->client_limit)) - return ECORE_CALLBACK_CANCEL; - - cl = calloc(1, sizeof(Ecore_Con_Client)); - if (!cl) - { - ERR("allocation failed"); - return ECORE_CALLBACK_CANCEL; - } - - cl->host_server = svr; - ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT); - - cl->host_server->event_read = CreateEvent(NULL, TRUE, FALSE, NULL); - if (!cl->host_server->event_read) - { - ERR("Can not create event read"); - goto free_cl; - } - - handler_read = ecore_main_win32_handler_add(cl->host_server->event_read, - _ecore_con_local_win32_server_read_client_handler, - cl); - if (!handler_read) - { - ERR("Can not create handler read"); - goto close_event_read; - } - - cl->host_server->event_peek = CreateEvent(NULL, TRUE, FALSE, NULL); - if (!cl->host_server->event_peek) - { - ERR("Can not create event peek"); - goto del_handler_read; - } - - handler_peek = ecore_main_win32_handler_add(cl->host_server->event_peek, - _ecore_con_local_win32_server_peek_client_handler, - cl); - if (!handler_peek) - { - ERR("Can not create handler peek"); - goto close_event_peek; - } - - cl->host_server->read_stopped = EINA_TRUE; - cl->host_server->thread_read = (HANDLE)_beginthreadex(NULL, 0, _ecore_con_local_win32_server_read_client_thread, cl, CREATE_SUSPENDED, NULL); - if (!cl->host_server->thread_read) - { - ERR("Can not launch thread"); - goto del_handler_peek; - } - - svr->clients = eina_list_append(svr->clients, cl); - svr->client_count++; - - if (!cl->delete_me) - ecore_con_event_client_add(cl); - - ecore_main_win32_handler_del(wh); - - ResumeThread(cl->host_server->thread_read); - return ECORE_CALLBACK_DONE; - - del_handler_peek: - ecore_main_win32_handler_del(handler_peek); - close_event_peek: - CloseHandle(cl->host_server->event_peek); - del_handler_read: - ecore_main_win32_handler_del(handler_read); - close_event_read: - CloseHandle(cl->host_server->event_read); - free_cl: - free(cl); - - return ECORE_CALLBACK_CANCEL; -} - -static unsigned int __stdcall -_ecore_con_local_win32_listening(void *data) -{ - Ecore_Con_Server *svr; - BOOL res; - - svr = (Ecore_Con_Server *)data; - - while (1) - { - res = ConnectNamedPipe(svr->pipe, NULL); - if (!res) - { - ERR("Opening the connection to the client failed"); - CloseHandle(svr->pipe); - svr->pipe = NULL; - } - break; - } - - DBG("Client connected"); - - printf(" ### %s\n", __FUNCTION__); - _endthreadex(0); - return 0; -} - -Eina_Bool -ecore_con_local_listen(Ecore_Con_Server *svr) -{ - char buf[256]; - HANDLE thread_listening; - Ecore_Win32_Handler *handler; - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - { - ERR("Your system does not support abstract sockets!"); - return EINA_FALSE; - } - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER) - snprintf(buf, sizeof(buf), "\\\\.\\pipe\\%s", svr->name); - else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM) - { - const char *computername; - - computername = getenv("CoMPUTERNAME"); - snprintf(buf, sizeof(buf), "\\\\%s\\pipe\\%s", computername, svr->name); - } - - svr->path = strdup(buf); - if (!svr->path) - { - ERR("Allocation failed"); - return EINA_FALSE; - } - - /* - * synchronuous - * block mode - * wait mode - */ - svr->pipe = CreateNamedPipe(svr->path, - PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, - BUFSIZE, - BUFSIZE, - 5000, - NULL); - if (svr->pipe == INVALID_HANDLE_VALUE) - { - ERR("Creation of the named pipe failed"); - goto free_path; - } - - /* - * We use ConnectNamedPipe() to wait for a client to connect. - * As the function is blocking, to let the main loop continuing - * its iterations, we call ConnectNamedPipe() in a thread - */ - thread_listening = (HANDLE)_beginthreadex(NULL, 0, _ecore_con_local_win32_listening, svr, CREATE_SUSPENDED, NULL); - if (!thread_listening) - { - ERR("Creation of the listening thread failed"); - goto close_pipe; - } - - handler = ecore_main_win32_handler_add(thread_listening, - _ecore_con_local_win32_client_add, - svr); - if (!handler) - { - ERR("Creation of the client add handler failed"); - goto del_handler; - } - - svr->read_stopped = EINA_TRUE; - ResumeThread(thread_listening); - - return EINA_TRUE; - - del_handler: - ecore_main_win32_handler_del(handler); - close_pipe: - CloseHandle(svr->pipe); - free_path: - free(svr->path); - svr->path = NULL; - - return EINA_FALSE; -} - -void -ecore_con_local_win32_server_del(Ecore_Con_Server *svr) -{ - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - return; - - if (((svr->type & ECORE_CON_TYPE) != ECORE_CON_LOCAL_USER) && - ((svr->type & ECORE_CON_TYPE) != ECORE_CON_LOCAL_SYSTEM)) - return; - - svr->read_stop = 1; - while (!svr->read_stopped) - Sleep(100); - - if (svr->event_peek) - CloseHandle(svr->event_peek); - svr->event_peek = NULL; - if (svr->event_read) - CloseHandle(svr->event_read); - svr->event_read = NULL; - free(svr->path); - svr->path = NULL; - if (svr->pipe) - CloseHandle(svr->pipe); - svr->pipe = NULL; -} - -void -ecore_con_local_win32_client_del(Ecore_Con_Client *cl) -{ - if ((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - return; - - if (((cl->host_server->type & ECORE_CON_TYPE) != ECORE_CON_LOCAL_USER) && - ((cl->host_server->type & ECORE_CON_TYPE) != ECORE_CON_LOCAL_SYSTEM)) - return; - - cl->host_server->read_stop = 1; - while (!cl->host_server->read_stopped) - Sleep(100); - - if (cl->host_server->event_peek) - CloseHandle(cl->host_server->event_peek); - cl->host_server->event_peek = NULL; - if (cl->host_server->event_read) - CloseHandle(cl->host_server->event_read); - cl->host_server->event_read = NULL; - free(cl->host_server->path); - cl->host_server->path = NULL; - if (cl->host_server->pipe) - CloseHandle(cl->host_server->pipe); - cl->host_server->pipe = NULL; -} - -Eina_Bool -ecore_con_local_connect(Ecore_Con_Server *svr, - Eina_Bool (*cb_done)(void *data, - Ecore_Fd_Handler *fd_handler)) -{ - char buf[256]; - Ecore_Win32_Handler *handler_read; - Ecore_Win32_Handler *handler_peek; - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - { - ERR("Your system does not support abstract sockets!"); - return EINA_FALSE; - } - - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER) - snprintf(buf, sizeof(buf), "\\\\.\\pipe\\%s", svr->name); - else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM) - { - const char *computername; - - computername = getenv("COMPUTERNAME"); - snprintf(buf, sizeof(buf), "\\\\%s\\pipe\\%s", computername, svr->name); - } - - while (1) - { - svr->pipe = CreateFile(buf, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - 0, - NULL); - if (svr->pipe != INVALID_HANDLE_VALUE) - break; - - /* if pipe not busy, we exit */ - if (GetLastError() != ERROR_PIPE_BUSY) - { - ERR("Connection to a server failed"); - return EINA_FALSE; - } - - /* pipe busy, so we wait for it */ - if (!WaitNamedPipe(buf, NMPWAIT_WAIT_FOREVER)) - { - ERR("Can not wait for a server"); - goto close_pipe; - } - } - - svr->path = strdup(buf); - if (!svr->path) - { - ERR("Allocation failed"); - goto close_pipe; - } - - svr->event_read = CreateEvent(NULL, TRUE, FALSE, NULL); - if (!svr->event_read) - { - ERR("Can not create event read"); - goto free_path; - } - - handler_read = ecore_main_win32_handler_add(svr->event_read, - _ecore_con_local_win32_client_read_server_handler, - svr); - if (!handler_read) - { - ERR("Can not create handler read"); - goto close_event_read; - } - - svr->event_peek = CreateEvent(NULL, TRUE, FALSE, NULL); - if (!svr->event_peek) - { - ERR("Can not create event peek"); - goto del_handler_read; - } - - handler_peek = ecore_main_win32_handler_add(svr->event_peek, - _ecore_con_local_win32_client_peek_server_handler, - svr); - if (!handler_peek) - { - ERR("Can not create handler peek"); - goto close_event_peek; - } - - svr->thread_read = (HANDLE)_beginthreadex(NULL, 0, _ecore_con_local_win32_client_read_server_thread, svr, CREATE_SUSPENDED, NULL); - if (!svr->thread_read) - { - ERR("Can not launch thread"); - goto del_handler_peek; - } - - if (!svr->delete_me) ecore_con_event_server_add(svr); - - ResumeThread(svr->thread_read); - - return EINA_TRUE; - - del_handler_peek: - ecore_main_win32_handler_del(handler_peek); - close_event_peek: - CloseHandle(svr->event_peek); - del_handler_read: - ecore_main_win32_handler_del(handler_read); - close_event_read: - CloseHandle(svr->event_read); - free_path: - free(svr->path); - svr->path = NULL; - close_pipe: - CloseHandle(svr->pipe); - - return EINA_FALSE; -} - -Eina_Bool -ecore_con_local_win32_server_flush(Ecore_Con_Server *svr) -{ - int num; - BOOL res; - DWORD written; - - /* This check should never be true */ - if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) - return EINA_TRUE; - - if (((svr->type & ECORE_CON_TYPE) != ECORE_CON_LOCAL_USER) && - ((svr->type & ECORE_CON_TYPE) != ECORE_CON_LOCAL_SYSTEM)) - return EINA_FALSE; - - num = eina_binbuf_length_get(svr->buf) - svr->write_buf_offset; - if (num <= 0) return EINA_TRUE; - - res = WriteFile(svr->pipe, eina_binbuf_string_get(svr->buf) + svr->write_buf_offset, num, &written, NULL); - if (!res) - { - char *msg; - - msg = evil_last_error_get(); - if (msg) - { - ecore_con_event_server_error(svr, msg); - free(msg); - } - _ecore_con_server_kill(svr); - } - - svr->write_buf_offset += written; - if (svr->write_buf_offset >= eina_binbuf_length_get(svr->buf)) - { - svr->write_buf_offset = 0; - eina_binbuf_free(svr->buf); - svr->buf = NULL; - svr->want_write = 0; - } - else if (written < (DWORD)num) - svr->want_write = 1; - - return EINA_TRUE; -} - -Eina_Bool -ecore_con_local_win32_client_flush(Ecore_Con_Client *cl) -{ - Ecore_Con_Type type; - int num; - BOOL res; - DWORD written; - - type = cl->host_server->type & ECORE_CON_TYPE; - - /* This check should never be true */ - if (type == ECORE_CON_LOCAL_ABSTRACT) - return EINA_TRUE; - - if ((type != ECORE_CON_LOCAL_USER) && - (type != ECORE_CON_LOCAL_SYSTEM)) - return EINA_FALSE; - - num = eina_binbuf_length_get(cl->buf) - cl->buf_offset; - if (num <= 0) return EINA_TRUE; - - res = WriteFile(cl->host_server->pipe, eina_binbuf_string_get(cl->buf) + cl->buf_offset, num, &written, NULL); - if (!res) - { - char *msg; - - msg = evil_last_error_get(); - if (msg) - { - ecore_con_event_client_error(cl, msg); - free(msg); - } - _ecore_con_client_kill(cl); - } - - cl->buf_offset += written; - if (cl->buf_offset >= eina_binbuf_length_get(cl->buf)) - { - cl->buf_offset = 0; - eina_binbuf_free(cl->buf); - cl->buf = NULL; - cl->host_server->want_write = 0; - } - else if (written < (DWORD)num) - cl->host_server->want_write = 1; - - return EINA_TRUE; -} diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_private.h b/libraries/ecore/src/lib/ecore_con/ecore_con_private.h deleted file mode 100644 index 91f5d39..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_private.h +++ /dev/null @@ -1,397 +0,0 @@ -#ifndef _ECORE_CON_PRIVATE_H -#define _ECORE_CON_PRIVATE_H - -#include "ecore_private.h" -#include "Ecore_Con.h" - -#define ECORE_MAGIC_CON_SERVER 0x77665544 -#define ECORE_MAGIC_CON_CLIENT 0x77556677 -#define ECORE_MAGIC_CON_URL 0x77074255 - -#define ECORE_CON_TYPE 0x0f -#define ECORE_CON_SSL 0xf0 - -#if USE_GNUTLS -# include -#elif USE_OPENSSL -# include -#endif -#ifdef HAVE_CURL -#include -#endif - -#define READBUFSIZ 65536 - -extern int _ecore_con_log_dom; - -#ifdef ECORE_CON_DEFAULT_LOG_COLOR -#undef ECORE_LOG_DEFAULT_LOG_COLOR -#endif -#define ECORE_CON_DEFAULT_LOG_COLOR EINA_COLOR_BLUE - -#ifdef ERR -# undef ERR -#endif -#define ERR(...) EINA_LOG_DOM_ERR(_ecore_con_log_dom, __VA_ARGS__) - -#ifdef DBG -# undef DBG -#endif -#define DBG(...) EINA_LOG_DOM_DBG(_ecore_con_log_dom, __VA_ARGS__) - -#ifdef INF -# undef INF -#endif -#define INF(...) EINA_LOG_DOM_INFO(_ecore_con_log_dom, __VA_ARGS__) - -#ifdef WRN -# undef WRN -#endif -#define WRN(...) EINA_LOG_DOM_WARN(_ecore_con_log_dom, __VA_ARGS__) - -#ifdef CRIT -# undef CRIT -#endif -#define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_con_log_dom, __VA_ARGS__) - -typedef struct _Ecore_Con_Lookup Ecore_Con_Lookup; -typedef struct _Ecore_Con_Info Ecore_Con_Info; -typedef struct Ecore_Con_Socks Ecore_Con_Socks_v4; -typedef struct Ecore_Con_Socks_v5 Ecore_Con_Socks_v5; -typedef void (*Ecore_Con_Info_Cb)(void *data, Ecore_Con_Info *infos); - -typedef enum _Ecore_Con_State -{ - ECORE_CON_CONNECTED, - ECORE_CON_DISCONNECTED, - ECORE_CON_INPROGRESS -} Ecore_Con_State; - -typedef enum _Ecore_Con_Ssl_Error -{ - ECORE_CON_SSL_ERROR_NONE = 0, - ECORE_CON_SSL_ERROR_NOT_SUPPORTED, - ECORE_CON_SSL_ERROR_INIT_FAILED, - ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED, - ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED -} Ecore_Con_Ssl_Error; - -typedef enum _Ecore_Con_Ssl_Handshake -{ - ECORE_CON_SSL_STATE_DONE = 0, - ECORE_CON_SSL_STATE_HANDSHAKING, - ECORE_CON_SSL_STATE_INIT -} Ecore_Con_Ssl_State; - -typedef enum Ecore_Con_Proxy_State -{ /* named PROXY instead of SOCKS in case some handsome and enterprising - * developer decides to add HTTP CONNECT support - */ - ECORE_CON_PROXY_STATE_DONE = 0, - ECORE_CON_PROXY_STATE_RESOLVED, - ECORE_CON_PROXY_STATE_INIT, - ECORE_CON_PROXY_STATE_READ, - ECORE_CON_PROXY_STATE_AUTH, - ECORE_CON_PROXY_STATE_REQUEST, - ECORE_CON_PROXY_STATE_CONFIRM, -} Ecore_Con_Proxy_State; - -struct _Ecore_Con_Client -{ - ECORE_MAGIC; - int fd; - Ecore_Con_Server *host_server; - void *data; - Ecore_Fd_Handler *fd_handler; - unsigned int buf_offset; - Eina_Binbuf *buf; - const char *ip; - Eina_List *event_count; - struct sockaddr *client_addr; - int client_addr_len; - double start_time; - Ecore_Timer *until_deletion; - double disconnect_time; -#if USE_GNUTLS - gnutls_datum_t session_ticket; - gnutls_session_t session; -#elif USE_OPENSSL - SSL *ssl; - int ssl_err; -#endif - Ecore_Con_Ssl_State ssl_state; - Eina_Bool handshaking : 1; - Eina_Bool upgrade : 1; /* STARTTLS queued */ - Eina_Bool delete_me : 1; /* del event has been queued */ -}; - -struct _Ecore_Con_Server -{ - ECORE_MAGIC; - int fd; - Ecore_Con_Type type; - char *name; - int port; - char *path; - void *data; - Ecore_Fd_Handler *fd_handler; - Eina_List *clients; - unsigned int client_count; - Eina_Binbuf *buf; - unsigned int write_buf_offset; - Eina_List *infos; - Eina_List *event_count; - int client_limit; - pid_t ppid; - /* socks */ - Ecore_Con_Socks *ecs; - Ecore_Con_Proxy_State ecs_state; - int ecs_addrlen; - unsigned char ecs_addr[16]; - unsigned int ecs_buf_offset; - Eina_Binbuf *ecs_buf; - Eina_Binbuf *ecs_recvbuf; - const char *proxyip; - int proxyport; - /* endsocks */ - const char *verify_name; -#if USE_GNUTLS - gnutls_session_t session; - gnutls_anon_client_credentials_t anoncred_c; - gnutls_anon_server_credentials_t anoncred_s; - gnutls_psk_client_credentials_t pskcred_c; - gnutls_psk_server_credentials_t pskcred_s; - gnutls_certificate_credentials_t cert; - char *cert_file; - gnutls_dh_params_t dh_params; -#elif USE_OPENSSL - SSL_CTX *ssl_ctx; - SSL *ssl; - int ssl_err; -#endif - double start_time; - Ecore_Timer *until_deletion; - double disconnect_time; - double client_disconnect_time; - const char *ip; - Eina_Bool created : 1; /* EINA_TRUE if server is our listening server */ - Eina_Bool connecting : 1; /* EINA_FALSE if just initialized or connected */ - Eina_Bool handshaking : 1; /* EINA_TRUE if server is ssl handshaking */ - Eina_Bool upgrade : 1; /* STARTTLS queued */ - Eina_Bool ssl_prepared : 1; - Eina_Bool use_cert : 1; /* EINA_TRUE if using certificate auth */ - Ecore_Con_Ssl_State ssl_state; /* current state of ssl handshake on the server */ - Eina_Bool verify : 1; /* EINA_TRUE if certificates will be verified */ - Eina_Bool verify_basic : 1; /* EINA_TRUE if certificates will be verified only against the hostname */ - Eina_Bool reject_excess_clients : 1; - Eina_Bool delete_me : 1; /* del event has been queued */ -#ifdef _WIN32 - Eina_Bool want_write : 1; - Eina_Bool read_stop : 1; - Eina_Bool read_stopped : 1; - HANDLE pipe; - HANDLE thread_read; - HANDLE event_read; - HANDLE event_peek; - DWORD nbr_bytes; -#endif -}; - -#ifdef HAVE_CURL -struct _Ecore_Con_Url -{ - ECORE_MAGIC; - CURL *curl_easy; - struct curl_slist *headers; - Eina_List *additional_headers; - Eina_List *response_headers; - const char *url; - long proxy_type; - int status; - - Ecore_Timer *timer; - - Ecore_Con_Url_Time time_condition; - double timestamp; - void *data; - - void *post_data; - - int received; - int write_fd; - - unsigned int event_count; - Eina_Bool dead : 1; - Eina_Bool multi : 1; -}; -#endif - -struct _Ecore_Con_Info -{ - unsigned int size; - struct addrinfo info; - char ip[NI_MAXHOST]; - char service[NI_MAXSERV]; -}; - -struct _Ecore_Con_Lookup -{ - Ecore_Con_Dns_Cb done_cb; - const void *data; -}; - -#define ECORE_CON_SOCKS_CAST_ELSE(X) \ - Ecore_Con_Socks_v4 *v4 = NULL; \ - Ecore_Con_Socks_v5 *v5 = NULL; \ - if ((X) && ((X)->version == 4)) \ - v4 = (Ecore_Con_Socks_v4*)(X); \ - else if ((X) && ((X)->version == 5)) \ - v5 = (Ecore_Con_Socks_v5*)(X); \ - else - -struct Ecore_Con_Socks /* v4 */ -{ - unsigned char version; - - const char *ip; - int port; - const char *username; - unsigned int ulen; - Eina_Bool lookup : 1; - Eina_Bool bind : 1; -}; - -struct Ecore_Con_Socks_v5 -{ - unsigned char version; - - const char *ip; - int port; - const char *username; - unsigned int ulen; - Eina_Bool lookup : 1; - Eina_Bool bind : 1; - /* v5 only */ - unsigned char method; - const char *password; - unsigned int plen; -}; - -extern Ecore_Con_Socks *_ecore_con_proxy_once; -extern Ecore_Con_Socks *_ecore_con_proxy_global; -void ecore_con_socks_init(void); -void ecore_con_socks_shutdown(void); -Eina_Bool ecore_con_socks_svr_init(Ecore_Con_Server *svr); -void ecore_con_socks_read(Ecore_Con_Server *svr, unsigned char *buf, int num); -void ecore_con_socks_dns_cb(const char *canonname, const char *ip, struct sockaddr *addr, int addrlen, Ecore_Con_Server *svr); -/* from ecore_con.c */ -void ecore_con_server_infos_del(Ecore_Con_Server *svr, void *info); -void ecore_con_event_proxy_bind(Ecore_Con_Server *svr); -void ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num, Eina_Bool duplicate); -void ecore_con_event_server_del(Ecore_Con_Server *svr); -#define ecore_con_event_server_error(svr, error) _ecore_con_event_server_error((svr), (char*)(error), EINA_TRUE) -void _ecore_con_event_server_error(Ecore_Con_Server *svr, char *error, Eina_Bool duplicate); -void ecore_con_event_client_add(Ecore_Con_Client *cl); -void ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate); -void ecore_con_event_client_del(Ecore_Con_Client *cl); -void ecore_con_event_client_error(Ecore_Con_Client *cl, const char *error); -void _ecore_con_server_kill(Ecore_Con_Server *svr); -void _ecore_con_client_kill(Ecore_Con_Client *cl); -/* from ecore_local_win32.c */ -#ifdef _WIN32 -Eina_Bool ecore_con_local_listen(Ecore_Con_Server *svr); -Eina_Bool ecore_con_local_connect(Ecore_Con_Server *svr, - Eina_Bool (*cb_done)(void *data, - Ecore_Fd_Handler *fd_handler)); -Eina_Bool ecore_con_local_win32_server_flush(Ecore_Con_Server *svr); -Eina_Bool ecore_con_local_win32_client_flush(Ecore_Con_Client *cl); -void ecore_con_local_win32_server_del(Ecore_Con_Server *svr); -void ecore_con_local_win32_client_del(Ecore_Con_Client *cl); -#else -/* from ecore_local.c */ -int ecore_con_local_init(void); -int ecore_con_local_shutdown(void); -int ecore_con_local_connect(Ecore_Con_Server *svr, - Eina_Bool (*cb_done)( - void *data, - Ecore_Fd_Handler *fd_handler), - void *data); -int ecore_con_local_listen(Ecore_Con_Server *svr, - Eina_Bool (*cb_listen)( - void *data, - Ecore_Fd_Handler *fd_handler), - void *data); -#endif - -/* from ecore_con_info.c */ -int ecore_con_info_init(void); -int ecore_con_info_shutdown(void); -int ecore_con_info_tcp_connect(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data); -int ecore_con_info_tcp_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data); -int ecore_con_info_udp_connect(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data); -int ecore_con_info_udp_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data); -int ecore_con_info_mcast_listen(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data); -void ecore_con_info_data_clear(void *info); - -void ecore_con_event_server_add(Ecore_Con_Server *svr); - - -/* from ecore_con_ssl.c */ -Ecore_Con_Ssl_Error ecore_con_ssl_init(void); -Ecore_Con_Ssl_Error ecore_con_ssl_shutdown(void); -Ecore_Con_Ssl_Error ecore_con_ssl_server_prepare(Ecore_Con_Server *svr, int ssl_type); -Ecore_Con_Ssl_Error ecore_con_ssl_server_init(Ecore_Con_Server *svr); -Ecore_Con_Ssl_Error ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr); -int ecore_con_ssl_server_read(Ecore_Con_Server *svr, - unsigned char *buf, - int size); -int ecore_con_ssl_server_write(Ecore_Con_Server *svr, - const unsigned char *buf, - int size); -Ecore_Con_Ssl_Error ecore_con_ssl_client_init(Ecore_Con_Client *svr); -Ecore_Con_Ssl_Error ecore_con_ssl_client_shutdown(Ecore_Con_Client *svr); -int ecore_con_ssl_client_read(Ecore_Con_Client *svr, - unsigned char *buf, - int size); -int ecore_con_ssl_client_write(Ecore_Con_Client *svr, - const unsigned char *buf, - int size); - -int ecore_con_info_get(Ecore_Con_Server *svr, - Ecore_Con_Info_Cb done_cb, - void *data, - struct addrinfo *hints); - - -#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \ - TYPE *Type##_alloc(void); \ - void Type##_free(TYPE *e); - -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Add, ecore_con_event_client_add); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Del, ecore_con_event_client_del); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Write, ecore_con_event_client_write); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Data, ecore_con_event_client_data); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Error, ecore_con_event_server_error); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Error, ecore_con_event_client_error); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Add, ecore_con_event_server_add); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Del, ecore_con_event_server_del); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Write, ecore_con_event_server_write); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Data, ecore_con_event_server_data); -GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind); - -void ecore_con_mempool_init(void); -void ecore_con_mempool_shutdown(void); - -#undef GENERIC_ALLOC_FREE_HEADER - -#endif diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_socks.c b/libraries/ecore/src/lib/ecore_con/ecore_con_socks.c deleted file mode 100644 index 686f73b..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_socks.c +++ /dev/null @@ -1,940 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - -#ifdef HAVE_NETINET_TCP_H -# include -#endif - -#ifdef HAVE_NET_IF_H -# include -#endif - -/* if net/if.h is not found or if an older versions of net/if.h is provided - which does not define IF_NAMESIZE. We must define it ourselves */ -#ifndef IF_NAMESIZE -# ifdef IFNAMSIZ -# define IF_NAMESIZE IFNAMSIZ -# else -# define IF_NAMESIZE 16 -# endif -#endif - -#ifdef HAVE_NETINET_IN_H -# include -#endif - -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#ifdef HAVE_SYS_UN_H -# include -#endif - -#ifdef HAVE_WS2TCPIP_H -# include -#endif - -#ifdef HAVE_EVIL -# include -#endif - -#include "Ecore.h" -#include "ecore_private.h" -#include "Ecore_Con.h" -#include "ecore_con_private.h" - -/* http://tools.ietf.org/html/rfc1928 - o X'00' NO AUTHENTICATION REQUIRED - o X'01' GSSAPI - o X'02' USERNAME/PASSWORD - o X'03' to X'7F' IANA ASSIGNED - o X'80' to X'FE' RESERVED FOR PRIVATE METHODS - o X'FF' NO ACCEPTABLE METHODS -*/ -#define ECORE_CON_SOCKS_V5_METHOD_NONE 0 -#define ECORE_CON_SOCKS_V5_METHOD_GSSAPI 1 -#define ECORE_CON_SOCKS_V5_METHOD_USERPASS 2 - -static int ECORE_CON_SOCKS_V5_METHODS[] = -{ - ECORE_CON_SOCKS_V5_METHOD_NONE, -// ECORE_CON_SOCKS_V5_METHOD_GSSAPI, TODO - ECORE_CON_SOCKS_V5_METHOD_USERPASS -}; - -#define ECORE_CON_SOCKS_V5_TOTAL_METHODS sizeof(ECORE_CON_SOCKS_V5_METHODS) - -#define _ecore_con_server_kill(svr) do { \ - DBG("KILL %p", (svr)); \ - _ecore_con_server_kill((svr)); \ -} while (0) - -Eina_List *ecore_con_socks_proxies = NULL; - -static Ecore_Con_Socks * -_ecore_con_socks_find(unsigned char version, const char *ip, int port, const char *username, size_t ulen, const char *password, size_t plen) -{ - Eina_List *l; - Ecore_Con_Socks_v5 *ecs; - - if (!ecore_con_socks_proxies) return NULL; - - EINA_LIST_FOREACH(ecore_con_socks_proxies, l, ecs) - { - if (ecs->version != version) continue; - if (strcmp(ecs->ip, ip)) continue; - if ((port != -1) && (port != ecs->port)) continue; - if (ulen != ecs->ulen) continue; - if (username && strcmp(ecs->username, username)) continue; - if (version == 5) - { - if (plen != ecs->plen) continue; - if (password && strcmp(ecs->password, password)) continue; - } - return (Ecore_Con_Socks*)ecs; - } - return NULL; -} - -static void -_ecore_con_socks_free(Ecore_Con_Socks *ecs) -{ - ECORE_CON_SOCKS_CAST_ELSE(ecs) return; - - if (_ecore_con_proxy_once == ecs) _ecore_con_proxy_once = NULL; - if (_ecore_con_proxy_global == ecs) _ecore_con_proxy_global = NULL; - eina_stringshare_del(ecs->ip); - eina_stringshare_del(ecs->username); - free(ecs); -} - -static Eina_Bool -_ecore_con_socks_svr_init_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4) -{ - size_t addrlen, buflen, ulen = 1; - unsigned char *sbuf; - - addrlen = v4->lookup ? strlen(svr->name) + 1 : 0; - if (v4->username) ulen += v4->ulen; - buflen = sizeof(char) * (8 + ulen + addrlen); - sbuf = malloc(buflen); - if (!sbuf) - { - ecore_con_event_server_error(svr, "Memory allocation failure!"); - _ecore_con_server_kill(svr); - return EINA_FALSE; - } - /* http://en.wikipedia.org/wiki/SOCKS */ - sbuf[0] = 4; - sbuf[1] = v4->bind ? 2 : 1; - sbuf[2] = svr->port >> 8; - sbuf[3] = svr->port & 0xff; - if (addrlen) - { - sbuf[4] = sbuf[5] = sbuf[6] = 0; - sbuf[7] = 1; - } - else - /* SOCKSv4 only handles IPV4, so addrlen is always 4 */ - memcpy(sbuf + 4, svr->ecs_addr, 4); - if (v4->username) - memcpy(sbuf + 8, v4->username, ulen); - else - sbuf[8] = 0; - if (addrlen) memcpy(sbuf + 8 + ulen, svr->name, addrlen); - - svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen); - return EINA_TRUE; -} - -static Eina_Bool -_ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5) -{ - size_t buflen; - unsigned int x; - unsigned char *sbuf; - - if (v5->username) - buflen = sizeof(char) * (2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS); - else - buflen = 3; - sbuf = malloc(buflen); - if (!sbuf) - { - ecore_con_event_server_error(svr, "Memory allocation failure!"); - _ecore_con_server_kill(svr); - return EINA_FALSE; - } - /* http://en.wikipedia.org/wiki/SOCKS - * http://tools.ietf.org/html/rfc1928 - */ - sbuf[0] = 5; - if (v5->username) - { - sbuf[1] = ECORE_CON_SOCKS_V5_TOTAL_METHODS; - for (x = 2; x < 2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS; x++) - sbuf[x] = ECORE_CON_SOCKS_V5_METHODS[x - 2]; - } - else - { - sbuf[1] = 1; - sbuf[2] = ECORE_CON_SOCKS_V5_METHOD_NONE; - } - - svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen); - return EINA_TRUE; -} - -#define ECORE_CON_SOCKS_READ(EXACT) \ - if (num < EXACT) \ - { \ - if (!svr->ecs_recvbuf) svr->ecs_recvbuf = eina_binbuf_new(); \ - if (!svr->ecs_recvbuf) goto error; \ - eina_binbuf_append_length(svr->ecs_recvbuf, buf, num); \ - /* the slowest connection on earth */ \ - if (eina_binbuf_length_get(svr->ecs_recvbuf) != EXACT) return; \ - data = eina_binbuf_string_get(svr->ecs_recvbuf); \ - } \ - else if (num > EXACT) goto error; \ - else \ - data = buf - -static void -_ecore_con_socks_read_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4 __UNUSED__, const unsigned char *buf, unsigned int num) -{ - const unsigned char *data; - DBG("SOCKS: %d bytes", num); - ECORE_CON_SOCKS_READ(8); - -/* http://ufasoft.com/doc/socks4_protocol.htm */ - if (data[0]) goto error; - switch (data[1]) - { - case 90: - /* success! */ - break; - case 91: - ecore_con_event_server_error(svr, "proxy request rejected or failed"); - goto error; - case 92: - ecore_con_event_server_error(svr, "proxying SOCKS server could not perform authentication"); - goto error; - case 93: - ecore_con_event_server_error(svr, "proxy request authentication rejected"); - goto error; - default: - ecore_con_event_server_error(svr, "garbage data from proxy"); - goto error; - } - if (svr->ecs->bind) - { - unsigned int nport; - char naddr[IF_NAMESIZE]; - - memcpy(&nport, &data[2], 2); - svr->proxyport = ntohl(nport); - - if (!inet_ntop(AF_INET, &data[4], naddr, sizeof(naddr))) goto error; - svr->proxyip = eina_stringshare_add(naddr); - ecore_con_event_proxy_bind(svr); - } - svr->ecs_state = ECORE_CON_PROXY_STATE_DONE; - INF("PROXY CONNECTED"); - if (svr->ecs_recvbuf) eina_binbuf_free(svr->ecs_recvbuf); - svr->ecs_recvbuf = NULL; - svr->ecs_buf_offset = svr->ecs_addrlen = 0; - memset(svr->ecs_addr, 0, sizeof(svr->ecs_addr)); - if (!svr->ssl_state) - ecore_con_event_server_add(svr); - if (svr->ssl_state || (svr->buf && eina_binbuf_length_get(svr->buf))) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE); - return; -error: - _ecore_con_server_kill(svr); -} - -static Eina_Bool -_ecore_con_socks_auth_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5) -{ - size_t size; - unsigned char *data; - switch (v5->method) - { - case ECORE_CON_SOCKS_V5_METHOD_NONE: - svr->ecs_state = ECORE_CON_PROXY_STATE_REQUEST; - return EINA_TRUE; - case ECORE_CON_SOCKS_V5_METHOD_GSSAPI: - return EINA_TRUE; - case ECORE_CON_SOCKS_V5_METHOD_USERPASS: - if (!v5->username) return EINA_FALSE; - if (!v5->password) v5->plen = 1; - /* http://tools.ietf.org/html/rfc1929 */ - size = sizeof(char) * (3 + v5->ulen + v5->plen); - data = malloc(size); - if (!data) break; - data[0] = 1; - data[1] = v5->ulen; - memcpy(&data[2], v5->username, v5->ulen); - data[1 + v5->ulen] = v5->plen; - if (v5->password) - memcpy(&data[2 + v5->ulen], v5->password, v5->plen); - else - data[2 + v5->ulen] = 0; - svr->ecs_buf = eina_binbuf_manage_new_length(data, size); - return EINA_TRUE; - default: - break; - } - return EINA_FALSE; -} - -static void -_ecore_con_socks_read_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5, const unsigned char *buf, unsigned int num) -{ - const unsigned char *data; - - DBG("SOCKS: %d bytes", num); - switch (svr->ecs_state) - { - - case ECORE_CON_PROXY_STATE_READ: - ECORE_CON_SOCKS_READ(2); - /* http://en.wikipedia.org/wiki/SOCKS */ - if (data[0] != 5) goto error; - if (data[1] == 0xFF) - { - ecore_con_event_server_error(svr, "proxy authentication methods rejected"); - goto error; - } - v5->method = data[1]; - if (!_ecore_con_socks_auth_v5(svr, v5)) goto error; - if (svr->ecs_state == ECORE_CON_PROXY_STATE_REQUEST) - { - /* run again to skip auth reading */ - _ecore_con_socks_read_v5(svr, v5, NULL, 0); - return; - } - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); - svr->ecs_state = ECORE_CON_PROXY_STATE_AUTH; - break; - case ECORE_CON_PROXY_STATE_AUTH: - ECORE_CON_SOCKS_READ(2); - switch (v5->method) - { - case ECORE_CON_SOCKS_V5_METHOD_NONE: - CRIT("HOW DID THIS HAPPEN?????????"); - goto error; - case ECORE_CON_SOCKS_V5_METHOD_GSSAPI: - /* TODO: this */ - break; - case ECORE_CON_SOCKS_V5_METHOD_USERPASS: - if (data[0] != 1) - { - ecore_con_event_server_error(svr, "protocol error"); - goto error; /* wrong version */ - } - if (data[1]) - { - ecore_con_event_server_error(svr, "proxy request authentication rejected"); - goto error; - } - default: - break; - } - case ECORE_CON_PROXY_STATE_REQUEST: - { - size_t addrlen, buflen; - unsigned char *sbuf; - addrlen = v5->lookup ? strlen(svr->name) + 1 : (unsigned int)svr->ecs_addrlen; - buflen = sizeof(char) * (6 + addrlen); - sbuf = malloc(buflen); - if (!sbuf) - { - ecore_con_event_server_error(svr, "Memory allocation failure!"); - goto error; - } - sbuf[0] = 5; - sbuf[1] = v5->bind ? 2 : 1; /* TODO: 0x03 for UDP port association */ - sbuf[2] = 0; - if (v5->lookup) /* domain name */ - { - sbuf[3] = 3; - sbuf[4] = addrlen - 1; - memcpy(sbuf + 5, svr->name, addrlen - 1); - } - else - { - sbuf[3] = (svr->ecs_addrlen == 4) ? 1 : 4; - memcpy(sbuf + 4, svr->ecs_addr, addrlen); - } - sbuf[addrlen + 4] = svr->port >> 8; - sbuf[addrlen + 5] = svr->port & 0xff; - - svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen); - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); - break; - } - case ECORE_CON_PROXY_STATE_CONFIRM: - { - /* this is ugly because we have to read an exact number of bytes, - * but we don't know what that number is until we've already read - * at least 5 bytes to determine the length of the unknown stream. - * yep. - */ - size_t to_read, len = svr->ecs_recvbuf ? eina_binbuf_length_get(svr->ecs_recvbuf) : 0; - if (num + len < 5) - { - /* guarantees we get called again */ - ECORE_CON_SOCKS_READ(5); - } - if (len >= 5) - { - data = eina_binbuf_string_get(svr->ecs_recvbuf); - data += 3; - } - else - data = buf + 3 - len; - switch (data[0]) - { - case 1: - to_read = 4; - break; - case 3: - to_read = data[1] + 1; - break; - case 4: - to_read = 16; - /* lazy debugging stub comment */ - break; - default: - ecore_con_event_server_error(svr, "protocol error"); - goto error; - } - /* at this point, we finally know exactly how much we need to read */ - ECORE_CON_SOCKS_READ(6 + to_read); - - if (data[0] != 5) - { - ecore_con_event_server_error(svr, "protocol error"); - goto error; /* wrong version */ - } - switch (data[1]) - { - case 0: - break; - case 1: - ecore_con_event_server_error(svr, "general proxy failure"); - goto error; - case 2: - ecore_con_event_server_error(svr, "connection not allowed by ruleset"); - goto error; - case 3: - ecore_con_event_server_error(svr, "network unreachable"); - goto error; - case 4: - ecore_con_event_server_error(svr, "host unreachable"); - goto error; - case 5: - ecore_con_event_server_error(svr, "connection refused by destination host"); - goto error; - case 6: - ecore_con_event_server_error(svr, "TTL expired"); - goto error; - case 7: - ecore_con_event_server_error(svr, "command not supported / protocol error"); - goto error; - case 8: - ecore_con_event_server_error(svr, "address type not supported"); - default: - goto error; - } - if (data[2]) - { - ecore_con_event_server_error(svr, "protocol error"); - goto error; - } - memset(svr->ecs_addr, 0, sizeof(svr->ecs_addr)); - if (!svr->ssl_state) - ecore_con_event_server_add(svr); - if (svr->ssl_state || (svr->buf && eina_binbuf_length_get(svr->buf))) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE); - svr->ecs_buf_offset = svr->ecs_addrlen = 0; - svr->ecs_state = ECORE_CON_PROXY_STATE_DONE; - INF("PROXY CONNECTED"); - break; - } - default: - break; - } - if (svr->ecs_recvbuf) eina_binbuf_free(svr->ecs_recvbuf); - svr->ecs_recvbuf = NULL; - - return; -error: - _ecore_con_server_kill(svr); -} - -///////////////////////////////////////////////////////////////////////////////////// -void -ecore_con_socks_shutdown(void) -{ - Ecore_Con_Socks *ecs; - EINA_LIST_FREE(ecore_con_socks_proxies, ecs) - _ecore_con_socks_free(ecs); - _ecore_con_proxy_once = NULL; - _ecore_con_proxy_global = NULL; -} - -void -ecore_con_socks_read(Ecore_Con_Server *svr, unsigned char *buf, int num) -{ - ECORE_CON_SOCKS_CAST_ELSE(svr->ecs) return; - - if (svr->ecs_state < ECORE_CON_PROXY_STATE_READ) return; - - if (v4) _ecore_con_socks_read_v4(svr, v4, buf, (unsigned int)num); - else _ecore_con_socks_read_v5(svr, v5, buf, (unsigned int)num); -} - -Eina_Bool -ecore_con_socks_svr_init(Ecore_Con_Server *svr) -{ - ECORE_CON_SOCKS_CAST_ELSE(svr->ecs) return EINA_FALSE; - - if (!svr->ip) return EINA_FALSE; - if (svr->ecs_buf) return EINA_FALSE; - if (svr->ecs_state != ECORE_CON_PROXY_STATE_INIT) return EINA_FALSE; - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); - if (v4) return _ecore_con_socks_svr_init_v4(svr, v4); - return _ecore_con_socks_svr_init_v5(svr, v5); -} - -void -ecore_con_socks_dns_cb(const char *canonname __UNUSED__, const char *ip, struct sockaddr *addr, int addrlen __UNUSED__, Ecore_Con_Server *svr) -{ - svr->ip = eina_stringshare_add(ip); - svr->ecs_state++; - if (addr->sa_family == AF_INET) - { - memcpy(svr->ecs_addr, &((struct sockaddr_in *)addr)->sin_addr.s_addr, 4); - svr->ecs_addrlen = 4; - } -#ifdef HAVE_IPV6 - else - { - memcpy(svr->ecs_addr, &((struct sockaddr_in6 *)addr)->sin6_addr.s6_addr, 16); - svr->ecs_addrlen = 16; - } -#endif - ecore_con_socks_svr_init(svr); -} - -void -ecore_con_socks_init(void) -{ - const char *socks; - char *h, *p, *l, *u = NULL; - char buf[512]; - int port, lookup = 0; - Eina_Bool v5 = EINA_FALSE; - Ecore_Con_Socks *ecs; - unsigned char addr[sizeof(struct in_addr)]; -#ifdef HAVE_IPV6 - unsigned char addr6[sizeof(struct in6_addr)]; -#endif - - /* ECORE_CON_SOCKS_V4=[user@]host:port-[1|0] */ - socks = getenv("ECORE_CON_SOCKS_V4"); - if (!socks) - { - /* ECORE_CON_SOCKS_V5=[user@]host-port:[1|0] */ - socks = getenv("ECORE_CON_SOCKS_V5"); - v5 = EINA_TRUE; - } - if ((!socks) || (!socks[0]) || (strlen(socks) > 512)) return; - strncpy(buf, socks, sizeof(buf)); - h = strchr(buf, '@'); - /* username */ - if (h && (h - buf > 0)) *h++ = 0, u = buf; - else h = buf; - - /* host ip; I ain't resolvin shit here */ - p = strchr(h, '-'); - if (!p) return; - *p++ = 0; - if (!inet_pton(AF_INET, h, addr)) -#ifdef HAVE_IPV6 - { - if (!v5) return; - if (!inet_pton(AF_INET6, h, addr6)) - return; - } -#else - return; -#endif - - errno = 0; - port = strtol(p, &l, 10); - if (errno || (port < 0) || (port > 65535)) return; - if (l && (l[0] == ':')) - lookup = (l[1] == '1'); - if (v5) - ecs = ecore_con_socks5_remote_add(h, port, u, NULL); - else - ecs = ecore_con_socks4_remote_add(h, port, u); - if (!ecs) return; - ecore_con_socks_lookup_set(ecs, lookup); - ecore_con_socks_apply_always(ecs); - INF("Added global proxy server %s%s%s:%d - DNS lookup %s", - u ?: "", u ? "@" : "", h, port, lookup ? "ENABLED" : "DISABLED"); -} - -///////////////////////////////////////////////////////////////////////////////////// - -/** - * @defgroup Ecore_Con_Socks_Group Ecore Connection SOCKS functions - * @{ - */ - -/** - * Add a SOCKS v4 proxy to the proxy list - * - * Use this to create (or return, if previously added) a SOCKS proxy - * object which can be used by any ecore_con servers. - * @param ip The ip address of the proxy (NOT DOMAIN NAME. IP ADDRESS.) - * @param port The port to connect to on the proxy - * @param username The username to use for the proxy (OPTIONAL) - * @return An allocated proxy object, or NULL on failure - * @note This object NEVER needs to be explicitly freed. - * @since 1.2 - */ -EAPI Ecore_Con_Socks * -ecore_con_socks4_remote_add(const char *ip, int port, const char *username) -{ - Ecore_Con_Socks *ecs; - size_t ulen = 0; - - if ((!ip) || (!ip[0]) || (port < 0) || (port > 65535)) return NULL; - - if (username) - { - ulen = strlen(username); - /* max length for protocol */ - if ((!ulen) || (ulen > 255)) return NULL; - } - ecs = _ecore_con_socks_find(4, ip, port, username, ulen, NULL, 0); - if (ecs) return ecs; - - ecs = calloc(1, sizeof(Ecore_Con_Socks_v4)); - if (!ecs) return NULL; - - ecs->version = 4; - ecs->ip = eina_stringshare_add(ip); - ecs->port = port; - ecs->username = eina_stringshare_add(username); - ecs->ulen = ulen; - ecore_con_socks_proxies = eina_list_append(ecore_con_socks_proxies, ecs); - return ecs; -} - -/** - * Find a SOCKS v4 proxy in the proxy list - * - * Use this to determine if a SOCKS proxy was previously added by checking - * the proxy list against the parameters given. - * @param ip The ip address of the proxy (NOT DOMAIN NAME. IP ADDRESS.) - * @param port The port to connect to on the proxy, or -1 to match the first proxy with @p ip - * @param username The username used for the proxy (OPTIONAL) - * @return true only if a proxy exists matching the given params - * @note This function matches slightly more loosely than ecore_con_socks4_remote_add(), and - * ecore_con_socks4_remote_add() should be used to return the actual object. - * @since 1.2 - */ -EAPI Eina_Bool -ecore_con_socks4_remote_exists(const char *ip, int port, const char *username) -{ - if ((!ip) || (!ip[0]) || (port < -1) || (port > 65535) || (username && (!username[0]))) - return EINA_FALSE; - return !!_ecore_con_socks_find(4, ip, port, username, username ? strlen(username) : 0, NULL, 0); -} - -/** - * Remove a SOCKS v4 proxy from the proxy list and delete it - * - * Use this to remove a SOCKS proxy from the proxy list by checking - * the list against the parameters given. The proxy will then be deleted. - * @param ip The ip address of the proxy (NOT DOMAIN NAME. IP ADDRESS.) - * @param port The port to connect to on the proxy, or -1 to match the first proxy with @p ip - * @param username The username used for the proxy (OPTIONAL) - * @note This function matches in the same way as ecore_con_socks4_remote_exists(). - * @warning Be aware that deleting a proxy which is being used WILL ruin your life. - * @since 1.2 - */ -EAPI void -ecore_con_socks4_remote_del(const char *ip, int port, const char *username) -{ - Ecore_Con_Socks_v4 *v4; - - if ((!ip) || (!ip[0]) || (port < -1) || (port > 65535) || (username && (!username[0]))) return; - if (!ecore_con_socks_proxies) return; - - v4 = (Ecore_Con_Socks_v4*)_ecore_con_socks_find(4, ip, port, username, username ? strlen(username) : 0, NULL, 0); - if (!v4) return; - ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v4); - _ecore_con_socks_free((Ecore_Con_Socks*)v4); -} -/** - * Add a SOCKS v5 proxy to the proxy list - * - * Use this to create (or return, if previously added) a SOCKS proxy - * object which can be used by any ecore_con servers. - * @param ip The ip address of the proxy (NOT DOMAIN NAME. IP ADDRESS.) - * @param port The port to connect to on the proxy - * @param username The username to use for the proxy (OPTIONAL) - * @param password The password to use for the proxy (OPTIONAL) - * @return An allocated proxy object, or NULL on failure - * @note This object NEVER needs to be explicitly freed. - * @since 1.2 - */ -EAPI Ecore_Con_Socks * -ecore_con_socks5_remote_add(const char *ip, int port, const char *username, const char *password) -{ - Ecore_Con_Socks_v5 *ecs5; - size_t ulen = 0, plen = 0; - - if ((!ip) || (!ip[0]) || (port < 0) || (port > 65535)) return NULL; - - if (username) - { - ulen = strlen(username); - /* max length for protocol */ - if ((!ulen) || (ulen > 255)) return NULL; - } - if (password) - { - plen = strlen(password); - /* max length for protocol */ - if ((!plen) || (plen > 255)) return NULL; - } - ecs5 = (Ecore_Con_Socks_v5*)_ecore_con_socks_find(5, ip, port, username, ulen, password, plen); - if (ecs5) return (Ecore_Con_Socks*)ecs5; - - ecs5 = calloc(1, sizeof(Ecore_Con_Socks_v5)); - if (!ecs5) return NULL; - - ecs5->version = 5; - ecs5->ip = eina_stringshare_add(ip); - ecs5->port = port; - ecs5->username = eina_stringshare_add(username); - ecs5->ulen = ulen; - ecs5->password = eina_stringshare_add(password); - ecs5->plen = plen; - ecore_con_socks_proxies = eina_list_append(ecore_con_socks_proxies, ecs5); - return (Ecore_Con_Socks*)ecs5; -} - -/** - * Find a SOCKS v5 proxy in the proxy list - * - * Use this to determine if a SOCKS proxy was previously added by checking - * the proxy list against the parameters given. - * @param ip The ip address of the proxy (NOT DOMAIN NAME. IP ADDRESS.) - * @param port The port to connect to on the proxy, or -1 to match the first proxy with @p ip - * @param username The username used for the proxy (OPTIONAL) - * @param password The password used for the proxy (OPTIONAL) - * @return true only if a proxy exists matching the given params - * @note This function matches slightly more loosely than ecore_con_socks5_remote_add(), and - * ecore_con_socks5_remote_add() should be used to return the actual object. - * @since 1.2 - */ -EAPI Eina_Bool -ecore_con_socks5_remote_exists(const char *ip, int port, const char *username, const char *password) -{ - if ((!ip) || (!ip[0]) || (port < -1) || (port > 65535) || (username && (!username[0])) || (password && (!password[0]))) - return EINA_FALSE; - return !!_ecore_con_socks_find(5, ip, port, username, username ? strlen(username) : 0, password, password ? strlen(password) : 0); -} - -/** - * Remove a SOCKS v5 proxy from the proxy list and delete it - * - * Use this to remove a SOCKS proxy from the proxy list by checking - * the list against the parameters given. The proxy will then be deleted. - * @param ip The ip address of the proxy (NOT DOMAIN NAME. IP ADDRESS.) - * @param port The port to connect to on the proxy, or -1 to match the first proxy with @p ip - * @param username The username used for the proxy (OPTIONAL) - * @param password The password used for the proxy (OPTIONAL) - * @note This function matches in the same way as ecore_con_socks4_remote_exists(). - * @warning Be aware that deleting a proxy which is being used WILL ruin your life. - * @since 1.2 - */ -EAPI void -ecore_con_socks5_remote_del(const char *ip, int port, const char *username, const char *password) -{ - Ecore_Con_Socks_v5 *v5; - - if ((!ip) || (!ip[0]) || (port < -1) || (port > 65535) || (username && (!username[0])) || (password && (!password[0]))) - return; - if (!ecore_con_socks_proxies) return; - - v5 = (Ecore_Con_Socks_v5*)_ecore_con_socks_find(5, ip, port, username, username ? strlen(username) : 0, password, password ? strlen(password) : 0); - if (!v5) return; - ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v5); - _ecore_con_socks_free((Ecore_Con_Socks*)v5); -} - -/** - * Set DNS lookup mode on an existing SOCKS proxy - * - * According to RFC, SOCKS v4 does not require that a proxy perform - * its own DNS lookups for addresses. SOCKS v4a specifies the protocol - * for this. SOCKS v5 allows DNS lookups. - * If you want to enable remote DNS lookup and are sure that your - * proxy supports it, use this function. - * @param ecs The proxy object - * @param enable If true, the proxy will perform the dns lookup - * @note By default, this setting is DISABLED. - * @since 1.2 - */ -EAPI void -ecore_con_socks_lookup_set(Ecore_Con_Socks *ecs, Eina_Bool enable) -{ - ECORE_CON_SOCKS_CAST_ELSE(ecs) return; - ecs->lookup = !!enable; -} - -/** - * Get DNS lookup mode on an existing SOCKS proxy - * - * According to RFC, SOCKS v4 does not require that a proxy perform - * its own DNS lookups for addresses. SOCKS v4a specifies the protocol - * for this. SOCKS v5 allows DNS lookups. - * This function returns whether lookups are enabled on a proxy object. - * @param ecs The proxy object - * @return If true, the proxy will perform the dns lookup - * @note By default, this setting is DISABLED. - * @since 1.2 - */ -EAPI Eina_Bool -ecore_con_socks_lookup_get(Ecore_Con_Socks *ecs) -{ - ECORE_CON_SOCKS_CAST_ELSE(ecs) return EINA_FALSE; - return ecs->lookup; -} - -/** - * Enable bind mode on a SOCKS proxy - * - * Use this function to enable binding a remote port for use with a remote server. - * For more information, see http://ufasoft.com/doc/socks4_protocol.htm - * @param ecs The proxy object - * @param is_bind If true, the connection established will be a port binding - * @warning Be aware that changing the operation mode of an active proxy may result in undefined behavior - * @since 1.2 - */ -EAPI void -ecore_con_socks_bind_set(Ecore_Con_Socks *ecs, Eina_Bool is_bind) -{ - EINA_SAFETY_ON_NULL_RETURN(ecs); - ecs->bind = !!is_bind; -} - -/** - * Return bind mode of a SOCKS proxy - * - * Use this function to return bind mode of a proxy (binding a remote port for use with a remote server). - * For more information, see http://ufasoft.com/doc/socks4_protocol.htm - * @param ecs The proxy object - * @return If true, the connection established will be a port binding - * @since 1.2 - */ -EAPI Eina_Bool -ecore_con_socks_bind_get(Ecore_Con_Socks *ecs) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(ecs, EINA_FALSE); - return ecs->bind; -} - -/** - * Return SOCKS version of a SOCKS proxy - * - * Use this function to return the SOCKS protocol version of a proxy - * @param ecs The proxy object - * @return 0 on error, else 4/5 - * @since 1.2 - */ -EAPI unsigned int -ecore_con_socks_version_get(Ecore_Con_Socks *ecs) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(ecs, 0); - return ecs->version; -} - -/** - * Remove a SOCKS v4 proxy from the proxy list and delete it - * - * Use this to remove a SOCKS proxy from the proxy list by directly deleting the object given. - * @param ecs The proxy object to delete - * @warning Be aware that deleting a proxy which is being used WILL ruin your life. - * @since 1.2 - */ -EAPI void -ecore_con_socks_remote_del(Ecore_Con_Socks *ecs) -{ - EINA_SAFETY_ON_NULL_RETURN(ecs); - if (!ecore_con_socks_proxies) return; - - ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, ecs); - _ecore_con_socks_free(ecs); -} - -/** - * Set a proxy object to be used with the next server created with ecore_con_server_connect() - * - * This function sets a proxy for the next ecore_con connection. After the next server is created, - * the proxy will NEVER be applied again unless explicitly enabled. - * @param ecs The proxy object - * @see ecore_con_socks_apply_always() - * @since 1.2 - */ -EAPI void -ecore_con_socks_apply_once(Ecore_Con_Socks *ecs) -{ - _ecore_con_proxy_once = ecs; -} - -/** - * Set a proxy object to be used with all servers created with ecore_con_server_connect() - * - * This function sets a proxy for all ecore_con connections. It will always be used. - * @param ecs The proxy object - * @see ecore_con_socks_apply_once() - * @since 1.2 - * @note ecore-con supports setting this through environment variables like so: - * ECORE_CON_SOCKS_V4=[user@]server-port:lookup - * ECORE_CON_SOCKS_V5=[user@]server-port:lookup - * user is the OPTIONAL string that would be passed to the proxy as the username - * server is the IP_ADDRESS of the proxy server - * port is the port to connect to on the proxy server - * lookup is 1 if the proxy should perform all DNS lookups, otherwise 0 or omitted - */ -EAPI void -ecore_con_socks_apply_always(Ecore_Con_Socks *ecs) -{ - _ecore_con_proxy_global = ecs; -} -/** @} */ diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_ssl.c b/libraries/ecore/src/lib/ecore_con/ecore_con_ssl.c deleted file mode 100644 index cd8b9c6..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_ssl.c +++ /dev/null @@ -1,2113 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#if USE_GNUTLS -# include -# include -# include -#elif USE_OPENSSL -# include -# include -# include -#endif - -#ifdef HAVE_WS2TCPIP_H -# include -#endif - -#include -#include "Ecore.h" -#include "ecore_con_private.h" - -EAPI int ECORE_CON_EVENT_CLIENT_UPGRADE = 0; -EAPI int ECORE_CON_EVENT_SERVER_UPGRADE = 0; - -static int _init_con_ssl_init_count = 0; - -#ifdef USE_GNUTLS -# ifdef EINA_HAVE_THREADS -GCRY_THREAD_OPTION_PTHREAD_IMPL; -# endif - -static int _client_connected = 0; - -# define SSL_SUFFIX(ssl_func) ssl_func ## _gnutls -# define _ECORE_CON_SSL_AVAILABLE 1 - -#elif USE_OPENSSL - -# define SSL_SUFFIX(ssl_func) ssl_func ## _openssl -# define _ECORE_CON_SSL_AVAILABLE 2 - -#else -# define SSL_SUFFIX(ssl_func) ssl_func ## _none -# define _ECORE_CON_SSL_AVAILABLE 0 - -#endif - -#if USE_GNUTLS -static void -_gnutls_print_errors(void *conn, int type, int ret) -{ - char buf[1024]; - - if (!ret) return; - - snprintf(buf, sizeof(buf), "GNUTLS error: %s - %s", gnutls_strerror_name(ret), gnutls_strerror(ret)); - if (type == ECORE_CON_EVENT_CLIENT_ERROR) - ecore_con_event_client_error(conn, buf); - else - ecore_con_event_server_error(conn, buf); -} - -static void -_gnutls_print_session(const gnutls_datum_t *cert_list, unsigned int cert_list_size) -{ - char *c = NULL; - gnutls_x509_crt_t crt; - unsigned int x; - - if (!eina_log_domain_level_check(_ecore_con_log_dom, EINA_LOG_LEVEL_DBG)) return; - for (x = 0; x < cert_list_size; x++) - { - gnutls_x509_crt_init(&crt); - gnutls_x509_crt_import(crt, &cert_list[x], GNUTLS_X509_FMT_DER); - gnutls_x509_crt_print(crt, GNUTLS_CRT_PRINT_FULL, (gnutls_datum_t*)&c); - INF("CERTIFICATE:\n%s", c); - gnutls_free(c); - gnutls_x509_crt_deinit(crt); - crt = NULL; - } -} - -#ifdef ISCOMFITOR -static void -_gnutls_log_func(int level, - const char *str) -{ - char buf[128]; - strncat(buf, str, strlen(str) - 1); - DBG("|<%d>| %s", level, buf); -} -#endif - -static const char * -SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status) -{ - switch (status) - { - case GNUTLS_HANDSHAKE_HELLO_REQUEST: - return "Hello request"; - - case GNUTLS_HANDSHAKE_CLIENT_HELLO: - return "Client hello"; - - case GNUTLS_HANDSHAKE_SERVER_HELLO: - return "Server hello"; - - case GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: - return "New session ticket"; - - case GNUTLS_HANDSHAKE_CERTIFICATE_PKT: - return "Certificate packet"; - - case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: - return "Server key exchange"; - - case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: - return "Certificate request"; - - case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: - return "Server hello done"; - - case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: - return "Certificate verify"; - - case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: - return "Client key exchange"; - - case GNUTLS_HANDSHAKE_FINISHED: - return "Finished"; - - case GNUTLS_HANDSHAKE_SUPPLEMENTAL: - return "Supplemental"; - } - return NULL; -} - -#elif USE_OPENSSL - -static void -_openssl_print_verify_error(int error) -{ - switch (error) - { -#define ERROR(X) \ - case (X): \ - ERR("%s", #X); \ - break -#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT - ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT); -#endif -#ifdef X509_V_ERR_UNABLE_TO_GET_CRL - ERROR(X509_V_ERR_UNABLE_TO_GET_CRL); -#endif -#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE - ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE); -#endif -#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE - ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE); -#endif -#ifdef X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY - ERROR(X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY); -#endif -#ifdef X509_V_ERR_CERT_SIGNATURE_FAILURE - ERROR(X509_V_ERR_CERT_SIGNATURE_FAILURE); -#endif -#ifdef X509_V_ERR_CRL_SIGNATURE_FAILURE - ERROR(X509_V_ERR_CRL_SIGNATURE_FAILURE); -#endif -#ifdef X509_V_ERR_CERT_NOT_YET_VALID - ERROR(X509_V_ERR_CERT_NOT_YET_VALID); -#endif -#ifdef X509_V_ERR_CERT_HAS_EXPIRED - ERROR(X509_V_ERR_CERT_HAS_EXPIRED); -#endif -#ifdef X509_V_ERR_CRL_NOT_YET_VALID - ERROR(X509_V_ERR_CRL_NOT_YET_VALID); -#endif -#ifdef X509_V_ERR_CRL_HAS_EXPIRED - ERROR(X509_V_ERR_CRL_HAS_EXPIRED); -#endif -#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD - ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD); -#endif -#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD - ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD); -#endif -#ifdef X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD - ERROR(X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD); -#endif -#ifdef X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD - ERROR(X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD); -#endif -#ifdef X509_V_ERR_OUT_OF_MEM - ERROR(X509_V_ERR_OUT_OF_MEM); -#endif -#ifdef X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT - ERROR(X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT); -#endif -#ifdef X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN - ERROR(X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN); -#endif -#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY - ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY); -#endif -#ifdef X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE - ERROR(X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE); -#endif -#ifdef X509_V_ERR_CERT_CHAIN_TOO_LONG - ERROR(X509_V_ERR_CERT_CHAIN_TOO_LONG); -#endif -#ifdef X509_V_ERR_CERT_REVOKED - ERROR(X509_V_ERR_CERT_REVOKED); -#endif -#ifdef X509_V_ERR_INVALID_CA - ERROR(X509_V_ERR_INVALID_CA); -#endif -#ifdef X509_V_ERR_PATH_LENGTH_EXCEEDED - ERROR(X509_V_ERR_PATH_LENGTH_EXCEEDED); -#endif -#ifdef X509_V_ERR_INVALID_PURPOSE - ERROR(X509_V_ERR_INVALID_PURPOSE); -#endif -#ifdef X509_V_ERR_CERT_UNTRUSTED - ERROR(X509_V_ERR_CERT_UNTRUSTED); -#endif -#ifdef X509_V_ERR_CERT_REJECTED - ERROR(X509_V_ERR_CERT_REJECTED); -#endif - /* These are 'informational' when looking for issuer cert */ -#ifdef X509_V_ERR_SUBJECT_ISSUER_MISMATCH - ERROR(X509_V_ERR_SUBJECT_ISSUER_MISMATCH); -#endif -#ifdef X509_V_ERR_AKID_SKID_MISMATCH - ERROR(X509_V_ERR_AKID_SKID_MISMATCH); -#endif -#ifdef X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH - ERROR(X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH); -#endif -#ifdef X509_V_ERR_KEYUSAGE_NO_CERTSIGN - ERROR(X509_V_ERR_KEYUSAGE_NO_CERTSIGN); -#endif - -#ifdef X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER - ERROR(X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER); -#endif -#ifdef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION - ERROR(X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION); -#endif -#ifdef X509_V_ERR_KEYUSAGE_NO_CRL_SIGN - ERROR(X509_V_ERR_KEYUSAGE_NO_CRL_SIGN); -#endif -#ifdef X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION - ERROR(X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION); -#endif -#ifdef X509_V_ERR_INVALID_NON_CA - ERROR(X509_V_ERR_INVALID_NON_CA); -#endif -#ifdef X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED - ERROR(X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED); -#endif -#ifdef X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE - ERROR(X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE); -#endif -#ifdef X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED - ERROR(X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED); -#endif - -#ifdef X509_V_ERR_INVALID_EXTENSION - ERROR(X509_V_ERR_INVALID_EXTENSION); -#endif -#ifdef X509_V_ERR_INVALID_POLICY_EXTENSION - ERROR(X509_V_ERR_INVALID_POLICY_EXTENSION); -#endif -#ifdef X509_V_ERR_NO_EXPLICIT_POLICY - ERROR(X509_V_ERR_NO_EXPLICIT_POLICY); -#endif -#ifdef X509_V_ERR_DIFFERENT_CRL_SCOPE - ERROR(X509_V_ERR_DIFFERENT_CRL_SCOPE); -#endif -#ifdef X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE - ERROR(X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE); -#endif - -#ifdef X509_V_ERR_UNNESTED_RESOURCE - ERROR(X509_V_ERR_UNNESTED_RESOURCE); -#endif - -#ifdef X509_V_ERR_PERMITTED_VIOLATION - ERROR(X509_V_ERR_PERMITTED_VIOLATION); -#endif -#ifdef X509_V_ERR_EXCLUDED_VIOLATION - ERROR(X509_V_ERR_EXCLUDED_VIOLATION); -#endif -#ifdef X509_V_ERR_SUBTREE_MINMAX - ERROR(X509_V_ERR_SUBTREE_MINMAX); -#endif -#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE - ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE); -#endif -#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX - ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX); -#endif -#ifdef X509_V_ERR_UNSUPPORTED_NAME_SYNTAX - ERROR(X509_V_ERR_UNSUPPORTED_NAME_SYNTAX); -#endif -#ifdef X509_V_ERR_CRL_PATH_VALIDATION_ERROR - ERROR(X509_V_ERR_CRL_PATH_VALIDATION_ERROR); -#endif - - /* The application is not happy */ -#ifdef X509_V_ERR_APPLICATION_VERIFICATION - ERROR(X509_V_ERR_APPLICATION_VERIFICATION); -#endif - } -#undef ERROR -} - -static void -_openssl_print_errors(void *conn, int type) -{ - char buf[1024]; - do - { - unsigned long err; - - err = ERR_get_error(); - if (!err) break; - snprintf(buf, sizeof(buf), "OpenSSL error: %s", ERR_reason_error_string(err)); - if (type == ECORE_CON_EVENT_CLIENT_ERROR) - ecore_con_event_client_error(conn, buf); - else - ecore_con_event_server_error(conn, buf); - - } while (1); -} - -static Eina_Bool -_openssl_name_verify(const char *name, const char *svrname) -{ - if (name[0] == '*') - { - /* we allow *.domain.TLD with a wildcard, but nothing else */ - const char *p, *s; - - EINA_SAFETY_ON_TRUE_RETURN_VAL((name[1] != '.') || (!name[2]), EINA_FALSE); - p = strchr(name + 1, '*'); - EINA_SAFETY_ON_TRUE_RETURN_VAL(!!p, EINA_FALSE); - /* verify that we have a domain of at least *.X.TLD and not *.TLD */ - p = strchr(name + 2, '.'); - EINA_SAFETY_ON_TRUE_RETURN_VAL(!p, EINA_FALSE); - s = strchr(svrname, '.'); - EINA_SAFETY_ON_TRUE_RETURN_VAL(!s, EINA_FALSE); - /* same as above for the stored name */ - EINA_SAFETY_ON_TRUE_RETURN_VAL(!strchr(s + 1, '.'), EINA_FALSE); - if (strcasecmp(s, name + 1)) - { - ERR("%s != %s", s, name + 1); - return EINA_FALSE; - } - } - else - if (strcasecmp(name, svrname)) - { - ERR("%s != %s", name, svrname); - return EINA_FALSE; - } - return EINA_TRUE; -} - -static void -_openssl_print_session(SSL *ssl) -{ - /* print session info into DBG */ - SSL_SESSION *s; - STACK_OF(X509) *sk; - BIO *b; - char log[4096], *p; - int x; - - if (!eina_log_domain_level_check(_ecore_con_log_dom, EINA_LOG_LEVEL_DBG)) return; - - memset(log, 0, sizeof(log)); - b = BIO_new(BIO_s_mem()); - sk = SSL_get_peer_cert_chain(ssl); - if (sk) - { - DBG("CERTIFICATES:"); - for (x = 0; x < sk_X509_num(sk); x++) - { - p = X509_NAME_oneline(X509_get_subject_name(sk_X509_value(sk, x)), log, sizeof(log)); - DBG("%2d s:%s", x, p); - p = X509_NAME_oneline(X509_get_issuer_name(sk_X509_value(sk, x)), log, sizeof(log)); - DBG(" i:%s", p); - PEM_write_X509(stderr, sk_X509_value(sk, x)); - } - } - s = SSL_get_session(ssl); - SSL_SESSION_print(b, s); - fprintf(stderr, "\n"); - while (BIO_read(b, log, sizeof(log)) > 0) - fprintf(stderr, "%s", log); - - BIO_free(b); -} - -#endif - -#define SSL_ERROR_CHECK_GOTO_ERROR(X) \ - do \ - { \ - if ((X)) \ - { \ - ERR("Error at %s:%s:%d!", __FILE__, __PRETTY_FUNCTION__, __LINE__); \ - goto error; \ - } \ - } \ - while (0) - -static Ecore_Con_Ssl_Error - SSL_SUFFIX(_ecore_con_ssl_init) (void); -static Ecore_Con_Ssl_Error - SSL_SUFFIX(_ecore_con_ssl_shutdown) (void); - -static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server * svr, const char *ca_file); -static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server * svr, const char *crl_file); -static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server * svr, const char *cert); -static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_privkey_add) (Ecore_Con_Server * svr, const char *key_file); - -static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_prepare) (Ecore_Con_Server * svr, int ssl_type); -static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_init) (Ecore_Con_Server * svr); -static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_shutdown) (Ecore_Con_Server *svr); -static int SSL_SUFFIX(_ecore_con_ssl_server_read) (Ecore_Con_Server *svr, unsigned char *buf, int size); -static int SSL_SUFFIX(_ecore_con_ssl_server_write) (Ecore_Con_Server *svr, const unsigned char *buf, int size); - -static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_init) (Ecore_Con_Client * cl); -static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (Ecore_Con_Client *cl); -static int SSL_SUFFIX(_ecore_con_ssl_client_read) (Ecore_Con_Client * cl, - unsigned char *buf, int size); -static int SSL_SUFFIX(_ecore_con_ssl_client_write) (Ecore_Con_Client * cl, - const unsigned char *buf, int size); - -/* - * General SSL API - */ - -Ecore_Con_Ssl_Error -ecore_con_ssl_init(void) -{ - if (!_init_con_ssl_init_count++) - { - SSL_SUFFIX(_ecore_con_ssl_init) (); -#if _ECORE_CON_SSL_AVAILABLE != 0 - ECORE_CON_EVENT_CLIENT_UPGRADE = ecore_event_type_new(); - ECORE_CON_EVENT_SERVER_UPGRADE = ecore_event_type_new(); -#endif - } - - return _init_con_ssl_init_count; -} - -Ecore_Con_Ssl_Error -ecore_con_ssl_shutdown(void) -{ - if (!--_init_con_ssl_init_count) - SSL_SUFFIX(_ecore_con_ssl_shutdown) (); - - return _init_con_ssl_init_count; -} - -Ecore_Con_Ssl_Error -ecore_con_ssl_server_prepare(Ecore_Con_Server *svr, - int ssl_type) -{ - if (!ssl_type) - return ECORE_CON_SSL_ERROR_NONE; - return SSL_SUFFIX(_ecore_con_ssl_server_prepare) (svr, ssl_type); -} - -Ecore_Con_Ssl_Error -ecore_con_ssl_server_init(Ecore_Con_Server *svr) -{ - if (!(svr->type & ECORE_CON_SSL)) - return ECORE_CON_SSL_ERROR_NONE; - return SSL_SUFFIX(_ecore_con_ssl_server_init) (svr); -} - -Ecore_Con_Ssl_Error -ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr) -{ - if (!(svr->type & ECORE_CON_SSL)) - return ECORE_CON_SSL_ERROR_NONE; - return SSL_SUFFIX(_ecore_con_ssl_server_shutdown) (svr); -} - -int -ecore_con_ssl_server_read(Ecore_Con_Server *svr, - unsigned char *buf, - int size) -{ - return SSL_SUFFIX(_ecore_con_ssl_server_read) (svr, buf, size); -} - -int -ecore_con_ssl_server_write(Ecore_Con_Server *svr, - const unsigned char *buf, - int size) -{ - return SSL_SUFFIX(_ecore_con_ssl_server_write) (svr, buf, size); -} - -Ecore_Con_Ssl_Error -ecore_con_ssl_client_init(Ecore_Con_Client *cl) -{ - if (!(cl->host_server->type & ECORE_CON_SSL)) - return ECORE_CON_SSL_ERROR_NONE; - return SSL_SUFFIX(_ecore_con_ssl_client_init) (cl); -} - -Ecore_Con_Ssl_Error -ecore_con_ssl_client_shutdown(Ecore_Con_Client *cl) -{ - if (!(cl->host_server->type & ECORE_CON_SSL)) - return ECORE_CON_SSL_ERROR_NONE; - return SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (cl); -} - -int -ecore_con_ssl_client_read(Ecore_Con_Client *cl, - unsigned char *buf, - int size) -{ - return SSL_SUFFIX(_ecore_con_ssl_client_read) (cl, buf, size); -} - -int -ecore_con_ssl_client_write(Ecore_Con_Client *cl, - const unsigned char *buf, - int size) -{ - return SSL_SUFFIX(_ecore_con_ssl_client_write) (cl, buf, size); -} - -/** - * Returns if SSL support is available - * @return 1 if SSL is available and provided by gnutls, 2 if provided by openssl, - * 0 if it is not available. - * @ingroup Ecore_Con_Client_Group - */ -EAPI int -ecore_con_ssl_available_get(void) -{ - return _ECORE_CON_SSL_AVAILABLE; -} - -/** - * @addtogroup Ecore_Con_SSL_Group Ecore Connection SSL Functions - * - * Functions that operate on Ecore connection objects pertaining to SSL. - * - * @{ - */ - -/** - * @brief Enable certificate verification on a server object - * - * Call this function on a server object before main loop has started - * to enable verification of certificates against loaded certificates. - * @param svr The server object - */ -EAPI void -ecore_con_ssl_server_verify(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_verify"); - return; - } - svr->verify = EINA_TRUE; -} - -/** - * @brief Enable hostname-based certificate verification on a server object - * - * Call this function on a server object before main loop has started - * to enable verification of certificates using ONLY their hostnames. - * @param svr The server object - * @note This function has no effect when used on a listening server created by - * ecore_con_server_add - * @since 1.1 - */ -EAPI void -ecore_con_ssl_server_verify_basic(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__); - return; - } - svr->verify_basic = EINA_TRUE; -} - -/** - * @brief Set the hostname to verify against in certificate verification - * - * Sometimes the certificate hostname will not match the hostname that you are - * connecting to, and will instead match a different name. An example of this is - * that if you connect to talk.google.com to use Google Talk, you receive Google's - * certificate for gmail.com. This certificate should be trusted, and so you must call - * this function with "gmail.com" as @p name. - * See RFC2818 for more details. - * @param svr The server object - * @param name The hostname to verify against - * @since 1.2 - */ -EAPI void -ecore_con_ssl_server_verify_name_set(Ecore_Con_Server *svr, const char *name) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__); - return; - } - eina_stringshare_replace(&svr->verify_name, name); -} - -/** - * @brief Get the hostname to verify against in certificate verification - * - * This function returns the name which will be used to validate the SSL certificate - * common name (CN) or alt name (subjectAltName). It will default to the @p name - * param in ecore_con_server_connect(), but can be changed with ecore_con_ssl_server_verify_name_set(). - * @param svr The server object - * @return The hostname which will be used - * @since 1.2 - */ -EAPI const char * -ecore_con_ssl_server_verify_name_get(Ecore_Con_Server *svr) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__); - return NULL; - } - return svr->verify_name ?: svr->name; -} - -/** - * @brief Add an ssl certificate for use in ecore_con functions. - * - * Use this function to add a SSL PEM certificate. - * Simply specify the cert here to use it in the server object for connecting or listening. - * If there is an error loading the certificate, an error will automatically be logged. - * @param svr The server object - * @param cert The path to the certificate. - * @return EINA_FALSE if the file cannot be loaded, otherwise EINA_TRUE. - */ - -EAPI Eina_Bool -ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr, - const char *cert) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_cert_add"); - return EINA_FALSE; - } - - if (!svr->ssl_prepared) - { - svr->use_cert = EINA_TRUE; - svr->type |= ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT; - if (ecore_con_ssl_server_prepare(svr, svr->type & ECORE_CON_SSL)) - return EINA_FALSE; - } - - return SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (svr, cert); -} - -/** - * @brief Add an ssl CA file for use in ecore_con functions. - * - * Use this function to add a SSL PEM CA file. - * Simply specify the file here to use it in the server object for connecting or listening. - * If there is an error loading the CAs, an error will automatically be logged. - * @param svr The server object - * @param ca_file The path to the CA file. - * @return EINA_FALSE if the file cannot be loaded, otherwise EINA_TRUE. - * @note since 1.2, this function can load directores - */ - -EAPI Eina_Bool -ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr, - const char *ca_file) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_cafile_add"); - return EINA_FALSE; - } - - if (!svr->ssl_prepared) - { - svr->use_cert = EINA_TRUE; - svr->type |= ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT; - if (ecore_con_ssl_server_prepare(svr, svr->type & ECORE_CON_SSL)) - return EINA_FALSE; - } - - return SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (svr, ca_file); -} - -/** - * @brief Add an ssl private key for use in ecore_con functions. - * - * Use this function to add a SSL PEM private key - * Simply specify the key file here to use it in the server object for connecting or listening. - * If there is an error loading the key, an error will automatically be logged. - * @param key_file The path to the key file. - * @return EINA_FALSE if the file cannot be loaded, - * otherwise EINA_TRUE. - */ - -EAPI Eina_Bool -ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr, - const char *key_file) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_privkey_add"); - return EINA_FALSE; - } - - if (!svr->ssl_prepared) - { - svr->use_cert = EINA_TRUE; - svr->type |= ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT; - if (ecore_con_ssl_server_prepare(svr, svr->type & ECORE_CON_SSL)) - return EINA_FALSE; - } - - return SSL_SUFFIX(_ecore_con_ssl_server_privkey_add) (svr, key_file); -} - -/** - * @brief Add an ssl CRL for use in ecore_con functions. - * - * Use this function to add a SSL PEM CRL file - * Simply specify the CRL file here to use it in the server object for connecting or listening. - * If there is an error loading the CRL, an error will automatically be logged. - * @param svr The server object - * @param crl_file The path to the CRL file. - * @return EINA_FALSE if the file cannot be loaded, - * otherwise EINA_TRUE. - */ - -EAPI Eina_Bool -ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr, - const char *crl_file) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_crl_add"); - return EINA_FALSE; - } - - if (!svr->ssl_prepared) - { - svr->use_cert = EINA_TRUE; - svr->type |= ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT; - if (ecore_con_ssl_server_prepare(svr, svr->type & ECORE_CON_SSL)) - return EINA_FALSE; - } - - return SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (svr, crl_file); -} - -/** - * @brief Upgrade a connection to a specified level of encryption - * - * Use this function to begin an SSL handshake on a connection (STARTTLS or similar). - * Once the upgrade has been completed, an ECORE_CON_EVENT_SERVER_UPGRADE event will be emitted. - * The connection should be treated as disconnected until the next event. - * @param svr The server object - * @param ssl_type The SSL connection type (ONLY). - * @return EINA_FALSE if the connection cannot be upgraded, otherwise EINA_TRUE. - * @note This function is NEVER to be used on a server object created with ecore_con_server_add - * @warning Setting a wrong value for @p compl_type WILL mess up your program. - * @since 1.1 - */ - -EAPI Eina_Bool -ecore_con_ssl_server_upgrade(Ecore_Con_Server *svr, Ecore_Con_Type ssl_type) -{ - if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) - { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__); - return EINA_FALSE; - } -#if _ECORE_CON_SSL_AVAILABLE == 0 - return EINA_FALSE; -#endif - - if (!svr->ssl_prepared) - { - if (ecore_con_ssl_server_prepare(svr, ssl_type)) - return EINA_FALSE; - } - if (!svr->use_cert) - svr->type |= ssl_type; - svr->upgrade = EINA_TRUE; - svr->handshaking = EINA_TRUE; - svr->ssl_state = ECORE_CON_SSL_STATE_INIT; - return !SSL_SUFFIX(_ecore_con_ssl_server_init) (svr); -} - -/** - * @brief Upgrade a connection to a specified level of encryption - * - * Use this function to begin an SSL handshake on a connection (STARTTLS or similar). - * Once the upgrade has been completed, an ECORE_CON_EVENT_CLIENT_UPGRADE event will be emitted. - * The connection should be treated as disconnected until the next event. - * @param cl The client object - * @param ssl_type The SSL connection type (ONLY). - * @return EINA_FALSE if the connection cannot be upgraded, otherwise EINA_TRUE. - * @warning Setting a wrong value for @p compl_type WILL mess up your program. - * @since 1.1 - */ - -EAPI Eina_Bool -ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type ssl_type) -{ - if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) - { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, __func__); - return EINA_FALSE; - } -#if _ECORE_CON_SSL_AVAILABLE == 0 - return EINA_FALSE; -#endif - - if (!cl->host_server->ssl_prepared) - { - if (ecore_con_ssl_server_prepare(cl->host_server, ssl_type)) - return EINA_FALSE; - } - if (!cl->host_server->use_cert) - cl->host_server->type |= ssl_type; - cl->upgrade = EINA_TRUE; - cl->host_server->upgrade = EINA_TRUE; - cl->handshaking = EINA_TRUE; - cl->ssl_state = ECORE_CON_SSL_STATE_INIT; - return SSL_SUFFIX(_ecore_con_ssl_client_init) (cl); -} - -/** - * @} - */ - -#if USE_GNUTLS - -/* - * GnuTLS - */ - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_init_gnutls(void) -{ -#ifdef EINA_HAVE_THREADS - if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread)) - WRN("YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!"); -#endif - if (gnutls_global_init()) - return ECORE_CON_SSL_ERROR_INIT_FAILED; - -#ifdef ISCOMFITOR - if (eina_log_domain_level_check(_ecore_con_log_dom, EINA_LOG_LEVEL_DBG)) - { - gnutls_global_set_log_level(9); - gnutls_global_set_log_function(_gnutls_log_func); - } -#endif - return ECORE_CON_SSL_ERROR_NONE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_shutdown_gnutls(void) -{ - gnutls_global_deinit(); - - return ECORE_CON_SSL_ERROR_NONE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr, - int ssl_type) -{ - int ret; - - if (ssl_type & ECORE_CON_USE_SSL2) - return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; - - switch (ssl_type) - { - case ECORE_CON_USE_SSL3: - case ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT: - case ECORE_CON_USE_TLS: - case ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT: - case ECORE_CON_USE_MIXED: - case ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT: - break; - - default: - return ECORE_CON_SSL_ERROR_NONE; - } - - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_certificate_allocate_credentials(&svr->cert)); - - if (svr->use_cert) - { - if (svr->created) - { - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_dh_params_init(&svr->dh_params)); - INF("Generating DH params"); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_dh_params_generate2(svr->dh_params, 1024)); - - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_server_credentials(&svr->anoncred_s)); - /* TODO: implement PSK */ - // SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_server_credentials(&svr->pskcred_s)); - - gnutls_anon_set_server_dh_params(svr->anoncred_s, svr->dh_params); - gnutls_certificate_set_dh_params(svr->cert, svr->dh_params); - //gnutls_psk_set_server_dh_params(svr->pskcred_s, svr->dh_params); - INF("DH params successfully generated and applied!"); - } - else - { - //SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_client_credentials(&svr->pskcred_c)); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_client_credentials(&svr->anoncred_c)); - } - } - - svr->ssl_prepared = EINA_TRUE; - return ECORE_CON_SSL_ERROR_NONE; - -error: - _gnutls_print_errors(svr, ECORE_CON_EVENT_SERVER_ERROR, ret); - _ecore_con_ssl_server_shutdown_gnutls(svr); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; -} - - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_init_gnutls(Ecore_Con_Server *svr) -{ - const gnutls_datum_t *cert_list; - unsigned int iter, cert_list_size; - gnutls_x509_crt_t cert = NULL; - const char *priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:+VERS-TLS1.2:+VERS-TLS1.1:+VERS-TLS1.0:+VERS-SSL3.0"; - int ret = 0; - - switch (svr->ssl_state) - { - case ECORE_CON_SSL_STATE_DONE: - return ECORE_CON_SSL_ERROR_NONE; - - case ECORE_CON_SSL_STATE_INIT: - if (svr->type & ECORE_CON_USE_SSL2) /* not supported because of security issues */ - return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; - - switch (svr->type & ECORE_CON_SSL) - { - case ECORE_CON_USE_SSL3: - case ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT: - priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:!VERS-TLS1.0:!VERS-TLS1.1"; - break; - - case ECORE_CON_USE_TLS: - case ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT: - priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:!VERS-SSL3.0"; - break; - - case ECORE_CON_USE_MIXED: - case ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT: - break; - - default: - return ECORE_CON_SSL_ERROR_NONE; - } - - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_init(&svr->session, GNUTLS_CLIENT)); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_session_ticket_enable_client(svr->session)); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_server_name_set(svr->session, GNUTLS_NAME_DNS, svr->name, strlen(svr->name))); - INF("Applying priority string: %s", priority); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_priority_set_direct(svr->session, priority, NULL)); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(svr->session, GNUTLS_CRD_CERTIFICATE, svr->cert)); - // SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(svr->session, GNUTLS_CRD_PSK, svr->pskcred_c)); - if (!svr->use_cert) - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(svr->session, GNUTLS_CRD_ANON, svr->anoncred_c)); - - gnutls_dh_set_prime_bits(svr->session, 512); - gnutls_transport_set_ptr(svr->session, (gnutls_transport_ptr_t)((intptr_t)svr->fd)); - svr->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; - - case ECORE_CON_SSL_STATE_HANDSHAKING: - if (!svr->session) - { - DBG("Server was previously lost, going to error condition"); - goto error; - } - ret = gnutls_handshake(svr->session); - DBG("calling gnutls_handshake(): returned with '%s'", gnutls_strerror_name(ret)); - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_error_is_fatal(ret)); - if (!ret) - { - svr->handshaking = EINA_FALSE; - svr->ssl_state = ECORE_CON_SSL_STATE_DONE; - } - else - { - if (gnutls_record_get_direction(svr->session)) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); - else - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); - return ECORE_CON_SSL_ERROR_NONE; - } - - default: - break; - } - - if ((!svr->verify) && (!svr->verify_basic)) - /* not verifying certificates, so we're done! */ - return ECORE_CON_SSL_ERROR_NONE; - if (svr->verify) - { - /* use CRL/CA lists to verify */ - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_certificate_verify_peers2(svr->session, &iter)); - if (iter & GNUTLS_CERT_INVALID) - ERR("The certificate is not trusted."); - else if (iter & GNUTLS_CERT_SIGNER_NOT_FOUND) - ERR("The certificate hasn't got a known issuer."); - else if (iter & GNUTLS_CERT_REVOKED) - ERR("The certificate has been revoked."); - else if (iter & GNUTLS_CERT_EXPIRED) - ERR("The certificate has expired"); - else if (iter & GNUTLS_CERT_NOT_ACTIVATED) - ERR("The certificate is not yet activated"); - - if (iter) - goto error; - } - if (gnutls_certificate_type_get(svr->session) != GNUTLS_CRT_X509) - { - ERR("Warning: PGP certificates are not yet supported!"); - goto error; - } - - SSL_ERROR_CHECK_GOTO_ERROR(!(cert_list = gnutls_certificate_get_peers(svr->session, &cert_list_size))); - SSL_ERROR_CHECK_GOTO_ERROR(!cert_list_size); - - _gnutls_print_session(cert_list, cert_list_size); - - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_init(&cert)); - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER)); - - SSL_ERROR_CHECK_GOTO_ERROR(!gnutls_x509_crt_check_hostname(cert, svr->verify_name ?: svr->name)); - gnutls_x509_crt_deinit(cert); - DBG("SSL certificate verification succeeded!"); - return ECORE_CON_SSL_ERROR_NONE; - -error: - _gnutls_print_errors(svr, ECORE_CON_EVENT_SERVER_ERROR, ret); - if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) || (ret == GNUTLS_E_FATAL_ALERT_RECEIVED)) - ERR("Also received alert: %s", gnutls_alert_get_name(gnutls_alert_get(svr->session))); - if (svr->session && (svr->ssl_state != ECORE_CON_SSL_STATE_DONE)) - { - ERR("last out: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_out(svr->session))); - ERR("last in: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_in(svr->session))); - } - if (cert) - gnutls_x509_crt_deinit(cert); - _ecore_con_ssl_server_shutdown_gnutls(svr); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; -} - -static Eina_Bool -_ecore_con_ssl_server_cafile_add_gnutls(Ecore_Con_Server *svr, - const char *ca_file) -{ - struct stat st; - Eina_Iterator *it; - const char *file; - Eina_Bool error = EINA_FALSE; - - if (stat(ca_file, &st)) return EINA_FALSE; - if (S_ISDIR(st.st_mode)) - { - it = eina_file_ls(ca_file); - SSL_ERROR_CHECK_GOTO_ERROR(!it); - EINA_ITERATOR_FOREACH(it, file) - { - if (!error) - { - if (gnutls_certificate_set_x509_trust_file(svr->cert, file, GNUTLS_X509_FMT_PEM) < 1) - error++; - } - eina_stringshare_del(file); - } - eina_iterator_free(it); - } - else - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_trust_file(svr->cert, ca_file, - GNUTLS_X509_FMT_PEM) < 1); - - return !error; -error: - ERR("Could not load CA file!"); - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_crl_add_gnutls(Ecore_Con_Server *svr, - const char *crl_file) -{ - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_crl_file(svr->cert, crl_file, - GNUTLS_X509_FMT_PEM) < 1); - - return EINA_TRUE; -error: - ERR("Could not load CRL file!"); - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_privkey_add_gnutls(Ecore_Con_Server *svr, - const char *key_file) -{ - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_key_file(svr->cert, svr->cert_file, key_file, - GNUTLS_X509_FMT_PEM)); - - return EINA_TRUE; -error: - ERR("Could not load certificate/key file!"); - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_cert_add_gnutls(Ecore_Con_Server *svr, - const char *cert_file) -{ - if (!(svr->cert_file = strdup(cert_file))) - return EINA_FALSE; - - return EINA_TRUE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_shutdown_gnutls(Ecore_Con_Server *svr) -{ - if (svr->session) - { - gnutls_bye(svr->session, GNUTLS_SHUT_RDWR); - gnutls_deinit(svr->session); - } - - free(svr->cert_file); - svr->cert_file = NULL; - if (svr->cert) - gnutls_certificate_free_credentials(svr->cert); - svr->cert = NULL; - - if ((svr->type & ECORE_CON_SSL) && svr->created) - { - if (svr->dh_params) - { - gnutls_dh_params_deinit(svr->dh_params); - svr->dh_params = NULL; - } - if (svr->anoncred_s) - gnutls_anon_free_server_credentials(svr->anoncred_s); - // if (svr->pskcred_s) - // gnutls_psk_free_server_credentials(svr->pskcred_s); - - svr->anoncred_s = NULL; - svr->pskcred_s = NULL; - } - else if (svr->type & ECORE_CON_SSL) - { - if (svr->anoncred_c) - gnutls_anon_free_client_credentials(svr->anoncred_c); - // if (svr->pskcred_c) - // gnutls_psk_free_client_credentials(svr->pskcred_c); - - svr->anoncred_c = NULL; - svr->pskcred_c = NULL; - } - - svr->session = NULL; - - return ECORE_CON_SSL_ERROR_NONE; -} - -static int -_ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr, - unsigned char *buf, - int size) -{ - int num; - - if (svr->ssl_state == ECORE_CON_SSL_STATE_HANDSHAKING) - { - DBG("Continuing gnutls handshake"); - if (!_ecore_con_ssl_server_init_gnutls(svr)) - return 0; - return -1; - } - - num = gnutls_record_recv(svr->session, buf, size); - if (num > 0) - return num; - - if (num == GNUTLS_E_REHANDSHAKE) - { - WRN("Rehandshake request ignored"); - return 0; - - svr->handshaking = EINA_TRUE; - svr->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; - if (!_ecore_con_ssl_server_init_gnutls(svr)) - return 0; - } - else if ((!gnutls_error_is_fatal(num)) && (num != GNUTLS_E_SUCCESS)) - return 0; - - return -1; -} - -static int -_ecore_con_ssl_server_write_gnutls(Ecore_Con_Server *svr, - const unsigned char *buf, - int size) -{ - int num; - - if (svr->ssl_state == ECORE_CON_SSL_STATE_HANDSHAKING) - { - DBG("Continuing gnutls handshake"); - if (!_ecore_con_ssl_server_init_gnutls(svr)) - return 0; - return -1; - } - - num = gnutls_record_send(svr->session, buf, size); - if (num > 0) - return num; - - if (num == GNUTLS_E_REHANDSHAKE) - { - WRN("Rehandshake request ignored"); - return 0; -/* this is only partly functional I think? */ - svr->handshaking = EINA_TRUE; - svr->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; - if (!_ecore_con_ssl_server_init_gnutls(svr)) - return 0; - } - else if (!gnutls_error_is_fatal(num)) - return 0; - - return -1; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_client_init_gnutls(Ecore_Con_Client *cl) -{ - const gnutls_datum_t *cert_list; - unsigned int iter, cert_list_size; - const char *priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:+VERS-TLS1.2:+VERS-TLS1.1:+VERS-TLS1.0:+VERS-SSL3.0"; - int ret = 0; - - switch (cl->ssl_state) - { - case ECORE_CON_SSL_STATE_DONE: - return ECORE_CON_SSL_ERROR_NONE; - - case ECORE_CON_SSL_STATE_INIT: - if (cl->host_server->type & ECORE_CON_USE_SSL2) /* not supported because of security issues */ - return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; - - switch (cl->host_server->type & ECORE_CON_SSL) - { - case ECORE_CON_USE_SSL3: - case ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT: - priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:!VERS-TLS1.0:!VERS-TLS1.1"; - break; - - case ECORE_CON_USE_TLS: - case ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT: - priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:!VERS-SSL3.0"; - break; - - case ECORE_CON_USE_MIXED: - case ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT: - break; - - default: - return ECORE_CON_SSL_ERROR_NONE; - } - - _client_connected++; - - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_init(&cl->session, GNUTLS_SERVER)); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_session_ticket_key_generate(&cl->session_ticket)); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_session_ticket_enable_server(cl->session, &cl->session_ticket)); - INF("Applying priority string: %s", priority); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_priority_set_direct(cl->session, priority, NULL)); - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_CERTIFICATE, cl->host_server->cert)); - // SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_PSK, cl->host_server->pskcred_s)); - if (!cl->host_server->use_cert) - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(cl->session, GNUTLS_CRD_ANON, cl->host_server->anoncred_s)); - - gnutls_certificate_server_set_request(cl->session, GNUTLS_CERT_REQUEST); - - gnutls_dh_set_prime_bits(cl->session, 2048); - gnutls_transport_set_ptr(cl->session, (gnutls_transport_ptr_t)((intptr_t)cl->fd)); - cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; - - case ECORE_CON_SSL_STATE_HANDSHAKING: - if (!cl->session) - { - DBG("Client was previously lost, going to error condition"); - goto error; - } - DBG("calling gnutls_handshake()"); - ret = gnutls_handshake(cl->session); - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_error_is_fatal(ret)); - - if (!ret) - { - cl->handshaking = EINA_FALSE; - cl->ssl_state = ECORE_CON_SSL_STATE_DONE; - } - else - { - if (gnutls_record_get_direction(cl->session)) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_WRITE); - else - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); - return ECORE_CON_SSL_ERROR_NONE; - } - - default: - break; - } - - if (!cl->host_server->verify) - /* not verifying certificates, so we're done! */ - return ECORE_CON_SSL_ERROR_NONE; - /* use CRL/CA lists to verify */ - SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_certificate_verify_peers2(cl->session, &iter)); - if (iter & GNUTLS_CERT_INVALID) - ERR("The certificate is not trusted."); - else if (iter & GNUTLS_CERT_SIGNER_NOT_FOUND) - ERR("The certificate hasn't got a known issuer."); - else if (iter & GNUTLS_CERT_REVOKED) - ERR("The certificate has been revoked."); - else if (iter & GNUTLS_CERT_EXPIRED) - ERR("The certificate has expired"); - else if (iter & GNUTLS_CERT_NOT_ACTIVATED) - ERR("The certificate is not yet activated"); - - if (iter) - goto error; - if (gnutls_certificate_type_get(cl->session) != GNUTLS_CRT_X509) - { - ERR("Warning: PGP certificates are not yet supported!"); - goto error; - } - - SSL_ERROR_CHECK_GOTO_ERROR(!(cert_list = gnutls_certificate_get_peers(cl->session, &cert_list_size))); - SSL_ERROR_CHECK_GOTO_ERROR(!cert_list_size); - - _gnutls_print_session(cert_list, cert_list_size); -/* - gnutls_x509_crt_t cert = NULL; - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_init(&cert)); - SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER)); - - SSL_ERROR_CHECK_GOTO_ERROR(!gnutls_x509_crt_check_hostname(cert, cl->host_server->name)); - gnutls_x509_crt_deinit(cert); -*/ - DBG("SSL certificate verification succeeded!"); - return ECORE_CON_SSL_ERROR_NONE; - -error: - _gnutls_print_errors(cl, ECORE_CON_EVENT_CLIENT_ERROR, ret); - if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) || (ret == GNUTLS_E_FATAL_ALERT_RECEIVED)) - ERR("Also received alert: %s", gnutls_alert_get_name(gnutls_alert_get(cl->session))); - if (cl->session && (cl->ssl_state != ECORE_CON_SSL_STATE_DONE)) - { - ERR("last out: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_out(cl->session))); - ERR("last in: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_in(cl->session))); - } -/* - if (cert) - gnutls_x509_crt_deinit(cert); -*/ - _ecore_con_ssl_client_shutdown_gnutls(cl); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_client_shutdown_gnutls(Ecore_Con_Client *cl) -{ - if (cl->session) - { - gnutls_bye(cl->session, GNUTLS_SHUT_RDWR); - gnutls_deinit(cl->session); - gnutls_free(cl->session_ticket.data); - cl->session_ticket.data = NULL; - } - - cl->session = NULL; - - return ECORE_CON_SSL_ERROR_NONE; -} - -static int -_ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl, - unsigned char *buf, - int size) -{ - int num; - - if (cl->ssl_state == ECORE_CON_SSL_STATE_HANDSHAKING) - { - if (!_ecore_con_ssl_client_init_gnutls(cl)) - return 0; - return -1; - } - - num = gnutls_record_recv(cl->session, buf, size); - if (num > 0) - return num; - - if (num == GNUTLS_E_REHANDSHAKE) - { - WRN("Rehandshake request ignored"); - return 0; - cl->handshaking = EINA_TRUE; - cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; - if (!_ecore_con_ssl_client_init_gnutls(cl)) - return 0; - WRN("Rehandshake request ignored"); - return 0; - } - else if ((!gnutls_error_is_fatal(num)) && (num != GNUTLS_E_SUCCESS)) - return 0; - - return -1; -} - -static int -_ecore_con_ssl_client_write_gnutls(Ecore_Con_Client *cl, - const unsigned char *buf, - int size) -{ - int num; - - if (cl->ssl_state == ECORE_CON_SSL_STATE_HANDSHAKING) - { - if (!_ecore_con_ssl_client_init_gnutls(cl)) - return 0; - return -1; - } - - num = gnutls_record_send(cl->session, buf, size); - if (num > 0) - return num; - - if (num == GNUTLS_E_REHANDSHAKE) - { - WRN("Rehandshake request ignored"); - return 0; - cl->handshaking = EINA_TRUE; - cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; - if (!_ecore_con_ssl_client_init_gnutls(cl)) - return 0; - } - else if (!gnutls_error_is_fatal(num)) - return 0; - - return -1; -} - -#elif USE_OPENSSL && !USE_GNUTLS - -/* - * OpenSSL - */ - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_init_openssl(void) -{ - SSL_library_init(); - SSL_load_error_strings(); - OpenSSL_add_all_algorithms(); - - return ECORE_CON_SSL_ERROR_NONE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_shutdown_openssl(void) -{ - ERR_free_strings(); - EVP_cleanup(); - return ECORE_CON_SSL_ERROR_NONE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *svr, - int ssl_type) -{ - long options; - int dh = 0; - - if (ssl_type & ECORE_CON_USE_SSL2) - return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; - - switch (ssl_type) - { - case ECORE_CON_USE_SSL3: - case ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT: - if (!svr->created) - SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(SSLv3_client_method()))); - else - SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(SSLv3_server_method()))); - break; - - case ECORE_CON_USE_TLS: - case ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT: - if (!svr->created) - SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(TLSv1_client_method()))); - else - SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(TLSv1_server_method()))); - break; - - case ECORE_CON_USE_MIXED: - case ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT: - if (!svr->created) - SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(SSLv23_client_method()))); - else - SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(SSLv23_server_method()))); - options = SSL_CTX_get_options(svr->ssl_ctx); - SSL_CTX_set_options(svr->ssl_ctx, options | SSL_OP_NO_SSLv2 | SSL_OP_SINGLE_DH_USE); - break; - - default: - return ECORE_CON_SSL_ERROR_NONE; - } - - if ((!svr->use_cert) && svr->created) - { - DH *dh_params; - INF("Generating DH params"); - SSL_ERROR_CHECK_GOTO_ERROR(!(dh_params = DH_new())); - SSL_ERROR_CHECK_GOTO_ERROR(!DH_generate_parameters_ex(dh_params, 1024, DH_GENERATOR_5, NULL)); - SSL_ERROR_CHECK_GOTO_ERROR(!DH_check(dh_params, &dh)); - SSL_ERROR_CHECK_GOTO_ERROR((dh & DH_CHECK_P_NOT_PRIME) || (dh & DH_CHECK_P_NOT_SAFE_PRIME)); - SSL_ERROR_CHECK_GOTO_ERROR(!DH_generate_key(dh_params)); - SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_set_tmp_dh(svr->ssl_ctx, dh_params)); - DH_free(dh_params); - INF("DH params successfully generated and applied!"); - SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_set_cipher_list(svr->ssl_ctx, "aNULL:!eNULL:!LOW:!EXPORT:@STRENGTH")); - } - else if (!svr->use_cert) - SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_set_cipher_list(svr->ssl_ctx, "aNULL:!eNULL:!LOW:!EXPORT:!ECDH:RSA:AES:!PSK:@STRENGTH")); - - return ECORE_CON_SSL_ERROR_NONE; - -error: - if (dh) - { - if (dh & DH_CHECK_P_NOT_PRIME) - ERR("openssl error: dh_params could not generate a prime!"); - else - ERR("openssl error: dh_params could not generate a safe prime!"); - } - else - _openssl_print_errors(svr, ECORE_CON_EVENT_SERVER_ERROR); - _ecore_con_ssl_server_shutdown_openssl(svr); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr) -{ - int ret = -1; - - switch (svr->ssl_state) - { - case ECORE_CON_SSL_STATE_DONE: - return ECORE_CON_SSL_ERROR_NONE; - - case ECORE_CON_SSL_STATE_INIT: - SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl = SSL_new(svr->ssl_ctx))); - - SSL_ERROR_CHECK_GOTO_ERROR(!SSL_set_fd(svr->ssl, svr->fd)); - SSL_set_connect_state(svr->ssl); - svr->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; - - case ECORE_CON_SSL_STATE_HANDSHAKING: - if (!svr->ssl) - { - DBG("Server was previously lost, going to error condition"); - goto error; - } - ret = SSL_do_handshake(svr->ssl); - svr->ssl_err = SSL_get_error(svr->ssl, ret); - SSL_ERROR_CHECK_GOTO_ERROR((svr->ssl_err == SSL_ERROR_SYSCALL) || (svr->ssl_err == SSL_ERROR_SSL)); - - if (ret == 1) - { - svr->handshaking = EINA_FALSE; - svr->ssl_state = ECORE_CON_SSL_STATE_DONE; - } - else - { - if (svr->ssl_err == SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); - else if (svr->ssl_err == SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); - return ECORE_CON_SSL_ERROR_NONE; - } - - default: - break; - } - - _openssl_print_session(svr->ssl); - if ((!svr->verify) && (!svr->verify_basic)) - /* not verifying certificates, so we're done! */ - return ECORE_CON_SSL_ERROR_NONE; - - { - X509 *cert; - SSL_set_verify(svr->ssl, SSL_VERIFY_PEER, NULL); - /* use CRL/CA lists to verify */ - cert = SSL_get_peer_certificate(svr->ssl); - if (cert) - { - char *c; - int clen; - int name = 0; - - if (svr->verify) - { - int err; - - err = SSL_get_verify_result(svr->ssl); - _openssl_print_verify_error(err); - SSL_ERROR_CHECK_GOTO_ERROR(err); - } - clen = X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_subject_alt_name, NULL, 0); - if (clen > 0) - name = NID_subject_alt_name; - else - clen = X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_commonName, NULL, 0); - SSL_ERROR_CHECK_GOTO_ERROR(clen < 1); - if (!name) name = NID_commonName; - c = alloca(++clen); - X509_NAME_get_text_by_NID(X509_get_subject_name(cert), name, c, clen); - INF("CERT NAME: %s\n", c); - SSL_ERROR_CHECK_GOTO_ERROR(!_openssl_name_verify(c, svr->verify_name ?: svr->name)); - } - } - - DBG("SSL certificate verification succeeded!"); - - return ECORE_CON_SSL_ERROR_NONE; - -error: - _openssl_print_errors(svr, ECORE_CON_EVENT_SERVER_ERROR); - _ecore_con_ssl_server_shutdown_openssl(svr); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; -} - -static Eina_Bool -_ecore_con_ssl_server_cafile_add_openssl(Ecore_Con_Server *svr, - const char *ca_file) -{ - struct stat st; - - if (stat(ca_file, &st)) return EINA_FALSE; - if (S_ISDIR(st.st_mode)) - SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_load_verify_locations(svr->ssl_ctx, NULL, ca_file)); - else - SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_load_verify_locations(svr->ssl_ctx, ca_file, NULL)); - return EINA_TRUE; - -error: - _openssl_print_errors(svr, ECORE_CON_EVENT_SERVER_ERROR); - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_crl_add_openssl(Ecore_Con_Server *svr, - const char *crl_file) -{ - X509_STORE *st; - X509_LOOKUP *lu; - static Eina_Bool flag = EINA_FALSE; - - SSL_ERROR_CHECK_GOTO_ERROR(!(st = SSL_CTX_get_cert_store(svr->ssl_ctx))); - SSL_ERROR_CHECK_GOTO_ERROR(!(lu = X509_STORE_add_lookup(st, X509_LOOKUP_file()))); - SSL_ERROR_CHECK_GOTO_ERROR(X509_load_crl_file(lu, crl_file, X509_FILETYPE_PEM) < 1); - if (!flag) - { - X509_STORE_set_flags(st, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL); - flag = EINA_TRUE; - } - - return EINA_TRUE; - -error: - _openssl_print_errors(svr, ECORE_CON_EVENT_SERVER_ERROR); - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_privkey_add_openssl(Ecore_Con_Server *svr, - const char *key_file) -{ - FILE *fp = NULL; - EVP_PKEY *privkey = NULL; - - if (!(fp = fopen(key_file, "r"))) - goto error; - - SSL_ERROR_CHECK_GOTO_ERROR(!(privkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL))); - - fclose(fp); - SSL_ERROR_CHECK_GOTO_ERROR(SSL_CTX_use_PrivateKey(svr->ssl_ctx, privkey) < 1); - SSL_ERROR_CHECK_GOTO_ERROR(SSL_CTX_check_private_key(svr->ssl_ctx) < 1); - - return EINA_TRUE; - -error: - if (fp) - fclose(fp); - _openssl_print_errors(svr, ECORE_CON_EVENT_SERVER_ERROR); - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_cert_add_openssl(Ecore_Con_Server *svr, - const char *cert_file) -{ - FILE *fp = NULL; - X509 *cert = NULL; - - if (!(fp = fopen(cert_file, "r"))) - goto error; - - SSL_ERROR_CHECK_GOTO_ERROR(!(cert = PEM_read_X509(fp, NULL, NULL, NULL))); - - fclose(fp); - - SSL_ERROR_CHECK_GOTO_ERROR(SSL_CTX_use_certificate(svr->ssl_ctx, cert) < 1); - - return EINA_TRUE; - -error: - if (fp) - fclose(fp); - _openssl_print_errors(svr, ECORE_CON_EVENT_SERVER_ERROR); - return EINA_FALSE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_shutdown_openssl(Ecore_Con_Server *svr) -{ - if (svr->ssl) - { - if (!SSL_shutdown(svr->ssl)) - SSL_shutdown(svr->ssl); - - SSL_free(svr->ssl); - } - - if (svr->ssl_ctx) - SSL_CTX_free(svr->ssl_ctx); - - svr->ssl = NULL; - svr->ssl_ctx = NULL; - svr->ssl_err = SSL_ERROR_NONE; - - return ECORE_CON_SSL_ERROR_NONE; -} - -static int -_ecore_con_ssl_server_read_openssl(Ecore_Con_Server *svr, - unsigned char *buf, - int size) -{ - int num; - - if (!svr->ssl) return -1; - num = SSL_read(svr->ssl, buf, size); - svr->ssl_err = SSL_get_error(svr->ssl, num); - - if (svr->fd_handler) - { - if (svr->ssl && svr->ssl_err == SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); - else if (svr->ssl && svr->ssl_err == SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); - } - - if ((svr->ssl_err == SSL_ERROR_ZERO_RETURN) || - (svr->ssl_err == SSL_ERROR_SYSCALL) || - (svr->ssl_err == SSL_ERROR_SSL)) - return -1; - - if (num < 0) - return 0; - - return num; -} - -static int -_ecore_con_ssl_server_write_openssl(Ecore_Con_Server *svr, - const unsigned char *buf, - int size) -{ - int num; - - num = SSL_write(svr->ssl, buf, size); - svr->ssl_err = SSL_get_error(svr->ssl, num); - - if (svr->fd_handler) - { - if (svr->ssl && svr->ssl_err == SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); - else if (svr->ssl && svr->ssl_err == SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); - } - - if ((svr->ssl_err == SSL_ERROR_ZERO_RETURN) || - (svr->ssl_err == SSL_ERROR_SYSCALL) || - (svr->ssl_err == SSL_ERROR_SSL)) - return -1; - - if (num < 0) - return 0; - - return num; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_client_init_openssl(Ecore_Con_Client *cl) -{ - int ret = -1; - switch (cl->ssl_state) - { - case ECORE_CON_SSL_STATE_DONE: - return ECORE_CON_SSL_ERROR_NONE; - - case ECORE_CON_SSL_STATE_INIT: - SSL_ERROR_CHECK_GOTO_ERROR(!(cl->ssl = SSL_new(cl->host_server->ssl_ctx))); - - SSL_ERROR_CHECK_GOTO_ERROR(!SSL_set_fd(cl->ssl, cl->fd)); - SSL_set_accept_state(cl->ssl); - cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; - - case ECORE_CON_SSL_STATE_HANDSHAKING: - if (!cl->ssl) - { - DBG("Client was previously lost, going to error condition"); - goto error; - } - ret = SSL_do_handshake(cl->ssl); - cl->ssl_err = SSL_get_error(cl->ssl, ret); - SSL_ERROR_CHECK_GOTO_ERROR((cl->ssl_err == SSL_ERROR_SYSCALL) || (cl->ssl_err == SSL_ERROR_SSL)); - if (ret == 1) - { - cl->handshaking = EINA_FALSE; - cl->ssl_state = ECORE_CON_SSL_STATE_DONE; - } - else - { - if (cl->ssl_err == SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); - else if (cl->ssl_err == SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_WRITE); - return ECORE_CON_SSL_ERROR_NONE; - } - - default: - break; - } - - _openssl_print_session(cl->ssl); - if (!cl->host_server->verify) - /* not verifying certificates, so we're done! */ - return ECORE_CON_SSL_ERROR_NONE; - SSL_set_verify(cl->ssl, SSL_VERIFY_PEER, NULL); - /* use CRL/CA lists to verify */ - if (SSL_get_peer_certificate(cl->ssl)) - { - int err; - - err = SSL_get_verify_result(cl->ssl); - _openssl_print_verify_error(err); - SSL_ERROR_CHECK_GOTO_ERROR(err); - } - - return ECORE_CON_SSL_ERROR_NONE; - -error: - _openssl_print_errors(cl, ECORE_CON_EVENT_CLIENT_ERROR); - _ecore_con_ssl_client_shutdown_openssl(cl); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_client_shutdown_openssl(Ecore_Con_Client *cl) -{ - if (cl->ssl) - { - if (!SSL_shutdown(cl->ssl)) - SSL_shutdown(cl->ssl); - - SSL_free(cl->ssl); - } - - cl->ssl = NULL; - cl->ssl_err = SSL_ERROR_NONE; - - return ECORE_CON_SSL_ERROR_NONE; -} - -static int -_ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl, - unsigned char *buf, - int size) -{ - int num; - - if (!cl->ssl) return -1; - num = SSL_read(cl->ssl, buf, size); - cl->ssl_err = SSL_get_error(cl->ssl, num); - - if (cl->fd_handler) - { - if (cl->ssl && cl->ssl_err == SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); - else if (cl->ssl && cl->ssl_err == SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_WRITE); - } - - if ((cl->ssl_err == SSL_ERROR_ZERO_RETURN) || - (cl->ssl_err == SSL_ERROR_SYSCALL) || - (cl->ssl_err == SSL_ERROR_SSL)) - return -1; - - if (num < 0) - return 0; - - return num; -} - -static int -_ecore_con_ssl_client_write_openssl(Ecore_Con_Client *cl, - const unsigned char *buf, - int size) -{ - int num; - - num = SSL_write(cl->ssl, buf, size); - cl->ssl_err = SSL_get_error(cl->ssl, num); - - if (cl->fd_handler) - { - if (cl->ssl && cl->ssl_err == SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); - else if (cl->ssl && cl->ssl_err == SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_WRITE); - } - - if ((cl->ssl_err == SSL_ERROR_ZERO_RETURN) || - (cl->ssl_err == SSL_ERROR_SYSCALL) || - (cl->ssl_err == SSL_ERROR_SSL)) - return -1; - - if (num < 0) - return 0; - - return num; -} - -#else - -/* - * No Ssl - */ - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_init_none(void) -{ - return ECORE_CON_SSL_ERROR_NONE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_shutdown_none(void) -{ - return ECORE_CON_SSL_ERROR_NONE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_prepare_none(Ecore_Con_Server *svr __UNUSED__, - int ssl_type __UNUSED__) -{ - return ECORE_CON_SSL_ERROR_NONE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_init_none(Ecore_Con_Server *svr __UNUSED__) -{ - return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; -} - -static Eina_Bool -_ecore_con_ssl_server_cafile_add_none(Ecore_Con_Server *svr __UNUSED__, - const char *ca_file __UNUSED__) -{ - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_cert_add_none(Ecore_Con_Server *svr __UNUSED__, - const char *cert_file __UNUSED__) -{ - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_privkey_add_none(Ecore_Con_Server *svr __UNUSED__, - const char *key_file __UNUSED__) -{ - return EINA_FALSE; -} - -static Eina_Bool -_ecore_con_ssl_server_crl_add_none(Ecore_Con_Server *svr __UNUSED__, - const char *crl_file __UNUSED__) -{ - return EINA_FALSE; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_shutdown_none(Ecore_Con_Server *svr __UNUSED__) -{ - return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; -} - -static int -_ecore_con_ssl_server_read_none(Ecore_Con_Server *svr __UNUSED__, - unsigned char *buf __UNUSED__, - int size __UNUSED__) -{ - return -1; -} - -static int -_ecore_con_ssl_server_write_none(Ecore_Con_Server *svr __UNUSED__, - const unsigned char *buf __UNUSED__, - int size __UNUSED__) -{ - return -1; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_client_init_none(Ecore_Con_Client *cl __UNUSED__) -{ - return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; -} - -static Ecore_Con_Ssl_Error -_ecore_con_ssl_client_shutdown_none(Ecore_Con_Client *cl __UNUSED__) -{ - return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; -} - -static int -_ecore_con_ssl_client_read_none(Ecore_Con_Client *cl __UNUSED__, - unsigned char *buf __UNUSED__, - int size __UNUSED__) -{ - return -1; -} - -static int -_ecore_con_ssl_client_write_none(Ecore_Con_Client *cl __UNUSED__, - const unsigned char *buf __UNUSED__, - int size __UNUSED__) -{ - return -1; -} - -#endif diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_url.c b/libraries/ecore/src/lib/ecore_con/ecore_con_url.c deleted file mode 100644 index 05f0678..0000000 --- a/libraries/ecore/src/lib/ecore_con/ecore_con_url.c +++ /dev/null @@ -1,1635 +0,0 @@ -/* - * For info on how to use libcurl, see: - * http://curl.haxx.se/libcurl/c/libcurl-tutorial.html - */ - -/* - * FIXME: Support more CURL features... - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include - -#ifdef HAVE_WS2TCPIP_H -# include -#endif - -#ifdef HAVE_ESCAPE -# include -#endif - -#include "Ecore.h" -#include "ecore_private.h" -#include "Ecore_Con.h" -#include "ecore_con_private.h" - -#define CURL_MIN_TIMEOUT 100 - -int ECORE_CON_EVENT_URL_DATA = 0; -int ECORE_CON_EVENT_URL_COMPLETE = 0; -int ECORE_CON_EVENT_URL_PROGRESS = 0; - -#ifdef HAVE_CURL -static void _ecore_con_url_event_url_complete(Ecore_Con_Url *url_con, CURLMsg *curlmsg); -static void _ecore_con_url_multi_remove(Ecore_Con_Url *url_con); -static Eina_Bool _ecore_con_url_perform(Ecore_Con_Url *url_con); -static size_t _ecore_con_url_header_cb(void *ptr, size_t size, size_t nitems, void *stream); -static size_t _ecore_con_url_data_cb(void *buffer, size_t size, size_t nitems, void *userp); -static int _ecore_con_url_progress_cb(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); -static size_t _ecore_con_url_read_cb(void *ptr, size_t size, size_t nitems, void *stream); -static void _ecore_con_event_url_free(Ecore_Con_Url *url_con, void *ev); -static Eina_Bool _ecore_con_url_timer(void *data); -static Eina_Bool _ecore_con_url_fd_handler(void *data, Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_url_timeout_cb(void *data); -static void _ecore_con_url_status_get(Ecore_Con_Url *url_con); - -static Eina_List *_url_con_list = NULL; -static Eina_List *_fd_hd_list = NULL; -static CURLM *_curlm = NULL; -static int _init_count = 0; -static Ecore_Timer *_curl_timer = NULL; -static Eina_Bool pipelining = EINA_FALSE; - -#endif - -/** - * @addtogroup Ecore_Con_Url_Group Ecore URL Connection Functions - * - * @{ - */ - -EAPI int -ecore_con_url_init(void) -{ -#ifdef HAVE_CURL - long ms; - if (++_init_count > 1) return _init_count; - - ECORE_CON_EVENT_URL_DATA = ecore_event_type_new(); - ECORE_CON_EVENT_URL_COMPLETE = ecore_event_type_new(); - ECORE_CON_EVENT_URL_PROGRESS = ecore_event_type_new(); - - // curl_global_init() is not thread safe! - if (curl_global_init(CURL_GLOBAL_ALL)) return --_init_count; - - _curlm = curl_multi_init(); - if (!_curlm) - { - curl_global_cleanup(); - return --_init_count; - } - - curl_multi_timeout(_curlm, &ms); - if (ms >= CURL_MIN_TIMEOUT || ms <= 0) ms = CURL_MIN_TIMEOUT; - - _curl_timer = ecore_timer_add((double)ms / 1000, _ecore_con_url_timer, NULL); - ecore_timer_freeze(_curl_timer); - - return _init_count; -#else - return 0; -#endif -} - -EAPI int -ecore_con_url_shutdown(void) -{ -#ifdef HAVE_CURL - Ecore_Con_Url *url_con; - Ecore_Fd_Handler *fd_handler; - if (_init_count == 0) return 0; - --_init_count; - if (_init_count) return _init_count; - - if (_curl_timer) - { - ecore_timer_del(_curl_timer); - _curl_timer = NULL; - } - - EINA_LIST_FREE(_url_con_list, url_con) - ecore_con_url_free(url_con); - EINA_LIST_FREE(_fd_hd_list, fd_handler) - ecore_main_fd_handler_del(fd_handler); - - if (_curlm) - { - curl_multi_cleanup(_curlm); - _curlm = NULL; - } - curl_global_cleanup(); - return 0; -#endif - return 1; -} - -EAPI void -ecore_con_url_pipeline_set(Eina_Bool enable) -{ -#ifdef HAVE_CURL - if (enable == pipelining) return; - curl_multi_setopt(_curlm, CURLMOPT_PIPELINING, !!enable); - pipelining = enable; -#else - return; - (void)enable; -#endif -} - -EAPI Eina_Bool -ecore_con_url_pipeline_get(void) -{ -#ifdef HAVE_CURL - return pipelining; -#endif - return EINA_FALSE; -} - -extern Ecore_Con_Socks *_ecore_con_proxy_global; - -EAPI Ecore_Con_Url * -ecore_con_url_new(const char *url) -{ -#ifdef HAVE_CURL - Ecore_Con_Url *url_con; - CURLcode ret; - - if (!_init_count) - return NULL; - - url_con = calloc(1, sizeof(Ecore_Con_Url)); - if (!url_con) - return NULL; - - url_con->write_fd = -1; - - url_con->curl_easy = curl_easy_init(); - if (!url_con->curl_easy) - { - free(url_con); - return NULL; - } - - ECORE_MAGIC_SET(url_con, ECORE_MAGIC_CON_URL); - - if (!ecore_con_url_url_set(url_con, url)) - { - ecore_con_url_free(url_con); - return NULL; - } - - // Read socks proxy - url_con->proxy_type = -1; - if (_ecore_con_proxy_global && _ecore_con_proxy_global->ip && - (_ecore_con_proxy_global->version == 4 || - _ecore_con_proxy_global->version == 5)) - { - char proxy[256]; - char host[256]; - - if (_ecore_con_proxy_global->version == 5) - { - if (_ecore_con_proxy_global->lookup) - snprintf(host, sizeof(host), "socks5h://%s", - _ecore_con_proxy_global->ip); - else snprintf(host, sizeof(host), "socks5://%s", - _ecore_con_proxy_global->ip); - } - else if (_ecore_con_proxy_global->version == 4) - { - if (_ecore_con_proxy_global->lookup) - snprintf(host, sizeof(host), "socks4a://%s", - _ecore_con_proxy_global->ip); - else snprintf(host, sizeof(host), "socks4://%s", - _ecore_con_proxy_global->ip); - } - - if (_ecore_con_proxy_global->port > 0 && - _ecore_con_proxy_global->port <= 65535) - snprintf(proxy, sizeof(proxy), "%s:%d", host, - _ecore_con_proxy_global->port); - else snprintf(proxy, sizeof(proxy), "%s", host); - - ecore_con_url_proxy_set(url_con, proxy); - ecore_con_url_proxy_username_set(url_con, - _ecore_con_proxy_global->username); - } - - ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_ENCODING, "gzip,deflate"); - if (ret != CURLE_OK) - { - ERR("Could not set CURLOPT_ENCODING to \"gzip,deflate\": %s", - curl_easy_strerror(ret)); - ecore_con_url_free(url_con); - return NULL; - } - - curl_easy_setopt(url_con->curl_easy, CURLOPT_WRITEFUNCTION, - _ecore_con_url_data_cb); - curl_easy_setopt(url_con->curl_easy, CURLOPT_WRITEDATA, url_con); - - curl_easy_setopt(url_con->curl_easy, CURLOPT_PROGRESSFUNCTION, - _ecore_con_url_progress_cb); - curl_easy_setopt(url_con->curl_easy, CURLOPT_PROGRESSDATA, url_con); - curl_easy_setopt(url_con->curl_easy, CURLOPT_NOPROGRESS, EINA_FALSE); - - curl_easy_setopt(url_con->curl_easy, CURLOPT_HEADERFUNCTION, - _ecore_con_url_header_cb); - curl_easy_setopt(url_con->curl_easy, CURLOPT_HEADERDATA, url_con); - - /* - * FIXME: Check that these timeouts are sensible defaults - * FIXME: Provide a means to change these timeouts - */ - curl_easy_setopt(url_con->curl_easy, CURLOPT_CONNECTTIMEOUT, 30); - curl_easy_setopt(url_con->curl_easy, CURLOPT_FOLLOWLOCATION, 1); - - return url_con; -#else - return NULL; - url = NULL; -#endif -} - -EAPI Ecore_Con_Url * -ecore_con_url_custom_new(const char *url, - const char *custom_request) -{ -#ifdef HAVE_CURL - Ecore_Con_Url *url_con; - CURLcode ret; - - if (!url) - return NULL; - - if (!custom_request) - return NULL; - - url_con = ecore_con_url_new(url); - - if (!url_con) - return NULL; - - ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_CUSTOMREQUEST, custom_request); - if (ret != CURLE_OK) - { - ERR("Could not set a custom request string: %s", - curl_easy_strerror(ret)); - ecore_con_url_free(url_con); - return NULL; - } - - return url_con; -#else - return NULL; - url = NULL; - custom_request = NULL; -#endif -} - -EAPI void -ecore_con_url_free(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - char *s; - - if (!url_con) return; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_free"); - return; - } - - if (url_con->curl_easy) - { - // FIXME : How can we delete curl_easy's fds ?? (Curl do not give this info.) - // This cause "Failed to delete epoll fd xx!" error messages - curl_easy_setopt(url_con->curl_easy, CURLOPT_PROGRESSFUNCTION, NULL); - curl_easy_setopt(url_con->curl_easy, CURLOPT_NOPROGRESS, EINA_TRUE); - - if (url_con->multi) - { - _ecore_con_url_multi_remove(url_con); - _url_con_list = eina_list_remove(_url_con_list, url_con); - } - - curl_easy_cleanup(url_con->curl_easy); - } - if (url_con->timer) ecore_timer_del(url_con->timer); - - url_con->curl_easy = NULL; - url_con->timer = NULL; - url_con->dead = EINA_TRUE; - if (url_con->event_count) return; - ECORE_MAGIC_SET(url_con, ECORE_MAGIC_NONE); - - curl_slist_free_all(url_con->headers); - EINA_LIST_FREE(url_con->additional_headers, s) - free(s); - EINA_LIST_FREE(url_con->response_headers, s) - free(s); - eina_stringshare_del(url_con->url); - if (url_con->post_data) free(url_con->post_data); - free(url_con); -#else - return; - (void)url_con; -#endif -} - -EAPI const char * -ecore_con_url_url_get(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, __func__); - return NULL; - } - return url_con->url; -#else - return NULL; - (void)url_con; -#endif -} - -EAPI int -ecore_con_url_status_code_get(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, __func__); - return 0; - } - - if (url_con->status) return url_con->status; - _ecore_con_url_status_get(url_con); - return url_con->status; -#else - return -1; - (void)url_con; -#endif -} - -EAPI Eina_Bool -ecore_con_url_url_set(Ecore_Con_Url *url_con, const char *url) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_url_set"); - return EINA_FALSE; - } - - if (url_con->dead) return EINA_FALSE; - eina_stringshare_replace(&url_con->url, url); - - if (url_con->url) - curl_easy_setopt(url_con->curl_easy, CURLOPT_URL, - url_con->url); - else - curl_easy_setopt(url_con->curl_easy, CURLOPT_URL, ""); - - return EINA_TRUE; -#else - return EINA_FALSE; - (void)url; - (void)url_con; -#endif -} - -EAPI void -ecore_con_url_data_set(Ecore_Con_Url *url_con, void *data) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_data_set"); - return; - } - - url_con->data = data; -#else - return; - url_con = NULL; - data = NULL; -#endif -} - -EAPI void -ecore_con_url_additional_header_add(Ecore_Con_Url *url_con, const char *key, const char *value) -{ -#ifdef HAVE_CURL - char *tmp; - - if (url_con->dead) return; - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_additional_header_add"); - return; - } - - if (url_con->dead) return; - tmp = malloc(strlen(key) + strlen(value) + 3); - if (!tmp) - return; - - sprintf(tmp, "%s: %s", key, value); - url_con->additional_headers = eina_list_append(url_con->additional_headers, - tmp); -#else - return; - url_con = NULL; - key = NULL; - value = NULL; -#endif -} - -EAPI void -ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - char *s; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_additional_headers_clear"); - return; - } - - EINA_LIST_FREE(url_con->additional_headers, s) - free(s); -#else - return; - url_con = NULL; -#endif -} - -EAPI void * -ecore_con_url_data_get(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_data_get"); - return NULL; - } - - return url_con->data; -#else - return NULL; - url_con = NULL; -#endif -} - -EAPI void -ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time condition, double timestamp) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_time"); - return; - } - - if (url_con->dead) return; - url_con->time_condition = condition; - url_con->timestamp = timestamp; -#else - return; - (void)url_con; - (void)condition; - (void)timestamp; -#endif -} - -EAPI void -ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_set"); - return; - } - - if (url_con->dead) return; - url_con->write_fd = fd; -#else - return; - (void)url_con; - (void)fd; -#endif -} - -EAPI int -ecore_con_url_received_bytes_get(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_received_bytes_get"); - return -1; - } - - return url_con->received; -#else - return 0; - (void)url_con; -#endif -} - -EAPI const Eina_List * -ecore_con_url_response_headers_get(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - return url_con->response_headers; -#else - return NULL; - (void)url_con; -#endif -} - -EAPI Eina_Bool -ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, const char *password, Eina_Bool safe) -{ -#ifdef HAVE_CURL - CURLcode ret; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_httpauth_set"); - return EINA_FALSE; - } - - if (url_con->dead) return EINA_FALSE; -# if LIBCURL_VERSION_NUM >= 0x071301 - if ((username) && (password)) - { - if (safe) - curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH, - CURLAUTH_ANYSAFE); - else - curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH, CURLAUTH_ANY); - - ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_USERNAME, username); - if (ret != CURLE_OK) - { - ERR("Could not set username for HTTP authentication: %s", - curl_easy_strerror(ret)); - return EINA_FALSE; - } - - ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_PASSWORD, password); - if (ret != CURLE_OK) - { - ERR("Could not set password for HTTP authentication: %s", - curl_easy_strerror(ret)); - return EINA_FALSE; - } - - return EINA_TRUE; - } -# endif -#else - return EINA_FALSE; - (void)url_con; - (void)username; - (void)password; - (void)safe; -#endif - - return EINA_FALSE; -} - -#define MODE_AUTO 0 -#define MODE_GET 1 -#define MODE_POST 2 - -static Eina_Bool -_ecore_con_url_send(Ecore_Con_Url *url_con, int mode, const void *data, long length, const char *content_type) -{ -#ifdef HAVE_CURL - Eina_List *l; - const char *s; - char tmp[512]; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_send"); - return EINA_FALSE; - } - - if (!url_con->url) return EINA_FALSE; - if (url_con->dead) return EINA_FALSE; - - /* Free response headers from previous send() calls */ - EINA_LIST_FREE(url_con->response_headers, s) - free((char *)s); - url_con->response_headers = NULL; - url_con->status = 0; - - curl_slist_free_all(url_con->headers); - url_con->headers = NULL; - - if ((mode == MODE_POST) || (mode == MODE_AUTO)) - { - if (url_con->post_data) free(url_con->post_data); - url_con->post_data = NULL; - if ((data) && (length > 0)) - { - url_con->post_data = malloc(length); - if (url_con->post_data) - { - memcpy(url_con->post_data, data, length); - if ((content_type) && (strlen(content_type) < 450)) - { - snprintf(tmp, sizeof(tmp), "Content-Type: %s", content_type); - url_con->headers = curl_slist_append(url_con->headers, tmp); - } - curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDS, url_con->post_data); - curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDSIZE, length); - } - else - return EINA_FALSE; - } - else curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDSIZE, 0); - if (mode == MODE_POST) - curl_easy_setopt(url_con->curl_easy, CURLOPT_POST, 1); - } - - switch (url_con->time_condition) - { - case ECORE_CON_URL_TIME_NONE: - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, - CURL_TIMECOND_NONE); - break; - - case ECORE_CON_URL_TIME_IFMODSINCE: - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, - CURL_TIMECOND_IFMODSINCE); - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, - (long)url_con->timestamp); - break; - - case ECORE_CON_URL_TIME_IFUNMODSINCE: - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, - CURL_TIMECOND_IFUNMODSINCE); - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, - (long)url_con->timestamp); - break; - } - - /* Additional headers */ - EINA_LIST_FOREACH(url_con->additional_headers, l, s) - url_con->headers = curl_slist_append(url_con->headers, s); - - curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPHEADER, url_con->headers); - - url_con->received = 0; - - return _ecore_con_url_perform(url_con); -#else - return EINA_FALSE; - (void)url_con; - (void)mode; - (void)data; - (void)length; - (void)content_type; -#endif -} - -EAPI Eina_Bool -ecore_con_url_get(Ecore_Con_Url *url_con) -{ - return _ecore_con_url_send(url_con, MODE_GET, NULL, 0, NULL); -} - -EAPI Eina_Bool -ecore_con_url_post(Ecore_Con_Url *url_con, const void *data, long length, const char *content_type) -{ - return _ecore_con_url_send(url_con, MODE_POST, data, length, content_type); -} - -EAPI Eina_Bool -ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, const char *user, const char *pass, const char *upload_dir) -{ -#ifdef HAVE_CURL - char url[4096]; - char userpwd[4096]; - FILE *fd; - struct stat file_info; - CURLcode ret; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, - ECORE_MAGIC_CON_URL, - "ecore_con_url_ftp_upload"); - return EINA_FALSE; - } - - if (url_con->dead) return EINA_FALSE; - if (!url_con->url) return EINA_FALSE; - if ((!filename) || (!filename[0])) return EINA_FALSE; - - if (stat(filename, &file_info)) - return EINA_FALSE; - - snprintf(userpwd, sizeof(userpwd), "%s:%s", user, pass); - ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_USERPWD, userpwd); - if (ret != CURLE_OK) - { - ERR("Could not set username and password for FTP upload: %s", - curl_easy_strerror(ret)); - return EINA_FALSE; - } - - char tmp[PATH_MAX]; - snprintf(tmp, PATH_MAX, "%s", filename); - - if (upload_dir) - snprintf(url, sizeof(url), "ftp://%s/%s/%s", url_con->url, - upload_dir, basename(tmp)); - else - snprintf(url, sizeof(url), "ftp://%s/%s", url_con->url, - basename(tmp)); - - if (!ecore_con_url_url_set(url_con, url)) - return EINA_FALSE; - - curl_easy_setopt(url_con->curl_easy, CURLOPT_INFILESIZE_LARGE, - (curl_off_t)file_info.st_size); - curl_easy_setopt(url_con->curl_easy, CURLOPT_UPLOAD, 1); - curl_easy_setopt(url_con->curl_easy, CURLOPT_READFUNCTION, - _ecore_con_url_read_cb); - - fd = fopen(filename, "rb"); - if (!fd) - { - ERR("Could not open \"%s\" for FTP upload", filename); - return EINA_FALSE; - } - curl_easy_setopt(url_con->curl_easy, CURLOPT_READDATA, fd); - - return _ecore_con_url_perform(url_con); -#else - return EINA_FALSE; - (void)url_con; - (void)filename; - (void)user; - (void)pass; - (void)upload_dir; -#endif -} - -EAPI void -ecore_con_url_cookies_init(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - if (!url_con) - return; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_cookies_init"); - return; - } - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_COOKIEFILE, ""); -#else - return; - (void)url_con; -#endif -} - -EAPI void -ecore_con_url_cookies_ignore_old_session_set(Ecore_Con_Url *url_con, Eina_Bool ignore) -{ -#ifdef HAVE_CURL - if (!url_con) - return; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_cookies_ignore_old_session_set"); - return; - } - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_COOKIESESSION, ignore); -#else - return; - (void)url_con; - (void)ignore; -#endif -} - -EAPI void -ecore_con_url_cookies_clear(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - if (!url_con) - return; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_cookies_clear"); - return; - } - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_COOKIELIST, "ALL"); -#else - return; - (void)url_con; -#endif -} - -EAPI void -ecore_con_url_cookies_session_clear(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - if (!url_con) - return; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_cookies_session_clear"); - return; - } - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_COOKIELIST, "SESS"); -#else - return; - (void)url_con; -#endif -} - -EAPI void -ecore_con_url_cookies_file_add(Ecore_Con_Url *url_con, const char *const file_name) -{ -#ifdef HAVE_CURL - if (!url_con) - return; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_cookies_file_add"); - return; - } - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_COOKIEFILE, file_name); -#else - return; - (void)url_con; - (void)file_name; -#endif -} - -EAPI Eina_Bool -ecore_con_url_cookies_jar_file_set(Ecore_Con_Url *url_con, const char *const cookiejar_file) -{ -#ifdef HAVE_CURL - CURLcode ret; - - if (!url_con) - return EINA_FALSE; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_cookies_jar_file_set"); - return EINA_FALSE; - } - - if (url_con->dead) return EINA_FALSE; - ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_COOKIEJAR, - cookiejar_file); - if (ret != CURLE_OK) - { - ERR("Setting the cookie-jar name failed: %s", - curl_easy_strerror(ret)); - return EINA_FALSE; - } - - return EINA_TRUE; -#else - return EINA_FALSE; - (void)url_con; - (void)cookiejar_file; -#endif -} - -EAPI void -ecore_con_url_cookies_jar_write(Ecore_Con_Url *url_con) -{ -#ifdef HAVE_CURL - if (!url_con) - return; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_cookies_jar_write"); - return; - } - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_COOKIELIST, "FLUSH"); -#else - return; - (void)url_con; -#endif -} - -EAPI void -ecore_con_url_verbose_set(Ecore_Con_Url *url_con, Eina_Bool verbose) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_verbose_set"); - return; - } - - if (!url_con->url) - return; - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_VERBOSE, (int)verbose); -#else - return; - (void)url_con; - (void)verbose; -#endif -} - -EAPI void -ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, Eina_Bool use_epsv) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_ftp_use_epsv_set"); - return; - } - - if (!url_con->url) - return; - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_FTP_USE_EPSV, (int)use_epsv); -#else - return; - (void)url_con; - (void)use_epsv; -#endif -} - -/** - * Toggle libcurl's verify peer's certificate option. - * - * If @p verify is @c EINA_TRUE, libcurl will verify - * the authenticity of the peer's certificate, otherwise - * it will not. Default behavior of libcurl is to check - * peer's certificate. - * - * @param url_con Ecore_Con_Url instance which will be acted upon. - * @param verify Whether or not libcurl will check peer's certificate. - * @since 1.1.0 - */ -EAPI void -ecore_con_url_ssl_verify_peer_set(Ecore_Con_Url *url_con, Eina_Bool verify) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_ssl_verify_peer_set"); - return; - } - - if (!url_con->url) - return; - - if (url_con->dead) return; - curl_easy_setopt(url_con->curl_easy, CURLOPT_SSL_VERIFYPEER, (int)verify); -#else - return; - (void)url_con; - (void)verify; -#endif -} - -/** - * Set a custom CA to trust for SSL/TLS connections. - * - * Specify the path of a file (in PEM format) containing one or more - * CA certificate(s) to use for the validation of the server certificate. - * - * This function can also disable CA validation if @p ca_path is @c NULL. - * However, the server certificate still needs to be valid for the connection - * to succeed (i.e., the certificate must concern the server the - * connection is made to). - * - * @param url_con Connection object that will use the custom CA. - * @param ca_path Path to a CA certificate(s) file or @c NULL to disable - * CA validation. - * - * @return @c 0 on success. When cURL is used, non-zero return values - * are equal to cURL error codes. - */ -EAPI int -ecore_con_url_ssl_ca_set(Ecore_Con_Url *url_con, const char *ca_path) -{ - int res = -1; - -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_ssl_ca_set"); - return -1; - } - - if (!url_con->url) return -1; - if (url_con->dead) return -1; - if (ca_path == NULL) - res = curl_easy_setopt(url_con->curl_easy, CURLOPT_SSL_VERIFYPEER, 0); - else - { - res = curl_easy_setopt(url_con->curl_easy, CURLOPT_SSL_VERIFYPEER, 1); - if (!res) - res = curl_easy_setopt(url_con->curl_easy, CURLOPT_CAINFO, ca_path); - } -#else - return -1; - (void)url_con; - (void)ca_path; -#endif - - return res; -} - -EAPI Eina_Bool -ecore_con_url_http_version_set(Ecore_Con_Url *url_con, Ecore_Con_Url_Http_Version version) -{ -#ifdef HAVE_CURL - int res = -1; - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_http_version_set"); - return EINA_FALSE; - } - if (url_con->dead) return EINA_FALSE; - switch (version) - { - case ECORE_CON_URL_HTTP_VERSION_1_0: - res = curl_easy_setopt(url_con->curl_easy, - CURLOPT_HTTP_VERSION, - CURL_HTTP_VERSION_1_0); - break; - - case ECORE_CON_URL_HTTP_VERSION_1_1: - res = curl_easy_setopt(url_con->curl_easy, - CURLOPT_HTTP_VERSION, - CURL_HTTP_VERSION_1_1); - break; - - default: - break; - } - if (res != CURLE_OK) - { - ERR("curl http version setting failed: %s", curl_easy_strerror(res)); - return EINA_FALSE; - } - return EINA_TRUE; -#else - (void)url_con; - (void)version; - return EINA_FALSE; -#endif -} - -EAPI Eina_Bool -ecore_con_url_proxy_set(Ecore_Con_Url *url_con, const char *proxy) -{ -#ifdef HAVE_CURL - int res = -1; - curl_version_info_data *vers = NULL; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_proxy_set"); - return EINA_FALSE; - } - - if (!url_con->url) return EINA_FALSE; - if (url_con->dead) return EINA_FALSE; - - if (!proxy) res = curl_easy_setopt(url_con->curl_easy, CURLOPT_PROXY, ""); - else - { - // before curl version 7.21.7, socks protocol:// prefix is not supported - // (e.g. socks4://, socks4a://, socks5:// or socks5h://, etc.) - vers = curl_version_info(CURLVERSION_NOW); - if (vers->version_num < 0x71507) - { - url_con->proxy_type = CURLPROXY_HTTP; - if (strstr(proxy, "socks4a")) - url_con->proxy_type = CURLPROXY_SOCKS4A; - else if (strstr(proxy, "socks4")) - url_con->proxy_type = CURLPROXY_SOCKS4; - else if (strstr(proxy, "socks5h")) - url_con->proxy_type = CURLPROXY_SOCKS5_HOSTNAME; - else if (strstr(proxy, "socks5")) - url_con->proxy_type = CURLPROXY_SOCKS5; - res = curl_easy_setopt(url_con->curl_easy, CURLOPT_PROXYTYPE, - url_con->proxy_type); - if (res != CURLE_OK) - { - ERR("curl proxy type setting failed: %s", - curl_easy_strerror(res)); - url_con->proxy_type = -1; - return EINA_FALSE; - } - } - res = curl_easy_setopt(url_con->curl_easy, CURLOPT_PROXY, proxy); - } - if (res != CURLE_OK) - { - ERR("curl proxy setting failed: %s", curl_easy_strerror(res)); - url_con->proxy_type = -1; - return EINA_FALSE; - } - return EINA_TRUE; -#else - return EINA_FALSE; - (void)url_con; - (void)proxy; -#endif -} - -EAPI void -ecore_con_url_timeout_set(Ecore_Con_Url *url_con, double timeout) -{ -#ifdef HAVE_CURL - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_timeout_set"); - return; - } - - if (url_con->dead) return; - if (!url_con->url || timeout < 0) return; - if (url_con->timer) ecore_timer_del(url_con->timer); - url_con->timer = ecore_timer_add(timeout, _ecore_con_url_timeout_cb, url_con); -#else - return; - (void)url_con; - (void)timeout; -#endif -} - -EAPI Eina_Bool -ecore_con_url_proxy_username_set(Ecore_Con_Url *url_con, const char *username) -{ -#ifdef HAVE_CURL - int res = -1; - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_proxy_username_set"); - return EINA_FALSE; - } - - if (url_con->dead) return EINA_FALSE; - if (!url_con->url) return EINA_FALSE; - if ((!username) || (!username[0])) return EINA_FALSE; - if (url_con->proxy_type == CURLPROXY_SOCKS4 || url_con->proxy_type == CURLPROXY_SOCKS4A) - { - ERR("Proxy type should be socks5 and above"); - return EINA_FALSE; - } - - res = curl_easy_setopt(url_con->curl_easy, CURLOPT_USERNAME, username); - if (res != CURLE_OK) - { - ERR("curl_easy_setopt() failed: %s", curl_easy_strerror(res)); - return EINA_FALSE; - } - return EINA_TRUE; -#else - return EINA_FALSE; - (void)url_con; - (void)username; -#endif -} - -EAPI Eina_Bool -ecore_con_url_proxy_password_set(Ecore_Con_Url *url_con, const char *password) -{ -#ifdef HAVE_CURL - int res = -1; - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_proxy_password_set"); - return EINA_FALSE; - } - if (!url_con->url) return EINA_FALSE; - if (url_con->dead) return EINA_FALSE; - if (!password) return EINA_FALSE; - if (url_con->proxy_type == CURLPROXY_SOCKS4 || url_con->proxy_type == CURLPROXY_SOCKS4A) - { - ERR("Proxy type should be socks5 and above"); - return EINA_FALSE; - } - - res = curl_easy_setopt(url_con->curl_easy, CURLOPT_PASSWORD, password); - if (res != CURLE_OK) - { - ERR("curl_easy_setopt() failed: %s", curl_easy_strerror(res)); - return EINA_FALSE; - } - return EINA_TRUE; -#else - return EINA_FALSE; - (void)url_con; - (void)password; -#endif -} - -/** - * @} - */ - -#ifdef HAVE_CURL -static void -_ecore_con_url_status_get(Ecore_Con_Url *url_con) -{ - long status = 0; - - if (!url_con->curl_easy) return; - if (!curl_easy_getinfo(url_con->curl_easy, CURLINFO_RESPONSE_CODE, &status)) - url_con->status = status; - else - url_con->status = 0; -} - -static void -_ecore_con_url_event_url_complete(Ecore_Con_Url *url_con, CURLMsg *curlmsg) -{ - Ecore_Con_Event_Url_Complete *e; - - e = calloc(1, sizeof(Ecore_Con_Event_Url_Complete)); - if (!e) return; - - if (curlmsg && (curlmsg->data.result == CURLE_OK)) - { - if (!url_con->status) - _ecore_con_url_status_get(url_con); - } - else if (curlmsg) - ERR("Curl message have errors: %d", curlmsg->data.result); - else - CRIT("THIS IS BAD."); - - e->status = url_con->status; - e->url_con = url_con; - url_con->event_count++; - ecore_event_add(ECORE_CON_EVENT_URL_COMPLETE, e, (Ecore_End_Cb)_ecore_con_event_url_free, url_con); -} - -static void -_ecore_con_url_multi_remove(Ecore_Con_Url *url_con) -{ - CURLMcode ret; - - ret = curl_multi_remove_handle(_curlm, url_con->curl_easy); - url_con->multi = EINA_FALSE; - if (ret != CURLM_OK) ERR("curl_multi_remove_handle failed: %s", curl_multi_strerror(ret)); -} - -static Eina_Bool -_ecore_con_url_timeout_cb(void *data) -{ - Ecore_Con_Url *url_con = data; - - if (!url_con) return ECORE_CALLBACK_CANCEL; - if (!url_con->curl_easy) return ECORE_CALLBACK_CANCEL; - - _ecore_con_url_multi_remove(url_con); - _url_con_list = eina_list_remove(_url_con_list, url_con); - - curl_slist_free_all(url_con->headers); - url_con->headers = NULL; - - url_con->timer = NULL; - - _ecore_con_url_event_url_complete(url_con, NULL); - return ECORE_CALLBACK_CANCEL; -} - -static size_t -_ecore_con_url_data_cb(void *buffer, size_t size, size_t nitems, void *userp) -{ - Ecore_Con_Url *url_con; - Ecore_Con_Event_Url_Data *e; - size_t real_size = size * nitems; - - url_con = (Ecore_Con_Url *)userp; - - if (!url_con) - return -1; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_data_cb"); - return -1; - } - - url_con->received += real_size; - - INF("reading from %s", url_con->url); - if (url_con->write_fd < 0) - { - e = - malloc(sizeof(Ecore_Con_Event_Url_Data) + sizeof(unsigned char) * - (real_size - 1)); - if (e) - { - e->url_con = url_con; - e->size = real_size; - memcpy(e->data, buffer, real_size); - url_con->event_count++; - ecore_event_add(ECORE_CON_EVENT_URL_DATA, e, (Ecore_End_Cb)_ecore_con_event_url_free, url_con); - } - } - else - { - ssize_t count = 0; - size_t total_size = real_size; - size_t offset = 0; - - while (total_size > 0) - { - count = write(url_con->write_fd, - (char *)buffer + offset, - total_size); - if (count < 0) - { - if (errno != EAGAIN && errno != EINTR) - return -1; - } - else - { - total_size -= count; - offset += count; - } - } - } - - return real_size; -} - -static size_t -_ecore_con_url_header_cb(void *ptr, size_t size, size_t nitems, void *stream) -{ - size_t real_size = size * nitems; - Ecore_Con_Url *url_con = stream; - - char *header = malloc(sizeof(char) * (real_size + 1)); - if (!header) - return real_size; - - memcpy(header, ptr, real_size); - header[real_size] = '\0'; - - url_con->response_headers = eina_list_append(url_con->response_headers, - header); - - return real_size; -} - -static int -_ecore_con_url_progress_cb(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) -{ - Ecore_Con_Event_Url_Progress *e; - Ecore_Con_Url *url_con; - - url_con = clientp; - - e = malloc(sizeof(Ecore_Con_Event_Url_Progress)); - if (e) - { - e->url_con = url_con; - e->down.total = dltotal; - e->down.now = dlnow; - e->up.total = ultotal; - e->up.now = ulnow; - url_con->event_count++; - ecore_event_add(ECORE_CON_EVENT_URL_PROGRESS, e, (Ecore_End_Cb)_ecore_con_event_url_free, url_con); - } - - return 0; -} - -static size_t -_ecore_con_url_read_cb(void *ptr, size_t size, size_t nitems, void *stream) -{ - size_t retcode = fread(ptr, size, nitems, stream); - - if (ferror((FILE *)stream)) - { - fclose(stream); - return CURL_READFUNC_ABORT; - } - else if (retcode == 0) - { - fclose((FILE *)stream); - return 0; - } - -#ifdef _WIN32 - INF("*** We read %Iu bytes from file", retcode); -#else - INF("*** We read %zu bytes from file", retcode); -#endif - return retcode; -} - -static void -_ecore_con_url_info_read(void) -{ - CURLMsg *curlmsg; - int n_remaining; - - while ((curlmsg = curl_multi_info_read(_curlm, &n_remaining))) - { - Eina_List *l, *ll; - Ecore_Con_Url *url_con = NULL; - DBG("Curl message: %d", curlmsg->msg); - - if (curlmsg->msg == CURLMSG_DONE) - { - EINA_LIST_FOREACH_SAFE(_url_con_list, l, ll, url_con) - { - if (curlmsg->easy_handle == url_con->curl_easy) - _ecore_con_url_event_url_complete(url_con, curlmsg); - } - } - } -} - -static void -_ecore_con_url_curl_clear(void) -{ - Ecore_Fd_Handler *fdh; - Ecore_Con_Url *url_con; - - EINA_LIST_FREE(_fd_hd_list, fdh) ecore_main_fd_handler_del(fdh); - EINA_LIST_FREE(_url_con_list, url_con) _ecore_con_url_multi_remove(url_con); -} - -static Eina_Bool -_ecore_con_url_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__) -{ - Ecore_Fd_Handler *fdh; - EINA_LIST_FREE(_fd_hd_list, fdh) ecore_main_fd_handler_del(fdh); - ecore_timer_interval_set(_curl_timer, 0.1); - return ECORE_CALLBACK_CANCEL; -} - -static void -_ecore_con_url_fdset(void) -{ - CURLMcode ret; - fd_set read_set, write_set, exc_set; - int fd, fd_max; - - FD_ZERO(&read_set); - FD_ZERO(&write_set); - FD_ZERO(&exc_set); - - ret = curl_multi_fdset(_curlm, &read_set, &write_set, &exc_set, &fd_max); - if (ret != CURLM_OK) - { - ERR("curl_multi_fdset failed: %s", curl_multi_strerror(ret)); - return; - } - - for (fd = 0; fd <= fd_max; fd++) - { - int flags = 0; - if (FD_ISSET(fd, &read_set)) flags |= ECORE_FD_READ; - if (FD_ISSET(fd, &write_set)) flags |= ECORE_FD_WRITE; - if (FD_ISSET(fd, &exc_set)) flags |= ECORE_FD_ERROR; - if (flags) - { - // FIXME: Who is owner (easy_handle) of this fd?? (Curl do not give this info.) - // This cause "Failed to delete epoll fd xx!" error messages - Ecore_Fd_Handler *fd_handler; - fd_handler = ecore_main_fd_handler_add(fd, flags, - _ecore_con_url_fd_handler, - NULL, NULL, NULL); - if (fd_handler) - _fd_hd_list = eina_list_append(_fd_hd_list, fd_handler); - } - } -} - -static Eina_Bool -_ecore_con_url_timer(void *data __UNUSED__) -{ - Ecore_Fd_Handler *fdh; - int still_running; - CURLMcode ret; - - EINA_LIST_FREE(_fd_hd_list, fdh) ecore_main_fd_handler_del(fdh); - _ecore_con_url_info_read(); - - ret = curl_multi_perform(_curlm, &still_running); - if (ret == CURLM_CALL_MULTI_PERFORM) - { - DBG("curl_multi_perform() again immediately"); - return ECORE_CALLBACK_RENEW; - } - else if (ret != CURLM_OK) - { - ERR("curl_multi_perform() failed: %s", curl_multi_strerror(ret)); - _ecore_con_url_curl_clear(); - ecore_timer_freeze(_curl_timer); - } - - if (still_running) - { - long ms; - _ecore_con_url_fdset(); - curl_multi_timeout(_curlm, &ms); - DBG("multiperform is still running: %d, timeout: %ld", still_running, ms); - if (ms >= CURL_MIN_TIMEOUT || ms <= 0) ms = CURL_MIN_TIMEOUT; - ecore_timer_interval_set(_curl_timer, (double)ms / 1000); - } - else - { - DBG("multiperform ended"); - _ecore_con_url_info_read(); - _ecore_con_url_curl_clear(); - ecore_timer_freeze(_curl_timer); - } - - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool -_ecore_con_url_perform(Ecore_Con_Url *url_con) -{ - CURLMcode ret; - - ret = curl_multi_add_handle(_curlm, url_con->curl_easy); - if (ret != CURLM_OK) - { - ERR("curl_multi_add_handle() failed: %s", curl_multi_strerror(ret)); - return EINA_FALSE; - } - - url_con->multi = EINA_TRUE; - _url_con_list = eina_list_append(_url_con_list, url_con); - ecore_timer_thaw(_curl_timer); - - return EINA_TRUE; -} - -static void -_ecore_con_event_url_free(Ecore_Con_Url *url_con, void *ev) -{ - free(ev); - url_con->event_count--; - if (url_con->dead && (!url_con->event_count)) - ecore_con_url_free(url_con); -} - -#endif -- cgit v1.1