1
0

config.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #include <windows.h>
  2. #include "resource.h"
  3. #include "../Agave/Language/api_language.h"
  4. #include "main.h"
  5. #include <strsafe.h>
  6. extern const char *INI_FILE;
  7. static char app_name[] = "in_dshow";
  8. static char default_extlist[]="MPG;MPEG;M2V;AVI";
  9. char config_extlist[129] = {0};
  10. static int _r_i(char *name, int def)
  11. {
  12. if (!_strnicmp(name,"config_",7)) name += 7;
  13. return GetPrivateProfileIntA(app_name,name,def,INI_FILE);
  14. }
  15. #define RI(x) (( x ) = _r_i(#x,( x )))
  16. static void _w_i(char *name, int d)
  17. {
  18. char str[120] = {0};
  19. StringCchPrintfA(str, 120, "%d",d);
  20. if (!_strnicmp(name,"config_",7)) name += 7;
  21. WritePrivateProfileStringA(app_name,name,str,INI_FILE);
  22. }
  23. #define WI(x) _w_i(#x,( x ))
  24. static void _r_s(char *name,char *data, int mlen)
  25. {
  26. char buf[2048] = {0};
  27. lstrcpynA(buf,data, 2048);
  28. if (!_strnicmp(name,"config_",7)) name += 7;
  29. GetPrivateProfileStringA(app_name,name,buf,data,mlen,INI_FILE);
  30. }
  31. #define RS(x) (_r_s(#x,x,sizeof(x)))
  32. static void _w_s(char *name, char *data)
  33. {
  34. if (!_strnicmp(name,"config_",7)) name += 7;
  35. WritePrivateProfileStringA(app_name,name,data,INI_FILE);
  36. }
  37. #define WS(x) (_w_s(#x,x))
  38. #define ISSEP(x) ((x) == ' ' || (x) == ';' || (x) == ',' || (x) == ':' || (x) == '.')
  39. char *getfileextensions()
  40. {
  41. static char list[512];
  42. char *op=list;
  43. // char *g_fileassos="MP3;MP2;MP1\0MPEG Audio Files (*.MP3;*.MP2;*.MP1)\0";
  44. char *p=config_extlist;
  45. int s=0;
  46. while (p && *p)
  47. {
  48. while (ISSEP(*p)) p++;
  49. if (!*p) break;
  50. if (s) *op++=';';
  51. s=1;
  52. while (p && *p && !ISSEP(*p)) *op++=*p++;
  53. }
  54. *op++=0;
  55. lstrcpynA(op,WASABI_API_LNGSTRING(IDS_VIDEO_FILES_OFD),512);
  56. while (op && *op) op++;
  57. p=config_extlist;
  58. s=0;
  59. while (p && *p)
  60. {
  61. while (ISSEP(*p)) p++;
  62. if (!p || !*p) break;
  63. if (s) *op++=';';
  64. s=1;
  65. *op++='*';
  66. *op++='.';
  67. while (p && *p && !ISSEP(*p)) *op++=*p++;
  68. }
  69. *op++=')';
  70. *op++=0;
  71. *op++=0;
  72. return list;
  73. }
  74. void config_read()
  75. {
  76. lstrcpynA(config_extlist,default_extlist, 129);
  77. RS(config_extlist);
  78. }
  79. void config_write()
  80. {
  81. WS(config_extlist);
  82. }
  83. INT_PTR CALLBACK configProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  84. {
  85. switch(uMsg)
  86. {
  87. case WM_INITDIALOG:
  88. SetDlgItemTextA(hwndDlg,IDC_TYPES,config_extlist);
  89. SendDlgItemMessage(hwndDlg,IDC_TYPES,EM_LIMITTEXT,128,0);
  90. return TRUE;
  91. case WM_COMMAND:
  92. switch(LOWORD(wParam))
  93. {
  94. case IDC_DEFAULTTYPES:
  95. SetDlgItemTextA(hwndDlg,IDC_TYPES,default_extlist);
  96. break;
  97. case IDOK:
  98. GetDlgItemTextA(hwndDlg,IDC_TYPES,config_extlist,128);
  99. config_write();
  100. case IDCANCEL:
  101. EndDialog(hwndDlg,0);
  102. break;
  103. }
  104. break;
  105. }
  106. return FALSE;
  107. }
  108. void doConfig(HINSTANCE hInstance, HWND hwndParent)
  109. {
  110. WASABI_API_DIALOGBOXW(IDD_CONFIG,hwndParent,configProc);
  111. }