summaryrefslogtreecommitdiffstats
path: root/tinyDEMO/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'tinyDEMO/cmd.c')
-rwxr-xr-xtinyDEMO/cmd.c114
1 files changed, 56 insertions, 58 deletions
diff --git a/tinyDEMO/cmd.c b/tinyDEMO/cmd.c
index a2d6c89..7daf91a 100755
--- a/tinyDEMO/cmd.c
+++ b/tinyDEMO/cmd.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -33,15 +33,15 @@ static int pred_find_opt_by_type(const tsk_list_item_t *item, const void *type);
/* parse a command line */
cmd_t* cmd_parse(const char* buffer, tsk_size_t size, tsk_bool_t *comment, tsk_params_L_t* params)
-{
- return dssl_parse(buffer, size, comment, params);
+{
+ return dssl_parse(buffer, size, comment, params);
}
///* print usage */
void cmd_print_help()
{
- printf("\n\n========================= Usage =========================\n\n");
- printf("Please refer to the Programmer's Guide at\n http://www.doubango.org/\n\n");
+ printf("\n\n========================= Usage =========================\n\n");
+ printf("Please refer to the Programmer's Guide at\n http://www.doubango.org/\n\n");
//
// printf("Usage:\n");
@@ -71,89 +71,87 @@ void cmd_print_help()
cmd_t* cmd_create(cmd_type_t type)
{
- return tsk_object_new(cmd_def_t, type);
+ return tsk_object_new(cmd_def_t, type);
}
static tsk_object_t* cmd_ctor(tsk_object_t * self, va_list * app)
{
- cmd_t *cmd = self;
- if(cmd){
- cmd->type = va_arg(*app, cmd_type_t);
- cmd->opts = tsk_list_create();
- }
- return self;
+ cmd_t *cmd = self;
+ if(cmd) {
+ cmd->type = va_arg(*app, cmd_type_t);
+ cmd->opts = tsk_list_create();
+ }
+ return self;
}
static tsk_object_t* cmd_dtor(tsk_object_t * self)
-{
- cmd_t *cmd = self;
- if(cmd){
- TSK_OBJECT_SAFE_FREE(cmd->opts);
- TSK_FREE(cmd->sidparam);
- }
-
- return self;
+{
+ cmd_t *cmd = self;
+ if(cmd) {
+ TSK_OBJECT_SAFE_FREE(cmd->opts);
+ TSK_FREE(cmd->sidparam);
+ }
+
+ return self;
}
-static const tsk_object_def_t cmd_def_s =
-{
- sizeof(cmd_t),
- cmd_ctor,
- cmd_dtor,
- tsk_null,
+static const tsk_object_def_t cmd_def_s = {
+ sizeof(cmd_t),
+ cmd_ctor,
+ cmd_dtor,
+ tsk_null,
};
const tsk_object_def_t *cmd_def_t = &cmd_def_s;
opt_t* opt_create(opt_type_t type, lv_t level, const char* value)
{
- return tsk_object_new(opt_def_t, type, level, value);
+ return tsk_object_new(opt_def_t, type, level, value);
}
const opt_t* opt_get_by_type(const opts_L_t* opts, opt_type_t type)
{
- const tsk_list_item_t* item;
- if((item = tsk_list_find_item_by_pred(opts, pred_find_opt_by_type, &type))){
- return item->data;
- }
- return tsk_null;
+ const tsk_list_item_t* item;
+ if((item = tsk_list_find_item_by_pred(opts, pred_find_opt_by_type, &type))) {
+ return item->data;
+ }
+ return tsk_null;
}
static int pred_find_opt_by_type(const tsk_list_item_t *item, const void *type)
{
- if(item && item->data){
- opt_t *opt = item->data;
- return (opt->type - *((opt_type_t*)type));
- }
- return -1;
+ if(item && item->data) {
+ opt_t *opt = item->data;
+ return (opt->type - *((opt_type_t*)type));
+ }
+ return -1;
}
static tsk_object_t* opt_ctor(tsk_object_t * self, va_list * app)
{
- opt_t *opt = self;
- if(opt){
- opt->type = va_arg(*app, opt_type_t);
- opt->lv = va_arg(*app, lv_t);
- opt->value = tsk_strdup(va_arg(*app, const char*));
- }
- return self;
+ opt_t *opt = self;
+ if(opt) {
+ opt->type = va_arg(*app, opt_type_t);
+ opt->lv = va_arg(*app, lv_t);
+ opt->value = tsk_strdup(va_arg(*app, const char*));
+ }
+ return self;
}
static tsk_object_t* opt_dtor(tsk_object_t * self)
-{
- opt_t *opt = self;
- if(opt){
- TSK_FREE(opt->value);
- }
+{
+ opt_t *opt = self;
+ if(opt) {
+ TSK_FREE(opt->value);
+ }
- return self;
+ return self;
}
-static const tsk_object_def_t opt_def_s =
-{
- sizeof(opt_t),
- opt_ctor,
- opt_dtor,
- tsk_null,
+static const tsk_object_def_t opt_def_s = {
+ sizeof(opt_t),
+ opt_ctor,
+ opt_dtor,
+ tsk_null,
};
const tsk_object_def_t *opt_def_t = &opt_def_s;
OpenPOWER on IntegriCloud