diff --git a/CHANGESTODO b/CHANGESTODO index a5e468b..0d9221f 100644 --- a/CHANGESTODO +++ b/CHANGESTODO @@ -38,6 +38,10 @@ ________________________________________________________________________ ________________________________________________________________________ == desperate, but not serious ========================================== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +- _message_echo_private should display full origin to make fakes recognizable + (or we should check lastlog to see when an echo is fake) + Du sagst [_nick_target]: hallo alda <- not so neat. + - check in user:input() if data is in utf8 (using RE_UTF8) in order to produce proper error messages before it is processed further and may end up in net/jabber's emit() where it is dropped silently (see CHARS_XMPP.log) diff --git a/world/net/psyc/render.i b/world/net/psyc/render.i index e577389..7e3c13a 100644 --- a/world/net/psyc/render.i +++ b/world/net/psyc/render.i @@ -268,7 +268,6 @@ static varargs string render_psyc(mixed source, string mc, mixed data, } #endif /* NEW_RENDER */ -#ifdef LIBPSYC int routeMe = 0; mapping evars = ([ ]); @@ -287,53 +286,10 @@ static varargs string render_psyc(mixed source, string mc, mixed data, } return psyc_render(({ rvars, evars, mc, data })); -#else - -#if __EFUN_DEFINED__(walk_mapping) - // walk_mapping could be rewritten into foreach, but thats work - walk_mapping(rvars, #'build_header, rvars, 0); -#else // PIKE, MudOS... - mapeach(key, val, rvars) { - build_header(key, val, rvars, 0); - } -#endif - - if (mappingp(vars)) { -#if 0 //ndef EXPERIMENTAL - if (member(vars, "_count")) - ebuf += "\n:_count\t" + vars["_count"]; -#endif -#if __EFUN_DEFINED__(walk_mapping) - // walk_mapping could be rewritten into foreach, but thats work - walk_mapping(vars, #'build_header, vars, 1); -#else // PIKE, MudOS... - mapeach(key, val, vars) { - build_header(key, val, vars, 1); - } -#endif - } - - if (data == "") ebuf += "\n"+ mc; - else ebuf += "\n"+ mc + "\n"+ data; - -#ifdef SPYC // || MODULE_LENGTH - if (needLen || strlen(ebuf) + strlen(rbuf) > 555) - return ":_length\t"+ strlen(ebuf) + rbuf +"\n"+ - ebuf +"\n" S_GLYPH_PACKET_DELIMITER "\n"; - else -#endif -#ifndef NEW_LINE - if (excessiveNewline) return rbuf[1 ..] +"\n"+ - ebuf + S_GLYPH_PACKET_DELIMITER "\n"; - else -#endif - if (strlen(rbuf)) return rbuf[1 ..] +"\n"+ - ebuf +"\n" S_GLYPH_PACKET_DELIMITER "\n"; - return ebuf +"\n" S_GLYPH_PACKET_DELIMITER "\n"; -#endif } // notice for completeness: the PSYC renderer does not convert_charset // from SYSTEM_CHARSET to UTF-8, so to produce correct PSYC you must not // switch to a different SYSTEM_CHARSET, or you have to fix that... +// probably the right thing to do is to remove configurable SYSTEM_CHARSET diff --git a/world/net/spyc/active.c b/world/net/spyc/active.c index 5ab1a95..34b9027 100644 --- a/world/net/spyc/active.c +++ b/world/net/spyc/active.c @@ -1,7 +1,2 @@ -// $Id: active.c,v 1.1 2008/01/30 17:06:48 lynx Exp $ // vim:syntax=lpc #include "psyc.h" -#ifdef LIBPSYC - #include "../psyc/active.c" - -#endif // LIBPSYC diff --git a/world/net/spyc/circuit.c b/world/net/spyc/circuit.c index 34e1875..b8ef5f4 100644 --- a/world/net/spyc/circuit.c +++ b/world/net/spyc/circuit.c @@ -2,7 +2,6 @@ // $Id: circuit.c,v 1.38 2008/10/14 19:02:29 lynx Exp $ #include "psyc.h" -#ifdef LIBPSYC #include #include @@ -276,4 +275,3 @@ varargs int msg(string source, string mc, string data, return emit(buf); } -#endif // LIBPSYC diff --git a/world/net/spyc/dispatch.i b/world/net/spyc/dispatch.i index 24549eb..e031690 100644 --- a/world/net/spyc/dispatch.i +++ b/world/net/spyc/dispatch.i @@ -38,11 +38,7 @@ mixed process_routing_modifiers(mapping rvars, mapping vars) { mixed process_entity_modifiers(mapping evars, mapping vars, mapping cstate) { // apply evars to context state foreach (mixed vname : m_indices(evars)) { - if (routing[vname] || abbrev("_INTERNAL", vname) -#ifndef LIBPSYC - || !legal_keyword(vname) -#endif - ) { + if (routing[vname] || abbrev("_INTERNAL", vname)) { DISPATCHERROR("illegal varname in entity header") } @@ -107,32 +103,6 @@ mixed process_var_types(mapping evars) { if (!legal_name(evars[vname])) croak("_error_illegal_nick"); break; -#ifndef LIBPSYC - case "_degree": - // only honour the first digit - if (strlen(evars[vname]) && evars[vname][0] >= '0' && evars[vname][0] <= '9') - evars[vname] = evars[vname][0] - '0'; - else { - PT(("type parser _degree: could not handle value %O\n", - evars[vname])) - evars[vname] = 0; - } - break; - case "_date": - evars[vname] = to_int(evars[vname]) + PSYC_EPOCH; - break; - case "_time": - case "_amount": - evars[vname] = to_int(evars[vname]); - break; - case "_list": - mixed plist = list_parse(evars[vname]); - if (plist == -1) { - DISPATCHERROR("could not parse list"); - } - evars[vname] = plist; - break; -#endif PSYC_SLICE_AND_REPEAT } } @@ -173,11 +143,6 @@ void dispatch(mapping rvars, mapping evars, mixed method, mixed body) { if (!process_routing_modifiers(rvars, vars)) return; -#ifndef LIBPSYC - if (!process_var_types(evars)) - return; -#endif - // check that _target is hosted by us // this check can be skipped if _target is not set if ((t = vars["_target"])) { diff --git a/world/net/spyc/parse.c b/world/net/spyc/parse.c index 10fb8c8..8597597 100644 --- a/world/net/spyc/parse.c +++ b/world/net/spyc/parse.c @@ -1,9 +1,6 @@ // vim:foldmethod=marker:syntax=lpc:noexpandtab #include "psyc.h" -#ifdef LIBPSYC // net/spyc currently doesn't work without libpsyc - // and probably never will.. will delete the old code soon - #include #include @@ -11,19 +8,6 @@ private string buffer; int state; int may_parse_more; -#ifndef LIBPSYC // {{{ -private string body_buffer; -int body_len; - -// temporary used to hold assigment lists vname -> ({ glyph, state, vvalue }) -// this won't work anymore, dispatch now expects two mappings: rvars & evars -array(mixed) tvars; -mapping hvars; -// prototypes -parse_header(); -buffer_content(); -#endif // }}} LIBPSYC - // being faded out in favor of regular croak() #define PARSEERROR(reason) { \ croak("_error_syntax_broken", \ @@ -45,24 +29,8 @@ step(); // prototype // overload this as needed varargs mixed croak(string mc, string data, vamapping vars) { return 0; } -#ifndef LIBPSYC //{{{ -// reset parser state -void parser_reset() { - if (state != PSYCPARSE_STATE_BLOCKED) - state = PSYCPARSE_STATE_HEADER; - body_len = 0; - body_buffer = 0; - may_parse_more = 1; - tvars = ({ }); - hvars = ([ ]); -} -#endif //}}} - // initialize the parser void parser_init() { -# ifndef LIBPSYC //{{{ - parser_reset(); -# endif //}}} buffer = ""; state = PSYCPARSE_STATE_GREET; // AFTER reset } @@ -79,9 +47,6 @@ void resume_parse() { // called when a complete packet has arrived void dispatch(mapping rvars, mapping evars, mixed method, mixed body) { -#ifndef LIBPSYC //{{{ - parser_reset(); -#endif //}}} } void psyc_dispatch(mixed p) { @@ -108,13 +73,6 @@ void feed(string data) { buffer += data; -# ifndef LIBPSYC //{{{ - do { - may_parse_more = 0; - step(); - } while (may_parse_more); - -# else //}}} if (state != PSYCPARSE_STATE_HEADER) step(); @@ -148,7 +106,6 @@ void feed(string data) { } buffer = ""; } -# endif } // parser stepping function @@ -157,14 +114,6 @@ void step() { if (!strlen(buffer)) return; switch(state) { -#ifndef LIBPSYC //{{{ - case PSYCPARSE_STATE_HEADER: - parse_header(); - break; - case PSYCPARSE_STATE_CONTENT: - buffer_content(); - break; -#endif //}}} case PSYCPARSE_STATE_BLOCKED: // someone requested to stop parsing - e.g. _request_features circuit // message @@ -176,9 +125,6 @@ void step() { state = PSYCPARSE_STATE_HEADER; buffer = buffer[2 ..]; first_response(); -#ifndef LIBPSYC //{{{ - step(); -#endif //}}} } else { croak("_error_syntax_initialization"); // "The new protocol begins with a pipe and a line feed."); @@ -189,294 +135,3 @@ void step() { } } -// EOF for LIBPSYC - -#ifndef LIBPSYC //{{{ -// processes routing header variable assignments -// basic version does no state -mapping process_header(mixed varops) { - mapping vars = ([ ]); - // apply mmp state - foreach(mixed vop : varops) { - string vname = vop[0]; - switch(vop[1]) { - case C_GLYPH_MODIFIER_SET: - vars[vname] = vop[2]; - break; - case C_GLYPH_MODIFIER_AUGMENT: - case C_GLYPH_MODIFIER_DIMINISH: - case C_GLYPH_MODIFIER_QUERY: - case C_GLYPH_MODIFIER_ASSIGN: - croak("_failure_unavailable_state"); - QUIT - default: - croak("_failure_unknown_glyph"); - QUIT - } - // FIXME: not every legal varname is a routing varname - // look at shared_memory("routing") - if (!legal_keyword(vname) || abbrev("_INTERNAL", vname)) { - croak("_error_illegal_protocol_variable", 0, - ([ "_variable_name": vname ])); - return 0; - } - } - return vars; -} - -// parse the header part of the packet -// i.e. that is all mmp modifiers -// switch to content buffering mode afterwards -void parse_header() { - if (!strlen(buffer)) return; - if (buffer[0] == C_GLYPH_PACKET_DELIMITER) { - if (strlen(buffer) < 2) - return; - if (buffer[1] == C_LINEFEED) { - buffer = buffer[2..]; - hvars = process_header(tvars); - tvars = ({ }); - dispatch(hvars, tvars, 0, 0); - } else { - // this one is sth like |whatever - // actually this should be noglyph i think - PARSEERROR("strange thing") - } - } else if (buffer[0] == C_LINEFEED) { - // state transition from parsing header to buffering body - buffer = buffer[1..]; - hvars = process_header(tvars); - tvars = ({ }); - // FIXME: validate source/context here - state = PSYCPARSE_STATE_CONTENT; - if (hvars["_length"]) - body_len = to_int(hvars["_length"][MVAR_VALUE]); - step(); - } else { // parse mmp-header - int fit; - int glyph; - string vname, vvalue; - switch(buffer[0]) { - case C_GLYPH_MODIFIER_SET: - case C_GLYPH_MODIFIER_ASSIGN: - case C_GLYPH_MODIFIER_AUGMENT: - case C_GLYPH_MODIFIER_DIMINISH: - case C_GLYPH_MODIFIER_QUERY: - glyph = buffer[0]; - buffer = buffer[1..]; - break; - default: - croak("_error_syntax_expected_routing"); - QUIT - } - fit = sscanf(buffer, "%.1s%t", vname); - if (fit != 1) { - PARSEERROR("vname") - } - buffer = buffer[strlen(vname)..]; - switch(buffer[0]) { - case '\t': - fit = sscanf(buffer, "\t%s\n%.0s", vvalue, buffer); - if (fit != 2) { - PARSEERROR("simple-arg") - } - break; - case '\n': // deletion - // this is currently implemented as "vvalue is 0" internally - // and must handled in dispatch() when merging - buffer = buffer[1..]; - break; - default: - PARSEERROR("arg") - } - tvars += ({ ({ vname, glyph, vvalue }) }); - step(); - } -} - -// parse all psyc-modifiers -// this differes from the mmp modifiers in the sense that -// a) packet is known to be complete here -// b) psyc modifiers may have binary args -void parse_psyc() { - while(1) { // slurp in all psyc-modifiers - int fit, len; - int glyph; - string vname, vvalue; - switch(body_buffer[0]) { - case C_GLYPH_MODIFIER_SET: - case C_GLYPH_MODIFIER_ASSIGN: - case C_GLYPH_MODIFIER_AUGMENT: - case C_GLYPH_MODIFIER_DIMINISH: - case C_GLYPH_MODIFIER_QUERY: - glyph = body_buffer[0]; - body_buffer = body_buffer[1..]; - break; - default: - // this is the method - return; - } - fit = sscanf(body_buffer, "%.1s%t", vname); - if (fit != 1) { - PARSEERROR("vname") - } - body_buffer = body_buffer[strlen(vname)..]; - switch(body_buffer[0]) { - case ' ': - fit = sscanf(body_buffer, " %d\t%.0s", len, body_buffer); - if (fit != 2) { - PARSEERROR("binary-arg length") - } - if (len < 0) { - PARSEERROR("negative binary length") - } - if (strlen(body_buffer) < len) { - // ouch, this is a problem here - PARSEERROR("not enough to read binary arg, may not happen") - } - vvalue = body_buffer[..len-1]; - body_buffer = body_buffer[len..]; - if (body_buffer[0] != C_LINEFEED) { - PARSEERROR("binary terminal") - } - body_buffer = body_buffer[1..]; - break; - case '\t': - fit = sscanf(body_buffer, "\t%s\n%.0s", vvalue, body_buffer); - if (fit != 2) { - PARSEERROR("simple-arg") - } - break; - case '\n': - switch(glyph) { - case C_GLYPH_MODIFIER_ASSIGN: - // delete this context's state - PARSEERROR("tbd") - // unfortunately the routing hasn't been processed at - // this moment yet, so we don't know whose context this - // is and if it is legitimate. we first have to fix the - // processing of the routing layer before we can implement - // anything of this - continue; - case C_GLYPH_MODIFIER_SET: - // remember to temporarily ignore state - PARSEERROR("tbd") - continue; - case C_GLYPH_MODIFIER_QUERY: - // mark that the next reply packet should - // contain a state sync - PARSEERROR("tbd") - continue; - default: - PARSEERROR("undefined operation") - } - return; - default: - PARSEERROR("arg") - } - tvars += ({ ({ vname, glyph, vvalue }) }); - } -} - -// parse completed content -void parse_content() { - int fit; - string method, body; - - // at this point we should check for relaying, then potentially - // route the data without parsing it.. TODO - - parse_psyc(); - // ASSERT strlen(buffer) - if (body_buffer[0] == C_LINEFEED) { - PARSEERROR("empty method") - } - - // FIXME: i am not sure if this is correct... - if (body_buffer == S_GLYPH_PACKET_DELIMITER) { - P0(("encountered packet delimiter in packet body? how's that?\n")) - dispatch(hvars, tvars, 0, 0); - return; - } - fit = sscanf(body_buffer, "%.1s\n%.0s", method, body_buffer); - if (fit != 2 || !legal_keyword(method)) { - croak("_error_illegal_method"); - // "That's not a valid method name."); - return; - } - - // mhmm... why does body_buffer still contain the newline? - // because the newline is by definition not part of the body! - if (strlen(body_buffer)) body = body_buffer[..<2]; - dispatch(hvars, tvars, method, body); -} - -// buffer content until complete -// then parse it -// note: you could overload this, if you just want to route -// the packet -void buffer_content() { - int t; - if (body_len) { - if (strlen(buffer) >= body_len + 3) { - // make sure that the packet is properly terminated - if (buffer[body_len..body_len+2] != "\n" DELIM) { - PARSEERROR("packet delimiter after binary body not found") - } - body_buffer = buffer[..body_len]; - buffer = buffer[body_len+3..]; - parse_content(); - } else { - P4(("buffer_content: waiting for more binary data\n")) - } - } else if ((t = strstr(buffer, "\n" DELIM)) != -1) { - body_buffer = buffer[..t]; - buffer = buffer[t+3..]; - parse_content(); - P4(("buffer_content: packet complete\n")) - } else { - P4(("buffer_content: waiting for more plain data. buffer %O vs %O\n", to_array(buffer), to_array("\n" DELIM))) - } -} - -// FIXME should be in a standalone module -//#define PARSEERROR(args) debug_message(sprintf("LIST PARSE ERROR: " args)); -#define LISTSEP '|' -#define LISTPARSE_FAIL -1 -#define LISTMODE_PLAIN 0 -#define LISTMODE_BINARY 1 -// list parsing function - val is assumed to be stripped of the final LF -mixed list_parse(string val) { - mixed *lv = ({ }); - if (val[0] == LISTSEP) - return explode(val[1..], "|"); - while(strlen(val)) { - int fit, len; - fit = sscanf(val, "%d %s", len, val); - if (fit != 2) { - // invalid binary fit - return LISTPARSE_FAIL; - } - if (len < 0 || len > strlen(val)) { - // invalid binary length - return LISTPARSE_FAIL; - } - if (len != strlen(val) && val[len] != LISTSEP) { - // listsep not found after binary - return LISTPARSE_FAIL; - } - lv += ({ val[..len-1] }); - val = val[len+1..]; - } - return lv; -} - -# ifdef SELFTESTS -test() { - list_parse("|psyc://example.net/~jim|psyc://example.org/~judy"); - list_parse("5\tabcde|4\tabcd"); -} -# endif -#endif // !LIBPSYC //}}} - -#endif // LIBPSYC diff --git a/world/net/spyc/server.c b/world/net/spyc/server.c index 61765f8..f8aee5c 100644 --- a/world/net/spyc/server.c +++ b/world/net/spyc/server.c @@ -4,7 +4,6 @@ // the thing that answers on port 4404 of psyced. #include "psyc.h" -#ifdef LIBPSYC #include #include @@ -201,4 +200,3 @@ int logon(int nothing) { return 1; // success } -#endif // LIBPSYC