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

Go to the source code of this file.

Functions

void fake_download (uv_work_t *req)
 
void after (uv_work_t *req, int status)
 
void print_progress (uv_async_t *handle)
 
int main ()
 

Variables

uv_loop_tloop
 
uv_async_t async
 
double percentage
 

Function Documentation

◆ after()

void after ( uv_work_t req,
int  status 
)

Definition at line 26 of file main.c.

26  {
27  fprintf(stderr, "Download complete\n");
29 }
#define NULL
Definition: cris-opc.c:27
uv_async_t async
Definition: main.c:8
UV_EXTERN void uv_close(uv_handle_t *handle, uv_close_cb close_cb)
Definition: core.c:108

References async, NULL, and uv_close().

Referenced by main(), and run_basic_block_analysis().

◆ fake_download()

void fake_download ( uv_work_t req)

Definition at line 12 of file main.c.

12  {
13  int size = *((int*) req->data);
14  int downloaded = 0;
15  while (downloaded < size) {
16  percentage = downloaded*100.0/size;
17  async.data = (void*) &percentage;
19 
20  sleep(1);
21  downloaded += (200+random())%1000; // can only download max 1000bytes/sec,
22  // but at least a 200;
23  }
24 }
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 uLong size
Definition: ioapi.h:138
double percentage
Definition: main.c:10
UV_EXTERN int uv_async_send(uv_async_t *async)
Definition: async.c:63

References async, percentage, req, and uv_async_send().

Referenced by main().

◆ main()

int main ( void  )

Definition at line 36 of file main.c.

36  {
38 
39  uv_work_t req;
40  int size = 10240;
41  req.data = (void*) &size;
42 
45 
46  return uv_run(loop, UV_RUN_DEFAULT);
47 }
Definition: uv.h:1066
uv_loop_t * loop
Definition: main.c:7
void after(uv_work_t *req, int status)
Definition: main.c:26
void print_progress(uv_async_t *handle)
Definition: main.c:31
void fake_download(uv_work_t *req)
Definition: main.c:12
@ UV_RUN_DEFAULT
Definition: uv.h:255
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition: core.c:365
UV_EXTERN int uv_queue_work(uv_loop_t *loop, uv_work_t *req, uv_work_cb work_cb, uv_after_work_cb after_work_cb)
Definition: threadpool.c:338
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:763
UV_EXTERN int uv_async_init(uv_loop_t *, uv_async_t *async, uv_async_cb async_cb)
Definition: async.c:45

References after(), async, fake_download(), loop, print_progress(), req, uv_async_init(), uv_default_loop(), uv_queue_work(), uv_run(), and UV_RUN_DEFAULT.

◆ print_progress()

void print_progress ( uv_async_t handle)

Definition at line 31 of file main.c.

31  {
32  double percentage = *((double*) handle->data);
33  fprintf(stderr, "Downloaded %.2f%%\n", percentage);
34 }
static mcore_handle handle
Definition: asm_mcore.c:8

References handle, and percentage.

Referenced by cancel(), and main().

Variable Documentation

◆ async

uv_async_t async

Definition at line 8 of file main.c.

Referenced by after(), fake_download(), and main().

◆ loop

uv_loop_t* loop

Definition at line 7 of file main.c.

◆ percentage