glue.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. Copyright (c) 2022-2023 Bruce A Henderson
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #define INI_IMPLEMENTATION
  20. #include "ini.h"
  21. #include "brl.mod/blitz.mod/blitz.h"
  22. BBString * bmx_ini_section_name(ini_t const * ini, int section) {
  23. char * n = ini_section_name(ini, section);
  24. if (n) {
  25. return bbStringFromUTF8String(n);
  26. } else {
  27. return &bbEmptyString;
  28. }
  29. }
  30. void bmx_ini_section_name_set(ini_t const * ini, int section, BBString * name) {
  31. char * n = (char*)bbStringToUTF8String(name);
  32. ini_section_name_set(ini, section, n, 0);
  33. bbMemFree(n);
  34. }
  35. int bmx_ini_find_section(ini_t const * ini, BBString * name) {
  36. char * n = (char*)bbStringToUTF8String(name);
  37. int index = ini_find_section(ini, n, 0);
  38. bbMemFree(n);
  39. return index;
  40. }
  41. int bmx_ini_section_add(ini_t const * ini, BBString * name) {
  42. char * n = (char*)bbStringToUTF8String(name);
  43. int index = ini_section_add(ini, n, 0);
  44. bbMemFree(n);
  45. return index;
  46. }
  47. BBString * bmx_ini_property_name(ini_t const * ini, int section, int property) {
  48. char * n = ini_property_name(ini, section, property);
  49. if (n) {
  50. return bbStringFromUTF8String(n);
  51. } else {
  52. return &bbEmptyString;
  53. }
  54. }
  55. BBString * bmx_ini_property_value(ini_t const * ini, int section, int property) {
  56. char * n = ini_property_value(ini, section, property);
  57. if (n) {
  58. return bbStringFromUTF8String(n);
  59. } else {
  60. return &bbEmptyString;
  61. }
  62. }
  63. void bmx_ini_property_add(ini_t const * ini, int section, BBString * name, BBString * value) {
  64. char * n = (char*)bbStringToUTF8String(name);
  65. char * v = (char*)bbStringToUTF8String(value);
  66. ini_property_add(ini, section, n, 0, v, 0);
  67. bbMemFree(v);
  68. bbMemFree(n);
  69. }
  70. void bmx_ini_property_value_set(ini_t const * ini, int section, int property, BBString * value) {
  71. char * v = (char*)bbStringToUTF8String(value);
  72. ini_property_value_set(ini, section, property, v, 0);
  73. bbMemFree(v);
  74. }
  75. void bmx_ini_property_name_set(ini_t const * ini, int section, int property, BBString * name) {
  76. char * n = (char*)bbStringToUTF8String(name);
  77. ini_property_name_set(ini, section, property, n, 0);
  78. bbMemFree(n);
  79. }