Coverage Report

Created: 2026-02-10 07:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poppler/glib/poppler.cc
Line
Count
Source
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
43
GQuark poppler_error_quark(void)
44
11.8k
{
45
11.8k
    static GQuark q = 0;
46
47
11.8k
    if (q == 0) {
48
6
        q = g_quark_from_static_string("poppler-quark");
49
6
    }
50
51
11.8k
    return q;
52
11.8k
}
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
 **/
61
PopplerBackend poppler_get_backend(void)
62
0
{
63
0
    return POPPLER_BACKEND_CAIRO;
64
0
}
65
66
static 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
 **/
75
const char *poppler_get_version(void)
76
0
{
77
0
    return poppler_version;
78
0
}
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
85
void _poppler_error_cb(ErrorCategory category, Goffset pos, const char *message)
86
156M
{
87
156M
    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
156M
    if (category == errConfig || category == errCommandLine || category == errNotAllowed) {
91
76
        return;
92
76
    }
93
94
156M
    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "%s at position %" G_GOFFSET_FORMAT ": %s", cat_str[category], (goffset)pos, message);
95
156M
}