• 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., 59 Temple Place - Suite 330, Boston, MA
00020  * 02111-1307, USA.
00021  */
00022 
00023 #ifndef IE_IMPEXP_MSWRITE_H
00024 #define IE_IMPEXP_MSWRITE_H
00025 
00026 #include <gsf/gsf.h>
00027 
00028 #define CT_IGNORE 0
00029 #define CT_VALUE  1
00030 #define CT_BLOB   2
00031 
00032 // the general structure for all structures
00033 typedef struct
00034 {
00035     int value;
00036     char *data;
00037     short size;         // in bytes
00038     short type;         // a CT_xxx from above
00039     const char *name;
00040 } wri_struct;
00041 
00042 bool read_wri_struct(wri_struct *w, GsfInput *f);
00043 bool read_wri_struct_mem(wri_struct *w, unsigned char *blob);
00044 int wri_struct_value(const wri_struct *w, const char *name);
00045 void free_wri_struct(wri_struct *w);
00046 void DEBUG_WRI_STRUCT(wri_struct *w, int spaces = 1);
00047 
00048 // endian neutral helper macros
00049 
00050 #define READ_WORD(d)  (*(d) + (*((d) + 1) << 8))
00051 
00052 #define READ_DWORD(d) (*(d) + (*((d) + 1) << 8) + \
00053                               (*((d) + 2) << 16) + \
00054                               (*((d) + 3) << 24))
00055 
00056 #define WRITE_WORD(d, s) \
00057 { \
00058     char *p = reinterpret_cast<char *>(&(d)); \
00059 \
00060     p[0] = (s) & 0xff; \
00061     p[1] = ((s) & 0xff00) >> 8; \
00062 }
00063 
00064 #define WRITE_DWORD(d, s) \
00065 { \
00066     char *p = reinterpret_cast<char *>(&(d)); \
00067 \
00068     p[0] = (s) & 0xff; \
00069     p[1] = ((s) & 0xff00) >> 8; \
00070     p[2] = ((s) & 0xff0000) >> 16; \
00071     p[3] = ((s) & 0xff000000) >> 24; \
00072 }
00073 
00074 #endif

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1