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
|
2023-05-05 18:05:20 +00:00
|
|
|
// Utility to convert *.icns file into app_icon.h file for use
|
2005-06-28 10:34:47 +00:00
|
|
|
// with api/setMacIcon() in science applications.
|
|
|
|
|
2017-02-27 14:37:48 +00:00
|
|
|
// THIS CODE IS OBSOLETE! A better way to add an icon to science applications
|
|
|
|
// (or any Mac executable, including command-line tools) is:
|
|
|
|
// [1] Select the application in the Finder
|
|
|
|
// [2] Get Info (command-I) for the selected application
|
|
|
|
// [3] Click on the file's current icon in the top left corner of the Get Info window
|
|
|
|
// [4] Paste (command-v) the desired icon.
|
|
|
|
//
|
|
|
|
// To copy an icon from a different file:
|
|
|
|
// [a] Get Info for the source file
|
|
|
|
// [b] Click on the file's icon in the top left corner of the Get Info window
|
|
|
|
// [c] Copy (command-c) the icon.
|
|
|
|
|
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;
|
|
|
|
}
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-06-28 10:34:47 +00:00
|
|
|
inFile = fopen(argv[1], "rb");
|
|
|
|
if (inFile == NULL) {
|
|
|
|
printf ("Couldn't open input file %s\n", argv[1]);
|
|
|
|
return 0;
|
|
|
|
}
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-06-28 10:34:47 +00:00
|
|
|
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;
|
|
|
|
}
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-06-28 10:34:47 +00:00
|
|
|
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;
|
|
|
|
}
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-06-28 10:34:47 +00:00
|
|
|
fprintf(outFile, "0X%02X", c);
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-06-28 10:34:47 +00:00
|
|
|
while ((c = getc(inFile)) != EOF) {
|
|
|
|
if (--count)
|
|
|
|
fputs(",", outFile);
|
|
|
|
else {
|
|
|
|
fputs(",\n\t", outFile);
|
|
|
|
count = 16;
|
|
|
|
}
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-06-28 10:34:47 +00:00
|
|
|
fprintf(outFile, "0X%02X", c);
|
|
|
|
}
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-06-28 10:34:47 +00:00
|
|
|
fputs("\n};\n", outFile);
|
|
|
|
fclose(inFile);
|
|
|
|
fclose(outFile);
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-06-28 10:34:47 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2023-05-05 18:05:20 +00:00
|
|
|
|