ucmd_gallery.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* gallery launcher: the real app ships in the rootfs pack as
  2. * bin/gallery.app (and can be overridden by /share/GALLERY or a FAT mount).
  3. * This tiny command keeps `gallery` on PATH; the app links ngui and the
  4. * font. */
  5. #include "ucmd_lib.h"
  6. static const char *const candidates[] = {
  7. "/share/GALLERY",
  8. "/share/GALLERY.ELF",
  9. /* The copy shipped in the command-pack rootfs. */
  10. "/ramfs/bin/gallery.app",
  11. "/floppy1/GALLERY",
  12. "/floppy1/GALLERY.ELF",
  13. "/ide0p1/GALLERY",
  14. "/sata0p1/GALLERY",
  15. "/ide0/GALLERY",
  16. "/sata0/GALLERY",
  17. 0
  18. };
  19. void _start(const char *arg)
  20. {
  21. char cwd[64];
  22. char argbuf[64];
  23. unsigned int i, n = 0;
  24. while (arg && arg[n] && n + 1 < sizeof(argbuf)) {
  25. argbuf[n] = arg[n];
  26. n++;
  27. }
  28. argbuf[n] = '\0';
  29. if (u_getcwd(cwd, sizeof(cwd)) != 0 || !cwd[0]) {
  30. cwd[0] = '/';
  31. cwd[1] = '\0';
  32. }
  33. for (i = 0; i < sizeof(candidates) / sizeof(candidates[0]) &&
  34. candidates[i]; i++) {
  35. int pid = u_spawn(candidates[i], argbuf, 0, cwd);
  36. if (pid > 0) {
  37. u_puts("gallery: started ");
  38. u_puts(candidates[i]);
  39. u_puts("\n");
  40. while (u_alive((unsigned int)pid))
  41. u_sleep_ms(100);
  42. u_exit(0);
  43. }
  44. }
  45. u_puts("gallery: GALLERY is not installed in the pack or on a disk\n");
  46. u_puts(" put gallery.elf on the root floppy or /share\n");
  47. u_exit(1);
  48. }