Chameleon

Chameleon Commit Details

Date:2015-05-09 17:03:10 (4 years 3 months ago)
Author:ErmaC
Commit:2668
Parents: 2667
Message:Refactoring prf and DecompressData functions (Credits to cparm).
Changes:
M/trunk/i386/boot2/bmdecompress.c
M/trunk/i386/libsa/prf.c

File differences

trunk/i386/boot2/bmdecompress.c
264264
265265
266266
267
268
267
269268
270
269
271270
272271
273272
274273
275274
276275
277
276
277
278
279
280
278281
282
283
284
285
286
287
288
289
279290
280291
281292
282293
283
294
284295
285296
286
297
287298
288
299
300
301
289302
303
290304
free(sc0);
}
void *
DecompressData(void *srcbase, int *dw, int *dh, int *bitsPerPixel)
void *DecompressData(void *srcbase, int *dw, int *dh, int *bitsPerPixel)
{
uint32_t *src = (uint32_t *) srcbase;
uint32_t *src = (uint32_t *) srcbase, size;
void * ret;
*bitsPerPixel = 8 * ((int) src[0]);
*dw = (int) src[1];
*dh = (int) src[2];
ret = malloc ((*dw * *dh * *bitsPerPixel)/ 8);
size = (*dw * *dh * *bitsPerPixel)/ 8;
if (!size)
{
return 0;
}
ret = malloc (size);
if (!ret)
{
return 0;
}
bzero(ret, size);
switch(*bitsPerPixel)
{
case 32:
PreviewDecompress32((uint32_t *)srcbase, *dw, *dh, *dw, ret);
return ret;
break;
case 16:
PreviewDecompress16((uint32_t *)srcbase, *dw, *dh, *dw, ret);
return ret;
break;
default:
return 0;
free(ret);
ret = 0;
break;
}
return ret;
}
trunk/i386/libsa/prf.c
6060
6161
6262
63
63
6464
6565
6666
......
9090
9191
9292
93
93
9494
9595
96
96
9797
9898
9999
100
100
101101
102102
103103
......
105105
106106
107107
108
109
108
109
110
111
112
113
114
115
116
110117
111
118
112119
113120
114121
115
116
117
118
119
120
121
122
123
124
122
125123
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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
165192
166193
167194
printn(n, b, flag, minwidth, putfn_p, putfn_arg)
u_long n;
int b, flag, minwidth;
int (*putfn_p)();
void (*putfn_p)();
void *putfn_arg;
{
char prbuf[11];
while (cp > prbuf);
}
void prf(
int prf(
char *fmt,
unsigned int *adx,
int (*putfn_p)(),
void (*putfn_p)(),
void *putfn_arg
)
{
int b, c;
int b, c, len =0;
char *s;
int flag = 0, width = 0;
int minwidth;
loop:
while ((c = *fmt++) != '%') {
if(c == '\0')
return;
(*putfn_p)(c, putfn_arg);
{
return len;
}
if (putfn_p)
{
(*putfn_p)(c, putfn_arg);
}
len++;
}
minwidth = 0;
minwidth = 0;
again:
c = *fmt++;
switch (c) {
case 'l':
goto again;
case ' ':
flag |= SPACE;
goto again;
case '0':
if (minwidth == 0)
{
/* this is a flag */
flag |= ZERO;
case 'l':
goto again;
} /* fall through */
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
minwidth *= 10;
minwidth += c - '0';
goto again;
case 'X':
flag |= UCASE;
/* fall through */
case 'x':
b = 16;
goto number;
case 'd':
b = 10;
goto number;
case 'o': case 'O':
b = 8;
number:
printn((u_long)*adx, b, flag, minwidth, putfn_p, putfn_arg);
break;
case 's':
s = (char *)*adx;
while ((c = *s++)) {
(*putfn_p)(c, putfn_arg);
width++;
}
while (width++ < minwidth)
(*putfn_p)(' ', putfn_arg);
break;
case 'c':
(*putfn_p)((char)*adx, putfn_arg);
break;
case ' ':
flag |= SPACE;
goto again;
case '0':
if (minwidth == 0)
{
/* this is a flag */
flag |= ZERO;
goto again;
} /* fall through */
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
minwidth *= 10;
minwidth += c - '0';
goto again;
case 'X':
flag |= UCASE;
/* fall through */
case 'x':
b = 16;
goto number;
case 'd':
b = 10;
goto number;
case 'o': case 'O':
b = 8;
number:
if (putfn_p)
{
printn((u_long)*adx, b, flag, minwidth, putfn_p, putfn_arg);
}
len++;
break;
case 's':
s = (char *)*adx;
while ((c = *s++)) {
if (putfn_p)
{
(*putfn_p)(c, putfn_arg);
}
len++;
width++;
}
while (width++ < minwidth)
{
if (putfn_p)
{
(*putfn_p)(' ', putfn_arg);
}
len++;
}
break;
case 'c':
if (putfn_p)
{
(*putfn_p)((char)*adx, putfn_arg);
}
len++;
break;
default:
break;
}
adx++;
goto loop;

Archive Download the corresponding diff file

Revision: 2668