aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries/SledjHamr.h
blob: 061f0812277f5b259d01ff5ed09831298c9a5e1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef _SLEDJHAMR_H_
#define _SLEDJHAMR_H_


#include <stdlib.h>

#include <Ecore.h>
#include <Ecore_Con.h>


typedef struct _Connection	Connection;

typedef boolean (* streamParser)(void *data, Connection *connection, char *SID, char *command, char *arguments);

typedef enum
{
  CT_CLIENT,
  CT_SERVER
} connType;

struct _ConnServer
{
  Ecore_Con_Server *server;
  char *serverCommand;
  int count, hackyCount;
  // A list of connected remote clients.
  //   A NULL list means this is a remote server stored in a local clients Connection.
  //   An empty list means this is a local server, with no clients.
  //   An actual list means this is a local server, with connected remote clients.
  Eina_Clist	*clients;	// HEAD element.
  Ecore_Exe	*serverHandle;	// For running the server.
  pid_t		pid;
};

struct _ConnClient
{
  Ecore_Con_Client *client;
  // If this is a local  client, then myServer is a server Connection representing the remote server, and the server list entry element can be NULL.
  // If this is a remote client, then myServer is NULL, and this Connection is stored in a list in the local server's Connection.
  Connection *myServer;
  Eina_Clist	*server;	// Entry element.
};

struct _Connection
{
  connType type;
  union
  {
    struct _ConnServer		server;
    struct _ConnClient		client;
  } conn;
  char		*name; // For log entries and such.
  char		*address;
  int		port;
  Eina_Strbuf	*stream;
  Eina_Hash	*commands;
//		    streamParser *func;
  //  Callbacks.
  void *pointer;
  Ecore_Event_Handler_Cb _add, _data, _del;
  Ecore_Event_Handler *add, *data, *del, *died;
  streamParser unknownInCommand, unknownOutCommand;

  int		stage;	// Stage of creation for the Connection.
};


void *addMessage(Eina_Clist *list, size_t size, const char *message, ...);
void send2(Connection *conn, const char *SID, const char *message, ...);
Connection *openArms(char *name, const char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del, streamParser _inParser, streamParser _outParser);
Connection *reachOut(char *name, char *command, char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del, streamParser _inParser, streamParser _outParser);

#endif