view mot931c/ptydump.c @ 186:e03aba49d5b4

leo-obj/tpudrv/tpudrv12.hints: literal pools and branches around them
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 15 Aug 2014 00:59:45 +0000
parents 9082f3991fe5
children
line wrap: on
line source

#include <sys/types.h>
#include <sys/file.h>
#include <stdio.h>
#include <stdlib.h>

main(argc, argv)
	char **argv;
{
	int fd;
	u_char buf[1024];
	int cc, i;

	if (argc != 2) {
		fprintf(stderr, "usage: %s pty\n", argv[0]);
		exit(1);
	}
	fd = open(argv[1], O_RDWR);
	if (fd < 0) {
		perror(argv[1]);
		exit(1);
	}
	for (;;) {
		cc = read(fd, buf, sizeof buf);
		if (cc < 0) {
			perror("read error");
			exit(1);
		}
		if (cc == 0) {
			fprintf(stderr, "read EOF\n");
			exit(1);
		}
		printf("read %d bytes:", cc);
		for (i = 0; i < cc; i++)
			printf(" %02X", buf[i]);
		putchar('\n');
	}
}