source: trunk/libdjvu/DjVuErrorList.cpp @ 15

Last change on this file since 15 was 15, checked in by Eugene Romanenko, 15 years ago

needed libs update

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