/[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 by simple, Mon Jul 26 21:11:06 2010 UTC revision 1.3.2.2 by pseudo, Wed Jan 12 13:54:00 2011 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 69  static inline void *n_malloc_null(int si Line 73  static inline void *n_malloc_null(int si
73    void *ptr = nmalloc(size);    void *ptr = nmalloc(size);
74  #endif  #endif
75    
76    egg_memset(ptr, 0, size);    memset(ptr, 0, size);
77    return ptr;    return ptr;
78  }  }
79    
# 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 251  void kill_bind(void) Line 259  void kill_bind(void)
259      tl_next = tl->next;      tl_next = tl->next;
260    
261      if (!(tl->flags |= HT_DELETED))      if (!(tl->flags |= HT_DELETED))
262        putlog(LOG_DEBUG, "*", "De-Allocated bind table %s", tl->name);        putlog(LOG_DEBUG, "*", _("De-Allocated bind table %s"), tl->name);
263      tcl_bind_list_delete(tl);      tcl_bind_list_delete(tl);
264    }    }
265    H_log = NULL;    H_log = NULL;
# Line 290  tcl_bind_list_t *add_bind_table(const ch Line 298  tcl_bind_list_t *add_bind_table(const ch
298      bind_table_list = tl;      bind_table_list = tl;
299    }    }
300    
301    putlog(LOG_DEBUG, "*", "Allocated bind table %s (flags %d)", nme, flg);    putlog(LOG_DEBUG, "*", _("Allocated bind table %s (flags %d)"), nme, flg);
302    return tl;    return tl;
303  }  }
304    
# Line 303  void del_bind_table(tcl_bind_list_t *tl_ Line 311  void del_bind_table(tcl_bind_list_t *tl_
311        continue;        continue;
312      if (tl == tl_which) {      if (tl == tl_which) {
313        tl->flags |= HT_DELETED;        tl->flags |= HT_DELETED;
314        putlog(LOG_DEBUG, "*", "De-Allocated bind table %s", tl->name);        putlog(LOG_DEBUG, "*", _("De-Allocated bind table %s"), tl->name);
315        return;        return;
316      }      }
317    }    }
318    putlog(LOG_DEBUG, "*", "??? Tried to delete not listed bind table ???");    putlog(LOG_DEBUG, "*", _("??? Tried to delete not listed bind table ???"));
319  }  }
320    
321  tcl_bind_list_t *find_bind_table(const char *nme)  tcl_bind_list_t *find_bind_table(const char *nme)
# 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 921  int check_tcl_dcc(const char *cmd, int i Line 942  int check_tcl_dcc(const char *cmd, int i
942    x = check_tcl_bind(H_dcc, cmd, &fr, " $_dcc1 $_dcc2 $_dcc3",    x = check_tcl_bind(H_dcc, cmd, &fr, " $_dcc1 $_dcc2 $_dcc3",
943                       MATCH_PARTIAL | BIND_USE_ATTR | BIND_HAS_BUILTINS);                       MATCH_PARTIAL | BIND_USE_ATTR | BIND_HAS_BUILTINS);
944    if (x == BIND_AMBIGUOUS) {    if (x == BIND_AMBIGUOUS) {
945      dprintf(idx, MISC_AMBIGUOUS);      dprintf(idx, _("Ambiguous command.\n"));
946      return 0;      return 0;
947    }    }
948    if (x == BIND_NOMATCH) {    if (x == BIND_NOMATCH) {
949      dprintf(idx, MISC_NOSUCHCMD);      dprintf(idx, _("What?  You need '.help'\n"));
950      return 0;      return 0;
951    }    }
952    
# Line 1160  void check_tcl_cron(struct tm *tm) Line 1181  void check_tcl_cron(struct tm *tm)
1181                   MATCH_CRON | BIND_STACKABLE);                   MATCH_CRON | BIND_STACKABLE);
1182  }  }
1183    
1184  void check_tcl_event(const char *event)  int check_tcl_event(const char *event)
1185  {  {
1186      int x;
1187    
1188    Tcl_SetVar(interp, "_event1", (char *) event, 0);    Tcl_SetVar(interp, "_event1", (char *) event, 0);
1189    check_tcl_bind(H_event, event, 0, " $_event1", MATCH_EXACT | BIND_STACKABLE);    x = check_tcl_bind(H_event, event, 0, " $_event1",
1190                     MATCH_EXACT | BIND_STACKABLE | BIND_WANTRET);
1191      return (x == BIND_EXEC_LOG);
1192    }
1193    
1194    void check_tcl_die(char *reason)
1195    {
1196      Tcl_SetVar(interp, "_die1", reason, 0);
1197      check_tcl_bind(H_die, reason, 0, " $_die1", MATCH_MASK | BIND_STACKABLE);
1198  }  }
1199    
1200  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 1209  void check_tcl_log(int lv, char *chan, c
1209                   MATCH_MASK | BIND_STACKABLE);                   MATCH_MASK | BIND_STACKABLE);
1210  }  }
1211    
1212    #ifdef TLS
1213    int check_tcl_tls(int sock)
1214    {
1215      int x;
1216      char s[11];
1217    
1218      egg_snprintf(s, sizeof s, "%d", sock);
1219      Tcl_SetVar(interp, "_tls", s, 0);
1220      x = check_tcl_bind(H_tls, s, 0, " $_tls", MATCH_MASK | BIND_STACKABLE |
1221                         BIND_WANTRET);
1222      return (x == BIND_EXEC_LOG);
1223    }
1224    #endif
1225    
1226  void tell_binds(int idx, char *par)  void tell_binds(int idx, char *par)
1227  {  {
1228    tcl_bind_list_t *tl, *tl_kind;    tcl_bind_list_t *tl, *tl_kind;
# Line 1206  void tell_binds(int idx, char *par) Line 1251  void tell_binds(int idx, char *par)
1251    if (tl_kind == NULL && name && name[0] && egg_strcasecmp(name, "all"))    if (tl_kind == NULL && name && name[0] && egg_strcasecmp(name, "all"))
1252      patmatc = 1;      patmatc = 1;
1253    
1254    dprintf(idx, MISC_CMDBINDS);    dprintf(idx, _("Command bindings:\n"));
1255    dprintf(idx, "  TYPE FLAGS    COMMAND              HITS BINDING (TCL)\n");    dprintf(idx, _("  TYPE FLAGS    COMMAND              HITS BINDING (TCL)\n"));
1256    
1257    for (tl = tl_kind ? tl_kind : bind_table_list; tl;    for (tl = tl_kind ? tl_kind : bind_table_list; tl;
1258         tl = tl_kind ? 0 : tl->next) {         tl = tl_kind ? 0 : tl->next) {
# Line 1243  void tell_binds(int idx, char *par) Line 1288  void tell_binds(int idx, char *par)
1288    }    }
1289    if (!fnd) {    if (!fnd) {
1290      if (patmatc)      if (patmatc)
1291        dprintf(idx, "No command bindings found that match %s\n", name);        dprintf(idx, _("No command bindings found that match %s\n"), name);
1292      else if (tl_kind)      else if (tl_kind)
1293        dprintf(idx, "No command bindings for type: %s.\n", name);        dprintf(idx, _("No command bindings for type: %s.\n"), name);
1294      else      else
1295        dprintf(idx, "No command bindings exist.\n");        dprintf(idx, _("No command bindings exist.\n"));
1296    }    }
1297  }  }
1298    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3.2.2

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23