2011-05-08 22:15:03 +00:00
|
|
|
/** @file d/psyc/common.d
|
2011-04-30 12:30:01 +00:00
|
|
|
*
|
|
|
|
* @brief Main PSYC interface providing crucial functionality.
|
|
|
|
*/
|
|
|
|
|
2011-05-08 22:15:03 +00:00
|
|
|
|
2011-04-30 12:30:01 +00:00
|
|
|
|
2011-04-30 12:39:04 +00:00
|
|
|
module psyc.common;
|
|
|
|
|
|
|
|
const EPOCH = 1440444041; // 2015-08-24 21:20:41 CET (Monday)
|
2011-04-30 12:30:01 +00:00
|
|
|
|
|
|
|
extern (C):
|
|
|
|
|
|
|
|
enum Bool
|
|
|
|
{
|
|
|
|
FALSE = 0,
|
|
|
|
TRUE = 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PSYC packet parts.
|
|
|
|
*/
|
|
|
|
enum Part
|
|
|
|
{
|
2011-05-08 22:15:03 +00:00
|
|
|
RESET = -1,
|
|
|
|
ROUTING = 0,
|
|
|
|
LENGTH = 1,
|
|
|
|
CONTENT = 2,
|
|
|
|
METHOD = 3,
|
|
|
|
DATA = 4,
|
|
|
|
END = 5,
|
2011-04-30 12:30:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Different types that a variable can have.
|
|
|
|
*
|
|
|
|
* This enum lists PSYC variable types that
|
|
|
|
* this library is capable of checking for
|
|
|
|
* validity. Other variable types are treated
|
|
|
|
* as opaque data.
|
|
|
|
*/
|
|
|
|
enum Type
|
|
|
|
{
|
2011-05-08 22:15:03 +00:00
|
|
|
UNKNOWN,
|
|
|
|
AMOUNT,
|
|
|
|
COLOR,
|
|
|
|
DATE,
|
|
|
|
DEGREE,
|
|
|
|
ENTITY,
|
|
|
|
FLAG,
|
|
|
|
LANGUAGE,
|
|
|
|
LIST,
|
|
|
|
NICK,
|
|
|
|
PAGE,
|
|
|
|
UNIFORM,
|
|
|
|
TIME,
|
2011-04-30 12:30:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List types.
|
|
|
|
* Possible types are text and binary.
|
|
|
|
*/
|
|
|
|
enum ListType
|
|
|
|
{
|
|
|
|
LIST_TEXT = 1,
|
|
|
|
LIST_BINARY = 2,
|
|
|
|
}
|
|
|
|
|
2011-06-12 11:13:17 +00:00
|
|
|
/+
|
2011-04-30 12:30:01 +00:00
|
|
|
struct String
|
|
|
|
{
|
|
|
|
size_t length;
|
2011-05-08 22:15:03 +00:00
|
|
|
ubyte *ptr;
|
2011-06-12 11:13:17 +00:00
|
|
|
}+/
|
|
|
|
|
|
|
|
alias char[] String;
|
2011-04-30 12:30:01 +00:00
|
|
|
|
|
|
|
struct MatchVar
|
|
|
|
{
|
|
|
|
String name;
|
|
|
|
int value;
|
|
|
|
}
|
|
|
|
|
2011-05-08 22:15:03 +00:00
|
|
|
int psyc_version()
|
2011-04-30 12:30:01 +00:00
|
|
|
{
|
2011-05-08 22:15:03 +00:00
|
|
|
return 1;
|
2011-04-30 12:30:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Routing vars in alphabetical order.
|
|
|
|
extern (C) String routingVars[];
|
|
|
|
extern (C) MatchVar varTypes[];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the type of variable name.
|
|
|
|
*/
|
2011-05-15 22:01:13 +00:00
|
|
|
Bool psyc_isRoutingVar(char *name, size_t len);
|
|
|
|
|
|
|
|
alias psyc_isRoutingVar isRoutingVar;
|
2011-04-30 12:30:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the type of variable name.
|
|
|
|
*/
|
2011-05-15 22:01:13 +00:00
|
|
|
Type psyc_getVarType(char *name, size_t len);
|
|
|
|
|
|
|
|
alias psyc_getVarType getVarType;
|
2011-04-30 12:30:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if long keyword string inherits from short keyword string.
|
|
|
|
*/
|
|
|
|
int inherits(char *sho, size_t slen,
|
2011-05-08 22:15:03 +00:00
|
|
|
char *lon, size_t llen);
|
2011-04-30 12:30:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if short keyword string matches long keyword string.
|
|
|
|
*/
|
|
|
|
int matches(char *sho, size_t slen,
|
2011-05-08 22:15:03 +00:00
|
|
|
char *lon, size_t llen);
|
2011-04-30 12:30:01 +00:00
|
|
|
|
|
|
|
|