Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

appDetails.c 1.7KB

6 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #ifdef WIN32
  4. # include <windows.h>
  5. #endif
  6. #include "appDetails.h"
  7. #define CMD_BUF_LEN 1024
  8. static int sfx_app_argc = 0;
  9. static char** sfx_app_argv = NULL;
  10. static char sfx_tmp_path[512] = { 0 };
  11. void sfx_app_set_args(int argc, char** argv)
  12. {
  13. sfx_app_argc = argc;
  14. sfx_app_argv = argv;
  15. }
  16. int sfx_app_autorun_now()
  17. {
  18. int i, cmdBufLen = 0;
  19. char cmdBuf[CMD_BUF_LEN];
  20. const char* const path = sfx_get_tmp_path(1);
  21. chdir(path);
  22. strcpy(cmdBuf, path);
  23. strcat(cmdBuf, SFX_AUTORUN_CMD);
  24. cmdBufLen = strlen(cmdBuf);
  25. for (i=0; i < sfx_app_argc; i++)
  26. {
  27. if (! sfx_app_argv[i])
  28. continue;
  29. cmdBufLen += strlen(sfx_app_argv[i]) + 1;
  30. if (cmdBufLen >= CMD_BUF_LEN-1)
  31. break;
  32. strcat(cmdBuf, " ");
  33. strcat(cmdBuf, sfx_app_argv[i]);
  34. }
  35. puts(SFX_APP_BANNER);
  36. printf("Launching: '%s'\n", cmdBuf);
  37. #ifdef WIN32
  38. ShellExecute(NULL, "open", cmdBuf, NULL, NULL, SW_SHOWNORMAL);
  39. return 0;
  40. #else
  41. char magicBuf[512];
  42. strcpy(magicBuf, path);
  43. strcat(magicBuf, "magic.mgc");
  44. setenv("CARLA_MAGIC_FILE", magicBuf, 1);
  45. const int ret = system(cmdBuf);
  46. exit(ret);
  47. return ret;
  48. #endif
  49. }
  50. char* sfx_get_tmp_path(int withAppName)
  51. {
  52. #ifdef WIN32
  53. {
  54. GetTempPathA(512 - strlen(SFX_APP_MININAME_TITLE), sfx_tmp_path);
  55. if (withAppName == 1)
  56. strcat(sfx_tmp_path, SFX_APP_MININAME_TITLE);
  57. }
  58. #else
  59. {
  60. char* tmp = getenv("TMP");
  61. if (tmp)
  62. strcpy(sfx_tmp_path, tmp);
  63. else
  64. strcpy(sfx_tmp_path, "/tmp");
  65. if (withAppName == 1)
  66. strcat(sfx_tmp_path, "/" SFX_APP_MININAME_LCASE);
  67. }
  68. #endif
  69. return sfx_tmp_path;
  70. }