static int proc_args(int argc, char *argv[]) { unsigned short cnt, idle_time, tolerance; short length; /* check the function to test: if the first characters match, accept it */ if (strncmp(argv[1], "packet", strlen("packet")) == 0) { if (argc != 3) { printf( "test_packet: wrong no of arguments for test of test_packet \n"); return EXIT_FAILURE; } cnt = parse_ulong(argv[2], 10); printf("test:: packet(%d)\n", (unsigned short) cnt); if (cnt == ULONG_MAX || cnt < 1) return EXIT_FAILURE; test_packet(cnt); return EXIT_SUCCESS; } else if (strncmp(argv[1], "async", strlen("async")) == 0) { if (argc != 3) { printf( "test_async: wrong no of arguments for test of test_async() \n"); return EXIT_FAILURE; } idle_time = parse_ulong(argv[2], 10); printf("test:: async(%d)\n", (unsigned short) idle_time); if (idle_time == ULONG_MAX) return EXIT_FAILURE; test_async(idle_time); return EXIT_SUCCESS; } else if (strncmp(argv[1], "config", strlen("config")) == 0) { if (argc != 2) { printf( "test_config: wrong no of arguments for test of test_config() \n"); return EXIT_FAILURE; } printf("test:: config()\n"); test_config(); return EXIT_SUCCESS; } /*else if (strncmp(argv[1], "gesture", strlen("gesture")) == 0) { if (argc != 4) { printf( "test_gesture: wrong no of arguments for test of test_gesture() \n"); return EXIT_FAILURE; } length = parse_ulong(argv[2], 10); tolerance = parse_ulong(argv[3], 10); printf("test:: gesture(%d, %d)\n", (unsigned short) length, (unsigned short) tolerance); if (length == ULONG_MAX) return EXIT_FAILURE; if (tolerance == ULONG_MAX) return EXIT_FAILURE; test_gesture(length, tolerance); return EXIT_SUCCESS; }*/ }
static int proc_args(int argc, char *argv[]) { unsigned long cnt, idle_time, tolerance; long length; /* check the function to test: if the first characters match, accept it */ if (strncmp(argv[1], "packet", strlen("packet")) == 0) { if( argc != 3 ) { printf("mouse: wrong no of arguments for test of test_packet() \n"); return 1; } if( (cnt = parse_ulong(argv[2], 10)) == ULONG_MAX ) return 1; printf("mouse:: test_packet(%lu)\n", cnt); return test_packet(cnt); } else if (strncmp(argv[1], "async", strlen("async")) == 0) { if( argc != 3 ) { printf("mouse: wrong no of arguments for test_async() \n"); return 1; } if( (idle_time = parse_ulong(argv[2], 10)) == ULONG_MAX ) return 1; printf("mouse:: test_async(%lu)\n", idle_time); return test_async(idle_time); } else if (strncmp(argv[1], "config", strlen("config")) == 0) { if( argc != 2 ) { printf("mouse: wrong no of arguments for test_config() \n"); return 1; } printf("mouse:: test_config()\n"); return test_config(); } else if (strncmp(argv[1], "gesture", strlen("gesture")) == 0) { if( argc != 4 ) { printf("mouse: wrong no of arguments for test_gesture() \n"); return 1; } if( (length = parse_long(argv[2], 10)) == LONG_MAX ) return 1; if( (tolerance = parse_ulong(argv[3], 10)) == ULONG_MAX ) return 1; printf("mouse:: test_gesture(%ld, %lu)\n", length, tolerance); return test_gesture(length, tolerance); } else { printf("mouse: non valid function \"%s\" to test\n", argv[1]); return 1; } }
static int proc_args(int argc, char *argv[]) { unsigned short number, time, tolerance; short length; /* check the function to test: if the first characters match, accept it */ if (strncmp(argv[1], "test_packet", strlen("test_packet")) == 0) { if( argc != 3 ) { printf("Keyboard: wrong no of arguments for test of test_packet() \n"); return 1; } if((number = parse_ulong(argv[2], 10)) == ULONG_MAX) return 1; printf("Mouse:: test_packet(%u)\n\n", number); /* Actually, it was already invoked */ return test_packet(number); } else if (strncmp(argv[1], "test_async", strlen("test_async")) == 0) { if( argc != 3) { printf("Mouse: wrong no of arguments for test of test_async() \n"); return 1; } if((time = parse_ulong(argv[2], 10)) == ULONG_MAX) return 1; if(time <= 0) return 1; printf("Mouse:: test_async(%u)\n\n", time); return test_async(time); } else if (strncmp(argv[1], "test_config", strlen("test_config")) == 0) { if( argc != 2 ) { printf("Mouse: wrong no of arguments for test of test_config() \n"); return 1; } printf("Mouse:: test_config()\n\n"); return test_config(); } else if (strncmp(argv[1], "test_gesture", strlen("test_gesture")) == 0) { if( argc != 4 ) { printf("Mouse: wrong no of arguments for test of test_gesture() \n"); return 1; } if((length = parse_ulong(argv[2], 10)) == ULONG_MAX) return 1; if((tolerance = parse_ulong(argv[3], 10)) == ULONG_MAX) return 1; printf("Mouse:: test_gesture(%d, %u)\n\n", length, tolerance); return test_gesture(length, tolerance); } else { printf("Mouse: non valid function \"%s\" to test\n", argv[1]); return 1; } }
static int proc_args(int argc, char *argv[]) { unsigned short cnt, tolerance, i_time; short length = 0; /* check the function to test: if the first characters match, accept it */ if (strncmp(argv[1], "packet", strlen("packet")) == 0) { if( argc != 3 ) { printf("mouse: wrong no of arguments for test of test_packet() \n"); return 1; } if( (cnt = parse_ushort(argv[2], 10)) == USHRT_MAX ) return 1; printf("mouse: test_packet()\n"); test_packet(cnt); return 0; } else if (strncmp(argv[1], "async", strlen("async")) == 0) { if( argc != 3 ) { printf("mouse: wrong no of arguments for test of test_async() \n"); return 1; } if( (i_time = parse_ushort(argv[2], 10)) == USHRT_MAX ) return 1; printf("mouse: test_async()\n"); test_async(i_time); return 0; } else if (strncmp(argv[1], "config", strlen("config")) == 0) { if( argc != 2 ) { printf("mouse: wrong no of arguments for test of test_config() \n"); return 1; } printf("mouse: test_config\n"); test_config(); return 0; } else if (strncmp(argv[1], "gesture", strlen("gesture")) == 0) { if( argc != 4 ) { printf("mouse: wrong no of arguments for test of test_gesture() \n"); return 1; } length = parse_ushort(argv[2], 10); if( (tolerance = parse_ushort(argv[3], 10)) == USHRT_MAX ) return 1; printf("mouse: test_gesture()\n"); test_gesture(length, tolerance); return 0; } else { printf("mouse: non valid function \"%s\" to test\n", argv[1]); return 1; } }
static int proc_args(int argc, char *argv[]) { unsigned short number_packets, idle_time, length, tolerance; if (strncmp(argv[1], "packet", strlen("packet")) == 0) { if (argc != 3) { printf("mouse:: wrong no of arguments for test_packet() \n"); return 1; } number_packets = parse_ulong(argv[2], 10); printf("mouse:: packets()\n"); /* Actually, it was already invoked */ test_packet(number_packets); return 0; } else if (strncmp(argv[1], "async", strlen("async")) == 0) { if (argc != 3) { printf("mouse:: wrong no of arguments for test_async() \n"); return 1; } printf("mouse:: async()\n"); /* Actually, it was already invoked */ idle_time = parse_ulong(argv[2], 10); mouse_packet_async(idle_time); return 0; } else if (strncmp(argv[1], "config", strlen("config")) == 0) { if (argc != 2) { printf("mouse: wrong no of arguments for test of test_config() \n"); return 1; } printf("mouse:: config()\n"); /* Actually, it was already invoked */ test_config(); return 0; } else if (strncmp(argv[1], "gesture", strlen("gesture")) == 0) { if (argc != 4) { printf("mouse:: wrong no of arguments for test_gesture() \n"); return 1; } printf("mouse:: gesture()\n"); /* Actually, it was already invoked */ length = parse_ulong(argv[2], 10); tolerance = parse_ulong(argv[3], 10); mouse_gesture(length,tolerance); return 0; } }