|
Packit |
df99a1 |
//C- -*- C++ -*-
|
|
Packit |
df99a1 |
//C- -------------------------------------------------------------------
|
|
Packit |
df99a1 |
//C- DjVuLibre-3.5
|
|
Packit |
df99a1 |
//C- Copyright (c) 2002 Leon Bottou and Yann Le Cun.
|
|
Packit |
df99a1 |
//C- Copyright (c) 2001 AT&T
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- This software is subject to, and may be distributed under, the
|
|
Packit |
df99a1 |
//C- GNU General Public License, either Version 2 of the license,
|
|
Packit |
df99a1 |
//C- or (at your option) any later version. The license should have
|
|
Packit |
df99a1 |
//C- accompanied the software or you may obtain a copy of the license
|
|
Packit |
df99a1 |
//C- from the Free Software Foundation at http://www.fsf.org .
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- This program is distributed in the hope that it will be useful,
|
|
Packit |
df99a1 |
//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
df99a1 |
//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
df99a1 |
//C- GNU General Public License for more details.
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
|
|
Packit |
df99a1 |
//C- Lizardtech Software. Lizardtech Software has authorized us to
|
|
Packit |
df99a1 |
//C- replace the original DjVu(r) Reference Library notice by the following
|
|
Packit |
df99a1 |
//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- ------------------------------------------------------------------
|
|
Packit |
df99a1 |
//C- | DjVu (r) Reference Library (v. 3.5)
|
|
Packit |
df99a1 |
//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
|
|
Packit |
df99a1 |
//C- | The DjVu Reference Library is protected by U.S. Pat. No.
|
|
Packit |
df99a1 |
//C- | 6,058,214 and patents pending.
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | This software is subject to, and may be distributed under, the
|
|
Packit |
df99a1 |
//C- | GNU General Public License, either Version 2 of the license,
|
|
Packit |
df99a1 |
//C- | or (at your option) any later version. The license should have
|
|
Packit |
df99a1 |
//C- | accompanied the software or you may obtain a copy of the license
|
|
Packit |
df99a1 |
//C- | from the Free Software Foundation at http://www.fsf.org .
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | The computer code originally released by LizardTech under this
|
|
Packit |
df99a1 |
//C- | license and unmodified by other parties is deemed "the LIZARDTECH
|
|
Packit |
df99a1 |
//C- | ORIGINAL CODE." Subject to any third party intellectual property
|
|
Packit |
df99a1 |
//C- | claims, LizardTech grants recipient a worldwide, royalty-free,
|
|
Packit |
df99a1 |
//C- | non-exclusive license to make, use, sell, or otherwise dispose of
|
|
Packit |
df99a1 |
//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the
|
|
Packit |
df99a1 |
//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU
|
|
Packit |
df99a1 |
//C- | General Public License. This grant only confers the right to
|
|
Packit |
df99a1 |
//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to
|
|
Packit |
df99a1 |
//C- | the extent such infringement is reasonably necessary to enable
|
|
Packit |
df99a1 |
//C- | recipient to make, have made, practice, sell, or otherwise dispose
|
|
Packit |
df99a1 |
//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to
|
|
Packit |
df99a1 |
//C- | any greater extent that may be necessary to utilize further
|
|
Packit |
df99a1 |
//C- | modifications or combinations.
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
|
|
Packit |
df99a1 |
//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
Packit |
df99a1 |
//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
|
|
Packit |
df99a1 |
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
df99a1 |
//C- +------------------------------------------------------------------
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
df99a1 |
# include "config.h"
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
#if NEED_GNUG_PRAGMAS
|
|
Packit |
df99a1 |
# pragma implementation
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** @name djvuinfo
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
{\bf Synopsis}
|
|
Packit |
df99a1 |
\begin{verbatim}
|
|
Packit |
df99a1 |
djvudump <... iff_file_names ...>
|
|
Packit |
df99a1 |
\end{verbatim}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
{\bf Description} --- File #"djvudump.cpp"# uses the facilities
|
|
Packit |
df99a1 |
provided by \Ref{IFFByteStream.h} to display an indented
|
|
Packit |
df99a1 |
representation of the chunk structure of an ``EA IFF 85'' file.
|
|
Packit |
df99a1 |
Each line represent contains a chunk ID followed by the chunk
|
|
Packit |
df99a1 |
size. Additional information about the chunk is provided when
|
|
Packit |
df99a1 |
program #djvuinfo.cpp# recognizes the chunk name and knows how to
|
|
Packit |
df99a1 |
summarize the chunk data. Furthermore, page identifiers are
|
|
Packit |
df99a1 |
printed between curly braces when #djvudump# recognizes a bundled
|
|
Packit |
df99a1 |
multipage document. Lines are indented in order to reflect the
|
|
Packit |
df99a1 |
hierarchical structure of the IFF files.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
{\bf Example}
|
|
Packit |
df99a1 |
\begin{verbatim}
|
|
Packit |
df99a1 |
% djvuinfo graham1.djvu
|
|
Packit |
df99a1 |
graham1.djvu:
|
|
Packit |
df99a1 |
FORM:DJVU [32553]
|
|
Packit |
df99a1 |
INFO [5] 2325x3156, version 20, 300 dpi, gamma 2.2
|
|
Packit |
df99a1 |
ANTa [34] Page annotation
|
|
Packit |
df99a1 |
INCL [11] Indirection chunk (document.dir)
|
|
Packit |
df99a1 |
Sjbz [17692] JB2 data, no header
|
|
Packit |
df99a1 |
BG44 [2570] #1 - 74 slices - v1.2 (color) - 775x1052
|
|
Packit |
df99a1 |
FG44 [1035] #1 - 100 slices - v1.2 (color) - 194x263
|
|
Packit |
df99a1 |
BG44 [3048] #2 - 10 slices
|
|
Packit |
df99a1 |
BG44 [894] #3 - 4 slices
|
|
Packit |
df99a1 |
BG44 [7247] #4 - 9 slices
|
|
Packit |
df99a1 |
\end{verbatim}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
{\bf References} ---
|
|
Packit |
df99a1 |
EA IFF 85 file format specification:\\
|
|
Packit |
df99a1 |
\URL{http://www.cica.indiana.edu/graphics/image_specs/ilbm.format.txt}
|
|
Packit |
df99a1 |
or \URL{http://www.tnt.uni-hannover.de/soft/compgraph/fileformats/docs/iff.pre}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
@memo
|
|
Packit |
df99a1 |
Prints the structure of an IFF file.
|
|
Packit |
df99a1 |
xxx
|
|
Packit |
df99a1 |
@author
|
|
Packit |
df99a1 |
L\'eon Bottou <leonb@research.att.com>
|
|
Packit |
df99a1 |
*/
|
|
Packit |
df99a1 |
//@{
|
|
Packit |
df99a1 |
//@}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#include "DjVuDumpHelper.h"
|
|
Packit |
df99a1 |
#include "ByteStream.h"
|
|
Packit |
df99a1 |
#include "GException.h"
|
|
Packit |
df99a1 |
#include "GOS.h"
|
|
Packit |
df99a1 |
#include "GString.h"
|
|
Packit |
df99a1 |
#include "GURL.h"
|
|
Packit |
df99a1 |
#include "DjVuMessage.h"
|
|
Packit |
df99a1 |
#include "common.h"
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
const char *outputfile = 0;
|
|
Packit |
df99a1 |
FILE *outputf = stdout;
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
void
|
|
Packit |
df99a1 |
display(const GURL &url)
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
DjVuDumpHelper helper;
|
|
Packit |
df99a1 |
GP<ByteStream> ibs = ByteStream::create(url, "rb");
|
|
Packit |
df99a1 |
GP<ByteStream> obs = helper.dump(ibs);
|
|
Packit |
df99a1 |
GUTF8String str;
|
|
Packit |
df99a1 |
size_t size = obs->size();
|
|
Packit |
df99a1 |
char *buf = str.getbuf(obs->size());
|
|
Packit |
df99a1 |
obs->seek(0);
|
|
Packit |
df99a1 |
obs->readall(buf, size);
|
|
Packit |
df99a1 |
GNativeString ns = str;
|
|
Packit |
df99a1 |
fputs((const char*)ns, outputf);
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
void
|
|
Packit |
df99a1 |
usage()
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
DjVuPrintErrorUTF8(
|
|
Packit |
df99a1 |
#ifdef DJVULIBRE_VERSION
|
|
Packit |
df99a1 |
"DJVUDUMP --- DjVuLibre-" DJVULIBRE_VERSION "\n"
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
"Describes DjVu and IFF85 files\n\n"
|
|
Packit |
df99a1 |
"Usage: djvudump [-o outputfile] <iff_filenames>\n" );
|
|
Packit |
df99a1 |
exit(1);
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
int
|
|
Packit |
df99a1 |
main(int argc, char **argv)
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
DJVU_LOCALE;
|
|
Packit |
df99a1 |
// get output file name
|
|
Packit |
df99a1 |
if (argc>2 && !strcmp(argv[1],"-o"))
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
outputfile = argv[2];
|
|
Packit |
df99a1 |
argv += 2;
|
|
Packit |
df99a1 |
argc -= 2;
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
// convert iff file name
|
|
Packit |
df99a1 |
GArray<GUTF8String> dargv(0, argc-1);
|
|
Packit |
df99a1 |
for(int i=0;i
|
|
Packit |
df99a1 |
dargv[i]=GNativeString(argv[i]);
|
|
Packit |
df99a1 |
if (argc <= 1)
|
|
Packit |
df99a1 |
usage();
|
|
Packit |
df99a1 |
if (outputfile && !(outputf = fopen(outputfile,"w")))
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
DjVuPrintErrorUTF8("djvudump: Cannot open output file.\n");
|
|
Packit |
df99a1 |
exit(1);
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
G_TRY
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
for (int i=1; i
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
const GURL::Filename::UTF8 url(dargv[i]);
|
|
Packit |
df99a1 |
display(url);
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
G_CATCH(ex)
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
ex.perror();
|
|
Packit |
df99a1 |
exit(1);
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
G_ENDCATCH;
|
|
Packit |
df99a1 |
return 0;
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
|