ucmd_gallery.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. u_exit(0);
  41. }
  42. }
  43. u_puts("gallery: GALLERY is not installed in the pack or on a disk\n");
  44. u_puts(" put gallery.elf on the root floppy or /share\n");
  45. u_exit(1);
  46. }