1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00
libpsyc/d/include/psyc/common.d

127 lines
1.7 KiB
D
Raw Normal View History

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
2011-04-30 12:30:01 +00:00
{
FALSE = 0,
TRUE = 1,
}+/
alias bool Bool;
static const FALSE = false;
static const TRUE = true;
2011-04-30 12:30:01 +00:00
/**
* 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 ubyte[] 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-10-31 19:04:16 +00:00
Bool psyc_var_is_routing (char* name, size_t len);
2011-05-15 22:01:13 +00:00
bool isRoutingVar (char[] name)
{
2011-11-01 11:06:58 +00:00
return psyc_var_is_routing(name.data, name.length); //FIXME
}
2011-04-30 12:30:01 +00:00
/**
* Get the type of variable name.
*/
2011-10-31 19:04:16 +00:00
Type psyc_var_type(char *name, size_t len);
2011-05-15 22:01:13 +00:00
2011-10-31 19:04:16 +00:00
alias psyc_var_type 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