14int main(
int argc,
char* argv[])
17 printf(
"IccFromXml built with IccProfLib Version " ICCPROFLIBVER ", IccLibXML Version " ICCLIBXMLVER "\n\nUsage: IccFromXml xml_file saved_profile_file {-noid -v{=[relax_ng_schema_file - optional]}}\n");
27 std::string szRelaxNGDir;
30 const char* szRelaxNGFileName =
"SampleIccRELAX.rng";
32 for (i=3; i<argc; i++) {
33 if (!
stricmp(argv[i],
"-noid")) {
36 else if (!strncmp(argv[i],
"-v", 2) || !strncmp(argv[i],
"-V", 2)) {
37 if (argv[i][2]==
'=') {
38 szRelaxNGDir = argv[i]+3;
41 std::string path = argv[0];
44 if (path !=
"IccFromXml.exe") {
45 path = path.substr(0,path.find_last_of(
"\\"));
49 if (path.substr(0,1) !=
"./"){
50 path = path.substr(0,path.find_last_of(
"//"));
55 path += szRelaxNGFileName;
57 FILE *f = fopen(path.c_str(),
"r");
68 if (!profile.
LoadXml(argv[1], szRelaxNGDir.c_str(), &reason)) {
69 printf(
"%s", reason.c_str());
73 printf(
"Unable to Parse '%s'\n", argv[1]);
77 std::string valid_report;
82 for (i=0; i<16; i++) {
83 if (profile.m_Header.profileID.ID8[i])
86 if (
SaveIccProfile(argv[2], &profile, bNoId ? icNeverWriteID : (i<16 ? icAlwaysWriteID : icVersionBasedID))) {
87 printf(
"Profile parsed and saved correctly\n");
90 printf(
"Unable to save profile as '%s'\n", argv[2]);
97 for (i=0; i<16; i++) {
98 if (profile.m_Header.profileID.ID8[i])
101 if (
SaveIccProfile(argv[2], &profile, bNoId ? icNeverWriteID : (i<16 ? icAlwaysWriteID : icVersionBasedID))) {
102 printf(
"Profile parsed. Profile is invalid, but saved correctly\n");
105 printf(
"Unable to save profile - profile is invalid!\n");
108 printf(
"%s", valid_report.c_str());