这似乎是一个相当常见的模式,例如在hexchat中(可能无法编译,另请参阅插件文档.还请注意,这些文档hexchat_plugin_get_info尚未永久使用,因此我为了简单起见省略了它):
static hexchat_plugin *ph;
static int timer_cb(void *userdata) {
if (hexchat_set_context(ph, userdata)) { /* <-- is this line UB? */
/* omitted */
}
return 0;
}
static int do_ub(char *word[], char *word_eol[], void *userdata) {
void *context = hexchat_get_context(ph);
hexchat_hook_timer(ph, 1000, timer_cb, context);
hexchat_command(ph, "close"); /* free the context - in practice this would be done by another plugin or by the user, not like this, but for the purposes of this example this …Run Code Online (Sandbox Code Playgroud) 我相信我可以直接向任何姓名发送消息msg <nick> <message>,但是有没有办法实际查看我与该人的消息对话/历史记录?