error.c 745 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include "pci.h"
  5. #include "vga.h"
  6. int vflag, Vflag;
  7. void
  8. error(char* format, ...)
  9. {
  10. char buf[512], *out;
  11. va_list arg;
  12. int n;
  13. sequencer(0, 1);
  14. n = sprint(buf, "%s: ", argv0);
  15. va_start(arg, format);
  16. out = vseprint(buf+n, buf+sizeof(buf)-n, format, arg);
  17. va_end(arg);
  18. if(vflag)
  19. Bprint(&stdout, "%s", buf+n);
  20. Bflush(&stdout);
  21. write(2, buf, out-buf);
  22. exits("error");
  23. }
  24. void
  25. trace(char* format, ...)
  26. {
  27. char buf[512];
  28. va_list arg;
  29. if(vflag || Vflag){
  30. if(curprintindex){
  31. curprintindex = 0;
  32. Bprint(&stdout, "\n");
  33. }
  34. va_start(arg, format);
  35. vseprint(buf, buf+sizeof(buf), format, arg);
  36. va_end(arg);
  37. Bprint(&stdout, "%s", buf);
  38. if(Vflag)
  39. print("%s", buf);
  40. }
  41. }