source: trunk/libdjvu/ddjvuapiw.h @ 199

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

needed libs update

File size: 45.9 KB
Line 
1/*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//C- */ 
54
55/* $Id: ddjvuapi.h,v 1.34 2005/10/31 16:44:10 leonb Exp $ */
56
57#ifndef DDJVUAPI_H
58#define DDJVUAPI_H
59
60#ifdef __cplusplus
61extern "C" { 
62#endif
63#if 0
64}
65#endif
66
67#include <stdlib.h>
68#include <stdio.h>
69
70#ifndef DDJVUAPI
71#define DDJVUAPI _System
72#endif
73#ifndef TRUE
74# define TRUE  (1)
75#endif
76#ifndef FALSE
77# define FALSE (0)
78#endif
79
80
81
82/* -------------------------------------------------- */
83/* DDJVU API                                          */
84/* -------------------------------------------------- */
85
86/* The DDJVU API provides for efficiently decoding and
87   displaying DjVu documents.  It provides for displaying
88   images without waiting for the complete DjVu data. Images
89   can be displayed as soon as sufficient data is
90   available. A higher quality image might later be
91   displayed when further data is available.  The DjVu
92   library achieves this using a complicated scheme
93   involving multiple threads. The DDJVU API hides this
94   complexity with a familiar event model.
95*/
96
97/* Compiler symbol DDJVUAPI_VERSION tracks
98   backward compatible additions to the DDJVU API.
99
100   Version   Change
101   -----------------------------
102     16    Addition of miniexp.h and related functions:
103              ddjvu_miniexp_release()
104              ddjvu_document_get_outline/pagetext/pageanno()
105              ddjvu_anno_get_XXX()
106     15    Addition of:
107              ddjvu_document_get_pageinfo()
108              ddjvu_document_print()
109     14    Initial version.
110*/
111
112#define DDJVUAPI_VERSION 16
113
114typedef struct ddjvu_context_s  ddjvu_context_t;
115typedef union  ddjvu_message_s  ddjvu_message_t;
116typedef struct ddjvu_job_s      ddjvu_job_t;
117typedef struct ddjvu_document_s ddjvu_document_t;
118typedef struct ddjvu_page_s     ddjvu_page_t;
119typedef struct ddjvu_format_s   ddjvu_format_t;
120
121
122/* GENERAL CONVENTIONS:
123
124   - all strings use locale encoding (unless specified otherwise).
125   - all filenames are unencoded byte strings,
126   - all errors are signaled with error event messages,
127   - all functions returning a pointer might return a null pointer.
128
129   HEADER:
130   Always use the following idiom to include this file.
131
132     #include <libdjvu/ddjvuapi.h>
133     #include <libdjvu/miniexp.h>
134
135   This file does not declare functions ddjvu_get_DjVuImage()
136   and djvu_get_DjVuDocument() unless you include files
137   "DjVuImage.h" and "DjVuDocument.h" before this file.
138
139   PREREQUISITES:
140   - Please read the djvu man page: <"tools/djvu.1">.
141   - Please browse the file format specifications
142     <"doc/djvu3changes.txt"> and <"doc/djvu2spec.djvu">.
143*/
144
145 
146
147/* -------------------------------------------------- */
148/* DDJVU_CONTEXT_T                                    */
149/* -------------------------------------------------- */
150
151/* There is usually only one <ddjvu_context_t> object. 
152   This object holds global data structures such as the
153   cache of decoded pages, or the list of pending
154   event messages.
155 */
156
157
158/* ddjvu_context_create ---
159   Creates a <ddjvu_context_t> object.
160   Argument <programname> is the name of the calling executable. */
161
162ddjvu_context_t * DDJVUAPI ddjvu_context_create(const char *programname);
163
164
165/* ddjvu_context_release ---
166   Release a reference to a <ddjvu_context_t> object.
167   The calling program should no longer reference this object.
168   The object itself will be destroyed as soon as no other object
169   or thread needs it. */
170
171void DDJVUAPI ddjvu_context_release(ddjvu_context_t *context);
172
173
174
175/* ------- CACHE ------- */
176
177/* ddjvu_cache_set_size ---
178   Sets the maximum size of the cache of decoded page data.
179   The argument is expressed in bytes. */
180
181void DDJVUAPI ddjvu_cache_set_size(ddjvu_context_t *context,
182                     unsigned long cachesize);
183
184
185/* ddjvu_cache_get_size ---
186   Returns the maximum size of the cache. */
187
188unsigned long DDJVUAPI ddjvu_cache_get_size(ddjvu_context_t *context);
189
190
191/* ddjvu_cache_clear ---
192   Clears all cached data. */
193
194void DDJVUAPI ddjvu_cache_clear(ddjvu_context_t *context);
195
196
197
198/* ------- MESSAGE QUEUE ------- */
199
200/* Messages produced by the ddjvu api accumulate into
201   the message queue. Processing messages is not optional!
202   A typical message handling routine looks like this:
203   
204   void handle_ddjvu_messages(ddjvu_context_t *ctx, int wait)
205   {
206     const ddjvu_message_t *msg;
207     if (wait)
208       ddjvu_message_wait(ctx);
209     while ((msg = ddjvu_message_peek(ctx)))
210     {
211       switch(msg->m_any.tag)
212       {
213       case DDJVU_ERROR:      .... ; break;
214       case DDJVU_INFO:       .... ; break;
215       case DDJVU_NEWSTREAM:  .... ; break;
216       ....
217       default: break;
218       }
219       ddjvu_message_pop(ctx);
220     }
221   }
222*/
223
224
225/* ddjvu_message_peek ---
226   Returns a pointer to the next DDJVU message.
227   This function returns 0 if no message is available.
228   It does not remove the message from the queue. */
229
230ddjvu_message_t * DDJVUAPI ddjvu_message_peek(ddjvu_context_t *context);
231
232
233/* ddjvu_message_wait ---
234   Returns a pointer to the next DDJVU message.
235   This function waits until a message is available.
236   It does not remove the message from the queue. */
237
238ddjvu_message_t * DDJVUAPI ddjvu_message_wait(ddjvu_context_t *context);
239
240
241/* ddjvu_message_pop ---
242   Removes one message from the queue.
243   This function must be called after processing the message.
244   Pointers returned by previous calls to <ddjvu_message_peek>
245   or <ddjvu_message_wait> are no longer valid after
246   calling <ddjvu_message_pop>. */
247
248void DDJVUAPI ddjvu_message_pop(ddjvu_context_t *context);
249
250
251/* ddjvu_message_set_callback ---
252   Defines a callback function invoked whenever
253   a new message is posted to the ddjvuapi message queue,
254   and returns a pointer to the previous callback function.
255   This callback function can be called at any time
256   while other code is executing. Do not call ddjvuapi
257   functions from this callback. It should simply signal
258   the main application event loop that new ddjvuapi messages
259   are available.  Under WIN32, this is usually achieved
260   by posting a user window message.  Under UNIX, this is
261   usually achieved using a pipe: the callback writes
262   a single byte into the pipe; the main application loop
263   monitors the reading end of the pipe and detects
264   the presence of data. */
265
266typedef void 
267(*ddjvu_message_callback_t)(ddjvu_context_t *context, void *closure);
268
269void DDJVUAPI ddjvu_message_set_callback(ddjvu_context_t *context,
270                           ddjvu_message_callback_t callback,
271                           void *closure);
272
273
274
275/* -------------------------------------------------- */
276/* DDJVU_JOB_T                                        */
277/* -------------------------------------------------- */
278
279
280/* Many essential ddjvuapi functions initiate asynchronous operations.
281   These "jobs" run in seperate threads and report their
282   progress by posting messages into the ddjvu context event queue.
283   Jobs are sometimes represented by a ddjvu_job_t object. */
284
285/* ddjvu_job_status ---
286   Returns the status of the specified job. */
287
288typedef enum {
289  DDJVU_JOB_NOTSTARTED, /* operation was not even started */
290  DDJVU_JOB_STARTED,    /* operation is in progress */
291  DDJVU_JOB_OK,         /* operation terminated successfully */
292  DDJVU_JOB_FAILED,     /* operation failed because of an error */
293  DDJVU_JOB_STOPPED     /* operation was interrupted by user */
294} ddjvu_status_t;
295
296ddjvu_status_t DDJVUAPI ddjvu_job_status(ddjvu_job_t *job);
297
298#define ddjvu_job_done(job) \
299    (ddjvu_job_status(job) >= DDJVU_JOB_OK)
300#define ddjvu_job_error(job) \
301    (ddjvu_job_status(job) >= DDJVU_JOB_FAILED)
302
303
304/* ddjvu_job_stop ---
305   Attempts to cancel the specified job.
306   This is a best effort function.
307   There no guarantee that the job will
308   actually stop.
309 */
310
311void DDJVUAPI ddjvu_job_stop(ddjvu_job_t *job);
312
313
314/* ddjvu_job_set_user_data ---
315   ddjvu_job_get_user_data ---
316   Each job can store an arbitray pointer
317   that callers can use for any purpose. These two
318   functions provide for accessing or setting this pointer.
319   This pointer is cleared when the job is released */
320
321void DDJVUAPI ddjvu_job_set_user_data(ddjvu_job_t *job, void *userdata);
322
323void * DDJVUAPI ddjvu_job_get_user_data(ddjvu_job_t *job);
324
325
326/* ddjvu_job_release ---
327   Releases a reference to a job object and clears its user
328   data field.  This does not cause the job to stop executing.
329   The calling program should no longer reference this object.
330   The object itself will be destroyed as soon as no
331   other object or thread needs it. */
332
333void DDJVUAPI ddjvu_job_release(ddjvu_job_t *job);
334
335
336
337/* -------------------------------------------------- */
338/* DDJVU_MESSAGE_T                                    */
339/* -------------------------------------------------- */
340
341
342/* ddjvu_message_t ---
343   This union type represents messages delivered by the
344   DDJVU API. Each member of the union pertains to a
345   specific kind of message.  Member <m_any> represents the
346   information common to all kinds of messages.  Given a
347   pointer <p> to a <djvu_message_t>, the message kind can
348   be accessed as <"p->m_any.tag">. */
349
350
351/* ddjvu_message_tag_t ---
352   This enumerated type identifies each kind of
353   message delivered by the DDJVU API.  */
354
355typedef enum {
356  DDJVU_ERROR,
357  DDJVU_INFO,
358  DDJVU_NEWSTREAM,
359  DDJVU_DOCINFO,
360  DDJVU_PAGEINFO,
361  DDJVU_RELAYOUT,
362  DDJVU_REDISPLAY,
363  DDJVU_CHUNK,
364  DDJVU_THUMBNAIL,
365  DDJVU_PROGRESS,
366} ddjvu_message_tag_t;
367
368
369/* ddjvu_message_t::m_any ---
370   This structure is a member of the union <djvu_message_t>.
371   It represents the information common to all kinds of
372   messages.  Member <tag> indicates the kind of message.
373   Members <context>, <document>, <page>, and <job> indicate
374   the origin of the message.  These fields contain null
375   pointers when they are not relevant. */
376
377typedef struct ddjvu_message_any_s {
378  ddjvu_message_tag_t   tag;
379  ddjvu_context_t      *context;
380  ddjvu_document_t     *document;
381  ddjvu_page_t         *page;
382  ddjvu_job_t          *job;
383} ddjvu_message_any_t; 
384
385
386/* ddjvu_message_t::m_error ---
387   Error messages are generated whenever the decoder or the
388   DDJVU API encounters an error condition.  All errors are
389   reported as error messages because they can occur
390   asynchronously.  Member <message> is the error message.
391   Members <function>, <filename> and <lineno>
392   indicates the place where the error was detected.
393*/
394
395struct ddjvu_message_error_s {  /* ddjvu_message_t::m_error */
396  ddjvu_message_any_t   any;
397  const char           *message;
398  const char           *function;
399  const char           *filename;
400  int                   lineno;
401}; 
402
403
404/* ddjvu_message_t::m_info ---
405   This messages provides informational text indicating
406   the progress of the decoding process. This might
407   be displayed in the browser status bar. */
408
409struct ddjvu_message_info_s {   /* ddjvu_message_t::m_info */
410  ddjvu_message_any_t  any;
411  const char          *message;
412}; 
413
414
415
416
417/* -------------------------------------------------- */
418/* DDJVU_DOCUMENT_T                                    */
419/* -------------------------------------------------- */
420
421
422/* ddjvu_document_create ---
423   Creates a decoder for a DjVu document and starts
424   decoding.  This function returns immediately.  The
425   decoding job then generates messages to request the raw
426   data and to indicate the state of the decoding process.
427
428   Argument <url> specifies an optional URL for the document. 
429   The URL follows the usual syntax (<"protocol://machine/path">).
430   It should not end with a slash. It only serves two purposes:
431   - The URL is used as a key for the cache of decoded pages.
432   - The URL is used to document <m_newstream> messages.
433
434   Setting argument <cache> to <TRUE> indicates that decoded pages
435   should be cached when possible.  This only works when
436   argument <url> is not the null pointer.
437
438   It is important to understand that the URL is not used to
439   access the data.  The document generates <m_newstream>
440   messages to indicate which data is needed.  The caller must
441   then provide the raw data using <ddjvu_stream_write>
442   and <ddjvu_stream_close>.
443
444   Localized characters in argument <url> should be in
445   urlencoded utf-8 (like "%2A"). What is happening for non
446   ascii characters is unclear (probably plain utf8). */
447
448ddjvu_document_t * DDJVUAPI ddjvu_document_create(ddjvu_context_t *context,
449                      const char *url,
450                      int cache);
451
452
453/* ddjvu_document_create_from_file ---
454   Creates a document for a DjVu document stored in a file.
455   The document will directly access the specified DjVu file
456   or related files without generating <m_newstream> messages. */
457
458ddjvu_document_t * DDJVUAPI ddjvu_document_create_by_filename(ddjvu_context_t *context,
459                                  const char *filename,
460                                  int cache);
461
462
463/* ddjvu_document_job ---
464   Access the job object in charge of decoding the document header.
465   In fact <ddjvu_document_t> is a subclass of <ddjvu_job_t>
466   and this function is a type cast. */
467
468ddjvu_job_t * DDJVUAPI ddjvu_document_job(ddjvu_document_t *document);
469
470
471/* ddjvu_document_release ---
472   Release a reference to a <ddjvu_document_t> object.
473   The calling program should no longer reference this object. 
474   The object itself will be destroyed as soon as no other object
475   or thread needs it. */
476 
477#define ddjvu_document_release(document) \
478   ddjvu_job_release(ddjvu_document_job(document))
479
480
481/* ddjvu_document_set_user_data ---
482   ddjvu_document_get_user_data ---
483   Each <ddjvu_document_t> object can store an arbitray pointer
484   that callers can use for any purpose. These two functions
485   provide for accessing or setting this pointer. */
486
487#define ddjvu_document_set_user_data(document,userdata) \
488   ddjvu_job_set_user_data(ddjvu_document_job(document),userdata)
489#define ddjvu_document_get_user_data(document) \
490   ddjvu_job_get_user_data(ddjvu_document_job(document))
491
492/* ddjvu_document_decoding_status ---
493   ddjvu_document_decoding_done, ddjvu_document_decoding_error ---
494   This function returns the status of the document header decoding job */
495   
496#define ddjvu_document_decoding_status(document) \
497   ddjvu_job_status(ddjvu_document_job(document))
498#define ddjvu_document_decoding_done(page) \
499    (ddjvu_document_decoding_status(page) >= DDJVU_JOB_OK)
500#define ddjvu_document_decoding_error(page) \
501    (ddjvu_document_decoding_status(page) >= DDJVU_JOB_FAILED)
502
503
504/* ------- STREAMS ------- */
505
506
507/* ddjvu_message_t::m_newstream ---
508   Newstream messages are generated whenever the decoder
509   needs to access raw DjVu data.  The caller must then
510   provide the requested data using <ddjvu_stream_write>
511   and <ddjvu_stream_close>.
512
513   In the case of indirect documents, a single decoder
514   might simultaneously request several streams of data. 
515   Each stream is identified by a small integer <streamid>.
516
517   The first <m_newstream> message always has member
518   <streamid> set to zero and member <name> set to the null
519   pointer.  It indicates that the decoder needs to access
520   the data in the main DjVu file.  In fact, data can be
521   written to stream <0> as soon as the <ddjvu_document_t>
522   object is created.
523
524   Further <m_newstream> messages are generated to access
525   the auxilliary files of indirect or indexed DjVu
526   documents.  Member <name> then provides the basename of
527   the auxilliary file.
528
529   Member <url> is set according to the url argument
530   provided to function <ddjvu_document_create>.  The first
531   newstream message always contain the url passed to
532   <ddjvu_document_create>.  Subsequent newstream messages
533   contain the url of the auxilliary files for indirect or
534   indexed DjVu documents. */
535   
536struct ddjvu_message_newstream_s { /* ddjvu_message_t::m_newstream */
537  ddjvu_message_any_t  any;
538  int                  streamid;
539  const char          *name;
540  const char          *url;
541}; 
542
543
544/* ddjvu_stream_write ---
545   Provide raw data to the DjVu decoder.
546   This function should be called as soon as the data is available,
547   for instance when receiving DjVu data from a network connection.
548 */
549
550void DDJVUAPI ddjvu_stream_write(ddjvu_document_t *document,
551                   int streamid,
552                   const char *data,
553                   unsigned long datalen );
554
555
556/* ddjvu_stream_close ---
557   Indicates that no more data will be provided on a
558   particular stream.  Argument <stop> most likely should be
559   set to <FALSE>. Setting argument <stop> to <TRUE>
560   indicates that the user has interrupted the data transfer
561   (for instance by pressing the stop button of a browser)
562   and that the decoding threads should be stopped as
563   soon as feasible. */
564
565void DDJVUAPI ddjvu_stream_close(ddjvu_document_t *document,
566                   int streamid,
567                   int stop );
568
569
570
571/* ------- QUERIES ------- */
572
573
574/* ddjvu_message_t::m_docinfo ---
575   The <m_docinfo> message indicates that basic information
576   about the document has been obtained and decoded.
577   Not much can be done before this happens.
578 */
579
580struct ddjvu_message_docinfo_s {
581  ddjvu_message_any_t  any;
582};
583
584
585/* ddjvu_document_get_type ---
586   Returns the type of a DjVu document.
587   This function might return <DDJVU_DOCTYPE_UNKNOWN>
588   when called before receiving a <m_docinfo> message. */
589
590typedef enum {
591  DDJVU_DOCTYPE_UNKNOWN=0,
592  DDJVU_DOCTYPE_SINGLEPAGE,
593  DDJVU_DOCTYPE_BUNDLED, 
594  DDJVU_DOCTYPE_INDIRECT,
595  DDJVU_DOCTYPE_OLD_BUNDLED, /* obsolete */
596  DDJVU_DOCTYPE_OLD_INDEXED, /* obsolete */
597} ddjvu_document_type_t;
598
599ddjvu_document_type_t DDJVUAPI ddjvu_document_get_type(ddjvu_document_t *document);
600
601
602/* ddjvu_document_get_pagenum ---
603   Returns the number of pages in a DjVu document.
604   This function might return 1 when called
605   before receiving a <m_docinfo> message */
606   
607int DDJVUAPI ddjvu_document_get_pagenum(ddjvu_document_t *document);
608
609
610/* ddjvu_document_get_pageinfo ---
611   Attempts to obtain information about page <pageno>
612   without decoding the page. If the information is available,
613   the function returns <DDJVU_JOB_OK> and fills the <info> structure.
614   Otherwise it starts fetching page data and returns <DDJVU_JOB_STARTED>.
615   This function causes the emission of <m_pageinfo> messages
616   with zero in the <m_any.page> field.
617   Typical synchronous usage:
618
619   ddjvu_status_t r;
620   ddjvu_pageinfo_t info;
621   while ((r=ddjvu_document_get_pageinfo(doc,pageno,&info))<DDJVU_JOB_OK)
622     handle_ddjvu_messages(ctx, TRUE);
623   if (r>=DDJVU_JOB_FAILED)
624     signal_error();
625
626   When the djvu document comes from the network, the above idiom
627   is very slow because it waits until the data for all page is present.
628*/     
629
630typedef struct ddjvu_pageinfo_s {
631  int width;
632  int height;
633  int dpi;
634} ddjvu_pageinfo_t;
635
636ddjvu_status_t DDJVUAPI ddjvu_document_get_pageinfo(ddjvu_document_t *document, int pageno, 
637                            ddjvu_pageinfo_t *info);
638
639
640
641/* -------------------------------------------------- */
642/* DJVU_PAGE_T                                        */
643/* -------------------------------------------------- */
644
645
646/* ddjvu_page_create_by_pageno ---
647   Each page of a document can be accessed by creating a
648   <ddjvu_page_t> object with this function.  Argument
649   <pageno> indicates the page number, starting with page
650   <0> to <pagenum-1>. This function can be called
651   immediately after creating the <ddjvu_document_t> object.
652   It also initiates the data transfer and the decoding threads
653   for the specified page.  Various messages will document
654   the progress of these operations. Error messages will be
655   generated if the page does not exists. */
656
657ddjvu_page_t * DDJVUAPI ddjvu_page_create_by_pageno(ddjvu_document_t *document,
658                            int pageno);
659
660/* ddjvu_page_create_by_pageid ---
661   This function is similar to <ddjvu_page_create_by_pageno>
662   but identifies the desired page by name instead of page
663   number. */
664
665ddjvu_page_t * DDJVUAPI ddjvu_page_create_by_pageid(ddjvu_document_t *document,
666                            const char *pageid);
667
668
669/* ddjvu_page_job ---
670   Access the job object in charge of decoding the document header.
671   In fact <ddjvu_page_t> is a subclass of <ddjvu_job_t>
672   and this function is a type cast. */
673
674ddjvu_job_t * DDJVUAPI ddjvu_page_job(ddjvu_page_t *page);
675
676
677/* ddjvu_page_release ---
678   Release a reference to a <ddjvu_page_t> object.
679   The calling program should no longer reference this object.
680   The object itself will be destroyed as soon as no other object
681   or thread needs it. */
682
683#define ddjvu_page_release(page) \
684  ddjvu_job_release(ddjvu_page_job(page))
685
686
687/* ddjvu_page_set_user_data ---
688   ddjvu_page_get_user_data ---
689   Each <ddjvu_paqge_t> object can store an arbitray pointer
690   that callers can use for any purpose. These two functions
691   provide for accessing or setting this pointer. */
692
693#define ddjvu_page_set_user_data(page,userdata) \
694   ddjvu_job_set_user_data(ddjvu_page_job(page),userdata)
695#define ddjvu_page_get_user_data(page) \
696   ddjvu_job_get_user_data(ddjvu_page_job(page))
697
698/* ddjvu_page_decoding_status ---
699   ddjvu_page_decoding_done ---
700   ddjvu_page_decoding_error ---
701   These calls return the status of the page decoding job. */
702   
703#define ddjvu_page_decoding_status(page) \
704   ddjvu_job_status(ddjvu_page_job(page))
705#define ddjvu_page_decoding_done(page) \
706    (ddjvu_page_decoding_status(page) >= DDJVU_JOB_OK)
707#define ddjvu_page_decoding_error(page) \
708    (ddjvu_page_decoding_status(page) >= DDJVU_JOB_FAILED)
709
710
711/* ------- MESSAGES ------- */
712
713
714/* ddjvu_message_t::m_pageinfo ---
715   The page decoding process generates this message
716   - when basic page information is available and
717     before any <m_relayout> or <m_redisplay> message,
718   - when the page decoding thread terminates.
719   You can distinguish both cases using
720   function ddjvu_page_decoding_done().
721   Messages <m_pageinfo> are also generated as a consequence of
722   functions such as <ddjvu_document_get_pageinfo>.
723   The field <m_any.page> of such message is null.
724*/
725
726struct ddjvu_message_pageinfo_s {  /* ddjvu_message_t::m_pageinfo */
727  ddjvu_message_any_t  any;
728}; 
729
730
731/* ddjvu_message_t::m_relayout ---
732   This message is generated when a DjVu viewer
733   should recompute the layout of the page viewer
734   because the page size and resolution information has
735   been updated. */
736
737struct ddjvu_message_relayout_s {  /* ddjvu_message_t::m_relayout */
738  ddjvu_message_any_t  any;
739}; 
740
741
742/* ddjvu_message_t::m_redisplay ---
743   This message is generated when a DjVu viewer
744   should call <ddjvu_page_render> and redisplay
745   the page. This happens, for instance, when newly
746   decoded DjVu data provides a better image. */
747
748struct ddjvu_message_redisplay_s { /* ddjvu_message_t::m_redisplay */
749  ddjvu_message_any_t  any;
750}; 
751
752
753/* ddjvu_message_t::m_chunk ---
754   This message indicates that an additional chunk
755   of DjVu data has been decoded.  Member <chunkid>
756   indicates the type of the DjVu chunk. */
757
758struct ddjvu_message_chunk_s {     /* ddjvu_message_t::m_chunk */
759  ddjvu_message_any_t  any;
760  const char *chunkid;
761}; 
762
763/* About page messages --
764   Both the <m_relayout> and <m_redisplay> messages are derived from the
765   <m_chunk> message.  They are intended for driving a djvu image viewer.
766   When receiving <m_relayout>, the viewer should get the image size, decide
767   zoom factors, and place the image area, scrollbars, toolbars, and other gui
768   objects.  When receiving <m_redisplay>, the viewer should invalidate the
769   image area so that the gui toolkint calls the repaint event handler. This
770   handler should call ddjvu_page_render() and paint the part og the
771   image that needs repainting. */
772
773
774
775/* ------- QUERIES ------- */
776
777/* ddjvu_page_get_width ---
778   Returns the page width in pixels. Calling this function
779   before receiving a <m_pageinfo> message always yields <0>. */
780
781int DDJVUAPI ddjvu_page_get_width(ddjvu_page_t *page);
782
783
784/* ddjvu_page_get_height---
785   Returns the page height in pixels. Calling this function
786   before receiving a <m_pageinfo> message always yields <0>. */
787
788int DDJVUAPI ddjvu_page_get_height(ddjvu_page_t *page);
789
790/* ddjvu_page_get_resolution ---
791   Returns the page resolution in pixels per inche (dpi).
792   Calling this function before receiving a <m_pageinfo>
793   message yields a meaningless but plausible value. */
794
795int DDJVUAPI ddjvu_page_get_resolution(ddjvu_page_t *page);
796
797
798/* ddjvu_page_get_gamma ---
799   Returns the gamma of the display for which this page was designed.
800   Calling this function before receiving a <m_pageinfo>
801   message yields a meaningless but plausible value. */
802
803double DDJVUAPI ddjvu_page_get_gamma(ddjvu_page_t *page);
804
805
806/* ddjvu_page_get_version ---
807   Returns the version of the djvu file format.
808   Calling this function before receiving a <m_pageinfo>
809   message yields a meaningless but plausible value. */
810
811int DDJVUAPI ddjvu_page_get_version(ddjvu_page_t *page);
812
813
814/* ddjvu_page_get_type ---
815   Returns the type of the page data.
816   Calling this function before the termination of the
817   decoding process might returns <DDJVU_PAGETYPE_UNKNOWN>. */
818
819typedef enum {
820  DDJVU_PAGETYPE_UNKNOWN,
821  DDJVU_PAGETYPE_BITONAL,
822  DDJVU_PAGETYPE_PHOTO,
823  DDJVU_PAGETYPE_COMPOUND,
824} ddjvu_page_type_t;
825
826ddjvu_page_type_t DDJVUAPI ddjvu_page_get_type(ddjvu_page_t *page);
827
828/* ddjvu_page_get_short_description ---
829   ddjvu_page_get_long_description ---
830   Return strings describing the DjVu page.
831   The returned string must be freed with the C function <free>.
832   The short description is a one liner suitable for a status bar.
833   The long description lists all the decoded chunks.
834   These strings are updated during the decoding process.
835   Their value might change until the decoding terminates. */
836
837char * DDJVUAPI ddjvu_page_get_short_description(ddjvu_page_t *page);
838
839char * DDJVUAPI ddjvu_page_get_long_description(ddjvu_page_t *page);
840
841
842/* ddjvu_page_get_rotation ---
843   Returns the rotation angle for the DjVu page.
844   The rotation is automatically taken into account
845   by <ddjvu_page_render>, <ddjvu_page_get_width>
846   and <ddjvu_page_get_height>. */
847
848typedef enum {
849  DDJVU_ROTATE_0   = 0,
850  DDJVU_ROTATE_90  = 1,
851  DDJVU_ROTATE_180 = 2,
852  DDJVU_ROTATE_270 = 3,
853} ddjvu_page_rotation_t;
854
855ddjvu_page_rotation_t DDJVUAPI ddjvu_page_get_rotation(ddjvu_page_t *page);
856
857
858/* ddjvu_page_set_rotation ---
859   Changes the rotation angle for a DjVu page.
860   Calling this function before receiving a <m_pageinfo>
861   message has no effect. */
862
863void DDJVUAPI ddjvu_page_set_rotation(ddjvu_page_t *page,
864                        ddjvu_page_rotation_t rot);
865
866
867
868/* ------- RENDER ------- */
869
870
871/* ddjvu_rect_t ---
872   This structure specifies the location of a rectangle.
873   Coordinates are usually expressed in pixels relative to
874   the BOTTOM LEFT CORNER (but see ddjvu_format_set_y_direction).
875   Members <x> and <y> indicate the position of the bottom left
876   corner of the rectangle Members <w> and <h> indicate the
877   width and height of the rectangle. */
878
879typedef struct ddjvu_rect_s {
880  int x, y;
881  unsigned int w, h;
882} ddjvu_rect_t;
883
884
885/* ddjvu_render_mode_t ---
886   Various ways to render a page. */
887
888typedef enum {
889  DDJVU_RENDER_COLOR = 0,       /* color page or stencil */
890  DDJVU_RENDER_BLACK,           /* stencil or color page */
891  DDJVU_RENDER_COLORONLY,       /* color page or fail */
892  DDJVU_RENDER_MASKONLY,        /* stencil or fail */
893  DDJVU_RENDER_BACKGROUND,      /* color background layer */
894  DDJVU_RENDER_FOREGROUND,      /* color foreground layer */
895} ddjvu_render_mode_t;
896
897
898
899/* ddjvu_page_render --
900   Renders a segment of a page with arbitrary scale.
901   Argument <mode> indicates what image layers
902   should be rendered.
903
904   Conceptually this function renders the full page
905   into a rectangle <pagerect> and copies the
906   pixels specified by rectangle <renderrect>
907   into the buffer starting at position <imagebuffer>.
908   The actual code is much more efficient than that.
909
910   The final image is written into buffer <imagebuffer>. 
911   Argument <pixelformat> specifies the expected pixel format. 
912   Argument <rowsize> specifies the number of BYTES from
913   one row to the next in the buffer. The buffer must be
914   large enough to accomodate the desired image.
915
916   This function makes a best effort to compute an image
917   that reflects the most recently decoded data.  It might
918   return <FALSE> to indicate that no image could be
919   computed at this point, and that nothing was written into
920   the buffer. */
921
922int DDJVUAPI ddjvu_page_render(ddjvu_page_t *page,
923                  const ddjvu_render_mode_t mode,
924                  const ddjvu_rect_t *pagerect,
925                  const ddjvu_rect_t *renderrect,
926                  const ddjvu_format_t *pixelformat,
927                  unsigned long rowsize,
928                  char *imagebuffer );
929
930
931
932
933/* -------------------------------------------------- */
934/* DJVU_FORMAT_T                                      */
935/* -------------------------------------------------- */
936
937
938/* ddjvu_format_style_t ---
939   Enumerated type for pixel formats. */
940
941typedef enum {
942  DDJVU_FORMAT_BGR24,           /* truecolor 24 bits in BGR order */
943  DDJVU_FORMAT_RGB24,           /* truecolor 24 bits in RGB order */
944  DDJVU_FORMAT_RGBMASK16,       /* truecolor 16 bits with masks */
945  DDJVU_FORMAT_RGBMASK32,       /* truecolor 32 bits with masks */
946  DDJVU_FORMAT_GREY8,           /* greylevel 8 bits */
947  DDJVU_FORMAT_PALETTE8,        /* paletized 8 bits (6x6x6 color cube) */
948  DDJVU_FORMAT_MSBTOLSB,        /* packed bits, msb on the left */
949  DDJVU_FORMAT_LSBTOMSB,        /* packed bits, lsb on the left */
950} ddjvu_format_style_t;
951   
952
953/* ddjvu_format_create ---
954   Creates a <ddjvu_format_t> object describing a pixel format.
955   Argument <style> describes the generic pixel format.
956   Argument <args> is an array of <nargs> unsigned ints
957   providing additionnal information:
958   - When style is <RGBMASK*>, argument <nargs> must be <3>
959     and array <args> contains three contiguous bit masks for
960     the red, green, and blue components of each pixel.
961   - When style is <PALETTE*>, argument <nargs> must be <216>
962     and array <args> contains the 6*6*6 entries of a web
963     color cube.
964   - Otherwise <nargs> must be <0>. */
965
966ddjvu_format_t * DDJVUAPI ddjvu_format_create(ddjvu_format_style_t style, 
967                    int nargs, unsigned int *args);
968
969
970/* ddjvu_format_set_row_order ---
971   Sets a flag indicating whether the rows in the pixel buffer
972   are stored starting from the top or the bottom of the image.
973   Default ordering starts from the bottom of the image.
974   This is the opposite of the X11 convention. */
975
976void DDJVUAPI ddjvu_format_set_row_order(ddjvu_format_t *format, int top_to_bottom);
977
978
979/* ddjvu_format_set_y_direction ---
980   Sets a flag indicating whether the y coordinates in the drawing
981   area are oriented from bottom to top, or from top to botttom. 
982   The default is bottom to top, similar to PostScript.
983   This is the opposite of the X11 convention. */
984
985void DDJVUAPI ddjvu_format_set_y_direction(ddjvu_format_t *format, int top_to_bottom);
986
987
988/* ddjvu_format_set_ditherbits ---
989   Specifies the final depth of the image on the screen.
990   This is used to decide which dithering algorithm should be used.
991   The default is usually appropriate. */
992
993void DDJVUAPI ddjvu_format_set_ditherbits(ddjvu_format_t *format, int bits);
994
995
996/* ddjvu_format_set_gamma ---
997   Sets the gamma of the display for which the pixels are
998   intended.  This will be combined with the gamma stored in
999   DjVu documents in order to compute a suitable color
1000   correction.  The default value is 2.2. */
1001
1002void DDJVUAPI ddjvu_format_set_gamma(ddjvu_format_t *format, double gamma);
1003
1004
1005/* ddjvu_format_release ---
1006   Release a reference to a <ddjvu_format_t> object.
1007   The calling program should no longer reference this object. */
1008
1009void DDJVUAPI ddjvu_format_release(ddjvu_format_t *format);
1010
1011
1012
1013
1014/* -------------------------------------------------- */
1015/* THUMBNAILS                                         */
1016/* -------------------------------------------------- */
1017
1018
1019/* ddjvu_thumbnail_status ---
1020   Determine whether a thumbnail is available for page <pagenum>.
1021   Calling this function with non zero argument <start> initiates
1022   a thumbnail calculation job. Regardless of its success,
1023   the completion of the job is signalled by a subsequent
1024   <m_thumbnail> message. */
1025
1026ddjvu_status_t DDJVUAPI ddjvu_thumbnail_status(ddjvu_document_t *document, int pagenum, int start);
1027
1028
1029/* ddjvu_message_t::m_thumbnail ---
1030   This message is sent when additional thumbnails are available. */
1031
1032struct ddjvu_message_thumbnail_s { /* ddjvu_message_t::m_thumbnail */
1033  ddjvu_message_any_t  any;
1034  int pagenum;
1035}; 
1036
1037
1038/* ddjvu_thumbnail_render ---
1039   Renders a thumbnail for page <pagenum>.
1040   Argument <imagebuffer> must be large enough to contain
1041   an image of size <*wptr> by <*hptr> using pixel format
1042   <pixelformat>. Argument <rowsize> specifies the number
1043   of BYTES from one row to the next in the buffer.
1044   This function returns <FALSE> when no thumbnail is available.
1045   Otherwise it returns <TRUE>, adjusts <*wptr> and <*hptr> to
1046   reflect the thumbnail size, and writes the pixel data into
1047   the image buffer. */
1048
1049int DDJVUAPI ddjvu_thumbnail_render(ddjvu_document_t *document, int pagenum, 
1050                       int *wptr, int *hptr,
1051                       const ddjvu_format_t *pixelformat,
1052                       unsigned long rowsize,
1053                       char *imagebuffer);
1054
1055
1056
1057/* -------------------------------------------------- */
1058/* SAVE AND PRINT JOBS                                */
1059/* -------------------------------------------------- */
1060
1061
1062
1063/* ddjvu_message_t::m_progress ---
1064   These messages are generated to indicate progress
1065   towards the completion of a print or save job. */
1066
1067struct ddjvu_message_progress_s {
1068  ddjvu_message_any_t any;
1069  ddjvu_status_t status;
1070  int percent;
1071};
1072
1073/* ddjvu_document_print ---
1074   Converts specified pages of a djvu document into postscript. 
1075   This function works asynchronously in a separate thread.
1076   You can use the following idiom for synchronous operation:
1077
1078     ddjvu_job_t *job = ddjvu_document_print(....);
1079     while (! ddjvu_job_done(job) )
1080       handle_ddjvu_messages(context, TRUE);
1081       
1082   The postscript data is written to stdio file <output>.
1083   Arguments <optc> and <optv> specify printing options.
1084   All options described on the <djvups> man page are
1085   recognized, except <"-help"> and <"-verbose">.
1086*/
1087
1088ddjvu_job_t * DDJVUAPI ddjvu_document_print(ddjvu_document_t *document, FILE *output,
1089                     int optc, const char * const * optv);
1090
1091
1092/* NOT YET IMPLEMENTED ---
1093   Saves the djvu document as a bundled djvu file.
1094   This function works asynchronously in a separate thread.
1095   You can use the following idiom for synchronous operation:
1096
1097     ddjvu_job_t *job = ddjvu_document_save(....);
1098     while (! ddjvu_job_done(job) )
1099       handle_ddjvu_messages(context, TRUE);
1100     
1101   The bundled djvu data is written to file <output>
1102   which must be seekable. Arguments <optc> and <optv>
1103   exactly like command line arguments of a program.
1104   The only supported option is "-page=<pagespec>".
1105   See the man page for <djvups> for more information
1106   about page specifications.
1107*/
1108ddjvu_job_t * DDJVUAPI ddjvu_document_save(ddjvu_document_t *document, FILE *output, 
1109                    int optc, const char * const * optv);
1110
1111
1112
1113/* -------------------------------------------------- */
1114/* S-EXPRESSIONS                                      */
1115/* -------------------------------------------------- */
1116
1117/* DjVu files can contain ancillary information such as
1118   document outline, hidden text, hyperlinks, and metadata.
1119   Program <djvused> provides for manipulating such
1120   information.  Like <djvused>, the DDJVU API represents
1121   this information using a lisp s-expressions.  See file
1122   <"libdjvu/miniexp.h"> for the s-expression documentation
1123   and manipulation functions.  See the <djvused> man page
1124   for the specification of the s-expressions representing
1125   outlines, hidden text and annotations. It often help
1126   to print s-expressions using function <miniexp_pprint>.
1127
1128   WARNING: All strings in s-expression are UTF-8 encoded. 
1129   Strings returned by miniexp_to_str might have to be
1130   converted to the locale encoding. */
1131
1132
1133/* miniexp_t --
1134   Opaque type representing s-expressions.
1135   The same definition also appears in
1136   file <"libdjvu/miniexp.h">. */
1137
1138typedef struct miniexp_s* miniexp_t;
1139
1140
1141/* ddjvu_miniexp_release --
1142   This function controls the allocation of the
1143   s-expressions returned by functions from the DDJVU
1144   API. It indicates that the s-expression <expr> is no
1145   longer needed and can be deallocated as soon as
1146   necessary. Otherwise the s-expression remains allocated
1147   as long as the document object exists. */
1148
1149void DDJVUAPI ddjvu_miniexp_release(ddjvu_document_t *document, miniexp_t expr);
1150
1151
1152/* ddjvu_document_get_outline --
1153   This function tries to obtain the document outline. 
1154   If this information is available, it returns a
1155   s-expression with the same syntax as function
1156   <print-outline> of program <djvused>. 
1157   Otherwise it returns <miniexp_dummy> until
1158   the document header gets fully decoded.
1159   Typical synchronous usage:
1160
1161    miniexp_t r;
1162    while ((r=ddjvu_document_get_outline(doc))==miniexp_dummy)
1163      handle_ddjvu_messages(ctx, TRUE);
1164
1165   This function returns the empty list <miniexp_nil> when
1166   the document contains no outline information. It can also
1167   return symbols <failed> or <stopped> when an error occurs
1168   while accessing the desired information. */
1169
1170miniexp_t DDJVUAPI ddjvu_document_get_outline(ddjvu_document_t *document);
1171
1172
1173/* ddjvu_document_get_pagetext --
1174   This function tries to obtain the text information for
1175   page <pageno>. If this information is available, it
1176   returns a s-expression with the same syntax as function
1177   <print-txt> of program <djvused>.  Otherwise it starts
1178   fetching the page data and returns <miniexp_dummy>.
1179   This function causes the emission of <m_pageinfo> messages
1180   with zero in the <m_any.page> field.
1181   Typical synchronous usage:
1182
1183    miniexp_t r;
1184    while ((r=ddjvu_document_get_pagetext(doc,pageno,0))==miniexp_dummy)
1185      handle_ddjvu_messages(ctx, TRUE);
1186
1187   This function returns the empty list <miniexp_nil> when
1188   the page contains no text information. It can also return
1189   symbols <failed> or <stopped> when an error occurs while
1190   accessing the desired information.
1191
1192   Argument <maxdetail> controls the level of detail in the
1193   returned s-expression. Values "page", "region", "para",
1194   or "line" restrict the output to the specified granularity.
1195   All other values produce a s-expression that represents
1196   the hidden text data as finely as possible. */
1197
1198miniexp_t DDJVUAPI ddjvu_document_get_pagetext(ddjvu_document_t *document, int pageno, 
1199                            const char *maxdetail);
1200
1201
1202/* ddjvu_document_get_pageanno --
1203   This function tries to obtain the annotations for
1204   page <pageno>. If this information is available, it
1205   returns a s-expression with the same syntax as function
1206   <print-ant> of program <djvused>.  Otherwise it starts
1207   fetching the page data and returns <miniexp_dummy>.
1208   This function causes the emission of <m_pageinfo> messages
1209   with zero in the <m_any.page> field.
1210   Typical synchronous usage:
1211
1212     miniexp_t r;
1213     while ((r = ddjvu_document_get_pageanno(doc,pageno))==miniexp_dummy)
1214       handle_ddjvu_messages(ctx, TRUE);
1215
1216   This function returns the empty list <miniexp_nil> when
1217   the page contains no annotations. It can also return
1218   symbols <failed> or <stopped> when an error occurs while
1219   accessing the desired information. */
1220
1221miniexp_t DDJVUAPI ddjvu_document_get_pageanno(ddjvu_document_t *document, int pageno);
1222
1223
1224/* --- Helper functions to parse annotations --- */
1225
1226/* ddjvu_anno_get_bgcolor --
1227   Parse the annotations and extracts the desired
1228   background color as a color string ("#FFFFFF").
1229   See <(background ...)> in the djvused man page.
1230   This function zero if this information is not specified. */
1231
1232const char * DDJVUAPI ddjvu_anno_get_bgcolor(miniexp_t annotations);
1233
1234
1235/* ddjvu_anno_get_zoom --
1236   Parse the annotations and extracts the desired zoom factor.
1237   See <(zoom ...)> in the djvused man page.
1238   This function zero if this information is not specified. */
1239
1240const char * DDJVUAPI ddjvu_anno_get_zoom(miniexp_t annotations);
1241
1242
1243/* ddjvu_anno_get_mode --
1244   Parse the annotations and extracts the desired display mode.
1245   See <(mode ...)> in the djvused man page.
1246   This function zero if this information is not specified. */
1247
1248const char * DDJVUAPI ddjvu_anno_get_mode(miniexp_t annotations);
1249
1250
1251/* ddjvu_anno_get_horizalign --
1252   Parse the annotations and extracts how the page
1253   image should be aligned horizontally.
1254   See <(align ...)> in the djvused man page.
1255   This function zero if this information is not specified. */
1256
1257const char * DDJVUAPI ddjvu_anno_get_horizalign(miniexp_t annotations);
1258
1259
1260/* ddjvu_anno_get_vertalign --
1261   Parse the annotations and extracts how the page
1262   image should be aligned vertically.
1263   See <(align ...)> in the djvused man page.
1264   This function zero if this information is not specified. */
1265
1266const char * DDJVUAPI ddjvu_anno_get_vertalign(miniexp_t annotations);
1267
1268
1269/* ddjvu_anno_get_hyperlinks --
1270   Parse the annotations and returns a zero terminated
1271   array of <(maparea ...)> s-expressions.
1272   The called should free this array with function <free>.
1273   These s-expressions remain allocated as long
1274   as the annotations remain allocated.
1275   See also <(maparea ...)> in the djvused man page. */
1276
1277miniexp_t * DDJVUAPI ddjvu_anno_get_hyperlinks(miniexp_t annotations);
1278
1279
1280/* ddjvu_anno_get_metadata_keys --
1281   Parse the annotations and returns a zero terminated
1282   array of key symbols for the page metadata.
1283   The called should free this array with function <free>.
1284   See also <(metadata ...)> in the djvused man page. */
1285
1286miniexp_t * DDJVUAPI ddjvu_anno_get_metadata_keys(miniexp_t annotations);
1287
1288
1289/* ddjvu_anno_get_metadata --
1290   Parse the annotations and returns the metadata string
1291   corresponding to the metadata key symbol <key>.
1292   The string remains allocated as long as the
1293   annotations s-expression remain allocated.
1294   Returns zero if no such key is present. */
1295
1296const char * DDJVUAPI ddjvu_anno_get_metadata(miniexp_t annotations, miniexp_t key);
1297
1298
1299
1300/* -------------------------------------------------- */
1301/* DJVU_MESSAGE_T                                     */
1302/* -------------------------------------------------- */
1303
1304
1305/* We can now define the djvu_message_t union */
1306
1307union ddjvu_message_s {
1308  struct ddjvu_message_any_s        m_any;
1309  struct ddjvu_message_error_s      m_error;
1310  struct ddjvu_message_info_s       m_info;
1311  struct ddjvu_message_newstream_s  m_newstream;
1312  struct ddjvu_message_docinfo_s    m_docinfo;
1313  struct ddjvu_message_pageinfo_s   m_pageinfo;
1314  struct ddjvu_message_chunk_s      m_chunk;
1315  struct ddjvu_message_relayout_s   m_relayout;
1316  struct ddjvu_message_redisplay_s  m_redisplay;
1317  struct ddjvu_message_thumbnail_s  m_thumbnail;
1318  struct ddjvu_message_progress_s   m_progress;
1319};
1320
1321
1322/* -------------------------------------------------- */
1323/* BACKDOORS                                          */
1324/* -------------------------------------------------- */
1325
1326#ifdef __cplusplus
1327} // extern "C"
1328#endif
1329
1330/* ddjvu_get_DjVuImage ---
1331   ddjvu_get_DjVuDocument ---
1332   These functions provide an access to the libdjvu objects
1333   associated with the ddjvuapi objects.  These backdoors can
1334   be useful for advanced manipulations.  These two functions
1335   are declared in C++ when file <"ddjvuapi.h"> is included
1336   after the libdjvu header files <"DjVuImage.h"> and
1337   <"DjVuDocument.h">. */
1338
1339#ifdef __cplusplus
1340# ifndef NOT_USING_DJVU_NAMESPACE
1341#  ifdef _DJVUIMAGE_H
1342GP<DjVuImage> DDJVUAPI ddjvu_get_DjVuImage(ddjvu_page_t *page);
1343#  endif
1344#  ifdef _DJVUDOCUMENT_H
1345GP<DjVuDocument> DDJVUAPI ddjvu_get_DjVuDocument(ddjvu_document_t *document);
1346#  endif
1347# endif
1348#endif
1349
1350#endif /* DDJVUAPI_H */
Note: See TracBrowser for help on using the repository browser.