fork(1) download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <stdarg.h>
  4.  
  5. #define STOP 0
  6. #define WRITE 1
  7. #define READ 2
  8.  
  9. void vfunc(unsigned action, ...)
  10. {
  11. va_list ap;
  12.  
  13. va_start(ap, action);
  14.  
  15. while ((action == WRITE) || (action == READ))
  16. {
  17. uint8_t *ptr = va_arg(ap, uint8_t*);
  18.  
  19. int len = va_arg(ap, int);
  20.  
  21. printf("action=0x%04x, ptr=%p, len=%d\n", action, ptr, len);
  22.  
  23. action = va_arg(ap, unsigned);
  24. }
  25.  
  26. va_end(ap);
  27. }
  28.  
  29.  
  30. int main(void)
  31. {
  32. uint8_t foo = 55;
  33.  
  34. uint8_t bar = 66;
  35.  
  36. uint8_t *p_bar = &(bar);
  37.  
  38. vfunc(WRITE, &(foo), 1, READ, p_bar, 1, STOP);
  39.  
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
action=0x0001, ptr=0x7ffe19c8691e, len=1
action=0x0002, ptr=0x7ffe19c8691f, len=1