1 /* wvWare
2  * Copyright (C) Caolan McNamara, Dom Lachowicz, and others
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include "wv.h"
28 #include "wvinternal.h"
29 
30 /*
31 The NUMRM structure is used to track revision marking data for paragraph
32 numbers, and is stored in the PAP for each numbered paragraph. When revision
33 marking tracking is turned on, we fill out the NUMRM for each number with
34 the data required to recreate the number's text. Then at display time, that
35 string is compared with the current paragraph number string, and displayed
36 as changed (old deleted, current inserted) if the strings differ. The string
37 construction algorithm is the same as for an LVL structure.
38 */
39 
40 void
wvGetNUMRM_internal(NUMRM * item,wvStream * fd,U8 * pointer)41 wvGetNUMRM_internal (NUMRM * item, wvStream * fd, U8 * pointer)
42 {
43     int i;
44     item->fNumRM = dread_8ubit (fd, &pointer);
45     item->Spare1 = dread_8ubit (fd, &pointer);
46     item->ibstNumRM = (S16) dread_16ubit (fd, &pointer);
47     if (fd != NULL)
48 	wvGetDTTM (&(item->dttmNumRM), fd);
49     else
50       {
51 	  wvGetDTTMFromBucket (&(item->dttmNumRM), pointer);
52 	  pointer += cbDTTM;
53       }
54     for (i = 0; i < 9; i++)
55 	item->rgbxchNums[i] = dread_8ubit (fd, &pointer);
56     for (i = 0; i < 9; i++)
57 	item->rgnfc[i] = dread_8ubit (fd, &pointer);
58     item->Spare2 = (S16) dread_16ubit (fd, &pointer);
59     for (i = 0; i < 9; i++)
60 	item->PNBR[i] = (S32) dread_32ubit (fd, &pointer);
61     for (i = 0; i < 32; i++)
62 	item->xst[i] = dread_16ubit (fd, &pointer);
63 }
64 
65 void
wvGetNUMRM(NUMRM * item,wvStream * fd)66 wvGetNUMRM (NUMRM * item, wvStream * fd)
67 {
68     wvGetNUMRM_internal (item, fd, NULL);
69 }
70 
71 void
wvGetNUMRMFromBucket(NUMRM * item,U8 * pointer)72 wvGetNUMRMFromBucket (NUMRM * item, U8 * pointer)
73 {
74     wvGetNUMRM_internal (item, NULL, pointer);
75 }
76 
77 void
wvCopyNUMRM(NUMRM * dest,NUMRM * src)78 wvCopyNUMRM (NUMRM * dest, NUMRM * src)
79 {
80     memcpy (dest, src, sizeof (NUMRM));
81 }
82 
83 void
wvInitNUMRM(NUMRM * item)84 wvInitNUMRM (NUMRM * item)
85 {
86     int i;
87     item->fNumRM = 0;
88     item->Spare1 = 0;
89     item->ibstNumRM = 0;
90     wvInitDTTM (&(item->dttmNumRM));
91     for (i = 0; i < 9; i++)
92 	item->rgbxchNums[i] = 0;
93     for (i = 0; i < 9; i++)
94 	item->rgnfc[i] = 0;
95     item->Spare2 = 0;
96     for (i = 0; i < 9; i++)
97 	item->PNBR[i] = 0;
98     for (i = 0; i < 32; i++)
99 	item->xst[i] = 0;
100 }
101