| 1 | /**************************************************************************** |
|---|
| 2 | * |
|---|
| 3 | * $Id: linphonec.h,v 1.3 2006/01/20 14:12:34 strk Exp $ |
|---|
| 4 | * |
|---|
| 5 | * Copyright (C) 2005 Sandro Santilli <strk@keybit.net> |
|---|
| 6 | * |
|---|
| 7 | **************************************************************************** |
|---|
| 8 | * |
|---|
| 9 | * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | * it under the terms of the GNU General Public License as published by |
|---|
| 11 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | * (at your option) any later version. |
|---|
| 13 | * |
|---|
| 14 | * This program is distributed in the hope that it will be useful, |
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | * GNU Library General Public License for more details. |
|---|
| 18 | * |
|---|
| 19 | * You should have received a copy of the GNU General Public License |
|---|
| 20 | * along with this program; if not, write to the Free Software |
|---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 22 | * |
|---|
| 23 | ****************************************************************************/ |
|---|
| 24 | |
|---|
| 25 | #ifndef LINPHONEC_H |
|---|
| 26 | #define LINPHONEC_H 1 |
|---|
| 27 | |
|---|
| 28 | #ifdef HAVE_CONFIG_H |
|---|
| 29 | #include "config.h" |
|---|
| 30 | #endif |
|---|
| 31 | |
|---|
| 32 | #ifdef HAVE_READLINE_H |
|---|
| 33 | #include <readline.h> |
|---|
| 34 | #define HAVE_READLINE |
|---|
| 35 | #else |
|---|
| 36 | #ifdef HAVE_READLINE_READLINE_H |
|---|
| 37 | #include <readline/readline.h> |
|---|
| 38 | #define HAVE_READLINE |
|---|
| 39 | #endif |
|---|
| 40 | #endif |
|---|
| 41 | #ifdef HAVE_HISTORY_H |
|---|
| 42 | #include <history.h> |
|---|
| 43 | #else |
|---|
| 44 | #ifdef HAVE_READLINE_HISTORY_H |
|---|
| 45 | #include <readline/history.h> |
|---|
| 46 | #endif |
|---|
| 47 | #endif |
|---|
| 48 | |
|---|
| 49 | /************************************************************************** |
|---|
| 50 | * |
|---|
| 51 | * Compile-time defines |
|---|
| 52 | * |
|---|
| 53 | **************************************************************************/ |
|---|
| 54 | |
|---|
| 55 | #define HISTSIZE 500 /* how many lines of input history */ |
|---|
| 56 | #define PROMPT_MAX_LEN 256 /* max len of prompt string */ |
|---|
| 57 | #define LINE_MAX_LEN 256 /* really needed ? */ |
|---|
| 58 | |
|---|
| 59 | /* |
|---|
| 60 | * Define this to have your primary contact |
|---|
| 61 | * as the prompt string |
|---|
| 62 | */ |
|---|
| 63 | /* #define IDENTITY_AS_PROMPT 1 */ |
|---|
| 64 | |
|---|
| 65 | /* |
|---|
| 66 | * Time between calls to linphonec_idle_call during main |
|---|
| 67 | * input read loop in microseconds. |
|---|
| 68 | */ |
|---|
| 69 | #define LPC_READLINE_TIMEOUT 1000000 |
|---|
| 70 | |
|---|
| 71 | /* |
|---|
| 72 | * Filename of linphonec history |
|---|
| 73 | */ |
|---|
| 74 | #define LPC_HIST_FILE "~/.linphonec_history" |
|---|
| 75 | |
|---|
| 76 | /* |
|---|
| 77 | * Maximum number of pending authentications |
|---|
| 78 | */ |
|---|
| 79 | #define MAX_PENDING_AUTH 8 |
|---|
| 80 | |
|---|
| 81 | /************************************************************************** |
|---|
| 82 | * |
|---|
| 83 | * Types |
|---|
| 84 | * |
|---|
| 85 | **************************************************************************/ |
|---|
| 86 | |
|---|
| 87 | /* |
|---|
| 88 | * A structure which contains information on the commands this program |
|---|
| 89 | * can understand. |
|---|
| 90 | */ |
|---|
| 91 | typedef int (*lpc_cmd_handler)(LinphoneCore *, char *); |
|---|
| 92 | typedef struct { |
|---|
| 93 | char *name; /* User printable name of the function. */ |
|---|
| 94 | lpc_cmd_handler func; /* Function to call to do the job. */ |
|---|
| 95 | char *help; /* Short help for this function. */ |
|---|
| 96 | char *doc; /* Long description. */ |
|---|
| 97 | } LPC_COMMAND; |
|---|
| 98 | |
|---|
| 99 | /*************************************************************************** |
|---|
| 100 | * |
|---|
| 101 | * Forward declarations |
|---|
| 102 | * |
|---|
| 103 | ***************************************************************************/ |
|---|
| 104 | |
|---|
| 105 | extern int linphonec_parse_command_line(LinphoneCore *lc, char *cl); |
|---|
| 106 | extern char *linphonec_command_generator(const char *text, int state); |
|---|
| 107 | extern void linphonec_finish(int exit_status); |
|---|
| 108 | extern char *linphonec_readline(char *prompt); |
|---|
| 109 | void linphonec_set_autoanswer(bool_t enabled); |
|---|
| 110 | bool_t linphonec_get_autoanswer(); |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | #endif /* def LINPHONEC_H */ |
|---|
| 114 | |
|---|
| 115 | /**************************************************************************** |
|---|
| 116 | * |
|---|
| 117 | * $Log: linphonec.h,v $ |
|---|
| 118 | * Revision 1.3 2006/01/20 14:12:34 strk |
|---|
| 119 | * Added linphonec_init() and linphonec_finish() functions. |
|---|
| 120 | * Handled SIGINT and SIGTERM to invoke linphonec_finish(). |
|---|
| 121 | * Handling of auto-termination (-t) moved to linphonec_finish(). |
|---|
| 122 | * Reworked main (input read) loop to not rely on 'terminate' |
|---|
| 123 | * and 'run' variable (dropped). configfile_name allocated on stack |
|---|
| 124 | * using PATH_MAX limit. Changed print_usage signature to allow |
|---|
| 125 | * for an exit_status specification. |
|---|
| 126 | * |
|---|
| 127 | * Revision 1.2 2006/01/14 13:29:32 strk |
|---|
| 128 | * Reworked commands interface to use a table structure, |
|---|
| 129 | * used by command line parser and help function. |
|---|
| 130 | * Implemented first level of completion (commands). |
|---|
| 131 | * Added notification of invalid "answer" and "terminate" |
|---|
| 132 | * commands (no incoming call, no active call). |
|---|
| 133 | * Forbidden "call" intialization when a call is already active. |
|---|
| 134 | * Cleaned up all commands, adding more feedback and error checks. |
|---|
| 135 | * |
|---|
| 136 | * Revision 1.1 2006/01/13 13:00:29 strk |
|---|
| 137 | * Added linphonec.h. Code layout change (added comments, forward decl, |
|---|
| 138 | * globals on top, copyright notices and Logs). Handled out-of-memory |
|---|
| 139 | * condition on history management. Removed assumption on sizeof(char). |
|---|
| 140 | * Fixed bug in authentication prompt (introduced by readline). |
|---|
| 141 | * Added support for multiple authentication requests (up to MAX_PENDING_AUTH). |
|---|
| 142 | * |
|---|
| 143 | * |
|---|
| 144 | ****************************************************************************/ |
|---|