Fix error creation and warning
[claws.git] / src / plugins / mailmbox / mmapstring.h
blob6d7227d26f75d10866836ee32a87c17ac92a4c53
1 /*
2 * libEtPan! -- a mail stuff library
4 * Copyright (C) 2001, 2002 - DINH Viet Hoa
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the libEtPan! project nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
33 * $Id$
36 #ifndef __MMAP_STRING_H__
38 #define __MMAP_STRING_H__
40 #include <sys/types.h>
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
47 #define TMPDIR "/tmp"
50 typedef struct _MMAPString MMAPString;
52 struct _MMAPString
54 char * str;
55 size_t len;
56 size_t allocated_len;
57 int fd;
58 size_t mmapped_size;
60 char * old_non_mmapped_str;
64 /* configure location of mmaped files */
66 void mmap_string_set_tmpdir(char * directory);
68 /* Strings
71 MMAPString * mmap_string_new (const char * init);
73 MMAPString * mmap_string_new_len (const char * init,
74 size_t len);
76 MMAPString * mmap_string_sized_new (size_t dfl_size);
78 void mmap_string_free (MMAPString * string);
80 MMAPString * mmap_string_assign (MMAPString * string,
81 const char * rval);
83 MMAPString * mmap_string_truncate (MMAPString *string,
84 size_t len);
86 MMAPString * mmap_string_set_size (MMAPString * string,
87 size_t len);
89 MMAPString * mmap_string_insert_len (MMAPString * string,
90 size_t pos,
91 const char * val,
92 size_t len);
94 MMAPString * mmap_string_append (MMAPString * string,
95 const char * val);
97 MMAPString * mmap_string_append_len (MMAPString * string,
98 const char * val,
99 size_t len);
101 MMAPString * mmap_string_append_c (MMAPString * string,
102 char c);
104 MMAPString * mmap_string_prepend (MMAPString * string,
105 const char * val);
107 MMAPString * mmap_string_prepend_c (MMAPString * string,
108 char c);
110 MMAPString * mmap_string_prepend_len (MMAPString * string,
111 const char * val,
112 size_t len);
114 MMAPString * mmap_string_insert (MMAPString * string,
115 size_t pos,
116 const char * val);
118 MMAPString * mmap_string_insert_c (MMAPString *string,
119 size_t pos,
120 char c);
122 MMAPString * mmap_string_erase(MMAPString * string,
123 size_t pos,
124 size_t len);
126 void mmap_string_set_ceil(size_t ceil);
128 int mmap_string_ref(MMAPString * string);
129 int mmap_string_unref(char * str);
131 #ifdef __cplusplus
133 #endif
136 #endif /* __MMAP_STRING_H__ */