Add an example
This commit is contained in:
parent
77dc93e072
commit
6aee2f5875
2 changed files with 51 additions and 0 deletions
|
|
@ -17,3 +17,7 @@ if(UTF8)
|
|||
target_compile_definitions(sj3core PRIVATE UTF8)
|
||||
target_compile_definitions(sj3mkdic PRIVATE UTF8)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE SJ3TEST_SRCS src/sj3test/**.c)
|
||||
add_executable(sj3test ${SJ3TEST_SRCS})
|
||||
target_link_libraries(sj3test PRIVATE sj3core)
|
||||
|
|
|
|||
47
src/sj3test/main.c
Normal file
47
src/sj3test/main.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include <sj_kanakan.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
DictFile* dict;
|
||||
DICTL* node;
|
||||
char out[64 * 1024];
|
||||
int i = 0;
|
||||
char c[64 * 1024];
|
||||
char b;
|
||||
|
||||
work_base = calloc(1, sizeof(Global));
|
||||
node = calloc(1, sizeof(DICTL));
|
||||
|
||||
dictlist = node;
|
||||
|
||||
initwork();
|
||||
|
||||
dict = opendict("dic.bin", "");
|
||||
|
||||
node->dict = &dict->dict;
|
||||
node->next = NULL;
|
||||
|
||||
seldict(dict->dict.dicid);
|
||||
|
||||
c[0] = 0;
|
||||
|
||||
while(fread(&b, 1, 1, stdin) == 1) {
|
||||
if(b == '\n') {
|
||||
} else if(b != '\r') {
|
||||
int l = strlen(c);
|
||||
|
||||
c[l] = b;
|
||||
c[l + 1] = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while((strlen(c) - i) > 0 && (i += cl2knj(c + i, strlen(c) - i, out))) {
|
||||
STDYOUT* s = (STDYOUT*)out;
|
||||
|
||||
printf("> %s\n", out + sizeof(STDYOUT));
|
||||
}
|
||||
|
||||
c[0] = 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue