document.c 16 KB
Newer Older
Moritz Lipp's avatar
Moritz Lipp committed
1
2
3
/* See LICENSE file for license and copyright information */

#include <stdlib.h>
Moritz Lipp's avatar
Moritz Lipp committed
4
#include <string.h>
Moritz Lipp's avatar
Moritz Lipp committed
5
#include <limits.h>
6
#include <glib.h>
Sebastian Ramacher's avatar
Sebastian Ramacher committed
7
#include <gio/gio.h>
Moritz Lipp's avatar
Moritz Lipp committed
8

9
10
11
#include <girara/datastructures.h>
#include <girara/utils.h>

12
#include "adjustment.h"
Moritz Lipp's avatar
Moritz Lipp committed
13
#include "document.h"
14
15
#include "utils.h"
#include "zathura.h"
Moritz Lipp's avatar
Moritz Lipp committed
16
#include "page.h"
17
#include "plugin.h"
18
#include "content-type.h"
19

20
21
22
/**
 * Document
 */
Moritz Lipp's avatar
Moritz Lipp committed
23
struct zathura_document_s {
24
  char* file_path; /**< File path of the document */
Lukas K.'s avatar
Lukas K. committed
25
  char* uri; /**< URI of the document */
26
  char* basename; /**< Basename of the document */
27
28
29
30
31
32
33
  const char* password; /**< Password of the document */
  unsigned int current_page_number; /**< Current page number */
  unsigned int number_of_pages; /**< Number of pages */
  double scale; /**< Scale value */
  unsigned int rotate; /**< Rotation */
  void* data; /**< Custom data */
  zathura_adjust_mode_t adjust_mode; /**< Adjust mode (best-fit, width) */
Moritz Lipp's avatar
Moritz Lipp committed
34
  int page_offset; /**< Page offset */
35
36
  double cell_width; /**< width of a page cell in the document (not ransformed by scale and rotation) */
  double cell_height; /**< height of a page cell in the document (not ransformed by scale and rotation) */
37
38
  unsigned int view_width; /**< width of current viewport */
  unsigned int view_height; /**< height of current viewport */
39
40
41
  unsigned int pages_per_row; /**< number of pages in a row */
  unsigned int first_page_column; /**< column of the first page */
  unsigned int page_padding; /**< padding between pages */
42
43
  double position_x; /**< X adjustment */
  double position_y; /**< Y adjustment */
44
45
46
47
48
49

  /**
   * Document pages
   */
  zathura_page_t** pages;

50
51
52
53
  /**
   * Used plugin
   */
  zathura_plugin_t* plugin;
54
55
};

Sebastian Ramacher's avatar
Sebastian Ramacher committed
56
57
58
59
60
61
static void
check_set_error(zathura_error_t* error, zathura_error_t code) {
  if (error != NULL) {
    *error = code;
  }
}
62

63
zathura_document_t*
64
zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
Lukas K.'s avatar
Lukas K. committed
65
                      path, const char *uri, const char* password, zathura_error_t* error)
66
67
68
69
70
{
  if (path == NULL) {
    return NULL;
  }

Sebastian Ramacher's avatar
Sebastian Ramacher committed
71
72
73
74
75
  GFile* file = g_file_new_for_path(path);
  char* real_path = NULL;
  const char* content_type = NULL;
  zathura_plugin_t* plugin = NULL;
  zathura_document_t* document = NULL;
76

Sebastian Ramacher's avatar
Sebastian Ramacher committed
77
78
79
80
  if (file == NULL) {
    girara_error("Error while handling path '%s'.", path);
    check_set_error(error, ZATHURA_ERROR_UNKNOWN);
    goto error_free;
81
82
  }

Sebastian Ramacher's avatar
Sebastian Ramacher committed
83
  real_path = g_file_get_path(file);
Moritz Lipp's avatar
Moritz Lipp committed
84
  if (real_path == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
85
86
87
    girara_error("Error while handling path '%s'.", path);
    check_set_error(error, ZATHURA_ERROR_UNKNOWN);
    goto error_free;
Moritz Lipp's avatar
Moritz Lipp committed
88
89
  }

Sebastian Ramacher's avatar
Sebastian Ramacher committed
90
91
92
93
94
  content_type = guess_content_type(real_path);
  if (content_type == NULL) {
    girara_error("Could not determine file type.");
    check_set_error(error, ZATHURA_ERROR_UNKNOWN);
    goto error_free;
95
96
  }

Sebastian Ramacher's avatar
Sebastian Ramacher committed
97
  plugin = zathura_plugin_manager_get_plugin(plugin_manager, content_type);
98
99

  if (plugin == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
100
101
    girara_error("Unknown file type: '%s'", content_type);
    check_set_error(error, ZATHURA_ERROR_UNKNOWN);
102
103
104
105

    g_free((void*)content_type);
    content_type = NULL;

106
    goto error_free;
Moritz Lipp's avatar
Moritz Lipp committed
107
108
  }

109
110
111
  g_free((void*)content_type);
  content_type = NULL;

112
113
  document = g_try_malloc0(sizeof(zathura_document_t));
  if (document == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
114
    check_set_error(error, ZATHURA_ERROR_OUT_OF_MEMORY);
115
116
    goto error_free;
  }
Moritz Lipp's avatar
Moritz Lipp committed
117

Moritz Lipp's avatar
Moritz Lipp committed
118
  document->file_path   = real_path;
Lukas K.'s avatar
Lukas K. committed
119
  document->uri         = g_strdup(uri);
120
121
122
123
124
125
126
127
  if (document->uri == NULL) {
    document->basename    = g_file_get_basename(file);
  }
  else {
    GFile *gf = g_file_new_for_uri(document->uri);
    document->basename = g_file_get_basename(gf);
    g_object_unref(gf);
  }
Moritz Lipp's avatar
Moritz Lipp committed
128
129
130
131
  document->password    = password;
  document->scale       = 1.0;
  document->plugin      = plugin;
  document->adjust_mode = ZATHURA_ADJUST_NONE;
132
133
  document->cell_width  = 0.0;
  document->cell_height = 0.0;
134
135
136
137
  document->view_height = 0;
  document->view_width  = 0;
  document->position_x  = 0.0;
  document->position_y  = 0.0;
Moritz Lipp's avatar
Moritz Lipp committed
138

Sebastian Ramacher's avatar
Sebastian Ramacher committed
139
140
141
142
  real_path = NULL;
  g_object_unref(file);
  file = NULL;

143
  /* open document */
144
145
  zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
  if (functions->document_open == NULL) {
146
147
148
149
    girara_error("plugin has no open function\n");
    goto error_free;
  }

150
  zathura_error_t int_error = functions->document_open(document);
151
  if (int_error != ZATHURA_ERROR_OK) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
152
    check_set_error(error, int_error);
153
154
155
156
    girara_error("could not open document\n");
    goto error_free;
  }

Moritz Lipp's avatar
Moritz Lipp committed
157
158
159
  /* read all pages */
  document->pages = calloc(document->number_of_pages, sizeof(zathura_page_t*));
  if (document->pages == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
160
    check_set_error(error, ZATHURA_ERROR_OUT_OF_MEMORY);
Moritz Lipp's avatar
Moritz Lipp committed
161
162
    goto error_free;
  }
163

Moritz Lipp's avatar
Moritz Lipp committed
164
  for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++) {
165
    zathura_page_t* page = zathura_page_new(document, page_id, NULL);
Moritz Lipp's avatar
Moritz Lipp committed
166
    if (page == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
167
      check_set_error(error, ZATHURA_ERROR_OUT_OF_MEMORY);
Moritz Lipp's avatar
Moritz Lipp committed
168
      goto error_free;
Moritz Lipp's avatar
Moritz Lipp committed
169
    }
Moritz Lipp's avatar
Moritz Lipp committed
170
171

    document->pages[page_id] = page;
172
173

    /* cell_width and cell_height is the maximum of all the pages width and height */
Sebastian Ramacher's avatar
Some CS    
Sebastian Ramacher committed
174
    const double width = zathura_page_get_width(page);
175
176
177
    if (document->cell_width < width)
      document->cell_width = width;

Sebastian Ramacher's avatar
Some CS    
Sebastian Ramacher committed
178
    const double height = zathura_page_get_height(page);
179
180
    if (document->cell_height < height)
      document->cell_height = height;
Moritz Lipp's avatar
Moritz Lipp committed
181
182
183
  }

  return document;
Moritz Lipp's avatar
Moritz Lipp committed
184

Moritz Lipp's avatar
Moritz Lipp committed
185
186
error_free:

Sebastian Ramacher's avatar
Sebastian Ramacher committed
187
188
189
  if (file != NULL) {
    g_object_unref(file);
  }
190

Sebastian Ramacher's avatar
Sebastian Ramacher committed
191
  g_free(real_path);
Moritz Lipp's avatar
Moritz Lipp committed
192

Sebastian Ramacher's avatar
Sebastian Ramacher committed
193
194
  if (document != NULL) {
    zathura_document_free(document);
195
    document = NULL; /* prevent double-free */
Moritz Lipp's avatar
Moritz Lipp committed
196
197
  }

Moritz Lipp's avatar
Moritz Lipp committed
198
  g_free(document);
199

Moritz Lipp's avatar
Moritz Lipp committed
200
201
202
  return NULL;
}

203
zathura_error_t
Moritz Lipp's avatar
Moritz Lipp committed
204
zathura_document_free(zathura_document_t* document)
Moritz Lipp's avatar
Moritz Lipp committed
205
{
206
  if (document == NULL || document->plugin == NULL) {
207
    return ZATHURA_ERROR_INVALID_ARGUMENTS;
Moritz Lipp's avatar
Moritz Lipp committed
208
209
  }

Sebastian Ramacher's avatar
Sebastian Ramacher committed
210
211
212
213
214
215
216
  if (document->pages != NULL) {
    /* free pages */
    for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++) {
      zathura_page_free(document->pages[page_id]);
      document->pages[page_id] = NULL;
    }
    free(document->pages);
Moritz Lipp's avatar
Moritz Lipp committed
217
218
219
  }

  /* free document */
220
  zathura_error_t error = ZATHURA_ERROR_OK;
221
222
  zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
  if (functions->document_free == NULL) {
223
    error = ZATHURA_ERROR_NOT_IMPLEMENTED;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
224
  } else {
225
    error = functions->document_free(document, document->data);
Moritz Lipp's avatar
Moritz Lipp committed
226
227
  }

Lukas K.'s avatar
Lukas K. committed
228
229
  g_free(document->file_path);
  g_free(document->uri);
230
  g_free(document->basename);
Moritz Lipp's avatar
Moritz Lipp committed
231

Moritz Lipp's avatar
Moritz Lipp committed
232
  g_free(document);
Moritz Lipp's avatar
Moritz Lipp committed
233

Moritz Lipp's avatar
Moritz Lipp committed
234
  return error;
Moritz Lipp's avatar
Moritz Lipp committed
235
236
}

237
238
239
240
241
242
243
244
245
246
const char*
zathura_document_get_path(zathura_document_t* document)
{
  if (document == NULL) {
    return NULL;
  }

  return document->file_path;
}

Lukas K.'s avatar
Lukas K. committed
247
248
249
250
251
252
253
254
255
256
const char*
zathura_document_get_uri(zathura_document_t* document)
{
  if (document == NULL) {
    return NULL;
  }

  return document->uri;
}

257
258
259
260
261
262
263
264
265
266
const char*
zathura_document_get_basename(zathura_document_t* document)
{
  if (document == NULL) {
    return NULL;
  }

  return document->basename;
}

267
268
269
270
271
272
273
274
275
276
const char*
zathura_document_get_password(zathura_document_t* document)
{
  if (document == NULL) {
    return NULL;
  }

  return document->password;
}

277
278
279
280
281
282
283
284
285
286
zathura_page_t*
zathura_document_get_page(zathura_document_t* document, unsigned int index)
{
  if (document == NULL || document->pages == NULL || (document->number_of_pages <= index)) {
    return NULL;
  }

  return document->pages[index];
}

287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
void*
zathura_document_get_data(zathura_document_t* document)
{
  if (document == NULL) {
    return NULL;
  }

  return document->data;
}

void
zathura_document_set_data(zathura_document_t* document, void* data)
{
  if (document == NULL) {
    return;
  }

  document->data = data;
}

unsigned int
zathura_document_get_number_of_pages(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }

  return document->number_of_pages;
}

void
zathura_document_set_number_of_pages(zathura_document_t* document, unsigned int number_of_pages)
{
  if (document == NULL) {
    return;
  }

  document->number_of_pages = number_of_pages;
}

unsigned int
328
zathura_document_get_current_page_number(zathura_document_t* document)
329
330
331
332
333
334
335
336
337
{
  if (document == NULL) {
    return 0;
  }

  return document->current_page_number;
}

void
338
zathura_document_set_current_page_number(zathura_document_t* document, unsigned int
339
340
341
342
343
344
345
346
347
    current_page)
{
  if (document == NULL) {
    return;
  }

  document->current_page_number = current_page;
}

348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
double
zathura_document_get_position_x(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }

  return document->position_x;
}

double
zathura_document_get_position_y(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }

  return document->position_y;
}

void
zathura_document_set_position_x(zathura_document_t* document, double position_x)
{
  if (document == NULL) {
    return;
  }

  document->position_x = position_x;
}

void
zathura_document_set_position_y(zathura_document_t* document, double position_y)
{
  if (document == NULL) {
    return;
  }

  document->position_y = position_y;
}

388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
double
zathura_document_get_scale(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }

  return document->scale;
}

void
zathura_document_set_scale(zathura_document_t* document, double scale)
{
  if (document == NULL) {
    return;
  }

  document->scale = scale;
}

unsigned int
zathura_document_get_rotation(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }

  return document->rotate;
}

void
zathura_document_set_rotation(zathura_document_t* document, unsigned int rotation)
{
  if (document == NULL) {
    return;
  }

  document->rotate = rotation % 360;

Moritz Lipp's avatar
Moritz Lipp committed
427
  if (document->rotate > 0 && document->rotate <= 90) {
428
    document->rotate = 90;
Moritz Lipp's avatar
Moritz Lipp committed
429
  } else if (document->rotate > 0 && document->rotate <= 180) {
430
    document->rotate = 180;
Moritz Lipp's avatar
Moritz Lipp committed
431
  } else if (document->rotate > 0 && document->rotate <= 270) {
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
    document->rotate = 270;
  } else {
    document->rotate = 0;
  }
}

zathura_adjust_mode_t
zathura_document_get_adjust_mode(zathura_document_t* document)
{
  if (document == NULL) {
    return ZATHURA_ADJUST_NONE;
  }

  return document->adjust_mode;
}

void
zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mode_t mode)
{
  if (document == NULL) {
    return;
  }

455
  document->adjust_mode = mode;
456
457
}

Moritz Lipp's avatar
Moritz Lipp committed
458
int
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
zathura_document_get_page_offset(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }

  return document->page_offset;
}

void
zathura_document_set_page_offset(zathura_document_t* document, unsigned int page_offset)
{
  if (document == NULL) {
    return;
  }

Moritz Lipp's avatar
Moritz Lipp committed
475
  document->page_offset = page_offset;
476
477
}

478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
void
zathura_document_set_viewport_width(zathura_document_t* document, unsigned int width)
{
  if (document == NULL) {
    return;
  }
  document->view_width = width;
}

void
zathura_document_set_viewport_height(zathura_document_t* document, unsigned int height)
{
  if (document == NULL) {
    return;
  }
  document->view_height = height;
}

void
zathura_document_get_viewport_size(zathura_document_t* document,
                                   unsigned int *height, unsigned int* width)
{
  g_return_if_fail(document != NULL && height != NULL && width != NULL);
  *height = document->view_height;
  *width = document->view_width;
}

505
506
507
508
509
510
void
zathura_document_get_cell_size(zathura_document_t* document,
                               unsigned int* height, unsigned int* width)
{
  g_return_if_fail(document != NULL && height != NULL && width != NULL);

511
512
  page_calc_height_width(document, document->cell_height, document->cell_width,
                         height, width, true);
513
514
}

515
516
517
518
519
520
void
zathura_document_get_document_size(zathura_document_t* document,
                                   unsigned int* height, unsigned int* width)
{
  g_return_if_fail(document != NULL && height != NULL && width != NULL);

521
522
523
524
525
  const unsigned int npag  = zathura_document_get_number_of_pages(document);
  const unsigned int ncol  = zathura_document_get_pages_per_row(document);
  const unsigned int c0    = zathura_document_get_first_page_column(document);
  const unsigned int nrow  = (npag + c0 - 1 + ncol - 1) / ncol;  /* number of rows */
  const unsigned int pad   = zathura_document_get_page_padding(document);
526

Sebastian Ramacher's avatar
Some CS    
Sebastian Ramacher committed
527
528
  unsigned int cell_height = 0;
  unsigned int cell_width  = 0;
529
530
531
532
533
534
  zathura_document_get_cell_size(document, &cell_height, &cell_width);

  *width  = ncol * cell_width + (ncol - 1) * pad;
  *height = nrow * cell_height + (nrow - 1) * pad;
}

535
536
537
538
539
void
zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding,
                                 unsigned int pages_per_row, unsigned int first_page_column)
{
  g_return_if_fail(document != NULL);
540

541
542
  document->page_padding = page_padding;
  document->pages_per_row = pages_per_row;
543
544
545
546

  if (first_page_column < 1) {
    first_page_column = 1;
  } else if (first_page_column > pages_per_row) {
547
    first_page_column = ((first_page_column - 1) % pages_per_row) + 1;
548
549
  }

550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
  document->first_page_column = first_page_column;
}

unsigned int
zathura_document_get_page_padding(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }
  return document->page_padding;
}

unsigned int
zathura_document_get_pages_per_row(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }
  return document->pages_per_row;
}

unsigned int
zathura_document_get_first_page_column(zathura_document_t* document)
{
  if (document == NULL) {
    return 0;
  }
  return document->first_page_column;
}

580
zathura_error_t
Moritz Lipp's avatar
Moritz Lipp committed
581
582
zathura_document_save_as(zathura_document_t* document, const char* path)
{
583
  if (document == NULL || document->plugin == NULL || path == NULL) {
584
    return ZATHURA_ERROR_UNKNOWN;
Moritz Lipp's avatar
Moritz Lipp committed
585
586
  }

587
588
  zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
  if (functions->document_save_as == NULL) {
589
    return ZATHURA_ERROR_NOT_IMPLEMENTED;
Moritz Lipp's avatar
Moritz Lipp committed
590
591
  }

592
  return functions->document_save_as(document, document->data, path);
Moritz Lipp's avatar
Moritz Lipp committed
593
594
}

595
girara_tree_node_t*
596
zathura_document_index_generate(zathura_document_t* document, zathura_error_t* error)
Moritz Lipp's avatar
Moritz Lipp committed
597
{
598
  if (document == NULL || document->plugin == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
599
    check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
Moritz Lipp's avatar
Moritz Lipp committed
600
601
602
    return NULL;
  }

603
604
  zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
  if (functions->document_index_generate == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
605
    check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
Moritz Lipp's avatar
Moritz Lipp committed
606
607
608
    return NULL;
  }

609
  return functions->document_index_generate(document, document->data, error);
Moritz Lipp's avatar
Moritz Lipp committed
610
611
}

Sebastian Ramacher's avatar
Sebastian Ramacher committed
612
girara_list_t*
613
zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* error)
Moritz Lipp's avatar
Moritz Lipp committed
614
{
615
  if (document == NULL || document->plugin == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
616
    check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
Moritz Lipp's avatar
Moritz Lipp committed
617
618
619
    return NULL;
  }

620
621
  zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
  if (functions->document_attachments_get == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
622
    check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
Moritz Lipp's avatar
Moritz Lipp committed
623
624
625
    return NULL;
  }

626
  return functions->document_attachments_get(document, document->data, error);
Moritz Lipp's avatar
Moritz Lipp committed
627
628
}

629
zathura_error_t
630
zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file)
Moritz Lipp's avatar
Moritz Lipp committed
631
{
632
  if (document == NULL || document->plugin == NULL) {
633
    return ZATHURA_ERROR_INVALID_ARGUMENTS;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
634
635
  }

636
637
  zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
  if (functions->document_attachment_save == NULL) {
638
    return ZATHURA_ERROR_NOT_IMPLEMENTED;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
639
640
  }

641
  return functions->document_attachment_save(document, document->data, attachment, file);
Moritz Lipp's avatar
Moritz Lipp committed
642
643
}

644
645
girara_list_t*
zathura_document_get_information(zathura_document_t* document, zathura_error_t* error)
Moritz Lipp's avatar
Moritz Lipp committed
646
{
647
  if (document == NULL || document->plugin == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
648
    check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
Moritz Lipp's avatar
Moritz Lipp committed
649
650
651
    return NULL;
  }

652
653
  zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
  if (functions->document_get_information == NULL) {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
654
    check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
Moritz Lipp's avatar
Moritz Lipp committed
655
656
657
    return NULL;
  }

658
  girara_list_t* result = functions->document_get_information(document, document->data, error);
659
660
661
662
663
  if (result != NULL) {
    girara_list_set_free_function(result, (girara_free_function_t) zathura_document_information_entry_free);
  }

  return result;
Moritz Lipp's avatar
Moritz Lipp committed
664
665
}

666
667
668
669
670
671
672
673
674
zathura_plugin_t*
zathura_document_get_plugin(zathura_document_t* document)
{
  if (document == NULL) {
    return NULL;
  }

  return document->plugin;
}