19 # define EAPI __declspec(dllexport)
21 # define EAPI __declspec(dllimport)
26 # define EAPI __attribute__ ((visibility("default")))
36 * @defgroup Ecore_Con_Group Ecore_Con - Connection functions
38 * The Ecore Connection Library ( @c Ecore_Con ) provides simple mechanisms
39 * for communications between programs using reliable sockets. It saves
40 * the programmer from having to worry about file descriptors and waiting
41 * for incoming connections.
43 * There are two main objects in the @c Ecore_Con library: the @c
44 * Ecore_Con_Server and the @c Ecore_Con_Client.
46 * The @c Ecore_Con_Server represents a server that can be connected to.
47 * It is used regardless of whether the program is acting as a server or
50 * To create a listening server call @c ecore_con_server_add(), optionally using
51 * an ECORE_CON_USE_* encryption type OR'ed with the type for encryption.
53 * To connect to a server, call @c ecore_con_server_connect(). Data can
54 * then be sent to the server using the @c ecore_con_server_send().
56 * Functions are described in the following groupings:
57 * @li @ref Ecore_Con_Lib_Group
58 * @li @ref Ecore_Con_Server_Group
59 * @li @ref Ecore_Con_Client_Group
60 * @li @ref Ecore_Con_Url_Group
62 * Events are described in @ref Ecore_Con_Events_Group.
67 * @defgroup Ecore_Con_Events_Group Events
69 * @li ECORE_CON_CLIENT_ADD: Whenever a client connection is made to an
70 * @c Ecore_Con_Server, an event of this type is emitted, allowing the
71 * retrieval of the client's ip with @ref ecore_con_client_ip_get and
72 * associating data with the client using ecore_con_client_data_set.
73 * @li ECORE_CON_EVENT_CLIENT_DEL: Whenever a client connection to an
74 * @c Ecore_Con_Server, an event of this type is emitted. The contents of
75 * the data with this event are variable, but if the client object in the data
76 * is non-null, it must be freed with @ref ecore_con_client_del.
77 * @li ECORE_CON_EVENT_SERVER_ADD: Whenever a server object is created
78 * with @ref ecore_con_server_connect, an event of this type is emitted,
79 * allowing for data to be serialized and sent to the server using
80 * @ref ecore_con_server_send. At this point, the http handshake has
82 * @li ECORE_CON_EVENT_SERVER_DEL: Whenever a server object is destroyed,
83 * usually by the server connection being refused or dropped, an event of this
84 * type is emitted. The contents of the data with this event are variable,
85 * but if the server object in the data is non-null, it must be freed
86 * with @ref ecore_con_server_del.
87 * @li ECORE_CON_EVENT_CLIENT_DATA: Whenever a client connects to your server
88 * object and sends data, an event of this type is emitted. The data will contain both
89 * the size and contents of the message sent by the client. It should be noted that
90 * data within this object is transient, so it must be duplicated in order to be
91 * retained. This event will continue to occur until the client has stopped sending its
92 * message, so a good option for storing this data is an Eina_Strbuf. Once the message has
93 * been received in full, the client object must be freed with ecore_con_client_free.
94 * @li ECORE_CON_EVENT_SERVER_DATA: Whenever your server object connects to its destination
95 * and receives data, an event of this type is emitted. The data will contain both
96 * the size and contents of the message sent by the server. It should be noted that
97 * data within this object is transient, so it must be duplicated in order to be
98 * retained. This event will continue to occur until the server has stopped sending its
99 * message, so a good option for storing this data is an Eina_Strbuf. Once the message has
100 * been received in full, the server object must be freed with ecore_con_server_free.
107 #define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2
108 #define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP
112 * @typedef Ecore_Con_Server
113 * A connection handle to a server
114 * @ingroup Ecore_Con_Server_Group
116 typedef struct _Ecore_Con_Server Ecore_Con_Server;
119 * @typedef Ecore_Con_Client
120 * A connection handle to a client
121 * @ingroup Ecore_Con_Client_Group
123 typedef struct _Ecore_Con_Client Ecore_Con_Client;
126 * @typedef Ecore_Con_Url
127 * A handle to an http upload/download object
128 * @ingroup Ecore_Con_Url_Group
130 typedef struct _Ecore_Con_Url Ecore_Con_Url;
134 * @addtogroup Ecore_Con_Events_Group Events
139 * @typedef Ecore_Con_Event_Client_Add
140 * Used as the @p data param for the corresponding event
142 typedef struct _Ecore_Con_Event_Client_Add Ecore_Con_Event_Client_Add;
145 * @typedef Ecore_Con_Event_Client_Del
146 * Used as the @p data param for the corresponding event
148 typedef struct _Ecore_Con_Event_Client_Del Ecore_Con_Event_Client_Del;
151 * @typedef Ecore_Con_Event_Server_Add
152 * Used as the @p data param for the corresponding event
154 typedef struct _Ecore_Con_Event_Server_Add Ecore_Con_Event_Server_Add;
157 * @typedef Ecore_Con_Event_Server_Del
158 * Used as the @p data param for the corresponding event
160 typedef struct _Ecore_Con_Event_Server_Del Ecore_Con_Event_Server_Del;
163 * @typedef Ecore_Con_Event_Client_Data
164 * Used as the @p data param for the corresponding event
166 typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data;
169 * @typedef Ecore_Con_Event_Server_Data
170 * Used as the @p data param for the corresponding event
172 typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
175 * @typedef Ecore_Con_Event_Url_Data
176 * Used as the @p data param for the corresponding event
178 typedef struct _Ecore_Con_Event_Url_Data Ecore_Con_Event_Url_Data;
181 * @typedef Ecore_Con_Event_Url_Complete
182 * Used as the @p data param for the corresponding event
184 typedef struct _Ecore_Con_Event_Url_Complete Ecore_Con_Event_Url_Complete;
187 * @typedef Ecore_Con_Event_Url_Progress
188 * Used as the @p data param for the corresponding event
190 typedef struct _Ecore_Con_Event_Url_Progress Ecore_Con_Event_Url_Progress;
193 * @struct _Ecore_Con_Event_Client_Add
194 * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_ADD event
196 struct _Ecore_Con_Event_Client_Add
198 Ecore_Con_Client *client; /** the client that connected */
202 * @struct _Ecore_Con_Event_Client_Del
203 * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_DEL event
205 struct _Ecore_Con_Event_Client_Del
207 Ecore_Con_Client *client; /** the client that was lost */
211 * @struct _Ecore_Con_Event_Server_Add
212 * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_ADD event
214 struct _Ecore_Con_Event_Server_Add
216 Ecore_Con_Server *server; /** the server that was connected to */
220 * @struct _Ecore_Con_Event_Server_Del
221 * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_DEL event
223 struct _Ecore_Con_Event_Server_Del
225 Ecore_Con_Server *server; /** the client that was lost */
229 * @struct _Ecore_Con_Event_Client_Data
230 * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_DATA event
232 struct _Ecore_Con_Event_Client_Data
234 Ecore_Con_Client *client; /**< the client that connected */
235 void *data; /**< the data that the client sent */
236 int size; /**< the length of the data sent */
240 * @struct _Ecore_Con_Event_Server_Data
241 * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_DATA event
243 struct _Ecore_Con_Event_Server_Data
245 Ecore_Con_Server *server; /**< the server that was connected to */
246 void *data; /**< the data that the server sent */
247 int size; /**< the length of the data sent */
251 * @struct _Ecore_Con_Event_Url_Data
252 * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_DATA event
254 struct _Ecore_Con_Event_Url_Data
256 Ecore_Con_Url *url_con;
258 unsigned char data[1];
262 * @struct _Ecore_Con_Event_Url_Complete
263 * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_COMPLETE event
265 struct _Ecore_Con_Event_Url_Complete
267 Ecore_Con_Url *url_con;
272 * @struct _Ecore_Con_Event_Url_Progress
273 * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_PROGRESS event
275 struct _Ecore_Con_Event_Url_Progress
277 Ecore_Con_Url *url_con;
290 /** A client has connected to the server */
291 EAPI extern int ECORE_CON_EVENT_CLIENT_ADD;
292 /** A client has disconnected from the server */
293 EAPI extern int ECORE_CON_EVENT_CLIENT_DEL;
294 /** A server was created */
295 EAPI extern int ECORE_CON_EVENT_SERVER_ADD;
296 /** A server connection was lost */
297 EAPI extern int ECORE_CON_EVENT_SERVER_DEL;
298 /** A client connected to the server has sent data */
299 EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
300 /** A server connection object has data */
301 EAPI extern int ECORE_CON_EVENT_SERVER_DATA;
302 /** A URL object has data */
303 EAPI extern int ECORE_CON_EVENT_URL_DATA;
304 /** A URL object has completed its transfer to and from the server and can be reused */
305 EAPI extern int ECORE_CON_EVENT_URL_COMPLETE;
306 /** A URL object has made progress in its transfer */
307 EAPI extern int ECORE_CON_EVENT_URL_PROGRESS;
314 * @defgroup Ecore_Con_Lib_Group Ecore Connection Library Functions
320 * @typedef Ecore_Con_Dns_Cb
321 * A callback type for use with @ref ecore_con_lookup.
323 typedef void (*Ecore_Con_Dns_Cb)(const char *canonname,
325 struct sockaddr *addr,
330 * @typedef Ecore_Con_Type
331 * @enum _Ecore_Con_Type
332 * Types for an ecore_con client/server object. A correct way to set this type is
333 * with an ECORE_CON_$TYPE, optionally OR'ed with an ECORE_CON_$USE if encryption is desired,
334 * and LOAD_CERT if the previously loaded certificate should be used.
336 * ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT
339 typedef enum _Ecore_Con_Type
341 /** Socket in ~/.ecore */
342 ECORE_CON_LOCAL_USER = 0,
343 /** Socket in /tmp */
344 ECORE_CON_LOCAL_SYSTEM = 1,
345 /** Abstract socket */
346 ECORE_CON_LOCAL_ABSTRACT = 2,
347 /** Remote server using TCP */
348 ECORE_CON_REMOTE_TCP = 3,
349 /** Remote multicast server */
350 ECORE_CON_REMOTE_MCAST = 4,
351 /** Remote server using UDP */
352 ECORE_CON_REMOTE_UDP = 5,
353 /** Remote broadcast using UDP */
354 ECORE_CON_REMOTE_BROADCAST = 6,
355 ECORE_CON_REMOTE_NODELAY = 7,
356 /** Use SSL2: UNSUPPORTED. **/
357 ECORE_CON_USE_SSL2 = (1 << 4),
359 ECORE_CON_USE_SSL3 = (1 << 5),
361 ECORE_CON_USE_TLS = (1 << 6),
362 /** Use both TLS and SSL3 */
363 ECORE_CON_USE_MIXED = ECORE_CON_USE_SSL3 | ECORE_CON_USE_TLS,
364 /** Attempt to use the loaded certificate */
365 ECORE_CON_LOAD_CERT = (1 << 7)
368 EAPI int ecore_con_init(void);
369 EAPI int ecore_con_shutdown(void);
371 EAPI Eina_Bool ecore_con_lookup(const char *name,
372 Ecore_Con_Dns_Cb done_cb,
380 * @defgroup Ecore_Con_SSL_Group Ecore Connection SSL Functions
384 EAPI int ecore_con_ssl_available_get(void);
385 EAPI Eina_Bool ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr, const char *cert);
386 EAPI Eina_Bool ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr, const char *key_file);
387 EAPI Eina_Bool ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr, const char *crl_file);
388 EAPI Eina_Bool ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr, const char *ca_file);
389 EAPI void ecore_con_ssl_server_verify(Ecore_Con_Server *svr);
396 * @defgroup Ecore_Con_Server_Group Ecore Connection Server Functions
401 EAPI Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type,
402 const char *name, int port,
405 EAPI Ecore_Con_Server *ecore_con_server_connect(Ecore_Con_Type type,
406 const char *name, int port,
408 EAPI void * ecore_con_server_del(Ecore_Con_Server *svr);
409 EAPI void * ecore_con_server_data_get(Ecore_Con_Server *svr);
410 EAPI void * ecore_con_server_data_set(Ecore_Con_Server *svr,
412 EAPI Eina_Bool ecore_con_server_connected_get(Ecore_Con_Server *svr);
413 EAPI Eina_List * ecore_con_server_clients_get(Ecore_Con_Server *svr);
414 EAPI const char * ecore_con_server_name_get(Ecore_Con_Server *svr);
415 EAPI int ecore_con_server_port_get(Ecore_Con_Server *svr);
416 EAPI double ecore_con_server_uptime_get(Ecore_Con_Server *svr);
417 EAPI int ecore_con_server_send(Ecore_Con_Server *svr,
420 EAPI void ecore_con_server_client_limit_set(Ecore_Con_Server *svr,
422 char reject_excess_clients);
423 EAPI const char * ecore_con_server_ip_get(Ecore_Con_Server *svr);
424 EAPI void ecore_con_server_flush(Ecore_Con_Server *svr);
425 EAPI void ecore_con_server_timeout_set(Ecore_Con_Server *svr, double timeout);
426 EAPI double ecore_con_server_timeout_get(Ecore_Con_Server *svr);
433 * @defgroup Ecore_Con_Client_Group Ecore Connection Client Functions
438 EAPI int ecore_con_client_send(Ecore_Con_Client *cl,
441 EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl);
442 EAPI void * ecore_con_client_del(Ecore_Con_Client *cl);
443 EAPI void ecore_con_client_data_set(Ecore_Con_Client *cl,
445 EAPI void * ecore_con_client_data_get(Ecore_Con_Client *cl);
446 EAPI const char * ecore_con_client_ip_get(Ecore_Con_Client *cl);
447 EAPI void ecore_con_client_flush(Ecore_Con_Client *cl);
448 EAPI double ecore_con_client_uptime_get(Ecore_Con_Client *cl);
449 EAPI double ecore_con_client_timeout_get(Ecore_Con_Client *cl);
450 EAPI void ecore_con_client_timeout_set(Ecore_Con_Client *cl, double timeout);
457 * @defgroup Ecore_Con_Url_Group Ecore URL Connection Functions
463 * @typedef Ecore_Con_Url_Time
464 * @enum _Ecore_Con_Url_Time
465 * The type of condition to use when making an HTTP request dependent on time,
466 * so that headers such as "If-Modified-Since" are used.
468 typedef enum _Ecore_Con_Url_Time
471 * Do not place time restrictions on the HTTP requests.
473 ECORE_CON_URL_TIME_NONE = 0,
475 * Add the "If-Modified-Since" HTTP header, so that the request is performed
476 * by the server only if the target has been modified since the time value
477 * passed to it in the request.
479 ECORE_CON_URL_TIME_IFMODSINCE,
481 * Add the "If-Unmodified-Since" HTTP header, so that the request is
482 * performed by the server only if the target has NOT been modified since
483 * the time value passed to it in the request.
485 ECORE_CON_URL_TIME_IFUNMODSINCE
486 } Ecore_Con_Url_Time;
488 EAPI int ecore_con_url_init(void);
489 EAPI int ecore_con_url_shutdown(void);
490 EAPI Ecore_Con_Url * ecore_con_url_new(const char *url);
491 EAPI Ecore_Con_Url * ecore_con_url_custom_new(const char *url,
492 const char *custom_request);
493 EAPI void ecore_con_url_free(Ecore_Con_Url *url_con);
494 EAPI Eina_Bool ecore_con_url_url_set(Ecore_Con_Url *url_con,
496 EAPI void ecore_con_url_data_set(Ecore_Con_Url *url_con,
498 EAPI void * ecore_con_url_data_get(Ecore_Con_Url *url_con);
499 EAPI void ecore_con_url_additional_header_add(Ecore_Con_Url *url_con,
502 EAPI void ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con);
503 EAPI const Eina_List * ecore_con_url_response_headers_get(Ecore_Con_Url *url_con);
504 EAPI void ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd);
505 EAPI int ecore_con_url_received_bytes_get(Ecore_Con_Url *url_con);
506 EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con,
507 const char *username,
508 const char *password,
510 EAPI Eina_Bool ecore_con_url_send(Ecore_Con_Url *url_con,
511 const void *data, long length,
512 const char *content_type);
513 EAPI void ecore_con_url_time(Ecore_Con_Url *url_con,
514 Ecore_Con_Url_Time time_condition,
517 EAPI Eina_Bool ecore_con_url_ftp_upload(Ecore_Con_Url *url_con,
518 const char *filename,
521 const char *upload_dir);
522 EAPI void ecore_con_url_verbose_set(Ecore_Con_Url *url_con,
524 EAPI void ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con,