summaryrefslogtreecommitdiff
path: root/src/bin/efl/efl_debug_shell_bridge.c
blob: c2f60220f874cecc7bfa43972ef591ec4fb5f64b (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
74
75
76
77
78
79
80
81
82
/* EINA - EFL data type library
 * Copyright (C) 2015 Carsten Haitzler
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library;
 * if not, see <http://www.gnu.org/licenses/>.
 */

#include <Eo.h>
#include <Eina.h>
#include <Ecore.h>

#include <unistd.h>

#if 0
static Eina_Debug_Session *_shell_session = NULL, *_local_session = NULL;

static Eina_Bool
_shell_to_local_forward(Eina_Debug_Session *session EINA_UNUSED, void *buffer)
{
   char *data_buf = ((char *)buffer) + sizeof(Eina_Debug_Packet_Header);
   Eina_Debug_Packet_Header *hdr = buffer;
   int size = hdr->size + sizeof(int) - sizeof(Eina_Debug_Packet_Header);
   eina_debug_session_send(_local_session, hdr->cid, hdr->opcode, data_buf, size);
   free(buffer);
   return EINA_TRUE;
}

static Eina_Bool
_local_to_shell_forward(Eina_Debug_Session *session EINA_UNUSED, void *buffer)
{
   char *data_buf = ((char *)buffer) + sizeof(Eina_Debug_Packet_Header);
   Eina_Debug_Packet_Header *hdr = buffer;
   int size = hdr->size + sizeof(int) - sizeof(Eina_Debug_Packet_Header);
   eina_debug_session_send(_shell_session, hdr->cid, hdr->opcode, data_buf, size);
   free(buffer);
   return EINA_TRUE;
}
#endif

int
main(int argc, char **argv)
{
   (void)argc;
   (void)argv;

#if 0
   fprintf(stdout, "OK\n");
   fflush(stdout);
   sleep(1);

   eina_debug_default_connection_disable();
   eina_init();
   ecore_init();

   _local_session = eina_debug_session_new();
   eina_debug_session_dispatch_override(_local_session, _local_to_shell_forward);
   eina_debug_local_connect(_local_session, EINA_DEBUG_SESSION_MASTER);

   _shell_session = eina_debug_session_new();
   eina_debug_session_basic_codec_add(_shell_session, EINA_DEBUG_CODEC_SHELL);
   eina_debug_session_dispatch_override(_shell_session, _shell_to_local_forward);
   eina_debug_session_fd_attach(_shell_session, STDIN_FILENO);
   eina_debug_session_fd_out_set(_shell_session, STDOUT_FILENO);
   eina_debug_session_magic_set_on_send(_shell_session);

   ecore_main_loop_begin();

   ecore_shutdown();
   eina_shutdown();
#endif
}