File: import.c

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (276 lines) | stat: -rw-r--r-- 7,153 bytes parent folder | download
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/* Copyright INRIA */
#include "../machine.h"
#include <string.h>
#include "import.h"
extern struct {
  integer kfun;
} C2F(curblk);



ScicosImport  scicos_imp={
(double *) NULL,   /* x */
(integer *) NULL,  /* xptr */
(double *) NULL,   /* z */
(integer *) NULL,  /* zptr */
(integer *) NULL,  /* iz */
(integer *) NULL,  /* izptr */

(integer *) NULL,  /* inpptr */
(integer *) NULL,  /* inplnk */
(integer *) NULL,  /* outptr */
(integer *) NULL,  /* outlnk */
(integer *) NULL,  /* lnkptr */
0,                 /* nlnkptr */
(double *) NULL,   /* rpar */
(integer *) NULL,  /* rpptr */
(integer *) NULL,  /* ipar */
(integer *) NULL,  /* ipptr */
0,                 /* nblk */
(double *) NULL,   /* outtb */
0,                 /* nout */
(integer *) NULL,  /* subs */
0,                 /* nsubs */
(double *) NULL,   /* tevts */
(integer *) NULL,  /* evtspt */
0,                 /* nevts */
0,                 /* pointi */
(integer *) NULL,  /* oord */
(integer *) NULL,  /* zord */
(integer *) NULL,  /* funptr */
(integer *) NULL,   /* funtyp */
(integer *) NULL,   /* ztyp */
(integer *) NULL,   /* cord */
(integer *) NULL,   /* ordclk */
(integer *) NULL,   /* clkptr */
(integer *) NULL,   /* ordptr */
(integer *) NULL   /* critev */
};

void  
C2F(makescicosimport)(x,xptr,z,zptr,iz,izptr,
     inpptr,inplnk,outptr,outlnk,lnkptr,nlnkptr,
     rpar,rpptr,ipar,ipptr,nblk,outtb,nout,subs,nsubs,
     tevts,evtspt,nevts,pointi,oord,zord,
     funptr,funtyp,ztyp,cord,ordclk,clkptr,ordptr,critev)
     
double *x ,*z,*outtb,*rpar,*tevts;
integer *xptr,*zptr,*iz,*izptr,*inpptr,*inplnk,*outptr,*outlnk,*lnkptr;
integer *nlnkptr,*rpptr,*ipar,*ipptr,*nblk,*nout,*subs,*nsubs;
integer *evtspt,*nevts,*pointi,*oord,*zord,*funptr,*funtyp,*ztyp,*cord,*ordclk,*clkptr,*ordptr,*critev;
     
{
    scicos_imp.x=x;
    scicos_imp.xptr=xptr;
    scicos_imp.z=z;
    scicos_imp.zptr=zptr;
    scicos_imp.iz=iz;
    scicos_imp.izptr=izptr;

    scicos_imp.inpptr=inpptr;
    scicos_imp.inplnk=inplnk;
    scicos_imp.outptr=outptr;
    scicos_imp.outlnk=outlnk;
    scicos_imp.lnkptr=lnkptr;
    scicos_imp.nlnkptr=*nlnkptr;

    scicos_imp.rpar=rpar;
    scicos_imp.rpptr=rpptr;
    scicos_imp.ipar=ipar;
    scicos_imp.ipptr=ipptr;
    scicos_imp.nblk=*nblk;
    scicos_imp.outtb=outtb;
    scicos_imp.nout=*nout;

    scicos_imp.subs=subs;
    scicos_imp.nsubs=*nsubs;

    scicos_imp.tevts=tevts;
    scicos_imp.evtspt=evtspt;
    scicos_imp.nevts=*nevts;
    scicos_imp.pointi=*pointi;

    scicos_imp.oord=oord;
    scicos_imp.zord=zord;

    scicos_imp.funptr=funptr;
    scicos_imp.funtyp=funtyp;

    scicos_imp.ztyp=ztyp;
    scicos_imp.cord=cord;
    scicos_imp.ordclk=ordclk;
    scicos_imp.clkptr=clkptr;
    scicos_imp.ordptr=ordptr;
    scicos_imp.critev=critev;
}

void
C2F(clearscicosimport)()
{
    scicos_imp.x=(double *) NULL;
    scicos_imp.xptr=(integer *) NULL;
    scicos_imp.z=(double *) NULL;
    scicos_imp.zptr=(integer *) NULL;
    scicos_imp.iz=(integer *) NULL;
    scicos_imp.izptr=(integer *) NULL;

    scicos_imp.inpptr=(integer *) NULL;
    scicos_imp.inplnk=(integer *) NULL;
    scicos_imp.outptr=(integer *) NULL;
    scicos_imp.outlnk=(integer *) NULL;
    scicos_imp.lnkptr=(integer *) NULL;
    scicos_imp.nlnkptr=0;

    scicos_imp.rpar=(double *) NULL;
    scicos_imp.rpptr=(integer *) NULL;
    scicos_imp.ipar=(integer *) NULL;
    scicos_imp.ipptr=(integer *) NULL;
    scicos_imp.nblk=0;
    scicos_imp.outtb=(double *) NULL;
    scicos_imp.nout=0;

    scicos_imp.subs=(integer *) NULL;
    scicos_imp.nsubs=0;
    scicos_imp.tevts=(double *) NULL;
    scicos_imp.evtspt=(integer *) NULL;
    scicos_imp.nevts=0;
    scicos_imp.pointi=0;

    scicos_imp.oord=(integer *) NULL;
    scicos_imp.zord=(integer *) NULL;

    scicos_imp.funptr=(integer *) NULL;
    scicos_imp.funtyp=(integer *) NULL;

    scicos_imp.ztyp=(integer *) NULL;
    scicos_imp.cord=(integer *) NULL;
    scicos_imp.ordclk=(integer *) NULL;
    scicos_imp.clkptr=(integer *) NULL;
    scicos_imp.ordptr=(integer *) NULL;
    scicos_imp.critev=(integer *) NULL;
}

integer  
C2F(getscicosvars)(what,v,nv,type)
integer *what;  /* data structure selection */
double **v;    /* Pointer to the beginning of the imported data */
integer *nv;   /* size of the imported data */
integer *type ;/* type of the imported data 0:integer,1:double */
{
    int nblk;

    if (scicos_imp.x==(double *)NULL){
	*v=(void *) NULL;
	return(2); /* undefined import table scicos is not running */
    }
    nblk=scicos_imp.nblk;
    /* imported from */
    switch (*what) {
    case 1 :			/* continuous state */
	*nv=(integer) (scicos_imp.xptr[nblk]-scicos_imp.xptr[0]);
        *v=(void *)(scicos_imp.x);
	*type=1;
	break;
    case 2 :			/* continuous state splitting array*/
	*nv=(integer)(nblk+1);
	*v=(void *) (scicos_imp.xptr);
	*type=0;
	break;
    case 3 :			/* discrete state */
	*nv=(integer)(scicos_imp.zptr[nblk]-scicos_imp.zptr[0]);
	*v=(void *) (scicos_imp.z);
	*type=1;
	break;
    case 4 :			/* discrete  state splitting array*/
	*nv=(integer)(nblk+1);
	*v=(void *) (scicos_imp.zptr);
	*type=0;
	break;
    case 5 :			/* rpar */
	*nv=(integer)(scicos_imp.rpptr[nblk]-scicos_imp.rpptr[0]);
	*v=(void *) (scicos_imp.rpar);
	*type=1;
	break;
    case 6 :			/* rpar  splitting array*/
	*nv=(integer)(nblk+1);
	*v=(void *) (scicos_imp.rpptr);
	*type=0;
	break;
    case 7 :			/* ipar */
	*nv=(integer)(scicos_imp.ipptr[nblk]-scicos_imp.ipptr[0]);
	*v=(void *) (scicos_imp.ipar);
	*type=0;
	break;
    case 8 :			/* ipar  splitting array*/
	*nv=(integer)(nblk+1);
	*v=(void *) (scicos_imp.ipptr);
	*type=0;
	break;
    case 9 :			/* outtb */
	*nv=(integer)(scicos_imp.nout);
	*v=(void *) (scicos_imp.outtb);
	*type=1;
	break;
    case 10 :                   /* inpptr */
	*nv=(integer)(nblk+1);
	*v=(void *) (scicos_imp.inpptr); 
	*type=0;
	break;
    case 11 :                   /* outptr */
	*nv=(integer)(nblk+1);
	*v=(void *) (scicos_imp.outptr); 
	*type=0;
	break;
    case 12 :                   /* inplnk */
	*nv=(integer)(scicos_imp.inpptr[nblk]-scicos_imp.inpptr[0]); 
	*v=(void *) (scicos_imp.inplnk); 
	*type=0;
	break;
    case 13 :                   /* outlnk */
	*nv=(integer)(scicos_imp.outptr[nblk]-scicos_imp.outptr[0]); 
	*v=(void *) (scicos_imp.outlnk); 
	*type=0;
	break;
    case 14 :                   /* lnkptr */
	*nv=(integer)(scicos_imp.nlnkptr);
	*v=(void *) (scicos_imp.lnkptr); 
	*type=0;
	break;
    }
    return(0);
}
void 
C2F(getlabel)(kfun,label,n)
integer *n, *kfun;  /* length of the label */
char **label;    
{
    int k;
    int job=1;

    k= *kfun;
    *n=(integer)(scicos_imp.izptr[k]-scicos_imp.izptr[k-1]);
    if (*n>0 )
	F2C(cvstr)(n,&(scicos_imp.iz[scicos_imp.izptr[k-1]-1]),*label,&job,*n);
}
void 
C2F(getscilabel)(kfun,label,n)
integer *n, *kfun;  /* length of the label */
integer label[];    
{
    int k,i;
    integer *u,*y;

    k= *kfun;
    *n=(integer)(scicos_imp.izptr[k]-scicos_imp.izptr[k-1]);
    if (*n>0 ) {
	u=(integer *)&(scicos_imp.iz[scicos_imp.izptr[k-1]-1]);
	y=label;
	for (i=0;i<*n;i++)
	    *(y++)=*(u++);  
	}
}

integer C2F(getcurblock)()
{
return(C2F(curblk).kfun);
    }