File: fopt.c

package info (click to toggle)
abiword 0.7.7-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 20,604 kB
  • ctags: 18,358
  • sloc: cpp: 88,791; ansic: 66,296; sh: 7,777; makefile: 3,397; xml: 687; perl: 361; awk: 273; sed: 36; csh: 28
file content (91 lines) | stat: -rw-r--r-- 1,901 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <stdlib.h>
#include <stdio.h>
#include "wv.h"

U32 wvGetFAnchor(FAnchor *item,FILE *fd)
	{
	/* It is supposed to be a RECT, but its only 4 long so... */
	item->left = getc(fd);
	item->right = getc(fd);
	item->top = getc(fd);
	item->bottom = getc(fd);
	return(4);
	}

void wvInitFOPTEArray(FOPTE **fopte)
	{
	*fopte=NULL;
	}

void wvReleaseFOPTEArray(FOPTE **fopte)
	{
	U32 i=0;
	if (*fopte)
		{
		while((*fopte)[i].pid != 0)
			{
			wvFree((*fopte)[i].entry);
			i++;
			}
		wvFree(*fopte);
		}
	}

U32 wvGetFOPTEArray(FOPTE **fopte,MSOFBH *msofbh,FILE *fd)
	{
	U32 i,j,count=0;
	U32 no = msofbh->cbLength/6;
	*fopte = (FOPTE *)malloc(sizeof(FOPTE) * no);
	no=0;
	while (count < msofbh->cbLength)
		{
		wvTrace(("count %x %x, pos %x\n",count,msofbh->cbLength,ftell(fd)));
		count += wvGetFOPTE(&(*fopte)[no],fd);
		no++;
		}
	*fopte = (FOPTE *)realloc(*fopte,sizeof(FOPTE) * (no+1));
	for(i=0;i<no;i++)
		{
		if ( (*fopte)[i].fComplex )
			for(j=0;j<(*fopte)[i].op;j++)
			(*fopte)[i].entry[j] = getc(fd);	
		}
	(*fopte)[i].pid=0;
	wvTrace(("returning %x\n",count));
	return(count);
	}


U32 wvReleaseFOPTE(FOPTE *afopte)
	{
	wvFree(afopte->entry);
	}

U32 wvGetFOPTE(FOPTE *afopte,FILE *fd)
    {
	U32 i;
    U16 dtemp;
	wvTrace(("pos is %x\n",ftell(fd)));
    dtemp = read_16ubit(fd);
	wvTrace(("dtemp is %x\n",dtemp));
#ifdef PURIFY
    afopte->pid = 0;
    afopte->fBid = 0;
    afopte->fComplex = 0;
#endif
    afopte->pid = (dtemp & 0x3fff);
    afopte->fBid = ((dtemp & 0x4000)>>14);
    afopte->fComplex = ((dtemp & 0x8000)>>15);
    afopte->op = read_32ubit(fd);

    wvTrace(("orig %x,pid is %x %d, val is %x\n",dtemp,afopte->pid,afopte->pid,afopte->op));
    if ( afopte->fComplex )
		{
        wvTrace(("1 complex len is %d (%x)\n",afopte->op,afopte->op));
		afopte->entry = (U8 *)malloc(afopte->op);
		return(afopte->op+6);
        }

	afopte->entry = NULL;
    return(6);
    }