void run_cbot_cli(int argc, char **argv) { char *line, *plugin_dir="bin/release/plugin"; char *hash = NULL; cbot_t *bot; smb_ad args; arg_data_init(&args); process_args(&args, argc, argv); if (check_long_flag(&args, "name")) { name = get_long_flag_parameter(&args, "name"); } if (check_long_flag(&args, "plugin-dir")) { plugin_dir = get_long_flag_parameter(&args, "plugin-dir"); } if (check_long_flag(&args, "hash")) { hash = get_long_flag_parameter(&args, "hash"); } if (check_long_flag(&args, "help")) { help(); } if (!(name && plugin_dir)) { help(); } if (!hash) { help(); } bot = cbot_create("cbot"); bot->actions.send = cbot_cli_send; bot->actions.me = cbot_cli_me; bot->actions.op = cbot_cli_op; bot->actions.join = cbot_cli_join; // Set the hash in the bot. void *decoded = base64_decode(hash, 20); memcpy(bot->hash, decoded, 20); free(decoded); cbot_load_plugins(bot, plugin_dir, ll_get_iter(args.bare_strings)); while (!feof(stdin)) { printf("> "); line = read_line(stdin); cbot_handle_channel_message(bot, "stdin", "shell", line); smb_free(line); } arg_data_destroy(&args); cbot_delete(bot); }
t_infos *ft_newl(t_infos *llist, struct dirent *ret, t_opt *option, char *path) { t_infos *node; struct stat buf; if (!(node = (t_infos*)malloc(sizeof(t_infos)))) print_err(1, '-'); ft_putnull(node); ft_bzero(node->rights, 12); node->path = createpath(ret->d_name, path); if (lstat(node->path, &buf) == -1) perror("Erreur de lstat ="); node->type = typedefine(ret->d_type); if (node->type == 0) node->type = typedefineargs(buf.st_mode); node->name = ft_strdup(ret->d_name); if (check_long_flag(option) == 1) ft_fillstats(node, &buf, option); if (!llist) { llist = node; node->nxt = NULL; } else llist = ft_sort(llist, node, option->flag); return (llist); }