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.
 
 
 
 
 
 

155 lines
4.5 KiB

  1. /*
  2. * System character string functions
  3. *
  4. * Copyright (C) 2008-2019, Joachim Metz <joachim.metz@gmail.com>
  5. *
  6. * Refer to AUTHORS for acknowledgements.
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. #if !defined( _SYSTEM_STRING_H )
  22. #define _SYSTEM_STRING_H
  23. #include "common.h"
  24. #include "narrow_string.h"
  25. #include "types.h"
  26. #include "wide_string.h"
  27. #if defined( _cplusplus )
  28. extern "C" {
  29. #endif
  30. #if defined( HAVE_WIDE_SYSTEM_CHARACTER )
  31. #if SIZEOF_WCHAR_T != 2
  32. #error Unsupported wide system character size
  33. #endif
  34. /* Intermediate version of the macro required
  35. * for correct evaluation predefined string
  36. */
  37. #define _SYSTEM_STRING_INTERMEDIATE( string ) \
  38. L ## string
  39. #define _SYSTEM_STRING( string ) \
  40. _SYSTEM_STRING_INTERMEDIATE( string )
  41. #define system_string_allocate( size ) \
  42. wide_string_allocate( size )
  43. #define system_string_reallocate( string, size ) \
  44. wide_string_reallocate( string, size )
  45. #define system_string_compare( destination, source, size ) \
  46. wide_string_compare( destination, source, size )
  47. #define system_string_compare_no_case( destination, source, size ) \
  48. wide_string_compare_no_case( destination, source, size )
  49. #define system_string_copy( destination, source, size ) \
  50. wide_string_copy( destination, source, size )
  51. #define system_string_length( string ) \
  52. wide_string_length( string )
  53. #define system_string_search_character( string, character, size ) \
  54. wide_string_search_character( string, character, size )
  55. #define system_string_search_character_reverse( string, character, size ) \
  56. wide_string_search_character_reverse( string, character, size )
  57. #define system_string_search_string( string, substring, size ) \
  58. wide_string_search_string( string, substring, size )
  59. #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 )
  60. #define system_string_sprintf \
  61. wide_string_snwprintf
  62. #else
  63. #define system_string_sprintf( string, size, format, ... ) \
  64. wide_string_snwprintf( string, size, format, __VA_ARGS__ )
  65. #endif
  66. #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 )
  67. #define system_string_vsnprintf \
  68. wide_string_vsnwprintf
  69. #else
  70. #define system_string_vsnprintf( string, size, format, ... ) \
  71. wide_string_vsnwprintf( string, size, format, __VA_ARGS__ )
  72. #endif
  73. #else
  74. #define _SYSTEM_STRING( string ) \
  75. string
  76. #define system_string_allocate( size ) \
  77. narrow_string_allocate( size )
  78. #define system_string_reallocate( string, size ) \
  79. narrow_string_reallocate( string, size )
  80. #define system_string_compare( destination, source, size ) \
  81. narrow_string_compare( destination, source, size )
  82. #define system_string_compare_no_case( destination, source, size ) \
  83. narrow_string_compare_no_case( destination, source, size )
  84. #define system_string_copy( destination, source, size ) \
  85. narrow_string_copy( destination, source, size )
  86. #define system_string_length( string ) \
  87. narrow_string_length( string )
  88. #define system_string_search_character( string, character, size ) \
  89. narrow_string_search_character( string, character, size )
  90. #define system_string_search_character_reverse( string, character, size ) \
  91. narrow_string_search_character_reverse( string, character, size )
  92. #define system_string_search_string( string, substring, size ) \
  93. narrow_string_search_string( string, substring, size )
  94. #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 )
  95. #define system_string_sprintf \
  96. narrow_string_snprintf
  97. #else
  98. #define system_string_sprintf( string, size, format, ... ) \
  99. narrow_string_snprintf( string, size, format, __VA_ARGS__ )
  100. #endif
  101. #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 )
  102. #define system_string_vsnprintf \
  103. narrow_string_vsnprintf
  104. #else
  105. #define system_string_vsnprintf( string, size, format, ... ) \
  106. narrow_string_vsnprintf( string, size, format, __VA_ARGS__ )
  107. #endif
  108. #endif /* defined( HAVE_WIDE_SYSTEM_CHARACTER ) */
  109. /* For backwards compatibility */
  110. #define system_string_vsprintf system_string_vsnprintf
  111. #if defined( _cplusplus )
  112. }
  113. #endif
  114. #endif /* !defined( _SYSTEM_STRING_H ) */