diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/sectlist_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/sectlist_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ - - -
- -00001 /* -00002 * sectlist.c -00003 * Copyright (C) 2001-2004 A.J. van Os; Released under GNU GPL -00004 * -00005 * Description: -00006 * Build, read and destroy list(s) of Word section information -00007 */ -00008 -00009 #include <stddef.h> -00010 #include <string.h> -00011 #include "antiword.h" -00012 -00013 -00014 /* -00015 * Private structure to hide the way the information -00016 * is stored from the rest of the program -00017 */ -00018 typedef struct section_mem_tag { -00019 section_block_type tInfo; -00020 ULONG ulCharPos; -00021 struct section_mem_tag *pNext; -00022 } section_mem_type; -00023 -00024 /* Variables needed to write the Section Information List */ -00025 static section_mem_type *pAnchor = NULL; -00026 static section_mem_type *pSectionLast = NULL; -00027 -00028 -00029 /* -00030 * vDestroySectionInfoList - destroy the Section Information List -00031 */ -00032 void -00033 vDestroySectionInfoList(void) -00034 { -00035 section_mem_type *pCurr, *pNext; -00036 -00037 DBG_MSG("vDestroySectionInfoList"); -00038 -00039 /* Free the Section Information List */ -00040 pCurr = pAnchor; -00041 while (pCurr != NULL) { -00042 pNext = pCurr->pNext; -00043 pCurr = xfree(pCurr); -00044 pCurr = pNext; -00045 } -00046 pAnchor = NULL; -00047 /* Reset all control variables */ -00048 pSectionLast = NULL; -00049 } /* end of vDestroySectionInfoList */ -00050 -00051 /* -00052 * vAdd2SectionInfoList - Add an element to the Section Information List -00053 */ -00054 void -00055 vAdd2SectionInfoList(const section_block_type *pSection, ULONG ulCharPos) -00056 { -00057 section_mem_type *pListMember; -00058 -00059 fail(pSection == NULL); -00060 -00061 /* Create list member */ -00062 pListMember = xmalloc(sizeof(section_mem_type)); -00063 /* Fill the list member */ -00064 pListMember->tInfo = *pSection; -00065 pListMember->ulCharPos = ulCharPos; -00066 pListMember->pNext = NULL; -00067 /* Add the new member to the list */ -00068 if (pAnchor == NULL) { -00069 pAnchor = pListMember; -00070 } else { -00071 fail(pSectionLast == NULL); -00072 pSectionLast->pNext = pListMember; -00073 } -00074 pSectionLast = pListMember; -00075 } /* vAdd2SectionInfoList */ -00076 -00077 /* -00078 * vGetDefaultSection - fill the section struct with default values -00079 */ -00080 void -00081 vGetDefaultSection(section_block_type *pSection) -00082 { -00083 (void)memset(pSection, 0, sizeof(*pSection)); -00084 pSection->bNewPage = TRUE; -00085 } /* end of vGetDefaultSection */ -00086 -00087 /* -00088 * vDefault2SectionInfoList - Add a default to the Section Information List -00089 */ -00090 void -00091 vDefault2SectionInfoList(ULONG ulCharPos) -00092 { -00093 section_block_type tSection; -00094 -00095 vGetDefaultSection(&tSection); -00096 vAdd2SectionInfoList(&tSection, ulCharPos); -00097 } /* end of vDefault2SectionInfoList */ -00098 -00099 /* -00100 * pGetSectionInfo - get the section information -00101 */ -00102 const section_block_type * -00103 pGetSectionInfo(const section_block_type *pOld, ULONG ulCharPos) -00104 { -00105 const section_mem_type *pCurr; -00106 -00107 if (pOld == NULL || ulCharPos == 0) { -00108 if (pAnchor == NULL) { -00109 /* There are no records, make one */ -00110 vDefault2SectionInfoList(0); -00111 fail(pAnchor == NULL); -00112 } -00113 /* The first record */ -00114 NO_DBG_MSG("First record"); -00115 return &pAnchor->tInfo; -00116 } -00117 -00118 NO_DBG_HEX(ulCharPos); -00119 for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) { -00120 NO_DBG_HEX(pCurr->ulCharPos); -00121 if (ulCharPos == pCurr->ulCharPos || -00122 ulCharPos + 1 == pCurr->ulCharPos) { -00123 NO_DBG_HEX(pCurr->ulCharPos); -00124 return &pCurr->tInfo; -00125 } -00126 } -00127 return pOld; -00128 } /* end of pGetSectionInfo */ -00129 -00130 /* -00131 * tGetNumberOfSections - get the number of sections -00132 */ -00133 size_t -00134 tGetNumberOfSections(void) -00135 { -00136 const section_mem_type *pCurr; -00137 size_t tCounter; -00138 -00139 for (tCounter = 0, pCurr = pAnchor; -00140 pCurr != NULL; -00141 tCounter++, pCurr = pCurr->pNext) -00142 ; /* Empty */ -00143 return tCounter; -00144 } /* end of tGetNumberOfSections */ -00145 -00146 /* -00147 * ucGetSepHdrFtrSpecification - get the Heder/footer specification -00148 */ -00149 UCHAR -00150 ucGetSepHdrFtrSpecification(size_t tSectionNumber) -00151 { -00152 const section_mem_type *pCurr; -00153 size_t tIndex; -00154 -00155 for (tIndex = 0, pCurr = pAnchor; -00156 tIndex < tSectionNumber && pCurr != NULL; -00157 tIndex++, pCurr = pCurr->pNext) -00158 ; /* Empty */ -00159 if (pCurr == NULL) { -00160 DBG_DEC(tSectionNumber); -00161 DBG_FIXME(); -00162 return 0x00; -00163 } -00164 return pCurr->tInfo.ucHdrFtrSpecification; -00165 } /* end of ucGetSepHdrFtrSpecification */ -