2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-06-28 10:34:47 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2005-06-28 10:34:47 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2005-06-28 10:34:47 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-06-28 10:34:47 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-06-28 10:34:47 +00:00
|
|
|
|
|
|
|
// make_app_icon_h.C
|
|
|
|
// Utility to convert *.icns file into app_icon.h file for use
|
|
|
|
// with api/setMacIcon() in science applications.
|
|
|
|
|
2005-11-21 18:34:44 +00:00
|
|
|
#include "config.h"
|
2009-02-26 00:23:23 +00:00
|
|
|
#include <cstdio>
|
2005-06-28 10:34:47 +00:00
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
int retval = 0;
|
|
|
|
FILE *inFile, *outFile;
|
|
|
|
int count, c;
|
|
|
|
|
|
|
|
if (argc < 3) {
|
|
|
|
puts ("usage: make_app_icon_h source_path dest_path\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inFile = fopen(argv[1], "rb");
|
|
|
|
if (inFile == NULL) {
|
|
|
|
printf ("Couldn't open input file %s\n", argv[1]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
outFile = fopen(argv[2], "w");
|
2012-06-10 05:38:34 +00:00
|
|
|
if (outFile == NULL) {
|
2005-06-28 10:34:47 +00:00
|
|
|
printf ("Couldn't create output file %s\n", argv[2]);
|
|
|
|
fclose(inFile);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs("char MacAppIconData[] = {\n\t", outFile);
|
|
|
|
count = 16;
|
|
|
|
c = getc(inFile);
|
|
|
|
if (c == EOF) {
|
|
|
|
printf ("No data in input file %s\n", argv[1]);
|
|
|
|
fclose(inFile);
|
|
|
|
fclose(outFile);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(outFile, "0X%02X", c);
|
|
|
|
|
|
|
|
while ((c = getc(inFile)) != EOF) {
|
|
|
|
if (--count)
|
|
|
|
fputs(",", outFile);
|
|
|
|
else {
|
|
|
|
fputs(",\n\t", outFile);
|
|
|
|
count = 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(outFile, "0X%02X", c);
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs("\n};\n", outFile);
|
|
|
|
fclose(inFile);
|
|
|
|
fclose(outFile);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|