mirror of
https://github.com/fumiama/base16384.git
synced 2026-06-05 18:20:33 +08:00
完善CMake安装
This commit is contained in:
@@ -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)
|
||||
@@ -2,7 +2,7 @@
|
||||
//fumiama 20210408
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "base1432le.h"
|
||||
#include "base14.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
@@ -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)
|
||||
@@ -2,7 +2,7 @@
|
||||
//fumiama 20210407
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "base1464le.h"
|
||||
#include "base14.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
@@ -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)
|
||||
18
base16384.c
18
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user