aboutsummaryrefslogtreecommitdiff
path: root/client/libacron/include/ids.h
blob: 34d312ec7c1f1c3e9ba4e325fca416336b8f0e6b (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
/*
 * Created by yuuta on 7/19/22.
 */

#ifndef LIBAC_IDS_H
#define LIBAC_IDS_H

#include "incl.h"

#define AC_TYPE_EVENT       0   /* 0b00000000 */
#define AC_TYPE_REQUEST     64  /* 0b01000000 */
#define AC_TYPE_RESPONSE    128 /* 0b10000000 */

#define AC_ID(type, num) type + num

#define AC_IS_EVENT(type) (type & 192) == AC_TYPE_EVENT
#define AC_IS_REQUEST(type) (type & 192) == AC_TYPE_REQUEST
#define AC_IS_RESPONSE(type) (type & 192) == AC_TYPE_RESPONSE

#include <stdint.h>

typedef struct ac_obj {
    uint8_t type;
} ac_obj_t;

/**
 * Free the object.
 * @param obj Object to free. Must be a valid object.
 * @return AC_E_OK or an error code. When succeeds, obj is freed and no longer valid.
 */
LIBAC_EXPORT int ac_object_free(ac_obj_t *obj);

#endif /* LIBAC_IDS_H */