3 * Copyright (C) 2000-2004 A.J. van Os; Released under GNU GPL
6 * Build, read and destroy a list of Word picture information
14 * Private structure to hide the way the information
15 * is stored from the rest of the program
17 typedef struct picture_mem_tag {
18 picture_block_type tInfo;
19 struct picture_mem_tag *pNext;
22 /* Variables needed to write the Picture Information List */
23 static picture_mem_type *pAnchor = NULL;
24 static picture_mem_type *pPictureLast = NULL;
28 * vDestroyPictInfoList - destroy the Picture Information List
31 vDestroyPictInfoList(void)
33 picture_mem_type *pCurr, *pNext;
35 DBG_MSG("vDestroyPictInfoList");
37 /* Free the Picture Information List */
39 while (pCurr != NULL) {
45 /* Reset all control variables */
47 } /* end of vDestroyPictInfoList */
50 * vAdd2PictInfoList - Add an element to the Picture Information List
53 vAdd2PictInfoList(const picture_block_type *pPictureBlock)
55 picture_mem_type *pListMember;
57 fail(pPictureBlock == NULL);
59 NO_DBG_MSG("bAdd2PictInfoList");
61 if (pPictureBlock->ulFileOffset == FC_INVALID) {
63 * This offset is really past the end of the file,
64 * so don't waste any memory by storing it.
68 if (pPictureBlock->ulFileOffsetPicture == FC_INVALID) {
70 * The place where this picture is supposed to be stored
76 NO_DBG_HEX(pPictureBlock->ulFileOffset);
77 NO_DBG_HEX(pPictureBlock->ulFileOffsetPicture);
78 NO_DBG_HEX(pPictureBlock->ulPictureOffset);
80 /* Create list member */
81 pListMember = xmalloc(sizeof(picture_mem_type));
82 /* Fill the list member */
83 pListMember->tInfo = *pPictureBlock;
84 pListMember->pNext = NULL;
85 /* Add the new member to the list */
86 if (pAnchor == NULL) {
87 pAnchor = pListMember;
89 fail(pPictureLast == NULL);
90 pPictureLast->pNext = pListMember;
92 pPictureLast = pListMember;
93 } /* end of vAdd2PictInfoList */
96 * Get the info with the given file offset from the Picture Information List
99 ulGetPictInfoListItem(ULONG ulFileOffset)
101 picture_mem_type *pCurr;
103 for (pCurr = pAnchor; pCurr != NULL; pCurr = pCurr->pNext) {
104 if (pCurr->tInfo.ulFileOffset == ulFileOffset) {
105 return pCurr->tInfo.ulFileOffsetPicture;
109 } /* end of ulGetPictInfoListItem */