From 4ecf7277f26911d912b21c92f408090f5e4a896b Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 1 Mar 2012 00:09:58 -0600 Subject: [PATCH] Add Project: f_serialized --- level_0/f_serialized/c/serialized.h | 88 ++++++++++++++++++++++++++++++++ level_0/f_serialized/data/build/settings | 21 ++++++++ 2 files changed, 109 insertions(+) create mode 100644 level_0/f_serialized/c/serialized.h create mode 100644 level_0/f_serialized/data/build/settings diff --git a/level_0/f_serialized/c/serialized.h b/level_0/f_serialized/c/serialized.h new file mode 100644 index 0000000..6c129b9 --- /dev/null +++ b/level_0/f_serialized/c/serialized.h @@ -0,0 +1,88 @@ +/* FLL - Level 0 + * Project: Serialized + * Version: 0.2.0 + * Licenses: lgplv2.1 + * Programmers: Kevin Day + * Documentation: + * + * Provides string processing functionality for what is to be defined as a serialized string. + * Serialized strings are strings that can hold multiple values in a single variable. + * An example of serialized content is the PATH environment variable where ':" separates data." + */ +#ifndef _F_serialized_h +#define _F_serialized_h + +// libc includes +#include + +// fll-0 includes +#include +#include +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +#ifndef _di_f_serialized_strategies_ + // possible strategies. + enum { + f_serialized_strategy_simple, + f_serialized_strategy_delimited, // FIXME: not implemented + f_last_serialized_strategy, + }; // enum + + #define f_serialized_strategy_simple_splitter ":" + #define f_serialized_strategy_delimited_splitter "'" + #define f_serialized_strategy_delimited_delimiter "\\" +#endif // _di_f_serialized_strategies_ + +#ifndef _di_f_serialized_default_allocation_step_ + #define f_serialized_default_allocation_step f_memory_default_allocation_step +#endif // _di_f_serialized_default_allocation_step_ + +#ifndef _di_f_serialized_ + typedef struct { + f_string string; + f_string_length size; // total amount of allocated space + f_string_length used; // total number of allocated spaces used + f_array_length variables; // total number of serialized variables stored + f_u_short strategy, // serialized strategy in use + } f_serialized; + + #define f_serialized_initialize { f_string_initialize, f_string_length_initialize, f_string_length_initialize, f_array_length_initialize, 0 } + + #define f_delete_serialized(status, serialized) \ + status = f_delete((void **) & serialized.string, sizeof(f_string), serialized.size); \ + if (status == f_none){ \ + serialized.size = 0; \ + serialized.used = 0; \ + } + + #define f_destroy_serialized(status, serialized) \ + status = f_destroy((void **) & serialized.string, sizeof(f_string), serialized.size); \ + if (status == f_none){ \ + serialized.size = 0; \ + serialized.used = 0; \ + } + + #define f_resize_serialized(status, serialized, new_length) \ + status = f_resize((void **) & serialized.string, sizeof(f_string), serialized.size, new_length); \ + if (status == f_none){ \ + serialized.size = new_length; \ + if (serialized.used > serialized.size) serialized.used = new_length; \ + } + + #define f_adjust_serialized(status, serialized, new_length) \ + status = f_adjust((void **) & serialized.string, sizeof(f_string), serialized.size, new_length); \ + if (status == f_none){ \ + serialized.size = new_length; \ + if (serialized.used > serialized.size) serialized.used = new_length; \ + } +#endif // _di_f_serialized_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_serialized_h diff --git a/level_0/f_serialized/data/build/settings b/level_0/f_serialized/data/build/settings new file mode 100644 index 0000000..5e24d7e --- /dev/null +++ b/level_0/f_serialized/data/build/settings @@ -0,0 +1,21 @@ +# fss-0000 + +project_name f_serialized +project_level 0 + +version_major 0 +version_minor 2 +version_micro 0 + +build_compiler gcc +build_libraries -lc +build_sources_library +build_sources_program +build_sources_headers serialized.h +build_shared yes + +flags_all -z now +flags_shared +flags_static +flags_library -fPIC +flags_program -fPIE -- 1.8.3.1