/* This reads a an unsorted index file *.ind and writes a sorted, and converted *.sor index file File Names are specialized to the INRSTeX reference book ... DOS version uses strncmpi() */ #include #include #include #include #include #define NUL ((char)0) #define BSLASH ((char)0x5c) #define CR ((char)0x0d) #define LF ((char)0x0a) #define MAX 900 #define CS 20 #define SS 510 #define PL 8 /* type def */ typedef struct { char cmp_str[CS]; char *str; } ind; /* the variables */ FILE *outfile; /* out file. */ FILE *infile; /* input file */ char in_buf[512]; /* input buffer */ ind index[MAX]; char work[512]; int j, k, l, cp, in_len ; /* dummy vars */ int mem_over, op; /* Comparison Function */ int sortfcn(const void *a, const void *b) { return (strcmpi(a,b)); } /***** * The main function. input file name is masth.ind output is masth.sor ... for inrstex ref book *****/ void main() {printf("\n INRSTeX index massage and sort. \n Input file is 'masth.ind'. \n Output file is 'masth.sor'.\n"); infile = fopen( "masth.ind", "r"); if (infile==0) printf("\n Sorry ... I can't find the index file \n `masth.ind` \n"); else { outfile = fopen( "masth.sor", "w" ); j=0; while (j