/[cvs]/eggdrop1.8/src/tclhash.c
ViewVC logotype

Diff of /eggdrop1.8/src/tclhash.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.1.1 by simple, Mon Jul 26 21:11:06 2010 UTC revision 1.6 by thommey, Sat Jun 16 16:04:02 2012 UTC
# Line 41  extern time_t now; Line 41  extern time_t now;
41  p_tcl_bind_list bind_table_list;  p_tcl_bind_list bind_table_list;
42  p_tcl_bind_list H_chat, H_act, H_bcst, H_chon, H_chof, H_load, H_unld, H_link,  p_tcl_bind_list H_chat, H_act, H_bcst, H_chon, H_chof, H_load, H_unld, H_link,
43                  H_disc, H_dcc, H_chjn, H_chpt, H_bot, H_time, H_nkch, H_away,                  H_disc, H_dcc, H_chjn, H_chpt, H_bot, H_time, H_nkch, H_away,
44                  H_note, H_filt, H_event, H_cron, H_log = NULL;                  H_note, H_filt, H_event, H_die, H_cron, H_log = NULL;
45    #ifdef TLS
46    p_tcl_bind_list H_tls = NULL;
47    static int builtin_idx();
48    #endif
49    
50  static int builtin_2char();  static int builtin_2char();
51  static int builtin_3char();  static int builtin_3char();
# Line 237  void init_bind(void) Line 241  void init_bind(void)
241    H_away = add_bind_table("away", HT_STACKABLE, builtin_chat);    H_away = add_bind_table("away", HT_STACKABLE, builtin_chat);
242    H_act = add_bind_table("act", HT_STACKABLE, builtin_chat);    H_act = add_bind_table("act", HT_STACKABLE, builtin_chat);
243    H_event = add_bind_table("evnt", HT_STACKABLE, builtin_char);    H_event = add_bind_table("evnt", HT_STACKABLE, builtin_char);
244      H_die = add_bind_table("die", HT_STACKABLE, builtin_char);
245    H_log = add_bind_table("log", HT_STACKABLE, builtin_log);    H_log = add_bind_table("log", HT_STACKABLE, builtin_log);
246    #ifdef TLS
247      H_tls = add_bind_table("tls", HT_STACKABLE, builtin_idx);
248    #endif
249    add_builtins(H_dcc, C_dcc);    add_builtins(H_dcc, C_dcc);
250    Context;    Context;
251  }  }
# Line 687  static int builtin_log STDVAR Line 695  static int builtin_log STDVAR
695    return TCL_OK;    return TCL_OK;
696  }  }
697    
698    #ifdef TLS
699    static int builtin_idx STDVAR
700    {
701      Function F = (Function) cd;
702    
703      BADARGS(2, 2, " idx");
704    
705      CHECKVALIDITY(builtin_idx);
706      F(atoi(argv[1]));
707      return TCL_OK;
708    }
709    #endif
710    
711  /* Trigger (execute) a Tcl proc  /* Trigger (execute) a Tcl proc
712   *   *
713   * Note: This is INLINE code for check_tcl_bind().   * Note: This is INLINE code for check_tcl_bind().
# Line 723  static inline int trigger_bind(const cha Line 744  static inline int trigger_bind(const cha
744    if (x == TCL_ERROR) {    if (x == TCL_ERROR) {
745      /* FIXME: we really should be able to log longer errors */      /* FIXME: we really should be able to log longer errors */
746      putlog(LOG_MISC, "*", "Tcl error [%s]: %.*s", proc, 400, tcl_resultstring());      putlog(LOG_MISC, "*", "Tcl error [%s]: %.*s", proc, 400, tcl_resultstring());
747        Tcl_BackgroundError(interp);
748    
749      return BIND_EXECUTED;      return BIND_EXECUTED;
750    }    }
# Line 1163  void check_tcl_cron(struct tm *tm) Line 1185  void check_tcl_cron(struct tm *tm)
1185  void check_tcl_event(const char *event)  void check_tcl_event(const char *event)
1186  {  {
1187    Tcl_SetVar(interp, "_event1", (char *) event, 0);    Tcl_SetVar(interp, "_event1", (char *) event, 0);
1188    check_tcl_bind(H_event, event, 0, " $_event1", MATCH_EXACT | BIND_STACKABLE);    check_tcl_bind(H_event, event, 0, " $_event1",
1189                     MATCH_EXACT | BIND_STACKABLE);
1190    }
1191    
1192    int check_tcl_signal(const char *event)
1193    {
1194      int x;
1195    
1196      Tcl_SetVar(interp, "_event1", (char *) event, 0);
1197      x = check_tcl_bind(H_event, event, 0, " $_event1",
1198                     MATCH_EXACT | BIND_STACKABLE | BIND_STACKRET);
1199      return (x == BIND_EXEC_LOG);
1200    }
1201    
1202    void check_tcl_die(char *reason)
1203    {
1204      Tcl_SetVar(interp, "_die1", reason, 0);
1205      check_tcl_bind(H_die, reason, 0, " $_die1", MATCH_MASK | BIND_STACKABLE);
1206  }  }
1207    
1208  void check_tcl_log(int lv, char *chan, char *msg)  void check_tcl_log(int lv, char *chan, char *msg)
# Line 1178  void check_tcl_log(int lv, char *chan, c Line 1217  void check_tcl_log(int lv, char *chan, c
1217                   MATCH_MASK | BIND_STACKABLE);                   MATCH_MASK | BIND_STACKABLE);
1218  }  }
1219    
1220    #ifdef TLS
1221    int check_tcl_tls(int sock)
1222    {
1223      int x;
1224      char s[11];
1225    
1226      egg_snprintf(s, sizeof s, "%d", sock);
1227      Tcl_SetVar(interp, "_tls", s, 0);
1228      x = check_tcl_bind(H_tls, s, 0, " $_tls", MATCH_MASK | BIND_STACKABLE |
1229                         BIND_WANTRET);
1230      return (x == BIND_EXEC_LOG);
1231    }
1232    #endif
1233    
1234  void tell_binds(int idx, char *par)  void tell_binds(int idx, char *par)
1235  {  {
1236    tcl_bind_list_t *tl, *tl_kind;    tcl_bind_list_t *tl, *tl_kind;
# Line 1264  void add_builtins(tcl_bind_list_t *tl, c Line 1317  void add_builtins(tcl_bind_list_t *tl, c
1317    for (i = 0; cc[i].name; i++) {    for (i = 0; cc[i].name; i++) {
1318      egg_snprintf(p, sizeof p, "*%s:%s", tl->name,      egg_snprintf(p, sizeof p, "*%s:%s", tl->name,
1319                   cc[i].funcname ? cc[i].funcname : cc[i].name);                   cc[i].funcname ? cc[i].funcname : cc[i].name);
1320      l = nmalloc(Tcl_ScanElement(p, &k));      l = nmalloc(Tcl_ScanElement(p, &k) + 1);
1321      Tcl_ConvertElement(p, l, k | TCL_DONT_USE_BRACES);      Tcl_ConvertElement(p, l, k | TCL_DONT_USE_BRACES);
1322      table[0].cdata = (void *) cc[i].func;      table[0].cdata = (void *) cc[i].func;
1323      add_cd_tcl_cmds(table);      add_cd_tcl_cmds(table);
# Line 1282  void rem_builtins(tcl_bind_list_t *table Line 1335  void rem_builtins(tcl_bind_list_t *table
1335    for (i = 0; cc[i].name; i++) {    for (i = 0; cc[i].name; i++) {
1336      egg_snprintf(p, sizeof p, "*%s:%s", table->name,      egg_snprintf(p, sizeof p, "*%s:%s", table->name,
1337                   cc[i].funcname ? cc[i].funcname : cc[i].name);                   cc[i].funcname ? cc[i].funcname : cc[i].name);
1338      l = nmalloc(Tcl_ScanElement(p, &k));      l = nmalloc(Tcl_ScanElement(p, &k) + 1);
1339      Tcl_ConvertElement(p, l, k | TCL_DONT_USE_BRACES);      Tcl_ConvertElement(p, l, k | TCL_DONT_USE_BRACES);
1340      Tcl_DeleteCommand(interp, p);      Tcl_DeleteCommand(interp, p);
1341      unbind_bind_entry(table, cc[i].flags, cc[i].name, l);      unbind_bind_entry(table, cc[i].flags, cc[i].name, l);

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.6

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23