1*86d7f5d3SJohn Marino /*
2*86d7f5d3SJohn Marino * Copyright (c)2004 Cat's Eye Technologies. All rights reserved.
3*86d7f5d3SJohn Marino *
4*86d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without
5*86d7f5d3SJohn Marino * modification, are permitted provided that the following conditions
6*86d7f5d3SJohn Marino * are met:
7*86d7f5d3SJohn Marino *
8*86d7f5d3SJohn Marino * Redistributions of source code must retain the above copyright
9*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer.
10*86d7f5d3SJohn Marino *
11*86d7f5d3SJohn Marino * Redistributions in binary form must reproduce the above copyright
12*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in
13*86d7f5d3SJohn Marino * the documentation and/or other materials provided with the
14*86d7f5d3SJohn Marino * distribution.
15*86d7f5d3SJohn Marino *
16*86d7f5d3SJohn Marino * Neither the name of Cat's Eye Technologies nor the names of its
17*86d7f5d3SJohn Marino * contributors may be used to endorse or promote products derived
18*86d7f5d3SJohn Marino * from this software without specific prior written permission.
19*86d7f5d3SJohn Marino *
20*86d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21*86d7f5d3SJohn Marino * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*86d7f5d3SJohn Marino * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*86d7f5d3SJohn Marino * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24*86d7f5d3SJohn Marino * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25*86d7f5d3SJohn Marino * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26*86d7f5d3SJohn Marino * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27*86d7f5d3SJohn Marino * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28*86d7f5d3SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29*86d7f5d3SJohn Marino * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30*86d7f5d3SJohn Marino * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31*86d7f5d3SJohn Marino * OF THE POSSIBILITY OF SUCH DAMAGE.
32*86d7f5d3SJohn Marino */
33*86d7f5d3SJohn Marino
34*86d7f5d3SJohn Marino /*
35*86d7f5d3SJohn Marino * decode.c
36*86d7f5d3SJohn Marino * $Id: decode.c,v 1.11 2005/02/07 06:39:59 cpressey Exp $
37*86d7f5d3SJohn Marino */
38*86d7f5d3SJohn Marino
39*86d7f5d3SJohn Marino #include <ctype.h>
40*86d7f5d3SJohn Marino #include <stdlib.h>
41*86d7f5d3SJohn Marino
42*86d7f5d3SJohn Marino #include <libaura/mem.h>
43*86d7f5d3SJohn Marino #include <libaura/buffer.h>
44*86d7f5d3SJohn Marino
45*86d7f5d3SJohn Marino #define NEEDS_DFUI_STRUCTURE_DEFINITIONS
46*86d7f5d3SJohn Marino #include "dfui.h"
47*86d7f5d3SJohn Marino #undef NEEDS_DFUI_STRUCTURE_DEFINITIONS
48*86d7f5d3SJohn Marino #include "encoding.h"
49*86d7f5d3SJohn Marino #include "dump.h"
50*86d7f5d3SJohn Marino
51*86d7f5d3SJohn Marino /*** BASIC TYPES ***/
52*86d7f5d3SJohn Marino
53*86d7f5d3SJohn Marino /*
54*86d7f5d3SJohn Marino * This function returns a newly-allocated string. It is the
55*86d7f5d3SJohn Marino * caller's responsibility that it be free()'ed.
56*86d7f5d3SJohn Marino */
57*86d7f5d3SJohn Marino char *
dfui_decode_string(struct aura_buffer * e)58*86d7f5d3SJohn Marino dfui_decode_string(struct aura_buffer *e)
59*86d7f5d3SJohn Marino {
60*86d7f5d3SJohn Marino char *str;
61*86d7f5d3SJohn Marino int i = 0;
62*86d7f5d3SJohn Marino int len = 0;
63*86d7f5d3SJohn Marino
64*86d7f5d3SJohn Marino while (isdigit(aura_buffer_peek_char(e)) && !aura_buffer_eof(e)) {
65*86d7f5d3SJohn Marino len = len * 10 + aura_buffer_scan_char(e) - '0';
66*86d7f5d3SJohn Marino }
67*86d7f5d3SJohn Marino
68*86d7f5d3SJohn Marino str = aura_malloc(len + 1, "decoded string");
69*86d7f5d3SJohn Marino
70*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, ":")) return(NULL);
71*86d7f5d3SJohn Marino while (len > 0 && !aura_buffer_eof(e)) {
72*86d7f5d3SJohn Marino str[i++] = aura_buffer_scan_char(e);
73*86d7f5d3SJohn Marino len--;
74*86d7f5d3SJohn Marino }
75*86d7f5d3SJohn Marino
76*86d7f5d3SJohn Marino str[i] = '\0';
77*86d7f5d3SJohn Marino
78*86d7f5d3SJohn Marino return(str);
79*86d7f5d3SJohn Marino }
80*86d7f5d3SJohn Marino
81*86d7f5d3SJohn Marino int
dfui_decode_int(struct aura_buffer * e)82*86d7f5d3SJohn Marino dfui_decode_int(struct aura_buffer *e)
83*86d7f5d3SJohn Marino {
84*86d7f5d3SJohn Marino int x = 0;
85*86d7f5d3SJohn Marino
86*86d7f5d3SJohn Marino while (isdigit(aura_buffer_peek_char(e)) && !aura_buffer_eof(e)) {
87*86d7f5d3SJohn Marino x = x * 10 + aura_buffer_scan_char(e) - '0';
88*86d7f5d3SJohn Marino }
89*86d7f5d3SJohn Marino if (aura_buffer_expect(e, " ")) {
90*86d7f5d3SJohn Marino return(x);
91*86d7f5d3SJohn Marino } else {
92*86d7f5d3SJohn Marino return(0);
93*86d7f5d3SJohn Marino }
94*86d7f5d3SJohn Marino }
95*86d7f5d3SJohn Marino
96*86d7f5d3SJohn Marino int
dfui_decode_bool(struct aura_buffer * e)97*86d7f5d3SJohn Marino dfui_decode_bool(struct aura_buffer *e)
98*86d7f5d3SJohn Marino {
99*86d7f5d3SJohn Marino char c;
100*86d7f5d3SJohn Marino
101*86d7f5d3SJohn Marino c = aura_buffer_scan_char(e);
102*86d7f5d3SJohn Marino
103*86d7f5d3SJohn Marino if (c == 'Y')
104*86d7f5d3SJohn Marino return(1);
105*86d7f5d3SJohn Marino else if (c == 'N')
106*86d7f5d3SJohn Marino return(0);
107*86d7f5d3SJohn Marino else /* XXX ??? error */
108*86d7f5d3SJohn Marino return(0);
109*86d7f5d3SJohn Marino }
110*86d7f5d3SJohn Marino
111*86d7f5d3SJohn Marino /*** FORM TYPES ***/
112*86d7f5d3SJohn Marino
113*86d7f5d3SJohn Marino struct dfui_info *
dfui_decode_info(struct aura_buffer * e)114*86d7f5d3SJohn Marino dfui_decode_info(struct aura_buffer *e)
115*86d7f5d3SJohn Marino {
116*86d7f5d3SJohn Marino char *name, *short_desc, *long_desc;
117*86d7f5d3SJohn Marino struct dfui_info *i;
118*86d7f5d3SJohn Marino
119*86d7f5d3SJohn Marino name = dfui_decode_string(e);
120*86d7f5d3SJohn Marino short_desc = dfui_decode_string(e);
121*86d7f5d3SJohn Marino long_desc = dfui_decode_string(e);
122*86d7f5d3SJohn Marino
123*86d7f5d3SJohn Marino i = dfui_info_new(name, short_desc, long_desc);
124*86d7f5d3SJohn Marino
125*86d7f5d3SJohn Marino free(name);
126*86d7f5d3SJohn Marino free(short_desc);
127*86d7f5d3SJohn Marino free(long_desc);
128*86d7f5d3SJohn Marino
129*86d7f5d3SJohn Marino return(i);
130*86d7f5d3SJohn Marino }
131*86d7f5d3SJohn Marino
132*86d7f5d3SJohn Marino struct dfui_field *
dfui_decode_field(struct aura_buffer * e)133*86d7f5d3SJohn Marino dfui_decode_field(struct aura_buffer *e)
134*86d7f5d3SJohn Marino {
135*86d7f5d3SJohn Marino char *id;
136*86d7f5d3SJohn Marino struct dfui_info *i;
137*86d7f5d3SJohn Marino struct dfui_field *fi;
138*86d7f5d3SJohn Marino
139*86d7f5d3SJohn Marino id = dfui_decode_string(e);
140*86d7f5d3SJohn Marino i = dfui_decode_info(e);
141*86d7f5d3SJohn Marino
142*86d7f5d3SJohn Marino fi = dfui_field_new(id, i);
143*86d7f5d3SJohn Marino fi->option_head = dfui_decode_options(e);
144*86d7f5d3SJohn Marino fi->property_head = dfui_decode_properties(e);
145*86d7f5d3SJohn Marino free(id);
146*86d7f5d3SJohn Marino
147*86d7f5d3SJohn Marino return(fi);
148*86d7f5d3SJohn Marino }
149*86d7f5d3SJohn Marino
150*86d7f5d3SJohn Marino struct dfui_field *
dfui_decode_fields(struct aura_buffer * e)151*86d7f5d3SJohn Marino dfui_decode_fields(struct aura_buffer *e)
152*86d7f5d3SJohn Marino {
153*86d7f5d3SJohn Marino struct dfui_field *head = NULL, *fi;
154*86d7f5d3SJohn Marino
155*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, "f{")) return(NULL);
156*86d7f5d3SJohn Marino while (aura_buffer_peek_char(e) != '}') {
157*86d7f5d3SJohn Marino fi = dfui_decode_field(e);
158*86d7f5d3SJohn Marino fi->next = head;
159*86d7f5d3SJohn Marino head = fi;
160*86d7f5d3SJohn Marino }
161*86d7f5d3SJohn Marino aura_buffer_expect(e, "}");
162*86d7f5d3SJohn Marino
163*86d7f5d3SJohn Marino return(head);
164*86d7f5d3SJohn Marino }
165*86d7f5d3SJohn Marino
166*86d7f5d3SJohn Marino struct dfui_option *
dfui_decode_option(struct aura_buffer * e)167*86d7f5d3SJohn Marino dfui_decode_option(struct aura_buffer *e)
168*86d7f5d3SJohn Marino {
169*86d7f5d3SJohn Marino char *value;
170*86d7f5d3SJohn Marino
171*86d7f5d3SJohn Marino value = dfui_decode_string(e);
172*86d7f5d3SJohn Marino
173*86d7f5d3SJohn Marino return(dfui_option_new(value));
174*86d7f5d3SJohn Marino }
175*86d7f5d3SJohn Marino
176*86d7f5d3SJohn Marino struct dfui_option *
dfui_decode_options(struct aura_buffer * e)177*86d7f5d3SJohn Marino dfui_decode_options(struct aura_buffer *e)
178*86d7f5d3SJohn Marino {
179*86d7f5d3SJohn Marino struct dfui_option *head = NULL, *o;
180*86d7f5d3SJohn Marino
181*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, "O{")) return(NULL);
182*86d7f5d3SJohn Marino while (aura_buffer_peek_char(e) != '}') {
183*86d7f5d3SJohn Marino o = dfui_decode_option(e);
184*86d7f5d3SJohn Marino o->next = head;
185*86d7f5d3SJohn Marino head = o;
186*86d7f5d3SJohn Marino }
187*86d7f5d3SJohn Marino aura_buffer_expect(e, "}");
188*86d7f5d3SJohn Marino
189*86d7f5d3SJohn Marino return(head);
190*86d7f5d3SJohn Marino }
191*86d7f5d3SJohn Marino
192*86d7f5d3SJohn Marino struct dfui_action *
dfui_decode_action(struct aura_buffer * e)193*86d7f5d3SJohn Marino dfui_decode_action(struct aura_buffer *e)
194*86d7f5d3SJohn Marino {
195*86d7f5d3SJohn Marino char *id;
196*86d7f5d3SJohn Marino struct dfui_info *i;
197*86d7f5d3SJohn Marino struct dfui_action *a;
198*86d7f5d3SJohn Marino
199*86d7f5d3SJohn Marino id = dfui_decode_string(e);
200*86d7f5d3SJohn Marino i = dfui_decode_info(e);
201*86d7f5d3SJohn Marino a = dfui_action_new(id, i);
202*86d7f5d3SJohn Marino a->property_head = dfui_decode_properties(e);
203*86d7f5d3SJohn Marino free(id);
204*86d7f5d3SJohn Marino
205*86d7f5d3SJohn Marino return(a);
206*86d7f5d3SJohn Marino }
207*86d7f5d3SJohn Marino
208*86d7f5d3SJohn Marino struct dfui_action *
dfui_decode_actions(struct aura_buffer * e)209*86d7f5d3SJohn Marino dfui_decode_actions(struct aura_buffer *e)
210*86d7f5d3SJohn Marino {
211*86d7f5d3SJohn Marino struct dfui_action *head = NULL, *a;
212*86d7f5d3SJohn Marino
213*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, "a{")) return(NULL);
214*86d7f5d3SJohn Marino while (aura_buffer_peek_char(e) != '}') {
215*86d7f5d3SJohn Marino a = dfui_decode_action(e);
216*86d7f5d3SJohn Marino a->next = head;
217*86d7f5d3SJohn Marino head = a;
218*86d7f5d3SJohn Marino }
219*86d7f5d3SJohn Marino aura_buffer_expect(e, "}");
220*86d7f5d3SJohn Marino
221*86d7f5d3SJohn Marino return(head);
222*86d7f5d3SJohn Marino }
223*86d7f5d3SJohn Marino
224*86d7f5d3SJohn Marino struct dfui_celldata *
dfui_decode_celldata(struct aura_buffer * e)225*86d7f5d3SJohn Marino dfui_decode_celldata(struct aura_buffer *e)
226*86d7f5d3SJohn Marino {
227*86d7f5d3SJohn Marino char *field_id;
228*86d7f5d3SJohn Marino char *value;
229*86d7f5d3SJohn Marino struct dfui_celldata *c;
230*86d7f5d3SJohn Marino
231*86d7f5d3SJohn Marino field_id = dfui_decode_string(e);
232*86d7f5d3SJohn Marino value = dfui_decode_string(e);
233*86d7f5d3SJohn Marino
234*86d7f5d3SJohn Marino c = dfui_celldata_new(field_id, value);
235*86d7f5d3SJohn Marino
236*86d7f5d3SJohn Marino free(field_id);
237*86d7f5d3SJohn Marino free(value);
238*86d7f5d3SJohn Marino
239*86d7f5d3SJohn Marino return(c);
240*86d7f5d3SJohn Marino }
241*86d7f5d3SJohn Marino
242*86d7f5d3SJohn Marino struct dfui_celldata *
dfui_decode_celldatas(struct aura_buffer * e)243*86d7f5d3SJohn Marino dfui_decode_celldatas(struct aura_buffer *e)
244*86d7f5d3SJohn Marino {
245*86d7f5d3SJohn Marino struct dfui_celldata *c, *head = NULL;
246*86d7f5d3SJohn Marino
247*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, "d{")) return(NULL);
248*86d7f5d3SJohn Marino while (aura_buffer_peek_char(e) != '}') {
249*86d7f5d3SJohn Marino c = dfui_decode_celldata(e);
250*86d7f5d3SJohn Marino c->next = head;
251*86d7f5d3SJohn Marino head = c;
252*86d7f5d3SJohn Marino }
253*86d7f5d3SJohn Marino aura_buffer_expect(e, "}");
254*86d7f5d3SJohn Marino
255*86d7f5d3SJohn Marino return(head);
256*86d7f5d3SJohn Marino }
257*86d7f5d3SJohn Marino
258*86d7f5d3SJohn Marino struct dfui_property *
dfui_decode_property(struct aura_buffer * e)259*86d7f5d3SJohn Marino dfui_decode_property(struct aura_buffer *e)
260*86d7f5d3SJohn Marino {
261*86d7f5d3SJohn Marino char *name, *value;
262*86d7f5d3SJohn Marino struct dfui_property *h;
263*86d7f5d3SJohn Marino
264*86d7f5d3SJohn Marino name = dfui_decode_string(e);
265*86d7f5d3SJohn Marino value = dfui_decode_string(e);
266*86d7f5d3SJohn Marino
267*86d7f5d3SJohn Marino h = dfui_property_new(name, value);
268*86d7f5d3SJohn Marino
269*86d7f5d3SJohn Marino free(value);
270*86d7f5d3SJohn Marino free(name);
271*86d7f5d3SJohn Marino
272*86d7f5d3SJohn Marino return(h);
273*86d7f5d3SJohn Marino }
274*86d7f5d3SJohn Marino
275*86d7f5d3SJohn Marino struct dfui_property *
dfui_decode_properties(struct aura_buffer * e)276*86d7f5d3SJohn Marino dfui_decode_properties(struct aura_buffer *e)
277*86d7f5d3SJohn Marino {
278*86d7f5d3SJohn Marino struct dfui_property *h, *head = NULL;
279*86d7f5d3SJohn Marino
280*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, "p{")) return(NULL);
281*86d7f5d3SJohn Marino while (aura_buffer_peek_char(e) != '}') {
282*86d7f5d3SJohn Marino h = dfui_decode_property(e);
283*86d7f5d3SJohn Marino h->next = head;
284*86d7f5d3SJohn Marino head = h;
285*86d7f5d3SJohn Marino }
286*86d7f5d3SJohn Marino aura_buffer_expect(e, "}");
287*86d7f5d3SJohn Marino
288*86d7f5d3SJohn Marino return(head);
289*86d7f5d3SJohn Marino }
290*86d7f5d3SJohn Marino
291*86d7f5d3SJohn Marino struct dfui_dataset *
dfui_decode_dataset(struct aura_buffer * e)292*86d7f5d3SJohn Marino dfui_decode_dataset(struct aura_buffer *e)
293*86d7f5d3SJohn Marino {
294*86d7f5d3SJohn Marino struct dfui_dataset *ds;
295*86d7f5d3SJohn Marino
296*86d7f5d3SJohn Marino ds = dfui_dataset_new();
297*86d7f5d3SJohn Marino ds->celldata_head = dfui_decode_celldatas(e);
298*86d7f5d3SJohn Marino
299*86d7f5d3SJohn Marino return(ds);
300*86d7f5d3SJohn Marino }
301*86d7f5d3SJohn Marino
302*86d7f5d3SJohn Marino struct dfui_dataset *
dfui_decode_datasets(struct aura_buffer * e)303*86d7f5d3SJohn Marino dfui_decode_datasets(struct aura_buffer *e)
304*86d7f5d3SJohn Marino {
305*86d7f5d3SJohn Marino struct dfui_dataset *head = NULL, *ds;
306*86d7f5d3SJohn Marino
307*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, "D{")) return(NULL);
308*86d7f5d3SJohn Marino while (aura_buffer_peek_char(e) != '}') {
309*86d7f5d3SJohn Marino ds = dfui_decode_dataset(e);
310*86d7f5d3SJohn Marino ds->next = head;
311*86d7f5d3SJohn Marino head = ds;
312*86d7f5d3SJohn Marino }
313*86d7f5d3SJohn Marino aura_buffer_expect(e, "}");
314*86d7f5d3SJohn Marino
315*86d7f5d3SJohn Marino return(head);
316*86d7f5d3SJohn Marino }
317*86d7f5d3SJohn Marino
318*86d7f5d3SJohn Marino struct dfui_form *
dfui_decode_form(struct aura_buffer * e)319*86d7f5d3SJohn Marino dfui_decode_form(struct aura_buffer *e)
320*86d7f5d3SJohn Marino {
321*86d7f5d3SJohn Marino char *id;
322*86d7f5d3SJohn Marino struct dfui_info *i;
323*86d7f5d3SJohn Marino struct dfui_form *f;
324*86d7f5d3SJohn Marino
325*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, "F{")) return(NULL);
326*86d7f5d3SJohn Marino
327*86d7f5d3SJohn Marino id = dfui_decode_string(e);
328*86d7f5d3SJohn Marino i = dfui_decode_info(e);
329*86d7f5d3SJohn Marino
330*86d7f5d3SJohn Marino f = dfui_form_new(id, i);
331*86d7f5d3SJohn Marino
332*86d7f5d3SJohn Marino dfui_form_set_multiple(f, dfui_decode_bool(e));
333*86d7f5d3SJohn Marino dfui_form_set_extensible(f, dfui_decode_bool(e));
334*86d7f5d3SJohn Marino
335*86d7f5d3SJohn Marino f->field_head = dfui_decode_fields(e);
336*86d7f5d3SJohn Marino f->action_head = dfui_decode_actions(e);
337*86d7f5d3SJohn Marino f->dataset_head = dfui_decode_datasets(e);
338*86d7f5d3SJohn Marino f->property_head = dfui_decode_properties(e);
339*86d7f5d3SJohn Marino
340*86d7f5d3SJohn Marino aura_buffer_expect(e, "}");
341*86d7f5d3SJohn Marino free(id);
342*86d7f5d3SJohn Marino
343*86d7f5d3SJohn Marino return(f);
344*86d7f5d3SJohn Marino }
345*86d7f5d3SJohn Marino
346*86d7f5d3SJohn Marino struct dfui_response *
dfui_decode_response(struct aura_buffer * e)347*86d7f5d3SJohn Marino dfui_decode_response(struct aura_buffer *e)
348*86d7f5d3SJohn Marino {
349*86d7f5d3SJohn Marino char *form_id;
350*86d7f5d3SJohn Marino char *action_id;
351*86d7f5d3SJohn Marino struct dfui_response *r;
352*86d7f5d3SJohn Marino
353*86d7f5d3SJohn Marino if (!aura_buffer_expect(e, "R{")) return(NULL);
354*86d7f5d3SJohn Marino
355*86d7f5d3SJohn Marino form_id = dfui_decode_string(e);
356*86d7f5d3SJohn Marino action_id = dfui_decode_string(e);
357*86d7f5d3SJohn Marino r = dfui_response_new(form_id, action_id);
358*86d7f5d3SJohn Marino r->dataset_head = dfui_decode_datasets(e);
359*86d7f5d3SJohn Marino free(form_id);
360*86d7f5d3SJohn Marino free(action_id);
361*86d7f5d3SJohn Marino
362*86d7f5d3SJohn Marino aura_buffer_expect(e, "}");
363*86d7f5d3SJohn Marino
364*86d7f5d3SJohn Marino return(r);
365*86d7f5d3SJohn Marino }
366*86d7f5d3SJohn Marino
367*86d7f5d3SJohn Marino struct dfui_progress *
dfui_decode_progress(struct aura_buffer * e)368*86d7f5d3SJohn Marino dfui_decode_progress(struct aura_buffer *e)
369*86d7f5d3SJohn Marino {
370*86d7f5d3SJohn Marino struct dfui_info *i;
371*86d7f5d3SJohn Marino int amount, streaming;
372*86d7f5d3SJohn Marino char *msg_line;
373*86d7f5d3SJohn Marino struct dfui_progress *pr;
374*86d7f5d3SJohn Marino
375*86d7f5d3SJohn Marino i = dfui_decode_info(e);
376*86d7f5d3SJohn Marino amount = dfui_decode_int(e);
377*86d7f5d3SJohn Marino streaming = dfui_decode_int(e);
378*86d7f5d3SJohn Marino msg_line = dfui_decode_string(e);
379*86d7f5d3SJohn Marino
380*86d7f5d3SJohn Marino pr = dfui_progress_new(i, amount);
381*86d7f5d3SJohn Marino dfui_progress_set_streaming(pr, streaming);
382*86d7f5d3SJohn Marino dfui_progress_set_msg_line(pr, msg_line);
383*86d7f5d3SJohn Marino
384*86d7f5d3SJohn Marino free(msg_line);
385*86d7f5d3SJohn Marino
386*86d7f5d3SJohn Marino return(pr);
387*86d7f5d3SJohn Marino }
388