File: stack3.c

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (659 lines) | stat: -rw-r--r-- 19,709 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
/*------------------------------------------------------------------------
 *    Graphic library
 *    Copyright (C) 1998-2000 Enpc/Inria 
 *    jpc@cereve.enpc.fr 
 --------------------------------------------------------------------------*/
/*------------------------------------------------------
 * Read and Write inside the Scilab stack 
 *------------------------------------------------------*/

#include <string.h>
#include "../stack-c.h"

extern int C2F(dmcopy)  __PARAMS((double *a, integer *na, double *b, integer *nb, integer *m, integer *n));
extern int C2F(stackg)  __PARAMS((integer *id));
extern int C2F(stackp)  __PARAMS((integer *id, integer *macmod));

/* Table of constant values */

static integer cx0 = 0;
static integer cx1 = 1;

/*------------------------------------------------------
 * read a matrix 
 *------------------------------------------------------*/

int C2F(readmat)(namex, m, n, scimat, name_len)
     char *namex;
     integer *m, *n;
     double *scimat;
     unsigned long name_len;
{
    int j;
    j = C2F(creadmat)(namex, m, n, scimat, name_len);
    return 0;
}

/*----------------------------------------------------------------
 * readmat reads vector/matrix in scilab's internal stack 
 * calling sequence 
 *     logic=creadmat('matrixname',m,n,scimat) 
 *  matrixname: character string; name of the scilab variable. 
 *  m: number of rows (output of readmat) 
 *  n: number of columns (output of readmat) 
 *  scimat: matrix entries stored columnwise (output of readmat) 
 *    Example of use: 
 *    Amat is a real 2 x 3 scilab matrix 
 *    your subroutine should be as follows: 
 *    subroutine mysubr(...) 
 *    ... 
 *    call readmat('Amat',m,n,scimat) 
 *    => m=3 , n=2, and scimat(1)=Amat(1,1) 
 *                      scimat(2)=Amat(2,1) 
 *                      scimat(3)=Amat(3,1) 
 *                      scimat(4)=Amat(1,2) ... 
 *                      scimat(5)=Amat(3,2) 
 *                      scimat(6)=Amat(3,2) 
 *----------------------------------------------------------------*/

int C2F(creadmat)(namex, m, n, scimat, name_len)
     char *namex;
     integer *m, *n;
     double *scimat;
     unsigned long name_len;
{
    integer l;
    integer id[nsiz];

    C2F(str2name)(namex, id, name_len);
    /* read   : from scilab stack -> fortran variable */
    Fin = -1;
    C2F(stackg)(id);
    if (Err > 0) return FALSE_ ; 
    if (Fin == 0) {
      Scierror(4,"Undefined variable %s\r\n",get_fname(namex,name_len));
      return FALSE_;
    }
    if ( *Infstk(Fin ) == 2)  Fin = *istk(iadr(*Lstk(Fin )) + 1 +1);
    /* get matrix data pointer */
    if (! C2F(getrmat)("creadmat", &Fin, &Fin, m, n, &l, 8L)) 	return FALSE_;

    C2F(dmcopy)(stk(l ), m, scimat, m, m, n);

    return TRUE_;
}
/*----------------------------------------------------------------
 * creadcmat reads vector/matrix in scilab's internal stack 
 * calling sequence 
 *     logic=creadcmat('matrixname',m,n,scimat) 
 *  matrixname: character string; name of the scilab variable. 
 *  m: number of rows (output of readmat) 
 *  n: number of columns (output of readmat) 
 *  scimat: matrix entries stored columnwise (output of readmat) 
 *    Example of use: 
 *    Amat is a real 2 x 3 scilab matrix 
 *    your subroutine should be as follows: 
 *    subroutine mysubr(...) 
 *    ... 
 *    call readmat('Amat',m,n,scimat) 
 *    => m=3 , n=2, and scimat(1)=Amat(1,1) 
 *                      scimat(2)=Amat(2,1) 
 *                      scimat(3)=Amat(3,1) 
 *                      scimat(4)=Amat(1,2) ... 
 *                      scimat(5)=Amat(3,2) 
 *
 * Note d'Albert Y
 * 20/12/2003
 *    Cette routine est une simple copie de creadmat et lgrement
 *    modifie pour les matrices complexes
 *
 *----------------------------------------------------------------*/

int C2F(creadcmat)(namex, m, n, scimat, name_len)
     char *namex;
     integer *m, *n;
     double *scimat;
     unsigned long name_len;
{
    integer l, ix1;
    integer id[nsiz];

    C2F(str2name)(namex, id, name_len);
    /* read   : from scilab stack -> fortran variable */
    Fin = -1;
    C2F(stackg)(id);
    if (Err > 0) return FALSE_ ; 
    if (Fin == 0) {
      Scierror(4,"Undefined variable %s\r\n",get_fname(namex,name_len));
      return FALSE_;
    }
    if ( *Infstk(Fin ) == 2)  Fin = *istk(iadr(*Lstk(Fin )) + 1 +1);
    /* get matrix data pointer */
    if (! C2F(getcmat)("creadcmat", &Fin, &Fin, m, n, &l, 8L)) 	return FALSE_;
    ix1 = *m * *n;
    C2F(dmcopy)(stk(l ), m, scimat, m, m, n);
    C2F(dmcopy)(stk(l+ix1 ), m, scimat+ix1, m, m, n);

    return TRUE_;
}

/*----------------------------------------------------------------
 * cwritemat writes vector/matrix in scilab's internal stack
 * logic=cwritemat('matrixname'//char(0),m,n,mat)
 * name: character string; name of the scilab variable ( null terMinated) 
 * m: number of rows 
 *  n: number of columns 
 *  mat: matrix entries stored columnwise in Scilab object 
 *----------------------------------------------------------------*/

int C2F(cwritemat)(namex, m, n, mat, name_len)
     char *namex;
     integer *m, *n;
     double *mat;
     unsigned long name_len;
{
  integer   ix1 = *m * *n;
  integer Rhs_k = Rhs , Top_k = Top ;
  integer l4, id[nsiz], lc, lr;
  
  C2F(str2name)(namex, id, name_len);
  /* jpc april 2002 */ 
  /* ++Top; */
  Top = Top + Nbvars + 1; 
  if (! C2F(cremat)("cwritemat", &Top, &cx0, m, n, &lr, &lc, 9L)) return  FALSE_;
  C2F(dcopy)(&ix1, mat, &cx1, stk(lr ), &cx1);
  Rhs = 0;
  l4 = C2F(iop).lct[3];
  C2F(iop).lct[3] = -1;
  C2F(stackp)(id, &cx0);
  C2F(iop).lct[3] = l4;
  Top = Top_k;
  Rhs = Rhs_k;
  if (Err > 0)  return FALSE_;
  return TRUE_;
} 

int C2F(putvar)(number, namex, name_len)
     /* Put variable number into Scilab internal stack with name "namex" */
     char *namex;
     int  *number;
     unsigned long name_len;
{
  integer Rhs_k = Rhs , Top_k = Top ;
  integer l4, id[nsiz],/* lc, lr,*/ cx0=1;
  
  C2F(str2name)(namex, id, name_len);
  Top = *number + Top -Rhs;
  Rhs = 0;
  l4 = C2F(iop).lct[3];
  C2F(iop).lct[3] = -1;
  C2F(stackp)(id, &cx0);
  C2F(iop).lct[3] = l4;
  Top = Top_k;
  Rhs = Rhs_k;
  if (Err > 0)  return FALSE_;
  return TRUE_;
} 

/*------------------------------------------------------
 *     see creadchain 
 *------------------------------------------------------*/

int C2F(readchain)(namex, itslen, chai, name_len, chai_len)
     char *namex;
     integer *itslen;
     char *chai;
     unsigned long name_len, chai_len;
{
    int j;
    j = C2F(creadchain)(namex, itslen, chai, name_len, chai_len);
    return 0;
} 

/*------------------------------------------------------
 *     this routine reads a string in scilab's  memory 
 *     and store it into chai 
 * !calling sequence 
 *     integer       itslen 
 *     character*(*) chai,name 
 *     name    : character string = name of scilab variable (input) 
 *     chai    : chain to be read (output) 
 *               null terMinated 
 *     itslen  : (input) Maximum number of character that can ne stored 
 *               in chain 
 *               (output) number of copied characters into chai 
 *     if Scilab variable x='qwert' exists 
 *     character ch*(10) 
 *     l=10 
 *     logic= creadchain('x',l,ch) returns l=5 and ch='qwert' 
 *------------------------------------------------------*/

int C2F(creadchain)(namex, itslen, chai, name_len, chai_len)
     char *namex;
     integer *itslen;
     char *chai;
     unsigned long name_len;
     unsigned long chai_len;
{
    integer ix1;
    integer m1, n1;
    integer id[nsiz];
    integer lr1;
    integer nlr1;

    Err = 0;
    C2F(str2name)(namex, id, name_len);
    Fin = -1;
    C2F(stackg)(id);
    if (Err > 0) return FALSE_ ;
    if (Fin == 0) {
      Scierror(4,"Undefined variable %s\r\n",get_fname(namex,name_len));
      return FALSE_ ;
    }
    if (*Infstk(Fin ) == 2) {
	Fin = *istk(iadr(*Lstk(Fin )) + 1 +1);
    }
    if (! C2F(getsmat)("creadchain", &Fin, &Fin, &m1, &n1, &cx1, &cx1, &lr1, &nlr1, 10L)) {
	return FALSE_;
    }
    if (m1 * n1 != 1) {
      Scierror(999,"creadchain: argument must be a string\r\n");
      return FALSE_ ;
    }

    ix1 = *itslen - 1;
    *itslen = Min(ix1,nlr1);
    C2F(cvstr)(itslen, istk(lr1 ), chai, &cx1, chai_len);
    chai[*itslen] = '\0';
    return TRUE_ ;
}

/*----------------------------------------------------------------------
 *     this routine reads name(ir,ic) in scilab's  memory 
 *     and store it into chai 
 *     if ir=ic=-1 on entry then the routines returns in ir,ic 
 *     the size of the matrix 
 * !calling sequence 
 *     integer       itslen 
 *     character*(*) chai,name 
 *     name    : character string = name of scilab variable (input) 
 *     chai    : chain to be read (output) 
 *               null terMinated 
 *     itslen  : (input) Maximum number of character that can be stored 
 *               in chain 
 *               (output) number of copied characters into chai 
 *     if Scilab variable x='qwert' exists 
 *     character ch*(10) 
 *     l=10 
 *     logic= creadchain('x',l,ch) returns l=5 and ch='qwert' 
 *----------------------------------------------------------------------*/


int C2F(creadchains)(namex, ir, ic, itslen, chai, name_len, chai_len)
     char *namex;
     integer *ir, *ic, *itslen;
     char *chai;
     unsigned long name_len;
     unsigned long chai_len;
{
    integer ix1;
    integer m1, n1;
    integer id[nsiz];
    integer lr1;
    integer nlr1;

    Err = 0;
    C2F(str2name)(namex, id, name_len);
    Fin = -1;
    C2F(stackg)(id);
    if (Err > 0) return FALSE_ ;

    if (Fin == 0) {
      Scierror(4,"Undefined variable %s\r\n",get_fname(namex,name_len));
      return FALSE_ ;
    }

    if (*Infstk(Fin ) == 2) {
	Fin = *istk(iadr(*Lstk(Fin )) + 1 +1);
    }
    if (*ir == -1 && *ic == -1) {
	if (! C2F(getsmat)("creadchain", &Fin, &Fin, ir, ic, &cx1, &cx1, &lr1, &nlr1, 10L)) 
	  return FALSE_;
	else 
	  return TRUE_ ; 
    } else {
	if (! C2F(getsmat)("creadchain", &Fin, &Fin, &m1, &n1, ir, ic, &lr1, &nlr1, 10L)) {
	  return FALSE_;
	}
    }
    ix1 = *itslen - 1;
    *itslen = Min(ix1,nlr1);
    C2F(cvstr)(itslen, istk(lr1 ), chai, &cx1, chai_len);
    chai[*itslen]='\0';
    return TRUE_;
}

/*----------------------------------------------------------------
 *     cwritemat writes vector/matrix in scilab's internal stack 
 *     logic=cwritemat('matrixname'//char(0),m,n,mat) 
 *  name: character string; name of the scilab variable ( null terMinated) 
 *  m: number of rows 
 *  n: number of columns 
 *  mat: matrix entries stored columnwise in Scilab object 
 *----------------------------------------------------------------*/

int C2F(cwritechain)(namex, m, chai, name_len, chai_len)
     char *namex;
     integer *m;
     char *chai;
     unsigned long name_len,  chai_len;
{
    integer Rhs_k, Top_k;
    integer l4;
    integer id[nsiz], lr;
    C2F(str2name)(namex, id, name_len);
    Top_k = Top;
    /* jpc april 2002 */ 
    /* ++Top; */
    Top = Top + Nbvars + 1; 
    if (! C2F(cresmat2)("cwritechain", &Top, m, &lr, 11L)) {
	return FALSE_;
    }
    C2F(cvstr)(m, istk(lr ), chai, &cx0, chai_len);
    Rhs_k = Rhs;
    Rhs = 0;
    l4 = C2F(iop).lct[3];
    C2F(iop).lct[3] = -1;
    C2F(stackp)(id, &cx0);
    C2F(iop).lct[3] = l4;
    Top = Top_k ;
    Rhs = Rhs_k ;
    if (Err > 0)  return FALSE_;
    return TRUE_ ;
}

/*----------------------------------------------------------------
 *     see cmatptr 
 *----------------------------------------------------------------*/

int C2F(matptr)(namex, m, n, lp, name_len)
     char *namex;
     integer *m, *n, *lp;
     unsigned long name_len;
{
    int ix;
    ix = C2F(cmatptr)(namex, m, n, lp, name_len);
    return 0;
} 

/*----------------------------------------------------------------
 * !purpose 
 *     matptr returns the adress of real matrix "name" 
 *     in scilab's internal stack 
 *     m=number of rows 
 *     n=number of columns 
 *     stk(lp),stk(lp+1),...,stk(lp+m*n-1)= entries (columnwise) 
 *     If matrix "name" not in Scilab stack, returns m=n=-1. 
 *    Example of use: 
 *    Amat is a real 2 x 3 scilab matrix 
 *    your subroutine should be as follows: 
 *    subroutine mysubr(...) 
 *    ... 
 *    logic= cmatptr('Amat',m,n,lp) 
 *    => m=3 , n=2, and stk(lp)=Amat(1,1) 
 *                      stk(lp+1)=Amat(2,1) 
 *                      stk(lp+2)=Amat(3,1) 
 *                      stk(lp+3)=Amat(1,2) ... 
 *                      stk(lp+5)=Amat(3,2) 
 *   see example in fydot.f file 
 *   see also  readmat.f, matz.f 
 *----------------------------------------------------------------*/

int C2F(cmatptr)(namex, m, n, lp, name_len)
     char *namex;
     integer *m, *n, *lp;
     unsigned long name_len;
{
    integer id[nsiz];
    C2F(str2name)(namex, id, name_len);
    /* get the position in fin */
    Fin = -1;
    C2F(stackg)(id);
    if (Fin == 0) {
      Scierror(4,"Undefined variable %s\r\n",get_fname(namex,name_len));
      *m = -1;
      *n = -1;
      return FALSE_;
    }
    /* get data */
    if (*Infstk(Fin ) == 2) {
	Fin = *istk(iadr(*Lstk(Fin )) + 1 +1);
    }
    if (! C2F(getrmat)("creadmat", &Fin, &Fin, m, n, lp, 8L)) {
	return FALSE_;
    }
    return TRUE_ ;
}

/*----------------------------------------------------------------
 * !purpose 
 *     cmatcptr returns the adress of complex matrix "name" 
 *     in scilab's internal stack 
 *     m=number of rows 
 *     n=number of columns 
 *     stk(lp),stk(lp+1),...,stk(lp+m*n-1)= entries (columnwise) 
 *     If matrix "name" not in Scilab stack, returns m=n=-1. 
 *    Example of use: 
 *    Amat is a real 2 x 3 scilab matrix 
 *    your subroutine should be as follows: 
 *    subroutine mysubr(...) 
 *    ... 
 *    logic= cmatptr('Amat',m,n,lp) 
 *    => m=3 , n=2, and stk(lp)=Amat(1,1) 
 *                      stk(lp+1)=Amat(2,1) 
 *                      stk(lp+2)=Amat(3,1) 
 *                      stk(lp+3)=Amat(1,2) ... 
 *                      stk(lp+5)=Amat(3,2) 
 *   see example in fydot.f file 
 *   see also  readmat.f, matz.f
 * 
 * Note d'Albert Y
 * 20/12/2003
 *    Cette routine est une simple copie de creadmat et lgrement
 *    modifie pour les matrices complexes
 *
 *----------------------------------------------------------------*/

int C2F(cmatcptr)(namex, m, n, lp, name_len)
     char *namex;
     integer *m, *n, *lp;
     unsigned long name_len;
{
    integer id[nsiz];
    C2F(str2name)(namex, id, name_len);
    /* get the position in fin */
    Fin = -1;
    C2F(stackg)(id);
    if (Fin == 0) {
      Scierror(4,"Undefined variable %s\r\n",get_fname(namex,name_len));
      *m = -1;
      *n = -1;
      return FALSE_;
    }
    /* get data */
    if (*Infstk(Fin ) == 2) {
	Fin = *istk(iadr(*Lstk(Fin )) + 1 +1);
    }
    if (! C2F(getcmat)("creadmat", &Fin, &Fin, m, n, lp, 8L)) {
	return FALSE_;
    }
    return TRUE_ ;
}

/*----------------------------------------------------------------
 * !purpose 
 *     matptr returns the adress of real matrix "name" 
 *     in scilab's internal stack 
 *     m=number of rows 
 *     n=number of columns 
 *     stk(lp),stk(lp+1),...,stk(lp+m*n-1)= entries (columnwise) 
 *     If matrix "name" not in Scilab stack, returns m=n=-1. 
 *    Example of use: 
 *    Amat is a real 2 x 3 scilab matrix 
 *    your subroutine should be as follows: 
 *    subroutine mysubr(...) 
 *    ... 
 *    logic= cmatptr('Amat',m,n,lp) 
 *    => m=3 , n=2, and stk(lp)=Amat(1,1) 
 *                      stk(lp+1)=Amat(2,1) 
 *                      stk(lp+2)=Amat(3,1) 
 *                      stk(lp+3)=Amat(1,2) ... 
 *                      stk(lp+5)=Amat(3,2) 
 *   see example in fydot.f file 
 *   see also  readmat.f, matz.f 
 *----------------------------------------------------------------*/

int C2F(cmatsptr)(namex, m, n, ix, j, lp, nlr, name_len)
     char *namex;
     integer *m, *n, *lp, *ix, *j, *nlr;
     unsigned long name_len;
{
    integer id[nsiz];
    C2F(str2name)(namex, id, name_len);
    /* get the position in fin */
    Fin = -1;
    C2F(stackg)(id);
    if (Fin == 0) {
      Scierror(4,"Undefined variable %s\r\n",get_fname(namex,name_len));
      *m = -1;
      *n = -1;
      return FALSE_;
    }
    /* get data */
    if (*Infstk(Fin ) == 2) {
	Fin = *istk(iadr(*Lstk(Fin )) + 1 +1);
    }
    if (! C2F(getsmat)("creadmat", &Fin, &Fin, m, n, ix, j, lp, nlr, 8L)) {
	return FALSE_;
    }
    return TRUE_ ;
}

void *Name2ptr(namex)
     char *namex;
     /*  Returns a pointer to the Scilab variable with name namex
         Usage:   int *header;
                  header = (int *) Name2ptr("pipo");
                  header[0], header[1], etc contains header info 
                  about Scilab variable "pipo"   */
{
  int l1; int *loci;
  integer id[nsiz];
  C2F(str2name)(namex, id, strlen(namex));
  /* get the position in fin */
  Fin = -1;
  C2F(stackg)(id);
  if (Fin == 0) {
    Scierror(4,"Undefined variable %s\r\n",get_fname(namex,strlen(namex)));
    return 0;
  }
  /* get data */
  if (*Infstk(Fin ) == 2) {
    Fin = *istk(iadr(*Lstk(Fin )) + 1 +1);
  }
  loci = (int *) stk(*Lstk(Fin));
  if (loci[0] < 0) 
    {
      l1 = loci[1];
      loci = (int *) stk(l1);
    }
  return loci;
}

int Name2where(namex)
     /* returns the position in the internal stack of the variable with name
	namex 
     Usage:
             int l=Name2where("pipo");
	     stk(l) points to Scilab variable named "pipo"
	     e.g. if pipo is a standard real matrix
	     stk(l)[2]=first entry of the matrix pipo(1,1)
	     stk(l)[3]=pipo(2,1)  etc
	     (The header of pipo is given by istk(iadr(h))[0], 
                                             istk(iadr(h))[1], etc )
          */
     char *namex;
     /*     unsigned long name_len; */
{
  int loci;
  integer id[nsiz];
  C2F(str2name)(namex, id, strlen(namex));
  /* get the position in fin */
  Fin = -1;
  C2F(stackg)(id);
  if (Fin == 0) {
    Scierror(4,"Undefined variable %s\r\n",get_fname(namex,strlen(namex)));
    return 0;
  }
  loci = *Lstk(Fin);
  return loci;
}

/*----------------------------------------------------------------
 *     string conversion to Scilab ID 
 *     Warning : the character name is null terMinated 
 *             and len(name) is not used 
 *             since it can be wrong (ex when name is transmited 
 *             by fort (intfort : function )
 *----------------------------------------------------------------*/

int C2F(str2name)(namex, id, name_len)
     char *namex;
     integer *id;
     unsigned long name_len;
{
    integer ix;
    integer lon;
    lon = 0;
    for (ix = 0 ; ix < (integer) name_len ; ix++ ) {
      if ( namex[ix] == '\0') break;
      ++lon;
    }
    C2F(cvname)(id, namex, &cx0, lon);
    return 0;
} 

/*----------------------------------------------------------------
 *     objptr returns the adress of "name" 
 *     in scilab's internal stack 
 *----------------------------------------------------------------*/

int C2F(objptr)(namex, lp, fin, name_len)
     char *namex;
     integer *lp; integer *fin;
     unsigned long name_len;
{
    integer id[nsiz];
    *lp = 0;
    /*     ---- get the id */
    C2F(str2name)(namex, id, name_len);
    /*     ---- get the position in fin */
    Fin = -1;
    C2F(stackg)(id);
    if (Fin == 0) {
      C2F(putid)(&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], id);
      /*         we juste return false and lp is set to zero */
      /*         call error(4) */
      return FALSE_;
    }
    *fin = Fin;
    *lp = *Lstk(Fin );
    if (*Infstk(Fin ) == 2) {
	*lp = *Lstk(*istk(iadr(*lp) + 1 +1) );
    }
    return  TRUE_;
}