void init_bind(void) { bind_table_list = NULL; add_cd_tcl_cmds(cd_cmd_table); H_unld = add_bind_table("unld", HT_STACKABLE, builtin_char); H_time = add_bind_table("time", HT_STACKABLE, builtin_5int); H_note = add_bind_table("note", 0, builtin_3char); H_nkch = add_bind_table("nkch", HT_STACKABLE, builtin_2char); H_load = add_bind_table("load", HT_STACKABLE, builtin_char); H_link = add_bind_table("link", HT_STACKABLE, builtin_2char); H_filt = add_bind_table("filt", HT_STACKABLE, builtin_idxchar); H_disc = add_bind_table("disc", HT_STACKABLE, builtin_char); H_dcc = add_bind_table("dcc", 0, builtin_dcc); H_chpt = add_bind_table("chpt", HT_STACKABLE, builtin_chpt); H_chon = add_bind_table("chon", HT_STACKABLE, builtin_charidx); H_chof = add_bind_table("chof", HT_STACKABLE, builtin_charidx); H_chjn = add_bind_table("chjn", HT_STACKABLE, builtin_chjn); H_chat = add_bind_table("chat", HT_STACKABLE, builtin_chat); H_bot = add_bind_table("bot", 0, builtin_3char); H_bcst = add_bind_table("bcst", HT_STACKABLE, builtin_chat); H_away = add_bind_table("away", HT_STACKABLE, builtin_chat); H_act = add_bind_table("act", HT_STACKABLE, builtin_chat); H_event = add_bind_table("evnt", HT_STACKABLE, builtin_char); add_builtins(H_dcc, C_dcc); add_builtins(H_dcc, traffic_dcc); add_builtins(H_dcc, help_dcc); add_builtins(H_dcc, logfile_dcc); }
char *filesys_start(Function *global_funcs) { global = global_funcs; module_register(MODULE_NAME, filesys_table, 2, 0); if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.6.0 or later."; } if (!(transfer_funcs = module_depend(MODULE_NAME, "transfer", 2, 0))) { module_undepend(MODULE_NAME); return "This module requires transfer module 2.0 or later."; } add_tcl_commands(mytcls); add_tcl_strings(mystrings); add_tcl_ints(myints); H_fil = add_bind_table("fil", 0, builtin_fil); add_builtins(H_dcc, mydcc); add_builtins(H_fil, myfiles); add_builtins(H_load, myload); add_help_reference("filesys.help"); init_server_ctcps(0); my_memcpy(&USERENTRY_DCCDIR, &USERENTRY_INFO, sizeof(struct user_entry_type) - sizeof(char *)); USERENTRY_DCCDIR.got_share = 0; /* We dont want it shared tho */ add_entry_type(&USERENTRY_DCCDIR); DCC_FILES_PASS.timeout_val = &password_timeout; add_lang_section("filesys"); return NULL; }
char *wire_start(Function *global_funcs) { p_tcl_bind_list H_temp; global = global_funcs; module_register(MODULE_NAME, wire_table, 2, 0); if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.6.0 or later."; } if (!(encryption_funcs = module_depend(MODULE_NAME, "encryption", 2, 1))) { module_undepend(MODULE_NAME); return "This module requires an encryption module."; } add_help_reference("wire.help"); add_builtins(H_dcc, wire_dcc); H_temp = find_bind_table("filt"); add_builtins(H_filt, wire_filt); H_temp = find_bind_table("chof"); add_builtins(H_chof, wire_chof); wirelist = NULL; add_lang_section("wire"); return NULL; }
char *filesys_start(Function * global_funcs) { global = global_funcs; Context; dccdir[0] = 0; dccin[0] = 0; filedb_path[0] = 0; module_register(MODULE_NAME, filesys_table, 2, 0); if (!(transfer_funcs = module_depend(MODULE_NAME, "transfer", 2, 0))) return "You need the transfer module to user the file system."; if (!module_depend(MODULE_NAME, "eggdrop", 104, 0)) return "You need at least eggdrop1.4.0 to run this module."; add_tcl_commands(mytcls); add_tcl_strings(mystrings); add_tcl_ints(myints); H_fil = add_bind_table("fil", 0, builtin_fil); add_builtins(H_dcc, mydcc); add_builtins(H_fil, myfiles); add_builtins(H_load, myload); add_help_reference("filesys.help"); init_server_ctcps(0); my_memcpy(&USERENTRY_DCCDIR, &USERENTRY_INFO, sizeof(struct user_entry_type) - sizeof(char *)); USERENTRY_DCCDIR.got_share = 0; /* we dont want it shared tho */ add_entry_type(&USERENTRY_DCCDIR); DCC_FILES_PASS.timeout_val = &password_timeout; add_lang_section("filesys"); return NULL; }
char *notes_start(Function *global_funcs) { global = global_funcs; notefile[0] = 0; module_register(MODULE_NAME, notes_table, 2, 2); if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.8.0 or later."; } add_hook(HOOK_HOURLY, (Function) notes_hourly); add_hook(HOOK_MATCH_NOTEREJ, (Function) match_note_ignore); add_tcl_ints(notes_ints); add_tcl_strings(notes_strings); add_tcl_commands(notes_tcls); add_builtins(H_dcc, notes_cmds); add_builtins(H_chon, notes_chon); add_builtins(H_away, notes_away); add_builtins(H_nkch, notes_nkch); add_builtins(H_load, notes_load); add_help_reference("notes.help"); add_lang_section("notes"); notes_server_setup(0); notes_irc_setup(0); my_memcpy(&USERENTRY_FWD, &USERENTRY_INFO, sizeof(void *) * 12); add_entry_type(&USERENTRY_FWD); return NULL; }
void console_init() { add_builtins("dcc", mydcc); add_builtins("chon", mychon); add_entry_type(&USERENTRY_CONSOLE); }
machine *make_machine() { machine *ret = NEW(machine); ret->base_frame = make_frame(NULL, make_table(), make_table(), make_table(), NULL, PAUSE); incref(ret->base_frame); ret->current_frame = ret->base_frame; incref(ret->current_frame); ret->now = ret->base_frame; incref(ret->now); ret->accumulator = NULL; ret->paused = 0; ret->trace = make_stack_trace(arg("bottom-of-the-barrel"), NULL, NULL); incref(ret->trace); add_builtins(ret); add_builtin_numbers(ret); add_builtin_strings(ret); add_builtin_files(ret); return ret; }
char *ctcp_start(Function *global_funcs) { global = global_funcs; module_register(MODULE_NAME, ctcp_table, 1, 1); if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.8.0 or later."; } if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0))) { module_undepend(MODULE_NAME); return "This module requires server module 1.0 or later."; } add_tcl_strings(mystrings); add_tcl_ints(myints); add_builtins(H_ctcp, myctcp); add_help_reference("ctcp.help"); if (!ctcp_version[0]) { strncpy(ctcp_version, ver, 120); ctcp_version[120] = 0; } if (!ctcp_finger[0]) { strncpy(ctcp_finger, ver, 120); ctcp_finger[120] = 0; } if (!ctcp_userinfo[0]) { strncpy(ctcp_userinfo, ver, 120); ctcp_userinfo[120] = 0; } return NULL; }
char *seen_start(Function * egg_func_table) { global = egg_func_table; Context; module_register(MODULE_NAME, seen_table, 2, 0); if (!module_depend(MODULE_NAME, "eggdrop", 104, 0)) return "This module needs eggdrop1.4.0 or later"; add_builtins(H_load, seen_load); add_builtins(H_dcc, seen_dcc); add_help_reference("seen.help"); server_seen_setup(0); irc_seen_setup(0); trigdata[4].key = botnetnick; return NULL; }
static void init_server_ctcps(char *module) { p_tcl_bind_list H_ctcp; if ((H_ctcp = find_bind_table("ctcp"))) add_builtins(H_ctcp, myctcp); }
void channels_init() { timer_create_secs(60, "check_expired_masks", (Function) check_expired_masks); if (conf.bot->hub) { timer_create_secs(30, "rebalance_roles", (Function) rebalance_roles); timer_create_secs(30, "check_should_close", (Function) check_should_close); #ifdef G_BACKUP timer_create_secs(30, "check_should_backup", (Function) check_should_backup); #endif /* G_BACKUP */ } timer_create_secs(10, "channels_timers", (Function) channels_timers); add_builtins("dcc", C_dcc_channels); add_builtins("bot", channels_bot); add_builtins("chon", my_chon); }
/* This function is called as the module is loaded. */ char *sample_start(Function *global_funcs) { /* Assign the global function table. After this point, you can use all * normal functions defined in src/mod/modules.h. */ global = global_funcs; /* Register the module. */ module_register(MODULE_NAME, sample_table, 2, 0); /* ^--- minor module version * ^------ major module version * ^-------------------- module function table * ^--------------------------------- module name */ /* Depend on the Eggdrop core, version 1.7.0 or later. */ if (!module_depend(MODULE_NAME, "eggdrop", 107, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.7.0 or later."; } /* Add command table to bind list H_dcc, responsible for DCC/partyline * commands. Currently we only add one command, 'sample'. */ add_builtins(H_dcc, mydcc); /* Return NULL unless we're passing an error message. */ return NULL; }
static int notes_irc_setup(char *mod) { p_tcl_bind_list H_temp; if ((H_temp = find_bind_table("join"))) add_builtins(H_temp, notes_join); return 0; }
static int notes_server_setup(char *mod) { p_tcl_bind_list H_temp; if ((H_temp = find_bind_table("msg"))) add_builtins(H_temp, notes_msgs); return 0; }
char *seen_start(Function *egg_func_table) { global = egg_func_table; module_register(MODULE_NAME, seen_table, 2, 0); if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.6.0 or later."; } add_builtins(H_load, seen_load); add_builtins(H_dcc, seen_dcc); add_help_reference("seen.help"); server_seen_setup(NULL); irc_seen_setup(NULL); trigdata[4].key = botnetnick; return NULL; }
static int irc_seen_setup(char *mod) { p_tcl_bind_list H_temp; if ((H_temp = find_bind_table("pub"))) add_builtins(H_temp, seen_pub); return 0; }
char *assoc_start(Function *global_funcs) { global = global_funcs; module_register(MODULE_NAME, assoc_table, 2, 0); if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.6.0 or later."; } assoc = NULL; add_builtins(H_dcc, mydcc); add_builtins(H_bot, mybot); add_builtins(H_link, mylink); add_lang_section("assoc"); add_tcl_commands(mytcl); add_help_reference("assoc.help"); return NULL; }
char *channels_start(Function * global_funcs) { global = global_funcs; gfld_chan_thr = 10; gfld_chan_time = 60; gfld_deop_thr = 3; gfld_deop_time = 10; gfld_kick_thr = 3; gfld_kick_time = 10; gfld_join_thr = 5; gfld_join_time = 60; gfld_ctcp_thr = 5; gfld_ctcp_time = 60; global_idle_kick = 0; Context; module_register(MODULE_NAME, channels_table, 1, 0); if (!module_depend(MODULE_NAME, "eggdrop", 105, 3)) { module_undepend(MODULE_NAME); return "This module needs eggdrop1.5.3 or later"; } add_hook(HOOK_MINUTELY, (Function) check_expired_bans); add_hook(HOOK_MINUTELY, (Function) check_expired_exempts); add_hook(HOOK_MINUTELY, (Function) check_expired_invites); add_hook(HOOK_USERFILE, (Function) channels_writeuserfile); add_hook(HOOK_REHASH, (Function) channels_rehash); add_hook(HOOK_PRE_REHASH, (Function) channels_prerehash); Tcl_TraceVar(interp, "global-chanset", TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, traced_globchanset, NULL); add_builtins(H_chon, my_chon); add_builtins(H_dcc, C_dcc_irc); add_tcl_commands(channels_cmds); add_tcl_strings(my_tcl_strings); add_help_reference("channels.help"); add_help_reference("chaninfo.help"); my_tcl_ints[0].val = &share_greet; add_tcl_ints(my_tcl_ints); add_tcl_coups(mychan_tcl_coups); read_channels(0); setstatic = 1; return NULL; }
/** * Create a TestBaseCli object. */ TestBaseCli::TestBaseCli(YangModel& model, bool debug) : BaseCli(model), editline_(NULL), debug_(debug) { ModeState::ptr_t new_root_mode(new ModeState(*this,*root_parse_node_)); mode_stack_root(std::move(new_root_mode)); add_builtins(); setprompt(); }
void core_binds_init() { BT_away = bind_table_add("away", 3, "sis", MATCH_MASK, BIND_STACKABLE); BT_bot = bind_table_add("bot", 3, "sss", MATCH_EXACT, 0); BT_chon = bind_table_add("chon", 2, "si", MATCH_MASK | MATCH_FLAGS, BIND_STACKABLE); BT_dcc = bind_table_add("dcc", 2, "is", MATCH_PARTIAL | MATCH_FLAGS, 0); egg_bzero(&cmdlist, 500); add_builtins("dcc", C_dcc); BT_nkch = bind_table_add("nkch", 2, "ss", MATCH_MASK, BIND_STACKABLE); BT_note = bind_table_add("note", 3 , "sss", MATCH_EXACT, 0); BT_time = bind_table_add("time", 5, "iiiii", MATCH_MASK, BIND_STACKABLE); }
void ctcp_init() { char *p = NULL; struct utsname un; bzero(&un, sizeof(un)); if (!uname(&un)) { strlcpy(cloak_os, un.sysname, sizeof(cloak_os)); strlcpy(cloak_osver, un.release, sizeof(cloak_osver)); strlcpy(cloak_host, un.nodename, sizeof(cloak_host)); } else { /* shit, we have to come up with something ourselves.. */ switch (randint(2)) { case 0: strlcpy(cloak_os, "Linux", sizeof(cloak_os)); strlcpy(cloak_osver, "2.6.25.5", sizeof(cloak_osver)); break; case 1: strlcpy(cloak_os, "FreeBSD", sizeof(cloak_os)); strlcpy(cloak_osver, "7.0-p4", sizeof(cloak_osver)); break; } strlcpy(cloak_host, "login", sizeof(cloak_host)); } if ((p = strchr(cloak_host, '.'))) *p = 0; switch (randint(4)) { case 0: strlcpy(cloak_bxver, "1.1-final", sizeof(cloak_bxver)); break; case 1: strlcpy(cloak_bxver, "1.0c18", sizeof(cloak_bxver)); break; case 2: strlcpy(cloak_bxver, "1.0c19", sizeof(cloak_bxver)); break; case 3: strlcpy(cloak_bxver, "1.0c20cvs+", sizeof(cloak_bxver)); break; } scriptchanged(); add_builtins("ctcp", myctcp); timer_create_secs(60, "ctcp_minutely", (Function) ctcp_minutely); }
void init_builtins(t_shell *shell) { t_builtins *cur; cur = NULL; cur = add_builtins("cd", cur, &builtins_cd); cur = add_builtins("pwd", cur, &builtins_pwd); cur = add_builtins("exit", cur, &builtins_exit); cur = add_builtins("env", cur, &builtins_env); cur = add_builtins("setenv", cur, &builtins_setenv); cur = add_builtins("unsetenv", cur, &builtins_unsetenv); shell->builtins = cur; }
static int init_mysh(t_term *s_term, char **environ) { char *env_path; my_bzero((void *)s_term, sizeof(*s_term)); if (environ && *environ) { get_environ(s_term, environ); static_term(s_term); init_signals(); s_term->tsave = init_termcap(s_term->environ); s_term->pid = my_getpid(); s_term->progs = NULL; if ((env_path = my_getenv(environ, "PATH=")) && (s_term->progs = get_path_progs(env_path)) && !add_builtins(s_term->progs)) return (1); } return (0); }
char *channels_start(Function *global_funcs) { global = global_funcs; gfld_chan_thr = 10; gfld_chan_time = 60; gfld_deop_thr = 3; gfld_deop_time = 10; gfld_kick_thr = 3; gfld_kick_time = 10; gfld_join_thr = 5; gfld_join_time = 60; gfld_ctcp_thr = 5; gfld_ctcp_time = 60; global_idle_kick = 0; global_aop_min = 5; global_aop_max = 30; allow_ps = 0; lastdeletedmask = 0; use_info = 1; strcpy(chanfile, "chanfile"); chan_hack = 0; quiet_save = 0; strcpy(glob_chanmode, "nt"); udef = NULL; global_stopnethack_mode = 0; global_revenge_mode = 0; global_ban_type = 3; global_ban_time = 120; global_exempt_time = 60; global_invite_time = 60; strcpy(glob_chanset, "-enforcebans " "+dynamicbans " "+userbans " "-autoop " "-bitch " "+greet " "+protectops " "+statuslog " "-revenge " "-secret " "-autovoice " "+cycle " "+dontkickops " "-inactive " "-protectfriends " "+shared " "-seen " "+userexempts " "+dynamicexempts " "+userinvites " "+dynamicinvites " "-revengebot " "-protecthalfops " "-autohalfop " "-nodesynch " "-static "); module_register(MODULE_NAME, channels_table, 1, 1); if (!module_depend(MODULE_NAME, "eggdrop", 106, 20)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.6.20 or later."; } add_hook(HOOK_MINUTELY, (Function) check_expired_bans); add_hook(HOOK_MINUTELY, (Function) check_expired_exempts); add_hook(HOOK_MINUTELY, (Function) check_expired_invites); add_hook(HOOK_USERFILE, (Function) channels_writeuserfile); add_hook(HOOK_BACKUP, (Function) backup_chanfile); add_hook(HOOK_REHASH, (Function) channels_rehash); add_hook(HOOK_PRE_REHASH, (Function) channels_prerehash); Tcl_TraceVar(interp, "global-chanset", TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, traced_globchanset, NULL); add_builtins(H_chon, my_chon); add_builtins(H_dcc, C_dcc_irc); add_tcl_commands(channels_cmds); add_tcl_strings(my_tcl_strings); add_help_reference("channels.help"); add_help_reference("chaninfo.help"); my_tcl_ints[0].val = &share_greet; add_tcl_ints(my_tcl_ints); add_tcl_coups(mychan_tcl_coups); read_channels(0, 1); return NULL; }
static inline size_t add_builtins(const struct ast_unit *const unit) { size_t offset = 0; for (scope_bcon_id_t id = 0; id < SCOPE_BCON_ID_COUNT; ++id) { unit->scope->objs[offset++] = (struct scope_obj) { .name = scope_builtin_consts[id].name, .obj = SCOPE_OBJ_BCON, .bcon_id = id, }; } for (scope_bfun_id_t id = 0; id < SCOPE_BFUN_ID_COUNT; ++id) { unit->scope->objs[offset++] = (struct scope_obj) { .name = scope_builtin_funcs[id].name, .obj = SCOPE_OBJ_BFUN, .bfun_id = id, }; } return offset; } static int scope_build_inner(struct ast_node *const node, const struct scope *const outer) { assert(node != NULL); static struct ast_func *outer_func; int error = SCOPE_OK; switch (node->an) { case AST_AN_FUNC: { struct ast_func *const func = ast_data(node, func); const size_t objcount = count_objects_block(node); assert(func->scope == NULL); if (unlikely(!(func->scope = scope_alloc(objcount)))) { return NOMEM; } func->scope->outer = outer; func->scope->objcount = objcount; size_t offset = 0; for (size_t param_idx = 0; param_idx < func->param_count; ++param_idx) { func->scope->objs[offset++] = (struct scope_obj) { .name = func->params[param_idx].name, .obj = SCOPE_OBJ_PARM, .type = func->params[param_idx].type, }; } outer_func = func; for (size_t idx = 0; idx < func->stmt_count; ++idx) { struct ast_node *const stmt = func->stmts[idx]; if (unlikely(!stmt)) { continue; } if (stmt->an == AST_AN_DECL) { const struct ast_decl *const decl = ast_data(stmt, decl); for (size_t name_idx = 0; name_idx < decl->name_count; ++name_idx) { func->scope->objs[offset++] = (struct scope_obj) { .name = decl->names[name_idx], .obj = SCOPE_OBJ_AVAR, .decl = stmt, }; } } else if (stmt->an == AST_AN_WLAB) { aggr_error(&error, add_func_wlab(func, stmt)); } else { aggr_error(&error, scope_build_inner(stmt, func->scope)); } } qsort(func->wlabs, func->wlab_count, sizeof(*func->wlabs), cmp_scope_obj); identify_wlabs(func); aggr_error(&error, find_duplicates(func->scope->objs, objcount)); qsort(func->scope->objs, objcount, sizeof(struct scope_obj), cmp_scope_obj); } break; case AST_AN_BLOK: case AST_AN_NOIN: case AST_AN_WHIL: case AST_AN_DOWH: { struct scope **scope; size_t stmt_count; struct ast_node **stmts; const size_t objcount = count_objects_block(node); if (node->an == AST_AN_BLOK || node->an == AST_AN_NOIN) { struct ast_blok *const blok = ast_data(node, blok); scope = &blok->scope; stmt_count = blok->stmt_count; stmts = blok->stmts; } else { struct ast_whil *const whil = ast_data(node, whil); scope = &whil->scope; stmt_count = whil->stmt_count; stmts = whil->stmts; } assert(*scope == NULL); if (unlikely(!(*scope = scope_alloc(objcount)))) { return NOMEM; } (*scope)->outer = outer; (*scope)->objcount = objcount; for (size_t idx = 0, offset = 0; idx < stmt_count; ++idx) { struct ast_node *const stmt = stmts[idx]; if (unlikely(!stmt)) { continue; } if (stmt->an == AST_AN_DECL) { const struct ast_decl *const decl = ast_data(stmt, decl); for (size_t name_idx = 0; name_idx < decl->name_count; ++name_idx) { (*scope)->objs[offset++] = (struct scope_obj) { .name = decl->names[name_idx], .obj = SCOPE_OBJ_AVAR, .decl = stmt, }; } } else if (stmt->an == AST_AN_WLAB) { aggr_error(&error, add_func_wlab(outer_func, stmt)); } else { aggr_error(&error, scope_build_inner(stmt, *scope)); } } aggr_error(&error, find_duplicates((*scope)->objs, objcount)); qsort((*scope)->objs, objcount, sizeof(struct scope_obj), cmp_scope_obj); } break; case AST_AN_COND: { struct ast_cond *const cond = ast_data(node, cond); aggr_error(&error, scope_build_inner(cond->if_block, outer)); for (size_t idx = 0; idx < cond->elif_count; ++idx) { aggr_error(&error, scope_build_inner(cond->elif[idx].block, outer)); } if (cond->else_block) { aggr_error(&error, scope_build_inner(cond->else_block, outer)); } } break; } return error; } int scope_build(struct ast_node *const root) { assert(root != NULL); struct ast_unit *const unit = ast_data(root, unit); size_t objcount = count_objects_unit(unit); assert(unit->scope == NULL); if (unlikely(!(unit->scope = scope_alloc(objcount)))) { return NOMEM; } unit->scope->objcount = objcount; size_t offset = add_builtins(unit); int error = SCOPE_OK; for (size_t idx = 0; idx < unit->stmt_count; ++idx) { struct ast_node *const stmt = unit->stmts[idx]; if (unlikely(!stmt)) { continue; } if (stmt->an == AST_AN_DECL) { const struct ast_decl *const decl = ast_data(stmt, decl); for (size_t name_idx = 0; name_idx < decl->name_count; ++name_idx) { unit->scope->objs[offset++] = (struct scope_obj) { .name = decl->names[name_idx], .obj = SCOPE_OBJ_GVAR, .decl = stmt, }; } } else if (stmt->an == AST_AN_FUNC) { const struct ast_func *const func = ast_data(stmt, func); unit->scope->objs[offset++] = (struct scope_obj) { .name = func->name, .obj = SCOPE_OBJ_FUNC, .func = stmt, }; aggr_error(&error, scope_build_inner(stmt, unit->scope)); } } aggr_error(&error, find_duplicates(unit->scope->objs, objcount)); qsort(unit->scope->objs, objcount, sizeof(struct scope_obj), cmp_scope_obj); return error; } struct scope_obj *scope_find_object(const struct scope *scope, const struct lex_symbol *const name) { const struct scope_obj needle = { .name = name }; do { struct scope_obj *const found = bsearch(&needle, scope->objs, scope->objcount, sizeof(struct scope_obj), cmp_scope_obj); if (found && found->obj != SCOPE_OBJ_DUPL) { if (found->obj == SCOPE_OBJ_AVAR) { const struct ast_decl *const decl = ast_data(found->decl, decl); return likely(name->beg > decl->names[0]->beg) ? found : NULL; } else { return found; } } } while ((scope = scope->outer)); return NULL; } ptrdiff_t scope_find_wlab(const struct ast_func *const func, const struct lex_symbol *const name) { const struct scope_obj needle = { .name = name }; const ssize_t elem_size = sizeof(*func->wlabs); const void *const found = bsearch(&needle, func->wlabs, func->wlab_count, (size_t) elem_size, cmp_scope_obj); return likely(found) ? ((char *) found - (char *) func->wlabs) / elem_size : -1; }
static void wire_join(int idx, char *key) { char wirecmd[512]; char wiremsg[512]; char wiretmp[512]; char *enctmp; wire_list *w = wirelist, *w2; while (w) { if (w->next == 0) break; w = w->next; } if (!wirelist) { wirelist = nmalloc(sizeof *wirelist); w = wirelist; } else { w->next = nmalloc(sizeof *w->next); w = w->next; } w->sock = dcc[idx].sock; w->key = nmalloc(strlen(key) + 1); strcpy(w->key, key); w->next = 0; enctmp = encrypt_string(w->key, "wire"); strcpy(wiretmp, enctmp); nfree(enctmp); w->crypt = nmalloc(strlen(wiretmp) + 1); strcpy(w->crypt, wiretmp); sprintf(wirecmd, "!wire%s", wiretmp); sprintf(wiremsg, "%s joined wire '%s'", dcc[idx].nick, key); enctmp = encrypt_string(w->key, wiremsg); strcpy(wiretmp, enctmp); nfree(enctmp); { char x[1024]; simple_sprintf(x, "%s %s", botnetnick, wiretmp); botnet_send_zapf_broad(-1, botnetnick, wirecmd, x); } w2 = wirelist; while (w2) { if (!strcmp(w2->key, w->key)) dprintf(findanyidx(w2->sock), "----- %s %s '%s'.\n", dcc[findanyidx(w->sock)].nick, WIRE_JOINED, w2->key); w2 = w2->next; } w2 = wirelist; while (w2) { /* Is someone using this key here already? */ if (w2 != w) if (!strcmp(w2->key, w->key)) break; w2 = w2->next; } if (!w2) { /* Someone else is NOT using this key, so * we add a bind */ wire_bot[0].name = wirecmd; wire_bot[0].flags = ""; wire_bot[0].func = (IntFunc) wire_filter; add_builtins(H_bot, wire_bot); } }
int main(int argc, char** argv) { vector<string> in_files; // Names of the input files string exe_fname; // Name of the output executable bool run_lex_only = false; // Check whether only an input file (without the -i option) was given if(argc == 2) { in_files.push_back(string(argv[1])); } else { // Get file names char c; while((c = getopt(argc, argv, "i:l:")) != -1) { switch(c) { case 'i': // Input file in_files.push_back(string(optarg)); break; case 'l' : printLex = true; exe_fname = string(optarg); break; case '?': help(argv[0]); return -1; } } } // Fail if no input is given if(in_files.empty()) { cout << "Must specify at least one input file" << endl; help(argv[0]); return -1; } // We need to parse every file separately. ASTs will // combine as we go. for(auto in_fname : in_files) { // Start the lexer int err; if((err = perform_lex(in_fname, printLex))) { cout << "Failed lex on " << in_fname << endl; return err; } } add_builtins(); // Builds the scope table BuildST build; try { ast->accept(&build); } catch (StBuildErr& e) { cout << e.what() << endl; return 0; } CheckScope cs; try { build.getCurrScope()->accept(&cs); } catch (ScopeCheckErr& e) { cout << e.what() << endl; return 0; } // Runs the type checker TypeCheck tc(build.getCurrScope()); try { ast->accept(&tc); } catch (TypeErr& e) { cout << e.what() << endl; return 0; } // Build the IR ir::BuildIR bir(ast); codegen::Director* d = codegen::Director::getInstance(); d->generateCode(bir.getClassList()); d->writeFile("compout.s"); // Prints the AST PrettyPrint pp; ast->accept(&pp); cout << endl << "################" << endl << endl; // Prints the symbol tree SymbolTablePrint spt; build.getCurrScope()->accept(&spt); cout << endl << "################" << endl << endl; // Prints the IR ir::IrPrint irp; irp.visit(bir.getClassList()); delete ast; return 0; }
void init_botcmd() { add_builtins("bot", my_bot); }
char *irc_start(Function *global_funcs) { struct chanset_t *chan; global = global_funcs; module_register(MODULE_NAME, irc_table, 1, 5); if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.8.0 or later."; } if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0))) { module_undepend(MODULE_NAME); return "This module requires server module 1.0 or later."; } if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 1))) { module_undepend(MODULE_NAME); return "This module requires channels module 1.1 or later."; } for (chan = chanset; chan; chan = chan->next) { if (!channel_inactive(chan)) { if (chan->key_prot[0]) dprintf(DP_SERVER, "JOIN %s %s\n", chan->name[0] ? chan->name : chan->dname, chan->key_prot); else dprintf(DP_SERVER, "JOIN %s\n", chan->name[0] ? chan->name : chan->dname); } chan->status &= ~(CHAN_ACTIVE | CHAN_PEND | CHAN_ASKEDBANS); chan->ircnet_status &= ~(CHAN_ASKED_INVITED | CHAN_ASKED_EXEMPTS); } add_hook(HOOK_MINUTELY, (Function) check_expired_chanstuff); add_hook(HOOK_5MINUTELY, (Function) status_log); add_hook(HOOK_ADD_MODE, (Function) real_add_mode); add_hook(HOOK_IDLE, (Function) flush_modes); Tcl_TraceVar(interp, "net-type", TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, traced_nettype, NULL); Tcl_TraceVar(interp, "rfc-compliant", TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, traced_rfccompliant, NULL); strcpy(opchars, "@"); add_tcl_strings(mystrings); add_tcl_ints(myints); add_builtins(H_dcc, irc_dcc); add_builtins(H_msg, C_msg); add_builtins(H_raw, irc_raw); add_tcl_commands(tclchan_cmds); add_help_reference("irc.help"); H_topc = add_bind_table("topc", HT_STACKABLE, channels_5char); H_splt = add_bind_table("splt", HT_STACKABLE, channels_4char); H_sign = add_bind_table("sign", HT_STACKABLE, channels_5char); H_rejn = add_bind_table("rejn", HT_STACKABLE, channels_4char); H_part = add_bind_table("part", HT_STACKABLE, channels_5char); H_nick = add_bind_table("nick", HT_STACKABLE, channels_5char); H_mode = add_bind_table("mode", HT_STACKABLE, channels_6char); H_kick = add_bind_table("kick", HT_STACKABLE, channels_6char); H_join = add_bind_table("join", HT_STACKABLE, channels_4char); H_pubm = add_bind_table("pubm", HT_STACKABLE, channels_5char); H_pub = add_bind_table("pub", 0, channels_5char); H_need = add_bind_table("need", HT_STACKABLE, channels_2char); do_nettype(); return NULL; }