#include #include #include #include #define ROWSIZE 256 FILE *infile; int width, height, j, k, ccount, mcount, anum, dnum; int apos, dpos; char inbuf[ROWSIZE]; /* Here is a lazy programmer's waste of space. */ char aspace[ROWSIZE][ROWSIZE]; char dspace[ROWSIZE][ROWSIZE]; char rowtext[10*ROWSIZE]; char tmp[ROWSIZE]; char title[80]; char author[80]; char copyright[80]; char matrix[ROWSIZE*ROWSIZE*10]; char aclues[ROWSIZE*15*16]; char dclues[ROWSIZE*15*16]; void fgetaline(char *, FILE *); void main(int argc, char *argv[]) { /* Open the puzzle file. */ if (argc < 2) { printf("Usage: Acl2TeX \n"); exit(1); } infile = fopen(argv[1], "rb"); if (infile == NULL) { printf("Error opening %s.\n"); exit(1); } /* From here on we're assuming a non-corrupt puzzle file. An enhancement later could be to check for this. */ /* Read in the puzzle size, skipping the stuff we don't understand. */ fread(inbuf, 46, 1, infile); width = (int)(inbuf[44]); height = (int)(inbuf[45]); /* Read in the solution, assuming(!) it is not scrambled. This may be a bad idea but we do it anyhow. */ fread(inbuf, 6, 1, infile); /* more basura */ for (j=0; j=0 && dspace[j][k]=='-' && dspace[j][k-1]=='.' && dspace[j][k+1]=='-' ) ){ ccount++; anum = ccount; } /* Analyze position for down-number */ dnum = 0; /* Top row non-black followed by non-black */ if ( (j==0 && dspace[j][k]=='-' && dspace[j+1][k]=='-') || /* Black above - nonblack - nonblack below */ ( (j-1)>=0 && (j+1)