Rizin
unix-like reverse engineering framework and cli tools
main.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <unistd.h>
4 #include <uv.h>
5 
11 int pos = 0;
12 char *message = " Hello TTY ";
13 
15  char data[500];
16 
17  uv_buf_t buf;
18  buf.base = data;
19  buf.len = sprintf(data, "\033[2J\033[H\033[%dB\033[%luC\033[42;37m%s",
20  pos,
21  (unsigned long) (width-strlen(message))/2,
22  message);
24 
25  pos++;
26  if (pos > height) {
29  }
30 }
31 
32 int main() {
34 
36  uv_tty_set_mode(&tty, 0);
37 
38  if (uv_tty_get_winsize(&tty, &width, &height)) {
39  fprintf(stderr, "Could not get TTY information\n");
41  return 1;
42  }
43 
44  fprintf(stderr, "Width %d, height %d\n", width, height);
46  uv_timer_start(&tick, update, 200, 200);
47  return uv_run(loop, UV_RUN_DEFAULT);
48 }
#define NULL
Definition: cris-opc.c:27
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
sprintf
Definition: kernel.h:365
int main(int argc, const char **argv)
Definition: main.c:340
Definition: unix.h:123
Definition: uv.h:1780
Definition: uv.h:860
Definition: uv.h:714
Definition: uv.h:525
uv_loop_t * loop
Definition: main.c:7
char * message
Definition: main.c:12
int pos
Definition: main.c:11
uv_write_t write_req
Definition: main.c:9
int width
Definition: main.c:10
uv_timer_t tick
Definition: main.c:8
void update(uv_timer_t *req)
Definition: main.c:14
int height
Definition: main.c:10
uv_tty_t tty
Definition: main.c:7
#define STDOUT_FILENO
Definition: private.h:41
@ UV_RUN_DEFAULT
Definition: uv.h:255
UV_EXTERN int uv_timer_start(uv_timer_t *handle, uv_timer_cb cb, uint64_t timeout, uint64_t repeat)
Definition: timer.c:66
UV_EXTERN int uv_timer_init(uv_loop_t *, uv_timer_t *handle)
Definition: timer.c:58
UV_EXTERN int uv_write(uv_write_t *req, uv_stream_t *handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb)
Definition: stream.c:1492
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition: core.c:365
UV_EXTERN int uv_tty_set_mode(uv_tty_t *, uv_tty_mode_t mode)
Definition: tty.c:250
UV_EXTERN int uv_timer_stop(uv_timer_t *handle)
Definition: timer.c:97
UV_EXTERN int uv_tty_reset_mode(void)
Definition: tty.c:378
UV_EXTERN int uv_tty_get_winsize(uv_tty_t *, int *width, int *height)
Definition: tty.c:297
UV_EXTERN int uv_tty_init(uv_loop_t *, uv_tty_t *, uv_file fd, int readable)
Definition: tty.c:123
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:763