diff --git a/32/CMakeLists.txt b/32/CMakeLists.txt index b8ccaac..41f6102 100644 --- a/32/CMakeLists.txt +++ b/32/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required(VERSION 3.0.0) project(base1432 VERSION 2.0) -add_library(base1432 ./base1432le.c) +add_library(base1432 STATIC base14.c) +add_library(base14 SHARED base14.c) + +INSTALL(FILES base14.h DESTINATION include) \ No newline at end of file diff --git a/32/base1432le.c b/32/base14.c similarity index 99% rename from 32/base1432le.c rename to 32/base14.c index 0258739..013aa5e 100644 --- a/32/base1432le.c +++ b/32/base14.c @@ -2,7 +2,7 @@ //fumiama 20210408 #include #include -#include "base1432le.h" +#include "base14.h" //#define DEBUG diff --git a/32/base1432le.h b/32/base14.h similarity index 100% rename from 32/base1432le.h rename to 32/base14.h diff --git a/64/CMakeLists.txt b/64/CMakeLists.txt index 8ee6dec..13fc2fc 100644 --- a/64/CMakeLists.txt +++ b/64/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required(VERSION 3.0.0) project(base1464 VERSION 2.0) -add_library(base1464 ./base1464le.c) +add_library(base1464 STATIC base14.c) +add_library(base14 SHARED base14.c) + +INSTALL(FILES base14.h DESTINATION include) \ No newline at end of file diff --git a/64/base1464le.c b/64/base14.c similarity index 99% rename from 64/base1464le.c rename to 64/base14.c index 179868a..c6d016c 100644 --- a/64/base1464le.c +++ b/64/base14.c @@ -2,7 +2,7 @@ //fumiama 20210407 #include #include -#include "base1464le.h" +#include "base14.h" //#define DEBUG diff --git a/64/base1464le.h b/64/base14.h similarity index 100% rename from 64/base1464le.h rename to 64/base14.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ae08d51..2864b6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,3 +12,6 @@ ELSE() add_subdirectory("./32") target_link_libraries(base16384 base1432) ENDIF() + +INSTALL(TARGETS base14 LIBRARY DESTINATION lib) +INSTALL(TARGETS base16384 RUNTIME DESTINATION bin) \ No newline at end of file diff --git a/base16384.c b/base16384.c index 889c264..2472985 100644 --- a/base16384.c +++ b/base16384.c @@ -10,13 +10,13 @@ void encode_file(const char* input, const char* output) { FILE* fpo = NULL; fpo = fopen(output, "wb"); if(fpo) { - char* bufi = (char*)malloc(B14BUFSIZ/7*7); + uint8_t* bufi = (uint8_t*)malloc(B14BUFSIZ/7*7); if(bufi) { int cnt = 0; fputc(0xFE, fpo); fputc(0xFF, fpo); fflush(fpo); - while((cnt = fread(bufi, sizeof(char), B14BUFSIZ/7*7, fp))) { + while((cnt = fread(bufi, sizeof(uint8_t), B14BUFSIZ/7*7, fp))) { LENDAT* ld = encode(bufi, cnt); if(fwrite(ld->data, ld->len, 1, fpo) <= 0) { puts("Write file error!"); @@ -34,8 +34,14 @@ void encode_file(const char* input, const char* output) { int rm_head(FILE* fp) { int ch = fgetc(fp); - if(ch == 0xFE) fgetc(fp); - else rewind(fp); + if(ch == 0xFE) { + fgetc(fp); + return 1; + } + else { + rewind(fp); + return 0; + } } static int is_next_end(FILE* fp) { @@ -54,12 +60,12 @@ void decode_file(const char* input, const char* output) { FILE* fpo = NULL; fpo = fopen(output, "wb"); if(fpo) { - char* bufi = (char*)malloc(B14BUFSIZ/8*8 + 2); //+2避免漏检结束偏移标志 + uint8_t* bufi = (uint8_t*)malloc(B14BUFSIZ/8*8 + 2); //+2避免漏检结束偏移标志 if(bufi) { int cnt = 0; int end = 0; rm_head(fp); - while((cnt = fread(bufi, sizeof(char), B14BUFSIZ/8*8, fp))) { + while((cnt = fread(bufi, sizeof(uint8_t), B14BUFSIZ/8*8, fp))) { if((end = is_next_end(fp))) { bufi[cnt++] = '='; bufi[cnt++] = end; diff --git a/base16384.h b/base16384.h index 889518a..5082841 100644 --- a/base16384.h +++ b/base16384.h @@ -4,9 +4,9 @@ #endif #endif #ifdef CPUBIT32 - #include "./32/base1432le.h" + #include "./32/base14.h" #endif #ifdef CPUBIT64 - #include "./64/base1464le.h" + #include "./64/base14.h" #endif