2016-11-21 02:23:50 +00:00
|
|
|
/*
|
2017-02-05 20:30:57 +00:00
|
|
|
* Copyright (c) 2017 Alex Yatskov <alex@foosoft.net>
|
2016-11-21 02:23:50 +00:00
|
|
|
* Author: Alex Yatskov <alex@foosoft.net>
|
|
|
|
*
|
2017-02-05 20:30:57 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
* this software and associated documentation files (the "Software"), to deal in
|
|
|
|
* the Software without restriction, including without limitation the rights to
|
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
* subject to the following conditions:
|
2016-11-21 02:23:50 +00:00
|
|
|
*
|
2017-02-05 20:30:57 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
2016-11-21 02:23:50 +00:00
|
|
|
*
|
2017-02-05 20:30:57 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2016-11-21 02:23:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BOOK_H
|
|
|
|
#define BOOK_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2017-01-01 01:08:04 +00:00
|
|
|
#include <eb/font.h>
|
2016-11-21 02:23:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Types
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char* text;
|
2016-11-30 16:55:54 +00:00
|
|
|
int page;
|
|
|
|
int offset;
|
2016-11-30 17:26:50 +00:00
|
|
|
} Book_Block;
|
2016-11-30 16:55:54 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2016-11-30 17:26:50 +00:00
|
|
|
Book_Block heading;
|
|
|
|
Book_Block text;
|
2016-11-21 02:23:50 +00:00
|
|
|
} Book_Entry;
|
|
|
|
|
2017-01-01 01:08:04 +00:00
|
|
|
typedef struct {
|
2017-02-12 03:46:46 +00:00
|
|
|
char bitmap[EB_SIZE_WIDE_FONT_48];
|
|
|
|
int code;
|
2017-01-01 01:08:04 +00:00
|
|
|
} Book_Glyph;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Book_Glyph* glyphs;
|
2017-02-12 18:16:25 +00:00
|
|
|
int bitmap_size;
|
2017-02-12 03:46:46 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int count;
|
|
|
|
} Book_Glyph_Set;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Book_Glyph_Set wide;
|
|
|
|
Book_Glyph_Set narrow;
|
2017-01-01 01:08:04 +00:00
|
|
|
} Book_Font;
|
|
|
|
|
2016-11-21 02:23:50 +00:00
|
|
|
typedef struct {
|
2016-11-30 17:26:50 +00:00
|
|
|
char* title;
|
|
|
|
Book_Block copyright;
|
2017-01-01 01:08:04 +00:00
|
|
|
|
2016-11-30 17:26:50 +00:00
|
|
|
Book_Entry* entries;
|
|
|
|
int entry_count;
|
|
|
|
int entry_alloc;
|
2017-01-01 01:08:04 +00:00
|
|
|
|
2017-02-12 03:46:46 +00:00
|
|
|
Book_Font fonts[4];
|
2016-11-21 02:23:50 +00:00
|
|
|
} Book_Subbook;
|
|
|
|
|
|
|
|
typedef struct {
|
2016-11-29 05:24:51 +00:00
|
|
|
char char_code[32];
|
2016-11-22 06:44:33 +00:00
|
|
|
char disc_code[32];
|
2016-11-21 02:23:50 +00:00
|
|
|
Book_Subbook* subbooks;
|
|
|
|
int subbook_count;
|
|
|
|
} Book;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions
|
|
|
|
*/
|
|
|
|
|
2016-11-22 06:31:01 +00:00
|
|
|
void book_init(Book* book);
|
2016-11-21 02:23:50 +00:00
|
|
|
void book_free(Book* book);
|
2016-12-14 00:57:59 +00:00
|
|
|
int book_import(Book* book, const char path[], int flags);
|
2016-12-05 02:36:06 +00:00
|
|
|
int book_export(FILE* fp, const Book* book, int flags);
|
2016-11-21 02:23:50 +00:00
|
|
|
|
|
|
|
#endif /* BOOK_H */
|