SDL_dialog_utils.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "SDL_internal.h"
  19. /* The following are utility functions to help implementations.
  20. They are ordered by scope largeness, decreasing. All implementations
  21. should use them, as they check for invalid filters. Where they are unused,
  22. the validate_* function further down below should be used. */
  23. /* Transform the name given in argument into something viable for the engine.
  24. Useful if there are special characters to avoid on certain platforms (such
  25. as "|" with Zenity). */
  26. typedef char *(NameTransform)(const char * name);
  27. /* Converts all the filters into a single string. */
  28. /* <prefix>[filter]{<separator>[filter]...}<suffix> */
  29. char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters,
  30. NameTransform ntf, const char *prefix,
  31. const char *separator, const char *suffix,
  32. const char *filt_prefix, const char *filt_separator,
  33. const char *filt_suffix, const char *ext_prefix,
  34. const char *ext_separator, const char *ext_suffix);
  35. /* Converts one filter into a single string. */
  36. /* <prefix>[filter name]<separator>[filter extension list]<suffix> */
  37. char *convert_filter(const SDL_DialogFileFilter filter, NameTransform ntf,
  38. const char *prefix, const char *separator,
  39. const char *suffix, const char *ext_prefix,
  40. const char *ext_separator, const char *ext_suffix);
  41. /* Converts the extenstion list of a filter into a single string. */
  42. /* <prefix>[extension]{<separator>[extension]...}<suffix> */
  43. char *convert_ext_list(const char *list, const char *prefix,
  44. const char *separator, const char *suffix);
  45. /* Must be used if convert_* functions aren't used */
  46. /* Returns an error message if there's a problem, NULL otherwise */
  47. const char *validate_filters(const SDL_DialogFileFilter *filters,
  48. int nfilters);
  49. const char *validate_list(const char *list);