aboutsummaryrefslogtreecommitdiffstats
path: root/protocol/response.h
blob: 753240464e0c1e94125c02cd0786fd8da9fa3430 (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
/*
 * OProfile User Interface
 *
 * Copyright (C) 2007 Nokia Corporation. All rights reserved.
 *
 * Author: Robert Bradford <rob@openedhand.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program 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
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */


#ifndef __RESPONSE_H__
#define __RESPONSE_H__

#include <stdint.h>

enum
{
  RESPONSE_OP_OK,
  RESPONSE_OP_ERROR,
  RESPONSE_OP_FILE,
  RESPONSE_OP_ARCHIVE,
  RESPONSE_OP_FILESTAT,
  RESPONSE_OP_STATUS = 69, /* for compatability */
};

typedef struct
{
  char opcode;
  uint8_t reserved[3];
  uint32_t length;
  char payload[];
} OpuiResponse;

typedef struct
{
  uint32_t mtime_h; /* higher 32bit of mtime */
  uint32_t mtime_l; /* lower 32bit of mtime */
  uint32_t size_h;  /* higher 32bit of size */
  uint32_t size_l;  /* lower 32bit of size */
  uint32_t mode_h;  /* higher 32bit of mode */
  uint32_t mode_l;  /* lower 32bit of mode */
} OpuiResponseFileStat;

typedef struct
{
  uint32_t proto_version;
  uint32_t profiling;
  uint32_t configured;
} OpuiResponseStatus;

#define SIZE_OF_RESPONSE(x) sizeof(OpuiResponse) + x->length

#define RESP_FILESTAT_GET_MTIME(x) (((uint64_t)((x)->mtime_h) << 32) + x->mtime_l)
#define RESP_FILESTAT_GET_SIZE(x) (((uint64_t)((x)->size_h) << 32) + x->size_l)
#define RESP_FILESTAT_GET_MODE(x) (((uint64_t)((x)->mode_h) << 32) + x->mode_l)

#define RESP_FILESTAT_PUT_MTIME(x,v) ((x)->mtime_h = (uint32_t)((uint64_t)(v) >> 32), \
				      (x)->mtime_l = (uint32_t)(v) )
#define RESP_FILESTAT_PUT_SIZE(x,v) ((x)->size_h = (uint32_t)((uint64_t)(v) >> 32), \
				      (x)->size_l = (uint64_t)(v) )
#define RESP_FILESTAT_PUT_MODE(x,v) ((x)->mode_h = (uint32_t)((uint64_t)(v) >> 32), \
				      (x)->mode_l = (uint64_t)(v) )

#endif /* __RESPONSE_H__ */