LibreOffice Module registry (master) 1
reflcnst.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <registry/types.hxx>
23
24#include <string.h>
25
26#define REGTYPE_IEEE_NATIVE 1
27
28extern const sal_uInt32 magic;
29extern const sal_uInt16 minorVersion;
30extern const sal_uInt16 majorVersion;
31
32#define OFFSET_MAGIC 0
33#define OFFSET_SIZE static_cast<sal_uInt32>(OFFSET_MAGIC + sizeof(magic))
34#define OFFSET_MINOR_VERSION static_cast<sal_uInt32>(OFFSET_SIZE + sizeof(sal_uInt32))
35#define OFFSET_MAJOR_VERSION static_cast<sal_uInt32>(OFFSET_MINOR_VERSION + sizeof(minorVersion))
36#define OFFSET_N_ENTRIES static_cast<sal_uInt32>(OFFSET_MAJOR_VERSION + sizeof(majorVersion))
37#define OFFSET_TYPE_SOURCE static_cast<sal_uInt32>(OFFSET_N_ENTRIES + sizeof(sal_uInt16))
38#define OFFSET_TYPE_CLASS static_cast<sal_uInt32>(OFFSET_TYPE_SOURCE + sizeof(sal_uInt16))
39#define OFFSET_THIS_TYPE static_cast<sal_uInt32>(OFFSET_TYPE_CLASS + sizeof(sal_uInt16))
40#define OFFSET_UIK static_cast<sal_uInt32>(OFFSET_THIS_TYPE + sizeof(sal_uInt16))
41#define OFFSET_DOKU static_cast<sal_uInt32>(OFFSET_UIK + sizeof(sal_uInt16))
42#define OFFSET_FILENAME static_cast<sal_uInt32>(OFFSET_DOKU + sizeof(sal_uInt16))
43
44#define OFFSET_N_SUPERTYPES static_cast<sal_uInt32>(OFFSET_FILENAME + sizeof(sal_uInt16))
45#define OFFSET_SUPERTYPES static_cast<sal_uInt32>(OFFSET_N_SUPERTYPES + sizeof(sal_uInt16))
46
47#define OFFSET_CP_SIZE static_cast<sal_uInt32>(OFFSET_SUPERTYPES + sizeof(sal_uInt16))
48#define OFFSET_CP static_cast<sal_uInt32>(OFFSET_CP_SIZE + sizeof(sal_uInt16))
49
50#define CP_OFFSET_ENTRY_SIZE 0
51#define CP_OFFSET_ENTRY_TAG static_cast<sal_uInt32>(CP_OFFSET_ENTRY_SIZE + sizeof(sal_uInt32))
52#define CP_OFFSET_ENTRY_DATA static_cast<sal_uInt32>(CP_OFFSET_ENTRY_TAG + sizeof(sal_uInt16))
53
54#define FIELD_OFFSET_ACCESS 0
55#define FIELD_OFFSET_NAME static_cast<sal_uInt32>(FIELD_OFFSET_ACCESS + sizeof(sal_uInt16))
56#define FIELD_OFFSET_TYPE static_cast<sal_uInt32>(FIELD_OFFSET_NAME + sizeof(sal_uInt16))
57#define FIELD_OFFSET_VALUE static_cast<sal_uInt32>(FIELD_OFFSET_TYPE + sizeof(sal_uInt16))
58#define FIELD_OFFSET_DOKU static_cast<sal_uInt32>(FIELD_OFFSET_VALUE + sizeof(sal_uInt16))
59#define FIELD_OFFSET_FILENAME static_cast<sal_uInt32>(FIELD_OFFSET_DOKU + sizeof(sal_uInt16))
60
61#define PARAM_OFFSET_TYPE 0
62#define PARAM_OFFSET_MODE static_cast<sal_uInt32>(PARAM_OFFSET_TYPE + sizeof(sal_uInt16))
63#define PARAM_OFFSET_NAME static_cast<sal_uInt32>(PARAM_OFFSET_MODE + sizeof(sal_uInt16))
64
65#define METHOD_OFFSET_SIZE 0
66#define METHOD_OFFSET_MODE static_cast<sal_uInt32>(METHOD_OFFSET_SIZE + sizeof(sal_uInt16))
67#define METHOD_OFFSET_NAME static_cast<sal_uInt32>(METHOD_OFFSET_MODE + sizeof(sal_uInt16))
68#define METHOD_OFFSET_RETURN static_cast<sal_uInt32>(METHOD_OFFSET_NAME + sizeof(sal_uInt16))
69#define METHOD_OFFSET_DOKU static_cast<sal_uInt32>(METHOD_OFFSET_RETURN + sizeof(sal_uInt16))
70#define METHOD_OFFSET_PARAM_COUNT static_cast<sal_uInt32>(METHOD_OFFSET_DOKU + sizeof(sal_uInt16))
71
72#define REFERENCE_OFFSET_TYPE 0
73#define REFERENCE_OFFSET_NAME static_cast<sal_uInt32>(REFERENCE_OFFSET_TYPE + sizeof(sal_uInt16))
74#define REFERENCE_OFFSET_DOKU static_cast<sal_uInt32>(REFERENCE_OFFSET_NAME + sizeof(sal_uInt16))
75#define REFERENCE_OFFSET_ACCESS static_cast<sal_uInt32>(REFERENCE_OFFSET_DOKU + sizeof(sal_uInt16))
76
78{
92};
93
94inline sal_uInt32 writeUINT16(sal_uInt8* buffer, sal_uInt16 v)
95{
96 buffer[0] = static_cast<sal_uInt8>((v >> 8) & 0xFF);
97 buffer[1] = static_cast<sal_uInt8>((v >> 0) & 0xFF);
98
99 return sizeof(sal_uInt16);
100}
101
102inline sal_uInt32 readUINT16(const sal_uInt8* buffer, sal_uInt16& v)
103{
104 //This is untainted data which comes from a controlled source
105 //so, using a byte-swapping pattern which coverity doesn't
106 //detect as such
107 //http://security.coverity.com/blog/2014/Apr/on-detecting-heartbleed-with-static-analysis.html
108 v = *buffer++; v <<= 8;
109 v |= *buffer;
110 return sizeof(sal_uInt16);
111}
112
113inline sal_uInt32 writeINT32(sal_uInt8* buffer, sal_Int32 v)
114{
115 buffer[0] = static_cast<sal_uInt8>((v >> 24) & 0xFF);
116 buffer[1] = static_cast<sal_uInt8>((v >> 16) & 0xFF);
117 buffer[2] = static_cast<sal_uInt8>((v >> 8) & 0xFF);
118 buffer[3] = static_cast<sal_uInt8>((v >> 0) & 0xFF);
119
120 return sizeof(sal_Int32);
121}
122
123inline sal_uInt32 readINT32(const sal_uInt8* buffer, sal_Int32& v)
124{
125 v = (
126 (buffer[0] << 24) |
127 (buffer[1] << 16) |
128 (buffer[2] << 8) |
129 (buffer[3] << 0)
130 );
131
132 return sizeof(sal_Int32);
133}
134
135inline sal_uInt32 writeUINT32(sal_uInt8* buffer, sal_uInt32 v)
136{
137 buffer[0] = static_cast<sal_uInt8>((v >> 24) & 0xFF);
138 buffer[1] = static_cast<sal_uInt8>((v >> 16) & 0xFF);
139 buffer[2] = static_cast<sal_uInt8>((v >> 8) & 0xFF);
140 buffer[3] = static_cast<sal_uInt8>((v >> 0) & 0xFF);
141
142 return sizeof(sal_uInt32);
143}
144
145inline sal_uInt32 readUINT32(const sal_uInt8* buffer, sal_uInt32& v)
146{
147 //This is untainted data which comes from a controlled source
148 //so, using a byte-swapping pattern which coverity doesn't
149 //detect as such
150 //http://security.coverity.com/blog/2014/Apr/on-detecting-heartbleed-with-static-analysis.html
151 v = *buffer++; v <<= 8;
152 v |= *buffer++; v <<= 8;
153 v |= *buffer++; v <<= 8;
154 v |= *buffer;
155 return sizeof(sal_uInt32);
156}
157
158inline sal_uInt32 writeUtf8(sal_uInt8* buffer, const char* v)
159{
160 sal_uInt32 size = strlen(v) + 1;
161
162 memcpy(buffer, v, size);
163
164 return size;
165}
166
167inline sal_uInt32 readUtf8(const sal_uInt8* buffer, char* v, sal_uInt32 maxSize)
168{
169 sal_uInt32 size = strlen(reinterpret_cast<const char*>(buffer)) + 1;
170 if(size > maxSize)
171 {
172 size = maxSize;
173 }
174
175 memcpy(v, buffer, size);
176
177 if (size == maxSize) v[size - 1] = '\0';
178
179 return size;
180}
181
182
183sal_uInt32 writeString(sal_uInt8* buffer, const sal_Unicode* v);
184sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* v, sal_uInt32 maxSize);
185
186sal_uInt32 UINT16StringLen(const sal_uInt8* wstring);
187
188/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
float v
size
sal_uInt32 writeString(sal_uInt8 *buffer, const sal_Unicode *v)
Definition: reflwrit.cxx:40
const sal_uInt32 magic
Definition: reflread.cxx:43
sal_uInt32 readUINT16(const sal_uInt8 *buffer, sal_uInt16 &v)
Definition: reflcnst.hxx:102
const sal_uInt16 majorVersion
Definition: reflread.cxx:45
sal_uInt32 writeUINT32(sal_uInt8 *buffer, sal_uInt32 v)
Definition: reflcnst.hxx:135
sal_uInt32 readString(const sal_uInt8 *buffer, sal_Unicode *v, sal_uInt32 maxSize)
Definition: reflwrit.cxx:54
sal_uInt32 readINT32(const sal_uInt8 *buffer, sal_Int32 &v)
Definition: reflcnst.hxx:123
sal_uInt32 readUINT32(const sal_uInt8 *buffer, sal_uInt32 &v)
Definition: reflcnst.hxx:145
sal_uInt32 writeINT32(sal_uInt8 *buffer, sal_Int32 v)
Definition: reflcnst.hxx:113
const sal_uInt16 minorVersion
Definition: reflread.cxx:44
sal_uInt32 UINT16StringLen(const sal_uInt8 *wstring)
Definition: reflwrit.cxx:29
CPInfoTag
Definition: reflcnst.hxx:78
@ CP_TAG_CONST_BYTE
Definition: reflcnst.hxx:81
@ CP_TAG_CONST_FLOAT
Definition: reflcnst.hxx:88
@ CP_TAG_CONST_DOUBLE
Definition: reflcnst.hxx:89
@ CP_TAG_CONST_UINT32
Definition: reflcnst.hxx:85
@ CP_TAG_CONST_UINT16
Definition: reflcnst.hxx:83
@ CP_TAG_CONST_INT64
Definition: reflcnst.hxx:86
@ CP_TAG_CONST_INT32
Definition: reflcnst.hxx:84
@ CP_TAG_CONST_INT16
Definition: reflcnst.hxx:82
@ CP_TAG_INVALID
Definition: reflcnst.hxx:79
@ CP_TAG_CONST_BOOL
Definition: reflcnst.hxx:80
@ CP_TAG_CONST_UINT64
Definition: reflcnst.hxx:87
@ CP_TAG_UTF8_NAME
Definition: reflcnst.hxx:91
@ CP_TAG_CONST_STRING
Definition: reflcnst.hxx:90
sal_uInt32 readUtf8(const sal_uInt8 *buffer, char *v, sal_uInt32 maxSize)
Definition: reflcnst.hxx:167
sal_uInt32 writeUINT16(sal_uInt8 *buffer, sal_uInt16 v)
Definition: reflcnst.hxx:94
sal_uInt32 writeUtf8(sal_uInt8 *buffer, const char *v)
Definition: reflcnst.hxx:158
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
@ RT_TYPE_BYTE
Definition: types.hxx:201
@ RT_TYPE_FLOAT
Definition: types.hxx:208
@ RT_TYPE_INT64
Definition: types.hxx:206
@ RT_TYPE_INT32
Definition: types.hxx:204
@ RT_TYPE_DOUBLE
Definition: types.hxx:209
@ RT_TYPE_NONE
Definition: types.hxx:199
@ RT_TYPE_UINT16
Definition: types.hxx:203
@ RT_TYPE_BOOL
Definition: types.hxx:200
@ RT_TYPE_STRING
Definition: types.hxx:210
@ RT_TYPE_UINT64
Definition: types.hxx:207
@ RT_TYPE_UINT32
Definition: types.hxx:205
@ RT_TYPE_INT16
Definition: types.hxx:202