summaryrefslogtreecommitdiff
path: root/src/bin/efl/efl_debug_common.h
blob: dc6190e65300b15ad8048dfa3aa9df2889819ced (plain) (blame)
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
/* 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/>.
 */

#ifndef EFL_DEBUG_COMMON_H
#define EFL_DEBUG_COMMON_H 1

#include <Eina.h>
#include <Ecore.h>
#include <Ecore_Con.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

void _protocol_collect(unsigned char **buf, unsigned int *buf_size,
                       void *data, int size);
int _proto_read(unsigned char **buf, unsigned int *buf_size,
                char *op, unsigned char **data);

#define fetch_val(dst, buf, off) \
   memcpy(&dst, ((unsigned char *)buf) + off, sizeof(dst))
#define store_val(buf, off, src) \
   memcpy(buf + off, &src, sizeof(src))
#define send_svr(svr, op, data, size) \
   do { \
      unsigned char head[8]; \
      char *op2 = op; \
      int size2 = size + 4; \
      memcpy(head + 0, &size2, 4); \
      memcpy(head + 4, op2, 4); \
      ecore_con_server_send(svr, head, 8); \
      if (size > 0) ecore_con_server_send(svr, data, size); \
   } while (0)
#define send_cli(cli, op, data, size) \
   do { \
      unsigned char head[8]; \
      char *op2 = op; \
      int size2 = size + 4; \
      memcpy(head + 0, &size2, 4); \
      memcpy(head + 4, op2, 4); \
      ecore_con_client_send(cli, head, 8); \
      if (size > 0) ecore_con_client_send(cli, data, size); \
   } while (0)

#endif