Skip to content

Commit 692ad3f

Browse files
Move buf_ declarations to a separate, installed .h file
because sieve_intefrace.h depends on struct buf declaration and sieve_interface.h is installed. -- install libconfig.h, imap/message_guid.h -- charset.h (installed): do not depend on util.h and thus on config.h cyrusimap#5108
1 parent 7cc8d84 commit 692ad3f

File tree

6 files changed

+88
-75
lines changed

6 files changed

+88
-75
lines changed

Makefile.am

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ include_HEADERS = \
763763
lib/bitvector.h \
764764
lib/bloom.h \
765765
lib/bsearch.h \
766+
lib/buf.h \
766767
lib/charset.h \
767768
lib/command.h \
768769
lib/crc32.h \
@@ -780,6 +781,7 @@ include_HEADERS = \
780781
lib/imparse.h \
781782
lib/iostat.h \
782783
lib/iptostring.h \
784+
lib/libconfig.h \
783785
lib/libcyr_cfg.h \
784786
lib/lsort.h \
785787
lib/map.h \
@@ -810,14 +812,16 @@ include_HEADERS = \
810812
nodist_include_HEADERS = \
811813
lib/imapopts.h
812814

813-
nobase_include_HEADERS = sieve/sieve_interface.h
815+
nobase_include_HEADERS = \
816+
imap/message_guid.h \
817+
sieve/sieve_interface.h
818+
814819
nobase_nodist_include_HEADERS = sieve/sieve_err.h
815820

816821
noinst_HEADERS += \
817822
lib/bufarray.h \
818823
lib/byteorder.h \
819824
lib/gai.h \
820-
lib/libconfig.h \
821825
lib/md5.h \
822826
lib/prot.h \
823827
lib/ptrarray.h \
@@ -1010,7 +1014,6 @@ imap_libcyrus_imap_la_SOURCES = \
10101014
imap/mboxname.c \
10111015
imap/mboxname.h \
10121016
imap/message_guid.c \
1013-
imap/message_guid.h \
10141017
imap/message.c \
10151018
imap/message.h \
10161019
imap/message_priv.h \

imap/message.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@
4545

4646
#include <stdio.h>
4747

48+
#include "arrayu64.h"
49+
#include "buf.h"
4850
#include "prot.h"
4951
#include "mailbox.h"
52+
#include "imap/message_guid.h"
5053
#include "strarray.h"
51-
#include "util.h"
5254
#include "charset.h"
5355

5456
/* (draft standard) MIME tspecials */

lib/buf.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#ifndef CYRUS_BUF_H
2+
#define CYRUS_BUF_H
3+
4+
/* Examine the name of a file, and return a single character
5+
* (as an int) that can be used as the name of a hash
6+
* directory. Caller is responsible for skipping any prefix
7+
* of the name.
8+
*/
9+
int dir_hash_c(const char *name, int full);
10+
11+
#include <stddef.h>
12+
#define BUF_MMAP (1<<1)
13+
typedef unsigned long long int modseq_t;
14+
15+
struct buf {
16+
char *s;
17+
size_t len;
18+
size_t alloc;
19+
unsigned flags;
20+
};
21+
#define BUF_INITIALIZER { NULL, 0, 0, 0 }
22+
23+
#define buf_new() ((struct buf *) xzmalloc(sizeof(struct buf)))
24+
#define buf_destroy(b) do { buf_free((b)); free((b)); } while (0)
25+
#define buf_ensure(b, n) do { if ((b)->alloc < (b)->len + (n)) _buf_ensure((b), (n)); } while (0)
26+
#define buf_putc(b, c) do { buf_ensure((b), 1); (b)->s[(b)->len++] = (c); } while (0)
27+
28+
void _buf_ensure(struct buf *buf, size_t len);
29+
const char *buf_cstring(const struct buf *buf);
30+
const char *buf_cstringnull(const struct buf *buf);
31+
const char *buf_cstringnull_ifempty(const struct buf *buf);
32+
const char *buf_cstring_or_empty(const struct buf *buf);
33+
char *buf_newcstring(struct buf *buf);
34+
char *buf_release(struct buf *buf);
35+
char *buf_releasenull(struct buf *buf);
36+
void buf_getmap(struct buf *buf, const char **base, size_t *len);
37+
size_t buf_len(const struct buf *buf);
38+
const char *buf_base(const struct buf *buf);
39+
void buf_reset(struct buf *buf);
40+
void buf_setcstr(struct buf *buf, const char *str);
41+
void buf_setmap(struct buf *buf, const char *base, size_t len);
42+
void buf_copy(struct buf *dst, const struct buf *src);
43+
void buf_append(struct buf *dst, const struct buf *src);
44+
void buf_appendcstr(struct buf *buf, const char *str);
45+
void buf_appendoverlap(struct buf *buf, const char *str);
46+
void buf_appendmap(struct buf *buf, const char *base, size_t len);
47+
void buf_cowappendmap(struct buf *buf, const char *base, unsigned int len);
48+
void buf_cowappendfree(struct buf *buf, char *base, unsigned int len);
49+
void buf_insert(struct buf *dst, unsigned int off, const struct buf *src);
50+
void buf_insertcstr(struct buf *buf, unsigned int off, const char *str);
51+
void buf_insertmap(struct buf *buf, unsigned int off, const char *base, int len);
52+
void buf_printf(struct buf *buf, const char *fmt, ...)
53+
__attribute__((format(printf, 2, 3)));
54+
void buf_replace_buf(struct buf *buf, size_t offset, size_t length,
55+
const struct buf *replace);
56+
int buf_replace_all(struct buf *buf, const char *match,
57+
const char *replace);
58+
int buf_replace_char(struct buf *buf, char match, char replace);
59+
void buf_remove(struct buf *buf, unsigned int off, unsigned int len);
60+
int buf_cmp(const struct buf *, const struct buf *);
61+
int buf_findchar(const struct buf *, unsigned int off, int c);
62+
int buf_findline(const struct buf *buf, const char *line);
63+
void buf_init_ro(struct buf *buf, const char *base, size_t len);
64+
void buf_initm(struct buf *buf, char *base, int len);
65+
void buf_initmcstr(struct buf *buf, char *str);
66+
void buf_init_ro_cstr(struct buf *buf, const char *str);
67+
void buf_refresh_mmap(struct buf *buf, int onceonly, int fd,
68+
const char *fname, size_t size, const char *mboxname);
69+
void buf_free(struct buf *buf);
70+
void buf_move(struct buf *dst, struct buf *src);
71+
const char *buf_lcase(struct buf *buf);
72+
const char *buf_ucase(struct buf *buf);
73+
const char *buf_tocrlf(struct buf *buf);
74+
void buf_trim(struct buf *buf);
75+
76+
#endif /* CYRUS_BUF_H */

lib/charset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#define MIME_MAX_HEADER_LENGTH 78
6969
#define MIME_MAX_LINE_LENGTH 998
7070

71-
#include "util.h"
71+
#include "buf.h"
7272
#include "xsha1.h"
7373

7474
#define charset_base64_len_unpadded(n) \

lib/util.h

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#define STDERR_FILENO 2 /* Standard error output. */
6666
#endif
6767

68+
#include "buf.h"
6869
#include "xmalloc.h"
6970

7071
/* version string printable in gdb tracking */
@@ -106,7 +107,6 @@ typedef unsigned short bit32;
106107
#endif
107108

108109
typedef unsigned long long int bit64;
109-
typedef unsigned long long int modseq_t;
110110
#define MODSEQ_FMT "%llu"
111111
#define atomodseq_t(s) strtoull(s, NULL, 10)
112112
char *modseqtoa(modseq_t modseq);
@@ -191,12 +191,6 @@ int strcmpnull(const char *a, const char *b);
191191
extern keyvalue *kv_bsearch (const char *key, keyvalue *kv, int nelem,
192192
int (*cmpf)(const char *s1, const char *s2));
193193

194-
/* Examine the name of a file, and return a single character
195-
* (as an int) that can be used as the name of a hash
196-
* directory. Caller is responsible for skipping any prefix
197-
* of the name.
198-
*/
199-
extern int dir_hash_c(const char *name, int full);
200194
/*
201195
* Like dir_hash_c() but builds the result as a single-byte
202196
* C string in the provided buffer, and returns the buffer,
@@ -279,80 +273,18 @@ extern int64_t now_ms(void);
279273

280274
extern clock_t sclock(void);
281275

282-
#define BUF_MMAP (1<<1)
283-
284-
struct buf {
285-
char *s;
286-
size_t len;
287-
size_t alloc;
288-
unsigned flags;
289-
};
290-
#define BUF_INITIALIZER { NULL, 0, 0, 0 }
291-
292-
#define buf_new() ((struct buf *) xzmalloc(sizeof(struct buf)))
293-
#define buf_destroy(b) do { buf_free((b)); free((b)); } while (0)
294-
#define buf_ensure(b, n) do { if ((b)->alloc < (b)->len + (n)) _buf_ensure((b), (n)); } while (0)
295-
#define buf_putc(b, c) do { buf_ensure((b), 1); (b)->s[(b)->len++] = (c); } while (0)
296-
297-
void _buf_ensure(struct buf *buf, size_t len);
298-
const char *buf_cstring(const struct buf *buf);
299-
const char *buf_cstringnull(const struct buf *buf);
300-
const char *buf_cstringnull_ifempty(const struct buf *buf);
301-
const char *buf_cstring_or_empty(const struct buf *buf);
302-
char *buf_newcstring(struct buf *buf);
303-
char *buf_release(struct buf *buf);
304-
char *buf_releasenull(struct buf *buf);
305-
void buf_getmap(struct buf *buf, const char **base, size_t *len);
306276
int buf_getline(struct buf *buf, FILE *fp);
307-
size_t buf_len(const struct buf *buf);
308-
const char *buf_base(const struct buf *buf);
309-
void buf_reset(struct buf *buf);
310277
void buf_truncate(struct buf *buf, ssize_t len);
311-
void buf_setcstr(struct buf *buf, const char *str);
312-
void buf_setmap(struct buf *buf, const char *base, size_t len);
313-
void buf_copy(struct buf *dst, const struct buf *src);
314-
void buf_append(struct buf *dst, const struct buf *src);
315-
void buf_appendcstr(struct buf *buf, const char *str);
316-
void buf_appendoverlap(struct buf *buf, const char *str);
317278
void buf_appendbit32(struct buf *buf, bit32 num);
318279
void buf_appendbit64(struct buf *buf, bit64 num);
319-
void buf_appendmap(struct buf *buf, const char *base, size_t len);
320-
void buf_cowappendmap(struct buf *buf, const char *base, unsigned int len);
321-
void buf_cowappendfree(struct buf *buf, char *base, unsigned int len);
322-
void buf_insert(struct buf *dst, unsigned int off, const struct buf *src);
323-
void buf_insertcstr(struct buf *buf, unsigned int off, const char *str);
324-
void buf_insertmap(struct buf *buf, unsigned int off, const char *base, int len);
325280
void buf_vprintf(struct buf *buf, const char *fmt, va_list args)
326281
__attribute__((format(printf, 2, 0)));
327-
void buf_printf(struct buf *buf, const char *fmt, ...)
328-
__attribute__((format(printf, 2, 3)));
329-
void buf_replace_buf(struct buf *buf, size_t offset, size_t length,
330-
const struct buf *replace);
331-
int buf_replace_all(struct buf *buf, const char *match,
332-
const char *replace);
333-
int buf_replace_char(struct buf *buf, char match, char replace);
334282
#ifdef ENABLE_REGEX
335283
int buf_replace_all_re(struct buf *buf, const regex_t *,
336284
const char *replace);
337285
int buf_replace_one_re(struct buf *buf, const regex_t *,
338286
const char *replace);
339287
#endif
340-
void buf_remove(struct buf *buf, unsigned int off, unsigned int len);
341-
int buf_cmp(const struct buf *, const struct buf *);
342-
int buf_findchar(const struct buf *, unsigned int off, int c);
343-
int buf_findline(const struct buf *buf, const char *line);
344-
void buf_init_ro(struct buf *buf, const char *base, size_t len);
345-
void buf_initm(struct buf *buf, char *base, int len);
346-
void buf_initmcstr(struct buf *buf, char *str);
347-
void buf_init_ro_cstr(struct buf *buf, const char *str);
348-
void buf_refresh_mmap(struct buf *buf, int onceonly, int fd,
349-
const char *fname, size_t size, const char *mboxname);
350-
void buf_free(struct buf *buf);
351-
void buf_move(struct buf *dst, struct buf *src);
352-
const char *buf_lcase(struct buf *buf);
353-
const char *buf_ucase(struct buf *buf);
354-
const char *buf_tocrlf(struct buf *buf);
355-
void buf_trim(struct buf *buf);
356288

357289
/*
358290
* Given a list of strings, terminated by (char *)NULL,

sieve/sieve_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
#define SIEVE_OK (0)
5252

5353
#include "arrayu64.h"
54+
#include "buf.h"
5455
#include "strarray.h"
55-
#include "util.h"
5656
#include "sieve/sieve_err.h"
5757

5858
/* external sieve types */

0 commit comments

Comments
 (0)