2006-09-24 00:24:52 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2003-09-23 01:09:32 -07:00
|
|
|
#ifndef _ECORE_CON_H
|
|
|
|
#define _ECORE_CON_H
|
|
|
|
|
2009-01-31 10:33:39 -08:00
|
|
|
#include <time.h>
|
|
|
|
#include <libgen.h>
|
2010-02-24 09:52:54 -08:00
|
|
|
#ifdef _WIN32
|
|
|
|
# include <ws2tcpip.h>
|
|
|
|
#else
|
2009-01-31 10:33:39 -08:00
|
|
|
# include <netdb.h>
|
|
|
|
#endif
|
2010-01-15 13:47:27 -08:00
|
|
|
#include <Eina.h>
|
2009-01-31 10:33:39 -08:00
|
|
|
|
2004-11-24 21:18:31 -08:00
|
|
|
#ifdef EAPI
|
2009-01-31 10:33:39 -08:00
|
|
|
# undef EAPI
|
2004-11-24 21:18:31 -08:00
|
|
|
#endif
|
2009-01-31 10:33:39 -08:00
|
|
|
|
2007-03-15 15:21:28 -07:00
|
|
|
#ifdef _MSC_VER
|
2004-11-24 21:18:31 -08:00
|
|
|
# ifdef BUILDING_DLL
|
|
|
|
# define EAPI __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define EAPI __declspec(dllimport)
|
|
|
|
# endif
|
|
|
|
#else
|
2005-12-27 09:17:31 -08:00
|
|
|
# ifdef __GNUC__
|
|
|
|
# if __GNUC__ >= 4
|
|
|
|
# define EAPI __attribute__ ((visibility("default")))
|
|
|
|
# else
|
|
|
|
# define EAPI
|
|
|
|
# endif
|
2004-11-24 21:18:31 -08:00
|
|
|
# else
|
|
|
|
# define EAPI
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2004-04-29 20:10:17 -07:00
|
|
|
/**
|
|
|
|
* @file Ecore_Con.h
|
|
|
|
* @brief Sockets functions.
|
2004-09-22 21:58:16 -07:00
|
|
|
*
|
|
|
|
* 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 descripters 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.
|
|
|
|
*
|
2008-10-09 05:30:19 -07:00
|
|
|
* 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
|
2007-11-30 00:10:37 -08:00
|
|
|
* client itself.
|
2004-09-22 21:58:16 -07:00
|
|
|
*
|
|
|
|
* To create a listening server, call @c ecore_con_server_add().
|
|
|
|
*
|
2005-02-17 09:15:22 -08:00
|
|
|
* To connect to a server, call @c ecore_con_server_connect(). Data can
|
2004-09-22 21:58:16 -07:00
|
|
|
* then be sent to the server using the @c ecore_con_server_send().
|
2008-10-09 05:30:19 -07:00
|
|
|
*
|
2004-09-22 21:58:16 -07:00
|
|
|
* Whenever a client connection is made to an @c Ecore_Con_Server, a
|
|
|
|
* @c ECORE_CON_CLIENT_ADD event is emitted. Any event callbacks that are
|
|
|
|
* called receive a @c Ecore_Con_Client object, which represents a
|
|
|
|
* connection that that particular client.
|
|
|
|
*
|
|
|
|
* 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
|
2008-02-11 15:24:11 -08:00
|
|
|
* @li @ref Ecore_Con_Url_Group
|
2004-04-29 20:10:17 -07:00
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2008-10-09 05:30:19 -07:00
|
|
|
|
|
|
|
typedef struct _Ecore_Con_Server Ecore_Con_Server; /**< A connection handle */
|
|
|
|
typedef struct _Ecore_Con_Client Ecore_Con_Client; /**< A connection handle */
|
|
|
|
typedef struct _Ecore_Con_Url Ecore_Con_Url;
|
|
|
|
|
2010-07-22 04:32:55 -07:00
|
|
|
typedef void (*Ecore_Con_Dns_Cb)(const char *canonname,
|
|
|
|
const char *ip,
|
|
|
|
struct sockaddr *addr,
|
|
|
|
int addrlen,
|
|
|
|
void *data);
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
typedef enum _Ecore_Con_Type
|
|
|
|
{
|
2010-05-15 20:04:18 -07:00
|
|
|
ECORE_CON_LOCAL_USER = 0,
|
|
|
|
ECORE_CON_LOCAL_SYSTEM = 1,
|
|
|
|
ECORE_CON_LOCAL_ABSTRACT = 2,
|
|
|
|
ECORE_CON_REMOTE_TCP = 3,
|
|
|
|
ECORE_CON_REMOTE_MCAST = 4,
|
|
|
|
ECORE_CON_REMOTE_UDP = 5,
|
|
|
|
ECORE_CON_REMOTE_BROADCAST = 6,
|
|
|
|
ECORE_CON_REMOTE_NODELAY = 7,
|
2010-07-22 04:32:55 -07:00
|
|
|
|
2008-01-08 13:06:43 -08:00
|
|
|
ECORE_CON_USE_SSL2 = (1 << 4),
|
2008-01-08 13:28:51 -08:00
|
|
|
ECORE_CON_USE_SSL3 = (1 << 5),
|
|
|
|
ECORE_CON_USE_TLS = (1 << 6)
|
2003-09-23 01:09:32 -07:00
|
|
|
} Ecore_Con_Type;
|
2008-01-08 13:06:43 -08:00
|
|
|
#define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2
|
2008-09-25 04:37:01 -07:00
|
|
|
#define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP
|
2007-09-26 09:01:04 -07:00
|
|
|
|
|
|
|
typedef enum _Ecore_Con_Url_Time
|
|
|
|
{
|
2007-09-26 09:34:14 -07:00
|
|
|
ECORE_CON_URL_TIME_NONE = 0,
|
|
|
|
ECORE_CON_URL_TIME_IFMODSINCE,
|
|
|
|
ECORE_CON_URL_TIME_IFUNMODSINCE,
|
|
|
|
ECORE_CON_URL_TIME_LASTMOD
|
2007-09-26 09:01:04 -07:00
|
|
|
} Ecore_Con_Url_Time;
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Client_Add Ecore_Con_Event_Client_Add;
|
|
|
|
typedef struct _Ecore_Con_Event_Client_Del Ecore_Con_Event_Client_Del;
|
|
|
|
typedef struct _Ecore_Con_Event_Server_Add Ecore_Con_Event_Server_Add;
|
|
|
|
typedef struct _Ecore_Con_Event_Server_Del Ecore_Con_Event_Server_Del;
|
|
|
|
typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data;
|
|
|
|
typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
|
2005-06-24 06:38:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Url_Data Ecore_Con_Event_Url_Data;
|
|
|
|
typedef struct _Ecore_Con_Event_Url_Complete Ecore_Con_Event_Url_Complete;
|
2007-09-26 09:01:04 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Url_Progress Ecore_Con_Event_Url_Progress;
|
2003-09-23 01:09:32 -07:00
|
|
|
|
|
|
|
struct _Ecore_Con_Event_Client_Add
|
|
|
|
{
|
|
|
|
Ecore_Con_Client *client;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ecore_Con_Event_Client_Del
|
|
|
|
{
|
|
|
|
Ecore_Con_Client *client;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ecore_Con_Event_Server_Add
|
|
|
|
{
|
|
|
|
Ecore_Con_Server *server;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ecore_Con_Event_Server_Del
|
|
|
|
{
|
|
|
|
Ecore_Con_Server *server;
|
|
|
|
};
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
struct _Ecore_Con_Event_Client_Data
|
|
|
|
{
|
|
|
|
Ecore_Con_Client *client;
|
|
|
|
void *data;
|
|
|
|
int size;
|
|
|
|
};
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
struct _Ecore_Con_Event_Server_Data
|
|
|
|
{
|
|
|
|
Ecore_Con_Server *server;
|
|
|
|
void *data;
|
|
|
|
int size;
|
|
|
|
};
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2005-06-24 06:38:27 -07:00
|
|
|
struct _Ecore_Con_Event_Url_Data
|
|
|
|
{
|
|
|
|
Ecore_Con_Url *url_con;
|
|
|
|
int size;
|
2007-09-26 09:34:14 -07:00
|
|
|
unsigned char data[1];
|
2005-06-24 06:38:27 -07:00
|
|
|
};
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2005-06-24 06:38:27 -07:00
|
|
|
struct _Ecore_Con_Event_Url_Complete
|
|
|
|
{
|
|
|
|
Ecore_Con_Url *url_con;
|
|
|
|
int status;
|
|
|
|
};
|
2007-09-26 09:01:04 -07:00
|
|
|
|
|
|
|
struct _Ecore_Con_Event_Url_Progress
|
|
|
|
{
|
2007-09-26 09:34:14 -07:00
|
|
|
Ecore_Con_Url *url_con;
|
2008-03-09 09:43:32 -07:00
|
|
|
struct {
|
|
|
|
double total;
|
|
|
|
double now;
|
|
|
|
} down;
|
|
|
|
struct {
|
|
|
|
double total;
|
|
|
|
double now;
|
|
|
|
} up;
|
2007-09-26 09:01:04 -07:00
|
|
|
};
|
|
|
|
|
2005-12-27 09:17:31 -08:00
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_ADD;
|
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_DEL;
|
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_ADD;
|
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_DEL;
|
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
|
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_DATA;
|
|
|
|
EAPI extern int ECORE_CON_EVENT_URL_DATA;
|
|
|
|
EAPI extern int ECORE_CON_EVENT_URL_COMPLETE;
|
2008-03-09 09:43:32 -07:00
|
|
|
EAPI extern int ECORE_CON_EVENT_URL_PROGRESS;
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2004-11-24 21:18:31 -08:00
|
|
|
EAPI int ecore_con_init(void);
|
|
|
|
EAPI int ecore_con_shutdown(void);
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2005-03-04 11:29:39 -08:00
|
|
|
EAPI Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type, const char *name, int port, const void *data);
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2005-03-04 11:29:39 -08:00
|
|
|
EAPI Ecore_Con_Server *ecore_con_server_connect(Ecore_Con_Type type, const char *name, int port, const void *data);
|
2004-11-24 21:18:31 -08:00
|
|
|
EAPI void *ecore_con_server_del(Ecore_Con_Server *svr);
|
|
|
|
EAPI void *ecore_con_server_data_get(Ecore_Con_Server *svr);
|
|
|
|
EAPI int ecore_con_server_connected_get(Ecore_Con_Server *svr);
|
2008-12-11 05:55:47 -08:00
|
|
|
EAPI Eina_List *ecore_con_server_clients_get(Ecore_Con_Server *svr);
|
2006-11-05 08:49:55 -08:00
|
|
|
EAPI int ecore_con_server_send(Ecore_Con_Server *svr, const void *data, int size);
|
2005-04-28 21:51:31 -07:00
|
|
|
EAPI void ecore_con_server_client_limit_set(Ecore_Con_Server *svr, int client_limit, char reject_excess_clients);
|
2006-03-19 23:45:58 -08:00
|
|
|
EAPI char *ecore_con_server_ip_get(Ecore_Con_Server *svr);
|
2007-02-16 10:12:38 -08:00
|
|
|
EAPI void ecore_con_server_flush(Ecore_Con_Server *svr);
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2007-10-21 08:16:14 -07:00
|
|
|
EAPI int ecore_con_client_send(Ecore_Con_Client *cl, const void *data, int size);
|
2004-11-24 21:18:31 -08:00
|
|
|
EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl);
|
|
|
|
EAPI void *ecore_con_client_del(Ecore_Con_Client *cl);
|
|
|
|
EAPI void ecore_con_client_data_set(Ecore_Con_Client *cl, const void *data);
|
|
|
|
EAPI void *ecore_con_client_data_get(Ecore_Con_Client *cl);
|
2006-03-19 23:45:58 -08:00
|
|
|
EAPI char *ecore_con_client_ip_get(Ecore_Con_Client *cl);
|
2007-02-16 10:12:38 -08:00
|
|
|
EAPI void ecore_con_client_flush(Ecore_Con_Client *cl);
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2004-11-24 21:18:31 -08:00
|
|
|
EAPI int ecore_con_ssl_available_get(void);
|
2004-10-21 20:41:49 -07:00
|
|
|
|
2005-06-24 06:38:27 -07:00
|
|
|
EAPI int ecore_con_url_init(void);
|
|
|
|
EAPI int ecore_con_url_shutdown(void);
|
|
|
|
EAPI Ecore_Con_Url *ecore_con_url_new(const char *url);
|
2009-08-12 02:47:04 -07:00
|
|
|
EAPI Ecore_Con_Url *ecore_con_url_custom_new(const char *url, const char *custom_request);
|
2005-06-24 06:38:27 -07:00
|
|
|
EAPI void ecore_con_url_destroy(Ecore_Con_Url *url_con);
|
2007-09-26 10:18:52 -07:00
|
|
|
EAPI void ecore_con_url_data_set(Ecore_Con_Url *url_con, void *data);
|
2007-09-26 09:01:04 -07:00
|
|
|
EAPI void *ecore_con_url_data_get(Ecore_Con_Url *url_con);
|
2009-08-12 02:47:04 -07:00
|
|
|
EAPI void ecore_con_url_additional_header_add(Ecore_Con_Url *url_con, const char *key, const char *value);
|
|
|
|
EAPI void ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con);
|
2009-08-27 14:21:43 -07:00
|
|
|
EAPI const Eina_List *ecore_con_url_response_headers_get(Ecore_Con_Url *url_con);
|
2005-06-24 06:38:27 -07:00
|
|
|
EAPI int ecore_con_url_url_set(Ecore_Con_Url *url_con, const char *url);
|
2008-03-09 09:43:32 -07:00
|
|
|
EAPI void ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd);
|
|
|
|
EAPI int ecore_con_url_received_bytes_get(Ecore_Con_Url *url_con);
|
2010-05-09 08:06:06 -07:00
|
|
|
EAPI int ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, const char *password, Eina_Bool safe);
|
2009-03-16 06:46:16 -07:00
|
|
|
EAPI int ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, const char *content_type);
|
2007-09-26 09:01:04 -07:00
|
|
|
EAPI void ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time condition, time_t tm);
|
2005-06-24 06:38:27 -07:00
|
|
|
|
2010-07-22 04:32:55 -07:00
|
|
|
EAPI Eina_Bool ecore_con_lookup(const char *name, Ecore_Con_Dns_Cb done_cb, const void *data);
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2009-03-16 06:46:16 -07:00
|
|
|
EAPI int ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, const char *user, const char *pass, const char *upload_dir);
|
2008-07-07 21:08:52 -07:00
|
|
|
EAPI void ecore_con_url_verbose_set(Ecore_Con_Url *url_con, int verbose);
|
|
|
|
EAPI void ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, int use_epsv);
|
2010-05-06 13:18:39 -07:00
|
|
|
EAPI int ecore_con_url_http_post_send(Ecore_Con_Url *url_con, void *curl_httppost);
|
2005-08-16 02:25:02 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|