~ubuntu-branches/debian/squeeze/djvulibre/squeeze

« back to all changes in this revision

Viewing changes to xmltools/djvuxmlparser.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barak A. Pearlmutter
  • Date: 2004-11-01 16:49:49 UTC
  • Revision ID: james.westby@ubuntu.com-20041101164949-fm4bl2hmkvkseoqw
Tags: upstream-3.5.14
ImportĀ upstreamĀ versionĀ 3.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//C-  -*- C++ -*-
 
2
//C- -------------------------------------------------------------------
 
3
//C- Xmltools for DjVu3 and DjVuLibre-3.5
 
4
//C- Copyright (c) 2002  Bill C. Riemers
 
5
//C- -------------------------------------------------------------------
 
6
//C- This software is subject to, and may be distributed under, the
 
7
//C- GNU General Public License, Version 2. The license should have
 
8
//C- accompanied the software or you may obtain a copy of the license
 
9
//C- from the Free Software Foundation at http://www.fsf.org .
 
10
//C-
 
11
//C- This program is distributed in the hope that it will be useful,
 
12
//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//C- GNU General Public License for more details.
 
15
//C- 
 
16
//C- I, Bill C. Riemers, hereby grant all rights to this code,
 
17
//C- provided usage complies with the GPL or a written exception to 
 
18
//C- the GPL granted by any of Bill C. Riemers, Leon Bottou, 
 
19
//C- Yann Le Cun, or the Free Source Foundation.
 
20
//C-
 
21
//C- ------------------------------------------------------------------
 
22
//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library
 
23
//C- distributed by Lizardtech Software.  On July 19th 2002, Lizardtech 
 
24
//C- Software authorized us to replace the original DjVu(r) Reference 
 
25
//C- Library notice by the following text (see doc/lizard2002.djvu):
 
26
//C-
 
27
//C-  ------------------------------------------------------------------
 
28
//C- | DjVu (r) Reference Library (v. 3.5)
 
29
//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
 
30
//C- | The DjVu Reference Library is protected by U.S. Pat. No.
 
31
//C- | 6,058,214 and patents pending.
 
32
//C- |
 
33
//C- | This software is subject to, and may be distributed under, the
 
34
//C- | GNU General Public License, Version 2. The license should have
 
35
//C- | accompanied the software or you may obtain a copy of the license
 
36
//C- | from the Free Software Foundation at http://www.fsf.org .
 
37
//C- |
 
38
//C- | The computer code originally released by LizardTech under this
 
39
//C- | license and unmodified by other parties is deemed "the LIZARDTECH
 
40
//C- | ORIGINAL CODE."  Subject to any third party intellectual property
 
41
//C- | claims, LizardTech grants recipient a worldwide, royalty-free, 
 
42
//C- | non-exclusive license to make, use, sell, or otherwise dispose of 
 
43
//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 
 
44
//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 
 
45
//C- | General Public License.   This grant only confers the right to 
 
46
//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 
 
47
//C- | the extent such infringement is reasonably necessary to enable 
 
48
//C- | recipient to make, have made, practice, sell, or otherwise dispose 
 
49
//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 
 
50
//C- | any greater extent that may be necessary to utilize further 
 
51
//C- | modifications or combinations.
 
52
//C- |
 
53
//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
 
54
//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 
55
//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
 
56
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
 
57
//C- +------------------------------------------------------------------
 
58
// 
 
59
// $Id: djvuxmlparser.cpp,v 1.7 2003/11/07 22:08:23 leonb Exp $
 
60
// $Name: release_3_5_14 $
 
61
 
 
62
#ifdef HAVE_CONFIG_H
 
63
# include "config.h"
 
64
#endif
 
65
#if NEED_GNUG_PRAGMAS
 
66
# pragma implementation
 
67
#endif
 
68
 
 
69
#include "XMLParser.h"
 
70
#include "XMLTags.h"
 
71
#include "GOS.h"
 
72
#include "GURL.h"
 
73
#include "DjVuDocument.h"
 
74
#include "ByteStream.h"
 
75
#include "DjVuMessage.h"
 
76
#include <stdio.h>
 
77
#include <ctype.h>
 
78
#include <locale.h>
 
79
#include <stdlib.h>
 
80
 
 
81
int 
 
82
main(int argc,char *argv[],char *[])
 
83
{
 
84
  setlocale(LC_ALL,"");
 
85
  djvu_programname(argv[0]);
 
86
  GArray<GUTF8String> dargv(0,argc-1);
 
87
  for(int i=0;i<argc;++i)
 
88
    dargv[i]=GNativeString(argv[i]);
 
89
  G_TRY
 
90
  {
 
91
    bool is_valid=(argc >= 2);
 
92
    if((is_valid=(argc>=2)))
 
93
    {
 
94
      int i=1;
 
95
      do {
 
96
        if(! GURL::Filename::Native(argv[i]).is_file())
 
97
        {
 
98
          is_valid=false;
 
99
          DjVuPrintErrorUTF8("Error: File '%s' does not exist.\n",argv[i]);
 
100
          exit(1);
 
101
        }
 
102
      } while (++i<argc);
 
103
    }
 
104
    if(! is_valid)
 
105
    {
 
106
      DjVuPrintErrorUTF8("Usage: %s <inputfiles>\n",argc?argv[0]:"-");
 
107
      exit(1);
 
108
    }
 
109
 
 
110
    for(int i=1;i<argc;++i)
 
111
    {
 
112
      const GP<lt_XMLParser> parser(lt_XMLParser::create());
 
113
      {
 
114
        const GP<lt_XMLTags> tag(
 
115
          lt_XMLTags::create(GURL::Filename::Native(dargv[i])));
 
116
        parser->parse(*tag);
 
117
      }
 
118
      parser->save();
 
119
    }
 
120
  }
 
121
  G_CATCH(ex)
 
122
  {
 
123
    ex.perror();
 
124
    exit(1);
 
125
  }
 
126
  G_ENDCATCH;
 
127
  exit(0);
 
128
#ifdef WIN32
 
129
  return 0;
 
130
#endif
 
131
}
 
132