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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
/* EFL Stuff */
#include <Ecore.h>
#include <Ecore_Config.h> /* Configuration lib */
/*#include <Ecore_Con.h> */ /* Socket lib */
/* Espik Stuff */
#include "espik.h"
#include "espik_global.h"
#include "espik_config.h"
#include "espik_irc.h"
#include "espik_common_handler.h"
#include "espik_net.h"
#include "espik_debug.h"
typedef int (*Handler_Func) (void *data, int ev_type, void *ev);
/* typedef int (*Handler_Fd_Func) (void *data, Ecore_Fd_Handler * fd_handler); */
/* Use to replace EOL ('\n') with NULL ('\0') */
int del_backslash (char *msg)
{
int i, count;
espik_enter();
for (i = 0, count = 0; msg[i]; i++)
{
if (msg[i] == '\n')
{
msg[i] = '\0';
count++;
}
}
espik_leave();
return (count);
}
int main (int argc, char **argv)
{
Ecore_Fd_Handler *fd_kb;
__indent_level = 0;
espik_enter();
printf ("Welcome to %s %s\n", APPS_NAME, ESPIK_VERSION);
#ifdef _ESPIK_DEBUG_
espik_debug_init();
#endif
espik_config_init ();
if (argc < 3)
{
printf ("Loading from conf ...\n");
espik_config_get (&a_infos);
}
else
{
printf ("Connecting to %s:%s\n", argv[1], argv[2]);
a_infos.client = espik_user_sysinfo_get ();
a_infos.server = espik_server_config_set (argv[1], (unsigned short)atoi (argv[2]));
}
espik_config_set (a_infos);
printf ("host: %s\n", a_infos.server->host);
printf ("port: %hd\n", a_infos.server->port);
printf ("nick: %s\n", a_infos.client->nickname);
printf ("user: %s\n", a_infos.client->username);
printf ("real: %s\n", a_infos.client->realname);
if (!ecore_init ())
{
printf ("Cannot init ecore; %d\n", 1);
exit (-1);
}
/*
* con_sock =
* ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM, a_infos.server->host,
* (int)a_infos.server->port, NULL);
* if (!con_sock)
* {
* fprintf (stderr, "Baaa\n");
* exit (-1);
* }
*/
/* Handler Network & Keyboard */
fd_kb = ecore_main_fd_handler_add (STDIN_FILENO, ECORE_FD_READ, kb_get, NULL, NULL, NULL);
if (!fd_kb)
{
printf ("Cannot ecore_main_fd_handler_add\n");
exit (-1);
}
/* ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA, (Handler_Func) server_data, NULL); */
espik_con_init (a_infos);
/* Init IRC connection */
ecore_main_loop_begin ();
/* ecore_con_server_del (con_sock); */
free (a_infos.server->host);
free (a_infos.server);
/*
free (a_infos.client->nickname);
free (a_infos.client->username);
free (a_infos.client->realname);
*/
free (a_infos.client);
/* ecore_main_loop_quit (); */
espik_debug_print ("end");
ecore_config_shutdown ();
/* ecore_con_shutdown (); */
ecore_shutdown ();
espik_leave();
return (0);
}
|