aboutsummaryrefslogtreecommitdiffstats
path: root/src/cnki_nh.c
diff options
context:
space:
mode:
authoryzrh <yzrh@noema.org>2020-12-29 02:10:17 +0000
committeryzrh <yzrh@noema.org>2020-12-29 02:10:17 +0000
commit5c5ddc926b20fae71544a8f2e2d96f15e1546c71 (patch)
treea6144bf5f9f2e45085d125e9c11575a6855821a6 /src/cnki_nh.c
parentbcb8ef9cd96738da8474e70c03c1f2a3bdf9053a (diff)
downloadmelon-5c5ddc926b20fae71544a8f2e2d96f15e1546c71.tar.gz
melon-5c5ddc926b20fae71544a8f2e2d96f15e1546c71.tar.zst
Update HN data structure.
Diffstat (limited to 'src/cnki_nh.c')
-rw-r--r--src/cnki_nh.c110
1 files changed, 0 insertions, 110 deletions
diff --git a/src/cnki_nh.c b/src/cnki_nh.c
deleted file mode 100644
index 94613b5..0000000
--- a/src/cnki_nh.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2020, yzrh <yzrh@noema.org>
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-#include <stdlib.h>
-
-#include "cnki.h"
-
-int
-cnki_nh(cnki_t **param)
-{
- if (*param == NULL)
- return 1;
-
- if ((*param)->stat > 0)
- printf("Begin 'HN' conversion\n");
-
- if ((*param)->file_stat->page > 0)
- (*param)->object_nh = malloc(sizeof(object_nh_t));
- else
- return 1;
-
- if ((*param)->object_nh == NULL)
- return 1;
-
- if ((*param)->stat > 1) {
- printf("Loading page(s)\n");
- printf("\t%8s\t%8s\t%13s\t%6s\t%4s\t%8s\t%8s\n",
- "address",
- "text",
- "page",
- "zero",
- "code",
- "address",
- "image");
- }
-
- object_nh_t *ptr = (*param)->object_nh;
- for (int i = 0; i < (*param)->file_stat->page; i++) {
- fread(&ptr->address, 4, 1, (*param)->fp_i);
- fread(&ptr->size, 4, 1, (*param)->fp_i);
- fread(&ptr->page, 4, 1, (*param)->fp_i);
- fread(&ptr->zero, 8, 1, (*param)->fp_i);
-
- ptr->text = NULL;
- ptr->image_format = -1;
- ptr->image_address = 0;
- ptr->image_size = 0;
- ptr->image = NULL;
- ptr->next = NULL;
-
- if (i < (*param)->file_stat->page - 1) {
- ptr->next = malloc(sizeof(object_nh_t));
-
- if (ptr->next == NULL)
- return 1;
- }
-
- ptr = ptr->next;
- }
-
- ptr = (*param)->object_nh;
- while (ptr != NULL) {
- ptr->text = malloc(ptr->size);
-
- if (ptr->text == NULL)
- return 1;
-
- fseek((*param)->fp_i, ptr->address, SEEK_SET);
- fread(ptr->text, ptr->size, 1, (*param)->fp_i);
- fread(&ptr->image_format, 4, 1, (*param)->fp_i);
- fread(&ptr->image_address, 4, 1, (*param)->fp_i);
- fread(&ptr->image_size, 4, 1, (*param)->fp_i);
-
- ptr->image = malloc(ptr->image_size);
-
- if (ptr->image == NULL)
- return 1;
-
- fseek((*param)->fp_i, ptr->image_address, SEEK_SET);
- fread(ptr->image, ptr->image_size, 1, (*param)->fp_i);
-
- if ((*param)->stat > 1)
- printf("\t%08x\t%8d\t{%d, %8d}\t{%d, %d}\t%4d\t%08x\t%8d\n",
- ptr->address,
- ptr->size,
- ptr->page[0],
- ptr->page[1],
- ptr->zero[0],
- ptr->zero[1],
- ptr->image_format,
- ptr->image_address,
- ptr->image_size);
-
- ptr = ptr->next;
- }
-
- if ((*param)->stat > 1)
- printf("Loaded %d page(s)\n", (*param)->file_stat->page);
-
- /* TODO: Study signed int __fastcall CAJDoc::OpenNHCAJFile(int a1, int a2) */
-
- if ((*param)->stat > 0)
- printf("Conversion ended\n");
-
- /* TODO: Finish me please :) */
- return 1;
-}