/* Simple tokeniser V1.13 3/06/07
   Copyright 2008 Jeffrey Lee
   This file is part of WOUM.
   WOUM 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.
   WOUM 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 WOUM.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _STOK_H
#define _STOK_H

#include "fixmath.h"

extern int stok_flags; /* Flags to show which tokens were detected */

#define STOK_STRING 1
#define STOK_INT 2
#define STOK_FLOAT 4
#define STOK_F1616 8
#define STOK_NEWLINE 16
#define STOK_QUOTED 32

#define STOK_STRLEN_MAX 256

extern char stok_string[STOK_STRLEN_MAX]; /* String read in */
extern int stok_strlen; /* Length of string (handy if it can contain null chars) */
extern int stok_int; /* Int value */
extern float stok_float; /* Float value */
extern f1616 stok_f1616; /* f1616 value */

extern char stok_esc; /* Escape char to use, 0 for none */

extern char *stok_skipws(char *s);
/* Skip any whitespace characters in s, and return a pointer to the next
   non-whitespace char */

extern char *stok_tok(char *s);
/* Get a token from s, storing it in the stok_* vars.
   Returns the pointer to the char after the token, or 0 for an error
   All control chars are skipped (bar newlines of CR-LF, CR, LF and LF-CR varieties)
   Handles quoted strings and escaped chars, as well as 0x... format hex numbers
   Returns s if at the end of the string */

#endif
