/* * TCL scripting extension. * * mICQ TCL extension Copyright (C) © 2003 Roman Hoog Antink * * This extension is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 dated June, 1991. * * This extension is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with this package; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * $Id$ */ #include "micq.h" #include "util_tcl.h" #ifdef ENABLE_TCL #include "contact.h" #include "preferences.h" #include "session.h" #include "cmd_user.h" #include "util_str.h" #include "color.h" #if HAVE_TCL8_4_TCL_H #include #elif HAVE_TCL8_3_TCL_H #include #else #include #endif #include static Tcl_Interp *tinterp; static tcl_hook_p tcl_events = NULL; static tcl_hook_p tcl_msgs = NULL; static char *buf = NULL; static UDWORD buflen = 0; char *RemEscapes (const char *s) { /* Ansi sequences: ESC [ m ESC ! ESC */ const char *c = s, *d; char *p, *q; q = strdup (s); for (p = q; *c; ) { if (*c == *ESC) { if (c[1] == '[') { d = strchr (c, 'm'); if (!d) c += 2; else c = d; } else if (c[1] == '!' && c[2]) c += 3; else c += 2; } else *(p++) = *(c++); } *p = 0; return q; } TCL_CALLBACK (TCL_collect_out) { char *unes; unes = RemEscapes (s); buf = s_cat (buf, &buflen, unes); free (unes); } TCL_COMMAND (TCL_command_help) { if (argc == 1) { M_printf (i18n (2346, "The following Tcl commands are supported:\n")); M_printf (COLMESSAGE "%s" COLNONE "\n\t" COLINDENT "%s\n%s" COLEXDENT "\n", i18n (2347, "micq receive