HelloWorld.c 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* This Hello World simply print out "Hello World" */
  4. #include "pal.h"
  5. #include "pal_debug.h"
  6. char str[13];
  7. int main (int argc, char ** argv, char ** envp)
  8. {
  9. pal_printf("start program: %s\n", pal_control.executable);
  10. PAL_HANDLE out = DkStreamOpen("dev:tty", PAL_ACCESS_WRONLY, 0, 0, 0);
  11. if (out == NULL) {
  12. pal_printf("DkStreamOpen failed\n");
  13. return -1;
  14. }
  15. str[0] = 'H';
  16. str[1] = 'e';
  17. str[2] = 'l';
  18. str[3] = 'l';
  19. str[4] = 'o';
  20. str[5] = ' ';
  21. str[6] = 'W';
  22. str[7] = 'o';
  23. str[8] = 'r';
  24. str[9] = 'l';
  25. str[10] = 'd';
  26. str[11] = '\n';
  27. str[12] = 0;
  28. int bytes = DkStreamWrite(out, 0, 12, str, NULL);
  29. if (bytes < 0) {
  30. pal_printf("DkStreamWrite failed\n");
  31. return -1;
  32. }
  33. DkObjectClose(out);
  34. return 0;
  35. }