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