Rizin
unix-like reverse engineering framework and cli tools
sdb_private.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: MIT
3 
4 #ifndef SDB_PRIVATE_H_
5 #define SDB_PRIVATE_H_
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 #ifndef HAVE_HEADER_SYS_MMAN_H
12 #define HAVE_HEADER_SYS_MMAN_H HAVE_MMAN
13 #endif
14 
15 #define SDB_V_NOT(op, fail_ret) \
16  if ((op) == (fail_ret)) \
17  eprintf(#op " at %s:%d failed: %s\n", __FILE__, __LINE__, strerror(errno))
18 #define write_(fd, buf, count) SDB_V_NOT(write(fd, buf, count), -1)
19 #define read_(fd, buf, count) SDB_V_NOT(read(fd, buf, count), -1)
20 
21 static inline int seek_set(int fd, off_t pos) {
22  return ((fd == -1) || (lseek(fd, (off_t)pos, SEEK_SET) == -1)) ? 0 : 1;
23 }
24 
25 static inline void ut32_pack(char s[4], ut32 u) {
26  s[0] = u & 255;
27  u >>= 8;
28  s[1] = u & 255;
29  u >>= 8;
30  s[2] = u & 255;
31  s[3] = u >> 8;
32 }
33 
34 static inline void ut32_pack_big(char s[4], ut32 u) {
35  s[3] = u & 255;
36  u >>= 8;
37  s[2] = u & 255;
38  u >>= 8;
39  s[1] = u & 255;
40  s[0] = u >> 8;
41 }
42 
43 static inline void ut32_unpack(char s[4], ut32 *u) {
44  ut32 result = 0;
45  result = (ut8)s[3];
46  result <<= 8;
47  result += (ut8)s[2];
48  result <<= 8;
49  result += (ut8)s[1];
50  result <<= 8;
51  result += (ut8)s[0];
52  *u = result;
53 }
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep lseek
Definition: sflib.h:113
#define ut8
Definition: dcpu16.h:8
uint32_t ut32
static RzSocket * s
Definition: rtr.c:28
static void ut32_pack(char s[4], ut32 u)
Definition: sdb_private.h:25
static int seek_set(int fd, off_t pos)
Definition: sdb_private.h:21
static void ut32_unpack(char s[4], ut32 *u)
Definition: sdb_private.h:43
static void ut32_pack_big(char s[4], ut32 u)
Definition: sdb_private.h:34
int off_t
Definition: sftypes.h:41
int pos
Definition: main.c:11
static const z80_opcode fd[]
Definition: z80_tab.h:997
#define SEEK_SET
Definition: zip.c:88