1/* poppler.cc: glib wrapper for poppler
2 * Copyright (C) 2005, Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include <config.h>
20#include "poppler.h"
21
22#ifndef __GI_SCANNER__
23# include <Error.h>
24#endif
25
26#include "poppler-private.h"
27
28/**
29 * SECTION: poppler-errors
30 * @title: Error handling
31 * @short_description: Error domain and codes
32 *
33 */
34
35/**
36 * POPPLER_ERROR:
37 *
38 * Error domain for poppler operations. Errors in this domain will
39 * be from the #PopplerError enumeration. See #GError for information
40 * on error domains.
41 */
42
43GQuark poppler_error_quark(void)
44{
45 static GQuark q = 0;
46
47 if (q == 0) {
48 q = g_quark_from_static_string(string: "poppler-quark");
49 }
50
51 return q;
52}
53
54/**
55 * poppler_get_backend:
56 *
57 * Returns the backend compiled into the poppler library.
58 *
59 * Return value: The backend used by poppler
60 **/
61PopplerBackend poppler_get_backend(void)
62{
63 return POPPLER_BACKEND_CAIRO;
64}
65
66static const char poppler_version[] = PACKAGE_VERSION;
67
68/**
69 * poppler_get_version:
70 *
71 * Returns the version of poppler in use. This result is not to be freed.
72 *
73 * Return value: the version of poppler.
74 **/
75const char *poppler_get_version(void)
76{
77 return poppler_version;
78}
79
80/* We want to install an error callback so that PDF syntax warnings etc
81 * can be redirected through the GLib logging API instead of always just
82 * going to stderr.
83 */
84
85void _poppler_error_cb(ErrorCategory category, Goffset pos, const char *message)
86{
87 static const char *const cat_str[] = { "Syntax warning", "Syntax error", nullptr, nullptr, "IO error", nullptr, "Unimplemented feature", "Internal error" };
88
89 /* The following will never occur in poppler-glib */
90 if (category == errConfig || category == errCommandLine || category == errNotAllowed) {
91 return;
92 }
93
94 g_log(G_LOG_DOMAIN, log_level: G_LOG_LEVEL_INFO, format: "%s at position %" G_GOFFSET_FORMAT ": %s", cat_str[category], (goffset)pos, message);
95}
96

source code of poppler/glib/poppler.cc