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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_WIDTHMAP
#endif
/*
XW_EXT_WIDTHMAP* Xw_def_widthmap(adisplay,nwidth):
XW_EXT_DISPLAY *adisplay Extended Display structure
int nwidth Number of width cells to be allocated
Create a widthmap extension
allocate the width cells in the widthmap as if possible
depending of the MAXWIDTH define .
Returns Widthmap extension address if successful
or NULL if ERROR
STATUS Xw_close_widthmap(awidthmap):
XW_EXT_WIDTHMAP* awidthmap Extended Widthmap address
Destroy The specified Extended Widthmap
Returns SUCCESS if successuful
Returns ERROR if Bad Extended Widthmap
*/
#ifdef XW_PROTOTYPE
void* Xw_def_widthmap (void* adisplay,int nwidth)
#else
void* Xw_def_widthmap (adisplay,nwidth)
void *adisplay ;
int nwidth ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_WIDTHMAP *pwidthmap = NULL ;
//int i ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_def_widthmap",pdisplay) ;
return (NULL) ;
}
if( !(pwidthmap = Xw_add_widthmap_structure(sizeof(XW_EXT_WIDTHMAP))) )
return (NULL) ;
if( nwidth <= 0 ) nwidth = MAXWIDTH ;
pwidthmap->connexion = pdisplay ;
pwidthmap->maxwidth = min(nwidth,MAXWIDTH) ;
#ifdef TRACE_DEF_WIDTHMAP
if( Xw_get_trace() ) {
printf(" %lx = Xw_def_widthmap(%lx,%d)\n",
(long ) pwidthmap,(long ) adisplay,nwidth) ;
}
#endif
return (pwidthmap);
}
static XW_EXT_WIDTHMAP *PwidthmapList =NULL ;
#ifdef XW_PROTOTYPE
XW_EXT_WIDTHMAP* Xw_add_widthmap_structure(int size)
#else
XW_EXT_WIDTHMAP* Xw_add_widthmap_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended widthmap structure in the
EXtended widthmap List
returns Extended widthmap address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_WIDTHMAP *pwidthmap = (XW_EXT_WIDTHMAP*) Xw_malloc(size) ;
int i ;
if( pwidthmap ) {
pwidthmap->type = WIDTHMAP_TYPE ;
pwidthmap->link = PwidthmapList ;
PwidthmapList = pwidthmap ;
pwidthmap->connexion = NULL ;
pwidthmap->maxwidth = 0 ;
pwidthmap->maxwindow = 0 ;
for( i=0 ; i<MAXWIDTH ; i++ ) {
pwidthmap->widths[i] = 0 ;
}
} else {
/*EXT_WIDTHMAP Allocation Failed*/
Xw_set_error(23,"Xw_add_widthmap_structure",0) ;
}
return (pwidthmap) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_widthmap(void* awidthmap)
#else
XW_STATUS Xw_close_widthmap(awidthmap)
void* awidthmap ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WIDTHMAP *pwidthmap = (XW_EXT_WIDTHMAP*)awidthmap ;
XW_STATUS status ;
if( !Xw_isdefine_widthmap(pwidthmap) ) {
/*Bad EXT_WIDTHMAP Address*/
Xw_set_error(53,"Xw_close_widthmap",pwidthmap) ;
return (XW_ERROR) ;
}
status = Xw_del_widthmap_structure(pwidthmap) ;
#ifdef TRACE_DEF_WIDTHMAP
if( Xw_get_trace() ) {
printf(" %d = Xw_close_widthmap(%lx)\n",status,(long ) pwidthmap) ;
}
#endif
return (status) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_widthmap_structure(XW_EXT_WIDTHMAP* awidthmap)
#else
XW_STATUS Xw_del_widthmap_structure(awidthmap)
XW_EXT_WIDTHMAP *awidthmap;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended widthmap address from the Extended List
returns ERROR if the widthmap address is not Found in the list
returns SUCCESS if successful
*/
{
XW_EXT_WIDTHMAP *pwidthmap = PwidthmapList ;
//int i ;
if( !awidthmap ) return (XW_ERROR) ;
if( awidthmap->maxwindow ) {
return (XW_ERROR) ;
} else {
if( awidthmap == pwidthmap ) {
PwidthmapList = (XW_EXT_WIDTHMAP*) awidthmap->link ;
} else {
for( ; pwidthmap ; pwidthmap = (XW_EXT_WIDTHMAP*) pwidthmap->link ) {
if( pwidthmap->link == awidthmap ) {
pwidthmap->link = awidthmap->link ;
break ;
}
}
}
Xw_free(awidthmap) ;
}
return (XW_SUCCESS) ;
}
|