Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/linux-sunxi/sunxi-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Mery <amery@geeks.cl>2012-05-04 16:49:32 +0400
committerAlejandro Mery <amery@geeks.cl>2012-05-04 16:49:32 +0400
commit33d67b72881001e41f596d82088c3502032bbeb8 (patch)
tree5759bc28219a88babd3c340d9f23ea5459a55b30 /script.c
parent05a2d8f70a8d51c262d33193972a2fd178ff2981 (diff)
script: implemented script_string_entry_append()
Diffstat (limited to 'script.c')
-rw-r--r--script.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/script.c b/script.c
index 34e91cb..0a92b79 100644
--- a/script.c
+++ b/script.c
@@ -125,6 +125,7 @@ void script_entry_delete(struct script_entry *entry)
assert(entry);
assert(entry->type == SCRIPT_VALUE_TYPE_SINGLE_WORD ||
+ entry->type == SCRIPT_VALUE_TYPE_STRING ||
entry->type == SCRIPT_VALUE_TYPE_NULL);
if (!list_empty(&entry->entries))
@@ -134,6 +135,9 @@ void script_entry_delete(struct script_entry *entry)
case SCRIPT_VALUE_TYPE_SINGLE_WORD:
container = container_of(entry, struct script_single_entry, entry);
break;
+ case SCRIPT_VALUE_TYPE_STRING:
+ container = container_of(entry, struct script_string_entry, entry);
+ break;
case SCRIPT_VALUE_TYPE_NULL:
container = container_of(entry, struct script_null_entry, entry);
break;
@@ -180,3 +184,26 @@ struct script_single_entry *script_single_entry_append(struct script *script,
return entry;
}
+
+struct script_string_entry *script_string_entry_append(struct script *script,
+ const char *name,
+ size_t l, const char *s)
+{
+ struct script_string_entry *entry;
+
+ assert(script);
+ assert(!list_empty(&script->sections));
+ assert(name && *name);
+ assert(s);
+
+ if ((entry = malloc(sizeof(*entry)+l+1))) {
+ entry->l = l;
+ memcpy(entry->string, s, l);
+ entry->string[l] = '\0';
+
+ script_entry_append(script, &entry->entry,
+ SCRIPT_VALUE_TYPE_STRING, name);
+ }
+
+ return entry;
+}