source: trunk/libdjvu/DjVuErrorList.cpp @ 280

Last change on this file since 280 was 280, checked in by rbri, 11 years ago

DJVU plugin: djvulibre updated to version 3.5.22

File size: 5.2 KB
Line 
1//C-  -*- C++ -*-
2//C- -------------------------------------------------------------------
3//C- DjVuLibre-3.5
4//C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
5//C- Copyright (c) 2001  AT&T
6//C-
7//C- This software is subject to, and may be distributed under, the
8//C- GNU General Public License, either Version 2 of the license,
9//C- or (at your option) any later version. The license should have
10//C- accompanied the software or you may obtain a copy of the license
11//C- from the Free Software Foundation at http://www.fsf.org .
12//C-
13//C- This program is distributed in the hope that it will be useful,
14//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
15//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16//C- GNU General Public License for more details.
17//C-
18//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
19//C- Lizardtech Software.  Lizardtech Software has authorized us to
20//C- replace the original DjVu(r) Reference Library notice by the following
21//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
22//C-
23//C-  ------------------------------------------------------------------
24//C- | DjVu (r) Reference Library (v. 3.5)
25//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
26//C- | The DjVu Reference Library is protected by U.S. Pat. No.
27//C- | 6,058,214 and patents pending.
28//C- |
29//C- | This software is subject to, and may be distributed under, the
30//C- | GNU General Public License, either Version 2 of the license,
31//C- | or (at your option) any later version. The license should have
32//C- | accompanied the software or you may obtain a copy of the license
33//C- | from the Free Software Foundation at http://www.fsf.org .
34//C- |
35//C- | The computer code originally released by LizardTech under this
36//C- | license and unmodified by other parties is deemed "the LIZARDTECH
37//C- | ORIGINAL CODE."  Subject to any third party intellectual property
38//C- | claims, LizardTech grants recipient a worldwide, royalty-free,
39//C- | non-exclusive license to make, use, sell, or otherwise dispose of
40//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the
41//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU
42//C- | General Public License.   This grant only confers the right to
43//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to
44//C- | the extent such infringement is reasonably necessary to enable
45//C- | recipient to make, have made, practice, sell, or otherwise dispose
46//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to
47//C- | any greater extent that may be necessary to utilize further
48//C- | modifications or combinations.
49//C- |
50//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
51//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
52//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
53//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
54//C- +------------------------------------------------------------------
55//
56// $Id: DjVuErrorList.cpp,v 1.9 2007/03/25 20:48:30 leonb Exp $
57// $Name: release_3_5_22 $
58
59#ifdef HAVE_CONFIG_H
60# include "config.h"
61#endif
62#if NEED_GNUG_PRAGMAS
63# pragma implementation
64#endif
65
66#include "DjVuErrorList.h"
67#include "DjVmDoc.h"
68#include "GException.h"
69#include "GContainer.h"
70#include "GOS.h"
71#include "DataPool.h"
72#include <string.h>
73
74
75#ifdef HAVE_NAMESPACES
76namespace DJVU {
77# ifdef NOT_DEFINED // Just to fool emacs c++ mode
78}
79#endif
80#endif
81
82
83DjVuErrorList::DjVuErrorList() {}
84
85GURL
86DjVuErrorList::set_stream(GP<ByteStream> xibs)
87{
88  GUTF8String name;
89  static unsigned long serial=0;
90  pool=DataPool::create(xibs);
91  name.format("data://%08lx/%08lx.djvu",
92    ++serial,(unsigned long)(size_t)((const ByteStream *)xibs));
93  pool_url=GURL::UTF8(name);
94  return pool_url;
95}
96
97bool
98DjVuErrorList::notify_error(const DjVuPort * source, const GUTF8String & msg)
99{
100  Errors.append(msg);
101  return 1;
102}
103
104bool
105DjVuErrorList::notify_status(const DjVuPort * source, const GUTF8String &msg)
106{
107  Status.append(msg);
108  return 1;
109} 
110
111GUTF8String
112DjVuErrorList::GetError(void)
113{
114  GUTF8String PrevError;
115  GPosition pos;
116  if((pos=Errors))
117  {
118    PrevError=Errors[pos];
119    Errors.del(pos);
120  }
121  return PrevError;
122}
123
124GUTF8String
125DjVuErrorList::GetStatus(void)
126{
127  GUTF8String PrevStatus;
128  GPosition pos;
129  if((pos=Status))
130  {
131    PrevStatus=Status[pos];
132    Status.del(pos);
133  }
134  return PrevStatus;
135}
136
137GP<DataPool>
138DjVuErrorList::request_data(const DjVuPort * source, const GURL & url)
139{
140   GP<DataPool> retval;
141   G_TRY
142   {
143     if (pool && url.protocol().downcase() == "data")
144     {
145       if(url == pool_url)
146       {
147         retval=pool;
148       }else if(url.base() == pool_url)
149       {
150         GUTF8String name=url.fname();
151         GP<DjVmDoc> doc=DjVmDoc::create();
152         GP<ByteStream> bs=pool->get_stream();
153         doc->read(*bs);
154         retval=doc->get_data(name);
155       }
156     }else if (url.is_local_file_url())
157     {
158//       GUTF8String fname=GOS::url_to_filename(url);
159//       if (GOS::basename(fname)=="-") fname="-";
160       retval=DataPool::create(url);
161     }
162   }
163   G_CATCH_ALL
164   {
165     retval=0;
166   } G_ENDCATCH;
167   return retval;
168}
169 
170
171#ifdef HAVE_NAMESPACES
172}
173# ifndef NOT_USING_DJVU_NAMESPACE
174using namespace DJVU;
175# endif
176#endif
Note: See TracBrowser for help on using the repository browser.