1
0
mirror of https://github.com/fumiama/base16384.git synced 2026-06-05 18:20:33 +08:00

完善CMake安装

This commit is contained in:
fumiama
2021-05-19 23:00:25 +08:00
parent d4df0567d5
commit 4900e47b9e
9 changed files with 27 additions and 12 deletions

View File

@@ -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)

View File

@@ -2,7 +2,7 @@
//fumiama 20210408
#include <stdio.h>
#include <stdlib.h>
#include "base1432le.h"
#include "base14.h"
//#define DEBUG

View File

@@ -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)

View File

@@ -2,7 +2,7 @@
//fumiama 20210407
#include <stdio.h>
#include <stdlib.h>
#include "base1464le.h"
#include "base14.h"
//#define DEBUG

View File

@@ -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)

View File

@@ -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;

View File

@@ -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