diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/propmod_8c_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/propmod_8c_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,126 @@ + + +
+ +00001 /* +00002 * propmod.c +00003 * Copyright (C) 2001-2003 A.J. van Os; Released under GPL +00004 * +00005 * Description: +00006 * Build, read and destroy a list (array) of Word property modifiers +00007 */ +00008 +00009 #include <stdio.h> +00010 #include <string.h> +00011 #include "antiword.h" +00012 +00013 #if defined(DEBUG) +00014 #define ELEMENTS_TO_ADD 3 +00015 #else +00016 #define ELEMENTS_TO_ADD 30 +00017 #endif /* DEBUG */ +00018 +00019 /* Variables needed to write the property modifier list */ +00020 static UCHAR **ppAnchor = NULL; +00021 static size_t tNextFree = 0; +00022 static size_t tMaxElements = 0; +00023 +00024 +00025 /* +00026 * vDestroyPropModList - destroy the property modifier list +00027 */ +00028 void +00029 vDestroyPropModList(void) +00030 { +00031 size_t tIndex; +00032 +00033 DBG_MSG("vDestroyPropModList"); +00034 +00035 /* Free all the elements of the list */ +00036 for (tIndex = 0; tIndex < tNextFree; tIndex++) { +00037 ppAnchor[tIndex] = xfree(ppAnchor[tIndex]); +00038 } +00039 /* Free the list itself */ +00040 ppAnchor = xfree(ppAnchor); +00041 /* Reset all control variables */ +00042 tNextFree = 0; +00043 tMaxElements = 0; +00044 } /* end of vDestroyPropModList */ +00045 +00046 /* +00047 * vAdd2PropModList - add an element to the property modifier list +00048 */ +00049 void +00050 vAdd2PropModList(const UCHAR *aucPropMod) +00051 { +00052 size_t tSize, tLen; +00053 +00054 fail(aucPropMod == NULL); +00055 +00056 NO_DBG_MSG("vAdd2PropModList"); +00057 +00058 if (tNextFree >= tMaxElements) { +00059 tMaxElements += ELEMENTS_TO_ADD; +00060 tSize = tMaxElements * sizeof(UCHAR **); +00061 ppAnchor = xrealloc(ppAnchor, tSize); +00062 } +00063 NO_DBG_DEC(tNextFree); +00064 +00065 tLen = 2 + (size_t)usGetWord(0, aucPropMod); +00066 NO_DBG_HEX(tLen); +00067 NO_DBG_PRINT_BLOCK(pucPropMod, tLen); +00068 ppAnchor[tNextFree] = xmalloc(tLen); +00069 memcpy(ppAnchor[tNextFree], aucPropMod, tLen); +00070 tNextFree++; +00071 } /* end of vAdd2PropModList */ +00072 +00073 /* +00074 * aucReadPropModListItem - get an item of the property modifier list +00075 */ +00076 const UCHAR * +00077 aucReadPropModListItem(USHORT usPropMod) +00078 { +00079 static UCHAR aucBuffer[4]; +00080 size_t tIndex; +00081 +00082 if (usPropMod == IGNORE_PROPMOD) { +00083 /* This Properties Modifier must be ignored */ +00084 return NULL; +00085 } +00086 +00087 if (!odd(usPropMod)) { +00088 /* Variant 1: The information is in the input ifself */ +00089 aucBuffer[0] = 2; +00090 aucBuffer[1] = 0; +00091 aucBuffer[2] = (UCHAR)((usPropMod & 0x00fe) >> 1); +00092 aucBuffer[3] = (UCHAR)((usPropMod & 0xff00) >> 8); +00093 return aucBuffer; +00094 } +00095 +00096 if (ppAnchor == NULL) { +00097 /* No information available */ +00098 return NULL; +00099 } +00100 +00101 /* Variant 2: The input contains an index */ +00102 tIndex = (size_t)(usPropMod >> 1); +00103 if (tIndex >= tNextFree) { +00104 DBG_HEX(usPropMod); +00105 DBG_DEC(tIndex); +00106 DBG_DEC(tNextFree); +00107 return NULL; +00108 } +00109 return ppAnchor[tIndex]; +00110 } /* end of aucGetPropModListItem */ +