_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cmd.cpp File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "stratagus.h"
#include "cmd.h"
#include "netdriver.h"
#include "db.h"
#include "games.h"

cmd.cpp - Client/Server Command Interpreter.

#define GetNextArg(buf, arg)
 
#define GetLastArg(buf, arg)
 
#define GetNextAndOptionalArg(buf, arg1, arg2)
 
#define SkipSpaces(buf)
 
#define CheckExtraParameter(buf)
 
static int Parse1Arg (char *buf, char **arg1)
 
static int Parse1or2Args (char *buf, char **arg1, char **arg2)
 
static int Parse4Args (char *buf, char **arg1, char **arg2, char **arg3, char **arg4)
 
static int Parse5or6Args (char *buf, char **arg1, char **arg2, char **arg3, char **arg4, char **arg5, char **arg6)
 
static void ParsePing (Session *session)
 
static void ParseUser (Session *session, char *buf)
 
static void ParseRegister (Session *session, char *buf)
 
static void ParseCreateGame (Session *session, char *buf)
 
static void ParseCancelGame (Session *session, char *buf)
 
static void ParseStartGame (Session *session, char *buf)
 
static void ParseListGames (Session *session, char *buf)
 
static void ParseJoinGame (Session *session, char *buf)
 
static void ParsePartGame (Session *session, char *buf)
 
static void ParseEndGame (Session *session, char *buf)
 
static void ParseMsg (Session *session, char *buf)
 
static void ParseBuffer (Session *session)
 
int UpdateParser (void)
 

Macro Definition Documentation

#define CheckExtraParameter (   buf)
Value:
do { \
if (*buf) { \
while (*buf == ' ') ++buf; \
if (*buf) return 1; \
} \
} while (0)
#define GetLastArg (   buf,
  arg 
)
Value:
do { \
if (*buf == '\"') { \
*arg = ++buf; \
while (*buf != '\"' && *buf) ++buf; \
if (*buf != '\"') return 1; \
*buf++ = '\0'; \
if (**arg == '\0') return 1; \
if (*buf != ' ' && *buf) return 1; \
} else { \
*arg = buf; \
while (*buf != ' ' && *buf) ++buf; \
} \
} while (0)
#define GetNextAndOptionalArg (   buf,
  arg1,
  arg2 
)
Value:
do { \
if (*buf == '\"') { \
*arg1 = ++buf; \
while (*buf != '\"' && *buf) ++buf; \
if (*buf != '\"') return 1; \
*buf++ = '\0'; \
if (**arg1 == '\0') return 1; \
if (*buf != ' ' && *buf) return 1; \
} else { \
*arg1 = buf; \
while (*buf != ' ' && *buf) ++buf; \
} \
if (*buf == ' ') *buf++ = '\0'; \
\
*arg2 = NULL; \
while (*buf == ' ') ++buf; \
if (!*buf) return 0; \
\
GetLastArg(buf, arg2); \
} while (0)
#define GetLastArg(buf, arg)
Definition: cmd.cpp:67
#define GetNextArg (   buf,
  arg 
)
Value:
do { \
if (*buf == '\"') { \
*arg = ++buf; \
while (*buf != '\"' && *buf) ++buf; \
if (*buf != '\"') return 1; \
*buf++ = '\0'; \
if (**arg == '\0') return 1; \
if (*buf != ' ') return 1; \
} else { \
*arg = buf; \
while (*buf != ' ' && *buf) ++buf; \
if (!*buf) return 1; \
} \
*buf++ = '\0'; \
} while (0)
#define SkipSpaces (   buf)
Value:
do { \
while (*buf == ' ') ++buf; \
if (!*buf) return 1; \
} while (0)

Function Documentation

static int Parse1Arg ( char *  buf,
char **  arg1 
)
static
static int Parse1or2Args ( char *  buf,
char **  arg1,
char **  arg2 
)
static
static int Parse4Args ( char *  buf,
char **  arg1,
char **  arg2,
char **  arg3,
char **  arg4 
)
static
static int Parse5or6Args ( char *  buf,
char **  arg1,
char **  arg2,
char **  arg3,
char **  arg4,
char **  arg5,
char **  arg6 
)
static
static void ParseBuffer ( Session session)
static

ParseBuffer: Handler client/server interaction.

Parameters
sessionCurrent session.
static void ParseCancelGame ( Session session,
char *  buf 
)
static

Parse CANCELGAME

static void ParseCreateGame ( Session session,
char *  buf 
)
static

Parse CREATEGAME

static void ParseEndGame ( Session session,
char *  buf 
)
static

Parse ENDGAME

static void ParseJoinGame ( Session session,
char *  buf 
)
static

Parse JOINGAME

static void ParseListGames ( Session session,
char *  buf 
)
static

Parse LISTGAMES

static void ParseMsg ( Session session,
char *  buf 
)
static

Parse MSG

static void ParsePartGame ( Session session,
char *  buf 
)
static

Parse PARTGAME

static void ParsePing ( Session session)
static

Parse PING

static void ParseRegister ( Session session,
char *  buf 
)
static

Parse REGISTER

static void ParseStartGame ( Session session,
char *  buf 
)
static

Parse STARTGAME

static void ParseUser ( Session session,
char *  buf 
)
static

Parse USER

int UpdateParser ( void  )

Parse all session buffers

(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.