Blame packet/cmdparse.h

Packit b802ec
/*
Packit b802ec
    mtr  --  a network diagnostic tool
Packit b802ec
    Copyright (C) 2016  Matt Kimball
Packit b802ec
Packit b802ec
    This program is free software; you can redistribute it and/or modify
Packit b802ec
    it under the terms of the GNU General Public License version 2 as
Packit b802ec
    published by the Free Software Foundation.
Packit b802ec
Packit b802ec
    This program is distributed in the hope that it will be useful,
Packit b802ec
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b802ec
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit b802ec
    GNU General Public License for more details.
Packit b802ec
Packit b802ec
    You should have received a copy of the GNU General Public License
Packit b802ec
    along with this program; if not, write to the Free Software
Packit b802ec
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit b802ec
*/
Packit b802ec
Packit b802ec
#ifndef CMDPARSE_H
Packit b802ec
#define CMDPARSE_H
Packit b802ec
Packit b802ec
enum {
Packit b802ec
    MAX_COMMAND_ARGUMENTS = 16,
Packit b802ec
    MAX_COMMAND_TOKENS = MAX_COMMAND_ARGUMENTS * 2 + 2
Packit b802ec
};
Packit b802ec
Packit b802ec
/*  Parsed commands, or command replies, ready for semantic interpretation  */
Packit b802ec
struct command_t {
Packit b802ec
    /*  A unique value for matching command requests with replies  */
Packit b802ec
    int token;
Packit b802ec
Packit b802ec
    /*  Text indiciating the command type, or reply type  */
Packit b802ec
    char *command_name;
Packit b802ec
Packit b802ec
    /*  The number of key, value argument pairs used  */
Packit b802ec
    int argument_count;
Packit b802ec
Packit b802ec
    /*  Names for each argument  */
Packit b802ec
    char *argument_name[MAX_COMMAND_ARGUMENTS];
Packit b802ec
Packit b802ec
    /*  Values for each argument, parallel to the argument_name array  */
Packit b802ec
    char *argument_value[MAX_COMMAND_ARGUMENTS];
Packit b802ec
};
Packit b802ec
Packit b802ec
int parse_command(
Packit b802ec
    struct command_t *command,
Packit b802ec
    char *command_string);
Packit b802ec
Packit b802ec
#endif