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

added psyc operator defs

This commit is contained in:
tg(x) 2011-11-09 19:01:05 +01:00
parent 940a18572c
commit 4b31a16ad6
10 changed files with 32 additions and 21 deletions

View file

@ -32,6 +32,7 @@
#define PSYC_NUM_ELEM(a) (sizeof(a) / sizeof(*(a))) #define PSYC_NUM_ELEM(a) (sizeof(a) / sizeof(*(a)))
/// Boolean: true/false, yes/no.
typedef enum typedef enum
{ {
PSYC_FALSE = 0, PSYC_FALSE = 0,
@ -40,15 +41,14 @@ typedef enum
PSYC_YES = 1, PSYC_YES = 1,
} PsycBool; } PsycBool;
/// Return code: OK/error.
typedef enum typedef enum
{ {
PSYC_OK = 1, PSYC_OK = 1,
PSYC_ERROR = -1, PSYC_ERROR = -1,
} PsycRC; } PsycRC;
/** /// PSYC packet parts.
* PSYC packet parts.
*/
typedef enum typedef enum
{ {
PSYC_PART_RESET = -1, PSYC_PART_RESET = -1,

View file

@ -54,6 +54,15 @@ typedef enum
PSYC_PACKET_NO_LENGTH = 2, PSYC_PACKET_NO_LENGTH = 2,
} PsycPacketFlag; } PsycPacketFlag;
typedef enum
{
PSYC_OPERATOR_SET = ':',
PSYC_OPERATOR_ASSIGN = '=',
PSYC_OPERATOR_AUGMENT = '+',
PSYC_OPERATOR_DIMINISH = '-',
PSYC_OPERATOR_QUERY = '?',
} PsycOperator;
/** Structure for a modifier. */ /** Structure for a modifier. */
typedef struct typedef struct
{ {

View file

@ -121,7 +121,7 @@ PIKEFUN string render(mapping rvars, mapping evars, string method, string|void b
struct keypair *k; // for mappings struct keypair *k; // for mappings
INT32 e; INT32 e;
char oper = C_GLYPH_OPERATOR_SET; char oper = PSYC_OPERATOR_SET;
// fill headers // fill headers
rheaders.lines = 0; rheaders.lines = 0;

View file

@ -92,8 +92,8 @@ int main (int argc, char **argv) {
CASE_v CASE_S CASE_P CASE_v CASE_S CASE_P
case 'h': case 'h':
printf( printf(
HELP_FILE("testJson", "mnqSsvP") HELP_FILE("test_json", "mnqSsvP")
HELP_PORT("testJson", "nqsvP") HELP_PORT("test_json", "nqsvP")
HELP_f HELP_p HELP_b HELP_c HELP_f HELP_p HELP_b HELP_c
HELP_m HELP_n HELP_q HELP_S HELP_m HELP_n HELP_q HELP_S
HELP_s HELP_v HELP_P HELP_h, HELP_s HELP_v HELP_P HELP_h,

View file

@ -78,8 +78,8 @@ int main (int argc, char **argv) {
CASE_s CASE_v CASE_P CASE_s CASE_v CASE_P
case 'h': case 'h':
printf( printf(
HELP_FILE("testJsonGlib", "mnqSsvP") HELP_FILE("test_json_glib", "mnqSsvP")
HELP_PORT("testJsonGlib", "nqsvP") HELP_PORT("test_json_glib", "nqsvP")
HELP_f HELP_p HELP_b HELP_c HELP_f HELP_p HELP_b HELP_c
HELP_m HELP_n HELP_q HELP_S HELP_m HELP_n HELP_q HELP_S
HELP_s HELP_v HELP_P HELP_h, HELP_s HELP_v HELP_P HELP_h,

View file

@ -326,8 +326,8 @@ int main (int argc, char **argv) {
CASE_s CASE_v CASE_S CASE_P CASE_s CASE_v CASE_S CASE_P
case 'h': case 'h':
printf( printf(
HELP_FILE("testPsyc", "mnqrSsvP") HELP_FILE("test_psyc", "mnqrSsvP")
HELP_PORT("testPsyc", "nqrsvP") HELP_PORT("test_psyc", "nqrsvP")
HELP_f HELP_p HELP_b HELP_c HELP_f HELP_p HELP_b HELP_c
HELP_m HELP_n HELP_r HELP_m HELP_n HELP_r
HELP_q HELP_S HELP_s HELP_q HELP_S HELP_s

View file

@ -52,8 +52,8 @@ int main (int argc, char **argv) {
CASE_r CASE_s CASE_r CASE_s
case 'h': case 'h':
printf( printf(
HELP_FILE("testPsycSpeed", "rs") HELP_FILE("test_psyc_speed", "rs")
HELP_PORT("testPsycSpeed", "rs") HELP_PORT("test_psyc_speed", "rs")
HELP_f HELP_p HELP_b HELP_c HELP_f HELP_p HELP_b HELP_c
HELP_r HELP_s HELP_h, HELP_r HELP_s HELP_h,
port, RECV_BUF_SIZE); port, RECV_BUF_SIZE);

View file

@ -12,16 +12,16 @@ int testPresence (const char *avail, int availlen,
const char *rendered, uint8_t verbose) const char *rendered, uint8_t verbose)
{ {
PsycModifier routing[1]; PsycModifier routing[1];
psyc_modifier_init(&routing[0], C_GLYPH_OPERATOR_SET, psyc_modifier_init(&routing[0], PSYC_OPERATOR_SET,
PSYC_C2ARG("_context"), PSYC_C2ARG("_context"),
PSYC_C2ARG(myUNI), PSYC_MODIFIER_ROUTING); PSYC_C2ARG(myUNI), PSYC_MODIFIER_ROUTING);
PsycModifier entity[2]; PsycModifier entity[2];
// presence is to be assigned permanently in distributed state // presence is to be assigned permanently in distributed state
psyc_modifier_init(&entity[0], C_GLYPH_OPERATOR_ASSIGN, psyc_modifier_init(&entity[0], PSYC_OPERATOR_ASSIGN,
PSYC_C2ARG("_degree_availability"), PSYC_C2ARG("_degree_availability"),
avail, availlen, PSYC_MODIFIER_CHECK_LENGTH); avail, availlen, PSYC_MODIFIER_CHECK_LENGTH);
psyc_modifier_init(&entity[1], C_GLYPH_OPERATOR_ASSIGN, psyc_modifier_init(&entity[1], PSYC_OPERATOR_ASSIGN,
PSYC_C2ARG("_description_presence"), PSYC_C2ARG("_description_presence"),
desc, desclen, PSYC_MODIFIER_CHECK_LENGTH); desc, desclen, PSYC_MODIFIER_CHECK_LENGTH);
@ -42,10 +42,10 @@ int testPresence (const char *avail, int availlen,
int testList (const char *rendered, uint8_t verbose) int testList (const char *rendered, uint8_t verbose)
{ {
PsycModifier routing[2]; PsycModifier routing[2];
psyc_modifier_init(&routing[0], C_GLYPH_OPERATOR_SET, psyc_modifier_init(&routing[0], PSYC_OPERATOR_SET,
PSYC_C2ARG("_source"), PSYC_C2ARG("_source"),
PSYC_C2ARG(myUNI), PSYC_MODIFIER_ROUTING); PSYC_C2ARG(myUNI), PSYC_MODIFIER_ROUTING);
psyc_modifier_init(&routing[1], C_GLYPH_OPERATOR_SET, psyc_modifier_init(&routing[1], PSYC_OPERATOR_SET,
PSYC_C2ARG("_context"), PSYC_C2ARG("_context"),
PSYC_C2ARG(myUNI), PSYC_MODIFIER_ROUTING); PSYC_C2ARG(myUNI), PSYC_MODIFIER_ROUTING);
@ -70,10 +70,10 @@ int testList (const char *rendered, uint8_t verbose)
psyc_render_list(&list_bin, buf_bin, sizeof(buf_bin)); psyc_render_list(&list_bin, buf_bin, sizeof(buf_bin));
PsycModifier entity[2]; PsycModifier entity[2];
psyc_modifier_init(&entity[0], C_GLYPH_OPERATOR_SET, psyc_modifier_init(&entity[0], PSYC_OPERATOR_SET,
PSYC_C2ARG("_list_text"), PSYC_C2ARG("_list_text"),
buf_text, list_text.length, list_text.flag); buf_text, list_text.length, list_text.flag);
psyc_modifier_init(&entity[1], C_GLYPH_OPERATOR_SET, psyc_modifier_init(&entity[1], PSYC_OPERATOR_SET,
PSYC_C2ARG("_list_binary"), PSYC_C2ARG("_list_binary"),
buf_bin, list_bin.length, list_bin.flag); buf_bin, list_bin.length, list_bin.flag);

View file

@ -44,8 +44,8 @@ int main (int argc, char **argv) {
CASE_s CASE_s
case 'h': case 'h':
printf( printf(
HELP_FILE("testStrlen", "s") HELP_FILE("test_strlen", "s")
HELP_PORT("testStrlen", "s") HELP_PORT("test_strlen", "s")
HELP_f HELP_p HELP_b HELP_c HELP_f HELP_p HELP_b HELP_c
HELP_s HELP_h, HELP_s HELP_h,
port, RECV_BUF_SIZE); port, RECV_BUF_SIZE);

View file

@ -35,6 +35,8 @@ int main () {
testUniform("psyc://foo:4405/~bar", PSYC_SCHEME_PSYC); testUniform("psyc://foo:4405/~bar", PSYC_SCHEME_PSYC);
testUniform("psyc://foo:1234", PSYC_SCHEME_PSYC); testUniform("psyc://foo:1234", PSYC_SCHEME_PSYC);
testUniform("psyc://foo:1234d", PSYC_SCHEME_PSYC); testUniform("psyc://foo:1234d", PSYC_SCHEME_PSYC);
testUniform("psyc://foo:-1234", PSYC_SCHEME_PSYC);
testUniform("psyc://foo:-1234d", PSYC_SCHEME_PSYC);
testUniform("psyc://foo/", PSYC_SCHEME_PSYC); testUniform("psyc://foo/", PSYC_SCHEME_PSYC);
testUniform("psyc://foo", PSYC_SCHEME_PSYC); testUniform("psyc://foo", PSYC_SCHEME_PSYC);
testUniform("psyc://1234567890abcdef:g/~foo", PSYC_SCHEME_PSYC); testUniform("psyc://1234567890abcdef:g/~foo", PSYC_SCHEME_PSYC);