File: PsychError.c

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (473 lines) | stat: -rw-r--r-- 26,387 bytes parent folder | download | duplicates (3)
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
/*
    PsychToolbox3/Source/Common/PsychError.c

    AUTHORS:

        Allen.Ingling@nyu.edu           awi
        mario.kleiner.de@gmail.com      mk

    PLATFORMS:

        All.

    HISTORY:

        8/19/02  awi    Wrote it.
        11/16/04 awi    Added PsychErorr_argumentValueOutOfRange.

*/

#include "Psych.h"
#define MAX_PSYCH_ERRORS 100

//file static variables
static char *errorStringsERROR[MAX_PSYCH_ERRORS];
static char *errorNameStringsERROR[MAX_PSYCH_ERRORS];
static char *ArgTypeStringsERROR[PsychArgType_NUMTYPES];
static psych_bool usageErrorFlagsERROR[MAX_PSYCH_ERRORS];
static PsychArgDescriptorType specifiedArgERROR, receivedArgERROR;


//file static functions (these don't need the "Psych" prefix because they are file local)
static void InitErrorNameStrings(void);
static void InitErrorStrings(void);
static void InitUsageErrorFlags(void);
static void InitArgFormatTypeStrings(void);


PsychError InitPsychError(void)
{
    InitErrorNameStrings();
    InitErrorStrings();
    InitUsageErrorFlags();
    InitArgFormatTypeStrings();
    return(PsychError_none);
}


static void InitErrorNameStrings(void)
{
    errorNameStringsERROR[PsychError_none]=                             "PsychError_none";

    errorNameStringsERROR[PsychError_invalidArg_absent]=                "PsychError_invalidArg_absent";
    errorNameStringsERROR[PsychError_invalidArg_extra]=                 "PsychError_invalidArg_extra";
    errorNameStringsERROR[PsychError_invalidArg_type]=                  "PsychError_invalidArg_type";
    errorNameStringsERROR[PsychError_invalidArg_size]=                  "PsychError_invalidArg_size";

    errorNameStringsERROR[PsychError_extraInputArg]=                    "PsychError_extraInputArg";
    errorNameStringsERROR[PsychError_missingInputArg]=                  "PsychError_missingInputArg";
    errorNameStringsERROR[PsychError_extraOutputArg]=                   "PsychError_extraOutputArg";
    errorNameStringsERROR[PsychError_missingOutputArg]=                 "PsychError_extraOutputArg";

    errorNameStringsERROR[PsychError_toomanyWin]=                       "PsychError_toomanyWin";
    errorNameStringsERROR[PsychError_outofMemory]=                      "PsychError_outofMemory";
    errorNameStringsERROR[PsychError_scumberNotWindex]=                 "PsychError_scumberNotWindex";
    errorNameStringsERROR[PsychError_windexNotScumber]=                 "PsychError_windexNotScumber";
    errorNameStringsERROR[PsychError_invalidIntegerArg]=                "PsychError_invalidIntegerArg";
    errorNameStringsERROR[PsychError_invalidWindex]=                    "PsychError_invalidWindex";
    errorNameStringsERROR[PsychError_invalidScumber]=                   "PsychError_invalidScumber";
    errorNameStringsERROR[PsychError_invalidNumdex]=                    "PsychError_invalidNumdex";
    errorNameStringsERROR[PsychError_invalidColorArg]=                  "PsychError_invalidColorArg";
    errorNameStringsERROR[PsychError_invalidDepthArg]=                  "PsychError_invalidDepthArg";
    errorNameStringsERROR[PsychError_invalidRectArg]=                   "PsychError_invalidRectArg";
    errorNameStringsERROR[PsychError_invalidNumberBuffersArg]=          "PsychError_invalidNumberBuffersArg";
    errorNameStringsERROR[PsychError_nullWinRecPntr]=                   "PsychError_nullWinRecPntr";
    errorNameStringsERROR[PsychError_registerLimit]=                    "PsychError_registerLimit";
    errorNameStringsERROR[PsychError_registered]=                       "PsychError_registered";
    errorNameStringsERROR[PsychError_longString]=                       "PsychError_longString";
    errorNameStringsERROR[PsychError_longStringPassed]=                 "PsychError_longStringPassed";
    errorNameStringsERROR[PsychError_unimplemented]=                    "PsychError_unimplemented";
    errorNameStringsERROR[PsychError_internal]=                         "PsychError_internal";
    errorNameStringsERROR[PsychError_system]=                           "PsychError_system";
    errorNameStringsERROR[PsychError_invalidArgRef]=                    "Psycherror_invalidArgRef";
    errorNameStringsERROR[PsychError_OpenGL]=                           "Psycherror_OpenGL";
    errorNameStringsERROR[PsychError_SDL]=                              "PsychError_SDL";
    errorNameStringsERROR[PsychError_SurfaceLockFailed]=                "PsychError_SurfaceLockFailed";
    errorNameStringsERROR[PsychError_SurfaceAlreadyLocked]=             "PsychError_SurfaceAlreadyLocked";
    errorNameStringsERROR[PsychError_InvalidWindowRecord]=              "PsychError_InvalidWindowRecord";
    errorNameStringsERROR[PsychError_unsupportedVideoMode]=             "PsychError_unsupportedVideoMode";
    errorNameStringsERROR[PsychError_user]=                             "PsychError_generalUser";
    errorNameStringsERROR[PsychError_unrecognizedPreferenceName]=       "PsychError_unrecognizedPreferenceName";
    errorNameStringsERROR[PsychError_unsupportedOS9Preference]=         "PsychError_unsupportedOS9Preference";
    errorNameStringsERROR[PsychError_inputMatrixIllegalDimensionSize]=  "PsychError_inputMatrixIllegalDimensionSize";
    errorNameStringsERROR[PsychError_stringOverrun]=                    "PsychError_stringOverrun";
    errorNameStringsERROR[PsychErorr_argumentValueOutOfRange]=          "PsychErorr_argumentValueOutOfRange";
}


static void InitErrorStrings(void)
{
    errorStringsERROR[PsychError_none]=                                 "No Error";

    errorStringsERROR[PsychError_invalidArg_absent]=                    "Missing argument";
    errorStringsERROR[PsychError_invalidArg_extra]=                     "Extra argument supplied";
    errorStringsERROR[PsychError_invalidArg_type]=                      "Incorrect argument type supplied";
    errorStringsERROR[PsychError_invalidArg_size]=                      "Wrong size argument supplied";

    errorStringsERROR[PsychError_extraInputArg]=                        "Extra input argument described";
    errorStringsERROR[PsychError_missingInputArg]=                      "Missing input argument";
    errorStringsERROR[PsychError_extraOutputArg]=                       "Extra output argument supplied";
    errorStringsERROR[PsychError_missingOutputArg]=                     "Missing output argument";

    errorStringsERROR[PsychError_toomanyWin]=                           "Exceeded window Limit";
    errorStringsERROR[PsychError_outofMemory]=                          "Out of memory";
    errorStringsERROR[PsychError_scumberNotWindex]=                     "Window index expected, screen number received";
    errorStringsERROR[PsychError_windexNotScumber]=                     "Screen number expected, window index received";
    errorStringsERROR[PsychError_invalidIntegerArg]=                    "Supplied value was either fractional or outside of allowed range.";
    errorStringsERROR[PsychError_invalidWindex]=                        "Invalid Window (or Texture) Index provided: It doesn't correspond to an open window or texture.\nDid you close it accidentally via Screen('Close') or Screen('CloseAll') ?";
    errorStringsERROR[PsychError_invalidScumber]=                       "Invalid Screen Number";
    errorStringsERROR[PsychError_invalidNumdex]=                        "Invalid or missing Screen Number or Window Index";
    errorStringsERROR[PsychError_invalidColorArg]=                      "Invalid Color Argument";
    errorStringsERROR[PsychError_invalidDepthArg]=                      "Invalid pixel size argument";
    errorStringsERROR[PsychError_invalidRectArg]=                       "Invalid Rect Argument";
    errorStringsERROR[PsychError_invalidNumberBuffersArg]=              "Invalid number of buffers specified";
    errorStringsERROR[PsychError_nullWinRecPntr]=                       "Window Record Pointer is NULL";
    errorStringsERROR[PsychError_registerLimit]=                        "Too many subfunctions registered";
    errorStringsERROR[PsychError_registered]=                           "Attempt to reregister a function";
    errorStringsERROR[PsychError_longString]=                           "String exceeds specified length limit";
    errorStringsERROR[PsychError_longStringPassed]=                     "String exceeds specified length limit";
    errorStringsERROR[PsychError_unimplemented]=                        "Feature not yet implemented";
    errorStringsERROR[PsychError_internal]=                             "Unspecified error, probably a Psychtoolbox bug";
    errorStringsERROR[PsychError_system]=                               "Error reported by a system call";
    errorStringsERROR[PsychError_invalidArgRef]=                        "Reference to nonexistent argument";
    errorStringsERROR[PsychError_OpenGL]=                               "OpenGL call returned an error";
    errorStringsERROR[PsychError_SDL]=                                  "SDL call failed.";
    errorStringsERROR[PsychError_SurfaceLockFailed]=                    "Could not lock screen surface.";
    errorStringsERROR[PsychError_SurfaceAlreadyLocked]=                 "Attempt to lock screen surface while it was already locked.";
    errorStringsERROR[PsychError_InvalidWindowRecord]=                  "An Invalid window record was referenced.";
    errorStringsERROR[PsychError_unsupportedVideoMode]=                 "The specified video mode is not supported by the specified display.";
    errorStringsERROR[PsychError_user]=                                 "Usage error";
    errorStringsERROR[PsychError_unrecognizedPreferenceName]=           "Unrecognized preference name";
    errorStringsERROR[PsychError_unsupportedOS9Preference]=             "OS 9 preference unsupported on OS X";
    errorStringsERROR[PsychError_inputMatrixIllegalDimensionSize]=      "Supplied matrix argument is the wrong size";
    errorStringsERROR[PsychError_stringOverrun]=                        "String longer than allocated storage space";
    errorStringsERROR[PsychErorr_argumentValueOutOfRange]=              "A numerical argument value was outside of the allowable range.";
}

/*
    All errors are classifed as either internal or usage errors.  Internal errors are caused
    presumably by a bug in the Psychtoolbox or project, usage errors are cuased by the user
    passing a bogus argument.  The classification determines the style in which PsychErrorExitMsg
    reports the bug.
*/
#define            kPsychUserError                    TRUE
#define            kPsychBug                        FALSE

static void InitUsageErrorFlags(void)
{

    //TRUE means that the user did something wrong.
    //FALSE means that it's an internal Psychtoolbox or OS error.
    usageErrorFlagsERROR[PsychError_none]=                                  kPsychBug;

    usageErrorFlagsERROR[PsychError_invalidArg_absent]=                     kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidArg_extra]=                      kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidArg_type]=                       kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidArg_size]=                       kPsychUserError;

    usageErrorFlagsERROR[PsychError_extraInputArg]=                         kPsychUserError;
    usageErrorFlagsERROR[PsychError_missingInputArg]=                       kPsychUserError;
    usageErrorFlagsERROR[PsychError_extraOutputArg]=                        kPsychUserError;
    usageErrorFlagsERROR[PsychError_missingOutputArg]=                      kPsychUserError;

    usageErrorFlagsERROR[PsychError_toomanyWin]=                            kPsychBug;
    usageErrorFlagsERROR[PsychError_outofMemory]=                           kPsychBug;
    usageErrorFlagsERROR[PsychError_scumberNotWindex]=                      kPsychUserError;
    usageErrorFlagsERROR[PsychError_windexNotScumber]=                      kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidWindex]=                         kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidIntegerArg]=                     kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidScumber]=                        kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidNumdex]=                         kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidColorArg]=                       kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidDepthArg]=                       kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidRectArg]=                        kPsychUserError;
    usageErrorFlagsERROR[PsychError_invalidNumberBuffersArg]=               kPsychUserError;
    usageErrorFlagsERROR[PsychError_nullWinRecPntr]=                        kPsychBug;
    usageErrorFlagsERROR[PsychError_registerLimit]=                         kPsychBug;
    usageErrorFlagsERROR[PsychError_registered]=                            kPsychBug;
    usageErrorFlagsERROR[PsychError_longString]=                            kPsychBug;
    usageErrorFlagsERROR[PsychError_longStringPassed]=                      kPsychUserError;
    usageErrorFlagsERROR[PsychError_unimplemented]=                         kPsychBug;
    usageErrorFlagsERROR[PsychError_internal]=                              kPsychBug;
    usageErrorFlagsERROR[PsychError_internal]=                              kPsychBug;
    usageErrorFlagsERROR[PsychError_invalidArgRef]=                         kPsychBug;
    usageErrorFlagsERROR[PsychError_OpenGL]=                                kPsychBug;
    usageErrorFlagsERROR[PsychError_SDL]=                                   kPsychBug;
    usageErrorFlagsERROR[PsychError_SurfaceLockFailed]=                     kPsychBug;
    usageErrorFlagsERROR[PsychError_SurfaceAlreadyLocked]=                  kPsychBug;
    usageErrorFlagsERROR[PsychError_InvalidWindowRecord]=                   kPsychBug;
    usageErrorFlagsERROR[PsychError_unsupportedVideoMode]=                  kPsychUserError;
    usageErrorFlagsERROR[PsychError_user]=                                  kPsychUserError;
    usageErrorFlagsERROR[PsychError_unrecognizedPreferenceName]=            kPsychUserError;
    usageErrorFlagsERROR[PsychError_unsupportedOS9Preference]=              kPsychUserError;
    usageErrorFlagsERROR[PsychError_inputMatrixIllegalDimensionSize]=       kPsychUserError;
    usageErrorFlagsERROR[PsychError_stringOverrun]=                         kPsychBug;
    usageErrorFlagsERROR[PsychErorr_argumentValueOutOfRange]=               kPsychUserError;
}


/*
    TO DO: These names depend on the scripting language and should be moved to ScriptingGlue
*/
static void InitArgFormatTypeStrings(void)
{
    ArgTypeStringsERROR[0] =    "unspecified";
    ArgTypeStringsERROR[1] =    "unclassified";
    ArgTypeStringsERROR[2] =    "char";
    ArgTypeStringsERROR[3] =    "uint8";
    ArgTypeStringsERROR[4] =    "uint16";
    ArgTypeStringsERROR[5] =    "uint32";
    ArgTypeStringsERROR[6] =    "int8";
    ArgTypeStringsERROR[7] =    "int16";
    ArgTypeStringsERROR[8] =    "int32";
    ArgTypeStringsERROR[9] =    "double";
    ArgTypeStringsERROR[10] =   "boolean";
    ArgTypeStringsERROR[11] =   "struct";
    ArgTypeStringsERROR[12] =   "cell";
    ArgTypeStringsERROR[13] =   "single";
    ArgTypeStringsERROR[14] =   "uint64";
    ArgTypeStringsERROR[15] =   "int64";
    ArgTypeStringsERROR[16] =   "default";
}


/*
    format specifiers can consist of multiple type specifications when specifing
    allowed inputs.  This function returns the number of types which compose a
    type specification and  a list of the strings naming those types.
*/
int PsychDecomposeArgFormat(PsychArgFormatType argType,  const char **names)
{
    int i, numTypes=0;
    PsychArgFormatType strIndex;
      psych_bool isElement;

    //we are given a composite of types so find which to name in the string
    for(i=0;i<PsychArgType_NUMTYPES;i++){
        strIndex = (PsychArgFormatType)pow(2,i);
        isElement = (psych_bool)(((int)argType & (int)strIndex) > 0);
        if(isElement){
            if(names!=NULL) //in case we only want a count and pass NULL for names
                names[numTypes]=ArgTypeStringsERROR[i];
            ++numTypes;
        }
    }
    return numTypes;
}

/*
    If there is no error then just return().  If there is an error then
    print the function name which should have been pushed using PsychPushHelp.
    and also print the string describing the type of error and then return
    control to the scripting environment.

    extraErrorString can provide addional debugging info.

    TO DO:
    See "to do" list above.  This could be improved to print more specific error
    information, for example whith an invalid argument it could print which argument
    was invalid or which was missing.

    PsychErrorExitMsg should be renamed PsychErrorExitC and accept another argument which
    is the string naming the file or function where the error occurred. A macro named PsychErrorExitMsg
    should be provided which calls PsychErrorExitMsg and plugs in the ANSI predifined macros giving the
    file and function where the error occurred.  PsychErrorExitC only prints that if the error type
    is internal.

*/
void PsychErrorExitC(PsychError error,
                     const char *extraErrorString,
                     int lineNum,
                     const char *funcName,
                     const char *fileName)
{
    char *functionName;
    PsychArgDescriptorType *specified, *received;
    int i, numTypes;
    const char *typeStrings[PsychArgType_NUMTYPES];

    // This function must be implemented by the scripting glue and allows to
    // process the error in some frontend specific way, e.g., set exception
    // state, or simply ignore it:
    PsychProcessErrorInScripting(error, extraErrorString ? extraErrorString : errorStringsERROR[error]);

    //if the error is type none then just return
    if(error==PsychError_none)
        return;

    //if the error is an internal error then display copious info
    if(!usageErrorFlagsERROR[error]){
        printf("INTERNAL PSYCHTOOLBOX ERROR\n");
        printf("\terror:                %s\n",errorNameStringsERROR[error]);
        printf("\tgeneral description:  %s\n",errorStringsERROR[error]);
        if(extraErrorString != NULL)
            printf("\tspecific description: %s\n",extraErrorString);
        printf("\tmodule name:          %s\n",PsychGetModuleName());
        printf("\tsubfunction call:     %s\n",PsychGetFunctionName());
        printf("\tfile name:            %s\n",fileName);
        printf("\tfunction name:        %s\n",funcName);
        printf("\tline number:          %d\n",lineNum);
        PsychErrMsgTxt(NULL);  //exit the module
    }else{
        //if the error is usage error then
        functionName = PsychGetFunctionName();
        printf("Error in function %s: ",functionName);
        printf("\t%s\n",errorStringsERROR[error]);
        if(extraErrorString !=NULL)
            printf("%s\n",extraErrorString);
        //attempts to fetch or return arguments cache descriptions of the the desired
        //and returned values in static variables.  If attempts to set or retrieve an
        //argument resulted in an error value PsychError_invalidArg_*, then we can retrieve that info
        //about the specified and desired argument to generate a detailed error message.
        if(error == PsychError_invalidArg_absent || error == PsychError_invalidArg_extra || error == PsychError_invalidArg_type || error == PsychError_invalidArg_size){
            PsychGetArgDescriptor(&specified, &received);
            if(specified != NULL && received != NULL){  //why would these be null ?
                //for specified
                printf("\tDiscrepancy between a specified and supplied argument:\n");
                printf("\t\tSpecified Argument Description:\n");
                printf("\t\t\tdirection: %s\n", (specified->direction==PsychArgIn) ? "Input" : "Output");  //input  or output
                printf("\t\t\tposition: %d\n", specified->position);  //position
                printf("\t\t\tpresence:");
                switch(specified->isThere){
                    case kPsychArgAbsent: printf("forbidden");break;
                    case kPsychArgPresent: printf("required");break;
                    case kPsychArgFixed: printf("fixed");break;
                }
                printf("\n");

                printf("\t\t\tformats allowed:\n");
                numTypes=PsychDecomposeArgFormat(specified->type, typeStrings);
                for(i=0;i<numTypes;i++)
                    printf("\t\t\t\t%s\n",typeStrings[i]);

                printf("\t\t\tminimum M: %s\n", int2str(specified->mDimMin));
                printf("\t\t\tmaximum M: %s\n", (specified->mDimMax==kPsychUnboundedArraySize) ? "unbounded" : int2str(specified->mDimMax));
                printf("\t\t\tminimum N: %s\n", int2str(specified->nDimMin));
                printf("\t\t\tmaximum N: %s\n", (specified->nDimMax==kPsychUnboundedArraySize) ? "unbounded" : int2str(specified->nDimMax));
                printf("\t\t\tminimum P: %s\n", int2str(specified->pDimMin));
                printf("\t\t\tmaximum P: %s\n", (specified->pDimMax==kPsychUnboundedArraySize) ? "unbounded" : int2str(specified->pDimMax));

                //For received
                printf("\t\tProvided Argument Description:\n");
                printf("\t\t\tdirection: %s\n", (received->direction== PsychArgIn) ? "Input" : "Output");  //input  or output
                printf("\t\t\tposition: %d\n", received->position);  //position
                printf("\t\t\tpresence: ");
                switch(received->isThere){
                    case kPsychArgAbsent: printf("absent\n");break;
                    case kPsychArgPresent: printf("present\n");break;
                    case kPsychArgFixed: printf("fixed\n");break;
                }
                if(received->isThere!=kPsychArgAbsent && received->direction==PsychArgIn){
                    printf("\t\t\tformat: ");

                    numTypes=PsychDecomposeArgFormat(received->type, typeStrings); //there should only be one, but check for bugs
                    for(i=0;i<numTypes;i++)
                        printf("%s\n",typeStrings[i]);
                    printf("\t\t\tnumber of dimensions: %d\n", received->numDims);
                    printf("\t\t\t\t M: %s\n", int2str(received->mDimMin));
                    printf("\t\t\t\t N: %s\n", int2str(received->nDimMin));
                    printf("\t\t\t\t P: %s\n", int2str(received->pDimMin));
                }
            }
        }
        PsychGiveUsageExit();
    }
}


/*
    copy out from structures specified by pointers and store in static variable
*/
PsychError PsychStoreArgDescriptor(PsychArgDescriptorType *specified,
                                   PsychArgDescriptorType *received)
{
    if(specified != NULL)
        memcpy(&specifiedArgERROR, specified, sizeof(PsychArgDescriptorType));

    if(received != NULL)
        memcpy(&receivedArgERROR, received, sizeof(PsychArgDescriptorType));

    return(PsychError_none);
}


/*
    set referenced pointers to the structures
*/
PsychError PsychGetArgDescriptor(PsychArgDescriptorType **specified,
                                 PsychArgDescriptorType **received)
{
    if(specified!=NULL)
        *specified = &specifiedArgERROR;
    if(received!=NULL)
        *received = &receivedArgERROR;

    return(PsychError_none);
}


/*
    PsychDumpArgDescriptors has not yet been tested.

    Note that argument descriptors are described in three dimensions:
    1- Specified or Received.
    2- Input or Output
    3- Position
*/
void PsychDumpArgDescriptors(void)
{
    printf("\n");
    printf("__________________________________________");
    /* display the specified argument descriptor. */
    printf("SPECIFIED ARGUMENT DESCRIPTOR:\n");
    printf("position:     %d\n", specifiedArgERROR.position);
    printf("direction:      ");
    switch(specifiedArgERROR.direction){
        case PsychArgIn: printf("PsychArgIn\n"); break;
        case PsychArgOut: printf("PsychArgOut\n"); break;
    }
    printf("isThere:      ");
    switch(specifiedArgERROR.isThere){
        case kPsychArgAbsent: printf("kPsychArgAbsent\n"); break;
        case kPsychArgPresent: printf("kPsychArgPresent\n"); break;
        case kPsychArgFixed: printf("kPsychArgFixed\n"); break;
    }

    printf("type:      %d\n", (int)specifiedArgERROR.type); //this should be fixed to display a type name
    printf("mDimMin:      %s\n", int2str(specifiedArgERROR.mDimMin));
    printf("mDimMax:      %s\n", int2str(specifiedArgERROR.mDimMax));
    printf("nDimMin:      %s\n", int2str(specifiedArgERROR.nDimMin));
    printf("nDimMax:      %s\n", int2str(specifiedArgERROR.nDimMax));
    printf("pDimMin:      %s\n", int2str(specifiedArgERROR.pDimMin));
    printf("pDimMax:      %s\n", int2str(specifiedArgERROR.pDimMax));

    /* display the received argument descriptor. */
    printf("RECEIVED ARGUMENT DESCRIPTOR:\n");
    printf("position:     %d\n", receivedArgERROR.position);
    printf("direction:      ");
    switch(receivedArgERROR.direction){
        case PsychArgIn: printf("PsychArgIn\n"); break;
        case PsychArgOut: printf("PsychArgOut\n"); break;
    }

    printf("isThere:      ");
    switch(receivedArgERROR.isThere){
        case kPsychArgAbsent: printf("kPsychArgAbsent\n"); break;
        case kPsychArgPresent: printf("kPsychArgPresent\n"); break;
        case kPsychArgFixed: printf("kPsychArgFixed\n"); break;
    }

    if((receivedArgERROR.isThere==kPsychArgPresent) && (receivedArgERROR.direction==PsychArgIn)){
        printf("type:      %d\n", (int)receivedArgERROR.type);
        printf("numDims:      %s\n", int2str(receivedArgERROR.numDims));
        printf("mDimMin:      %s\n", int2str(receivedArgERROR.mDimMin));
        printf("mDimMax:      %s\n", int2str(receivedArgERROR.mDimMax));
        printf("nDimMin:      %s\n", int2str(receivedArgERROR.nDimMin));
        printf("nDimMax:      %s\n", int2str(receivedArgERROR.nDimMax));
        printf("pDimMin:      %s\n", int2str(receivedArgERROR.pDimMin));
        printf("pDimMax:      %s\n", int2str(receivedArgERROR.pDimMax));
    }

    printf("__________________________________________");
    printf("\n");
}