• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ie_impexp_MSWrite.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 2001 Sean Young <sean@mess.org>
00003  * Copyright (C) 2001 Hubert Figuiere
00004  * Copyright (C) 2001 Dom Lachowicz
00005  * Copyright (C) 2010-2011 Ingo Brueckl
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
00021  */
00022 
00023 #ifndef IE_IMPEXP_MSWRITE_H
00024 #define IE_IMPEXP_MSWRITE_H
00025 
00026 #include "ut_compiler.h"
00027 ABI_W_NO_CONST_QUAL
00028 #include <gsf/gsf.h>
00029 ABI_W_POP
00030 
00031 #define CT_IGNORE 0
00032 #define CT_VALUE  1
00033 #define CT_BLOB   2
00034 
00035 // the general structure for all structures
00036 typedef struct
00037 {
00038     int value;
00039     char *data;
00040     short size;         // in bytes
00041     short type;         // a CT_xxx from above
00042     const char *name;
00043 } wri_struct;
00044 
00045 bool read_wri_struct(wri_struct *w, GsfInput *f);
00046 bool read_wri_struct_mem(wri_struct *w, unsigned char *blob);
00047 int wri_struct_value(const wri_struct *w, const char *name);
00048 void free_wri_struct(wri_struct *w);
00049 void DEBUG_WRI_STRUCT(wri_struct *w, int spaces = 1);
00050 
00051 // endian neutral helper macros
00052 
00053 #define READ_WORD(d)  (*(d) + (*((d) + 1) << 8))
00054 
00055 #define READ_DWORD(d) (*(d) + (*((d) + 1) << 8) + \
00056                               (*((d) + 2) << 16) + \
00057                               (*((d) + 3) << 24))
00058 
00059 #define WRITE_WORD(d, s) \
00060 { \
00061     char *p = reinterpret_cast<char *>(&(d)); \
00062 \
00063     p[0] = (s) & 0xff; \
00064     p[1] = ((s) & 0xff00) >> 8; \
00065 }
00066 
00067 #define WRITE_DWORD(d, s) \
00068 { \
00069     char *p = reinterpret_cast<char *>(&(d)); \
00070 \
00071     p[0] = (s) & 0xff; \
00072     p[1] = ((s) & 0xff00) >> 8; \
00073     p[2] = ((s) & 0xff0000) >> 16; \
00074     p[3] = ((s) & 0xff000000) >> 24; \
00075 }
00076 
00077 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1