Example #1
0
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;
	}
}
Example #2
0
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;
	}
}
Example #3
0
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;
	}
}