⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hooks.c

📁 Intercom 是一个 Unix系统上灵活的语音传输软件。支持标准音频压缩比如GSM, G.711, and G.72x和其他音频编码。Intercom专为高速网络设计来传输高品质的语音
💻 C
字号:
/*  hooks.c -- User-defined event hook support for Intercom    Copyright (C) 2001-2003  Shane Wegner    This file is part of Intercom.    Intercom is free software; you can redistribute it and/or modify it    under the terms of version 2 of the GNU General Public License as    published by the Free Software Foundation.    Intercom is distributed in the hope that it will be useful, but    WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    General Public License for more details.    You should have received a copy of version 2 of the GNU General Public    License along with Intercom; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    To contact the author, please send email to shane@cm.nu.    *//* $Id: hooks.c,v 1.9 2003/02/13 20:22:49 shane Exp $ */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include "hooks.h"#include "console.h"struct hook_info *hook_list = NULL;static int hk_high_id = 0;hk_type_t hk_strtotype(const char *s){if (!strcasecmp(s, "call_incoming"))return hk_call_incoming;else if (!strcasecmp(s, "call_outgoing"))return hk_call_outgoing;else if (!strcasecmp(s, "call_connect"))return hk_call_connect;else if (!strcasecmp(s, "hangup_lc"))return hk_hangup_lc;else if (!strcasecmp(s, "hangup_rmt"))return hk_hangup_rmt;else if (!strcasecmp(s, "sighup"))return hk_sighup;elsereturn hk_invalid;}int hk_add(hk_type_t type, const char *cmd){struct hook_info *l = hook_list;struct hook_info *h = malloc(sizeof(struct hook_info));h->id = hk_high_id++;h->type = type;h->cmd = strdup(cmd);h->next = NULL;if (l != NULL) {while(l->next != NULL)l = l->next;l->next = h;} elsehook_list = h;return h->id;}int hk_clear(int id){struct hook_info *h = hook_list;struct hook_info *prev = NULL;while (h != NULL) {if (h->id == id) {struct hook_info *next = h->next;if (prev != NULL)prev->next = next;else {hook_list = next;if (next == NULL)hk_high_id = 0;}free(h->cmd);free(h);return 1;}prev = h;h = h->next;}return 0;}int hk_cleartype(hk_type_t type){struct hook_info *h, *n;int nr;for (h = hook_list; h != NULL; h = n) {n = h->next;if (h->type == type) {hk_clear(h->id);nr++;}}return 0;}int hk_clearall(void){int nr = 0;while (hook_list != NULL) {hk_clear(hook_list->id);nr++;}return nr;}int hk_trigger(hk_type_t type){struct hook_info *h;for (h = hook_list; h != NULL; h = h->next)if (h->type == type)processline(0, h->cmd);return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -