Rizin
unix-like reverse engineering framework and cli tools
main.c
Go to the documentation of this file.
1 #include <stdio.h>
2 
3 #include <uv.h>
4 
8 char buffer[1024];
9 
11  // Compute extra-terrestrial life
12  // fold proteins
13  // computer another digit of PI
14  // or similar
15  fprintf(stderr, "Computing PI...\n");
16  // just to avoid overwhelming your terminal emulator
18 }
19 
21  if (stdin_watcher.result > 0) {
22  buffer[stdin_watcher.result] = '\0';
23  printf("Typed %s\n", buffer);
24 
25  uv_buf_t buf = uv_buf_init(buffer, 1024);
26  uv_fs_read(loop, &stdin_watcher, 0, &buf, 1, -1, on_type);
28  }
29  else if (stdin_watcher.result < 0) {
30  fprintf(stderr, "error opening file: %s\n", uv_strerror(req->result));
31  }
32 }
33 
34 int main() {
36 
38 
39  uv_buf_t buf = uv_buf_init(buffer, 1024);
40  uv_fs_read(loop, &stdin_watcher, 0, &buf, 1, -1, on_type);
42  return uv_run(loop, UV_RUN_DEFAULT);
43 }
static mcore_handle handle
Definition: asm_mcore.c:8
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
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 static whence static length const void static len static semflg const void static shmflg const struct timespec req
Definition: sflib.h:128
voidpf void * buf
Definition: ioapi.h:138
int main(int argc, const char **argv)
Definition: main.c:340
Definition: buffer.h:15
Definition: unix.h:123
Definition: uv.h:1306
ssize_t result
Definition: uv.h:1311
Definition: uv.h:834
Definition: uv.h:1780
uv_loop_t * loop
Definition: main.c:7
void crunch_away(uv_idle_t *handle)
Definition: main.c:10
uv_fs_t stdin_watcher
Definition: main.c:6
void on_type(uv_fs_t *req)
Definition: main.c:20
uv_idle_t idler
Definition: main.c:7
@ UV_RUN_DEFAULT
Definition: uv.h:255
UV_EXTERN int uv_fs_read(uv_loop_t *loop, uv_fs_t *req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
Definition: fs.c:1872
UV_EXTERN int uv_idle_stop(uv_idle_t *idle)
UV_EXTERN uv_buf_t uv_buf_init(char *base, unsigned int len)
Definition: uv-common.c:157
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition: core.c:365
UV_EXTERN const char * uv_strerror(int err)
Definition: uv-common.c:212
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:763
UV_EXTERN int uv_idle_start(uv_idle_t *idle, uv_idle_cb cb)
UV_EXTERN int uv_idle_init(uv_loop_t *, uv_idle_t *idle)