Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 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 | |
| 18 | #ifndef TRIO_TRIOSTR_H |
| 19 | #define TRIO_TRIOSTR_H |
| 20 | |
| 21 | #include <assert.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <string.h> |
| 24 | #include <time.h> |
| 25 | #include "triodef.h" |
| 26 | #include "triop.h" |
| 27 | |
| 28 | enum { |
| 29 | TRIO_HASH_NONE = 0, |
| 30 | TRIO_HASH_PLAIN, |
| 31 | TRIO_HASH_TWOSIGNED |
| 32 | }; |
| 33 | |
| 34 | /************************************************************************* |
| 35 | * String functions |
| 36 | */ |
| 37 | |
| 38 | int trio_append(char *target, const char *source); |
| 39 | int trio_append_max(char *target, size_t max, const char *source); |
| 40 | int trio_contains(const char *string, const char *substring); |
| 41 | int trio_copy(char *target, const char *source); |
| 42 | int trio_copy_max(char *target, size_t max, const char *source); |
| 43 | char *trio_create(size_t size); |
| 44 | void trio_destroy(char *string); |
| 45 | char *trio_duplicate(const char *source); |
| 46 | char *trio_duplicate_max(const char *source, size_t max); |
| 47 | int trio_equal(const char *first, const char *second); |
| 48 | int trio_equal_case(const char *first, const char *second); |
| 49 | int trio_equal_case_max(const char *first, size_t max, const char *second); |
| 50 | int trio_equal_locale(const char *first, const char *second); |
| 51 | int trio_equal_max(const char *first, size_t max, const char *second); |
| 52 | const char *trio_error(int); |
| 53 | size_t trio_format_date_max(char *target, size_t max, const char *format, const struct tm *datetime); |
| 54 | unsigned long trio_hash(const char *string, int type); |
| 55 | char *trio_index(const char *string, char character); |
| 56 | char *trio_index_last(const char *string, char character); |
| 57 | size_t trio_length(const char *string); |
| 58 | int trio_lower(char *target); |
| 59 | int trio_match(const char *string, const char *pattern); |
| 60 | int trio_match_case(const char *string, const char *pattern); |
| 61 | size_t trio_span_function(char *target, const char *source, int (*Function)(int)); |
| 62 | char *trio_substring(const char *string, const char *substring); |
| 63 | char *trio_substring_max(const char *string, size_t max, const char *substring); |
| 64 | char *trio_tokenize(char *string, const char *delimiters); |
| 65 | float trio_to_float(const char *source, const char **endp); |
| 66 | double trio_to_double(const char *source, const char **endp); |
| 67 | long trio_to_long(const char *source, char **endp, int base); |
| 68 | unsigned long trio_to_unsigned_long(const char *source, char **endp, int base); |
| 69 | int trio_upper(char *target); |
| 70 | |
| 71 | /************************************************************************* |
| 72 | * Dynamic string functions |
| 73 | */ |
| 74 | |
| 75 | /* |
| 76 | * Opaque type for dynamic strings |
| 77 | */ |
| 78 | typedef struct _trio_string_t trio_string_t; |
| 79 | |
| 80 | trio_string_t *trio_string_create(int initial_size); |
| 81 | void trio_string_destroy(trio_string_t *self); |
| 82 | char *trio_string_get(trio_string_t *self, int offset); |
| 83 | void trio_xstring_set(trio_string_t *self, char *buffer); |
| 84 | char *trio_string_extract(trio_string_t *self); |
| 85 | int trio_string_size(trio_string_t *self); |
| 86 | void trio_string_terminate(trio_string_t *self); |
| 87 | |
| 88 | int trio_string_append(trio_string_t *self, trio_string_t *other); |
| 89 | int trio_string_contains(trio_string_t *self, trio_string_t *other); |
| 90 | int trio_string_copy(trio_string_t *self, trio_string_t *other); |
| 91 | trio_string_t *trio_string_duplicate(trio_string_t *other); |
| 92 | int trio_string_equal(trio_string_t *self, trio_string_t *other); |
| 93 | int trio_string_equal_max(trio_string_t *self, size_t max, trio_string_t *second); |
| 94 | int trio_string_equal_case(trio_string_t *self, trio_string_t *other); |
| 95 | int trio_string_equal_case_max(trio_string_t *self, size_t max, trio_string_t *other); |
| 96 | size_t trio_string_format_date_max(trio_string_t *self, size_t max, const char *format, const struct tm *datetime); |
| 97 | char *trio_string_index(trio_string_t *self, int character); |
| 98 | char *trio_string_index_last(trio_string_t *self, int character); |
| 99 | int trio_string_length(trio_string_t *self); |
| 100 | int trio_string_lower(trio_string_t *self); |
| 101 | int trio_string_match(trio_string_t *self, trio_string_t *other); |
| 102 | int trio_string_match_case(trio_string_t *self, trio_string_t *other); |
| 103 | char *trio_string_substring(trio_string_t *self, trio_string_t *other); |
| 104 | int trio_string_upper(trio_string_t *self); |
| 105 | |
| 106 | int trio_xstring_append_char(trio_string_t *self, char character); |
| 107 | int trio_xstring_append(trio_string_t *self, const char *other); |
| 108 | int trio_xstring_contains(trio_string_t *self, const char *other); |
| 109 | int trio_xstring_copy(trio_string_t *self, const char *other); |
| 110 | trio_string_t *trio_xstring_duplicate(const char *other); |
| 111 | int trio_xstring_equal(trio_string_t *self, const char *other); |
| 112 | int trio_xstring_equal_max(trio_string_t *self, size_t max, const char *other); |
| 113 | int trio_xstring_equal_case(trio_string_t *self, const char *other); |
| 114 | int trio_xstring_equal_case_max(trio_string_t *self, size_t max, const char *other); |
| 115 | int trio_xstring_match(trio_string_t *self, const char *other); |
| 116 | int trio_xstring_match_case(trio_string_t *self, const char *other); |
| 117 | char *trio_xstring_substring(trio_string_t *self, const char *other); |
| 118 | |
| 119 | #endif /* TRIO_TRIOSTR_H */ |