~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbxt/src/util_xt.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2005 PrimeBase Technologies GmbH
 
2
 *
 
3
 * PrimeBase XT
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
18
 *
 
19
 * 2004-01-03   Paul McCullagh
 
20
 *
 
21
 * H&G2JCtL
 
22
 */
 
23
 
 
24
#ifndef __xt_xtutil_h__
 
25
#define __xt_xtutil_h__
 
26
 
 
27
#include <stddef.h>
 
28
 
 
29
#include "xt_defs.h"
 
30
 
 
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))
 
34
 
 
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);
 
43
 
 
44
typedef struct XTDataBuffer {
 
45
        size_t                  db_size;
 
46
        xtWord1                 *db_data;
 
47
} XTDataBufferRec, *XTDataBufferPtr;
 
48
 
 
49
xtBool xt_db_set_size(struct XTThread *self, XTDataBufferPtr db, size_t size);
 
50
 
 
51
#define XT_IB_DEFAULT_SIZE                      512
 
52
 
 
53
typedef struct XTInfoBuffer {
 
54
        xtBool                  ib_free;
 
55
        XTDataBufferRec ib_db;
 
56
        xtWord1                 ib_data[XT_IB_DEFAULT_SIZE];
 
57
} XTInfoBufferRec, *XTInfoBufferPtr;
 
58
 
 
59
xtBool  xt_ib_alloc(struct XTThread *self, XTInfoBufferPtr ib, size_t size);
 
60
void    xt_ib_free(struct XTThread *self, XTInfoBufferPtr ib);
 
61
 
 
62
typedef struct XTBasicList {
 
63
        u_int                   bl_item_size;
 
64
        u_int                   bl_size;
 
65
        u_int                   bl_count;
 
66
        xtWord1                 *bl_data;
 
67
} XTBasicListRec, *XTBasicListPtr;
 
68
 
 
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);
 
75
 
 
76
typedef struct XTBasicQueue {
 
77
        u_int                   bq_item_size;
 
78
        u_int                   bq_max_waste;
 
79
        u_int                   bq_item_inc;
 
80
        u_int                   bq_size;
 
81
        u_int                   bq_front;
 
82
        u_int                   bq_back;
 
83
        xtWord1                 *bq_data;
 
84
} XTBasicQueueRec, *XTBasicQueuePtr;
 
85
 
 
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);
 
90
 
 
91
typedef struct XTStringBuffer {
 
92
        size_t                  sb_size;
 
93
        size_t                  sb_len;
 
94
        char                    *sb_cstring;
 
95
} XTStringBufferRec, *XTStringBufferPtr;
 
96
 
 
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);
 
105
 
 
106
static inline size_t xt_align_size(size_t size, size_t align)
 
107
{
 
108
        register size_t diff = size % align;
 
109
        
 
110
        if (diff)
 
111
                return size + align - diff;
 
112
        return size;
 
113
}
 
114
 
 
115
static inline off_t xt_align_offset(off_t size, size_t align)
 
116
{
 
117
        register off_t diff = size % (off_t) align;
 
118
        
 
119
        if (diff)
 
120
                return size + align - diff;
 
121
        return size;
 
122
}
 
123
 
 
124
#endif