triostr.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*************************************************************************
  2. *
  3. * $Id$
  4. *
  5. * Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
  6. *
  7. * Permission to use, copy, modify, and distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  12. * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  13. * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
  14. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
  15. *
  16. ************************************************************************/
  17. #ifndef TRIO_TRIOSTR_H
  18. #define TRIO_TRIOSTR_H
  19. #include <assert.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <time.h>
  23. #include "triodef.h"
  24. #include "triop.h"
  25. enum {
  26. TRIO_HASH_NONE = 0,
  27. TRIO_HASH_PLAIN,
  28. TRIO_HASH_TWOSIGNED
  29. };
  30. #if !defined(TRIO_STRING_PUBLIC)
  31. # if !defined(TRIO_PUBLIC)
  32. # define TRIO_PUBLIC
  33. # endif
  34. # define TRIO_STRING_PUBLIC TRIO_PUBLIC
  35. #endif
  36. /*************************************************************************
  37. * String functions
  38. */
  39. TRIO_STRING_PUBLIC int trio_copy_max TRIO_PROTO((char *target, size_t max, const char *source));
  40. TRIO_STRING_PUBLIC char *trio_create TRIO_PROTO((size_t size));
  41. TRIO_STRING_PUBLIC void trio_destroy TRIO_PROTO((char *string));
  42. TRIO_STRING_PUBLIC char *trio_duplicate TRIO_PROTO((const char *source));
  43. TRIO_STRING_PUBLIC int trio_equal TRIO_PROTO((const char *first, const char *second));
  44. TRIO_STRING_PUBLIC int trio_equal_case TRIO_PROTO((const char *first, const char *second));
  45. TRIO_STRING_PUBLIC int trio_equal_locale TRIO_PROTO((const char *first, const char *second));
  46. TRIO_STRING_PUBLIC int trio_equal_max TRIO_PROTO((const char *first, size_t max, const char *second));
  47. TRIO_STRING_PUBLIC TRIO_CONST char *trio_error TRIO_PROTO((int));
  48. TRIO_STRING_PUBLIC size_t trio_length TRIO_PROTO((const char *string));
  49. TRIO_STRING_PUBLIC double trio_to_double TRIO_PROTO((const char *source, char **endp));
  50. TRIO_STRING_PUBLIC long trio_to_long TRIO_PROTO((const char *source, char **endp, int base));
  51. TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_PROTO((const char *source, char **endp));
  52. TRIO_STRING_PUBLIC int trio_to_upper TRIO_PROTO((int source));
  53. #if !defined(TRIO_MINIMAL)
  54. TRIO_STRING_PUBLIC int trio_append TRIO_PROTO((char *target, const char *source));
  55. TRIO_STRING_PUBLIC int trio_append_max TRIO_PROTO((char *target, size_t max, const char *source));
  56. TRIO_STRING_PUBLIC int trio_contains TRIO_PROTO((const char *string, const char *substring));
  57. TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source));
  58. TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max));
  59. TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second));
  60. #if !defined(_WIN32_WCE)
  61. TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_PROTO((char *target, size_t max, const char *format, const struct tm *datetime));
  62. #endif
  63. TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_PROTO((const char *string, int type));
  64. TRIO_STRING_PUBLIC char *trio_index TRIO_PROTO((const char *string, int character));
  65. TRIO_STRING_PUBLIC char *trio_index_last TRIO_PROTO((const char *string, int character));
  66. TRIO_STRING_PUBLIC int trio_lower TRIO_PROTO((char *target));
  67. TRIO_STRING_PUBLIC int trio_match TRIO_PROTO((const char *string, const char *pattern));
  68. TRIO_STRING_PUBLIC int trio_match_case TRIO_PROTO((const char *string, const char *pattern));
  69. TRIO_STRING_PUBLIC size_t trio_span_function TRIO_PROTO((char *target, const char *source, int (*Function) TRIO_PROTO((int))));
  70. TRIO_STRING_PUBLIC char *trio_substring TRIO_PROTO((const char *string, const char *substring));
  71. TRIO_STRING_PUBLIC char *trio_substring_max TRIO_PROTO((const char *string, size_t max, const char *substring));
  72. TRIO_STRING_PUBLIC float trio_to_float TRIO_PROTO((const char *source, char **endp));
  73. TRIO_STRING_PUBLIC int trio_to_lower TRIO_PROTO((int source));
  74. TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_PROTO((const char *source, char **endp, int base));
  75. TRIO_STRING_PUBLIC char *trio_tokenize TRIO_PROTO((char *string, const char *delimiters));
  76. TRIO_STRING_PUBLIC int trio_upper TRIO_PROTO((char *target));
  77. #endif /* !defined(TRIO_MINIMAL) */
  78. /*************************************************************************
  79. * Dynamic string functions
  80. */
  81. /*
  82. * Opaque type for dynamic strings
  83. */
  84. typedef struct _trio_string_t trio_string_t;
  85. TRIO_STRING_PUBLIC void trio_string_destroy TRIO_PROTO((trio_string_t *self));
  86. TRIO_STRING_PUBLIC char *trio_string_extract TRIO_PROTO((trio_string_t *self));
  87. TRIO_STRING_PUBLIC int trio_string_size TRIO_PROTO((trio_string_t *self));
  88. TRIO_STRING_PUBLIC void trio_string_terminate TRIO_PROTO((trio_string_t *self));
  89. TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_PROTO((trio_string_t *self, char character));
  90. TRIO_STRING_PUBLIC trio_string_t *trio_xstring_duplicate TRIO_PROTO((const char *other));
  91. #if !defined(TRIO_MINIMAL)
  92. TRIO_STRING_PUBLIC trio_string_t *trio_string_create TRIO_PROTO((int initial_size));
  93. TRIO_STRING_PUBLIC char *trio_string_get TRIO_PROTO((trio_string_t *self, int offset));
  94. TRIO_STRING_PUBLIC void trio_xstring_set TRIO_PROTO((trio_string_t *self, char *buffer));
  95. TRIO_STRING_PUBLIC int trio_string_append TRIO_PROTO((trio_string_t *self, trio_string_t *other));
  96. TRIO_STRING_PUBLIC int trio_string_contains TRIO_PROTO((trio_string_t *self, trio_string_t *other));
  97. TRIO_STRING_PUBLIC int trio_string_copy TRIO_PROTO((trio_string_t *self, trio_string_t *other));
  98. TRIO_STRING_PUBLIC trio_string_t *trio_string_duplicate TRIO_PROTO((trio_string_t *other));
  99. TRIO_STRING_PUBLIC int trio_string_equal TRIO_PROTO((trio_string_t *self, trio_string_t *other));
  100. TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *second));
  101. TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_PROTO((trio_string_t *self, trio_string_t *other));
  102. TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *other));
  103. #if !defined(_WIN32_WCE)
  104. TRIO_STRING_PUBLIC size_t trio_string_format_date_max TRIO_PROTO((trio_string_t *self, size_t max, const char *format, const struct tm *datetime));
  105. #endif
  106. TRIO_STRING_PUBLIC char *trio_string_index TRIO_PROTO((trio_string_t *self, int character));
  107. TRIO_STRING_PUBLIC char *trio_string_index_last TRIO_PROTO((trio_string_t *self, int character));
  108. TRIO_STRING_PUBLIC int trio_string_length TRIO_PROTO((trio_string_t *self));
  109. TRIO_STRING_PUBLIC int trio_string_lower TRIO_PROTO((trio_string_t *self));
  110. TRIO_STRING_PUBLIC int trio_string_match TRIO_PROTO((trio_string_t *self, trio_string_t *other));
  111. TRIO_STRING_PUBLIC int trio_string_match_case TRIO_PROTO((trio_string_t *self, trio_string_t *other));
  112. TRIO_STRING_PUBLIC char *trio_string_substring TRIO_PROTO((trio_string_t *self, trio_string_t *other));
  113. TRIO_STRING_PUBLIC int trio_string_upper TRIO_PROTO((trio_string_t *self));
  114. TRIO_STRING_PUBLIC int trio_xstring_append TRIO_PROTO((trio_string_t *self, const char *other));
  115. TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_PROTO((trio_string_t *self, const char *other));
  116. TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_PROTO((trio_string_t *self, const char *other));
  117. TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_PROTO((trio_string_t *self, const char *other));
  118. TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other));
  119. TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_PROTO((trio_string_t *self, const char *other));
  120. TRIO_STRING_PUBLIC int trio_xstring_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other));
  121. TRIO_STRING_PUBLIC int trio_xstring_match TRIO_PROTO((trio_string_t *self, const char *other));
  122. TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_PROTO((trio_string_t *self, const char *other));
  123. TRIO_STRING_PUBLIC char *trio_xstring_substring TRIO_PROTO((trio_string_t *self, const char *other));
  124. #endif /* !defined(TRIO_MINIMAL) */
  125. #endif /* TRIO_TRIOSTR_H */