~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/api_scilab/tests/unit_tests/common_read_api.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3
 
 * Copyright (C) 2009-2010 - DIGITEO - Scilab Consortium Operational Team
 
3
 * Copyright (C) 2009-2010 - DIGITEO
4
4
 *
5
5
 * This file must be used under the terms of the CeCILL.
6
6
 * This source file is licensed as described in the file COPYING, which
19
19
static int iTab = 0;
20
20
void insert_indent(void)
21
21
{
22
 
        int i = 0;
23
 
        for(i = 0 ; i < iTab ; i++)
24
 
        {
25
 
                sciprint("\t");
26
 
        }
27
 
}
28
 
 
29
 
int get_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
30
 
int get_list_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
31
 
int get_double_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
32
 
int get_poly_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
33
 
int get_boolean_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
34
 
int get_sparse_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
35
 
int get_bsparse_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
36
 
int get_integer_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
37
 
int get_string_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
38
 
int get_pointer_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
39
 
 
40
 
int common_read(char *fname,unsigned long fname_len)
41
 
{
42
 
        SciErr sciErr;
43
 
        int iItem       = 0;
44
 
        int iRet        = 0;
45
 
        int *piAddr     = NULL;
46
 
 
47
 
        CheckInputArgument(pvApiCtx, 1, 1);
48
 
 
49
 
        sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
50
 
        if(sciErr.iErr)
51
 
        {
52
 
                printError(&sciErr, 0);
53
 
                return 0;
54
 
        }
55
 
 
56
 
        get_info(1, NULL, piAddr, 0);
57
 
        AssignOutputVariable(1) = 0;
58
 
        return 0;
59
 
}
60
 
 
61
 
int get_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
62
 
{
63
 
        SciErr sciErr;
64
 
        int iRet    = 0;
65
 
        int iType   = 0;
66
 
 
67
 
        sciErr = getVarType(pvApiCtx, _piAddr, &iType);
68
 
        switch(iType)
69
 
        {
70
 
        case sci_matrix :
71
 
                iRet = get_double_info(_iRhs, _piParent, _piAddr, _iItemPos);
72
 
                break;
73
 
        case sci_poly :
74
 
                iRet = get_poly_info(_iRhs, _piParent, _piAddr, _iItemPos);
75
 
                break;
76
 
        case sci_boolean :
77
 
                iRet = get_boolean_info(_iRhs, _piParent, _piAddr, _iItemPos);
78
 
                break;
79
 
        case sci_sparse :
80
 
                iRet = get_sparse_info(_iRhs, _piParent, _piAddr, _iItemPos);
81
 
                break;
82
 
        case sci_boolean_sparse :
83
 
                iRet = get_bsparse_info(_iRhs, _piParent, _piAddr, _iItemPos);
84
 
                break;
85
 
        case sci_ints :
86
 
                iRet = get_integer_info(_iRhs, _piParent, _piAddr, _iItemPos);
87
 
                break;
88
 
        case sci_strings :
89
 
                iRet = get_string_info(_iRhs, _piParent, _piAddr, _iItemPos);
90
 
                break;
91
 
        case sci_list :
92
 
                insert_indent();
93
 
                sciprint("List ");
94
 
                iRet = get_list_info(_iRhs, _piParent, _piAddr, _iItemPos);
95
 
                break;
96
 
        case sci_tlist :
97
 
                insert_indent();
98
 
                sciprint("TList ");
99
 
                iRet = get_list_info(_iRhs, _piParent, _piAddr, _iItemPos);
100
 
                break;
101
 
        case sci_mlist :
102
 
                insert_indent();
103
 
                sciprint("MList ");
104
 
                iRet = get_list_info(_iRhs, _piParent, _piAddr, _iItemPos);
105
 
                break;
106
 
        case sci_pointer :
107
 
                iRet = get_pointer_info(_iRhs, _piParent, _piAddr, _iItemPos);
108
 
                break;
109
 
        default :
110
 
                insert_indent();
111
 
                sciprint("Unknown type\n");
112
 
                return 1;
113
 
        }
114
 
        return iRet;
115
 
}
116
 
 
117
 
int get_list_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
118
 
{
119
 
        SciErr sciErr;
120
 
        int i;
121
 
        int iRet        = 0;
122
 
        int iItem       = 0;
123
 
        int* piChild    = NULL;
124
 
 
125
 
        sciErr = getListItemNumber(pvApiCtx, _piAddr, &iItem);
126
 
        if(sciErr.iErr)
127
 
        {
128
 
                printError(&sciErr, 0);
129
 
                return 0;
130
 
        }
131
 
 
132
 
        sciprint("(%d)\n", iItem);
133
 
        for(i = 0 ; i < iItem ; i++)
134
 
        {
135
 
                sciErr = getListItemAddress(pvApiCtx, _piAddr, i + 1, &piChild);
136
 
                if(sciErr.iErr)
137
 
                {
138
 
                        printError(&sciErr, 0);
139
 
                        return 0;
140
 
                }
141
 
 
142
 
                iTab++;
143
 
                iRet = get_info(_iRhs, _piAddr, piChild, i + 1);
144
 
                iTab--;
145
 
        }
146
 
        return 0;;
147
 
}
148
 
 
149
 
int get_double_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
150
 
{
151
 
        SciErr sciErr;
152
 
        int iRows           = 0;
153
 
        int iCols           = 0;
154
 
        double* pdblReal    = NULL;
155
 
        double* pdblImg     = NULL;
156
 
 
157
 
        if(_iItemPos == 0)
158
 
        {//not in list
159
 
                if(isVarComplex(pvApiCtx, _piAddr))
160
 
                {
161
 
                        sciErr = getComplexMatrixOfDouble(pvApiCtx, _piAddr, &iRows, &iCols, &pdblReal, &pdblImg);
162
 
                }
163
 
                else
164
 
                {
165
 
                        sciErr = getMatrixOfDouble(pvApiCtx, _piAddr, &iRows, &iCols, &pdblReal);
166
 
                }
167
 
        }
168
 
        else
169
 
        {
170
 
                if(isVarComplex(pvApiCtx, _piAddr))
171
 
                {
172
 
                        sciErr = getComplexMatrixOfDoubleInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &pdblReal, &pdblImg);
173
 
                }
174
 
                else
175
 
                {
176
 
                        sciErr = getMatrixOfDoubleInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &pdblReal);
177
 
                }
178
 
        }
179
 
 
180
 
        if(sciErr.iErr)
181
 
        {
182
 
                printError(&sciErr, 0);
183
 
                return 0;
184
 
        }
185
 
 
186
 
        insert_indent();
187
 
        sciprint("Double (%d x %d)\n", iRows, iCols);
188
 
        return 0;;
189
 
}
190
 
 
191
 
int get_poly_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
192
 
{
193
 
        SciErr sciErr;
194
 
        int i;
195
 
        int iLen            = 0;
196
 
        int iRows           = 0;
197
 
        int iCols           = 0;
198
 
        char pstVar[16];
199
 
        int* piCoeff        = NULL;
200
 
        double** pdblReal   = NULL;
201
 
        double** pdblImg    = NULL;
202
 
 
203
 
        sciErr = getPolyVariableName(pvApiCtx, _piAddr, pstVar, &iLen);
204
 
        if(sciErr.iErr)
205
 
        {
206
 
                printError(&sciErr, 0);
207
 
                return 0;
208
 
        }
209
 
 
210
 
        if(_iItemPos == 0)
211
 
        {//not in list
212
 
                sciErr = getMatrixOfPoly(pvApiCtx, _piAddr, &iRows, &iCols, NULL, NULL);
213
 
                if(sciErr.iErr)
214
 
                {
215
 
                        printError(&sciErr, 0);
216
 
                        return 0;
217
 
                }
218
 
 
219
 
                piCoeff     = (int*)malloc(sizeof(int) * iRows * iCols);
220
 
                sciErr = getMatrixOfPoly(pvApiCtx, _piAddr, &iRows, &iCols, piCoeff, NULL);
221
 
                if(sciErr.iErr)
222
 
                {
223
 
                        printError(&sciErr, 0);
224
 
                        return 0;
225
 
                }
226
 
 
227
 
                pdblReal    = (double**)malloc(sizeof(double*) * iRows * iCols);
228
 
                pdblImg     = (double**)malloc(sizeof(double*) * iRows * iCols);
229
 
 
230
 
                for(i = 0 ; i < iRows * iCols ; i++)
231
 
                {
232
 
                        pdblReal[i] = (double*)malloc(sizeof(double) * piCoeff[i]);
233
 
                        pdblImg[i]  = (double*)malloc(sizeof(double) * piCoeff[i]);
234
 
                }
235
 
 
236
 
                if(isVarComplex(pvApiCtx, _piAddr))
237
 
                {
238
 
                        sciErr = getComplexMatrixOfPoly(pvApiCtx, _piAddr, &iRows, &iCols, piCoeff, pdblReal, pdblImg);
239
 
                        if(sciErr.iErr)
240
 
                        {
241
 
                                printError(&sciErr, 0);
242
 
                                return 0;
243
 
                        }
244
 
                }
245
 
                else
246
 
                {
247
 
                        sciErr = getMatrixOfPoly(pvApiCtx, _piAddr, &iRows, &iCols, piCoeff, pdblReal);
248
 
                        if(sciErr.iErr)
249
 
                        {
250
 
                                printError(&sciErr, 0);
251
 
                                return 0;
252
 
                        }
253
 
                }
254
 
        }
255
 
        else
256
 
        {
257
 
                sciErr = getMatrixOfPolyInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, NULL, NULL);
258
 
                if(sciErr.iErr)
259
 
                {
260
 
                        printError(&sciErr, 0);
261
 
                        return 0;
262
 
                }
263
 
 
264
 
                piCoeff = (int*)malloc(sizeof(int) * iRows * iCols);
265
 
 
266
 
                sciErr = getMatrixOfPolyInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, NULL);
267
 
                if(sciErr.iErr)
268
 
                {
269
 
                        printError(&sciErr, 0);
270
 
                        return 0;
271
 
                }
272
 
 
273
 
                pdblReal    = (double**)malloc(sizeof(double*) * iRows * iCols);
274
 
                pdblImg     = (double**)malloc(sizeof(double*) * iRows * iCols);
275
 
 
276
 
                for(i = 0 ; i < iRows * iCols ; i++)
277
 
                {
278
 
                        pdblReal[i] = (double*)malloc(sizeof(double) * piCoeff[i]);
279
 
                        pdblImg[i]  = (double*)malloc(sizeof(double) * piCoeff[i]);
280
 
                }
281
 
 
282
 
                if(isVarComplex(pvApiCtx, _piAddr))
283
 
                {
284
 
                        sciErr = getComplexMatrixOfPolyInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, pdblReal, pdblImg);
285
 
                }
286
 
                else
287
 
                {
288
 
                        sciErr = getMatrixOfPolyInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, pdblReal);
289
 
                }
290
 
        }
291
 
 
292
 
        if(sciErr.iErr)
293
 
        {
294
 
                printError(&sciErr, 0);
295
 
                return 0;
296
 
        }
297
 
 
298
 
        insert_indent();
299
 
        sciprint("Poly  (%d x %d), varname : \'%s\'\n", iRows, iCols, pstVar);
300
 
 
301
 
        for(i = 0 ; i < iRows * iCols ; i++)
302
 
        {
303
 
                free(pdblReal[i]);
304
 
                free(pdblImg[i]);
305
 
        }
306
 
 
307
 
        free(pdblReal);
308
 
        free(pdblImg);
309
 
        free(piCoeff);
310
 
        return 0;;
311
 
}
312
 
int get_boolean_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
313
 
{
314
 
        SciErr sciErr;
315
 
        int iRows       = 0;
316
 
        int iCols       = 0;
317
 
        int* piBool     = NULL;
318
 
 
319
 
        if(_iItemPos == 0)
320
 
        {
321
 
                sciErr = getMatrixOfBoolean(pvApiCtx, _piAddr, &iRows, &iCols, &piBool);
322
 
        }
323
 
        else
324
 
        {
325
 
                sciErr = getMatrixOfBooleanInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &piBool);
326
 
        }
327
 
 
328
 
        if(sciErr.iErr)
329
 
        {
330
 
                printError(&sciErr, 0);
331
 
                return 0;
332
 
        }
333
 
 
334
 
        insert_indent();
335
 
        sciprint("Boolean (%d x %d)\n", iRows, iCols);
336
 
        return 0;
337
 
}
338
 
int get_sparse_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
339
 
{
340
 
        SciErr sciErr;
341
 
        int iRows           = 0;
342
 
        int iCols           = 0;
343
 
        int iItem           = 0;
344
 
        int* piNbRow        = NULL;
345
 
        int* piColPos       = NULL;
346
 
        double* pdblReal    = NULL;
347
 
        double* pdblImg     = NULL;
348
 
 
349
 
        if(_iItemPos == 0)
350
 
        {//Not in list
351
 
                if(isVarComplex(pvApiCtx, _piAddr))
352
 
                {
353
 
                        sciErr = getComplexSparseMatrix(pvApiCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal, &pdblImg);
354
 
                }
355
 
                else
356
 
                {
357
 
                        sciErr = getSparseMatrix(pvApiCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal);
358
 
                }
359
 
        }
360
 
        else
361
 
        {
362
 
                if(isVarComplex(pvApiCtx, _piAddr))
363
 
                {
364
 
                        sciErr = getComplexSparseMatrixInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal, &pdblImg);
365
 
                }
366
 
                else
367
 
                {
368
 
                        sciErr = getSparseMatrixInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal);
369
 
                }
370
 
        }
371
 
 
372
 
        insert_indent();
373
 
        sciprint("Sparse (%d x %d), Item(s) : %d \n", iRows, iCols, iItem);
374
 
        return 0;;
375
 
}
376
 
 
377
 
int get_bsparse_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
378
 
{
379
 
        SciErr sciErr;
380
 
        int iRows       = 0;
381
 
        int iCols       = 0;
382
 
        int iItem       = 0;
383
 
        int* piNbRow    = NULL;
384
 
        int* piColPos   = NULL;
385
 
 
386
 
        if(_iItemPos == 0)
387
 
        {//Not in list
388
 
                sciErr = getBooleanSparseMatrix(pvApiCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos);
389
 
        }
390
 
        else
391
 
        {
392
 
                sciErr = getBooleanSparseMatrixInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos);
393
 
        }
394
 
 
395
 
        if(sciErr.iErr)
396
 
        {
397
 
                printError(&sciErr, 0);
398
 
                return 0;
399
 
        }
400
 
 
401
 
        insert_indent();
402
 
        sciprint("Boolean Sparse (%d x %d), Item(s) : %d \n", iRows, iCols, iItem);
403
 
        return 0;;
404
 
}
405
 
int get_integer_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
406
 
{
407
 
        SciErr sciErr;
408
 
        int iPrec               = 0;
409
 
        int iRows               = 0;
410
 
        int iCols               = 0;
411
 
        char* pcData            = NULL;
412
 
        short* psData           = NULL;
413
 
        int* piData             = NULL;
414
 
        unsigned char* pucData  = NULL;
415
 
        unsigned short* pusData = NULL;
416
 
        unsigned int* puiData   = NULL;
417
 
 
418
 
        if(_iItemPos == 0)
419
 
        {//Not in list
420
 
                sciErr = getMatrixOfIntegerPrecision(pvApiCtx, _piAddr, &iPrec);
421
 
                if(sciErr.iErr)
422
 
                {
423
 
                        printError(&sciErr, 0);
424
 
                        return 0;
425
 
                }
426
 
 
427
 
                switch(iPrec)
428
 
                {
429
 
                case SCI_INT8 :
430
 
                        sciErr = getMatrixOfInteger8(pvApiCtx, _piAddr, &iRows, &iCols, &pcData);
431
 
                        break;
432
 
                case SCI_INT16 :
433
 
                        sciErr = getMatrixOfInteger16(pvApiCtx, _piAddr, &iRows, &iCols, &psData);
434
 
                        break;
435
 
                case SCI_INT32 :
436
 
                        sciErr = getMatrixOfInteger32(pvApiCtx, _piAddr, &iRows, &iCols, &piData);
437
 
                        break;
438
 
                case SCI_UINT8 :
439
 
                        sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, _piAddr, &iRows, &iCols, &pucData);
440
 
                        break;
441
 
                case SCI_UINT16 :
442
 
                        sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, _piAddr, &iRows, &iCols, &pusData);
443
 
                        break;
444
 
                case SCI_UINT32 :
445
 
                        sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, _piAddr, &iRows, &iCols, &puiData);
446
 
                        break;
447
 
                default :
448
 
                        return 1;
449
 
                }
450
 
        }
451
 
        else
452
 
        {
453
 
                sciErr = getMatrixOfIntegerPrecision(pvApiCtx, _piAddr, &iPrec);
454
 
                if(sciErr.iErr)
455
 
                {
456
 
                        printError(&sciErr, 0);
457
 
                        return 0;
458
 
                }
459
 
 
460
 
                switch(iPrec)
461
 
                {
462
 
                case SCI_INT8 :
463
 
                        sciErr = getMatrixOfInteger8InList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &pcData);
464
 
                        break;
465
 
                case SCI_INT16 :
466
 
                        sciErr = getMatrixOfInteger16InList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &psData);
467
 
                        break;
468
 
                case SCI_INT32 :
469
 
                        sciErr = getMatrixOfInteger32InList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &piData);
470
 
                        break;
471
 
                case SCI_UINT8 :
472
 
                        sciErr = getMatrixOfUnsignedInteger8InList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &pucData);
473
 
                        break;
474
 
                case SCI_UINT16 :
475
 
                        sciErr = getMatrixOfUnsignedInteger16InList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &pusData);
476
 
                        break;
477
 
                case SCI_UINT32 :
478
 
                        sciErr = getMatrixOfUnsignedInteger32InList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, &puiData);
479
 
                        break;
480
 
                default :
481
 
                        return 1;
482
 
                }
483
 
        }
484
 
 
485
 
        if(sciErr.iErr)
486
 
        {
487
 
                printError(&sciErr, 0);
488
 
                return 0;
489
 
        }
490
 
 
491
 
        insert_indent();
492
 
 
493
 
        if(iPrec > 10)
494
 
        {
495
 
                sciprint("Unsigned ");
496
 
        }
497
 
 
498
 
        sciprint("Integer %d bits (%d x %d)\n", (iPrec % 10) * 8, iRows, iCols);
499
 
        return 0;;
500
 
}
501
 
int get_string_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
502
 
{
503
 
        SciErr sciErr;
504
 
        int i;
505
 
        int iRows       = 0;
506
 
        int iCols       = 0;
507
 
        int* piLen      = NULL;
508
 
        char **pstData  = NULL;
509
 
 
510
 
        if(_iItemPos == 0)
511
 
        {//Not in list
512
 
                sciErr = getMatrixOfString(pvApiCtx, _piAddr, &iRows, &iCols, NULL, NULL);
513
 
                if(sciErr.iErr)
514
 
                {
515
 
                        printError(&sciErr, 0);
516
 
                        return 0;
517
 
                }
518
 
 
519
 
                piLen = (int*)malloc(sizeof(int) * iRows * iCols);
520
 
                sciErr = getMatrixOfString(pvApiCtx, _piAddr, &iRows, &iCols, piLen, NULL);
521
 
                if(sciErr.iErr)
522
 
                {
523
 
                        printError(&sciErr, 0);
524
 
                        return 0;
525
 
                }
526
 
 
527
 
                pstData = (char**)malloc(sizeof(char*) * iRows * iCols);
528
 
 
529
 
                for(i = 0 ; i < iRows * iCols ; i++)
530
 
                {
531
 
                        pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination
532
 
                }
533
 
 
534
 
                sciErr = getMatrixOfString(pvApiCtx, _piAddr, &iRows, &iCols, piLen, pstData);
535
 
                if(sciErr.iErr)
536
 
                {
537
 
                        printError(&sciErr, 0);
538
 
                        return 0;
539
 
                }
540
 
        }
541
 
        else
542
 
        {
543
 
                sciErr = getMatrixOfStringInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, NULL, NULL);
544
 
                if(sciErr.iErr)
545
 
                {
546
 
                        printError(&sciErr, 0);
547
 
                        return 0;
548
 
                }
549
 
 
550
 
                piLen = (int*)malloc(sizeof(int) * iRows * iCols);
551
 
 
552
 
                sciErr = getMatrixOfStringInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, piLen, NULL);
553
 
                if(sciErr.iErr)
554
 
                {
555
 
                        printError(&sciErr, 0);
556
 
                        return 0;
557
 
                }
558
 
 
559
 
                pstData = (char**)malloc(sizeof(char*) * iRows * iCols);
560
 
 
561
 
                for(i = 0 ; i < iRows * iCols ; i++)
562
 
                {
563
 
                        pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination
564
 
                }
565
 
 
566
 
                sciErr = getMatrixOfStringInList(pvApiCtx, _piParent, _iItemPos, &iRows, &iCols, piLen, pstData);
567
 
                if(sciErr.iErr)
568
 
                {
569
 
                        printError(&sciErr, 0);
570
 
                        return 0;
571
 
                }
572
 
        }
573
 
        if(sciErr.iErr)
574
 
        {
575
 
                printError(&sciErr, 0);
576
 
                return 0;
577
 
        }
578
 
 
579
 
        insert_indent();
580
 
        sciprint("Strings (%d x %d)\n", iRows, iCols);
581
 
        return 0;;
582
 
}
583
 
int get_pointer_info(int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
584
 
{
585
 
        SciErr sciErr;
586
 
        void* pvPtr     = NULL;
587
 
 
588
 
        if(_iItemPos == 0)
589
 
        {
590
 
                sciErr = getPointer(pvApiCtx, _piAddr, &pvPtr);
591
 
        }
592
 
        else
593
 
        {
594
 
                sciErr = getPointerInList(pvApiCtx, _piParent, _iItemPos, &pvPtr);
595
 
        }
596
 
 
597
 
        if(sciErr.iErr)
598
 
        {
599
 
                printError(&sciErr, 0);
600
 
                return 0;
601
 
        }
602
 
 
603
 
        insert_indent();
604
 
        sciprint("Pointer : 0x%08X\n", pvPtr);
605
 
        return 0;
 
22
    int i = 0;
 
23
    for (i = 0 ; i < iTab ; i++)
 
24
    {
 
25
        sciprint("\t");
 
26
    }
 
27
}
 
28
 
 
29
int get_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
30
int get_list_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
31
int get_double_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
32
int get_poly_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
33
int get_boolean_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
34
int get_sparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
35
int get_bsparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
36
int get_integer_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
37
int get_string_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
38
int get_pointer_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
 
39
 
 
40
int common_read(char *fname, unsigned long fname_len)
 
41
{
 
42
    SciErr sciErr;
 
43
    int iItem       = 0;
 
44
    int iRet        = 0;
 
45
    int *piAddr     = NULL;
 
46
 
 
47
    CheckInputArgument(pvApiCtx, 1, 1);
 
48
 
 
49
    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
 
50
    if (sciErr.iErr)
 
51
    {
 
52
        printError(&sciErr, 0);
 
53
        return 0;
 
54
    }
 
55
 
 
56
    get_info(pvApiCtx, 1, NULL, piAddr, 0);
 
57
    AssignOutputVariable(pvApiCtx, 1) = 0;
 
58
    return 0;
 
59
}
 
60
 
 
61
int get_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
62
{
 
63
    SciErr sciErr;
 
64
    int iRet    = 0;
 
65
    int iType   = 0;
 
66
 
 
67
    sciErr = getVarType(_pvCtx, _piAddr, &iType);
 
68
    switch (iType)
 
69
    {
 
70
        case sci_matrix :
 
71
            iRet = get_double_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
72
            break;
 
73
        case sci_poly :
 
74
            iRet = get_poly_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
75
            break;
 
76
        case sci_boolean :
 
77
            iRet = get_boolean_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
78
            break;
 
79
        case sci_sparse :
 
80
            iRet = get_sparse_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
81
            break;
 
82
        case sci_boolean_sparse :
 
83
            iRet = get_bsparse_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
84
            break;
 
85
        case sci_ints :
 
86
            iRet = get_integer_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
87
            break;
 
88
        case sci_strings :
 
89
            iRet = get_string_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
90
            break;
 
91
        case sci_list :
 
92
            insert_indent();
 
93
            sciprint("List ");
 
94
            iRet = get_list_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
95
            break;
 
96
        case sci_tlist :
 
97
            insert_indent();
 
98
            sciprint("TList ");
 
99
            iRet = get_list_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
100
            break;
 
101
        case sci_mlist :
 
102
            insert_indent();
 
103
            sciprint("MList ");
 
104
            iRet = get_list_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
105
            break;
 
106
        case sci_pointer :
 
107
            iRet = get_pointer_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
 
108
            break;
 
109
        default :
 
110
            insert_indent();
 
111
            sciprint("Unknown type\n");
 
112
            return 1;
 
113
    }
 
114
    return iRet;
 
115
}
 
116
 
 
117
int get_list_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
118
{
 
119
    SciErr sciErr;
 
120
    int i;
 
121
    int iRet        = 0;
 
122
    int iItem       = 0;
 
123
    int* piChild    = NULL;
 
124
 
 
125
    sciErr = getListItemNumber(_pvCtx, _piAddr, &iItem);
 
126
    if (sciErr.iErr)
 
127
    {
 
128
        printError(&sciErr, 0);
 
129
        return 0;
 
130
    }
 
131
 
 
132
    sciprint("(%d)\n", iItem);
 
133
    for (i = 0 ; i < iItem ; i++)
 
134
    {
 
135
        sciErr = getListItemAddress(_pvCtx, _piAddr, i + 1, &piChild);
 
136
        if (sciErr.iErr)
 
137
        {
 
138
            printError(&sciErr, 0);
 
139
            return 0;
 
140
        }
 
141
 
 
142
        iTab++;
 
143
        iRet = get_info(_pvCtx, _iRhs, _piAddr, piChild, i + 1);
 
144
        iTab--;
 
145
    }
 
146
    return 0;;
 
147
}
 
148
 
 
149
int get_double_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
150
{
 
151
    SciErr sciErr;
 
152
    int iRows           = 0;
 
153
    int iCols           = 0;
 
154
    double* pdblReal    = NULL;
 
155
    double* pdblImg     = NULL;
 
156
 
 
157
    if (_iItemPos == 0)
 
158
    {
 
159
        //not in list
 
160
        if (isVarComplex(_pvCtx, _piAddr))
 
161
        {
 
162
            sciErr = getComplexMatrixOfDouble(_pvCtx, _piAddr, &iRows, &iCols, &pdblReal, &pdblImg);
 
163
        }
 
164
        else
 
165
        {
 
166
            sciErr = getMatrixOfDouble(_pvCtx, _piAddr, &iRows, &iCols, &pdblReal);
 
167
        }
 
168
    }
 
169
    else
 
170
    {
 
171
        if (isVarComplex(_pvCtx, _piAddr))
 
172
        {
 
173
            sciErr = getComplexMatrixOfDoubleInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pdblReal, &pdblImg);
 
174
        }
 
175
        else
 
176
        {
 
177
            sciErr = getMatrixOfDoubleInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pdblReal);
 
178
        }
 
179
    }
 
180
 
 
181
    if (sciErr.iErr)
 
182
    {
 
183
        printError(&sciErr, 0);
 
184
        return 0;
 
185
    }
 
186
 
 
187
    insert_indent();
 
188
    sciprint("Double (%d x %d)\n", iRows, iCols);
 
189
    return 0;;
 
190
}
 
191
 
 
192
int get_poly_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
193
{
 
194
    SciErr sciErr;
 
195
    int i;
 
196
    int iLen            = 0;
 
197
    int iRows           = 0;
 
198
    int iCols           = 0;
 
199
    char pstVar[16];
 
200
    int* piCoeff        = NULL;
 
201
    double** pdblReal   = NULL;
 
202
    double** pdblImg    = NULL;
 
203
 
 
204
    sciErr = getPolyVariableName(_pvCtx, _piAddr, pstVar, &iLen);
 
205
    if (sciErr.iErr)
 
206
    {
 
207
        printError(&sciErr, 0);
 
208
        return 0;
 
209
    }
 
210
 
 
211
    if (_iItemPos == 0)
 
212
    {
 
213
        //not in list
 
214
        sciErr = getMatrixOfPoly(_pvCtx, _piAddr, &iRows, &iCols, NULL, NULL);
 
215
        if (sciErr.iErr)
 
216
        {
 
217
            printError(&sciErr, 0);
 
218
            return 0;
 
219
        }
 
220
 
 
221
        piCoeff     = (int*)malloc(sizeof(int) * iRows * iCols);
 
222
        sciErr = getMatrixOfPoly(_pvCtx, _piAddr, &iRows, &iCols, piCoeff, NULL);
 
223
        if (sciErr.iErr)
 
224
        {
 
225
            printError(&sciErr, 0);
 
226
            return 0;
 
227
        }
 
228
 
 
229
        pdblReal    = (double**)malloc(sizeof(double*) * iRows * iCols);
 
230
        pdblImg     = (double**)malloc(sizeof(double*) * iRows * iCols);
 
231
 
 
232
        for (i = 0 ; i < iRows * iCols ; i++)
 
233
        {
 
234
            pdblReal[i] = (double*)malloc(sizeof(double) * piCoeff[i]);
 
235
            pdblImg[i]  = (double*)malloc(sizeof(double) * piCoeff[i]);
 
236
        }
 
237
 
 
238
        if (isVarComplex(_pvCtx, _piAddr))
 
239
        {
 
240
            sciErr = getComplexMatrixOfPoly(_pvCtx, _piAddr, &iRows, &iCols, piCoeff, pdblReal, pdblImg);
 
241
            if (sciErr.iErr)
 
242
            {
 
243
                printError(&sciErr, 0);
 
244
                return 0;
 
245
            }
 
246
        }
 
247
        else
 
248
        {
 
249
            sciErr = getMatrixOfPoly(_pvCtx, _piAddr, &iRows, &iCols, piCoeff, pdblReal);
 
250
            if (sciErr.iErr)
 
251
            {
 
252
                printError(&sciErr, 0);
 
253
                return 0;
 
254
            }
 
255
        }
 
256
    }
 
257
    else
 
258
    {
 
259
        sciErr = getMatrixOfPolyInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, NULL, NULL);
 
260
        if (sciErr.iErr)
 
261
        {
 
262
            printError(&sciErr, 0);
 
263
            return 0;
 
264
        }
 
265
 
 
266
        piCoeff = (int*)malloc(sizeof(int) * iRows * iCols);
 
267
 
 
268
        sciErr = getMatrixOfPolyInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, NULL);
 
269
        if (sciErr.iErr)
 
270
        {
 
271
            printError(&sciErr, 0);
 
272
            return 0;
 
273
        }
 
274
 
 
275
        pdblReal    = (double**)malloc(sizeof(double*) * iRows * iCols);
 
276
        pdblImg     = (double**)malloc(sizeof(double*) * iRows * iCols);
 
277
 
 
278
        for (i = 0 ; i < iRows * iCols ; i++)
 
279
        {
 
280
            pdblReal[i] = (double*)malloc(sizeof(double) * piCoeff[i]);
 
281
            pdblImg[i]  = (double*)malloc(sizeof(double) * piCoeff[i]);
 
282
        }
 
283
 
 
284
        if (isVarComplex(_pvCtx, _piAddr))
 
285
        {
 
286
            sciErr = getComplexMatrixOfPolyInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, pdblReal, pdblImg);
 
287
        }
 
288
        else
 
289
        {
 
290
            sciErr = getMatrixOfPolyInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, pdblReal);
 
291
        }
 
292
    }
 
293
 
 
294
    if (sciErr.iErr)
 
295
    {
 
296
        printError(&sciErr, 0);
 
297
        return 0;
 
298
    }
 
299
 
 
300
    insert_indent();
 
301
    sciprint("Poly  (%d x %d), varname : \'%s\'\n", iRows, iCols, pstVar);
 
302
 
 
303
    for (i = 0 ; i < iRows * iCols ; i++)
 
304
    {
 
305
        free(pdblReal[i]);
 
306
        free(pdblImg[i]);
 
307
    }
 
308
 
 
309
    free(pdblReal);
 
310
    free(pdblImg);
 
311
    free(piCoeff);
 
312
    return 0;;
 
313
}
 
314
int get_boolean_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
315
{
 
316
    SciErr sciErr;
 
317
    int iRows       = 0;
 
318
    int iCols       = 0;
 
319
    int* piBool     = NULL;
 
320
 
 
321
    if (_iItemPos == 0)
 
322
    {
 
323
        sciErr = getMatrixOfBoolean(_pvCtx, _piAddr, &iRows, &iCols, &piBool);
 
324
    }
 
325
    else
 
326
    {
 
327
        sciErr = getMatrixOfBooleanInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &piBool);
 
328
    }
 
329
 
 
330
    if (sciErr.iErr)
 
331
    {
 
332
        printError(&sciErr, 0);
 
333
        return 0;
 
334
    }
 
335
 
 
336
    insert_indent();
 
337
    sciprint("Boolean (%d x %d)\n", iRows, iCols);
 
338
    return 0;
 
339
}
 
340
int get_sparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
341
{
 
342
    SciErr sciErr;
 
343
    int iRows           = 0;
 
344
    int iCols           = 0;
 
345
    int iItem           = 0;
 
346
    int* piNbRow        = NULL;
 
347
    int* piColPos       = NULL;
 
348
    double* pdblReal    = NULL;
 
349
    double* pdblImg     = NULL;
 
350
 
 
351
    if (_iItemPos == 0)
 
352
    {
 
353
        //Not in list
 
354
        if (isVarComplex(_pvCtx, _piAddr))
 
355
        {
 
356
            sciErr = getComplexSparseMatrix(_pvCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal, &pdblImg);
 
357
        }
 
358
        else
 
359
        {
 
360
            sciErr = getSparseMatrix(_pvCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal);
 
361
        }
 
362
    }
 
363
    else
 
364
    {
 
365
        if (isVarComplex(_pvCtx, _piAddr))
 
366
        {
 
367
            sciErr = getComplexSparseMatrixInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal, &pdblImg);
 
368
        }
 
369
        else
 
370
        {
 
371
            sciErr = getSparseMatrixInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal);
 
372
        }
 
373
    }
 
374
 
 
375
    insert_indent();
 
376
    sciprint("Sparse (%d x %d), Item(s) : %d \n", iRows, iCols, iItem);
 
377
    return 0;;
 
378
}
 
379
 
 
380
int get_bsparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
381
{
 
382
    SciErr sciErr;
 
383
    int iRows       = 0;
 
384
    int iCols       = 0;
 
385
    int iItem       = 0;
 
386
    int* piNbRow    = NULL;
 
387
    int* piColPos   = NULL;
 
388
 
 
389
    if (_iItemPos == 0)
 
390
    {
 
391
        //Not in list
 
392
        sciErr = getBooleanSparseMatrix(_pvCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos);
 
393
    }
 
394
    else
 
395
    {
 
396
        sciErr = getBooleanSparseMatrixInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos);
 
397
    }
 
398
 
 
399
    if (sciErr.iErr)
 
400
    {
 
401
        printError(&sciErr, 0);
 
402
        return 0;
 
403
    }
 
404
 
 
405
    insert_indent();
 
406
    sciprint("Boolean Sparse (%d x %d), Item(s) : %d \n", iRows, iCols, iItem);
 
407
    return 0;;
 
408
}
 
409
int get_integer_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
410
{
 
411
    SciErr sciErr;
 
412
    int iPrec               = 0;
 
413
    int iRows               = 0;
 
414
    int iCols               = 0;
 
415
    char* pcData            = NULL;
 
416
    short* psData           = NULL;
 
417
    int* piData             = NULL;
 
418
    unsigned char* pucData  = NULL;
 
419
    unsigned short* pusData = NULL;
 
420
    unsigned int* puiData   = NULL;
 
421
 
 
422
    if (_iItemPos == 0)
 
423
    {
 
424
        //Not in list
 
425
        sciErr = getMatrixOfIntegerPrecision(_pvCtx, _piAddr, &iPrec);
 
426
        if (sciErr.iErr)
 
427
        {
 
428
            printError(&sciErr, 0);
 
429
            return 0;
 
430
        }
 
431
 
 
432
        switch (iPrec)
 
433
        {
 
434
            case SCI_INT8 :
 
435
                sciErr = getMatrixOfInteger8(_pvCtx, _piAddr, &iRows, &iCols, &pcData);
 
436
                break;
 
437
            case SCI_INT16 :
 
438
                sciErr = getMatrixOfInteger16(_pvCtx, _piAddr, &iRows, &iCols, &psData);
 
439
                break;
 
440
            case SCI_INT32 :
 
441
                sciErr = getMatrixOfInteger32(_pvCtx, _piAddr, &iRows, &iCols, &piData);
 
442
                break;
 
443
            case SCI_UINT8 :
 
444
                sciErr = getMatrixOfUnsignedInteger8(_pvCtx, _piAddr, &iRows, &iCols, &pucData);
 
445
                break;
 
446
            case SCI_UINT16 :
 
447
                sciErr = getMatrixOfUnsignedInteger16(_pvCtx, _piAddr, &iRows, &iCols, &pusData);
 
448
                break;
 
449
            case SCI_UINT32 :
 
450
                sciErr = getMatrixOfUnsignedInteger32(_pvCtx, _piAddr, &iRows, &iCols, &puiData);
 
451
                break;
 
452
            default :
 
453
                return 1;
 
454
        }
 
455
    }
 
456
    else
 
457
    {
 
458
        sciErr = getMatrixOfIntegerPrecision(_pvCtx, _piAddr, &iPrec);
 
459
        if (sciErr.iErr)
 
460
        {
 
461
            printError(&sciErr, 0);
 
462
            return 0;
 
463
        }
 
464
 
 
465
        switch (iPrec)
 
466
        {
 
467
            case SCI_INT8 :
 
468
                sciErr = getMatrixOfInteger8InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pcData);
 
469
                break;
 
470
            case SCI_INT16 :
 
471
                sciErr = getMatrixOfInteger16InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &psData);
 
472
                break;
 
473
            case SCI_INT32 :
 
474
                sciErr = getMatrixOfInteger32InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &piData);
 
475
                break;
 
476
            case SCI_UINT8 :
 
477
                sciErr = getMatrixOfUnsignedInteger8InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pucData);
 
478
                break;
 
479
            case SCI_UINT16 :
 
480
                sciErr = getMatrixOfUnsignedInteger16InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pusData);
 
481
                break;
 
482
            case SCI_UINT32 :
 
483
                sciErr = getMatrixOfUnsignedInteger32InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &puiData);
 
484
                break;
 
485
            default :
 
486
                return 1;
 
487
        }
 
488
    }
 
489
 
 
490
    if (sciErr.iErr)
 
491
    {
 
492
        printError(&sciErr, 0);
 
493
        return 0;
 
494
    }
 
495
 
 
496
    insert_indent();
 
497
 
 
498
    if (iPrec > 10)
 
499
    {
 
500
        sciprint("Unsigned ");
 
501
    }
 
502
 
 
503
    sciprint("Integer %d bits (%d x %d)\n", (iPrec % 10) * 8, iRows, iCols);
 
504
    return 0;;
 
505
}
 
506
int get_string_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
507
{
 
508
    SciErr sciErr;
 
509
    int i;
 
510
    int iRows       = 0;
 
511
    int iCols       = 0;
 
512
    int* piLen      = NULL;
 
513
    char **pstData  = NULL;
 
514
 
 
515
    if (_iItemPos == 0)
 
516
    {
 
517
        //Not in list
 
518
        sciErr = getMatrixOfString(_pvCtx, _piAddr, &iRows, &iCols, NULL, NULL);
 
519
        if (sciErr.iErr)
 
520
        {
 
521
            printError(&sciErr, 0);
 
522
            return 0;
 
523
        }
 
524
 
 
525
        piLen = (int*)malloc(sizeof(int) * iRows * iCols);
 
526
        sciErr = getMatrixOfString(_pvCtx, _piAddr, &iRows, &iCols, piLen, NULL);
 
527
        if (sciErr.iErr)
 
528
        {
 
529
            printError(&sciErr, 0);
 
530
            return 0;
 
531
        }
 
532
 
 
533
        pstData = (char**)malloc(sizeof(char*) * iRows * iCols);
 
534
 
 
535
        for (i = 0 ; i < iRows * iCols ; i++)
 
536
        {
 
537
            pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination
 
538
        }
 
539
 
 
540
        sciErr = getMatrixOfString(_pvCtx, _piAddr, &iRows, &iCols, piLen, pstData);
 
541
        if (sciErr.iErr)
 
542
        {
 
543
            printError(&sciErr, 0);
 
544
            return 0;
 
545
        }
 
546
    }
 
547
    else
 
548
    {
 
549
        sciErr = getMatrixOfStringInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, NULL, NULL);
 
550
        if (sciErr.iErr)
 
551
        {
 
552
            printError(&sciErr, 0);
 
553
            return 0;
 
554
        }
 
555
 
 
556
        piLen = (int*)malloc(sizeof(int) * iRows * iCols);
 
557
 
 
558
        sciErr = getMatrixOfStringInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piLen, NULL);
 
559
        if (sciErr.iErr)
 
560
        {
 
561
            printError(&sciErr, 0);
 
562
            return 0;
 
563
        }
 
564
 
 
565
        pstData = (char**)malloc(sizeof(char*) * iRows * iCols);
 
566
 
 
567
        for (i = 0 ; i < iRows * iCols ; i++)
 
568
        {
 
569
            pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination
 
570
        }
 
571
 
 
572
        sciErr = getMatrixOfStringInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piLen, pstData);
 
573
        if (sciErr.iErr)
 
574
        {
 
575
            printError(&sciErr, 0);
 
576
            return 0;
 
577
        }
 
578
    }
 
579
    if (sciErr.iErr)
 
580
    {
 
581
        printError(&sciErr, 0);
 
582
        return 0;
 
583
    }
 
584
 
 
585
    insert_indent();
 
586
    sciprint("Strings (%d x %d)\n", iRows, iCols);
 
587
    return 0;;
 
588
}
 
589
int get_pointer_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
 
590
{
 
591
    SciErr sciErr;
 
592
    void* pvPtr     = NULL;
 
593
 
 
594
    if (_iItemPos == 0)
 
595
    {
 
596
        sciErr = getPointer(_pvCtx, _piAddr, &pvPtr);
 
597
    }
 
598
    else
 
599
    {
 
600
        sciErr = getPointerInList(_pvCtx, _piParent, _iItemPos, &pvPtr);
 
601
    }
 
602
 
 
603
    if (sciErr.iErr)
 
604
    {
 
605
        printError(&sciErr, 0);
 
606
        return 0;
 
607
    }
 
608
 
 
609
    insert_indent();
 
610
    sciprint("Pointer : 0x%08X\n", pvPtr);
 
611
    return 0;
606
612
}