123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- /*
- * config.c
- *
- * This file provides the implementation of a config definition
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include <assert.h>
- #include <string.h>
- #include "lub/types.h"
- #include "lub/string.h"
- #include "private.h"
- /*---------------------------------------------------------
- * PRIVATE METHODS
- *--------------------------------------------------------- */
- static void clish_config_init(clish_config_t *this)
- {
- this->op = CLISH_CONFIG_NONE;
- this->priority = 0;
- this->pattern = NULL;
- this->file = NULL;
- this->splitter = BOOL_TRUE;
- this->seq = NULL;
- this->unique = BOOL_TRUE;
- this->depth = NULL;
- }
- /*--------------------------------------------------------- */
- static void clish_config_fini(clish_config_t *this)
- {
- lub_string_free(this->pattern);
- lub_string_free(this->file);
- lub_string_free(this->seq);
- lub_string_free(this->depth);
- }
- /*---------------------------------------------------------
- * PUBLIC META FUNCTIONS
- *--------------------------------------------------------- */
- clish_config_t *clish_config_new(void)
- {
- clish_config_t *this = malloc(sizeof(clish_config_t));
- if (this)
- clish_config_init(this);
- return this;
- }
- /*---------------------------------------------------------
- * PUBLIC METHODS
- *--------------------------------------------------------- */
- void clish_config_delete(clish_config_t *this)
- {
- clish_config_fini(this);
- free(this);
- }
- /*---------------------------------------------------------
- * PUBLIC ATTRIBUTES
- *--------------------------------------------------------- */
- void clish_config__set_op(clish_config_t *this, clish_config_op_t op)
- {
- this->op = op;
- }
- /*--------------------------------------------------------- */
- clish_config_op_t clish_config__get_op(const clish_config_t *this)
- {
- return this->op;
- }
- /*--------------------------------------------------------- */
- void clish_config__set_priority(clish_config_t *this, unsigned short priority)
- {
- this->priority = priority;
- }
- /*--------------------------------------------------------- */
- unsigned short clish_config__get_priority(const clish_config_t *this)
- {
- return this->priority;
- }
- /*--------------------------------------------------------- */
- void clish_config__set_pattern(clish_config_t *this, const char *pattern)
- {
- assert(!this->pattern);
- this->pattern = lub_string_dup(pattern);
- }
- /*--------------------------------------------------------- */
- char *clish_config__get_pattern(const clish_config_t *this)
- {
- return this->pattern;
- }
- /*--------------------------------------------------------- */
- void clish_config__set_file(clish_config_t *this, const char *file)
- {
- assert(!this->file);
- this->file = lub_string_dup(file);
- }
- /*--------------------------------------------------------- */
- char *clish_config__get_file(const clish_config_t *this)
- {
- return this->file;
- }
- /*--------------------------------------------------------- */
- bool_t clish_config__get_splitter(const clish_config_t *this)
- {
- return this->splitter;
- }
- /*--------------------------------------------------------- */
- void clish_config__set_splitter(clish_config_t *this, bool_t splitter)
- {
- this->splitter = splitter;
- }
- /*--------------------------------------------------------- */
- void clish_config__set_seq(clish_config_t *this, const char *seq)
- {
- assert(!this->seq);
- this->seq = lub_string_dup(seq);
- }
- /*--------------------------------------------------------- */
- const char *clish_config__get_seq(const clish_config_t *this)
- {
- return this->seq;
- }
- /*--------------------------------------------------------- */
- bool_t clish_config__get_unique(const clish_config_t *this)
- {
- return this->unique;
- }
- /*--------------------------------------------------------- */
- void clish_config__set_unique(clish_config_t *this, bool_t unique)
- {
- this->unique = unique;
- }
- /*--------------------------------------------------------- */
- void clish_config__set_depth(clish_config_t *this, const char *depth)
- {
- assert(!this->depth);
- this->depth = lub_string_dup(depth);
- }
- /*--------------------------------------------------------- */
- const char *clish_config__get_depth(const clish_config_t *this)
- {
- return this->depth;
- }
|