home *** CD-ROM | disk | FTP | other *** search
-
- /* ptrdata version 1.00, Donald L. Wahl 2/13/88 */
- /* generate C data for SetPointer() from devs:system-configuration file */
- #include "intuition/intuition.h"
- #include "intuition/intuitionbase.h"
- #include "stdio.h"
-
- FILE *source, *destination; /* files */
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- struct Preferences prefs;
- char buffer[64];
- int c,calc,height,width;
- long size;
- if(argc != 3)
- {
- printf("Usage:\nptrdata devs:system-configuration datafile\n");
- exit(0);
- }
-
- if((source = fopen(argv[1], "r"))== NULL)
- {
- printf("Can't open %s\n",argv[1]);
- exit(0);
- }
- /* check that file is correct size for prefs */
- fseek(source,0l,2);
- size = ftell(source);
- if(size != sizeof(struct Preferences))
- {
- printf("File %s is not a preferences file\n",argv[1]);
- fclose(source);
- exit(0);
- }
- fseek(source,0l,0);
- fread((char *)&prefs,(sizeof(struct Preferences)),1,source);
- fclose(source);
- if((destination = fopen(argv[2], "w"))== NULL)
- {
- printf("Can't open %s\n",argv[2]);
- exit(0);
- }
- width = height = calc = 0;
- c = 33;
- while(c > 0) /* get height */
- {
- if((prefs.PointerMatrix[c] || prefs.PointerMatrix[c - 1]) && !height)
- {
- height = (c - 1) / 2;
- }
- calc |= prefs.PointerMatrix[c];
- calc |= prefs.PointerMatrix[c - 1];
- c -= 2;
- }
- c = 16;
- while(c > 0) /* get width (but it don't care ??) */
- {
- if(calc & 1)
- {
- break;
- }
- calc = calc >> 1;
- c--;
- }
- width = c;
- sprintf(buffer,"#define PTR_WIDTH %dl\n",width);
- fputs(buffer,destination);
- sprintf(buffer,"#define PTR_HEIGHT %dl\n",height);
- fputs(buffer,destination);
- sprintf(buffer,"#define PTR_XOFFSET %dl\n",prefs.XOffset);
- fputs(buffer,destination);
- sprintf(buffer,"#define PTR_YOFFSET %dl\n",prefs.YOffset);
- fputs(buffer,destination);
- fputs("\n\nUSHORT ptrdata[] = \n{\n",destination);
- for(c = 0;c < POINTERSIZE;c += 2)
- {
- sprintf(buffer,"0x%04.4x, 0x%04.4x,\n",prefs.PointerMatrix[c],prefs.PointerMatrix[c + 1]);
- fputs(buffer,destination);
- }
- fputs("};\n",destination);
- fclose(destination);
-
- }
-