aboutsummaryrefslogtreecommitdiffstats
path: root/src/cnki_caj.c
blob: 3c0b1b9aebdb2a7b2e2fd844228dc48eb1a5b946 (plain) (blame)
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
/*
 * Copyright (c) 2020-2021, yzrh <yzrh@noema.org>
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <stdlib.h>

#include "cnki.h"

int
cnki_caj(cnki_t **param)
{
	if (*param == NULL)
		return 1;

	if ((*param)->stat > 0)
		printf("Begin 'CAJ' conversion\n");

	if ((*param)->stat > 1)
		printf("Reading document body address at 0x%x\n", ADDRESS_CAJ_BODY);

	int addr;

	fseek((*param)->fp_i, ADDRESS_CAJ_BODY, SEEK_SET);
	fread(&addr, 4, 1, (*param)->fp_i);
	fseek((*param)->fp_i, addr, SEEK_SET);
	fread(&addr, 4, 1, (*param)->fp_i);
	fseek((*param)->fp_i, addr, SEEK_SET);

	if ((*param)->stat > 0)
		printf("Advised document body address is 0x%x\n", addr);

	cnki_pdf(param);

	if ((*param)->stat > 0)
		printf("Conversion ended\n");

	return 0;
}