Rizin
unix-like reverse engineering framework and cli tools
main.c File Reference
#include <stdio.h>
#include <uv.h>

Go to the source code of this file.

Functions

void crunch_away (uv_idle_t *handle)
 
void on_type (uv_fs_t *req)
 
int main ()
 

Variables

uv_loop_tloop
 
uv_fs_t stdin_watcher
 
uv_idle_t idler
 
char buffer [1024]
 

Function Documentation

◆ crunch_away()

void crunch_away ( uv_idle_t handle)

Definition at line 10 of file main.c.

10  {
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 }
static mcore_handle handle
Definition: asm_mcore.c:8
UV_EXTERN int uv_idle_stop(uv_idle_t *idle)

References handle, and uv_idle_stop().

Referenced by main(), and on_type().

◆ main()

int main ( void  )

Definition at line 34 of file main.c.

34  {
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 }
voidpf void * buf
Definition: ioapi.h:138
Definition: buffer.h:15
Definition: unix.h:123
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 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 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)

References crunch_away(), idler, loop, on_type(), stdin_watcher, uv_buf_init(), uv_default_loop(), uv_fs_read(), uv_idle_init(), uv_idle_start(), uv_run(), and UV_RUN_DEFAULT.

◆ on_type()

void on_type ( uv_fs_t req)

Definition at line 20 of file main.c.

20  {
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 }
_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
ssize_t result
Definition: uv.h:1311
UV_EXTERN const char * uv_strerror(int err)
Definition: uv-common.c:212

References crunch_away(), idler, loop, printf(), req, uv_fs_s::result, stdin_watcher, uv_buf_init(), uv_fs_read(), uv_idle_start(), and uv_strerror().

Referenced by main().

Variable Documentation

◆ buffer

char buffer[1024]

Definition at line 8 of file main.c.

Referenced by make_discover_msg().

◆ idler

uv_idle_t idler

Definition at line 7 of file main.c.

Referenced by main(), and on_type().

◆ loop

uv_loop_t* loop

Definition at line 5 of file main.c.

◆ stdin_watcher

uv_fs_t stdin_watcher

Definition at line 6 of file main.c.

Referenced by main(), and on_type().