Rizin
unix-like reverse engineering framework and cli tools
input.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2019 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_cons.h>
5 #include <string.h>
6 #if __UNIX__
7 #include <errno.h>
8 #elif __WINDOWS__
9 #include <rz_windows.h>
10 #endif
11 
12 #define I rz_cons_singleton()
13 
14 RZ_API int rz_cons_controlz(int ch) {
15 #if __UNIX__
16  if (ch == 0x1a) {
17  rz_cons_show_cursor(true);
18  rz_cons_enable_mouse(false);
19  rz_sys_stop();
20  return 0;
21  }
22 #endif
23  return ch;
24 }
25 
26 // 96 - wheel up
27 // 97 - wheel down
28 // 95 - mouse up
29 // 92 - mouse down
30 static int __parseMouseEvent(void) {
31  char xpos[32];
32  char ypos[32];
33  (void)rz_cons_readchar(); // skip first char
34  int ch2 = rz_cons_readchar();
35 
36  // [32M - mousedown
37  // [35M - mouseup
38  if (ch2 == ';') {
39  int i;
40  // read until next ;
41  for (i = 0; i < sizeof(xpos) - 1; i++) {
42  char ch = rz_cons_readchar();
43  if (ch == ';' || ch == 'M') {
44  break;
45  }
46  xpos[i] = ch;
47  }
48  xpos[i] = 0;
49  for (i = 0; i < sizeof(ypos) - 1; i++) {
50  char ch = rz_cons_readchar();
51  if (ch == ';' || ch == 'M') {
52  break;
53  }
54  ypos[i] = ch;
55  }
56  ypos[i] = 0;
57  rz_cons_set_click(atoi(xpos), atoi(ypos));
58  (void)rz_cons_readchar();
59  // ignored
60  int ch = rz_cons_readchar();
61  if (ch == 27) {
62  ch = rz_cons_readchar(); // '['
63  }
64  if (ch == '[') {
65  do {
66  ch = rz_cons_readchar(); // '3'
67  } while (ch != 'M');
68  }
69  }
70  return 0;
71 }
72 
73 #if __WINDOWS__
74 static bool bCtrl;
75 static bool is_arrow;
76 #endif
77 
79 #if __WINDOWS__
80  if (I->vtmode != RZ_VIRT_TERM_MODE_COMPLETE) {
81  if (is_arrow) {
82  switch (ch) {
83  case VK_DOWN: // key down
84  ch = bCtrl ? 'J' : 'j';
85  break;
86  case VK_RIGHT: // key right
87  ch = bCtrl ? 'L' : 'l';
88  break;
89  case VK_UP: // key up
90  ch = bCtrl ? 'K' : 'k';
91  break;
92  case VK_LEFT: // key left
93  ch = bCtrl ? 'H' : 'h';
94  break;
95  case VK_PRIOR: // key home
96  ch = 'K';
97  break;
98  case VK_NEXT: // key end
99  ch = 'J';
100  break;
101  }
102  }
103  return I->mouse_event && (ut8)ch == UT8_MAX ? 0 : ch;
104  }
105 #endif
106  I->mouse_event = 0;
107  /* emacs */
108  switch ((ut8)ch) {
109  case 0xc3:
111  ch = 'K';
112  break; // emacs repag (alt + v)
113  case 0x16: ch = 'J'; break; // emacs avpag (ctrl + v)
114  case 0x10: ch = 'k'; break; // emacs up (ctrl + p)
115  case 0x0e: ch = 'j'; break; // emacs down (ctrl + n)
116  case 0x06: ch = 'l'; break; // emacs right (ctrl + f)
117  case 0x02: ch = 'h'; break; // emacs left (ctrl + b)
118  }
119  if (ch != 0x1b) {
120  return ch;
121  }
122  ch = rz_cons_readchar();
123  if (!ch) {
124  return 0;
125  }
126  switch (ch) {
127  case 0x1b:
128  ch = 'q'; // XXX: must be 0x1b (RZ_CONS_KEY_ESC)
129  break;
130  case 0x4f: // function keys from f1 to f4
131  ch = rz_cons_readchar();
132 #if defined(__HAIKU__)
133  /* Haiku't don use the '[' char for function keys */
134  if (ch > 'O') { /* only in f1..f12 function keys */
135  ch = 0xf1 + (ch & 0xf);
136  break;
137  }
138  case '[': // 0x5b function keys (2)
139  /* Haiku need ESC + [ for PageUp and PageDown */
140  if (ch < 'A' || ch == '[') {
141  ch = rz_cons_readchar();
142  }
143 #else
144  ch = 0xf1 + (ch & 0xf);
145  break;
146  case '[': // function keys (2)
147  ch = rz_cons_readchar();
148 #endif
149  switch (ch) {
150  case '<': {
151  char pos[8] = { 0 };
152  int p = 0;
153  int x = 0;
154  int y = 0;
155  int sc = 0;
156 
157  char vel[8] = { 0 };
158  int vn = 0;
159  do {
160  ch = rz_cons_readchar();
161  // just for debugging
162  // eprintf ( "%c", ch);
163  if (sc > 0) {
164  if (ch >= '0' && ch <= '9') {
165  pos[p++] = ch;
166  }
167  }
168  if (sc < 1) {
169  vel[vn++] = ch;
170  }
171  if (ch == ';') {
172  if (sc == 1) {
173  pos[p++] = 0;
174  x = atoi(pos);
175  }
176  sc++;
177  p = 0;
178  }
179  } while (ch != 'M' && ch != 'm');
180  int nvel = atoi(vel);
181  switch (nvel) {
182  case 2: // right click
183  if (ch == 'M') {
184  return INT8_MAX;
185  }
186  return -INT8_MAX;
187  case 64: // wheel up
188  return 'k';
189  case 65: // wheel down
190  return 'j';
191  }
192  pos[p++] = 0;
193  y = atoi(pos);
194  rz_cons_set_click(x, y);
195  }
196  return 0;
197  case '[':
198  ch = rz_cons_readchar();
199  switch (ch) {
200  case '2': ch = RZ_CONS_KEY_F11; break;
201  case 'A': ch = RZ_CONS_KEY_F1; break;
202  case 'B': ch = RZ_CONS_KEY_F2; break;
203  case 'C': ch = RZ_CONS_KEY_F3; break;
204  case 'D': ch = RZ_CONS_KEY_F4; break;
205  }
206  break;
207  case '9':
208  // handle mouse wheel
209  // __parseWheelEvent();
210  ch = rz_cons_readchar();
211  // 6 is up
212  // 7 is down
213  I->mouse_event = 1;
214  if (ch == '6') {
215  ch = 'k';
216  } else if (ch == '7') {
217  ch = 'j';
218  } else {
219  // unhandled case
220  ch = 0;
221  }
222  int ch2;
223  do {
224  ch2 = rz_cons_readchar();
225  } while (ch2 != 'M');
226  break;
227  case '3':
228  // handle mouse down /up events (35 vs 32)
230  return 0;
231  break;
232  case '2':
233  ch = rz_cons_readchar();
234  switch (ch) {
235  case 0x7e:
236  ch = RZ_CONS_KEY_F12;
237  break;
238  default:
240  switch (ch) {
241  case '0': ch = RZ_CONS_KEY_F9; break;
242  case '1': ch = RZ_CONS_KEY_F10; break;
243  case '3': ch = RZ_CONS_KEY_F11; break;
244  }
245  break;
246  }
247  break;
248  case '1':
249  ch = rz_cons_readchar();
250  switch (ch) {
251  case '1': ch = RZ_CONS_KEY_F1; break;
252  case '2': ch = RZ_CONS_KEY_F2; break;
253  case '3': ch = RZ_CONS_KEY_F3; break;
254  case '4': ch = RZ_CONS_KEY_F4; break;
255  case '5': ch = RZ_CONS_KEY_F5; break;
256  // case '6': ch = RZ_CONS_KEY_F5; break;
257  case '7': ch = RZ_CONS_KEY_F6; break;
258  case '8': ch = RZ_CONS_KEY_F7; break;
259  case '9': ch = RZ_CONS_KEY_F8; break;
260 #if 0
261  case '5':
262  rz_cons_readchar ();
263  ch = 0xf5;
264  break;
265  case '6':
266  rz_cons_readchar ();
267  ch = 0xf7;
268  break;
269  case '7':
270  rz_cons_readchar ();
271  ch = 0xf6;
272  break;
273  case '8':
274  rz_cons_readchar ();
275  ch = 0xf7;
276  break;
277  case '9':
278  rz_cons_readchar ();
279  ch = 0xf8;
280  break;
281 #endif
282  // Support st/st-256color term and others
283  // for shift+arrows
284  case ';': // arrow+mod
285  ch = rz_cons_readchar();
286  switch (ch) {
287  case '2': // arrow+shift
288  ch = rz_cons_readchar();
289  switch (ch) {
290  case 'A': ch = 'K'; break;
291  case 'B': ch = 'J'; break;
292  case 'C': ch = 'L'; break;
293  case 'D': ch = 'H'; break;
294  }
295  break;
296  // add other modifiers
297  }
298  break;
299  case ':': // arrow+shift
301  ch = rz_cons_readchar();
302  switch (ch) {
303  case 'A': ch = 'K'; break;
304  case 'B': ch = 'J'; break;
305  case 'C': ch = 'L'; break;
306  case 'D': ch = 'H'; break;
307  }
308  break;
309  } // F9-F12 not yet supported!!
310  break;
311  case '5':
312  ch = 'K';
314  break; // repag
315  case '6':
316  ch = 'J';
318  break; // avpag
319  /* arrow keys */
320  case 'A': ch = 'k'; break; // up
321  case 'B': ch = 'j'; break; // down
322  case 'C': ch = 'l'; break; // right
323  case 'D':
324  ch = 'h';
325  break; // left
326  // Support rxvt-unicode term for shift+arrows
327  case 'a': ch = 'K'; break; // shift+up
328  case 'b': ch = 'J'; break; // shift+down
329  case 'c': ch = 'L'; break; // shift+right
330  case 'd': ch = 'H'; break; // shift+left
331  case 'M': ch = __parseMouseEvent(); break;
332  }
333  break;
334  }
335  return ch;
336 }
337 
338 // XXX no control for max length here?!?!
339 RZ_API int rz_cons_fgets(char *buf, int len, int argc, const char **argv) {
340 #define RETURN(x) \
341  { \
342  ret = x; \
343  goto beach; \
344  }
345  RzCons *cons = rz_cons_singleton();
346  int ret = 0, color = cons->context->pal.input && *cons->context->pal.input;
347  if (cons->echo) {
348  rz_cons_set_raw(false);
349  rz_cons_show_cursor(true);
350  }
351 #if 0
352  int mouse = rz_cons_enable_mouse (false);
353  rz_cons_enable_mouse (false);
354  rz_cons_flush ();
355 #endif
356  errno = 0;
357  if (cons->user_fgets) {
358  RETURN(cons->user_fgets(buf, len, cons->user_fgets_user));
359  }
360  printf("%s", cons->line->prompt);
361  fflush(stdout);
362  *buf = '\0';
363  if (color) {
364  const char *p = cons->context->pal.input;
365  if (RZ_STR_ISNOTEMPTY(p)) {
366  fwrite(p, strlen(p), 1, stdout);
367  fflush(stdout);
368  }
369  }
370  if (!fgets(buf, len, cons->fdin)) {
371  if (color) {
373  fflush(stdout);
374  }
375  RETURN(-1);
376  }
377  if (feof(cons->fdin)) {
378  if (color) {
380  }
381  RETURN(-2);
382  }
384  if (color) {
386  }
387  ret = strlen(buf);
388 beach:
389  // rz_cons_enable_mouse (mouse);
390  return ret;
391 }
392 
393 RZ_API int rz_cons_any_key(const char *msg) {
394  if (msg && *msg) {
395  rz_cons_printf("\n-- %s --\n", msg);
396  } else {
397  rz_cons_print("\n--press any key--\n");
398  }
399  rz_cons_flush();
400  return rz_cons_readchar();
401  // rz_cons_strcat ("\x1b[2J\x1b[0;0H");
402 }
403 
404 extern void resizeWin(void);
405 
406 #if __WINDOWS__
407 static int __cons_readchar_w32(ut32 usec) {
408  int ch = 0;
409  BOOL ret;
410  bCtrl = false;
411  is_arrow = false;
412  DWORD mode, out;
413  HANDLE h;
414  INPUT_RECORD irInBuf = { 0 };
415  CONSOLE_SCREEN_BUFFER_INFO info = { 0 };
416  bool mouse_enabled = I->mouse;
417  bool click_n_drag = false;
418  void *bed;
419  I->mouse_event = 0;
420  h = GetStdHandle(STD_INPUT_HANDLE);
421  GetConsoleMode(h, &mode);
422  DWORD newmode = ENABLE_WINDOW_INPUT;
423  if (I->vtmode == RZ_VIRT_TERM_MODE_COMPLETE) {
424  newmode |= ENABLE_VIRTUAL_TERMINAL_INPUT;
425  }
426  newmode |= mode;
427  SetConsoleMode(h, newmode);
428  do {
429  bed = rz_cons_sleep_begin();
430  if (usec) {
431  if (WaitForSingleObject(h, usec) == WAIT_TIMEOUT) {
432  rz_cons_sleep_end(bed);
433  return -1;
434  }
435  }
436  if (I->term_xterm) {
437  ret = ReadFile(h, &ch, 1, &out, NULL);
438  if (ret) {
439  rz_cons_sleep_end(bed);
440  return ch;
441  }
442  } else {
443  ret = ReadConsoleInputW(h, &irInBuf, 1, &out);
444  }
445  rz_cons_sleep_end(bed);
446  if (ret) {
447  if (irInBuf.EventType == MENU_EVENT || irInBuf.EventType == FOCUS_EVENT) {
448  continue;
449  }
450  if (mouse_enabled) {
451  rz_cons_enable_mouse(true);
452  }
453  if (irInBuf.EventType == MOUSE_EVENT) {
454  if (irInBuf.Event.MouseEvent.dwEventFlags == MOUSE_MOVED) {
455  if (irInBuf.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) {
456  click_n_drag = true;
457  }
458  continue;
459  }
460  if (irInBuf.Event.MouseEvent.dwEventFlags == MOUSE_WHEELED) {
461  if (irInBuf.Event.MouseEvent.dwButtonState & 0xFF000000) {
462  ch = bCtrl ? 'J' : 'j';
463  } else {
464  ch = bCtrl ? 'K' : 'k';
465  }
466  I->mouse_event = 1;
467  }
468  switch (irInBuf.Event.MouseEvent.dwButtonState) {
469  case FROM_LEFT_1ST_BUTTON_PRESSED:
470  GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
471  int rel_y = irInBuf.Event.MouseEvent.dwMousePosition.Y - info.srWindow.Top;
472  rz_cons_set_click(irInBuf.Event.MouseEvent.dwMousePosition.X + 1, rel_y + 1);
473  ch = UT8_MAX;
474  break;
475  } // TODO: Handle more buttons?
476  }
477 
478  if (click_n_drag) {
479  rz_cons_set_click(irInBuf.Event.MouseEvent.dwMousePosition.X + 1, irInBuf.Event.MouseEvent.dwMousePosition.Y + 1);
480  ch = UT8_MAX;
481  }
482 
483  if (irInBuf.EventType == KEY_EVENT) {
484  if (irInBuf.Event.KeyEvent.bKeyDown) {
485  bCtrl = irInBuf.Event.KeyEvent.dwControlKeyState & LEFT_CTRL_PRESSED;
486  if (irInBuf.Event.KeyEvent.uChar.UnicodeChar) {
487  char *tmp = rz_utf16_to_utf8_l(&irInBuf.Event.KeyEvent.uChar.UnicodeChar, 1);
488  if (tmp) {
489  int len = strlen(tmp);
490  memcpy(&ch, tmp, RZ_MIN(len, sizeof(ch)));
491  free(tmp);
492  }
493  } else {
494  switch (irInBuf.Event.KeyEvent.wVirtualKeyCode) {
495  case VK_DOWN: // key down
496  case VK_RIGHT: // key right
497  case VK_UP: // key up
498  case VK_LEFT: // key left
499  case VK_PRIOR: // key home
500  case VK_NEXT: // key end
501  ch = irInBuf.Event.KeyEvent.wVirtualKeyCode;
502  is_arrow = true;
503  break;
504  case VK_F1:
505  ch = RZ_CONS_KEY_F1;
506  break;
507  case VK_F2:
508  ch = RZ_CONS_KEY_F2;
509  break;
510  case VK_F3:
511  ch = RZ_CONS_KEY_F3;
512  break;
513  case VK_F4:
514  ch = RZ_CONS_KEY_F4;
515  break;
516  case VK_F5:
517  ch = bCtrl ? 0xcf5 : RZ_CONS_KEY_F5;
518  break;
519  case VK_F6:
520  ch = RZ_CONS_KEY_F6;
521  break;
522  case VK_F7:
523  ch = RZ_CONS_KEY_F7;
524  break;
525  case VK_F8:
526  ch = RZ_CONS_KEY_F8;
527  break;
528  case VK_F9:
529  ch = RZ_CONS_KEY_F9;
530  break;
531  case VK_F10:
532  ch = RZ_CONS_KEY_F10;
533  break;
534  case VK_F11:
535  ch = RZ_CONS_KEY_F11;
536  break;
537  case VK_F12:
538  ch = RZ_CONS_KEY_F12;
539  case VK_SHIFT:
540  if (mouse_enabled) {
541  rz_cons_enable_mouse(false);
542  }
543  break;
544  default:
545  break;
546  }
547  }
548  }
549  }
550  if (irInBuf.EventType == WINDOW_BUFFER_SIZE_EVENT) {
551  resizeWin();
552  }
553  }
554  } while (ch == 0);
555  SetConsoleMode(h, mode);
556  return ch;
557 }
558 #endif
559 
561  char ch;
562  if (rz_cons_readbuffer_readchar(&ch)) {
563  return ch;
564  }
565 #if __UNIX__
566  struct timeval tv;
567  fd_set fdset, errset;
568  FD_ZERO(&fdset);
569  FD_ZERO(&errset);
570  FD_SET(0, &fdset);
571  tv.tv_sec = 0; // usec / 1000;
572  tv.tv_usec = 1000 * usec;
573  rz_cons_set_raw(1);
574  if (select(1, &fdset, NULL, &errset, &tv) == 1) {
575  return rz_cons_readchar();
576  }
577  rz_cons_set_raw(0);
578  // timeout
579  return -1;
580 #else
581  return __cons_readchar_w32(usec);
582 #endif
583 }
584 
585 RZ_API bool rz_cons_readpush(const char *str, int len) {
586  char *res = (len + I->input->readbuffer_length > 0) ? realloc(I->input->readbuffer, len + I->input->readbuffer_length) : NULL;
587  if (res) {
588  I->input->readbuffer = res;
589  memmove(I->input->readbuffer + I->input->readbuffer_length, str, len);
590  I->input->readbuffer_length += len;
591  return true;
592  }
593  return false;
594 }
595 
597  RZ_FREE(I->input->readbuffer);
598  I->input->readbuffer_length = 0;
599 }
600 
601 RZ_API void rz_cons_switchbuf(bool active) {
602  I->input->bufactive = active;
603 }
604 
605 #if !__WINDOWS__
606 extern volatile sig_atomic_t sigwinchFlag;
607 #endif
608 
610  if (I->input->readbuffer_length <= 0) {
611  return false;
612  }
613  *ch = *I->input->readbuffer;
614  I->input->readbuffer_length--;
615  memmove(I->input->readbuffer, I->input->readbuffer + 1, I->input->readbuffer_length);
616  return true;
617 }
618 
620  char buf[2], ch;
621  buf[0] = -1;
622  if (rz_cons_readbuffer_readchar(&ch)) {
623  return ch;
624  }
625  rz_cons_set_raw(1);
626 #if __WINDOWS__
627  return __cons_readchar_w32(0);
628 #else
629  void *bed = rz_cons_sleep_begin();
630 
631  // Blocks until either stdin has something to read or a signal happens.
632  // This serves to check if the terminal window was resized. It avoids the race
633  // condition that could happen if we did not use pselect or select in case SIGWINCH
634  // was handled immediately before the blocking call (select or read). The race is
635  // prevented from happening by having SIGWINCH blocked process-wide except for in
636  // pselect (that is what pselect is for).
637  fd_set readfds;
638  sigset_t sigmask;
639  FD_ZERO(&readfds);
641  rz_signal_sigmask(0, NULL, &sigmask);
642  sigdelset(&sigmask, SIGWINCH);
643  while (pselect(STDIN_FILENO + 1, &readfds, NULL, NULL, NULL, &sigmask) == -1) {
644  if (errno == EBADF) {
645  eprintf("rz_cons_readchar (): EBADF\n");
646  return -1;
647  }
648  if (sigwinchFlag) {
649  sigwinchFlag = 0;
650  resizeWin();
651  }
652  }
653 
654  ssize_t ret = read(STDIN_FILENO, buf, 1);
655  rz_cons_sleep_end(bed);
656  if (ret != 1) {
657  return -1;
658  }
659  if (I->input->bufactive) {
660  rz_cons_set_raw(0);
661  }
662  return rz_cons_controlz(buf[0]);
663 #endif
664 }
665 
666 RZ_API bool rz_cons_yesno(int def, const char *fmt, ...) {
667  va_list ap;
668  ut8 key = (ut8)def;
669  va_start(ap, fmt);
670 
671  if (!rz_cons_is_interactive()) {
672  va_end(ap);
673  return def == 'y';
674  }
675  vfprintf(stderr, fmt, ap);
676  va_end(ap);
677  fflush(stderr);
678  rz_cons_set_raw(true);
679  char buf[] = " ?\n";
680  if (read(0, buf + 1, 1) == 1) {
681  key = (ut8)buf[1];
682  if (write(2, buf, 3) == 3) {
683  if (key == 'Y') {
684  key = 'y';
685  }
686  rz_cons_set_raw(false);
687  if (key == '\n' || key == '\r') {
688  key = def;
689  }
690  return key == 'y';
691  }
692  }
693  return false;
694 }
695 
696 RZ_API char *rz_cons_input(const char *msg) {
697  char *oprompt = rz_line_get_prompt();
698  if (!oprompt) {
699  return NULL;
700  }
701  char buf[1024];
702  if (msg) {
704  } else {
705  rz_line_set_prompt("");
706  }
707  buf[0] = 0;
708  rz_cons_fgets(buf, sizeof(buf), 0, NULL);
709  rz_line_set_prompt(oprompt);
710  free(oprompt);
711  return strdup(buf);
712 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
RzBinInfo * info(RzBinFile *bf)
Definition: bin_ne.c:86
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
RZ_API void rz_cons_set_raw(bool is_raw)
Definition: cons.c:1617
RZ_API bool rz_cons_enable_mouse(const bool enable)
Definition: cons.c:500
RZ_API RzCons * rz_cons_singleton(void)
Definition: cons.c:300
RZ_API void * rz_cons_sleep_begin(void)
Definition: cons.c:443
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API bool rz_cons_is_interactive(void)
Definition: cons.c:365
RZ_API void rz_cons_show_cursor(int cursor)
Definition: cons.c:1581
RZ_API void rz_cons_set_click(int x, int y)
Definition: cons.c:477
RZ_API void rz_cons_flush(void)
Definition: cons.c:959
RZ_API void rz_cons_sleep_end(void *user)
Definition: cons.c:450
#define RZ_API
#define NULL
Definition: cris-opc.c:27
_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 tv
Definition: sflib.h:79
static static fork write
Definition: sflib.h:33
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 key
Definition: sflib.h:118
#define ut8
Definition: dcpu16.h:8
uint32_t ut32
static char sc[]
Definition: egg_cb.c:6
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API void rz_cons_readflush(void)
Definition: input.c:596
RZ_API void rz_cons_switchbuf(bool active)
Definition: input.c:601
RZ_API char * rz_cons_input(const char *msg)
Definition: input.c:696
volatile sig_atomic_t sigwinchFlag
RZ_API int rz_cons_controlz(int ch)
Definition: input.c:14
static int __parseMouseEvent(void)
Definition: input.c:30
RZ_API bool rz_cons_readbuffer_readchar(char *ch)
Definition: input.c:609
RZ_API int rz_cons_arrow_to_hjkl(int ch)
Definition: input.c:78
#define I
Definition: input.c:12
RZ_API int rz_cons_any_key(const char *msg)
Definition: input.c:393
RZ_API int rz_cons_readchar_timeout(ut32 usec)
Definition: input.c:560
RZ_API bool rz_cons_readpush(const char *str, int len)
Definition: input.c:585
#define RETURN(x)
void resizeWin(void)
Definition: cons.c:471
RZ_API int rz_cons_fgets(char *buf, int len, int argc, const char **argv)
Definition: input.c:339
RZ_API bool rz_cons_yesno(int def, const char *fmt,...)
Definition: input.c:666
RZ_API int rz_cons_readchar(void)
Definition: input.c:619
const char int mode
Definition: ioapi.h:137
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * realloc(void *ptr, size_t size)
Definition: malloc.c:144
RZ_API void rz_line_set_prompt(const char *prompt)
Definition: line.c:56
RZ_API RZ_OWN char * rz_line_get_prompt(void)
Definition: line.c:64
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set readfds
Definition: sflib.h:108
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz select
Definition: sflib.h:108
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
int x
Definition: mipsasm.c:20
#define eprintf(x, y...)
Definition: rlcc.c:7
#define RZ_CONS_KEY_F12
Definition: rz_cons.h:589
#define RZ_CONS_KEY_F11
Definition: rz_cons.h:588
@ RZ_VIRT_TERM_MODE_COMPLETE
All the sequences goes through VT (Windows Terminal, mintty, all OSs)
Definition: rz_cons.h:451
#define RZ_CONS_KEY_F10
Definition: rz_cons.h:587
#define Color_RESET
Definition: rz_cons.h:617
#define RZ_CONS_KEY_F6
Definition: rz_cons.h:583
#define RZ_CONS_KEY_F7
Definition: rz_cons.h:584
#define RZ_CONS_KEY_F3
Definition: rz_cons.h:580
#define RZ_CONS_KEY_F2
Definition: rz_cons.h:579
#define RZ_CONS_KEY_F1
Definition: rz_cons.h:578
#define RZ_CONS_KEY_F5
Definition: rz_cons.h:582
#define RZ_CONS_KEY_F4
Definition: rz_cons.h:581
#define RZ_CONS_KEY_F9
Definition: rz_cons.h:586
#define RZ_CONS_KEY_F8
Definition: rz_cons.h:585
#define RZ_STR_ISNOTEMPTY(x)
Definition: rz_str.h:68
RZ_API RZ_BORROW char * rz_str_trim_tail(RZ_NONNULL char *str)
Removes whitespace characters (space, tab, newline etc.) from the end of a string and replaces them w...
Definition: str_trim.c:125
RZ_API bool rz_sys_stop(void)
Send SIGTSTP signal to every process in this process group.
Definition: sys.c:1864
#define RZ_FREE(x)
Definition: rz_types.h:369
#define RZ_MIN(x, y)
#define UT8_MAX
static struct sockaddr static addrlen static backlog const void msg
Definition: sfsocketcall.h:119
#define FD_ZERO(set)
Definition: sftypes.h:204
#define FD_SET(d, set)
Definition: sftypes.h:212
#define EBADF
Definition: sftypes.h:119
int ssize_t
Definition: sftypes.h:39
int sigset_t
Definition: sftypes.h:63
#define h(i)
Definition: sha256.c:48
#define INT8_MAX
RzConsPrintablePalette pal
Definition: rz_cons.h:491
struct rz_line_t * line
Definition: rz_cons.h:553
int echo
Definition: rz_cons.h:509
void * user_fgets_user
Definition: rz_cons.h:521
RzConsContext * context
Definition: rz_cons.h:502
FILE * fdin
Definition: rz_cons.h:517
int(* user_fgets)(char *buf, int len, void *user)
Definition: rz_cons.h:520
char * prompt
Definition: rz_cons.h:1103
int pos
Definition: main.c:11
#define STDIN_FILENO
Definition: private.h:37
static int color
Definition: visual.c:20
#define SIGWINCH
Definition: win.h:88
DWORD * HANDLE
DWORD
int def(FILE *source, FILE *dest, int level)
Definition: zpipe.c:36
int read(izstream &zs, T *x, Items items)
Definition: zstream.h:115