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

📄 userdefs.c

📁 Intercom 是一个 Unix系统上灵活的语音传输软件。支持标准音频压缩比如GSM, G.711, and G.72x和其他音频编码。Intercom专为高速网络设计来传输高品质的语音
💻 C
字号:
/*  userdefs.c -- Configurable variables and accessor functions 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: userdefs.c,v 1.30 2003/02/13 20:22:49 shane Exp $ */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <assert.h>#ifdef USE_GETTEXT#include <libintl.h>#define _(String) gettext(String)#define gettext_noop(String) (String)#define N_(String) gettext_noop(String)#else#define _(String) (String)#define N_(String) (String)#endif#include "userdefs.h"#include "intercom.h"#ifdef USE_CRYPTO#include "crypto.h"#endifstatic int opt_int_unsigned(const char *val){if (atoi(val) < 0) {fputs(_("Error: value must be a positive integer.\n"), stderr);return 0;}return 1;}#ifdef USE_CRYPTOstatic int opt_cryptmethod(const char *s){if (cr_type_fromstr(s) == -1) {fputs(_("Invalid or unknown encryption method.\n"), stderr);return 0;}return 1;}#endifstruct user_option useropts[]= {{"cmd_maxdepth", opt_int, "10", N_("Maximum recursion depth of alias and if"), opt_int_unsigned},{"history_limit", opt_int, "100", N_("Number of entries in the command-history file"), opt_int_unsigned},{"iptos_lowdelay", opt_int, "1", N_("Use the IPTOS_LOWDELAY socket option on the audio socket"), NULL},{"port", opt_int, "4266", N_("Port on which Intercom listens for new incoming connections"), opt_int_unsigned},{"prompt", opt_str, "intercom: ", N_("Intercom command prompt"), NULL},{"reverse_lookup", opt_int, "1", N_("perform reverse DNS lookups on incoming connections"), NULL},{"silence_thresh", opt_int, "4096", N_("Sample value below which is considered to be silence)"), opt_int_unsigned},{"silence_time", opt_float, "1", N_("how many seconds of silence after which audio is squelched"), NULL},{"input_gain", opt_float, "0.000", N_("audio input gain in decibels"), NULL},{"output_gain", opt_float, "0.000", N_("Audio output gain in decibels"), NULL},{"snd_bitwidth", opt_int, "16", N_("Bits per sample"), NULL},#ifdef HAVE_LIBGSM{"snd_compression", opt_str, "GSM", N_("Desired audio compression codec"), NULL},#else#ifdef USE_G72X{"snd_compression", opt_str, "G.723-24", N_("Desired audio compression codec"), NULL},#else{"snd_compression", opt_str, "G.711-ULAW", N_("Desired audio compression codec"), NULL},#endif#endif{"snd_loopback", opt_int, "0", N_("Enable audio loopback mode"), opt_int_unsigned},{"snd_rate", opt_int, "8000", N_("Audio sampling rate"), opt_int_unsigned},{"snd_capture_device", opt_str, "/dev/dsp", N_("Device from which to capture audio data"), NULL},{"snd_play_device", opt_str, "/dev/dsp", N_("Device on which to play audio data"), NULL},{"snd_singleopen", opt_int, "1", N_("Open a device only once for playback and capture"), NULL},{"udp_minsize", opt_int, "64", N_("Minimum size of UDP data packets"), opt_int_unsigned},{"udp_maxsize", opt_int, "512", N_("Maximum size of UDP data packets"), opt_int_unsigned},{"username", opt_str, "(unknown)", N_("User name to send with a call"), NULL},#ifdef USE_CRYPTO{"crypt_method", opt_str, "des", N_("Default encryption method"), opt_cryptmethod},{"crypt_passphrase", opt_str, "", N_("Default encryption passphrase (dangerous)"), NULL},#endif{"verbose", opt_int, "0", N_("Verbose console output"), NULL},{NULL, 0, NULL, NULL}};int opt_find(const char *key){int i;for (i = 0; useropts[i].key != NULL; i++)if (!strcmp(useropts[i].key, key))return i;return -1;}int opt_get_int(const char *key){int i;i = opt_find(key);assert(i != -1 && useropts[i].type == opt_int);return atoi(useropts[i].value);}int opt_set_int(const char *key, int val){int i;char *valstr = malloc(16);i = opt_find(key);assert(i != -1 && useropts[i].type == opt_int);sprintf(valstr, "%d", val);if (useropts[i].validate != NULL && !useropts[i].validate(valstr))return -1;free(useropts[i].value);useropts[i].value = valstr;refresh_userdefs();return 0;}float opt_get_float(const char *key){int i;i = opt_find(key);assert(i != -1 && useropts[i].type == opt_float);return strtod(useropts[i].value, NULL);}int opt_set_float(const char *key, float val){int i;char *valstr = malloc(16);i = opt_find(key);assert(i != -1 && useropts[i].type == opt_float);sprintf(valstr, "%0.3f", val);if (useropts[i].validate != NULL && !useropts[i].validate(valstr))return -1;free(useropts[i].value);useropts[i].value = valstr;refresh_userdefs();return 0;}char *opt_get_str(const char *key){int i;i = opt_find(key);assert(i != -1 && useropts[i].type == opt_str);return useropts[i].value;}int opt_set_str(const char *key, const char *val){int i;i = opt_find(key);assert(i != -1 && useropts[i].type == opt_str);if (useropts[i].validate != NULL && !useropts[i].validate(val))return -1;free(useropts[i].value);useropts[i].value = strdup(val);refresh_userdefs();return 0;}void opt_init(void){char *user;size_t i;/* Initialize value from def_value */for (i = 0; useropts[i].key != NULL; i++)useropts[i].value = strdup(useropts[i].def_value);if ((user = getenv("USER")) != NULL)opt_set_str("username", user);}

⌨️ 快捷键说明

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