1
This commit is contained in:
Alex Yatskov 2016-11-19 18:14:55 -08:00
parent dfc3815a4a
commit 1cd408df8b
4 changed files with 53 additions and 20 deletions

44
gaiji.c
View File

@ -16,39 +16,65 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include "eb/eb/eb.h"
#include "eb/eb/text.h"
#include "util.h"
#include "gaiji.h"
/*
* Macros
*/
#define GAIJI_TABLE(name, ents) {\
name,\
gaiji_table_##ents##_wide,\
ARRSIZE(gaiji_table_##ents##_wide),\
gaiji_table_##ents##_narrow,\
ARRSIZE(gaiji_table_##ents##_narrow)\
}
/*
* Local data
*/
#include "gaiji_table_daijisen.h"
static const Gaiji_table gaiji_tables[] = {
GAIJI_TABLE("大辞泉", daijisen),
};
/*
* Exported functions
*/
void gaiji_init_context(Gaiji_context* context, const char title[]) {
(void)context;
(void)title;
const Gaiji_table * gaiji_select_table(const char title[]) {
for (unsigned i = 0; i < ARRSIZE(gaiji_tables); ++i) {
const Gaiji_table* table = gaiji_tables + i;
if (strcmp(table->title, title) == 0) {
return table;
}
}
return NULL;
}
void gaiji_build_stub(char text[MAX_STUB_BYTES], int code, const Gaiji_context* context, Gaiji_width width) {
sprintf(text, "!!!");
void gaiji_build_stub(char text[MAX_STUB_BYTES], int code, const Gaiji_table* table, Gaiji_width width) {
if (table == NULL) {
strcpy(text, "<?>");
return;
}
(void)code;
(void)text;
(void)context;
(void)table;
(void)width;
}
void gaiji_fixup_stub(char output[], int size, const char input[], const Gaiji_context* context) {
void gaiji_fixup_stub(char output[], int size, const char input[]) {
(void)output;
(void)size;
(void)input;
(void)context;
}

18
gaiji.h
View File

@ -24,6 +24,7 @@
*/
#define MAX_STUB_BYTES 10
#define MAX_TABLE_NAME 256
/*
* Types
@ -35,11 +36,12 @@ typedef struct {
} Gaiji_entry;
typedef struct {
Gaiji_entry* table_wide;
int count_wide;
Gaiji_entry* table_narrow;
int count_narrow;
} Gaiji_context;
char title[MAX_TABLE_NAME];
const Gaiji_entry* table_wide;
int count_wide;
const Gaiji_entry* table_narrow;
int count_narrow;
} Gaiji_table;
typedef enum {
GAIJI_WIDTH_WIDE,
@ -50,8 +52,8 @@ typedef enum {
* Functions
*/
void gaiji_init_context(Gaiji_context* context, const char title[]);
void gaiji_build_stub(char text[MAX_STUB_BYTES], int code, const Gaiji_context* context, Gaiji_width width);
void gaiji_fixup_stub(char output[], int size, const char input[], const Gaiji_context* context);
const Gaiji_table * gaiji_select_table(const char title[]);
void gaiji_build_stub(char text[MAX_STUB_BYTES], int code, const Gaiji_table* table, Gaiji_width width);
void gaiji_fixup_stub(char output[], int size, const char input[]);
#endif /* GAIJI_H */

View File

@ -22,7 +22,7 @@
#include "gaiji.h"
static const Gaiji_entry gaiji_table_narrow_daijisen[] = {
static const Gaiji_entry gaiji_table_daijisen_narrow[] = {
{ 0xA121, { 0xC2, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, /*   */
{ 0xA122, { 0xC2, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* ¡ */
{ 0xA123, { 0xC2, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* ¢ */
@ -252,8 +252,7 @@ static const Gaiji_entry gaiji_table_narrow_daijisen[] = {
{ 0xA34F, { 0xCB, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* ˜ */
};
static const Gaiji_entry gaiji_table_wide_daijisen[] =
{
static const Gaiji_entry gaiji_table_daijisen_wide[] = {
{ 0xB322, { 0xE3, 0x8B, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* ㋘ cb4960 */
{ 0xB323, { 0xE3, 0x8B, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* ㋙ cb4960 */
{ 0xB324, { 0xE3, 0x8B, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* ㋚ cb4960 */

6
util.h
View File

@ -25,6 +25,12 @@
#include "eb/eb/eb.h"
/*
* Macros
*/
#define ARRSIZE(arr) (sizeof(arr) / sizeof(arr[0]))
/*
* Types
*/