1
/* Copyright (c) 2005 PrimeBase Technologies GmbH
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* 2004-01-03 Paul McCullagh
24
#ifndef __xt_xtutil_h__
25
#define __xt_xtutil_h__
31
#define XT_CHECKSUM_1(sum) ((xtWord1) ((sum) ^ ((sum) >> 24) ^ ((sum) >> 16) ^ ((sum) >> 8)))
32
#define XT_CHECKSUM_2(sum) ((xtWord2) ((sum) ^ ((sum) >> 16)))
33
#define XT_CHECKSUM4_8(sum) ((xtWord4) (sum) ^ (xtWord4) ((sum) >> 32))
35
int xt_comp_log_pos(xtLogID id1, off_t off1, xtLogID id2, off_t off2);
36
xtWord8 xt_time_now(void);
37
void xt_free_nothing(struct XTThread *self, void *x);
38
xtWord4 xt_file_name_to_id(char *file_name);
39
xtBool xt_time_difference(register xtWord4 now, register xtWord4 then);
40
xtWord2 xt_get_checksum(xtWord1 *data, size_t len, u_int interval);
41
xtWord1 xt_get_checksum1(xtWord1 *data, size_t len);
42
xtWord4 xt_get_checksum4(xtWord1 *data, size_t len);
44
typedef struct XTDataBuffer {
47
} XTDataBufferRec, *XTDataBufferPtr;
49
xtBool xt_db_set_size(struct XTThread *self, XTDataBufferPtr db, size_t size);
51
#define XT_IB_DEFAULT_SIZE 512
53
typedef struct XTInfoBuffer {
55
XTDataBufferRec ib_db;
56
xtWord1 ib_data[XT_IB_DEFAULT_SIZE];
57
} XTInfoBufferRec, *XTInfoBufferPtr;
59
xtBool xt_ib_alloc(struct XTThread *self, XTInfoBufferPtr ib, size_t size);
60
void xt_ib_free(struct XTThread *self, XTInfoBufferPtr ib);
62
typedef struct XTBasicList {
67
} XTBasicListRec, *XTBasicListPtr;
69
xtBool xt_bl_set_size(struct XTThread *self, XTBasicListPtr wl, size_t size);
70
xtBool xt_bl_dup(struct XTThread *self, XTBasicListPtr from_bl, XTBasicListPtr to_bl);
71
xtBool xt_bl_append(struct XTThread *self, XTBasicListPtr wl, void *value);
72
void *xt_bl_last_item(XTBasicListPtr wl);
73
void *xt_bl_item_at(XTBasicListPtr wl, u_int i);
74
void xt_bl_free(struct XTThread *self, XTBasicListPtr wl);
76
typedef struct XTBasicQueue {
84
} XTBasicQueueRec, *XTBasicQueuePtr;
86
xtBool xt_bq_set_size(struct XTThread *self, XTBasicQueuePtr wq, size_t size);
87
void *xt_bq_get(XTBasicQueuePtr wq);
88
void xt_bq_next(XTBasicQueuePtr wq);
89
xtBool xt_bq_add(struct XTThread *self, XTBasicQueuePtr wl, void *value);
91
typedef struct XTStringBuffer {
95
} XTStringBufferRec, *XTStringBufferPtr;
97
void xt_sb_free(struct XTThread *self, XTStringBufferPtr db);
98
xtBool xt_sb_set_size(struct XTThread *self, XTStringBufferPtr db, size_t size);
99
xtBool xt_sb_concat_len(struct XTThread *self, XTStringBufferPtr dbuf, c_char *str, size_t len);
100
xtBool xt_sb_concat(struct XTThread *self, XTStringBufferPtr dbuf, c_char *str);
101
xtBool xt_sb_concat_char(struct XTThread *self, XTStringBufferPtr dbuf, int ch);
102
xtBool xt_sb_concat_int8(struct XTThread *self, XTStringBufferPtr dbuf, xtInt8 val);
103
char *xt_sb_take_cstring(XTStringBufferPtr dbuf);
104
xtBool xt_sb_concat_url_len(struct XTThread *self, XTStringBufferPtr dbuf, c_char *str, size_t len);
106
static inline size_t xt_align_size(size_t size, size_t align)
108
register size_t diff = size % align;
111
return size + align - diff;
115
static inline off_t xt_align_offset(off_t size, size_t align)
117
register off_t diff = size % (off_t) align;
120
return size + align - diff;