void check_for_shared_dict(GArray<GUTF8String> &argv) { const int argc=argv.hbound()+1; for (int i=2; i<argc; i++) if (!argv[i].cmp("INCL=",5)) analyze_incl_chunk(GURL::Filename::UTF8(5+(const char *)argv[i])); else if (!argv[i].cmp("Djbz=", 5)) analyze_djbz_chunk(GURL::Filename::UTF8(5+(const char *)argv[i])); }
void create_info_chunk(IFFByteStream &iff, GArray<GUTF8String> &argv) { const int argc=argv.hbound()+1; // Process info specification for (int i=2; i<argc; i++) if (!argv[i].cmp("INFO=",5)) { int narg = 0; const char *ptr = 5+(const char *)argv[i]; while (*ptr) { if (*ptr != ',') { int x = strtol((char *)ptr, (char **)&ptr, 10); switch(narg) { case 0: w = x; break; case 1: h = x; break; case 2: dpi = x; break; default: G_THROW("djvumake: incorrect 'INFO' chunk specification\n"); } } narg++; if (*ptr && *ptr++!=',') G_THROW("djvumake: comma expected in 'INFO' chunk specification\n"); } break; } if (w>0 && (w<=0 || w>=32768)) G_THROW("djvumake: incorrect width in 'INFO' chunk specification\n"); if (h>0 && (h<=0 || h>=32768)) G_THROW("djvumake: incorrect height in 'INFO' chunk specification\n"); if (dpi>0 && (dpi<25 || dpi>6000)) G_THROW("djvumake: incorrect dpi in 'INFO' chunk specification\n"); // Search first mask chunks if size is still unknown if (h<0 || w<0) { for (int i=2; i<argc; i++) if (!argv[i].cmp("Sjbz=",5)) { analyze_jb2_chunk(GURL::Filename::UTF8(5+(const char *)argv[i])); break; } else if (!argv[i].cmp("Smmr=",5)) { analyze_mmr_chunk(GURL::Filename::UTF8(5+(const char *)argv[i])); break; } } // Check that we have everything if (w<0 || h<0) G_THROW("djvumake: cannot determine image size\n"); // write info chunk GP<DjVuInfo> ginfo=DjVuInfo::create(); DjVuInfo &info=*ginfo; info.width = w; info.height = h; info.dpi = dpi; iff.put_chunk("INFO"); info.encode(*iff.get_bytestream()); iff.close_chunk(); }