ucmd_gallery.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* gallery launcher: the real app is a disk image (GALLERY) because the
  2. * kernel's embedded command pack is close to its low-memory wall. This tiny
  3. * command keeps `gallery` on PATH; the app itself links ngui and the font. */
  4. #include "ucmd_lib.h"
  5. static const char *const candidates[] = {
  6. "/share/GALLERY",
  7. "/share/GALLERY.ELF",
  8. "/floppy1/GALLERY",
  9. "/floppy1/GALLERY.ELF",
  10. "/ide0p1/GALLERY",
  11. "/sata0p1/GALLERY",
  12. "/ide0/GALLERY",
  13. "/sata0/GALLERY",
  14. 0
  15. };
  16. void _start(const char *arg)
  17. {
  18. char cwd[64];
  19. char argbuf[64];
  20. unsigned int i, n = 0;
  21. while (arg && arg[n] && n + 1 < sizeof(argbuf)) {
  22. argbuf[n] = arg[n];
  23. n++;
  24. }
  25. argbuf[n] = '\0';
  26. if (u_getcwd(cwd, sizeof(cwd)) != 0 || !cwd[0]) {
  27. cwd[0] = '/';
  28. cwd[1] = '\0';
  29. }
  30. for (i = 0; i < sizeof(candidates) / sizeof(candidates[0]) &&
  31. candidates[i]; i++) {
  32. int pid = u_spawn(candidates[i], argbuf, 0, cwd);
  33. if (pid > 0) {
  34. u_puts("gallery: started ");
  35. u_puts(candidates[i]);
  36. u_puts("\n");
  37. u_exit(0);
  38. }
  39. }
  40. u_puts("gallery: GALLERY is not installed on a mounted disk\n");
  41. u_puts(" put gallery.elf on the root floppy or /share\n");
  42. u_exit(1);
  43. }