Merge remote-tracking branch 'origin'

This commit is contained in:
psyc://psyced.org/~lynX 2013-09-04 19:32:38 +02:00
commit 658f67290e
9 changed files with 143 additions and 104 deletions

8
FAQ
View File

@ -20,3 +20,11 @@ Why our own derivate of the LDMud?
It should still be possible to run psyced with an off-the-mill ldmud and It should still be possible to run psyced with an off-the-mill ldmud and
counterwise run a MUD installation with a psyclpc. counterwise run a MUD installation with a psyclpc.
=============================================================================== ===============================================================================
Why is ERQ crashing?
- erq doesn't conform to fortify code safety standards. this is ugly and
should be fixed but it is okay to just turn off fortify because erq is
fed exclusively with sanitized data from psyced, so buffer overruns are
possible but only theoretical.

15
INSTALL
View File

@ -95,20 +95,13 @@ Unix or Unix-like system
install-headers: install the driver header files in ${includedir}. install-headers: install the driver header files in ${includedir}.
install-all: compile and install everything. install-all: compile and install everything.
To actually run this, you need either psyced or a mudlib. To actually use psyclpc, you need either psyced or a mudlib.
pthreads: Debian/Ubuntu Linux:
If your systems supports pthreads, --enable-use-pthreads will allow to apt-get install libssl-dev libidn11-dev libpcre3 bison autoconf
compile the driver with pthread support. Currently this means that
background threads will be used to write data to the network.
WARNING: pthreads support is still experimental and might crash
your driver!
FreeBSD: FreeBSD:
When using gcc, it could happen that the compiler aborts with signal 10 ...
or 11. The reasons are unknown, but you can restart the compilation
process by typing "make" again (and again...).
AIX 3.4: AIX 3.4:
The native compiler comes in several forms, of which only the The native compiler comes in several forms, of which only the

13
TODO
View File

@ -1,8 +1,16 @@
FROM LDMUD FROM LDMUD
+ we are glad to find out that Lars is back and working on ldmud! :D - ldmud has made quite some progress, although not exactly in the areas
- examine & apply: 2320, 2334, 2335, 2336, 2340, 2341 that we are active in. syncing with ldmud is a good idea.
BUGS BUGS
- erq doesn't conform to fortify code safety standards. this is ugly and
should be fixed but it is okay to just turn off fortify because erq is
fed exclusively with sanitized data from psyced, so buffer overruns are
possible but only theoretical.
- configure should warn more vehemently when libidn is missing
- libpsyc isnt recognized even if properly installed
- x86_64 seems to require -ldl explicitly at the end of libs
- sometimes -lpsyc and -lpcre are added twice to $LIBS !?
- should autoconf to sysmalloc also for osol (OpenSolaris) - should autoconf to sysmalloc also for osol (OpenSolaris)
- #define USE_EXPAT und JSON werden trotzdem gesetzt in config.h - #define USE_EXPAT und JSON werden trotzdem gesetzt in config.h
auch wenn configure keine libs gefunden hat (egal, wir verwenden beide nicht) auch wenn configure keine libs gefunden hat (egal, wir verwenden beide nicht)
@ -75,6 +83,7 @@ NETWORKING
- add_message("%s", "\n*** Text lost in transmission ***\n"); - add_message("%s", "\n*** Text lost in transmission ***\n");
should be passed to master instead. should be passed to master instead.
+ _length: <eL> somebody implement a new input_to(#'get_data, length). + _length: <eL> somebody implement a new input_to(#'get_data, length).
? replace ERQ with c-ares http://c-ares.haxx.se/ for async dns lookups
? MAYBE the whole networking should be replaced by libevent!?? ? MAYBE the whole networking should be replaced by libevent!??
+ support epoll() / kqueue (or just libevent?) + support epoll() / kqueue (or just libevent?)

View File

@ -84,9 +84,11 @@ SFMT_FLAGS = -fno-strict-aliasing
# #
MPATH=-DMUD_LIB='"$(MUD_LIB)"' -DBINDIR='"$(BINDIR)"' -DERQ_DIR='"$(ERQ_DIR)"' MPATH=-DMUD_LIB='"$(MUD_LIB)"' -DBINDIR='"$(BINDIR)"' -DERQ_DIR='"$(ERQ_DIR)"'
# #
# would be nicer to have this idn include in autoconf but it shouldn't hurt # tg says for OpenSolaris we need -I/usr/include/idn here but since that path
# here either.. it makes this compile on OpenSolaris.. --lynX via tg 2010 # may exist when idnkit is installed and cause errors because of its 'wrong'
CFLAGS=-DPROGNAME='"@PROGNAME@"' @EXTRA_CFLAGS@ $(OPTIMIZE) $(DEBUG) $(WARN) $(MPATH) $(PROFIL) -I/usr/include/idn -I/usr/local/include # assert.h, we can't include that path here by default. configure should
# learn when to add this path here, but that's tricky. --lynX
CFLAGS=-DPROGNAME='"@PROGNAME@"' @EXTRA_CFLAGS@ $(OPTIMIZE) $(DEBUG) $(WARN) $(MPATH) $(PROFIL) -I/usr/local/include
# #
LIBS= @PKGLIBS@ @LIBS@ -lm LIBS= @PKGLIBS@ @LIBS@ -lm
# #
@ -475,6 +477,9 @@ pkg-pgsql.o : ../mudlib/sys/pgsql.h xalloc.h stdstrings.h simulate.h \
strfuns.h sent.h bytecode.h hash.h backend.h exec.h port.h config.h \ strfuns.h sent.h bytecode.h hash.h backend.h exec.h port.h config.h \
hosts/unix.h hosts/be/be.h machine.h hosts/unix.h hosts/be/be.h machine.h
pkg-psyc.o : xalloc.h simulate.h pkg-psyc.h object.h mstrings.h mapping.h \
machine.h interpret.h efuns.h array.h
pkg-sqlite.o : xalloc.h stdstrings.h object.h svalue.h simulate.h \ pkg-sqlite.o : xalloc.h stdstrings.h object.h svalue.h simulate.h \
mstrings.h interpret.h array.h my-alloca.h typedefs.h driver.h \ mstrings.h interpret.h array.h my-alloca.h typedefs.h driver.h \
strfuns.h sent.h bytecode.h hash.h backend.h port.h config.h main.h \ strfuns.h sent.h bytecode.h hash.h backend.h port.h config.h main.h \

View File

@ -1390,27 +1390,27 @@ int main(void)
lp_cv_need_lib_iconv=no, lp_cv_need_lib_iconv=no,
lp_cv_need_lib_iconv=yes lp_cv_need_lib_iconv=yes
)) ))
if test "$lp_cv_need_lib_iconv" = "yes"; then # if test "$lp_cv_need_lib_iconv" = "yes"; then
# Search the libraries # # Search the libraries
tmp="" # tmp=""
AC_CHECK_LIB(iconv,libiconv_close, tmp="$PKGLIBS -liconv") # AC_CHECK_LIB(iconv,libiconv_close, tmp="$PKGLIBS -liconv")
if test "x$tmp" = "x"; then # if test "x$tmp" = "x"; then
CFLAGS="$saveflags -L/usr/local/lib" # CFLAGS="$saveflags -L/usr/local/lib"
AC_CHECK_LIB(iconv,libiconv_close, tmp="$PKGLIBS -L/usr/local/lib -liconv") # AC_CHECK_LIB(iconv,libiconv_close, tmp="$PKGLIBS -L/usr/local/lib -liconv")
fi # fi
if test "x$tmp" = "x"; then # if test "x$tmp" = "x"; then
echo "iconv library not found." # echo "iconv library not found."
lp_cv_has_iconv="no" # lp_cv_has_iconv="no"
else # else
PKGLIBS="$tmp" # PKGLIBS="$tmp"
fi # fi
CFLAGS="$saveflags" # CFLAGS="$saveflags"
fi # fi
fi fi
if test "x$lp_cv_has_iconv" = "xyes"; then if test "x$lp_cv_has_iconv" = "xyes"; then

View File

@ -66,7 +66,12 @@ psyc_dispatch(mixed p) {
*/ */
#include "machine.h"
#ifdef HAS_PSYC
# include "array.h" # include "array.h"
# include "efuns.h"
# include "interpret.h" # include "interpret.h"
# include "mapping.h" # include "mapping.h"
# include "mstrings.h" # include "mstrings.h"
@ -74,11 +79,6 @@ psyc_dispatch(mixed p) {
# include "pkg-psyc.h" # include "pkg-psyc.h"
# include "simulate.h" # include "simulate.h"
# include "xalloc.h" # include "xalloc.h"
#include "efuns.h"
#ifdef HAS_PSYC
# include "pkg-psyc.h"
# include <stdio.h> # include <stdio.h>
# include <unistd.h> # include <unistd.h>
@ -97,8 +97,8 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
uint8_t type; uint8_t type;
svalue_t vsp, *lval; svalue_t vsp, *lval;
psycList list; PsycList list;
psycString *elems = NULL; PsycString *elems = NULL;
if (key->type != T_STRING) { if (key->type != T_STRING) {
errorf("fill_header_from_mapping: key type %d not supported\n", key->type); errorf("fill_header_from_mapping: key type %d not supported\n", key->type);
@ -107,12 +107,12 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
name = get_txt(key->u.str); name = get_txt(key->u.str);
namelen = mstrsize(key->u.str); namelen = mstrsize(key->u.str);
type = psyc_getVarType2(name, namelen); type = psyc_var_type(name, namelen);
if (m->num_values > 1) if (m->num_values > 1)
oper = val[1].u.number; oper = val[1].u.number;
if (!oper) if (!oper)
oper = C_GLYPH_OPERATOR_SET; oper = PSYC_OPERATOR_SET;
switch (val->type) { switch (val->type) {
case T_STRING: case T_STRING:
@ -142,7 +142,7 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
case T_POINTER: case T_POINTER:
if (VEC_SIZE(val->u.vec)) { if (VEC_SIZE(val->u.vec)) {
elems = pxalloc(sizeof(psycString) * VEC_SIZE(val->u.vec)); elems = pxalloc(sizeof(PsycString) * VEC_SIZE(val->u.vec));
if (!elems) { if (!elems) {
errorf("Out of memory in fill_header_from_mapping for elems\n"); errorf("Out of memory in fill_header_from_mapping for elems\n");
return; // not reached return; // not reached
@ -152,7 +152,7 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
lval = &(val->u.vec->item[i]); lval = &(val->u.vec->item[i]);
switch (lval->type) { switch (lval->type) {
case T_STRING: case T_STRING:
elems[i] = (psycString){mstrsize(lval->u.str), get_txt(lval->u.str)}; elems[i] = (PsycString){mstrsize(lval->u.str), get_txt(lval->u.str)};
break; break;
case T_NUMBER: case T_NUMBER:
case T_OBJECT: case T_OBJECT:
@ -167,7 +167,7 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
} }
f_to_string(&vsp); f_to_string(&vsp);
elems[i] = (psycString){mstrsize(vsp.u.str), get_txt(vsp.u.str)}; elems[i] = (PsycString){mstrsize(vsp.u.str), get_txt(vsp.u.str)};
break; break;
default: default:
errorf("fill_header_from_mapping: list value type %d not supported\n", lval->type); errorf("fill_header_from_mapping: list value type %d not supported\n", lval->type);
@ -176,7 +176,7 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
} }
} }
list = psyc_newList(elems, VEC_SIZE(val->u.vec), PSYC_LIST_CHECK_LENGTH); psyc_list_init(&list, elems, VEC_SIZE(val->u.vec));
valuelen = list.length; valuelen = list.length;
value = pxalloc(valuelen); value = pxalloc(valuelen);
if (!value) { if (!value) {
@ -184,7 +184,7 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
return; // not reached return; // not reached
} }
psyc_renderList(&list, value, valuelen); psyc_render_list(&list, value, valuelen);
break; break;
default: default:
@ -192,8 +192,8 @@ fill_header_from_mapping (svalue_t *key, svalue_t *val, void *extra) {
return; // not reached return; // not reached
} }
m->header->modifiers[m->header->lines++] = psyc_modifier_init(&m->header->modifiers[m->header->lines++],
psyc_newModifier2(oper, name, namelen, value, valuelen, m->flag); oper, name, namelen, value, valuelen, m->flag);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
@ -209,8 +209,8 @@ f_psyc_render(svalue_t *sp) {
size_t mlen, blen; size_t mlen, blen;
mapping_t *map; mapping_t *map;
psycPacket packet; PsycPacket packet;
psycHeader headers[2]; PsycHeader headers[2];
// unless (sp->type == T_POINTER) return sp; // unless (sp->type == T_POINTER) return sp;
v = sp->u.vec; v = sp->u.vec;
@ -221,7 +221,7 @@ f_psyc_render(svalue_t *sp) {
map = v->item[i].u.map; map = v->item[i].u.map;
if (!MAP_SIZE(map)) continue; if (!MAP_SIZE(map)) continue;
headers[i].modifiers = malloc(sizeof(psycModifier) * MAP_SIZE(v->item[i].u.map)); headers[i].modifiers = malloc(sizeof(PsycModifier) * MAP_SIZE(v->item[i].u.map));
if (!headers[i].modifiers) { if (!headers[i].modifiers) {
errorf("Out of memory in psyc_render for modifier table.\n"); errorf("Out of memory in psyc_render for modifier table.\n");
return sp; // not reached return sp; // not reached
@ -259,11 +259,12 @@ f_psyc_render(svalue_t *sp) {
blen = 0; blen = 0;
} }
packet = psyc_newPacket2(headers[PACKET_ROUTING].modifiers, psyc_packet_init(&packet, headers[PACKET_ROUTING].modifiers,
headers[PACKET_ROUTING].lines, headers[PACKET_ROUTING].lines,
headers[PACKET_ENTITY].modifiers, headers[PACKET_ENTITY].modifiers,
headers[PACKET_ENTITY].lines, headers[PACKET_ENTITY].lines,
meth, mlen, body, blen, meth, mlen, body, blen,
PSYC_STATE_NOOP, // TODO: add support for state ops
PSYC_PACKET_CHECK_LENGTH); PSYC_PACKET_CHECK_LENGTH);
#ifdef DEBUG #ifdef DEBUG
@ -293,8 +294,8 @@ f_psyc_parse (svalue_t *sp) {
vector_t *v, *list; vector_t *v, *list;
mapping_t *map; mapping_t *map;
char oper = 0; char oper = 0;
psycString name = {0,0}, value = {0,0}, elems[MAX_LIST_SIZE], elem; PsycString name = {0,0}, value = {0,0}, elems[MAX_LIST_SIZE], elem, elem_type;
psycParseListState listState; PsycParseListState listState;
int ret, retl, type = -1, error = 0; int ret, retl, type = -1, error = 0;
size_t size, i; size_t size, i;
ssize_t n; ssize_t n;
@ -317,12 +318,12 @@ f_psyc_parse (svalue_t *sp) {
O_GET_PSYC_STATE(current_object) = state; O_GET_PSYC_STATE(current_object) = state;
memset(state, 0, sizeof(psyc_state_t)); memset(state, 0, sizeof(psyc_state_t));
state->parser = pxalloc(sizeof(psycParseState)); state->parser = pxalloc(sizeof(PsycParseState));
if (!state->parser) { if (!state->parser) {
errorf("Out of memory for psyc parse state struct.\n"); errorf("Out of memory for psyc parse state struct.\n");
return sp; // not reached return sp; // not reached
} }
psyc_initParseState(state->parser); psyc_parse_state_init(state->parser, PSYC_PARSE_ALL);
} }
v = state->packet; v = state->packet;
@ -345,13 +346,13 @@ f_psyc_parse (svalue_t *sp) {
memcpy(buffer, state->remaining, state->remaining_len); memcpy(buffer, state->remaining, state->remaining_len);
memcpy(buffer + state->remaining_len, get_txt(sp->u.str), memcpy(buffer + state->remaining_len, get_txt(sp->u.str),
mstrsize(sp->u.str)); mstrsize(sp->u.str));
psyc_setParseBuffer2(state->parser, buffer, psyc_parse_buffer_set(state->parser, buffer,
state->remaining_len + mstrsize(sp->u.str)); state->remaining_len + mstrsize(sp->u.str));
pfree(state->remaining); pfree(state->remaining);
state->remaining = NULL; state->remaining = NULL;
state->remaining_len = 0; state->remaining_len = 0;
} else { } else {
psyc_setParseBuffer2(state->parser, get_txt(sp->u.str), psyc_parse_buffer_set(state->parser, get_txt(sp->u.str),
mstrsize(sp->u.str)); mstrsize(sp->u.str));
} }
} else { } else {
@ -363,7 +364,7 @@ f_psyc_parse (svalue_t *sp) {
ret = psyc_parse(state->parser, &oper, &name, &value); ret = psyc_parse(state->parser, &oper, &name, &value);
#ifdef DEBUG #ifdef DEBUG
printf("#%2d %c%.*s = %.*s\n", ret, oper ? oper : ' ', printf("#%2d %c%.*s = %.*s\n", ret, oper ? oper : ' ',
(int)name.length, name.ptr, (int)value.length, value.ptr); (int)name.length, name.data, (int)value.length, value.data);
#endif #endif
if (!state->packet) { if (!state->packet) {
state->packet = allocate_array(4); state->packet = allocate_array(4);
@ -393,7 +394,7 @@ f_psyc_parse (svalue_t *sp) {
// incomplete entity or body // incomplete entity or body
state->oper = oper; state->oper = oper;
state->name = mstring_alloc_string(name.length); state->name = mstring_alloc_string(name.length);
memcpy(get_txt(state->name), name.ptr, name.length); memcpy(get_txt(state->name), name.data, name.length);
if (!state->name) { if (!state->name) {
errorf("Out of memory for name.\n"); errorf("Out of memory for name.\n");
return sp; // not reached return sp; // not reached
@ -401,7 +402,7 @@ f_psyc_parse (svalue_t *sp) {
// allocate memory for the total length of the value // allocate memory for the total length of the value
state->value_len = 0; state->value_len = 0;
state->value = mstring_alloc_string(psyc_getParseValueLength(state->parser)); state->value = mstring_alloc_string(psyc_parse_value_length(state->parser));
if (!state->value) { if (!state->value) {
errorf("Out of memory for value.\n"); errorf("Out of memory for value.\n");
return sp; // not reached return sp; // not reached
@ -411,7 +412,7 @@ f_psyc_parse (svalue_t *sp) {
case PSYC_PARSE_ENTITY_CONT: case PSYC_PARSE_BODY_CONT: case PSYC_PARSE_ENTITY_CONT: case PSYC_PARSE_BODY_CONT:
case PSYC_PARSE_ENTITY_END: case PSYC_PARSE_BODY_END: case PSYC_PARSE_ENTITY_END: case PSYC_PARSE_BODY_END:
// append value to tmp buffer in state // append value to tmp buffer in state
memcpy(get_txt(state->value) + state->value_len, value.ptr, value.length); memcpy(get_txt(state->value) + state->value_len, value.data, value.length);
state->value_len += value.length; state->value_len += value.length;
} }
@ -419,9 +420,9 @@ f_psyc_parse (svalue_t *sp) {
// incomplete entity or body parsing done, // incomplete entity or body parsing done,
// set oper/name/value to the ones saved in state // set oper/name/value to the ones saved in state
oper = state->oper; oper = state->oper;
name.ptr = get_txt(state->name); name.data = get_txt(state->name);
name.length = mstrsize(state->name); name.length = mstrsize(state->name);
value.ptr = get_txt(state->value); value.data = get_txt(state->value);
value.length = mstrsize(state->value); value.length = mstrsize(state->value);
} }
@ -431,13 +432,13 @@ f_psyc_parse (svalue_t *sp) {
// new_n_tabled fetches a reference of a probably existing // new_n_tabled fetches a reference of a probably existing
// shared string // shared string
put_string(sv, new_n_tabled(name.ptr, name.length)); put_string(sv, new_n_tabled(name.data, name.length));
sv = get_map_lvalue(v->item[PACKET_ROUTING].u.map, sv); sv = get_map_lvalue(v->item[PACKET_ROUTING].u.map, sv);
put_number(&sv[1], oper); put_number(&sv[1], oper);
// strings are capable of containing 0 so we can do this // strings are capable of containing 0 so we can do this
// for binary data too. let's use a tabled string even // for binary data too. let's use a tabled string even
// for values of routing variables as they repeat a lot // for values of routing variables as they repeat a lot
put_string(sv, new_n_tabled(value.ptr, value.length)); put_string(sv, new_n_tabled(value.data, value.length));
break; break;
case PSYC_PARSE_ENTITY_START: case PSYC_PARSE_ENTITY_START:
@ -449,54 +450,55 @@ f_psyc_parse (svalue_t *sp) {
sv = pxalloc(sizeof(svalue_t)); sv = pxalloc(sizeof(svalue_t));
if (ret == PSYC_PARSE_ENTITY) if (ret == PSYC_PARSE_ENTITY)
put_string(sv, new_n_tabled(name.ptr, name.length)); put_string(sv, new_n_tabled(name.data, name.length));
else // PSYC_PARSE_ENTITY_END else // PSYC_PARSE_ENTITY_END
put_string(sv, make_tabled(state->name)); put_string(sv, make_tabled(state->name));
sv = get_map_lvalue(v->item[PACKET_ENTITY].u.map, sv); sv = get_map_lvalue(v->item[PACKET_ENTITY].u.map, sv);
put_number(&sv[1], oper); put_number(&sv[1], oper);
type = psyc_getVarType(&name); type = psyc_var_type(PSYC_S2ARG(name));
switch (type) { switch (type) {
case PSYC_TYPE_DATE: // number + PSYC_EPOCH case PSYC_TYPE_DATE: // number + PSYC_EPOCH
if (psyc_parseDate(&value, &timmy)) if (psyc_parse_uint(PSYC_S2ARG(value), &timmy))
put_number(sv, timmy); put_number(sv, timmy);
else else
error = PSYC_PARSE_ERROR_DATE; error = PSYC_PARSE_ERROR_DATE;
break; break;
case PSYC_TYPE_TIME: // number case PSYC_TYPE_TIME: // number
if (psyc_parseTime(&value, &timmy)) if (psyc_parse_uint(PSYC_S2ARG(value), &timmy))
put_number(sv, timmy); put_number(sv, timmy);
else else
error = PSYC_PARSE_ERROR_TIME; error = PSYC_PARSE_ERROR_TIME;
break; break;
case PSYC_TYPE_AMOUNT: // number case PSYC_TYPE_AMOUNT: // number
if (psyc_parseNumber(&value, &n)) if (psyc_parse_uint(PSYC_S2ARG(value), &n))
put_number(sv, n); put_number(sv, n);
else else
error = PSYC_PARSE_ERROR_AMOUNT; error = PSYC_PARSE_ERROR_AMOUNT;
break; break;
case PSYC_TYPE_DEGREE: // first digit case PSYC_TYPE_DEGREE: // first digit
if (value.length && value.ptr[0] >= '0' && value.ptr[0] <= '9') if (value.length && value.data[0] >= '0' && value.data[0] <= '9')
put_number(sv, value.ptr[0] - '0'); put_number(sv, value.data[0] - '0');
else else
error = PSYC_PARSE_ERROR_DEGREE; error = PSYC_PARSE_ERROR_DEGREE;
break; break;
case PSYC_TYPE_FLAG: // 0 or 1 case PSYC_TYPE_FLAG: // 0 or 1
if (value.length && value.ptr[0] >= '0' && value.ptr[0] <= '1') if (value.length && value.data[0] >= '0' && value.data[0] <= '1')
put_number(sv, value.ptr[0] - '0'); put_number(sv, value.data[0] - '0');
else else
error = PSYC_PARSE_ERROR_FLAG; error = PSYC_PARSE_ERROR_FLAG;
break; break;
case PSYC_TYPE_LIST: // array case PSYC_TYPE_LIST: // array
size = 0; size = 0;
if (value.length) { if (value.length) {
psyc_initParseListState(&listState); psyc_parse_list_state_init(&listState);
psyc_setParseListBuffer(&listState, value); psyc_parse_list_buffer_set(&listState, PSYC_S2ARG(value));
elem = (psycString){0, 0}; elem = (PsycString){0, 0};
elem_type = (PsycString){0, 0};
do { do {
retl = psyc_parseList(&listState, &elem); retl = psyc_parse_list(&listState, &elem_type, &elem);
switch (retl) { switch (retl) {
case PSYC_PARSE_LIST_END: case PSYC_PARSE_LIST_END:
retl = 0; retl = 0;
@ -516,7 +518,7 @@ f_psyc_parse (svalue_t *sp) {
list = allocate_array(size); list = allocate_array(size);
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
put_string(&list->item[i], new_n_tabled(elems[i].ptr, put_string(&list->item[i], new_n_tabled(elems[i].data,
elems[i].length)); elems[i].length));
put_array(sv, list); put_array(sv, list);
@ -525,8 +527,8 @@ f_psyc_parse (svalue_t *sp) {
if (ret == PSYC_PARSE_ENTITY) if (ret == PSYC_PARSE_ENTITY)
// is it good to put entity variable values into the // is it good to put entity variable values into the
// shared string table? probably yes.. but it's a guess // shared string table? probably yes.. but it's a guess
//t_string(sv, new_n_mstring(value.ptr, value.length)); //t_string(sv, new_n_mstring(value.data, value.length));
put_string(sv, new_n_tabled(value.ptr, value.length)); put_string(sv, new_n_tabled(value.data, value.length));
else // PSYC_PARSE_ENTITY_END else // PSYC_PARSE_ENTITY_END
put_string(sv, state->value); put_string(sv, state->value);
} }
@ -544,11 +546,11 @@ f_psyc_parse (svalue_t *sp) {
case PSYC_PARSE_BODY: case PSYC_PARSE_BODY:
// new_n_tabled gets the shared string for the method // new_n_tabled gets the shared string for the method
put_string(&v->item[PACKET_METHOD], put_string(&v->item[PACKET_METHOD],
new_n_tabled(name.ptr, name.length)); new_n_tabled(name.data, name.length));
// allocate an untabled string for the packet body // allocate an untabled string for the packet body
put_string(&v->item[PACKET_BODY], put_string(&v->item[PACKET_BODY],
new_n_mstring(value.ptr, value.length)); new_n_mstring(value.data, value.length));
break; break;
case PSYC_PARSE_COMPLETE: case PSYC_PARSE_COMPLETE:
@ -559,11 +561,11 @@ f_psyc_parse (svalue_t *sp) {
case PSYC_PARSE_INSUFFICIENT: case PSYC_PARSE_INSUFFICIENT:
// insufficient data, save remaining bytes // insufficient data, save remaining bytes
state->remaining_len = psyc_getParseRemainingLength(state->parser); state->remaining_len = psyc_parse_remaining_length(state->parser);
if (state->remaining_len) { if (state->remaining_len) {
state->remaining = pxalloc(state->remaining_len); state->remaining = pxalloc(state->remaining_len);
memcpy(state->remaining, memcpy(state->remaining,
psyc_getParseRemainingBuffer(state->parser), psyc_parse_remaining_buffer(state->parser),
state->remaining_len); state->remaining_len);
} else } else
state->remaining = NULL; state->remaining = NULL;

View File

@ -6,6 +6,7 @@
* or int* where necessary. * or int* where necessary.
*/ */
# include <psyc.h>
# include <psyc/packet.h> # include <psyc/packet.h>
# include <psyc/parse.h> # include <psyc/parse.h>
@ -28,7 +29,7 @@
# define PSYC_PARSE_ERROR_LIST_TOO_LARGE 7 # define PSYC_PARSE_ERROR_LIST_TOO_LARGE 7
typedef struct psyc_state_s { typedef struct psyc_state_s {
psycParseState *parser; PsycParseState *parser;
vector_t *packet; vector_t *packet;
// tmp storage for incomplete modifier/body // tmp storage for incomplete modifier/body
char oper; char oper;
@ -41,9 +42,9 @@ typedef struct psyc_state_s {
} psyc_state_t; } psyc_state_t;
typedef struct psyc_modifier_s { typedef struct psyc_modifier_s {
psycHeader *header; PsycHeader *header;
p_int num_values; p_int num_values;
psycModifierFlag flag; PsycModifierFlag flag;
} psyc_modifier_t; } psyc_modifier_t;
static inline void static inline void

View File

@ -518,12 +518,33 @@ tls_global_init (void)
, time_stamp()); , time_stamp());
goto ssl_init_err; goto ssl_init_err;
} }
#ifdef SSL_CTRL_SET_TMP_ECDH
do {
EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
if (ecdh == NULL) {
debug_message("%s TLS: Error setting ECDHE parameters:\n"
, time_stamp());
goto ssl_init_err;
} else {
debug_message("%s: TLS: using ECDHE, yai\n"
, time_stamp());
}
SSL_CTX_set_tmp_ecdh(context,ecdh);
EC_KEY_free(ecdh);
} while (0);
#endif
/* Avoid small subgroup attacks */ /* Avoid small subgroup attacks */
/* do not do SSLv2 */ /* do not do SSLv2 */
SSL_CTX_set_options(context, SSL_OP_SINGLE_DH_USE); SSL_CTX_set_options(context, SSL_OP_SINGLE_DH_USE);
SSL_CTX_set_options(context, SSL_OP_NO_SSLv2); SSL_CTX_set_options(context, SSL_OP_NO_SSLv2);
if (SSL_CTX_set_cipher_list(context, "HIGH:!DSS:!aNULL@STRENGTH") != 1) {
debug_message("SSL_CTX_set_cipher_list failed."
, time_stamp());
goto ssl_init_err;
}
/* OpenSSL successfully initialised */ /* OpenSSL successfully initialised */
tls_available = MY_TRUE; tls_available = MY_TRUE;
return; return;
@ -1548,14 +1569,14 @@ f_tls_query_connection_info (svalue_t *sp)
#ifdef HAS_OPENSSL #ifdef HAS_OPENSSL
put_c_string(&(rc->item[TLS_CIPHER]) put_c_string(&(rc->item[TLS_CIPHER])
, SSL_get_cipher(ip->tls_session)); , SSL_get_cipher(ip->tls_session));
put_number(&(rc->item[TLS_COMP]), 0); put_number(&(rc->item[TLS_COMP]), ip->tls_session->session->compress_meth);
put_number(&(rc->item[TLS_KX]), 0); put_number(&(rc->item[TLS_KX]), 0);
put_number(&(rc->item[TLS_MAC]), 0); put_number(&(rc->item[TLS_MAC]), 0);
put_c_string(&(rc->item[TLS_PROT]) put_c_string(&(rc->item[TLS_PROT])
, SSL_get_version(ip->tls_session)); , SSL_get_version(ip->tls_session));
/* warning: this session id is binary .. maybe fix it someday */ /* warning: this session id is binary .. maybe fix it someday */
put_c_string(&(rc->item[TLS_SESSION]) put_c_n_string(&(rc->item[TLS_SESSION])
, (char*) ip->tls_session->session->session_id); , (char*) ip->tls_session->session->session_id, ip->tls_session->session->session_id_length);
#elif defined(HAS_GNUTLS) #elif defined(HAS_GNUTLS)
put_number(&(rc->item[TLS_CIPHER]) put_number(&(rc->item[TLS_CIPHER])
, gnutls_cipher_get(ip->tls_session)); , gnutls_cipher_get(ip->tls_session));

View File

@ -17,7 +17,7 @@ version_longtype="stable"
# A timestamp, to be used by bumpversion and other scripts. # A timestamp, to be used by bumpversion and other scripts.
# It can be used, for example, to 'touch' this file on every build, thus # 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. # forcing revision control systems to add it on every checkin automatically.
version_stamp="Tue May 24 18:47:17 CEST 2011" version_stamp="Mon Aug 29 16:41:20 CEST 2011"
# Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x # Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x
version_major=4 version_major=4