1
zero-epwing/util.h

81 lines
1.7 KiB
C
Raw Normal View History

2016-11-01 02:32:40 +00:00
/*
* Copyright (C) 2016 Alex Yatskov <alex@foosoft.net>
* Author: Alex Yatskov <alex@foosoft.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTIL_H
#define UTIL_H
#include <stdlib.h>
2016-11-03 03:37:11 +00:00
#include <stdbool.h>
2016-11-03 03:06:40 +00:00
#include <stdio.h>
2016-11-03 03:37:11 +00:00
2016-11-02 05:11:29 +00:00
#include "eb/eb/eb.h"
2016-11-01 02:32:40 +00:00
2016-11-20 03:40:29 +00:00
#include "gaiji.h"
2016-11-20 02:14:55 +00:00
/*
* Macros
*/
#define ARRSIZE(arr) (sizeof(arr) / sizeof(arr[0]))
2016-11-19 20:23:06 +00:00
/*
* Types
*/
2016-11-01 05:24:20 +00:00
typedef struct {
char* heading;
char* text;
2016-11-20 03:45:37 +00:00
} Text_Block;
2016-11-01 05:24:20 +00:00
2016-11-01 03:40:52 +00:00
typedef struct {
char* heading;
char* text;
} Entry;
typedef struct {
char* title;
2016-11-01 05:24:20 +00:00
char* copyright;
2016-11-01 03:40:52 +00:00
Entry* entries;
int entry_count;
2016-11-02 16:06:58 +00:00
int entry_cap;
2016-11-01 03:40:52 +00:00
} Subbook;
typedef struct {
2016-11-02 05:34:53 +00:00
char character_code[32];
char disc_code[32];
2016-11-01 03:40:52 +00:00
Subbook* subbooks;
int subbook_count;
} Book;
2016-11-02 16:14:14 +00:00
typedef enum {
READ_MODE_TEXT,
READ_MODE_HEADING,
2016-11-20 03:45:37 +00:00
} Read_Mode;
2016-11-02 16:14:14 +00:00
2016-11-19 20:23:06 +00:00
/*
* Functions
*/
2016-11-03 03:06:40 +00:00
2016-11-20 03:45:37 +00:00
char* read_book_data(EB_Book* book, EB_Hookset* hookset, Gaiji_Context* context, const EB_Position* position, Read_Mode mode);
2016-11-03 03:06:40 +00:00
void free_book(Book* book);
2016-11-03 03:37:11 +00:00
void dump_book(Book* book, bool pretty_print, FILE* fp);
2016-11-03 03:06:40 +00:00
2016-11-19 20:23:06 +00:00
#endif /* UTIL_H */