1    | /*
2    |    ** $Log: ascii_to_ded.c,v $
3    |    ** Revision 1.4  2002/08/27 22:27:44  millis
4    |    ** Updated for automake/autoconf functionality
5    |    **
6    |    ** Revision 1.3  2002/05/14 23:44:46  miller
7    |    ** Added simple error checking for ded.txt on fopen()
8    |    **
9    |    ** Revision 1.2  2002/04/18 04:44:30  greg
10   |    ** Added the following commands:
11   |    ** - unstart
12   |    ** - set secret
13   |    ** - set [prflist|prfrand|prfboth]
14   |    **
15   |    ** Fixed Set Absence so that "to" is not case sensitive
16   |    **
17   |    ** Fixed Quiet games so that new players are announced
18   |    ** before the game starts
19   |    **
20   |    ** Fixed ascii_to_ded.c so thatit no longer generates an
21   |    ** error when compiled
22   |    **
23   |    ** Revision 1.1  2002/04/11 23:49:00  miller
24   |    ** First draft.
25   |    **
26   | 
27   |   */
28   | 
29   | #include <sys/types.h>
30   | #include <sys/stat.h>
31   | #include <stdio.h>
32   | #include <ctype.h>
33   | #include <fcntl.h>
34   | #include "config.h"
35   | #include "dip.h"
36   | 
37   | int write();
38   | int close();
39   | 
40   | struct dedication ded[MAXUSER];
41   | int main()
42   | {
43   |     FILE *ind;
44   |     int outd;
45   |     int i;
46   |     int nded;
47   | 
48   |    printf("Reading from ded.txt, "),
49   | 
50   |    ind = fopen("ded.txt", "r");
51   |    if (!ind) {
52   |      fprintf(stderr, "Error opening ded.txt\n");
53   |      return 1;
54   |    }
55   |   
56   |    fscanf(ind, "%d\n", &nded);
57   | 
58   |    printf("Converting %d records\n", nded);
59   | 
60   |     for (i = 0; i < nded; i++)
61   |     {
62   |        fscanf(ind, "%hd %hd %hd %ld %ld %ld\n", 
63   | 	&ded[i].r, &ded[i].i1, &ded[i].i2, 
64   | 	&ded[i].ls, &ded[i].md, &ded[i].d0);
65   | /*
66   | 	if (ded[i].r !=0)
67   | 		ded[i].r +=50;
68   | */
69   |     }
70   |     fclose(ind);
71   | 
72   |    printf("Writing to dip.oded.\n");
73   |    outd = open("dip.oded", O_RDWR | O_CREAT, 0666);
74   |    nded = write(outd, ded, nded * sizeof(ded[0]) );
75   |    close(outd);
76   | 
77   | 
78   |    printf("\nIf all is ok, copy dip.oded to replace dip.ded.\n\n");
79   |    return 0;
80   | }