- char * f_name = "init_command_db_err";
- char * err_start = "Failed reading command config file at ";
- char * err_middle = " due to malformed line ";
- line_copy[strlen(line_copy) - 1] = '\0';
- char * err = try_malloc(strlen(err_start) + strlen(world.path_commands) +
- strlen(err_middle) + 3 + 2 + strlen(line_copy) + 1,
- f_name);
- sprintf(err, "%s%s%s%d: %s", err_start, world.path_commands, err_middle,
- line_number, line_copy);
- return err;
+ char * f_name = "tokens_into_entries()";
+ char * str_cmd = "COMMAND";
+ static uint8_t cmd_flags = READY_CMD;
+ static struct Command * cmd = NULL;
+ if (!token0 || !strcmp(token0, str_cmd))
+ {
+ finalize_by_readyflag(&cmd_flags, READY_CMD);
+ if (cmd)
+ {
+ array_append(world.commandDB.n, sizeof(struct Command),
+ (void *) cmd, (void **) &world.commandDB.cmds);
+ world.commandDB.n++;
+ free(cmd);
+ cmd = NULL;
+ }
+ }
+ err_line(token0 && NULL != token_from_line(NULL), "Too many values.");
+ if (token0 && !strcmp(token0, str_cmd))
+ {
+ char * err_uniq = "Declaration of ID already used.";
+ cmd_flags = EDIT_STARTED;
+ cmd = try_malloc(sizeof(struct Command), f_name);
+ memset(cmd, 0, sizeof(struct Command));
+ cmd->dsc_short = strdup(token1);
+ err_line(NULL != get_command(cmd->dsc_short), err_uniq);
+ }
+ else if ( token0
+ && !( set_val(token0, token1, "DESCRIPTION", &cmd_flags,
+ DESC_SET, 's', (char *) &cmd->dsc_long)
+ || set_val(token0, token1, "SERVER_COMMAND", &cmd_flags,
+ SERVERCMD_SET, 's', (char *) &cmd->server_msg)
+ || set_val(token0, token1, "SERVER_ARGUMENT", &cmd_flags,
+ SERVERARG_SET, 'c', (char *) &cmd->arg)))
+ {
+ err_line(1, "Unknown arguemnt.");
+ }