From 784076d51c3d95443b53416e593c38c612c14bbe Mon Sep 17 00:00:00 2001 From: systemcoder Date: Sun, 15 Mar 2020 08:34:44 +0000 Subject: Output as hex works, first version that produces results. --- H64E-2.xcodeproj/project.pbxproj | 312 +++++++++++++++++++++ .../project.xcworkspace/contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcschemes/xcschememanagement.plist | 14 + H64E-2/h64e-model.c | 81 ++++-- H64E-2/h64e-model.h | 27 +- H64E-2/h64e.c | 83 ++++++ H64E-2/h64e.h | 37 ++- H64E-2/main.c | 70 ++++- Tests/files/test_01 | 1 + Tests/files/test_02 | 10 + Tests/files/test_03 | 8 + 12 files changed, 610 insertions(+), 48 deletions(-) create mode 100644 H64E-2.xcodeproj/project.pbxproj create mode 100644 H64E-2.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 H64E-2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 H64E-2.xcodeproj/xcuserdata/dianshi.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 Tests/files/test_01 create mode 100644 Tests/files/test_02 create mode 100644 Tests/files/test_03 diff --git a/H64E-2.xcodeproj/project.pbxproj b/H64E-2.xcodeproj/project.pbxproj new file mode 100644 index 0000000..05aae75 --- /dev/null +++ b/H64E-2.xcodeproj/project.pbxproj @@ -0,0 +1,312 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + A927BD95241C279000DC8519 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = A927BD94241C279000DC8519 /* main.c */; }; + A927BD9D241C344C00DC8519 /* h64e.c in Sources */ = {isa = PBXBuildFile; fileRef = A927BD9C241C344C00DC8519 /* h64e.c */; }; + A927BDA0241C350A00DC8519 /* h64e-model.c in Sources */ = {isa = PBXBuildFile; fileRef = A927BD9F241C350A00DC8519 /* h64e-model.c */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + A927BD8F241C279000DC8519 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + A927BD91241C279000DC8519 /* H64E-2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "H64E-2"; sourceTree = BUILT_PRODUCTS_DIR; }; + A927BD94241C279000DC8519 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + A927BD9B241C344C00DC8519 /* h64e.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = h64e.h; sourceTree = ""; }; + A927BD9C241C344C00DC8519 /* h64e.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = h64e.c; sourceTree = ""; }; + A927BD9E241C350A00DC8519 /* h64e-model.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "h64e-model.h"; sourceTree = ""; }; + A927BD9F241C350A00DC8519 /* h64e-model.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "h64e-model.c"; sourceTree = ""; }; + A927BDA3241C534700DC8519 /* test_01 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test_01; sourceTree = ""; }; + A927BDA5241D0B4900DC8519 /* test_02 */ = {isa = PBXFileReference; lastKnownFileType = text; path = test_02; sourceTree = ""; }; + A927BDA6241D0B7700DC8519 /* test_03 */ = {isa = PBXFileReference; lastKnownFileType = text; path = test_03; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A927BD8E241C279000DC8519 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A927BD88241C279000DC8519 = { + isa = PBXGroup; + children = ( + A927BDA1241C530300DC8519 /* Tests */, + A927BD93241C279000DC8519 /* H64E-2 */, + A927BD92241C279000DC8519 /* Products */, + ); + sourceTree = ""; + }; + A927BD92241C279000DC8519 /* Products */ = { + isa = PBXGroup; + children = ( + A927BD91241C279000DC8519 /* H64E-2 */, + ); + name = Products; + sourceTree = ""; + }; + A927BD93241C279000DC8519 /* H64E-2 */ = { + isa = PBXGroup; + children = ( + A927BD94241C279000DC8519 /* main.c */, + A927BD9B241C344C00DC8519 /* h64e.h */, + A927BD9E241C350A00DC8519 /* h64e-model.h */, + A927BD9F241C350A00DC8519 /* h64e-model.c */, + A927BD9C241C344C00DC8519 /* h64e.c */, + ); + path = "H64E-2"; + sourceTree = ""; + }; + A927BDA1241C530300DC8519 /* Tests */ = { + isa = PBXGroup; + children = ( + A927BDA2241C530D00DC8519 /* files */, + ); + path = Tests; + sourceTree = ""; + }; + A927BDA2241C530D00DC8519 /* files */ = { + isa = PBXGroup; + children = ( + A927BDA3241C534700DC8519 /* test_01 */, + A927BDA5241D0B4900DC8519 /* test_02 */, + A927BDA6241D0B7700DC8519 /* test_03 */, + ); + path = files; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A927BD90241C279000DC8519 /* H64E-2 */ = { + isa = PBXNativeTarget; + buildConfigurationList = A927BD98241C279000DC8519 /* Build configuration list for PBXNativeTarget "H64E-2" */; + buildPhases = ( + A927BD8D241C279000DC8519 /* Sources */, + A927BD8E241C279000DC8519 /* Frameworks */, + A927BD8F241C279000DC8519 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "H64E-2"; + productName = "H64E-2"; + productReference = A927BD91241C279000DC8519 /* H64E-2 */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A927BD89241C279000DC8519 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = dianshi; + TargetAttributes = { + A927BD90241C279000DC8519 = { + CreatedOnToolsVersion = 11.3.1; + }; + }; + }; + buildConfigurationList = A927BD8C241C279000DC8519 /* Build configuration list for PBXProject "H64E-2" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = A927BD88241C279000DC8519; + productRefGroup = A927BD92241C279000DC8519 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A927BD90241C279000DC8519 /* H64E-2 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + A927BD8D241C279000DC8519 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A927BD9D241C344C00DC8519 /* h64e.c in Sources */, + A927BDA0241C350A00DC8519 /* h64e-model.c in Sources */, + A927BD95241C279000DC8519 /* main.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + A927BD96241C279000DC8519 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + A927BD97241C279000DC8519 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + A927BD99241C279000DC8519 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + A927BD9A241C279000DC8519 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A927BD8C241C279000DC8519 /* Build configuration list for PBXProject "H64E-2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A927BD96241C279000DC8519 /* Debug */, + A927BD97241C279000DC8519 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A927BD98241C279000DC8519 /* Build configuration list for PBXNativeTarget "H64E-2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A927BD99241C279000DC8519 /* Debug */, + A927BD9A241C279000DC8519 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = A927BD89241C279000DC8519 /* Project object */; +} diff --git a/H64E-2.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/H64E-2.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..0fedac4 --- /dev/null +++ b/H64E-2.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/H64E-2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/H64E-2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/H64E-2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/H64E-2.xcodeproj/xcuserdata/dianshi.xcuserdatad/xcschemes/xcschememanagement.plist b/H64E-2.xcodeproj/xcuserdata/dianshi.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..c3bc962 --- /dev/null +++ b/H64E-2.xcodeproj/xcuserdata/dianshi.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + H64E-2.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/H64E-2/h64e-model.c b/H64E-2/h64e-model.c index b794f52..3bd0d1f 100644 --- a/H64E-2/h64e-model.c +++ b/H64E-2/h64e-model.c @@ -8,7 +8,7 @@ #include "h64e-model.h" -int h64e_si_init(H64E_stream_in *in, ssize_t size) +int h64e_si_init(H64E_stream_in *in, int32_t size) { in->size = size; in->cur_size = 0; @@ -17,42 +17,53 @@ int h64e_si_init(H64E_stream_in *in, ssize_t size) } //return amount of copied bytes -int h64e_si_data_in(H64E_stream_in *in, uint8_t *data, size_t size) +int h64e_si_data_in(H64E_stream_in *in, uint8_t *data, int32_t size) { - ssize_t start = in->cur_size; - ssize_t end = start+size; - ssize_t len = 0; + int32_t start = in->cur_size; + int32_t end = start+size; + int32_t len = 0; + if (end > in->size) { end = in->size; } len = end-start; - - memcpy(in->buf, data, len); - + memcpy(&in->buf[start], data, len); + in->cur_size += len; return (int)len; } -int h64e_si_data_out(H64E_stream_in *in, uint8_t *data, size_t size) +int h64e_si_data_out(H64E_stream_in *in, uint8_t *data, int32_t size) { - ssize_t len=0; + int32_t len=0; + int32_t i=0; - if (sizecur_size) + if (size < in->cur_size) { len = size; } else { len = in->cur_size; } - memcpy(data,in->buf,len); - memmove(in->buf,in->buf[len],len); + //memcpy(data,&in->buf[0],len); + for (i=0;ibuf[i]; + } + + memmove(&in->buf[0],&in->buf[len],len); in->cur_size -= len; return len; } -int h64e_so_init(H64E_stream_out *out, ssize_t size) +int h64e_si_len(H64E_stream_in *in) +{ + return in->cur_size; +} + +int h64e_so_init(H64E_stream_out *out, int32_t size) { out->size = size; out->cur_size = 0; @@ -60,37 +71,55 @@ int h64e_so_init(H64E_stream_out *out, ssize_t size) return 0; } -int h64e_so_data_in(H64E_stream_in *out, uint8_t *data, size_t size) +int h64e_so_data_in(H64E_stream_out *out, uint8_t *data, int32_t size) { - ssize_t start = out->cur_size; - ssize_t end = start+size; - ssize_t len = 0; + int32_t start = out->cur_size; + int32_t end = start+size; + int32_t len = 0; + if (end > out->size) { end = out->size; } len = end-start; - - memcpy(out->buf, data, len); - + memcpy(&out->buf[start], data, len); + out->cur_size += len; return (int)len; } -int h64e_so_data_out(H64E_stream_in *out, uint8_t *data, size_t size) +int h64e_so_data_out(H64E_stream_out *out, uint8_t *data, int32_t size) { - ssize_t len=0; + int32_t len=0; + int32_t i=0; - if (sizecur_size) + if (size < out->cur_size) { len = size; } else { len = out->cur_size; } - memcpy(data,out->buf,len); - memmove(out->buf,out->buf[len],len); + //memcpy(data,&in->buf[0],len); + for (i=0;ibuf[i]; + } + + memmove(&out->buf[0],&out->buf[len],len); out->cur_size -= len; return len; } + +int h64e_so_ready(H64E_stream_out *out) +{ + int ret = 0; + + return ret; +} + +int h64e_so_len(H64E_stream_out *out) +{ + return out->cur_size; +} diff --git a/H64E-2/h64e-model.h b/H64E-2/h64e-model.h index 516f8dc..761d327 100644 --- a/H64E-2/h64e-model.h +++ b/H64E-2/h64e-model.h @@ -10,30 +10,37 @@ #define h64e_model_h #include +#include #include typedef int (*trnf_clb)(char*); typedef struct H64E_stream_in { - int cur_size; - int size; + int32_t cur_size; + int32_t size; uint8_t *buf; } H64E_stream_in; //used to get collected data -int h64e_si_init(H64E_stream_in *in, ssize_t size); -int h64e_si_data_in(H64E_stream_in *in, uint8_t *data, size_t size); -int h64e_si_data_out(H64E_stream_in *in, uint8_t *data, size_t size); +int h64e_si_init(H64E_stream_in *in, int32_t size); +int h64e_si_data_in(H64E_stream_in *in, uint8_t *data, int32_t size); +int h64e_si_data_out(H64E_stream_in *in, uint8_t *data, int32_t size); +int h64e_si_len(H64E_stream_in *in); typedef struct H64E_stream_out { - int cur_size; - int size; + int32_t cur_size; + int32_t size; uint8_t *buf; } H64E_stream_out; //using to collect output formated data -int h64e_so_init(H64E_stream_out *out, ssize_t size); -int h64e_so_data_in(H64E_stream_in *out, uint8_t *data, size_t size); -int h64e_so_data_out(H64E_stream_in *out, uint8_t *data, size_t size); +int h64e_so_init(H64E_stream_out *out, int32_t size); +int h64e_so_data_in(H64E_stream_out *out, uint8_t *data, int32_t size); +int h64e_so_data_out(H64E_stream_out *out, uint8_t *data, int32_t size); +/* + * Trigger that buffer is full, or trigger new line in buffer + */ +int h64e_so_ready(H64E_stream_out *out); +int h64e_so_len(H64E_stream_out *out); #endif /* h64e_model_h */ diff --git a/H64E-2/h64e.c b/H64E-2/h64e.c index 0072030..1e0662c 100644 --- a/H64E-2/h64e.c +++ b/H64E-2/h64e.c @@ -49,3 +49,86 @@ int h64e_destroy(H64E_t *s) { return 0; } + +int h64e_fmt_init( H64E_format *fs) +{ + memset(fs,0,sizeof(H64E_format)); + + return 0; +} + +/* + * out_size - allways give enought data to buffer otherwise it will partially write data, or flush data out more often + */ +int h64e_fmt_byte(H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size) +{ + //printf("h64e_fmt_byte in %d out %d\n",in_size,out_size); + int ret=0; + int cur_size=0; + int i,j=0; + const int SZ=16; + uint8_t buf[SZ]; + int buf_sz=0; + int trail_size=0; + + for (i=0; icur_pos += 1; + //add space if configured + if (fs->f_space) + { + if (buf_sz+1cur_pos == fs->column_size) + { + if (fs->f_new_line) { + //set triger to newline + fs->t_new_line = 1; + fs->cur_pos = 0; + //set new line to buffer + if (buf_sz+11) + { + int cnv_num=-1; + //printf("Input Out\n"); + cnv_bytes = h64e_si_data_out(&sin, &buf_cnv_in[0], 1); + //cnv_total += cnv_bytes; + + + //Convert output data to desired format + //printf("Start converting to byte8\n"); + cnv_num = h64e_fmt_byte(&int8_fmt, &buf_cnv_in[0], cnv_bytes, buf_cnv_out, 512); + //printf("Conversation amount\n"); + //Push all data ot output buffer + //printf("Write to output stream data %d bytes\n",cnv_bytes); + cnv_bytes = h64e_so_data_in(&sout, &buf_cnv_out[0], cnv_num); + cnv_total += cnv_num; + //printf("Written bytes to output steam %d bytes %d bytes total\n",cnv_bytes,cnv_total); + } + + //Get data out of buffer + if ((out_bytes = h64e_so_len(&sout)) > 0) + { + out_bytes = h64e_so_data_out(&sout, &buf_out[0],512); + buf_out[out_bytes] = 0x00; + printf("%s",buf_out); + } + /* + out_bytes = h64e_so_data_out(&sout, &buf_out[0],512); + printf("Output out\n"); + out_total += out_bytes; + buf_out[out_bytes] = 0x00; + printf("%s\n",buf_out); + printf("Read converted data %d bytes %d total bytes\n",out_bytes,out_total); + */ + //printf("Total: in %d cnv %d out %d\n",in_total,cnv_total,out_total); + + //printf("Reading %d bytes\n",in_bytes); } + //check and empty all buffers + //deinit all structures h64e_destroy(&h64e); file_close(fd); diff --git a/Tests/files/test_01 b/Tests/files/test_01 new file mode 100644 index 0000000..720691a --- /dev/null +++ b/Tests/files/test_01 @@ -0,0 +1 @@ +Hello this is me diff --git a/Tests/files/test_02 b/Tests/files/test_02 new file mode 100644 index 0000000..57d07c3 --- /dev/null +++ b/Tests/files/test_02 @@ -0,0 +1,10 @@ +LINE01 +LINE02 +LINE03 +LINE04 +LINE05 +LINE06 +LINE07 +LINE08 +LINE09 +LINE10 diff --git a/Tests/files/test_03 b/Tests/files/test_03 new file mode 100644 index 0000000..6b1a644 --- /dev/null +++ b/Tests/files/test_03 @@ -0,0 +1,8 @@ +AAAAAAAAAA +BBBBBBBBBB +CCCCCCCCCC +DDDDDDDDDD +EEEEEEEEEE +FFFFFFFFFF +GGGGGGGGGG +HHHHHHHHHH -- cgit v1.2.3