blob: 27f4ace236d5b28369ae3c1d977b1cf980fe236b [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
Daniel Veillardb7c29c32002-09-25 22:44:43 +000034#if !defined(TRIO_STRING_PUBLIC)
35# if !defined(TRIO_PUBLIC)
36# define TRIO_PUBLIC
37# endif
38# define TRIO_STRING_PUBLIC TRIO_PUBLIC
39#endif
40
Bjorn Reese026d29f2002-01-19 15:40:18 +000041/*************************************************************************
42 * String functions
43 */
44
Daniel Veillardb7c29c32002-09-25 22:44:43 +000045TRIO_STRING_PUBLIC int trio_copy_max TRIO_PROTO((char *target, size_t max, const char *source));
46TRIO_STRING_PUBLIC char *trio_create TRIO_PROTO((size_t size));
47TRIO_STRING_PUBLIC void trio_destroy TRIO_PROTO((char *string));
48TRIO_STRING_PUBLIC char *trio_duplicate TRIO_PROTO((const char *source));
Daniel Veillardb7c29c32002-09-25 22:44:43 +000049TRIO_STRING_PUBLIC int trio_equal TRIO_PROTO((const char *first, const char *second));
50TRIO_STRING_PUBLIC int trio_equal_case TRIO_PROTO((const char *first, const char *second));
Daniel Veillardb7c29c32002-09-25 22:44:43 +000051TRIO_STRING_PUBLIC int trio_equal_locale TRIO_PROTO((const char *first, const char *second));
52TRIO_STRING_PUBLIC int trio_equal_max TRIO_PROTO((const char *first, size_t max, const char *second));
53TRIO_STRING_PUBLIC TRIO_CONST char *trio_error TRIO_PROTO((int));
Daniel Veillarda48ed3d2003-04-03 15:28:28 +000054TRIO_STRING_PUBLIC size_t trio_length TRIO_PROTO((const char *string));
55TRIO_STRING_PUBLIC double trio_to_double TRIO_PROTO((const char *source, char **endp));
56TRIO_STRING_PUBLIC long trio_to_long TRIO_PROTO((const char *source, char **endp, int base));
57TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_PROTO((const char *source, char **endp));
58TRIO_STRING_PUBLIC int trio_to_upper TRIO_PROTO((int source));
59
60#if !defined(TRIO_MINIMAL)
61
62TRIO_STRING_PUBLIC int trio_append TRIO_PROTO((char *target, const char *source));
63TRIO_STRING_PUBLIC int trio_append_max TRIO_PROTO((char *target, size_t max, const char *source));
64TRIO_STRING_PUBLIC int trio_contains TRIO_PROTO((const char *string, const char *substring));
65TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source));
66TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max));
67TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second));
Daniel Veillard59d3ed82007-04-17 12:44:58 +000068#if !defined(_WIN32_WCE)
Daniel Veillardb7c29c32002-09-25 22:44:43 +000069TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_PROTO((char *target, size_t max, const char *format, const struct tm *datetime));
Daniel Veillard59d3ed82007-04-17 12:44:58 +000070#endif
Daniel Veillardb7c29c32002-09-25 22:44:43 +000071TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_PROTO((const char *string, int type));
72TRIO_STRING_PUBLIC char *trio_index TRIO_PROTO((const char *string, int character));
73TRIO_STRING_PUBLIC char *trio_index_last TRIO_PROTO((const char *string, int character));
Daniel Veillardb7c29c32002-09-25 22:44:43 +000074TRIO_STRING_PUBLIC int trio_lower TRIO_PROTO((char *target));
75TRIO_STRING_PUBLIC int trio_match TRIO_PROTO((const char *string, const char *pattern));
76TRIO_STRING_PUBLIC int trio_match_case TRIO_PROTO((const char *string, const char *pattern));
77TRIO_STRING_PUBLIC size_t trio_span_function TRIO_PROTO((char *target, const char *source, int (*Function) TRIO_PROTO((int))));
78TRIO_STRING_PUBLIC char *trio_substring TRIO_PROTO((const char *string, const char *substring));
79TRIO_STRING_PUBLIC char *trio_substring_max TRIO_PROTO((const char *string, size_t max, const char *substring));
Daniel Veillardb7c29c32002-09-25 22:44:43 +000080TRIO_STRING_PUBLIC float trio_to_float TRIO_PROTO((const char *source, char **endp));
Daniel Veillarda48ed3d2003-04-03 15:28:28 +000081TRIO_STRING_PUBLIC int trio_to_lower TRIO_PROTO((int source));
Daniel Veillardb7c29c32002-09-25 22:44:43 +000082TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_PROTO((const char *source, char **endp, int base));
83TRIO_STRING_PUBLIC char *trio_tokenize TRIO_PROTO((char *string, const char *delimiters));
84TRIO_STRING_PUBLIC int trio_upper TRIO_PROTO((char *target));
Bjorn Reese026d29f2002-01-19 15:40:18 +000085
Daniel Veillarda48ed3d2003-04-03 15:28:28 +000086#endif /* !defined(TRIO_MINIMAL) */
87
Bjorn Reese026d29f2002-01-19 15:40:18 +000088/*************************************************************************
89 * Dynamic string functions
90 */
91
92/*
93 * Opaque type for dynamic strings
94 */
Daniel Veillarda48ed3d2003-04-03 15:28:28 +000095
Bjorn Reese026d29f2002-01-19 15:40:18 +000096typedef struct _trio_string_t trio_string_t;
97
Daniel Veillardb7c29c32002-09-25 22:44:43 +000098TRIO_STRING_PUBLIC void trio_string_destroy TRIO_PROTO((trio_string_t *self));
Daniel Veillardb7c29c32002-09-25 22:44:43 +000099TRIO_STRING_PUBLIC char *trio_string_extract TRIO_PROTO((trio_string_t *self));
100TRIO_STRING_PUBLIC int trio_string_size TRIO_PROTO((trio_string_t *self));
101TRIO_STRING_PUBLIC void trio_string_terminate TRIO_PROTO((trio_string_t *self));
Daniel Veillarda48ed3d2003-04-03 15:28:28 +0000102TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_PROTO((trio_string_t *self, char character));
103TRIO_STRING_PUBLIC trio_string_t *trio_xstring_duplicate TRIO_PROTO((const char *other));
104
105#if !defined(TRIO_MINIMAL)
106
107TRIO_STRING_PUBLIC trio_string_t *trio_string_create TRIO_PROTO((int initial_size));
108TRIO_STRING_PUBLIC char *trio_string_get TRIO_PROTO((trio_string_t *self, int offset));
109TRIO_STRING_PUBLIC void trio_xstring_set TRIO_PROTO((trio_string_t *self, char *buffer));
Bjorn Reese026d29f2002-01-19 15:40:18 +0000110
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000111TRIO_STRING_PUBLIC int trio_string_append TRIO_PROTO((trio_string_t *self, trio_string_t *other));
112TRIO_STRING_PUBLIC int trio_string_contains TRIO_PROTO((trio_string_t *self, trio_string_t *other));
113TRIO_STRING_PUBLIC int trio_string_copy TRIO_PROTO((trio_string_t *self, trio_string_t *other));
114TRIO_STRING_PUBLIC trio_string_t *trio_string_duplicate TRIO_PROTO((trio_string_t *other));
115TRIO_STRING_PUBLIC int trio_string_equal TRIO_PROTO((trio_string_t *self, trio_string_t *other));
116TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *second));
117TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_PROTO((trio_string_t *self, trio_string_t *other));
118TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *other));
Daniel Veillard59d3ed82007-04-17 12:44:58 +0000119#if !defined(_WIN32_WCE)
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000120TRIO_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));
Daniel Veillard59d3ed82007-04-17 12:44:58 +0000121#endif
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000122TRIO_STRING_PUBLIC char *trio_string_index TRIO_PROTO((trio_string_t *self, int character));
123TRIO_STRING_PUBLIC char *trio_string_index_last TRIO_PROTO((trio_string_t *self, int character));
124TRIO_STRING_PUBLIC int trio_string_length TRIO_PROTO((trio_string_t *self));
125TRIO_STRING_PUBLIC int trio_string_lower TRIO_PROTO((trio_string_t *self));
126TRIO_STRING_PUBLIC int trio_string_match TRIO_PROTO((trio_string_t *self, trio_string_t *other));
127TRIO_STRING_PUBLIC int trio_string_match_case TRIO_PROTO((trio_string_t *self, trio_string_t *other));
128TRIO_STRING_PUBLIC char *trio_string_substring TRIO_PROTO((trio_string_t *self, trio_string_t *other));
129TRIO_STRING_PUBLIC int trio_string_upper TRIO_PROTO((trio_string_t *self));
Bjorn Reese026d29f2002-01-19 15:40:18 +0000130
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000131TRIO_STRING_PUBLIC int trio_xstring_append TRIO_PROTO((trio_string_t *self, const char *other));
132TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_PROTO((trio_string_t *self, const char *other));
133TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_PROTO((trio_string_t *self, const char *other));
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000134TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_PROTO((trio_string_t *self, const char *other));
135TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other));
136TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_PROTO((trio_string_t *self, const char *other));
137TRIO_STRING_PUBLIC int trio_xstring_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other));
138TRIO_STRING_PUBLIC int trio_xstring_match TRIO_PROTO((trio_string_t *self, const char *other));
139TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_PROTO((trio_string_t *self, const char *other));
140TRIO_STRING_PUBLIC char *trio_xstring_substring TRIO_PROTO((trio_string_t *self, const char *other));
Bjorn Reese026d29f2002-01-19 15:40:18 +0000141
Daniel Veillarda48ed3d2003-04-03 15:28:28 +0000142#endif /* !defined(TRIO_MINIMAL) */
143
Bjorn Reese026d29f2002-01-19 15:40:18 +0000144#endif /* TRIO_TRIOSTR_H */