#include #include #include #include int baud; FILE *fp; main(int argc,char *argv[]) { long delay; if (argc!=3) { fprintf(stderr,"\nUsage: slowrite \n\n"); exit(2); } baud=atoi(argv[1]); if ((fp=fopen(argv[2],"r"))==0) { perror(argv[2]); exit(3); } if (!baud) delay=baud; else delay=(100000/(long)baud); slowrite(fp,delay); } myusleep(long x) { struct timeval time; time.tv_sec= x/1000000L; time.tv_usec=x%1000000L; select(0, NULL, NULL, NULL, &time); } slowrite(FILE *fp,long delay) { int c; while ((read(fileno(fp),&c,sizeof(c)))>0) { myusleep(delay); write(1,&c,sizeof(int)); } }