summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/g_readwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/g_readwrite.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/g_readwrite.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_readwrite.c b/apps/plugins/pdbox/PDa/src/g_readwrite.c
index 55759dbf1a..81bf02e512 100644
--- a/apps/plugins/pdbox/PDa/src/g_readwrite.c
+++ b/apps/plugins/pdbox/PDa/src/g_readwrite.c
@@ -8,18 +8,29 @@ collection of "scalar" objects. Routines here can save collections of
8scalars into a file and reload them; also, support is included here for 8scalars into a file and reload them; also, support is included here for
9*/ 9*/
10 10
11#ifdef ROCKBOX
12#include "plugin.h"
13#include "pdbox.h"
14#include "m_pd.h"
15#include "g_canvas.h"
16#else /* ROCKBOX */
11#include <stdlib.h> 17#include <stdlib.h>
12#include <stdio.h> 18#include <stdio.h>
13#include "m_pd.h" 19#include "m_pd.h"
14#include "g_canvas.h" 20#include "g_canvas.h"
15#include <string.h> 21#include <string.h>
22#endif /* ROCKBOX */
16 23
17 /* the following routines read "scalars" from a file into a canvas. */ 24 /* the following routines read "scalars" from a file into a canvas. */
18 25
19static int canvas_scanbinbuf(int natoms, t_atom *vec, int *p_indexout, 26static int canvas_scanbinbuf(int natoms, t_atom *vec, int *p_indexout,
20 int *p_next) 27 int *p_next)
21{ 28{
29#ifdef ROCKBOX
30 int i;
31#else
22 int i, j; 32 int i, j;
33#endif
23 int indexwas = *p_next; 34 int indexwas = *p_next;
24 *p_indexout = indexwas; 35 *p_indexout = indexwas;
25 if (indexwas >= natoms) 36 if (indexwas >= natoms)
@@ -38,6 +49,9 @@ int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
38static void canvas_readerror(int natoms, t_atom *vec, int message, 49static void canvas_readerror(int natoms, t_atom *vec, int message,
39 int nline, char *s) 50 int nline, char *s)
40{ 51{
52#ifdef ROCKBOX
53 (void) natoms;
54#endif
41 error(s); 55 error(s);
42 startpost("line was:"); 56 startpost("line was:");
43 postatom(nline, vec + message); 57 postatom(nline, vec + message);
@@ -49,7 +63,11 @@ static void canvas_readerror(int natoms, t_atom *vec, int message,
49static void glist_readatoms(t_glist *x, int natoms, t_atom *vec, 63static void glist_readatoms(t_glist *x, int natoms, t_atom *vec,
50 int *p_nextmsg, t_symbol *templatesym, t_word *w, int argc, t_atom *argv) 64 int *p_nextmsg, t_symbol *templatesym, t_word *w, int argc, t_atom *argv)
51{ 65{
66#ifdef ROCKBOX
67 int message, n, i;
68#else
52 int message, nline, n, i; 69 int message, nline, n, i;
70#endif
53 71
54 t_template *template = template_findbyname(templatesym); 72 t_template *template = template_findbyname(templatesym);
55 if (!template) 73 if (!template)
@@ -64,7 +82,9 @@ static void glist_readatoms(t_glist *x, int natoms, t_atom *vec,
64 { 82 {
65 if (template->t_vec[i].ds_type == DT_ARRAY) 83 if (template->t_vec[i].ds_type == DT_ARRAY)
66 { 84 {
85#ifndef ROCKBOX
67 int j; 86 int j;
87#endif
68 t_array *a = w[i].w_array; 88 t_array *a = w[i].w_array;
69 int elemsize = a->a_elemsize, nitems = 0; 89 int elemsize = a->a_elemsize, nitems = 0;
70 t_symbol *arraytemplatesym = template->t_vec[i].ds_arraytemplate; 90 t_symbol *arraytemplatesym = template->t_vec[i].ds_arraytemplate;
@@ -104,7 +124,11 @@ static void glist_readatoms(t_glist *x, int natoms, t_atom *vec,
104int glist_readscalar(t_glist *x, int natoms, t_atom *vec, 124int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
105 int *p_nextmsg, int selectit) 125 int *p_nextmsg, int selectit)
106{ 126{
127#ifdef ROCKBOX
128 int message, nline;
129#else
107 int message, i, j, nline; 130 int message, i, j, nline;
131#endif
108 t_template *template; 132 t_template *template;
109 t_symbol *templatesym; 133 t_symbol *templatesym;
110 t_scalar *sc; 134 t_scalar *sc;
@@ -159,10 +183,16 @@ int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
159 183
160void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem) 184void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem)
161{ 185{
186#ifdef ROCKBOX
187 int natoms, nline, message, nextmsg = 0;
188#else
162 t_canvas *canvas = glist_getcanvas(x); 189 t_canvas *canvas = glist_getcanvas(x);
163 int cr = 0, natoms, nline, message, nextmsg = 0, i, j, nitems; 190 int cr = 0, natoms, nline, message, nextmsg = 0, i, j, nitems;
191#endif
164 t_atom *vec; 192 t_atom *vec;
193#ifndef ROCKBOX
165 t_gobj *gobj; 194 t_gobj *gobj;
195#endif
166 196
167 natoms = binbuf_getnatom(b); 197 natoms = binbuf_getnatom(b);
168 vec = binbuf_getvec(b); 198 vec = binbuf_getvec(b);
@@ -244,8 +274,12 @@ static void glist_doread(t_glist *x, t_symbol *filename, t_symbol *format,
244 t_binbuf *b = binbuf_new(); 274 t_binbuf *b = binbuf_new();
245 t_canvas *canvas = glist_getcanvas(x); 275 t_canvas *canvas = glist_getcanvas(x);
246 int wasvis = glist_isvisible(canvas); 276 int wasvis = glist_isvisible(canvas);
277#ifdef ROCKBOX
278 int cr = 0;
279#else
247 int cr = 0, natoms, nline, message, nextmsg = 0, i, j; 280 int cr = 0, natoms, nline, message, nextmsg = 0, i, j;
248 t_atom *vec; 281 t_atom *vec;
282#endif
249 283
250 if (!strcmp(format->s_name, "cr")) 284 if (!strcmp(format->s_name, "cr"))
251 cr = 1; 285 cr = 1;
@@ -302,7 +336,7 @@ void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b)
302 /* take the new object off the list */ 336 /* take the new object off the list */
303 if (ntotal) 337 if (ntotal)
304 { 338 {
305 for (y = x->gl_list, nnew = 1; y2 = y->g_next; 339 for(y = x->gl_list, nnew = 1; (y2 = y->g_next);
306 y = y2, nnew++) 340 y = y2, nnew++)
307 if (nnew == ntotal) 341 if (nnew == ntotal)
308 { 342 {
@@ -360,7 +394,9 @@ static void glist_writelist(t_gobj *y, t_binbuf *b);
360void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b, 394void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b,
361 int amarrayelement) 395 int amarrayelement)
362{ 396{
397#ifndef ROCKBOX
363 t_dataslot *ds; 398 t_dataslot *ds;
399#endif
364 t_template *template = template_findbyname(templatesym); 400 t_template *template = template_findbyname(templatesym);
365 t_atom *a = (t_atom *)t_getbytes(0); 401 t_atom *a = (t_atom *)t_getbytes(0);
366 int i, n = template->t_n, natom = 0; 402 int i, n = template->t_n, natom = 0;
@@ -532,12 +568,18 @@ t_binbuf *glist_writetobinbuf(t_glist *x, int wholething)
532 568
533static void glist_write(t_glist *x, t_symbol *filename, t_symbol *format) 569static void glist_write(t_glist *x, t_symbol *filename, t_symbol *format)
534{ 570{
571#ifdef ROCKBOX
572 int cr = 0;
573#else
535 int cr = 0, i; 574 int cr = 0, i;
575#endif
536 t_binbuf *b; 576 t_binbuf *b;
537 char buf[MAXPDSTRING]; 577 char buf[MAXPDSTRING];
578#ifndef ROCKBOX
538 t_symbol **templatevec = getbytes(0); 579 t_symbol **templatevec = getbytes(0);
539 int ntemplates = 0; 580 int ntemplates = 0;
540 t_gobj *y; 581 t_gobj *y;
582#endif
541 t_canvas *canvas = glist_getcanvas(x); 583 t_canvas *canvas = glist_getcanvas(x);
542 canvas_makefilename(canvas, filename->s_name, buf, MAXPDSTRING); 584 canvas_makefilename(canvas, filename->s_name, buf, MAXPDSTRING);
543 if (!strcmp(format->s_name, "cr")) 585 if (!strcmp(format->s_name, "cr"))
@@ -586,7 +628,7 @@ static void canvas_saveto(t_canvas *x, t_binbuf *b)
586 gobj_save(y, b); 628 gobj_save(y, b);
587 629
588 linetraverser_start(&t, x); 630 linetraverser_start(&t, x);
589 while (oc = linetraverser_next(&t)) 631 while((oc = linetraverser_next(&t)))
590 { 632 {
591 int srcno = canvas_getindex(x, &t.tr_ob->ob_g); 633 int srcno = canvas_getindex(x, &t.tr_ob->ob_g);
592 int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g); 634 int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g);
@@ -629,7 +671,9 @@ static void canvas_savetemplatesto(t_canvas *x, t_binbuf *b, int wholething)
629{ 671{
630 t_symbol **templatevec = getbytes(0); 672 t_symbol **templatevec = getbytes(0);
631 int i, ntemplates = 0; 673 int i, ntemplates = 0;
674#ifndef ROCKBOX
632 t_gobj *y; 675 t_gobj *y;
676#endif
633 canvas_collecttemplatesfor(x, &ntemplates, &templatevec, wholething); 677 canvas_collecttemplatesfor(x, &ntemplates, &templatevec, wholething);
634 for (i = 0; i < ntemplates; i++) 678 for (i = 0; i < ntemplates; i++)
635 { 679 {
@@ -687,9 +731,13 @@ static void canvas_savetofile(t_canvas *x, t_symbol *filename, t_symbol *dir)
687 731
688static void canvas_menusaveas(t_canvas *x) 732static void canvas_menusaveas(t_canvas *x)
689{ 733{
734#ifdef ROCKBOX
735 (void) x;
736#else /* ROCKBOX */
690 t_canvas *x2 = canvas_getrootfor(x); 737 t_canvas *x2 = canvas_getrootfor(x);
691 sys_vgui("pdtk_canvas_saveas .x%x \"%s\" \"%s\"\n", x2, 738 sys_vgui("pdtk_canvas_saveas .x%x \"%s\" \"%s\"\n", x2,
692 x2->gl_name->s_name, canvas_getdir(x2)->s_name); 739 x2->gl_name->s_name, canvas_getdir(x2)->s_name);
740#endif /* ROCKBOX */
693} 741}
694 742
695static void canvas_menusave(t_canvas *x) 743static void canvas_menusave(t_canvas *x)