]> Kevux Git Server - fll/commitdiff
Add Project: f_serialized
authorKevin Day <kevin@kevux.org>
Thu, 1 Mar 2012 06:09:58 +0000 (00:09 -0600)
committerKevin Day <kevin@kevux.org>
Thu, 1 Mar 2012 06:11:23 +0000 (00:11 -0600)
level_0/f_serialized/c/serialized.h [new file with mode: 0644]
level_0/f_serialized/data/build/settings [new file with mode: 0644]

diff --git a/level_0/f_serialized/c/serialized.h b/level_0/f_serialized/c/serialized.h
new file mode 100644 (file)
index 0000000..6c129b9
--- /dev/null
@@ -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 <string.h>
+
+// fll-0 includes
+#include <level_0/strings.h>
+#include <level_0/types.h>
+#include <level_0/errors.h>
+
+#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 (file)
index 0000000..5e24d7e
--- /dev/null
@@ -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