예제 #1
0
파일: test-log.c 프로젝트: yygcode/ycc
int main()
{
	if (gl_open("/tmp/tests/common/test-log.log", 1, LOG_DEBUG)) {
		pr_err("LOG_OPEN failed");
		return 1;
	}

	gl_write(LOG_DEBUG, "This is first log, write by %s", "yanyg");
	gl_write(LOG_INFO, "This is first log, write by %s", "yanyg");
	gl_write(LOG_NOTICE, "This is first log, write by %s", "yanyg");
	gl_write(LOG_WARNING, "This is first log, write by %s", "yanyg");
	gl_write(LOG_ERR, "This is first log, write by %s", "yanyg");
	gl_write(LOG_CRIT, "This is first log, write by %s", "yanyg");
	gl_write(LOG_ALERT, "This is first log, write by %s", "yanyg");
	gl_write(LOG_EMERG, "This is first log, write by %s", "yanyg");
	gl_write(10, "This is first log, write by %s", "yanyg");

	struct log_info *log;
	
	log = log_open("/tmp/tests/common/test-yyg.log", 0, LOG_NOTICE);
	if (!log) {
		DBG_PE("log_open failed");
		return 1;
	}

	log_write(log, LOG_INFO, "This is yyg log %d", 1000);
	log_write(log, LOG_NOTICE, "This is yyg log %d", 1000);
	log_write(log, LOG_WARNING, "This is yyg log %d", 1000);

	log_close(log);

	log_write(log, LOG_INFO, "This is yyg log %d", 1000);
	log_write(log, LOG_NOTICE, "This is yyg log %d", 1000);
	log_write(log, LOG_WARNING, "This is yyg log %d", 1000);

	log = log_open("tmp/test/common/test-yyg.log", 1, LOG_WARNING);
	if (!log) {
		DBG_PE("log_open failed");
		return 1;
	}

	log_write(log, LOG_INFO, "This is yyg log %d", 2000);
	log_write(log, LOG_NOTICE, "This is yyg log %d", 2000);
	log_write(log, LOG_WARNING, "This is yyg log %d", 2000);

	log_close(log);

	log_write(log, LOG_INFO, "This is yyg log %d", 2000);
	log_write(log, LOG_NOTICE, "This is yyg log %d", 2000);
	log_write(log, LOG_WARNING, "This is yyg log %d", 2000);

	DBG_PR("success");
	return 0;
}
예제 #2
0
파일: test-0137.c 프로젝트: Orwel/forester
int main()
{
    gl_read();
    gl_write();
    __VERIFIER_plot(NULL);

    gl_sort();
    gl_write();
    __VERIFIER_plot(NULL);

    gl_destroy();
    __VERIFIER_plot(NULL);

    return 0;
}
/* read data from fd. Write string if '\n' encountered */
void process_input(int fd)
{
    static char textbuf[80], *data = textbuf;
    char inbuf[80];
    int len, i;

    len = read(fd, inbuf, 80);
    if (len <= 0)
	return;
    for (i = 0; i < len; i++) {
	if (inbuf[i] == '\n') {
	    *data = 0;
	    gl_write(0, 10, textbuf);
	    ping();
	    data = textbuf;
	} else {
	    *data++ = inbuf[i];
	}
    }
}
예제 #4
0
int main(int argc, char **argv)
{
	int fd;
	__u32 mode;
	lirc_t data;
	lirc_t x1, y1, x2, y2;
	int result;
	int c = 10;
	char textbuffer[80];
	int div = 5;
	char *device = LIRC_DRIVER_DEVICE;
	char *progname;
	struct stat s;

	progname = "smode2";
	while (1) {
		int c;
		static struct option long_options[] = {
			{"help", no_argument, NULL, 'h'},
			{"version", no_argument, NULL, 'v'},
			{"device", required_argument, NULL, 'd'},
			{"timediv", required_argument, NULL, 't'},
			{0, 0, 0, 0}
		};
		c = getopt_long(argc, argv, "hvd:t:", long_options, NULL);
		if (c == -1)
			break;
		switch (c) {
		case 'h':
			printf("Usage: %s [options]\n", progname);
			printf("\t -h --help\t\tdisplay usage summary\n");
			printf("\t -v --version\t\tdisplay version\n");
			printf("\t -d --device=device\tread from given device\n");
			printf("\t -t --timediv=value\tms per unit\n");
			return (EXIT_SUCCESS);
		case 'v':
			printf("%s %s\n", progname, VERSION);
			return (EXIT_SUCCESS);
		case 'd':
			device = optarg;
			break;
		case 't':	/* timediv */
			div = strtol(optarg, NULL, 10);
			break;
		default:
			printf("Usage: %s [options]\n", progname);
			return (EXIT_FAILURE);
		}
	}
	if (optind < argc - 1) {
		fprintf(stderr, "%s: too many arguments\n", progname);
		return (EXIT_FAILURE);
	}

	fd = open(device, O_RDONLY);
	if (fd == -1) {
		perror(progname);
		fprintf(stderr, "%s: error opening %s\n", progname, device);
		exit(EXIT_FAILURE);
	};
	if ((fstat(fd, &s) != -1) && (S_ISFIFO(s.st_mode))) {
		/* can't do ioctls on a pipe */
	} else if (ioctl(fd, LIRC_GET_REC_MODE, &mode) == -1 || mode != LIRC_MODE_MODE2) {
		printf("This program is only intended for receivers supporting the pulse/space layer.\n");
		printf("Note that this is no error, but this program simply makes no sense for your\nreceiver.\n");
		printf("In order to test your setup run lircd with the "
		       "--nodaemon option and \n" "then check if the remote works with the irw tool.\n");
		close(fd);
		exit(EXIT_FAILURE);
	}

	initscreen();

	y1 = 20;
	x1 = x2 = 0;
	for (y2 = 0; y2 < 640; y2 += 20)
		gl_line(y2, 0, y2, 480, 1);
	sprintf(textbuffer, "%d ms/unit", div);
	gl_write(500, 10, textbuffer);
	gl_copyscreen(physicalscreen);

	while (1) {
		result = read(fd, &data, sizeof(data));
		if (result == sizeof(data)) {
//                  printf("%.8lx\t",(unsigned long) data);
			x2 = (data & PULSE_MASK) / (div * 50);
			if (x2 > 400) {
				y1 += 15;
				x1 = 0;
				gl_copyscreen(physicalscreen);
			} else {
				if (x1 < 640) {
					gl_line(x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1 + x2,
						((data & PULSE_BIT) ? y1 : y1 + 10), c);
					x1 += x2;
					gl_line(x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1,
						((data & PULSE_BIT) ? y1 + 10 : y1), c);
				}
			}
			if (y1 > 480) {
				y1 = 20;
				gl_clearscreen(0);
				for (y2 = 0; y2 < 640; y2 += 10)
					gl_line(y2, 0, y2, 480, 1);
				gl_write(500, 10, textbuffer);
			}
		}
//              gl_copyscreen(physicalscreen);
	};
	closescreen();
	exit(EXIT_SUCCESS);
}