LibreOffice Module registry (master)  1
reflread.cxx
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 #include <sal/config.h>
21 
22 #include <cstring>
23 #include <memory>
24 #include <new>
25 #include <vector>
26 
27 #include <sal/types.h>
28 #include <osl/endian.h>
29 #include <osl/diagnose.h>
30 #include "reflread.hxx"
31 #include <sal/log.hxx>
32 
34 #include <registry/version.h>
35 
36 #include "reflcnst.hxx"
37 
38 #include <cstddef>
39 
40 const char NULL_STRING[1] = { 0 };
41 const sal_Unicode NULL_WSTRING[1] = { 0 };
42 
43 const sal_uInt32 magic = 0x12345678;
44 const sal_uInt16 minorVersion = 0x0000;
45 const sal_uInt16 majorVersion = 0x0001;
46 
47 /**************************************************************************
48 
49  class BlopObject
50 
51  holds any data in a flat memory buffer
52 
53 **************************************************************************/
54 
55 namespace {
56 
57 class BlopObject
58 {
59 public:
60  struct BoundsError {};
61 
62  const sal_uInt8* m_pBuffer;
63  sal_uInt32 m_bufferLen;
64 
65  BlopObject(const sal_uInt8* buffer, sal_uInt32 len);
66  // throws std::bad_alloc
67 
68  sal_uInt8 readBYTE(sal_uInt32 index) const
69  {
70  if (index >= m_bufferLen) {
71  throw BoundsError();
72  }
73  return m_pBuffer[index];
74  }
75 
76  sal_Int16 readINT16(sal_uInt32 index) const
77  {
78  if (m_bufferLen < 2 || index >= m_bufferLen - 1) {
79  throw BoundsError();
80  }
81  return ((m_pBuffer[index] << 8) | (m_pBuffer[index+1] << 0));
82  }
83 
84  sal_uInt16 readUINT16(sal_uInt32 index) const
85  {
86  if (m_bufferLen < 2 || index >= m_bufferLen - 1) {
87  throw BoundsError();
88  }
89  return ((m_pBuffer[index] << 8) | (m_pBuffer[index+1] << 0));
90  }
91 
92  sal_Int32 readINT32(sal_uInt32 index) const
93  {
94  if (m_bufferLen < 4 || index >= m_bufferLen - 3) {
95  throw BoundsError();
96  }
97  return (
98  (m_pBuffer[index] << 24) |
99  (m_pBuffer[index+1] << 16) |
100  (m_pBuffer[index+2] << 8) |
101  (m_pBuffer[index+3] << 0)
102  );
103  }
104 
105  sal_uInt32 readUINT32(sal_uInt32 index) const
106  {
107  if (m_bufferLen < 4 || index >= m_bufferLen - 3) {
108  throw BoundsError();
109  }
110  return (
111  (m_pBuffer[index] << 24) |
112  (m_pBuffer[index+1] << 16) |
113  (m_pBuffer[index+2] << 8) |
114  (m_pBuffer[index+3] << 0)
115  );
116  }
117 
118  sal_Int64 readINT64(sal_uInt32 index) const
119  {
120  if (m_bufferLen < 8 || index >= m_bufferLen - 7) {
121  throw BoundsError();
122  }
123  return (
124  (static_cast<sal_Int64>(m_pBuffer[index]) << 56) |
125  (static_cast<sal_Int64>(m_pBuffer[index+1]) << 48) |
126  (static_cast<sal_Int64>(m_pBuffer[index+2]) << 40) |
127  (static_cast<sal_Int64>(m_pBuffer[index+3]) << 32) |
128  (static_cast<sal_Int64>(m_pBuffer[index+4]) << 24) |
129  (static_cast<sal_Int64>(m_pBuffer[index+5]) << 16) |
130  (static_cast<sal_Int64>(m_pBuffer[index+6]) << 8) |
131  (static_cast<sal_Int64>(m_pBuffer[index+7]) << 0)
132  );
133  }
134 
135  sal_uInt64 readUINT64(sal_uInt32 index) const
136  {
137  if (m_bufferLen < 8 || index >= m_bufferLen - 7) {
138  throw BoundsError();
139  }
140  return (
141  (static_cast<sal_uInt64>(m_pBuffer[index]) << 56) |
142  (static_cast<sal_uInt64>(m_pBuffer[index+1]) << 48) |
143  (static_cast<sal_uInt64>(m_pBuffer[index+2]) << 40) |
144  (static_cast<sal_uInt64>(m_pBuffer[index+3]) << 32) |
145  (static_cast<sal_uInt64>(m_pBuffer[index+4]) << 24) |
146  (static_cast<sal_uInt64>(m_pBuffer[index+5]) << 16) |
147  (static_cast<sal_uInt64>(m_pBuffer[index+6]) << 8) |
148  (static_cast<sal_uInt64>(m_pBuffer[index+7]) << 0)
149  );
150  }
151 };
152 
153 }
154 
155 BlopObject::BlopObject(const sal_uInt8* buffer, sal_uInt32 len)
156  : m_bufferLen(len)
157 {
158  m_pBuffer = buffer;
159 }
160 
161 /**************************************************************************
162 
163  class StringCache
164 
165 **************************************************************************/
166 
167 namespace {
168 
169 class StringCache
170 {
171 public:
172  std::vector<std::unique_ptr<sal_Unicode[]>> m_stringTable;
173  sal_uInt16 m_stringsCopied;
174 
175  explicit StringCache(sal_uInt16 size); // throws std::bad_alloc
176 
177  const sal_Unicode* getString(sal_uInt16 index) const;
178  sal_uInt16 createString(const sal_uInt8* buffer); // throws std::bad_alloc
179 };
180 
181 }
182 
183 StringCache::StringCache(sal_uInt16 size)
184  : m_stringTable(size)
185  , m_stringsCopied(0)
186 {
187 }
188 
189 const sal_Unicode* StringCache::getString(sal_uInt16 index) const
190 {
191  if ((index > 0) && (index <= m_stringsCopied))
192  return m_stringTable[index - 1].get();
193  else
194  return nullptr;
195 }
196 
197 sal_uInt16 StringCache::createString(const sal_uInt8* buffer)
198 {
199  if (m_stringsCopied < m_stringTable.size())
200  {
201  sal_uInt32 len = UINT16StringLen(buffer);
202 
203  m_stringTable[m_stringsCopied].reset( new sal_Unicode[len + 1] );
204 
205  readString(buffer, m_stringTable[m_stringsCopied].get(), (len + 1) * sizeof(sal_Unicode));
206 
207  return ++m_stringsCopied;
208  }
209  else
210  return 0;
211 }
212 
213 /**************************************************************************
214 
215  class ConstantPool
216 
217 **************************************************************************/
218 
219 namespace {
220 
221 class ConstantPool : public BlopObject
222 {
223 public:
224 
225  sal_uInt16 m_numOfEntries;
226  std::unique_ptr<sal_Int32[]> m_pIndex; // index values may be < 0 for cached string constants
227 
228  std::unique_ptr<StringCache> m_pStringCache;
229 
230  ConstantPool(const sal_uInt8* buffer, sal_uInt32 len, sal_uInt16 numEntries)
231  : BlopObject(buffer, len)
232  , m_numOfEntries(numEntries)
233  {
234  }
235 
236  sal_uInt32 parseIndex(); // throws std::bad_alloc
237 
238  CPInfoTag readTag(sal_uInt16 index) const;
239 
240  const char* readUTF8NameConstant(sal_uInt16 index) const;
241  bool readBOOLConstant(sal_uInt16 index) const;
242  sal_Int8 readBYTEConstant(sal_uInt16 index) const;
243  sal_Int16 readINT16Constant(sal_uInt16 index) const;
244  sal_uInt16 readUINT16Constant(sal_uInt16 index) const;
245  sal_Int32 readINT32Constant(sal_uInt16 index) const;
246  sal_uInt32 readUINT32Constant(sal_uInt16 index) const;
247  sal_Int64 readINT64Constant(sal_uInt16 index) const;
248  sal_uInt64 readUINT64Constant(sal_uInt16 index) const;
249  float readFloatConstant(sal_uInt16 index) const;
250  double readDoubleConstant(sal_uInt16 index) const;
251  const sal_Unicode* readStringConstant(sal_uInt16 index) const;
252  // throws std::bad_alloc
253 };
254 
255 }
256 
257 sal_uInt32 ConstantPool::parseIndex()
258 {
259  m_pIndex.reset();
260  m_pStringCache.reset();
261 
262  sal_uInt32 offset = 0;
263  sal_uInt16 numOfStrings = 0;
264 
265  if (m_numOfEntries)
266  {
267  m_pIndex.reset( new sal_Int32[m_numOfEntries] );
268 
269  for (int i = 0; i < m_numOfEntries; i++)
270  {
271  m_pIndex[i] = offset;
272 
273  offset += readUINT32(offset);
274 
275  if ( static_cast<CPInfoTag>(readUINT16(m_pIndex[i] + CP_OFFSET_ENTRY_TAG)) ==
277  {
278  numOfStrings++;
279  }
280 
281  }
282  }
283 
284  if (numOfStrings)
285  {
286  m_pStringCache.reset( new StringCache(numOfStrings) );
287  }
288 
289  m_bufferLen = offset;
290 
291  return offset;
292 }
293 
294 CPInfoTag ConstantPool::readTag(sal_uInt16 index) const
295 {
297 
298  if (m_pIndex && (index > 0) && (index <= m_numOfEntries))
299  {
300  tag = static_cast<CPInfoTag>(readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG));
301  }
302 
303  return tag;
304 }
305 
306 const char* ConstantPool::readUTF8NameConstant(sal_uInt16 index) const
307 {
308  const char* aName = NULL_STRING;
309 
310  if (m_pIndex && (index > 0) && (index <= m_numOfEntries))
311  {
312  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_UTF8_NAME)
313  {
314  sal_uInt32 n = m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA;
315  if (n < m_bufferLen
316  && std::memchr(m_pBuffer + n, 0, m_bufferLen - n) != nullptr)
317  {
318  aName = reinterpret_cast<const char*>(m_pBuffer + n);
319  }
320  }
321  }
322 
323  return aName;
324 }
325 
326 bool ConstantPool::readBOOLConstant(sal_uInt16 index) const
327 {
328  bool aBool = false;
329 
330  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
331  {
332  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_BOOL)
333  {
334  aBool = readBYTE(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA) != 0;
335  }
336  }
337 
338  return aBool;
339 }
340 
341 sal_Int8 ConstantPool::readBYTEConstant(sal_uInt16 index) const
342 {
343  sal_Int8 aByte = 0;
344 
345  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
346  {
347  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_BYTE)
348  {
349  aByte = static_cast< sal_Int8 >(
350  readBYTE(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA));
351  }
352  }
353 
354  return aByte;
355 }
356 
357 sal_Int16 ConstantPool::readINT16Constant(sal_uInt16 index) const
358 {
359  sal_Int16 aINT16 = 0;
360 
361  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
362  {
363  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_INT16)
364  {
365  aINT16 = readINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
366  }
367  }
368 
369  return aINT16;
370 }
371 
372 sal_uInt16 ConstantPool::readUINT16Constant(sal_uInt16 index) const
373 {
374  sal_uInt16 asal_uInt16 = 0;
375 
376  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
377  {
378  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_UINT16)
379  {
380  asal_uInt16 = readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
381  }
382  }
383 
384  return asal_uInt16;
385 }
386 
387 sal_Int32 ConstantPool::readINT32Constant(sal_uInt16 index) const
388 {
389  sal_Int32 aINT32 = 0;
390 
391  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
392  {
393  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_INT32)
394  {
395  aINT32 = readINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
396  }
397  }
398 
399  return aINT32;
400 }
401 
402 sal_uInt32 ConstantPool::readUINT32Constant(sal_uInt16 index) const
403 {
404  sal_uInt32 aUINT32 = 0;
405 
406  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
407  {
408  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_UINT32)
409  {
410  aUINT32 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
411  }
412  }
413 
414  return aUINT32;
415 }
416 
417 sal_Int64 ConstantPool::readINT64Constant(sal_uInt16 index) const
418 {
419  sal_Int64 aINT64 = 0;
420 
421  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
422  {
423  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_INT64)
424  {
425  aINT64 = readINT64(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
426  }
427  }
428 
429  return aINT64;
430 }
431 
432 sal_uInt64 ConstantPool::readUINT64Constant(sal_uInt16 index) const
433 {
434  sal_uInt64 aUINT64 = 0;
435 
436  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
437  {
438  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_UINT64)
439  {
440  aUINT64 = readUINT64(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
441  }
442  }
443 
444  return aUINT64;
445 }
446 
447 float ConstantPool::readFloatConstant(sal_uInt16 index) const
448 {
449  union
450  {
451  float v;
452  sal_uInt32 b;
453  } x = { 0.0f };
454 
455  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
456  {
457  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_FLOAT)
458  {
459 #ifdef REGTYPE_IEEE_NATIVE
460  x.b = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
461 #else
462 # error no IEEE
463 #endif
464  }
465  }
466 
467  return x.v;
468 }
469 
470 double ConstantPool::readDoubleConstant(sal_uInt16 index) const
471 {
472  union
473  {
474  double v;
475  struct
476  {
477  sal_uInt32 b1;
478  sal_uInt32 b2;
479  } b;
480  } x = { 0.0 };
481 
482  if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
483  {
484  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_DOUBLE)
485  {
486 
487 #ifdef REGTYPE_IEEE_NATIVE
488 # ifdef OSL_BIGENDIAN
489  x.b.b1 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
490  x.b.b2 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA + sizeof(sal_uInt32));
491 # else
492  x.b.b1 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA + sizeof(sal_uInt32));
493  x.b.b2 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
494 # endif
495 #else
496 # error no IEEE
497 #endif
498  }
499  }
500 
501  return x.v;
502 }
503 
504 const sal_Unicode* ConstantPool::readStringConstant(sal_uInt16 index) const
505 {
506  const sal_Unicode* aString = NULL_WSTRING;
507 
508  if (m_pIndex && (index> 0) && (index <= m_numOfEntries) && m_pStringCache)
509  {
510  if (m_pIndex[index - 1] >= 0)
511  {
512  // create cached string now
513 
514  if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_STRING)
515  {
516  sal_uInt32 n = m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA;
517  if (n >= m_bufferLen
518  || (std::memchr(m_pBuffer + n, 0, m_bufferLen - n)
519  == nullptr))
520  {
521  throw BoundsError();
522  }
523  m_pIndex[index - 1] = -1 * m_pStringCache->createString(m_pBuffer + n);
524  }
525  }
526 
527  aString = m_pStringCache->getString(static_cast<sal_uInt16>(m_pIndex[index - 1] * -1));
528  }
529 
530  return aString;
531 }
532 
533 /**************************************************************************
534 
535  class FieldList
536 
537 **************************************************************************/
538 
539 namespace {
540 
541 class FieldList : public BlopObject
542 {
543 public:
544 
545  sal_uInt16 m_numOfEntries;
546  size_t m_FIELD_ENTRY_SIZE;
547  ConstantPool* m_pCP;
548 
549  FieldList(const sal_uInt8* buffer, sal_uInt32 len, sal_uInt16 numEntries, ConstantPool* pCP)
550  : BlopObject(buffer, len)
551  , m_numOfEntries(numEntries)
552  , m_pCP(pCP)
553  {
554  if ( m_numOfEntries > 0 )
555  {
556  sal_uInt16 numOfFieldEntries = readUINT16(0);
557  m_FIELD_ENTRY_SIZE = numOfFieldEntries * sizeof(sal_uInt16);
558  } else
559  {
560  m_FIELD_ENTRY_SIZE = 0;
561  }
562  }
563 
564  sal_uInt32 parseIndex() const { return ((m_numOfEntries ? sizeof(sal_uInt16) : 0) + (m_numOfEntries * m_FIELD_ENTRY_SIZE));}
565 
566  const char* getFieldName(sal_uInt16 index) const;
567  const char* getFieldType(sal_uInt16 index) const;
568  RTFieldAccess getFieldAccess(sal_uInt16 index) const;
569  RTValueType getFieldConstValue(sal_uInt16 index, RTConstValueUnion* value) const;
570  // throws std::bad_alloc
571  const char* getFieldDoku(sal_uInt16 index) const;
572  const char* getFieldFileName(sal_uInt16 index) const;
573 };
574 
575 }
576 
577 const char* FieldList::getFieldName(sal_uInt16 index) const
578 {
579  const char* aName = nullptr;
580 
581  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
582  {
583  try {
584  aName = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_NAME));
585  } catch (BlopObject::BoundsError &) {
586  SAL_WARN("registry", "bad data");
587  }
588  }
589 
590  return aName;
591 }
592 
593 const char* FieldList::getFieldType(sal_uInt16 index) const
594 {
595  const char* aName = nullptr;
596 
597  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
598  {
599  try {
600  aName = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_TYPE));
601  } catch (BlopObject::BoundsError &) {
602  SAL_WARN("registry", "bad data");
603  }
604  }
605 
606  return aName;
607 }
608 
609 RTFieldAccess FieldList::getFieldAccess(sal_uInt16 index) const
610 {
612 
613  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
614  {
615  try {
616  aAccess = static_cast<RTFieldAccess>(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_ACCESS));
617  } catch (BlopObject::BoundsError &) {
618  SAL_WARN("registry", "bad data");
619  }
620  }
621 
622  return aAccess;
623 }
624 
625 RTValueType FieldList::getFieldConstValue(sal_uInt16 index, RTConstValueUnion* value) const
626 {
628  try {
629  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
630  {
631  sal_uInt16 cpIndex = readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_VALUE);
632  switch (m_pCP->readTag(cpIndex))
633  {
634  case CP_TAG_CONST_BOOL:
635  value->aBool = m_pCP->readBOOLConstant(cpIndex);
636  ret = RT_TYPE_BOOL;
637  break;
638  case CP_TAG_CONST_BYTE:
639  value->aByte = m_pCP->readBYTEConstant(cpIndex);
640  ret = RT_TYPE_BYTE;
641  break;
642  case CP_TAG_CONST_INT16:
643  value->aShort = m_pCP->readINT16Constant(cpIndex);
644  ret = RT_TYPE_INT16;
645  break;
646  case CP_TAG_CONST_UINT16:
647  value->aUShort = m_pCP->readUINT16Constant(cpIndex);
648  ret = RT_TYPE_UINT16;
649  break;
650  case CP_TAG_CONST_INT32:
651  value->aLong = m_pCP->readINT32Constant(cpIndex);
652  ret = RT_TYPE_INT32;
653  break;
654  case CP_TAG_CONST_UINT32:
655  value->aULong = m_pCP->readUINT32Constant(cpIndex);
656  ret = RT_TYPE_UINT32;
657  break;
658  case CP_TAG_CONST_INT64:
659  value->aHyper = m_pCP->readINT64Constant(cpIndex);
660  ret = RT_TYPE_INT64;
661  break;
662  case CP_TAG_CONST_UINT64:
663  value->aUHyper = m_pCP->readUINT64Constant(cpIndex);
664  ret = RT_TYPE_UINT64;
665  break;
666  case CP_TAG_CONST_FLOAT:
667  value->aFloat = m_pCP->readFloatConstant(cpIndex);
668  ret = RT_TYPE_FLOAT;
669  break;
670  case CP_TAG_CONST_DOUBLE:
671  value->aDouble = m_pCP->readDoubleConstant(cpIndex);
672  ret = RT_TYPE_DOUBLE;
673  break;
674  case CP_TAG_CONST_STRING:
675  value->aString = m_pCP->readStringConstant(cpIndex);
676  ret = RT_TYPE_STRING;
677  break;
678  default:
679  break;
680  }
681  }
682  } catch (BlopObject::BoundsError &) {
683  SAL_WARN("registry", "bad data");
684  }
685  return ret;
686 }
687 
688 const char* FieldList::getFieldDoku(sal_uInt16 index) const
689 {
690  const char* aDoku = nullptr;
691 
692  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
693  {
694  try {
695  aDoku = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_DOKU));
696  } catch (BlopObject::BoundsError &) {
697  SAL_WARN("registry", "bad data");
698  }
699  }
700 
701  return aDoku;
702 }
703 
704 const char* FieldList::getFieldFileName(sal_uInt16 index) const
705 {
706  const char* aFileName = nullptr;
707 
708  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
709  {
710  try {
711  aFileName = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_FILENAME));
712  } catch (BlopObject::BoundsError &) {
713  SAL_WARN("registry", "bad data");
714  }
715  }
716 
717  return aFileName;
718 }
719 
720 /**************************************************************************
721 
722  class ReferenceList
723 
724 **************************************************************************/
725 
726 namespace {
727 
728 class ReferenceList : public BlopObject
729 {
730 public:
731 
732  sal_uInt16 m_numOfEntries;
733  size_t m_REFERENCE_ENTRY_SIZE;
734  ConstantPool* m_pCP;
735 
736  ReferenceList(const sal_uInt8* buffer, sal_uInt32 len, sal_uInt16 numEntries, ConstantPool* pCP)
737  : BlopObject(buffer, len)
738  , m_numOfEntries(numEntries)
739  , m_pCP(pCP)
740  {
741  if ( m_numOfEntries > 0 )
742  {
743  sal_uInt16 numOfReferenceEntries = readUINT16(0);
744  m_REFERENCE_ENTRY_SIZE = numOfReferenceEntries * sizeof(sal_uInt16);
745  } else
746  {
747  m_REFERENCE_ENTRY_SIZE = 0;
748  }
749  }
750 
751  const char* getReferenceName(sal_uInt16 index) const;
752  RTReferenceType getReferenceType(sal_uInt16 index) const;
753  const char* getReferenceDoku(sal_uInt16 index) const;
754  RTFieldAccess getReferenceAccess(sal_uInt16 index) const;
755 };
756 
757 }
758 
759 const char* ReferenceList::getReferenceName(sal_uInt16 index) const
760 {
761  const char* aName = nullptr;
762 
763  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
764  {
765  try {
766  aName = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_NAME));
767  } catch (BlopObject::BoundsError &) {
768  SAL_WARN("registry", "bad data");
769  }
770  }
771 
772  return aName;
773 }
774 
775 RTReferenceType ReferenceList::getReferenceType(sal_uInt16 index) const
776 {
778 
779  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
780  {
781  try {
782  refType = static_cast<RTReferenceType>(readUINT16(sizeof(sal_uInt16) + (index * m_REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_TYPE));
783  } catch (BlopObject::BoundsError &) {
784  SAL_WARN("registry", "bad data");
785  }
786  }
787 
788  return refType;
789 }
790 
791 const char* ReferenceList::getReferenceDoku(sal_uInt16 index) const
792 {
793  const char* aDoku = nullptr;
794 
795  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
796  {
797  try {
798  aDoku = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_DOKU));
799  } catch (BlopObject::BoundsError &) {
800  SAL_WARN("registry", "bad data");
801  }
802  }
803 
804  return aDoku;
805 }
806 
807 RTFieldAccess ReferenceList::getReferenceAccess(sal_uInt16 index) const
808 {
810 
811  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
812  {
813  try {
814  aAccess = static_cast<RTFieldAccess>(readUINT16(sizeof(sal_uInt16) + (index * m_REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_ACCESS));
815  } catch (BlopObject::BoundsError &) {
816  SAL_WARN("registry", "bad data");
817  }
818  }
819 
820  return aAccess;
821 }
822 
823 /**************************************************************************
824 
825  class MethodList
826 
827 **************************************************************************/
828 
829 namespace {
830 
831 class MethodList : public BlopObject
832 {
833 public:
834 
835  sal_uInt16 m_numOfEntries;
836  size_t m_PARAM_ENTRY_SIZE;
837  std::unique_ptr<sal_uInt32[]> m_pIndex;
838  ConstantPool* m_pCP;
839 
840  MethodList(const sal_uInt8* buffer, sal_uInt32 len, sal_uInt16 numEntries, ConstantPool* pCP)
841  : BlopObject(buffer, len)
842  , m_numOfEntries(numEntries)
843  , m_pCP(pCP)
844  {
845  if ( m_numOfEntries > 0 )
846  {
847  readUINT16(0) /* numOfMethodEntries */;
848  sal_uInt16 numOfParamEntries = readUINT16(sizeof(sal_uInt16));
849  m_PARAM_ENTRY_SIZE = numOfParamEntries * sizeof(sal_uInt16);
850  } else
851  {
852  m_PARAM_ENTRY_SIZE = 0;
853  }
854  }
855 
856  sal_uInt32 parseIndex(); // throws std::bad_alloc
857 
858  const char* getMethodName(sal_uInt16 index) const;
859  sal_uInt16 getMethodParamCount(sal_uInt16 index) const;
860  const char* getMethodParamType(sal_uInt16 index, sal_uInt16 paramIndex) const;
861  const char* getMethodParamName(sal_uInt16 index, sal_uInt16 paramIndex) const;
862  RTParamMode getMethodParamMode(sal_uInt16 index, sal_uInt16 paramIndex) const;
863  sal_uInt16 getMethodExcCount(sal_uInt16 index) const;
864  const char* getMethodExcType(sal_uInt16 index, sal_uInt16 excIndex) const;
865  const char* getMethodReturnType(sal_uInt16 index) const;
866  RTMethodMode getMethodMode(sal_uInt16 index) const;
867  const char* getMethodDoku(sal_uInt16 index) const;
868 
869 private:
870  sal_uInt16 calcMethodParamIndex( const sal_uInt16 index ) const;
871 };
872 
873 }
874 
875 sal_uInt16 MethodList::calcMethodParamIndex( const sal_uInt16 index ) const
876 {
877  return (METHOD_OFFSET_PARAM_COUNT + sizeof(sal_uInt16) + (index * m_PARAM_ENTRY_SIZE));
878 }
879 
880 sal_uInt32 MethodList::parseIndex()
881 {
882  m_pIndex.reset();
883 
884  sal_uInt32 offset = 0;
885 
886  if (m_numOfEntries)
887  {
888  offset = 2 * sizeof(sal_uInt16);
889  m_pIndex.reset( new sal_uInt32[m_numOfEntries] );
890 
891  for (int i = 0; i < m_numOfEntries; i++)
892  {
893  m_pIndex[i] = offset;
894 
895  offset += readUINT16(offset);
896  }
897  }
898 
899  return offset;
900 }
901 
902 const char* MethodList::getMethodName(sal_uInt16 index) const
903 {
904  const char* aName = nullptr;
905 
906  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
907  {
908  try {
909  aName = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_NAME));
910  } catch (BlopObject::BoundsError &) {
911  SAL_WARN("registry", "bad data");
912  }
913  }
914 
915  return aName;
916 }
917 
918 sal_uInt16 MethodList::getMethodParamCount(sal_uInt16 index) const
919 {
920  sal_uInt16 aCount = 0;
921 
922  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
923  {
924  try {
925  aCount = readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT);
926  } catch (BlopObject::BoundsError &) {
927  SAL_WARN("registry", "bad data");
928  }
929  }
930 
931  return aCount;
932 }
933 
934 const char* MethodList::getMethodParamType(sal_uInt16 index, sal_uInt16 paramIndex) const
935 {
936  const char* aName = nullptr;
937  try {
938  if ((m_numOfEntries > 0) &&
939  (index <= m_numOfEntries) &&
940  (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)))
941  {
942  aName = m_pCP->readUTF8NameConstant(
943  readUINT16(
944  m_pIndex[index] +
945  calcMethodParamIndex(paramIndex) +
947  }
948  } catch (BlopObject::BoundsError &) {
949  SAL_WARN("registry", "bad data");
950  }
951  return aName;
952 }
953 
954 const char* MethodList::getMethodParamName(sal_uInt16 index, sal_uInt16 paramIndex) const
955 {
956  const char* aName = nullptr;
957  try {
958  if ((m_numOfEntries > 0) &&
959  (index <= m_numOfEntries) &&
960  (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)))
961  {
962  aName = m_pCP->readUTF8NameConstant(
963  readUINT16(
964  m_pIndex[index] +
965  calcMethodParamIndex(paramIndex) +
967  }
968  } catch (BlopObject::BoundsError &) {
969  SAL_WARN("registry", "bad data");
970  }
971  return aName;
972 }
973 
974 RTParamMode MethodList::getMethodParamMode(sal_uInt16 index, sal_uInt16 paramIndex) const
975 {
977  try {
978  if ((m_numOfEntries > 0) &&
979  (index <= m_numOfEntries) &&
980  (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)))
981  {
982  aMode = static_cast<RTParamMode>(readUINT16(
983  m_pIndex[index] +
984  calcMethodParamIndex(paramIndex) +
986  }
987  } catch (BlopObject::BoundsError &) {
988  SAL_WARN("registry", "bad data");
989  }
990  return aMode;
991 }
992 
993 #if defined(__COVERITY__)
994 extern "C" void __coverity_tainted_data_sanitize__(void *);
995 #endif
996 
997 sal_uInt16 MethodList::getMethodExcCount(sal_uInt16 index) const
998 {
999  sal_uInt16 aCount = 0;
1000 
1001  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1002  {
1003  try {
1004  aCount = readUINT16(m_pIndex[index] + calcMethodParamIndex(readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)));
1005 #if defined(__COVERITY__)
1006  __coverity_tainted_data_sanitize__(&aCount);
1007 #endif
1008  } catch (BlopObject::BoundsError &) {
1009  SAL_WARN("registry", "bad data");
1010  }
1011  }
1012 
1013  return aCount;
1014 }
1015 
1016 const char* MethodList::getMethodExcType(sal_uInt16 index, sal_uInt16 excIndex) const
1017 {
1018  const char* aName = nullptr;
1019 
1020  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1021  {
1022  try {
1023  sal_uInt32 excOffset = m_pIndex[index] + calcMethodParamIndex(readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT));
1024  if (excIndex <= readUINT16(excOffset))
1025  {
1026  aName = m_pCP->readUTF8NameConstant(
1027  readUINT16(
1028  excOffset +
1029  sizeof(sal_uInt16) +
1030  (excIndex * sizeof(sal_uInt16))));
1031  }
1032  } catch (BlopObject::BoundsError &) {
1033  SAL_WARN("registry", "bad data");
1034  }
1035  }
1036 
1037  return aName;
1038 }
1039 
1040 const char* MethodList::getMethodReturnType(sal_uInt16 index) const
1041 {
1042  const char* aName = nullptr;
1043 
1044  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1045  {
1046  try {
1047  aName = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_RETURN));
1048  } catch (BlopObject::BoundsError &) {
1049  SAL_WARN("registry", "bad data");
1050  }
1051  }
1052 
1053  return aName;
1054 }
1055 
1056 RTMethodMode MethodList::getMethodMode(sal_uInt16 index) const
1057 {
1059 
1060  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1061  {
1062  try {
1063  aMode = static_cast<RTMethodMode>(readUINT16(m_pIndex[index] + METHOD_OFFSET_MODE));
1064  } catch (BlopObject::BoundsError &) {
1065  SAL_WARN("registry", "bad data");
1066  }
1067  }
1068 
1069  return aMode;
1070 }
1071 
1072 const char* MethodList::getMethodDoku(sal_uInt16 index) const
1073 {
1074  const char* aDoku = nullptr;
1075 
1076  if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1077  {
1078  try {
1079  aDoku = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_DOKU));
1080  } catch (BlopObject::BoundsError &) {
1081  SAL_WARN("registry", "bad data");
1082  }
1083  }
1084 
1085  return aDoku;
1086 }
1087 
1088 /**************************************************************************
1089 
1090  class TypeRegistryEntry
1091 
1092 **************************************************************************/
1093 
1094 namespace {
1095 
1096 class TypeRegistryEntry: public BlopObject {
1097 public:
1098  std::unique_ptr<ConstantPool> m_pCP;
1099  std::unique_ptr<FieldList> m_pFields;
1100  std::unique_ptr<MethodList> m_pMethods;
1101  std::unique_ptr<ReferenceList> m_pReferences;
1102  sal_uInt32 m_refCount;
1103  sal_uInt16 m_nSuperTypes;
1104  sal_uInt32 m_offset_SUPERTYPES;
1105 
1106  TypeRegistryEntry(
1107  const sal_uInt8* buffer, sal_uInt32 len);
1108  // throws std::bad_alloc
1109 
1110  typereg_Version getVersion() const;
1111 };
1112 
1113 }
1114 
1115 TypeRegistryEntry::TypeRegistryEntry(
1116  const sal_uInt8* buffer, sal_uInt32 len):
1117  BlopObject(buffer, len), m_refCount(1), m_nSuperTypes(0),
1118  m_offset_SUPERTYPES(0)
1119 {
1120  std::size_t const entrySize = sizeof(sal_uInt16);
1121  sal_uInt16 nHeaderEntries = readUINT16(OFFSET_N_ENTRIES);
1122  sal_uInt32 offset_N_SUPERTYPES = OFFSET_N_ENTRIES + entrySize + (nHeaderEntries * entrySize); // cannot overflow
1123  m_offset_SUPERTYPES = offset_N_SUPERTYPES + entrySize; // cannot overflow
1124  m_nSuperTypes = readUINT16(offset_N_SUPERTYPES);
1125 
1126  sal_uInt32 offset_CP_SIZE = m_offset_SUPERTYPES + (m_nSuperTypes * entrySize); // cannot overflow
1127  sal_uInt32 offset_CP = offset_CP_SIZE + entrySize; // cannot overflow
1128 
1129  if (offset_CP > m_bufferLen) {
1130  throw BoundsError();
1131  }
1132  m_pCP.reset(
1133  new ConstantPool(
1134  m_pBuffer + offset_CP, m_bufferLen - offset_CP,
1135  readUINT16(offset_CP_SIZE)));
1136 
1137  sal_uInt32 offset = offset_CP + m_pCP->parseIndex(); //TODO: overflow
1138 
1139  assert(m_bufferLen >= entrySize);
1140  if (offset > m_bufferLen - entrySize) {
1141  throw BoundsError();
1142  }
1143  m_pFields.reset(
1144  new FieldList(
1145  m_pBuffer + offset + entrySize, m_bufferLen - (offset + entrySize),
1146  readUINT16(offset), m_pCP.get()));
1147 
1148  offset += sizeof(sal_uInt16) + m_pFields->parseIndex(); //TODO: overflow
1149 
1150  assert(m_bufferLen >= entrySize);
1151  if (offset > m_bufferLen - entrySize) {
1152  throw BoundsError();
1153  }
1154  m_pMethods.reset(
1155  new MethodList(
1156  m_pBuffer + offset + entrySize, m_bufferLen - (offset + entrySize),
1157  readUINT16(offset), m_pCP.get()));
1158 
1159  offset += sizeof(sal_uInt16) + m_pMethods->parseIndex(); //TODO: overflow
1160 
1161  assert(m_bufferLen >= entrySize);
1162  if (offset > m_bufferLen - entrySize) {
1163  throw BoundsError();
1164  }
1165  m_pReferences.reset(
1166  new ReferenceList(
1167  m_pBuffer + offset + entrySize, m_bufferLen - (offset + entrySize),
1168  readUINT16(offset), m_pCP.get()));
1169 }
1170 
1171 typereg_Version TypeRegistryEntry::getVersion() const {
1172  // Assumes two's complement arithmetic with modulo-semantics:
1173  return static_cast< typereg_Version >(readUINT32(OFFSET_MAGIC) - magic);
1174 }
1175 
1176 /**************************************************************************
1177 
1178  C-API
1179 
1180 **************************************************************************/
1181 
1183  void const * buffer, sal_uInt32 length,
1184  void ** result)
1185 {
1186  if (length < OFFSET_CP || length > SAL_MAX_UINT32) {
1187  *result = nullptr;
1188  return true;
1189  }
1190  std::unique_ptr< TypeRegistryEntry > entry;
1191  try {
1192  try {
1193  entry.reset(
1194  new TypeRegistryEntry(
1195  static_cast< sal_uInt8 const * >(buffer), length));
1196  } catch (std::bad_alloc &) {
1197  return false;
1198  }
1199  if (entry->readUINT32(OFFSET_SIZE) != length) {
1200  *result = nullptr;
1201  return true;
1202  }
1203  typereg_Version version = entry->getVersion();
1204  if (version < TYPEREG_VERSION_0 || version > TYPEREG_VERSION_1) {
1205  *result = nullptr;
1206  return true;
1207  }
1208  *result = entry.release();
1209  return true;
1210  } catch (BlopObject::BoundsError &) {
1211  SAL_WARN("registry", "bad data");
1212  return false;
1213  }
1214 }
1215 
1216 static TypeReaderImpl TYPEREG_CALLTYPE createEntry(const sal_uInt8* buffer, sal_uInt32 len)
1217 {
1218  void * handle;
1219  typereg_reader_create(buffer, len, &handle);
1220  return handle;
1221 }
1222 
1224 {
1225  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1226 
1227  if (pEntry != nullptr)
1228  pEntry->m_refCount++;
1229 }
1230 
1232 {
1233  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1234 
1235  if (pEntry != nullptr)
1236  {
1237  if (--pEntry->m_refCount == 0)
1238  delete pEntry;
1239  }
1240 }
1241 
1243  if (handle != nullptr) {
1244  try {
1245  return static_cast< TypeRegistryEntry const * >(handle)->getVersion();
1246  } catch (BlopObject::BoundsError &) {
1247  SAL_WARN("registry", "bad data");
1248  }
1249  }
1250  return TYPEREG_VERSION_0;
1251 }
1252 
1254 {
1255  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1256  if (pEntry != nullptr) {
1257  try {
1258  return static_cast<RTTypeClass>(pEntry->readUINT16(OFFSET_TYPE_CLASS) & ~RT_TYPE_PUBLISHED);
1259  } catch (BlopObject::BoundsError &) {
1260  SAL_WARN("registry", "bad data");
1261  }
1262  }
1263  return RT_TYPE_INVALID;
1264 }
1265 
1267 {
1268  TypeRegistryEntry * entry = static_cast< TypeRegistryEntry * >(hEntry);
1269  if (entry != nullptr) {
1270  try {
1271  return (entry->readUINT16(OFFSET_TYPE_CLASS) & RT_TYPE_PUBLISHED) != 0;
1272  } catch (BlopObject::BoundsError &) {
1273  SAL_WARN("registry", "bad data");
1274  }
1275  }
1276  return false;
1277 }
1278 
1279 void TYPEREG_CALLTYPE typereg_reader_getTypeName(void * hEntry, rtl_uString** pTypeName)
1280 {
1281  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1282  if (pEntry != nullptr) {
1283  try {
1284  const char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_THIS_TYPE));
1285  rtl_string2UString(
1286  pTypeName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1287  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1288  return;
1289  } catch (BlopObject::BoundsError &) {
1290  SAL_WARN("registry", "bad data");
1291  }
1292  }
1293  rtl_uString_new(pTypeName);
1294 }
1295 
1296 
1297 static void TYPEREG_CALLTYPE getSuperTypeName(TypeReaderImpl hEntry, rtl_uString** pSuperTypeName)
1298 {
1299  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1300  if (pEntry != nullptr && pEntry->m_nSuperTypes != 0) {
1301  try {
1302  const char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(pEntry->m_offset_SUPERTYPES )); //+ (index * sizeof(sal_uInt16))));
1303  rtl_string2UString(
1304  pSuperTypeName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1305  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1306  return;
1307  } catch (BlopObject::BoundsError &) {
1308  SAL_WARN("registry", "bad data");
1309  }
1310  }
1311  rtl_uString_new(pSuperTypeName);
1312 }
1313 
1314 void TYPEREG_CALLTYPE typereg_reader_getDocumentation(void * hEntry, rtl_uString** pDoku)
1315 {
1316  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1317  if (pEntry != nullptr) {
1318  try {
1319  const char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_DOKU));
1320  rtl_string2UString(
1321  pDoku, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1322  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1323  return;
1324  } catch (BlopObject::BoundsError &) {
1325  SAL_WARN("registry", "bad data");
1326  }
1327  }
1328  rtl_uString_new(pDoku);
1329 }
1330 
1331 void TYPEREG_CALLTYPE typereg_reader_getFileName(void * hEntry, rtl_uString** pFileName)
1332 {
1333  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1334  if (pEntry != nullptr) {
1335  try {
1336  const char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_FILENAME));
1337  rtl_string2UString(
1338  pFileName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1339  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1340  return;
1341  } catch (BlopObject::BoundsError &) {
1342  SAL_WARN("registry", "bad data");
1343  }
1344  }
1345  rtl_uString_new(pFileName);
1346 }
1347 
1348 
1350 {
1351  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1352 
1353  if (pEntry == nullptr) return 0;
1354 
1355  return pEntry->m_pFields->m_numOfEntries;
1356 }
1357 
1359 {
1360  return typereg_reader_getFieldCount(hEntry);
1361 }
1362 
1363 void TYPEREG_CALLTYPE typereg_reader_getFieldName(void * hEntry, rtl_uString** pFieldName, sal_uInt16 index)
1364 {
1365  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1366 
1367  if (pEntry == nullptr)
1368  {
1369  rtl_uString_new(pFieldName);
1370  return;
1371  }
1372  const char* pTmp = pEntry->m_pFields->getFieldName(index);
1373  rtl_string2UString(
1374  pFieldName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1375  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1376 }
1377 
1378 void TYPEREG_CALLTYPE typereg_reader_getFieldTypeName(void * hEntry, rtl_uString** pFieldType, sal_uInt16 index)
1379 {
1380  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1381 
1382  if (pEntry == nullptr)
1383  {
1384  rtl_uString_new(pFieldType);
1385  return;
1386  }
1387 
1388  const char* pTmp = pEntry->m_pFields->getFieldType(index);
1389  rtl_string2UString(
1390  pFieldType, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1391  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1392 }
1393 
1395 {
1396  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1397 
1398  if (pEntry == nullptr) return RTFieldAccess::INVALID;
1399 
1400  return pEntry->m_pFields->getFieldAccess(index);
1401 }
1402 
1404  void * hEntry, sal_uInt16 index, RTValueType * type,
1405  RTConstValueUnion * value)
1406 {
1407  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1408 
1409  if (pEntry == nullptr) {
1410  *type = RT_TYPE_NONE;
1411  return true;
1412  }
1413 
1414  try {
1415  *type = pEntry->m_pFields->getFieldConstValue(index, value);
1416  } catch (std::bad_alloc &) {
1417  return false;
1418  }
1419  return true;
1420 }
1421 
1423 {
1425  typereg_reader_getFieldValue(hEntry, index, &t, value);
1426  return t;
1427 }
1428 
1429 void TYPEREG_CALLTYPE typereg_reader_getFieldDocumentation(void * hEntry, rtl_uString** pDoku, sal_uInt16 index)
1430 {
1431  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1432 
1433  if (pEntry == nullptr)
1434  {
1435  rtl_uString_new(pDoku);
1436  return;
1437  }
1438 
1439  const char* pTmp = pEntry->m_pFields->getFieldDoku(index);
1440  rtl_string2UString(
1441  pDoku, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1442  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1443 }
1444 
1445 void TYPEREG_CALLTYPE typereg_reader_getFieldFileName(void * hEntry, rtl_uString** pFieldFileName, sal_uInt16 index)
1446 {
1447  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1448 
1449  if (pEntry == nullptr)
1450  {
1451  rtl_uString_new(pFieldFileName);
1452  return;
1453  }
1454 
1455  const char* pTmp = pEntry->m_pFields->getFieldFileName(index);
1456  rtl_string2UString(
1457  pFieldFileName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1458  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1459 }
1460 
1461 
1463 {
1464  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1465 
1466  if (pEntry == nullptr) return 0;
1467 
1468  return pEntry->m_pMethods->m_numOfEntries;
1469 }
1470 
1471 void TYPEREG_CALLTYPE typereg_reader_getMethodName(void * hEntry, rtl_uString** pMethodName, sal_uInt16 index)
1472 {
1473  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1474 
1475  if (pEntry == nullptr)
1476  {
1477  rtl_uString_new(pMethodName);
1478  return;
1479  }
1480 
1481  const char* pTmp = pEntry->m_pMethods->getMethodName(index);
1482  rtl_string2UString(
1483  pMethodName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1484  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1485 }
1486 
1488  void * hEntry, sal_uInt16 index)
1489 {
1490  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1491 
1492  if (pEntry == nullptr) return 0;
1493 
1494  return pEntry->m_pMethods->getMethodParamCount(index);
1495 }
1496 
1497 void TYPEREG_CALLTYPE typereg_reader_getMethodParameterTypeName(void * hEntry, rtl_uString** pMethodParamType, sal_uInt16 index, sal_uInt16 paramIndex)
1498 {
1499  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1500 
1501  if (pEntry == nullptr)
1502  {
1503  rtl_uString_new(pMethodParamType);
1504  return;
1505  }
1506 
1507  const char* pTmp = pEntry->m_pMethods->getMethodParamType(index, paramIndex);
1508  rtl_string2UString(
1509  pMethodParamType, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1510  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1511 }
1512 
1513 void TYPEREG_CALLTYPE typereg_reader_getMethodParameterName(void * hEntry, rtl_uString** pMethodParamName, sal_uInt16 index, sal_uInt16 paramIndex)
1514 {
1515  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1516 
1517  if (pEntry == nullptr)
1518  {
1519  rtl_uString_new(pMethodParamName);
1520  return;
1521  }
1522 
1523  const char* pTmp = pEntry->m_pMethods->getMethodParamName(index, paramIndex);
1524  rtl_string2UString(
1525  pMethodParamName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1526  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1527 }
1528 
1529 RTParamMode TYPEREG_CALLTYPE typereg_reader_getMethodParameterFlags(void * hEntry, sal_uInt16 index, sal_uInt16 paramIndex)
1530 {
1531  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1532 
1533  if (pEntry == nullptr) return RT_PARAM_INVALID;
1534 
1535  return pEntry->m_pMethods->getMethodParamMode(index, paramIndex);
1536 }
1537 
1539  void * hEntry, sal_uInt16 index)
1540 {
1541  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1542 
1543  if (pEntry == nullptr) return 0;
1544 
1545  return pEntry->m_pMethods->getMethodExcCount(index);
1546 }
1547 
1548 void TYPEREG_CALLTYPE typereg_reader_getMethodExceptionTypeName(void * hEntry, rtl_uString** pMethodExcpType, sal_uInt16 index, sal_uInt16 excIndex)
1549 {
1550  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1551 
1552  if (pEntry == nullptr)
1553  {
1554  rtl_uString_new(pMethodExcpType);
1555  return;
1556  }
1557 
1558  const char* pTmp = pEntry->m_pMethods->getMethodExcType(index, excIndex);
1559  rtl_string2UString(
1560  pMethodExcpType, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1561  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1562 }
1563 
1564 void TYPEREG_CALLTYPE typereg_reader_getMethodReturnTypeName(void * hEntry, rtl_uString** pMethodReturnType, sal_uInt16 index)
1565 {
1566  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1567 
1568  if (pEntry == nullptr)
1569  {
1570  rtl_uString_new(pMethodReturnType);
1571  return;
1572  }
1573 
1574  const char* pTmp = pEntry->m_pMethods->getMethodReturnType(index);
1575  rtl_string2UString(
1576  pMethodReturnType, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1577  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1578 }
1579 
1581 {
1582  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1583 
1584  if (pEntry == nullptr) return RTMethodMode::INVALID;
1585 
1586  return pEntry->m_pMethods->getMethodMode(index);
1587 }
1588 
1589 void TYPEREG_CALLTYPE typereg_reader_getMethodDocumentation(void * hEntry, rtl_uString** pMethodDoku, sal_uInt16 index)
1590 {
1591  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1592 
1593  if (pEntry == nullptr)
1594  {
1595  rtl_uString_new(pMethodDoku);
1596  return;
1597  }
1598 
1599  const char* pTmp = pEntry->m_pMethods->getMethodDoku(index);
1600  rtl_string2UString(
1601  pMethodDoku, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1602  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1603 }
1604 
1606 {
1607  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1608 
1609  if (pEntry == nullptr) return 0;
1610 
1611  return pEntry->m_pReferences->m_numOfEntries;
1612 }
1613 
1614 void TYPEREG_CALLTYPE typereg_reader_getReferenceTypeName(void * hEntry, rtl_uString** pReferenceName, sal_uInt16 index)
1615 {
1616  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1617 
1618  if (pEntry == nullptr)
1619  {
1620  rtl_uString_new(pReferenceName);
1621  return;
1622  }
1623 
1624  const char* pTmp = pEntry->m_pReferences->getReferenceName(index);
1625  rtl_string2UString(
1626  pReferenceName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1627  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1628 }
1629 
1631 {
1632  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1633 
1634  if (pEntry == nullptr) return RTReferenceType::INVALID;
1635 
1636  return pEntry->m_pReferences->getReferenceType(index);
1637 }
1638 
1639 void TYPEREG_CALLTYPE typereg_reader_getReferenceDocumentation(void * hEntry, rtl_uString** pReferenceDoku, sal_uInt16 index)
1640 {
1641  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1642 
1643  if (pEntry == nullptr)
1644  {
1645  rtl_uString_new(pReferenceDoku);
1646  return;
1647  }
1648 
1649  const char* pTmp = pEntry->m_pReferences->getReferenceDoku(index);
1650  rtl_string2UString(
1651  pReferenceDoku, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1652  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1653 }
1654 
1656 {
1657  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1658 
1659  if (pEntry == nullptr) return RTFieldAccess::INVALID;
1660 
1661  return pEntry->m_pReferences->getReferenceAccess(index);
1662 }
1663 
1665 {
1666  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1667 
1668  if (pEntry == nullptr) return 0;
1669 
1670  return pEntry->m_nSuperTypes;
1671 }
1672 
1674  void * hEntry, rtl_uString ** pSuperTypeName, sal_uInt16 index)
1675 {
1676  TypeRegistryEntry* pEntry = static_cast<TypeRegistryEntry*>(hEntry);
1677  if (pEntry != nullptr) {
1678  try {
1679  OSL_ASSERT(index < pEntry->m_nSuperTypes);
1680  const char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(pEntry->m_offset_SUPERTYPES + (index * sizeof(sal_uInt16))));
1681  rtl_string2UString(
1682  pSuperTypeName, pTmp, pTmp == nullptr ? 0 : rtl_str_getLength(pTmp),
1683  RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1684  return;
1685  } catch (BlopObject::BoundsError &) {
1686  SAL_WARN("registry", "bad data");
1687  }
1688  }
1689  rtl_uString_new(pSuperTypeName);
1690 }
1691 
1693  sal_uInt32 bufferLen)
1694  : m_hImpl(nullptr)
1695 {
1696  m_hImpl = createEntry(buffer, bufferLen);
1697 }
1698 
1701 
1704 
1706 {
1707  OUString sRet;
1708  typereg_reader_getTypeName(m_hImpl, &sRet.pData);
1709  return sRet;
1710 }
1711 
1713 {
1714  OUString sRet;
1715  ::getSuperTypeName(m_hImpl, &sRet.pData);
1716  return sRet;
1717 }
1718 
1721 
1722 OUString RegistryTypeReader::getFieldName( sal_uInt16 index ) const
1723 {
1724  OUString sRet;
1725  typereg_reader_getFieldName(m_hImpl, &sRet.pData, index);
1726  return sRet;
1727 }
1728 
1729 OUString RegistryTypeReader::getFieldType( sal_uInt16 index ) const
1730 {
1731  OUString sRet;
1732  typereg_reader_getFieldTypeName(m_hImpl, &sRet.pData, index);
1733  return sRet;
1734 }
1735 
1737 { return typereg_reader_getFieldFlags(m_hImpl, index); }
1738 
1740 {
1741  RTConstValue ret;
1742  ret.m_type = ::getFieldConstValue(m_hImpl, index, &ret.m_value);
1743  return ret;
1744 }
1745 
1746 OUString RegistryTypeReader::getFieldDoku( sal_uInt16 index ) const
1747 {
1748  OUString sRet;
1749  typereg_reader_getFieldDocumentation(m_hImpl, &sRet.pData, index);
1750  return sRet;
1751 }
1752 
1753 OUString RegistryTypeReader::getFieldFileName( sal_uInt16 index ) const
1754 {
1755  OUString sRet;
1756  typereg_reader_getFieldFileName(m_hImpl, &sRet.pData, index);
1757  return sRet;
1758 }
1759 
1760 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void TYPEREG_CALLTYPE typereg_reader_release(void *hEntry)
Decrements the reference count of a type reader.
Definition: reflread.cxx:1231
static RTValueType TYPEREG_CALLTYPE getFieldConstValue(TypeReaderImpl hEntry, sal_uInt16 index, RTConstValueUnion *value)
Definition: reflread.cxx:1422
#define FIELD_OFFSET_TYPE
Definition: reflcnst.hxx:62
sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getFieldCount(void *hEntry)
Returns the number of fields of a type reader.
Definition: reflread.cxx:1349
RTParamMode
specifies the mode of a parameter.
Definition: types.hxx:269
indicates an invalid parameter mode
Definition: types.hxx:271
const char NULL_STRING[1]
Definition: reflread.cxx:40
const sal_uInt16 minorVersion
Definition: reflread.cxx:44
sal_Int16 aShort
Definition: types.hxx:215
void * TypeReaderImpl
Implementation handle.
Definition: reflread.hxx:27
#define PARAM_OFFSET_TYPE
Definition: reflcnst.hxx:67
OUString getFieldName(guint nCol)
RTReferenceType
specifies the type of a reference used in a service description.
Definition: types.hxx:297
#define METHOD_OFFSET_PARAM_COUNT
Definition: reflcnst.hxx:76
OUString getFieldFileName(sal_uInt16 index) const
returns the IDL filename of the field specified by index.
Definition: reflread.cxx:1753
RTConstValue getFieldConstValue(sal_uInt16 index) const
returns the value of the field specified by index.
Definition: reflread.cxx:1739
static TypeReaderImpl TYPEREG_CALLTYPE createEntry(const sal_uInt8 *buffer, sal_uInt32 len)
Definition: reflread.cxx:1216
signed char sal_Int8
RTValueType m_type
stores the type of the constant value.
Definition: refltype.hxx:46
ULONG m_refCount
RTMethodMode TYPEREG_CALLTYPE typereg_reader_getMethodFlags(void *hEntry, sal_uInt16 index)
Returns the flags of a method of a type reader.
Definition: reflread.cxx:1580
OUString getFieldDoku(sal_uInt16 index) const
returns the documentation string for the field specified by index.
Definition: reflread.cxx:1746
#define FIELD_OFFSET_VALUE
Definition: reflcnst.hxx:63
const sal_uInt16 majorVersion
Definition: reflread.cxx:45
#define PARAM_OFFSET_MODE
Definition: reflcnst.hxx:68
sal_uInt8 m_pBuffer[RTL_DIGEST_LENGTH_SHA1]
void TYPEREG_CALLTYPE typereg_reader_getMethodDocumentation(void *hEntry, rtl_uString **pMethodDoku, sal_uInt16 index)
Returns the documentation of a method of a type reader.
Definition: reflread.cxx:1589
const sal_uInt32 magic
Definition: reflread.cxx:43
bool TYPEREG_CALLTYPE typereg_reader_getFieldValue(void *hEntry, sal_uInt16 index, RTValueType *type, RTConstValueUnion *value)
Returns the value of a field of a type reader.
Definition: reflread.cxx:1403
sal_Int64 n
static sal_uInt32 TYPEREG_CALLTYPE getFieldCount(TypeReaderImpl hEntry)
Definition: reflread.cxx:1358
#define METHOD_OFFSET_RETURN
Definition: reflcnst.hxx:74
sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getMethodParameterCount(void *hEntry, sal_uInt16 index)
Returns the number of parameters of a method of a type reader.
Definition: reflread.cxx:1487
void TYPEREG_CALLTYPE typereg_reader_getFileName(void *hEntry, rtl_uString **pFileName)
Returns the file name of a type reader.
Definition: reflread.cxx:1331
OUString getFieldName(sal_uInt16 index) const
returns the name of the field specified by index.
Definition: reflread.cxx:1722
#define REFERENCE_OFFSET_TYPE
Definition: reflcnst.hxx:78
void TYPEREG_CALLTYPE typereg_reader_getReferenceDocumentation(void *hEntry, rtl_uString **pReferenceDoku, sal_uInt16 index)
Returns the documentation of a reference of a type reader.
Definition: reflread.cxx:1639
indicates an invalid mode
#define OFFSET_DOKU
Definition: reflcnst.hxx:42
RTFieldAccess TYPEREG_CALLTYPE typereg_reader_getFieldFlags(void *hEntry, sal_uInt16 index)
Returns the flags of a field of a type reader.
Definition: reflread.cxx:1394
OUString getSuperTypeName() const
returns the full qualified name of the supertype.
Definition: reflread.cxx:1712
float x
#define METHOD_OFFSET_MODE
Definition: reflcnst.hxx:72
bool TYPEREG_CALLTYPE typereg_reader_isPublished(void *hEntry)
Returns whether a type reader is published.
Definition: reflread.cxx:1266
sal_uInt64 aUHyper
Definition: types.hxx:220
void TYPEREG_CALLTYPE typereg_reader_getFieldDocumentation(void *hEntry, rtl_uString **pDoku, sal_uInt16 index)
Returns the documentation of a field of a type reader.
Definition: reflread.cxx:1429
sal_uInt32 readUINT32(const sal_uInt8 *buffer, sal_uInt32 &v)
Definition: reflcnst.hxx:167
RTParamMode TYPEREG_CALLTYPE typereg_reader_getMethodParameterFlags(void *hEntry, sal_uInt16 index, sal_uInt16 paramIndex)
Returns the flags of a parameter of a method of a type reader.
Definition: reflread.cxx:1529
#define FIELD_OFFSET_NAME
Definition: reflcnst.hxx:61
#define SAL_MAX_UINT32
the reference type is unknown
#define METHOD_OFFSET_NAME
Definition: reflcnst.hxx:73
#define OFFSET_FILENAME
Definition: reflcnst.hxx:43
sal_uInt16 sal_Unicode
void TYPEREG_CALLTYPE typereg_reader_getTypeName(void *hEntry, rtl_uString **pTypeName)
Returns the type name of a type reader.
Definition: reflread.cxx:1279
typereg_Version
The version of a binary blob that represents a UNOIDL type.
Definition: version.h:41
sal_Unicode const * aString
Definition: types.hxx:223
#define TYPEREG_CALLTYPE
specifies the calling convention for type reader/writer api
Definition: refltype.hxx:73
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_uInt32 aULong
Definition: types.hxx:218
RTConstValueUnion m_value
stores the value of the constant.
Definition: refltype.hxx:48
RTFieldAccess getFieldAccess(sal_uInt16 index) const
returns the access mode of the field specified by index.
Definition: reflread.cxx:1736
specifies a variable container for field values.
Definition: types.hxx:212
void TYPEREG_CALLTYPE typereg_reader_getSuperTypeName(void *hEntry, rtl_uString **pSuperTypeName, sal_uInt16 index)
Returns the type name of a super type of a type reader.
Definition: reflread.cxx:1673
CPInfoTag
Definition: reflcnst.hxx:83
#define REFERENCE_OFFSET_ACCESS
Definition: reflcnst.hxx:81
static void TYPEREG_CALLTYPE getSuperTypeName(TypeReaderImpl hEntry, rtl_uString **pSuperTypeName)
Definition: reflread.cxx:1297
#define OFFSET_THIS_TYPE
Definition: reflcnst.hxx:40
specifies that the structure of the given blob is unknown and can't be read.
Definition: types.hxx:35
sal_uInt32 tag
sal_Int32 getFieldType(guint nCol)
#define CP_OFFSET_ENTRY_TAG
Definition: reflcnst.hxx:52
sal_uInt32 UINT16StringLen(const sal_uInt8 *wstring)
Definition: reflwrit.cxx:64
#define FIELD_OFFSET_ACCESS
Definition: reflcnst.hxx:60
int i
#define OFFSET_TYPE_CLASS
Definition: reflcnst.hxx:39
#define OFFSET_MAGIC
Definition: reflcnst.hxx:33
sal_uInt32 readUINT16(const sal_uInt8 *buffer, sal_uInt16 &v)
Definition: reflcnst.hxx:124
sal_uInt16 aUShort
Definition: types.hxx:216
sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getReferenceCount(void *hEntry)
Returns the number of references of a type reader.
Definition: reflread.cxx:1605
const sal_Unicode NULL_WSTRING[1]
Definition: reflread.cxx:41
#define FIELD_OFFSET_FILENAME
Definition: reflcnst.hxx:65
#define REFERENCE_OFFSET_NAME
Definition: reflcnst.hxx:79
sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getMethodExceptionCount(void *hEntry, sal_uInt16 index)
Returns the number of exceptions of a method of a type reader.
Definition: reflread.cxx:1538
#define PARAM_OFFSET_NAME
Definition: reflcnst.hxx:69
RTTypeClass
specifies the typeclass of a binary type blob.
Definition: types.hxx:31
sal_uInt32 getFieldCount() const
returns the number of fields (attributes/properties, enum values or number of constants in a module)...
Definition: reflread.cxx:1719
#define METHOD_OFFSET_DOKU
Definition: reflcnst.hxx:75
#define OFFSET_N_ENTRIES
Definition: reflcnst.hxx:37
sal_Int32 aLong
Definition: types.hxx:217
sal_uInt32 readINT32(const sal_uInt8 *buffer, sal_Int32 &v)
Definition: reflcnst.hxx:145
#define FIELD_OFFSET_DOKU
Definition: reflcnst.hxx:64
tuple index
RTFieldAccess TYPEREG_CALLTYPE typereg_reader_getReferenceFlags(void *hEntry, sal_uInt16 index)
Returns the flags of a reference of a type reader.
Definition: reflread.cxx:1655
void TYPEREG_CALLTYPE typereg_reader_getMethodParameterName(void *hEntry, rtl_uString **pMethodParamName, sal_uInt16 index, sal_uInt16 paramIndex)
Returns the name of a parameter of a method of a type reader.
Definition: reflread.cxx:1513
sal_uInt32 readString(const sal_uInt8 *buffer, sal_Unicode *v, sal_uInt32 maxSize)
Definition: reflwrit.cxx:89
sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getSuperTypeCount(void *hEntry)
Returns the number of super types of a type reader.
Definition: reflread.cxx:1664
XPropertyListType t
bool TYPEREG_CALLTYPE typereg_reader_create(void const *buffer, sal_uInt32 length, void **result)
Creates a type reader working on a binary blob that represents a UNOIDL type.
Definition: reflread.cxx:1182
RTValueType
specifies the type of a field value.
Definition: types.hxx:195
Denotes the updated version of UNOIDL type blobs.
Definition: version.h:55
float v
void TYPEREG_CALLTYPE typereg_reader_getFieldFileName(void *hEntry, rtl_uString **pFieldFileName, sal_uInt16 index)
Returns the file name of a field of a type reader.
Definition: reflread.cxx:1445
RTTypeClass getTypeClass() const
returns the typeclass of the type represented by this blob.
Definition: reflread.cxx:1702
specifies an unknown flag
void TYPEREG_CALLTYPE typereg_reader_getReferenceTypeName(void *hEntry, rtl_uString **pReferenceName, sal_uInt16 index)
Returns the type name of a reference of a type reader.
Definition: reflread.cxx:1614
RTReferenceType TYPEREG_CALLTYPE typereg_reader_getReferenceSort(void *hEntry, sal_uInt16 index)
Returns the sort of a reference of a type reader.
Definition: reflread.cxx:1630
void TYPEREG_CALLTYPE typereg_reader_getMethodReturnTypeName(void *hEntry, rtl_uString **pMethodReturnType, sal_uInt16 index)
Returns the return type name of a method of a type reader.
Definition: reflread.cxx:1564
unsigned char sal_uInt8
RTMethodMode
specifies the mode of a method.
Definition: types.hxx:231
OUString aName
#define CP_OFFSET_ENTRY_DATA
Definition: reflcnst.hxx:53
void TYPEREG_CALLTYPE typereg_reader_acquire(void *hEntry)
Increments the reference count of a type reader.
Definition: reflread.cxx:1223
void TYPEREG_CALLTYPE typereg_reader_getMethodParameterTypeName(void *hEntry, rtl_uString **pMethodParamType, sal_uInt16 index, sal_uInt16 paramIndex)
Returns the type name of a parameter of a method of a type reader.
Definition: reflread.cxx:1497
#define OFFSET_SIZE
Definition: reflcnst.hxx:34
void TYPEREG_CALLTYPE typereg_reader_getFieldTypeName(void *hEntry, rtl_uString **pFieldType, sal_uInt16 index)
Returns the type name of a field of a type reader.
Definition: reflread.cxx:1378
sal_Int8 aByte
Definition: types.hxx:214
void TYPEREG_CALLTYPE typereg_reader_getMethodName(void *hEntry, rtl_uString **pMethodName, sal_uInt16 index)
Returns the name of a method of a type reader.
Definition: reflread.cxx:1471
double aDouble
Definition: types.hxx:222
Denotes the original version of UNOIDL type blobs.
Definition: version.h:45
void TYPEREG_CALLTYPE typereg_reader_getFieldName(void *hEntry, rtl_uString **pFieldName, sal_uInt16 index)
Returns the name of a field of a type reader.
Definition: reflread.cxx:1363
#define SAL_WARN(area, stream)
TypeReaderImpl m_hImpl
stores the handle of an implementation class
Definition: reflread.hxx:109
typereg_Version TYPEREG_CALLTYPE typereg_reader_getVersion(void const *handle)
Returns the binary blob version of a type reader.
Definition: reflread.cxx:1242
RTTypeClass TYPEREG_CALLTYPE typereg_reader_getTypeClass(void *hEntry)
Returns the type class of a type reader.
Definition: reflread.cxx:1253
OUString getFieldType(sal_uInt16 index) const
returns the full qualified name of the field specified by index.
Definition: reflread.cxx:1729
OUString getString(const Any &_rAny)
RTFieldAccess
specifies the type for the field access.
Definition: types.hxx:132
#define REFERENCE_OFFSET_DOKU
Definition: reflcnst.hxx:80
sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getMethodCount(void *hEntry)
Returns the number of methods of a type reader.
Definition: reflread.cxx:1462
RegistryTypeReader(const sal_uInt8 *buffer, sal_uInt32 bufferLen)
Constructor.
Definition: reflread.cxx:1692
OUString getTypeName() const
returns the full qualified name of the type.
Definition: reflread.cxx:1705
~RegistryTypeReader()
Destructor. The Destructor frees the data block if the copyData flag was TRUE.
Definition: reflread.cxx:1699
sal_Int64 aHyper
Definition: types.hxx:219
void TYPEREG_CALLTYPE typereg_reader_getDocumentation(void *hEntry, rtl_uString **pDoku)
Returns the documentation of a type reader.
Definition: reflread.cxx:1314
void TYPEREG_CALLTYPE typereg_reader_getMethodExceptionTypeName(void *hEntry, rtl_uString **pMethodExcpType, sal_uInt16 index, sal_uInt16 excIndex)
Returns the type name of an exception of a method of a type reader.
Definition: reflread.cxx:1548
specifies a helper class for const values.
Definition: refltype.hxx:42