int PrepFrictionMeasurement( DexApparatus *apparatus, const char *params ) { double duration = 15.0; duration = ParseForDuration( apparatus, params ); char msg[1024]; AddDirective( apparatus, "You will first pinch the manipulandum at the center between thumb and forefinger.", "coef_frict.bmp" ); AddDirective( apparatus, "Squeeze according to the instructions that you will receive (firmly, moderately, lightly).", "coef_frict.bmp" ); AddDirective( apparatus, "When you hear the beep, rub the fingers up and down on the manipulandum. ", "coef_frict_fp.bmp"); sprintf( msg, "You will rub for %.0f seconds. Move from center to edge and back. Try to maintain pinch force.", duration ); AddDirective( apparatus, msg, "coef_frict_fp.bmp" ); ShowDirectives( apparatus ); return( NORMAL_EXIT ); }
int PrepOscillations( DexApparatus *apparatus, const char *params ) { int status = 0; char *target_filename = 0; char *mtb, *dsc; int direction = ParseForDirection( apparatus, params ); int eyes = ParseForEyeState( params ); DexSubjectPosture posture = ParseForPosture( params ); DexTargetBarConfiguration bar_position; if ( direction == VERTICAL ) bar_position = TargetBarRight; else bar_position = TargetBarLeft; // Prompt the subject to put the target bar in the correct position. if ( bar_position == TargetBarRight ) { status = apparatus->fWaitSubjectReady( ( posture == PostureSeated ? "TappingFolded.bmp" : "TappingFolded.bmp" ), PlaceTargetBarRightFolded, OkToContinue ); } else { status = apparatus->fWaitSubjectReady( ( posture == PostureSeated ? "BarLeft.bmp" : "BarLeft.bmp" ), "Place the target bar in the left position.%s", OkToContinue ); } if ( status == ABORT_EXIT ) exit( status ); // Verify that the apparatus is in the correct configuration, and if not, // give instructions to the subject about what to do. status = CheckInstall( apparatus, posture, bar_position ); if ( status != NORMAL_EXIT ) return( status ); // Instruct the subject on the task to be done. // Show them the targets that will be used. apparatus->TargetsOff(); if ( direction == VERTICAL ) { apparatus->VerticalTargetOn( oscillationTargets[UPPER] ); apparatus->VerticalTargetOn( oscillationTargets[LOWER] ); } else { apparatus->HorizontalTargetOn( oscillationTargets[UPPER] ); apparatus->HorizontalTargetOn( oscillationTargets[LOWER] ); } // Describe how to do the task, according to the desired conditions. AddDirective( apparatus, InstructPickUpManipulandum, "InHand.bmp" ); if ( direction == VERTICAL ) { mtb = "MvToBlkV.bmp"; dsc = "OscillateV.bmp"; } else { mtb = "MvToBlkH.bmp"; dsc = "OscillateH.bmp"; } if ( eyes == OPEN ) { AddDirective( apparatus, "You will hold the manipulandum upright and to the right of the blinking Target LED.", mtb ); AddDirective( apparatus, "You will then oscillate between the lit targets, one full cycle per beep.", dsc ); // Need to change pictures to remove beeps. AddDirective( apparatus, "When the beeps will stop, you should continue the oscillations.", dsc ); } // If we delete oscillation in discrete, then we don't need this condition here below any more. else { AddDirective( apparatus, "You will hold the manipulandum upright and to the right of the blinking Target LED.", mtb ); AddDirective( apparatus, "You will then CLOSE your eyes and oscillate between the targets, one full cycle per beep.", dsc ); AddDirective( apparatus, "When the beeps stop, you should continue the oscillations, keeping your eyes CLOSED.", dsc ); } ShowDirectives( apparatus ); return( NORMAL_EXIT ); }
static int ParseArgs( int argc, char **argv ) /*********************************************/ { char *p; int wcc_option; int c; int i; list *new_item; initialize_Flags(); DebugFlag = 1; StackSize = NULL; Conventions[0] = 'r'; Conventions[1] = '\0'; preprocess_only = 0; cpp_want_lines = 1; /* NB: wcc and wcl default to 0 here */ cpp_keep_comments = 0; cpp_encrypt_names = 0; cpp_linewrap = NULL; O_Name = NULL; AltOptChar = '-'; /* Suppress '/' as option herald */ while( (c = GetOpt( &argc, argv, #if 0 "b:Cc::D:Ef:g::" "HI:i::k:L:l:M::m:" "O::o:P::QSs::U:vW::wx:yz::", #else "b:CcD:Ef:g::" "HI:i::k:L:l:M::m:" "O::o:P::QSs::U:vW::wx::yz::", #endif EnglishHelp )) != -1 ) { char *Word = ""; int found_mapping = FALSE; for( i = 0; i < sizeof( mappings ) / sizeof( mappings[0] ); i++ ) { option_mapping *m = mappings + i; char *tail = strchr( m->LongName, ':' ); if( c != m->LongName[0] ) continue; if( OptArg == NULL ) { if( m->LongName[1] == '\0' ) { strcat( CC_Opts, " -" ); strcat( CC_Opts, m->WatcomName ); found_mapping = TRUE; break; } /* non-existant argument can't match other cases */ continue; } if( tail != NULL ) { if( !strncmp( OptArg, m->LongName + 1, tail - m->LongName - 1 ) ) { strcat( CC_Opts, " -" ); strcat( CC_Opts, m->WatcomName ); strcat( CC_Opts, OptArg + ( tail - m->LongName - 1) ); found_mapping = TRUE; break; } } else if( !strcmp( OptArg, m->LongName + 1 ) ) { strcat( CC_Opts, " -" ); strcat( CC_Opts, m->WatcomName ); found_mapping = TRUE; break; } } if( found_mapping ) continue; if( OptArg != NULL ) { Word = MemAlloc( strlen( OptArg ) + 6 ); strcpy( Word, OptArg ); } wcc_option = 1; switch( c ) { case 'f': if( !strcmp( Word, "syntax-only" ) ) { c = 'z'; strcpy( Word, "s" ); Flags.no_link = 1; break; } if( !strncmp( Word, "cpp-wrap=", 9 ) ) { MemFree( cpp_linewrap ); Word[7] = 'w'; cpp_linewrap = MemStrDup( Word + 7 ); wcc_option = 0; break; } if( !strcmp( Word, "mangle-cpp" ) ) { cpp_encrypt_names = 1; wcc_option = 0; break; } switch( Word[0] ) { case 'd': /* name of linker directive file */ if( Word[1] == '=' || Word[1] == '#' ) { MakeName( Word, ".lnk" ); /* add extension */ MemFree( Link_Name ); Link_Name = strfdup( Word + 2 ); } else { MemFree( Link_Name ); Link_Name = MemStrDup( TEMPFILE ); } wcc_option = 0; break; case 'm': /* name of map file */ Flags.map_wanted = TRUE; if( Word[1] == '=' || Word[1] == '#' ) { MemFree( Map_Name ); Map_Name = strfdup( Word + 2 ); } wcc_option = 0; break; case 'o': /* name of object file */ /* parse off argument, so we get right filename in linker command file */ p = &Word[1]; if( Word[1] == '=' || Word[1] == '#' ) { ++p; } MemFree( Obj_Name ); Obj_Name = strfdup( p ); /* 08-mar-90 */ break; case 'r': /* name of error report file */ Flags.want_errfile = TRUE; break; } /* avoid passing on unknown options */ wcc_option = 0; break; case 'k': /* stack size option */ if( Word[0] != '\0' ) { MemFree( StackSize ); StackSize = MemStrDup( Word ); } wcc_option = 0; break; /* compiler options that affect the linker */ case 'c': /* compile only */ Flags.no_link = TRUE; wcc_option = 0; break; case 'x': /* change source language */ if( strcmp( Word, "c" ) == 0 ) { Flags.force_c = TRUE; } else if( strcmp( Word, "c++" ) == 0 ) { Flags.force_c_plus = TRUE; } else { Flags.no_link = TRUE; } wcc_option = 0; break; case 'm': if( ( !strncmp( "cmodel=", Word, 7 ) ) && ( Word[8] == '\0' ) ) { if( Word[7] == 't' ) { /* tiny model */ Word[0] = 's'; /* change to small */ Flags.tiny_model = TRUE; } else { Word[0] = Word[7]; } Word[1] = '\0'; break; } if( !strncmp( "regparm=", Word, 8 ) ) { if( !strcmp( Word + 8, "0" ) ) { Conventions[0] = 's'; } else { Conventions[0] = 'r'; } wcc_option = 0; break; } if( !strncmp( "tune=i", Word, 6 ) ) { switch( Word[6] ) { case '0': case '1': case '2': CPU_Class = Word[6]; Conventions[0] = '\0'; break; case '3': case '4': case '5': case '6': CPU_Class = Word[6]; break; default: /* Unknown CPU type --- disable generation of this * option */ CPU_Class = '\0'; } wcc_option = 0; break; } wcc_option = 0; /* dont' pass on unknown options */ break; case 'z': /* 12-jan-89 */ switch( tolower( Word[0] ) ) { case 's': Flags.no_link = TRUE; break; case 'q': Flags.be_quiet = TRUE; break; case 'w': Flags.windows = TRUE; } break; case 'E': preprocess_only = 1; wcc_option = 0; break; case 'P': cpp_want_lines = 0; wcc_option = 0; break; case 'C': cpp_keep_comments = 1; wcc_option = 0; break; case 'o': MemFree( O_Name ); O_Name = strfdup( OptArg ); wcc_option = 0; break; case 'g': if( OptArg == NULL ) { Word = "2"; } else if( !isdigit( OptArg[0] ) ) { c = 'h'; if( strcmp( Word, "w" ) == 0 ) { DebugFlag = 3; } else if( strcmp( Word, "c" ) == 0 ) { /* 02-mar-91 */ Flags.do_cvpack = 1; DebugFlag = 4; } else if( strcmp( Word, "d" ) == 0 ) { DebugFlag = 5; } break; } c = 'd'; parse_d: if( DebugFlag == 0 ) { /* not set by -h yet */ if( strcmp( Word, "1" ) == 0 ) { DebugFlag = 1; } else if( strcmp( Word, "1+" ) == 0 ) { /* 02-mar-91 */ DebugFlag = 2; } else if( strcmp( Word, "2" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2s" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3s" ) == 0 ) { DebugFlag = 2; } } break; case 'S': Flags.do_disas = TRUE; Flags.no_link = TRUE; if( DebugFlag == 0 ) { c = 'd'; Word = "1"; goto parse_d; } wcc_option = 0; break; case 's': if( OptArg != NULL ) { /* leave -shared to mapping table */ wcc_option = 0; break; } Flags.strip_all = 1; DebugFlag = 0; wcc_option = 0; break; case 'v': Flags.be_quiet = 0; wcc_option = 0; break; case 'W': if( OptArg != NULL && strncmp( OptArg, "l,", 2 ) == 0 ) { AddDirective( OptArg + 2 ); wcc_option = 0; } /* other cases handled by table */ break; case 'I': xlate_fname( Word ); break; case 'b': Flags.link_for_sys = TRUE; MemFree( SystemName ); SystemName = MemStrDup( Word ); /* if Word found in specs.owc, add options from there: */ if( ConsultSpecsFile( Word ) ) { /* all set */ wcc_option = 0; } else { /* not found --- default to bt=<system> */ strcpy( Word, "t=" ); strcat( Word, SystemName ); } break; case 'l': new_item = MemAlloc( sizeof( list ) ); new_item->next = NULL; p = MemAlloc( strlen( OptArg ) + 2 + 1 ); strcpy( p, OptArg ); strcat( p, ".a" ); new_item->item = strfdup( p ); MemFree( p ); ListAppend( &Libs_List, new_item ); wcc_option = 0; break; case 'L': xlate_fname( Word ); fputs( "libpath ", Fp ); Fputnl( Word, Fp ); wcc_option = 0; break; case 'i': /* -include <file> --> -fi=<file> */ if( OptArg == NULL ) { wcc_option = 0; break; } if( !strcmp( OptArg, "nclude" ) ) { c = 'f'; Word = MemReAlloc( Word, strlen( argv[OptInd] ) + 6 ); if( OptInd >= argc - 1 ) { MemFree( cpp_linewrap ); PrintMsg( "Argument of -include missing\n", OptArg ); return( 1 ); } strcpy( Word, "i=" ); strfcat( Word, argv[OptInd] ); argv[OptInd++][0] = '\0'; break; } /* avoid passing un unknown options */ wcc_option = 0; break; case 'M': /* autodepend information for Unix makes */ if( OptArg == NULL ) { wcc_option = 0; break; } c = 'a'; if( !strcmp( OptArg, "D" ) || !strcmp( OptArg, "MD" ) ) { /* NB: only -MMD really matches OW's behaviour, but * for now, let's accept -MD to mean the same */ /* translate to -adt=.o */ strcpy( Word, "dt=.o" ); } else if( !strcmp( OptArg, "F" ) ) { Word = MemReAlloc( Word, strlen( argv[OptInd] ) + 6 ); if( OptInd >= argc - 1 ) { MemFree( cpp_linewrap ); PrintMsg( "Argument of -MF missing\n", OptArg ); return( 1 ); } strcpy( Word, "d=" ); strfcat( Word, argv[OptInd] ); argv[OptInd++][0] = '\0'; } else if( !strcmp( OptArg, "T") ) { Word = MemReAlloc( Word, strlen( argv[OptInd] ) + 6 ); if( OptInd >= argc - 1 ) { MemFree( cpp_linewrap ); PrintMsg( "Argument of -M%s missing\n", OptArg ); return( 1 ); } strcpy( Word, "dt=" ); strcat( Word, argv[OptInd] ); argv[OptInd++][0] = '\0'; } else { /* avoid passing on incompatible options */ wcc_option = 0; } break; } /* don't add linker-specific options */ /* to compiler command line: */ if( wcc_option ) { addccopt( c, Word ); } if( OptArg != NULL ) { MemFree( Word ); Word = NULL; } } if( preprocess_only ) { Flags.no_link = TRUE; if( O_Name == NULL ) { MemFree( Obj_Name ); /* preprocess to stdout by default */ Obj_Name = NULL; } strcat( CC_Opts, " -p" ); if( cpp_encrypt_names ) strcat( CC_Opts, "e" ); if( cpp_want_lines ) strcat( CC_Opts, "l" ); if( cpp_keep_comments ) strcat( CC_Opts, "c" ); if( cpp_linewrap != NULL ) { strcat( CC_Opts, cpp_linewrap ); } } if( CPU_Class ) addccopt( CPU_Class, Conventions ); if( Flags.be_quiet ) addccopt( 'z', "q" ); if( O_Name != NULL ) { if( Flags.no_link && !Flags.do_disas ) { MemFree( Obj_Name ); Obj_Name = O_Name; } else { strcpy( Exe_Name, O_Name ); Flags.keep_exename = 1; MemFree( O_Name ); } O_Name = NULL; } if( Obj_Name != NULL ) { strcat( CC_Opts, " -fo=" ); strcat( CC_Opts, Obj_Name ); } if( !Flags.want_errfile ) { strcat( CC_Opts, " -fr" ); } for( i = 1; i < argc ; i++ ) { Word = argv[i]; if( Word == NULL || Word[0] == '\0' ) /* HBB 20060217: argument was used up */ continue; new_item = MemAlloc( sizeof( list ) ); new_item->next = NULL; new_item->item = strfdup( Word ); if( FileExtension( Word, ".lib" ) || FileExtension( Word, ".a" ) ) { ListAppend( &Libs_List, new_item ); } else { ListAppend( &Files_List, new_item ); } } MemFree( cpp_linewrap ); return( 0 ); }
static int Parse( char *Cmd ) /***************************/ { char opt; char *end; FILE *atfp; char buffer[_MAX_PATH]; char unquoted[_MAX_PATH]; size_t len; char *p; int wcc_option; list *new_item; /* Cmd will always begin with at least one */ /* non-space character if we get this far */ for( ;; ) { Cmd = SkipSpaces( Cmd ); if( *Cmd == '\0' ) break; opt = *Cmd; if( opt == '-' || opt == Switch_Chars[1] ) { Cmd++; } else if( opt != '@' ) { opt = ' '; } end = Cmd; if( *Cmd == '"' ) { end = FindNextWS( end ); } else { end = FindNextWSOrOpt( end, opt, Switch_Chars ); } len = end - Cmd; if( len != 0 ) { if( opt == ' ' ) { /* if filename, add to list */ strncpy( Word, Cmd, len ); Word[len] = '\0'; end = ScanFName( end, len ); UnquoteFName( unquoted, sizeof( unquoted ), Word ); new_item = MemAlloc( sizeof( list ) ); new_item->next = NULL; new_item->item = MemStrDup( unquoted ); if( FileExtension( Word, ".lib" ) ) { ListAppend( &Libs_List, new_item ); } else if( FileExtension( Word, ".res" ) ) { ListAppend( &Res_List, new_item ); } else { ListAppend( &Files_List, new_item ); } } else { /* otherwise, do option */ --len; strncpy( Word, Cmd + 1, len ); Word[len] = '\0'; wcc_option = 1; /* assume it's a wcc option */ switch( tolower( *Cmd ) ) { case 'b': /* possibly -bcl */ if( strnicmp( Word, "cl=", 3 ) == 0 ) { strcat( CC_Opts, " -bt=" ); strcat( CC_Opts, Word+3 ); Flags.link_for_sys = TRUE; MemFree( SystemName ); SystemName = MemStrDup( Word+3 ); wcc_option = 0; } break; case 'f': /* files option */ p = ScanFName( end, len ); switch( tolower( Word[0] ) ) { case 'd': /* name of linker directive file */ if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target linker control filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); MakeName( unquoted, ".lnk" ); /* add extension */ MemFree( Link_Name ); Link_Name = MemStrDup( unquoted ); } else { MemFree( Link_Name ); Link_Name = MemStrDup( TEMPFILE ); } wcc_option = 0; break; case 'e': /* name of exe file */ if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target executable filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); strcpy( Exe_Name, unquoted ); } wcc_option = 0; break; case 'i': /* name of forced include file */ end = p; break; case 'm': /* name of map file */ Flags.map_wanted = TRUE; if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target map filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); MemFree( Map_Name ); Map_Name = MemStrDup( unquoted ); } wcc_option = 0; break; case 'o': /* name of object file */ end = p; /* parse off argument, so we get right filename in linker command file */ p = &Word[1]; if( Word[1] == '=' || Word[1] == '#' ) ++p; /* remove quotes from object name */ UnquoteFName( unquoted, sizeof( unquoted ), p ); MemFree( Obj_Name ); Obj_Name = MemStrDup( unquoted ); break; #if defined( WCLI86 ) || defined( WCL386 ) case 'p': /* floating-point option */ end = p; if( tolower( Word[1] ) == 'c' ) { Flags.math_8087 = 0; } break; #endif default: end = p; break; } break; case 'k': /* stack size option */ if( Word[0] != '\0' ) { MemFree( StackSize ); StackSize = MemStrDup( Word ); } wcc_option = 0; break; case 'l': /* link target option */ switch( (Word[1] << 8) | tolower( Word[0] ) ) { case 'p': Flags.link_for_dos = 0; Flags.link_for_os2 = TRUE; break; case 'r': Flags.link_for_dos = TRUE; Flags.link_for_os2 = 0; break; default: /* 10-jun-91 */ Flags.link_for_sys = TRUE; p = &Word[0]; if( Word[0] == '=' || Word[0] == '#' ) ++p; MemFree( SystemName ); SystemName = MemStrDup( p ); break; } wcc_option = 0; break; case 'x': if( Word[0] == '\0' ) { Flags.two_case = TRUE; wcc_option = 0; } break; case '@': if( Word[0] != '\0' ) { char const * const env = getenv( Word ); if( env != NULL ) { if( handle_environment_variable( env ) ) { return( 1 ); // Recursive call failed } via_environment = TRUE; Cmd = end; continue; } end = ScanFName( end, len ); /* remove quotes from additional linker options file */ UnquoteFName( unquoted, sizeof( unquoted ), Word ); strcpy( Word, unquoted ); MakeName( Word, ".lnk" ); errno = 0; if( (atfp = fopen( Word, "r" )) == NULL ) { PrintMsg( WclMsgs[UNABLE_TO_OPEN_DIRECTIVE_FILE], Word, strerror( errno ) ); return( 1 ); } while( fgets( buffer, sizeof( buffer ), atfp ) != NULL ) { if( strnicmp( buffer, "file ", 5 ) == 0 ) { /* look for names separated by ','s */ p = strchr( buffer, '\n' ); if( p != NULL ) *p = '\0'; AddName( &buffer[5], Fp ); Flags.do_link = TRUE; } else { fputs( buffer, Fp ); } } fclose( atfp ); } wcc_option = 0; break; /* compiler options that affect the linker */ #ifdef WCL386 case '3': case '4': case '5': /* 22-sep-92 */ Conventions = tolower( Word[0] ); break; #endif case 'd': if( DebugFlag == 0 ) { /* not set by -h yet */ if( strcmp( Word, "1" ) == 0 ) { DebugFlag = 1; } else if( strcmp( Word, "1+" ) == 0 ) { /* 02-mar-91 */ DebugFlag = 2; } else if( strcmp( Word, "2" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2s" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3s" ) == 0 ) { DebugFlag = 2; } } break; case 'h': if( strcmp( Word, "w" ) == 0 ) { DebugFlag = 3; } else if( strcmp( Word, "c" ) == 0 ) { /* 02-mar-91 */ Flags.do_cvpack = 1; DebugFlag = 4; } else if( strcmp( Word, "d" ) == 0 ) { DebugFlag = 5; } break; case 'i': /* include file path */ end = ScanFName( end, len ); break; case 'c': /* compile only */ if( stricmp( Word, "c" ) == 0 ) { Flags.force_c = TRUE; } else if( stricmp( Word, "c++" ) == 0 ) { Flags.force_c_plus = TRUE; } else { Flags.no_link = TRUE; } wcc_option = 0; break; case 'y': if( stricmp( Word, "x" ) == 0 ) { strcat( CC_Opts, " -x" ); wcc_option = 0; } else if( Word[0] == '\0' ) { wcc_option = 0; } break; #if defined( WCLI86 ) || defined( WCL386 ) case 'm': /* memory model */ if( Cmd[1] == 't' || Cmd[1] == 'T' ) { /* tiny model*/ Word[0] = 's'; /* change to small */ Flags.tiny_model = TRUE; } break; #endif case 'p': Flags.no_link = TRUE; break; /* this is a preprocessor option */ case 'q': Flags.be_quiet = TRUE; break; case 'z': /* 12-jan-89 */ switch( tolower( Cmd[1] ) ) { case 's': Flags.no_link = TRUE; break; case 'q': Flags.be_quiet = TRUE; break; #ifdef WCLI86 case 'w': Flags.windows = TRUE; #endif } break; case '"': /* 17-dec-91 */ /* As parameter passing to linker is a special case, we need to pass * whole command instead of first character removed. This allows us * to parse also string literals in AddDirective. */ wcc_option = 0; strncpy( Word, Cmd, ++len ); Word[len] = '\0'; AddDirective( len ); break; } /* don't add linker-specific options */ /* to compiler command line: */ if( wcc_option ) { len = strlen( CC_Opts ); CC_Opts[len++] = ' '; CC_Opts[len++] = opt; CC_Opts[len++] = *Cmd; /* keep original case */ CC_Opts[len] = '\0'; strcat( CC_Opts, Word ); } } Cmd = end; } } return( 0 ); }