/* This program will take a series of hands in a file and make a postscript file to print them nicely and big */ #include main(argc,argv) int argc; char **argv; { char line[1000]; /* temp storage */ int hands; /* hand number */ char *ptr; /* to start looking */ char temp[100]; /* part of a line */ void nots(); int args[26]; int nflag,sflag,eflag,wflag; /* do I print this hand */ int box; /* draw a box? */ /* Initial stuff */ hands = 1; /* first */ nflag = 1; sflag = 1; eflag = 1; wflag = 1; box = 0; clparse(argc,argv,args); if (args['t'-'a'] != 0) {eflag = 0; wflag = 0;} if (args['s'-'a'] != 0) sflag = 0; if (args['n'-'a'] != 0) nflag = 0; if (args['e'-'a'] != 0) eflag = 0; if (args['w'-'a'] != 0) wflag = 0; if (args['b'-'a'] != 0) box = 1; printf("%%!Postscript file\n"); printf("306 396 translate\n"); printf("306 306 scale\n"); printf("1 306 div setlinewidth\n"); printf("/d {lineto} def\n"); printf("/m {moveto} def\n"); printf("/tim { /Times-Roman findfont 20 306 div scalefont setfont } def\n"); printf("/sym { /Symbol findfont 25 306 div scalefont setfont } def\n"); printf("%%\n"); /* for each hand */ for (;;) { if (gets(line) == (char *)0) /* hand */ { /* final stuff */ printf("stop\n"); exit(0); } /* north hand */ if (nflag == 1) { printf("%%! North\n"); printf("tim\n"); gets(line); /* North spades */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 .6 m\n"); printf("(%s) show\n",ptr); gets(line); /* North hearts */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 .53 m\n"); printf("(%s) show\n",ptr); gets(line); /* North diamonds */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 .46 m\n"); printf("(%s) show\n",ptr); gets(line); /* North clubss */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 .39 m\n"); printf("(%s) show\n",ptr); gets(line); /* North specials */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 .32 m\n"); printf("(%s) show\n",ptr); /* North suit symbols */ printf("sym\n"); printf("-.22 .6 m\n"); printf("(\\252) show\n"); printf("-.22 .53 m\n"); printf("(\\251) show\n"); printf("-.22 .46 m\n"); printf("(\\250) show\n"); printf("-.22 .39 m\n"); printf("(\\247) show\n"); } else {gets(line);gets(line);gets(line);gets(line);} /* West and East hands */ /* Spades */ gets(line); if (wflag == 1) { /* West */ printf("%%! West\n"); printf("tim\n"); ptr = strstr(line,":"); ptr += 2; nots(ptr); strcpy(temp,ptr); ptr = strstr(temp," "); *ptr = '\0'; printf("-.63 .23 m\n"); printf("(%s) show\n",temp); } if (eflag == 1) { /* East */ ptr = strstr(line,":"); ptr = strstr(ptr+1,":"); ptr += 2; nots(ptr); printf("tim\n"); printf(".4 .23 m\n"); printf("(%s) show\n",ptr); } /* Hearts */ gets(line); if (wflag == 1) { /* West */ ptr = strstr(line,":"); ptr += 2; nots(ptr); strcpy(temp,ptr); ptr = strstr(temp," "); *ptr = '\0'; printf("-.63 .16 m\n"); printf("(%s) show\n",temp); } /* East */ if (eflag == 1) { ptr = strstr(line,":"); ptr = strstr(ptr+1,":"); ptr += 2; nots(ptr); printf(".4 .16 m\n"); printf("(%s) show\n",ptr); } /* Diamonds */ gets(line); /* West */ if (wflag == 1) { ptr = strstr(line,":"); ptr += 2; nots(ptr); strcpy(temp,ptr); ptr = strstr(temp," "); *ptr = '\0'; printf("-.63 .09 m\n"); printf("(%s) show\n",temp); } /* East */ if (eflag == 1) { ptr = strstr(line,":"); ptr = strstr(ptr+1,":"); ptr += 2; nots(ptr); printf(".4 .09 m\n"); printf("(%s) show\n",ptr); } /* Clubs */ gets(line); /* West */ if (wflag == 1) { ptr = strstr(line,":"); ptr += 2; nots(ptr); strcpy(temp,ptr); ptr = strstr(temp," "); *ptr = '\0'; printf("-.63 .02 m\n"); printf("(%s) show\n",temp); } /* East */ if (eflag == 1) { ptr = strstr(line,":"); ptr = strstr(ptr+1,":"); ptr += 2; nots(ptr); printf(".4 .02 m\n"); printf("(%s) show\n",ptr); } /* specials */ gets(line); /* West */ if (wflag == 1) { ptr = strstr(line,":"); ptr += 2; nots(ptr); strcpy(temp,ptr); ptr = strstr(temp," "); *ptr = '\0'; printf("-.63 -.05 m\n"); printf("(%s) show\n",temp); } /* East */ if (eflag == 1) { ptr = strstr(line,":"); ptr = strstr(ptr+1,":"); ptr += 2; nots(ptr); printf(".4 -.05 m\n"); printf("(%s) show\n",ptr); } /* suit symbols */ /* West */ if (wflag == 1) { printf("sym\n"); printf("-.7 .23 m\n"); printf("(\\252) show\n"); printf("-.7 .16 m\n"); printf("(\\251) show\n"); printf("-.7 .09 m\n"); printf("(\\250) show\n"); printf("-.7 .02 m\n"); printf("(\\247) show\n"); } /* East */ if (eflag == 1) { printf("%%! East\n"); printf("sym\n"); printf(".33 .23 m\n"); printf("(\\252) show\n"); printf(".33 .16 m\n"); printf("(\\251) show\n"); printf(".33 .09 m\n"); printf("(\\250) show\n"); printf(".33 .02 m\n"); printf("(\\247) show\n"); } /* South */ if (sflag == 1) { printf("%%! South\n"); printf("tim\n"); gets(line); /* South spades */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 -.14 m\n"); printf("(%s) show\n",ptr); gets(line); /* South hearts */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 -.21 m\n"); printf("(%s) show\n",ptr); gets(line); /* South diamonds */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 -.28 m\n"); printf("(%s) show\n",ptr); gets(line); /* South clubs */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 -.35 m\n"); printf("(%s) show\n",ptr); gets(line); /* South specials */ ptr = strstr(line,":"); ptr += 2; nots(ptr); printf("-.15 -.42 m\n"); printf("(%s) show\n",ptr); /* South suit symbols */ printf("sym\n"); printf("-.22 -.14 m\n"); printf("(\\252) show\n"); printf("-.22 -.21 m\n"); printf("(\\251) show\n"); printf("-.22 -.28 m\n"); printf("(\\250) show\n"); printf("-.22 -.35 m\n"); printf("(\\247) show\n"); } else {gets(line);gets(line);gets(line);gets(line);} /* Text */ printf("%%! Text\n"); printf("tim\n"); printf("-.7 .8 m\n"); printf("(Hand %d) show\n",hands++); /* Box */ if (box) { printf(".05 -.06 translate\n"); printf("newpath\n"); printf(".1 .33 m\n"); printf("-.31 .33 d\n"); printf("-.31 .09 d\n"); printf(".1 .09 d\n"); printf(".1 .33 d\n"); printf("stroke\n"); printf("-.12 .26 m\n"); printf("(N) show\n"); printf("-.12 .12 m\n"); printf("(S) show\n"); printf("-.28 .19 m\n"); printf("(W) show\n"); printf(".03 .19 m\n"); printf("(E) show\n"); printf("-.05 .06 translate\n"); } /* end of page */ printf("%%\n"); printf("copypage\n"); printf("erasepage\n"); gets(line); /* remove blank line */ } } /* convert away 'T's */ void nots(string) { char *ptr; char temp[1000]; ptr = strstr(string,"T"); if (ptr == (char *) 0) return; strcpy(temp,ptr+1); *ptr = '1'; *(ptr+1) = '0'; strcpy(ptr+2,temp); return; }