From f7dcb2eb8928aa3b384f30f6485fa4ade90f4c2e Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Wed, 27 Apr 2011 00:19:55 +0200 Subject: [PATCH] allow null methods and bodies --- src/pkg-psyc.c | 26 ++++++++++++++++++++++---- src/version.sh | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/pkg-psyc.c b/src/pkg-psyc.c index c795bbd..d7c7f23 100644 --- a/src/pkg-psyc.c +++ b/src/pkg-psyc.c @@ -42,14 +42,17 @@ f_psyc_render(svalue_t *sp) { vector_t *v; psycPacket packet; string_t *out; + char *meth, *body; + int mlen, blen; // unless (sp->type == T_POINTER) return sp; v = sp->u.vec; - if ((i = (mp_int)VEC_SIZE(v)) != 4) { + if ((i = (mp_int)VEC_SIZE(v)) != 1+PSYC_BODY) { errorf("Wrong number of elements (%"PRIdMPINT") in array argument to psyc_render()\n", i); /* NOTREACHED */ return sp; } +#if 0 if (v->item[PSYC_METHOD].type != T_STRING) { errorf("Wrong type for PSYC_METHOD element in PSYC packet.\n"); /* NOTREACHED */ @@ -60,11 +63,26 @@ f_psyc_render(svalue_t *sp) { /* NOTREACHED */ return sp; } +#else + if (v->item[PSYC_METHOD].type == T_STRING) { + meth = get_txt(v->item[PSYC_METHOD].u.str); + mlen = mstrsize(v->item[PSYC_METHOD].u.str); + } else { + meth = NULL; + mlen = 0; + } + if (v->item[PSYC_BODY].type == T_STRING) { + body = get_txt(v->item[PSYC_BODY].u.str); + blen = mstrsize(v->item[PSYC_BODY].u.str); + } else { + body = NULL; + blen = 0; + } +#endif + // TODO: handle _lists // FIXME: handle mappings packet = psyc_newPacket2(NULL, 0, NULL, 0, - get_txt(v->item[PSYC_METHOD].u.str), mstrsize(v->item[PSYC_METHOD].u.str), - // this should be an int* when "binary".. TODO - get_txt(v->item[PSYC_BODY].u.str), mstrsize(v->item[PSYC_BODY].u.str), + meth, mlen, body, blen, PSYC_PACKET_CHECK_LENGTH); printf("rendering... packet.length = %d\n", packet.length); diff --git a/src/version.sh b/src/version.sh index 046fcaf..cd4487a 100644 --- a/src/version.sh +++ b/src/version.sh @@ -17,7 +17,7 @@ version_longtype="stable" # A timestamp, to be used by bumpversion and other scripts. # It can be used, for example, to 'touch' this file on every build, thus # forcing revision control systems to add it on every checkin automatically. -version_stamp="Tue Apr 26 22:00:17 CEST 2011" +version_stamp="Wed Apr 27 00:18:40 CEST 2011" # Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x version_major=4