2 static char *RCSid() { return RCSid("$Id: geticon.c,v 1.3 2004/07/01 17:10:10 broeker Exp $"); }
6 /* extract Borland ascii format icons from resource script */
7 /* and write as Microsoft binary format .ICO files */
8 /* Russell Lang 1992-12-20 */
15 /* HBB 980809: naming a variable 'inline' is a bad idea, these days. Too
16 * many compilers use it as a keyword... Changed to 'inputline' */
19 char inputline[MAXLINE+1];
20 char *tok1, *tok2, *tok3;
22 char iconname[MAXLINE+1];
32 return((int)(ch - '0'));
36 return((int)(ch - 'A' + 10));
45 fgets(inputline,MAXLINE,rcfile);
47 if (strncmp(inputline,"BEGIN",5)) {
48 fprintf(stderr,"Expecting BEGIN at line %d\n",line);
51 if ( (iconfile = fopen(iconname,"wb")) == (FILE *)NULL) {
52 fprintf(stderr,"Can't open ICON file %s\n",iconname);
55 fgets(inputline,MAXLINE,rcfile);
57 while (strncmp(inputline,"END",3) && !feof(rcfile)) {
58 for (p = inputline; *p && (*p==' ' || *p == '\t' || *p=='\''); p++);
59 while (isxdigit(*p)) {
65 fgets(inputline,MAXLINE,rcfile);
72 main(int argc, char *argv[])
74 if ((argc < 2) || (argc > 3)) {
75 fprintf(stderr,"Usage: geticon resource_file [icon_directory]\n");
78 if ( (rcfile = fopen(argv[1],"r")) == (FILE *)NULL) {
79 fprintf(stderr,"Can't open RC file\n");
83 while (fgets(inputline,MAXLINE,rcfile)) {
85 tok1 = strtok(inputline," \t\r\n");
86 tok2 = strtok(NULL," \t\r\n");
87 tok3 = strtok(NULL," \t\r\n");
88 if (tok2 && !strcmp(tok2,"ICON") && (tok3 == (char *)NULL)) {
91 strcpy(iconname,argv[2]);
92 strcat(iconname,"\\");
94 strcat(iconname,tok1);
95 strcat(iconname,".ico");
96 fprintf(stdout,"%s\n",iconname);