blob: 02566b285e9a1773da78eb2d43b4e9a1e98424f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
* Copyright 2018 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of libnspdf.
*
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
*/
#include <libwapcaplet/libwapcaplet.h>
#include <nspdf/meta.h>
#include "cos_object.h"
#include "pdf_doc.h"
static nspdferror lwc2nspdferr(lwc_error ret)
{
nspdferror res;
switch (ret) {
case lwc_error_ok:
res = NSPDFERROR_OK;
break;
case lwc_error_oom:
res = NSPDFERROR_NOMEM;
break;
case lwc_error_range:
res = NSPDFERROR_RANGE;
break;
default:
res = NSPDFERROR_NOTFOUND;
break;
}
return res;
}
nspdferror nspdf_get_title(struct nspdf_doc *doc, struct lwc_string_s **title)
{
struct cos_string *cos_title;
nspdferror res;
if (doc->info == NULL) {
return NSPDFERROR_NOTFOUND;
}
res = cos_get_dictionary_string(doc, doc->info, "Title", &cos_title);
if (res != NSPDFERROR_OK) {
return res;
}
res = lwc2nspdferr(lwc_intern_string((const char *)cos_title->data,
cos_title->length,
title));
return res;
}
|