summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--CHANGES10
-rw-r--r--Makefile20
-rw-r--r--UPGRADE.txt7
-rw-r--r--addons/res_config_mysql.c66
-rw-r--r--cdr/cdr_csv.c12
-rw-r--r--cdr/cdr_custom.c12
-rw-r--r--cdr/cdr_manager.c12
-rw-r--r--cdr/cdr_odbc.c12
-rw-r--r--cdr/cdr_pgsql.c54
-rw-r--r--cdr/cdr_radius.c10
-rw-r--r--cdr/cdr_tds.c12
-rw-r--r--cel/cel_pgsql.c62
-rw-r--r--channels/sig_pri.c10
-rw-r--r--codecs/lpc10/lpcini.c3
-rw-r--r--configs/basic-pbx/extensions.conf4
-rw-r--r--configs/samples/cel_pgsql.conf.sample2
-rw-r--r--doc/.gitignore4
-rw-r--r--doc/asterisk-ng-doxygen.in (renamed from contrib/asterisk-ng-doxygen)0
-rw-r--r--doc/asterisk.85
-rw-r--r--include/asterisk/astmm.h16
-rw-r--r--include/asterisk/options.h3
-rw-r--r--include/asterisk/vector.h90
-rw-r--r--main/asterisk.c122
-rw-r--r--main/dns_srv.c12
-rw-r--r--pbx/pbx_spool.c35
-rw-r--r--res/res_fax_spandsp.c10
-rw-r--r--res/res_rtp_asterisk.c6
-rw-r--r--sounds/Makefile5
-rw-r--r--sounds/sounds.xml27
-rw-r--r--tests/test_vector.c31
-rw-r--r--utils/ael_main.c62
-rw-r--r--utils/astman.c62
-rw-r--r--utils/check_expr.c40
-rw-r--r--utils/extconf.c282
-rw-r--r--utils/frame.c6
-rw-r--r--utils/frame.h2
-rw-r--r--utils/muted.c28
-rw-r--r--utils/smsq.c8
-rw-r--r--utils/streamplayer.c20
40 files changed, 709 insertions, 478 deletions
diff --git a/.gitignore b/.gitignore
index 4b19213cc..0281e107c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,6 @@ menuselect-tree
*.pyc
*.gcno
*.gcda
+latex
+doxygen.log
+
diff --git a/CHANGES b/CHANGES
index 1753be663..26bcb4990 100644
--- a/CHANGES
+++ b/CHANGES
@@ -104,6 +104,12 @@ Core
for DNS functionality. Modules that use this functionality will require that
a DNS resolver module is loaded and available.
+ * Modified processing of command-line options to first parse only what
+ is necessary to read asterisk.conf. Once asterisk.conf is fully loaded,
+ the remaining options are processed. The -X option now applies to
+ asterisk.conf only. To enable #exec for other config files you must
+ set execincludes=yes in asterisk.conf. Any other option set on the
+ command-line will now override the equivalent setting from asterisk.conf.
Functions
------------------
@@ -153,6 +159,10 @@ cel_pgsql
* Added a new option, 'usegmtime', which causes timestamps in CEL events
to be logged in GMT.
+ * Added support to set schema where located the table cel. This settings is
+ configurable for cel_pgsql via the 'schema' in configuration file
+ cel_pgsql.conf.
+
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 13.3.0 to Asterisk 13.4.0 ------------
------------------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index 3252f7682..7157107b5 100644
--- a/Makefile
+++ b/Makefile
@@ -429,6 +429,8 @@ _clean:
rm -f doc/core-en_US.xml
rm -f doc/full-en_US.xml
rm -f doc/rest-api/*.wiki
+ rm -f doxygen.log
+ rm -rf latex
rm -f rest-api-templates/*.pyc
@$(MAKE) -C menuselect clean
cp -f .cleancount .lastclean
@@ -445,6 +447,7 @@ distclean: $(SUBDIRS_DIST_CLEAN) _clean
rm -f include/asterisk/autoconfig.h
rm -f include/asterisk/buildopts.h
rm -rf doc/api
+ rm -f doc/asterisk-ng-doxygen
rm -f build_tools/menuselect-deps
datafiles: _all doc/core-en_US.xml
@@ -763,7 +766,8 @@ webvmail:
@echo " +-------------------------------------------+"
progdocs:
- # Note, Makefile conditionals must not be tabbed out. Wasted hours with that.
+# Note, Makefile conditionals must not be tabbed out. Wasted hours with that.
+ @cp doc/asterisk-ng-doxygen.in doc/asterisk-ng-doxygen
ifeq ($(DOXYGEN),:)
@echo "Doxygen is not installed. Please install and re-run the configuration script."
else
@@ -771,20 +775,20 @@ ifeq ($(DOT),:)
@echo "DOT is not installed. Doxygen will not produce any diagrams. Please install and re-run the configuration script."
else
# Enable DOT
- @echo "HAVE_DOT = YES" >> contrib/asterisk-ng-doxygen
+ @echo "HAVE_DOT = YES" >> doc/asterisk-ng-doxygen
endif
# Set Doxygen PROJECT_NUMBER variable
ifneq ($(ASTERISKVERSION),UNKNOWN__and_probably_unsupported)
- @echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> contrib/asterisk-ng-doxygen
+ @echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> doc/asterisk-ng-doxygen
else
echo "Asterisk Version is unknown, not configuring Doxygen PROJECT_NUMBER."
endif
- # Validate Doxygen Configuration
- @doxygen -u contrib/asterisk-ng-doxygen
+ # Validate and auto-update local copy
+ @doxygen -u doc/asterisk-ng-doxygen
# Run Doxygen
- @doxygen contrib/asterisk-ng-doxygen
+ @doxygen doc/asterisk-ng-doxygen
# Remove configuration backup file
- @rm -f contrib/asterisk-ng-doxygen.bak
+ @rm -f doc/asterisk-ng-doxygen.bak
endif
install-logrotate:
@@ -937,7 +941,7 @@ nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
-@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
# options for make in menuselect/
-MAKE_MENUSELECT=CC="$(CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" \
+MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" \
CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
$(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
diff --git a/UPGRADE.txt b/UPGRADE.txt
index d9d5cec53..91d9edc92 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -36,6 +36,13 @@ Core:
The setting can be overridden in asterisk.conf by setting refdebug in
the options category. No recompile is required to enable/disable it.
+ - Modified processing of command-line options to first parse only what
+ is necessary to read asterisk.conf. Once asterisk.conf is fully loaded,
+ the remaining options are processed. The -X option now applies to
+ asterisk.conf only. To enable #exec for other config files you must
+ set execincludes=yes in asterisk.conf. Any other option set on the
+ command-line will now override the equivalent setting from asterisk.conf.
+
AMI:
- The 'ModuleCheck' Action's Version key will no longer show the module
version. The value will always be blank.
diff --git a/addons/res_config_mysql.c b/addons/res_config_mysql.c
index 299fe5619..76bdeed5c 100644
--- a/addons/res_config_mysql.c
+++ b/addons/res_config_mysql.c
@@ -1202,38 +1202,44 @@ static int require_mysql(const char *database, const char *tablename, va_list ap
PICK_WHICH_ALTER_ACTION(bigint)
}
}
- } else if (strncmp(column->type, "float", 5) == 0 && !ast_rq_is_int(type) && type != RQ_FLOAT) {
- if (table->database->requirements == RQ_WARN) {
- ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type);
- res = -1;
- } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) {
- table_altered = 1;
- } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) {
- table_altered = 1;
- } else {
- res = -1;
+ } else if (strncmp(column->type, "float", 5) == 0) {
+ if (!ast_rq_is_int(type) && type != RQ_FLOAT) {
+ if (table->database->requirements == RQ_WARN) {
+ ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type);
+ res = -1;
+ } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) {
+ table_altered = 1;
+ } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) {
+ table_altered = 1;
+ } else {
+ res = -1;
+ }
}
- } else if ((strncmp(column->type, "datetime", 8) == 0 || strncmp(column->type, "timestamp", 9) == 0) && type != RQ_DATETIME) {
- if (table->database->requirements == RQ_WARN) {
- ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type);
- res = -1;
- } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) {
- table_altered = 1;
- } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) {
- table_altered = 1;
- } else {
- res = -1;
+ } else if (strncmp(column->type, "datetime", 8) == 0 || strncmp(column->type, "timestamp", 9) == 0) {
+ if (type != RQ_DATETIME) {
+ if (table->database->requirements == RQ_WARN) {
+ ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type);
+ res = -1;
+ } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) {
+ table_altered = 1;
+ } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) {
+ table_altered = 1;
+ } else {
+ res = -1;
+ }
}
- } else if ((strncmp(column->type, "date", 4) == 0) && type != RQ_DATE) {
- if (table->database->requirements == RQ_WARN) {
- ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type);
- res = -1;
- } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) {
- table_altered = 1;
- } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) {
- table_altered = 1;
- } else {
- res = -1;
+ } else if (strncmp(column->type, "date", 4) == 0) {
+ if (type != RQ_DATE) {
+ if (table->database->requirements == RQ_WARN) {
+ ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type);
+ res = -1;
+ } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) {
+ table_altered = 1;
+ } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) {
+ table_altered = 1;
+ } else {
+ res = -1;
+ }
}
} else { /* Other, possibly unsupported types? */
if (table->database->requirements == RQ_WARN) {
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index 6fb2b7160..7a904a19d 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -352,9 +352,9 @@ static int reload(void)
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Comma Separated Values CDR Backend",
- .support_level = AST_MODULE_SUPPORT_EXTENDED,
- .load = load_module,
- .unload = unload_module,
- .reload = reload,
- .load_pri = AST_MODPRI_CDR_DRIVER,
- );
+ .support_level = AST_MODULE_SUPPORT_EXTENDED,
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ .load_pri = AST_MODPRI_CDR_DRIVER,
+);
diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c
index 2c4d8b712..24cb834f6 100644
--- a/cdr/cdr_custom.c
+++ b/cdr/cdr_custom.c
@@ -226,10 +226,10 @@ static int reload(void)
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Customizable Comma Separated Values CDR Backend",
- .support_level = AST_MODULE_SUPPORT_CORE,
- .load = load_module,
- .unload = unload_module,
- .reload = reload,
- .load_pri = AST_MODPRI_CDR_DRIVER,
- );
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ .load_pri = AST_MODPRI_CDR_DRIVER,
+);
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c
index 4a079aecd..ef9d63e47 100644
--- a/cdr/cdr_manager.c
+++ b/cdr/cdr_manager.c
@@ -368,9 +368,9 @@ static int reload(void)
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk Manager Interface CDR Backend",
- .support_level = AST_MODULE_SUPPORT_CORE,
- .load = load_module,
- .unload = unload_module,
- .reload = reload,
- .load_pri = AST_MODPRI_CDR_DRIVER,
- );
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ .load_pri = AST_MODPRI_CDR_DRIVER,
+);
diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c
index 4d601ef9a..5fddb7b23 100644
--- a/cdr/cdr_odbc.c
+++ b/cdr/cdr_odbc.c
@@ -324,9 +324,9 @@ static int reload(void)
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ODBC CDR Backend",
- .support_level = AST_MODULE_SUPPORT_EXTENDED,
- .load = load_module,
- .unload = unload_module,
- .reload = reload,
- .load_pri = AST_MODPRI_CDR_DRIVER,
- );
+ .support_level = AST_MODULE_SUPPORT_EXTENDED,
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ .load_pri = AST_MODPRI_CDR_DRIVER,
+);
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 194120564..37bc08406 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -680,42 +680,20 @@ static int config_module(int reload)
version = PQserverVersion(conn);
if (version >= 70300) {
- char *schemaname, *tablename;
+ char *schemaname, *tablename, *tmp_schemaname, *tmp_tablename;
if (strchr(table, '.')) {
- schemaname = ast_strdupa(table);
- tablename = strchr(schemaname, '.');
- *tablename++ = '\0';
+ tmp_schemaname = ast_strdupa(table);
+ tmp_tablename = strchr(tmp_schemaname, '.');
+ *tmp_tablename++ = '\0';
} else {
- schemaname = "";
- tablename = table;
+ tmp_schemaname = "";
+ tmp_tablename = table;
}
+ tablename = ast_alloca(strlen(tmp_tablename) * 2 + 1);
+ PQescapeStringConn(conn, tablename, tmp_tablename, strlen(tmp_tablename), NULL);
- /* Escape special characters in schemaname */
- if (strchr(schemaname, '\\') || strchr(schemaname, '\'')) {
- char *tmp = schemaname, *ptr;
-
- ptr = schemaname = ast_alloca(strlen(tmp) * 2 + 1);
- for (; *tmp; tmp++) {
- if (strchr("\\'", *tmp)) {
- *ptr++ = *tmp;
- }
- *ptr++ = *tmp;
- }
- *ptr = '\0';
- }
- /* Escape special characters in tablename */
- if (strchr(tablename, '\\') || strchr(tablename, '\'')) {
- char *tmp = tablename, *ptr;
-
- ptr = tablename = ast_alloca(strlen(tmp) * 2 + 1);
- for (; *tmp; tmp++) {
- if (strchr("\\'", *tmp)) {
- *ptr++ = *tmp;
- }
- *ptr++ = *tmp;
- }
- *ptr = '\0';
- }
+ schemaname = ast_alloca(strlen(tmp_schemaname) * 2 + 1);
+ PQescapeStringConn(conn, schemaname, tmp_schemaname, strlen(tmp_schemaname), NULL);
snprintf(sqlcmd, sizeof(sqlcmd), "SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod FROM (((pg_catalog.pg_class c INNER JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace AND c.relname = '%s' AND n.nspname = %s%s%s) INNER JOIN pg_catalog.pg_attribute a ON (NOT a.attisdropped) AND a.attnum > 0 AND a.attrelid = c.oid) INNER JOIN pg_catalog.pg_type t ON t.oid = a.atttypid) LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid AND d.adnum = a.attnum ORDER BY n.nspname, c.relname, attnum",
tablename,
@@ -811,9 +789,9 @@ static int reload(void)
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PostgreSQL CDR Backend",
- .support_level = AST_MODULE_SUPPORT_EXTENDED,
- .load = load_module,
- .unload = unload_module,
- .reload = reload,
- .load_pri = AST_MODPRI_CDR_DRIVER,
- );
+ .support_level = AST_MODULE_SUPPORT_EXTENDED,
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ .load_pri = AST_MODPRI_CDR_DRIVER,
+);
diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c
index d9542653f..e1a639cda 100644
--- a/cdr/cdr_radius.c
+++ b/cdr/cdr_radius.c
@@ -301,8 +301,8 @@ static int load_module(void)
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "RADIUS CDR Backend",
- .support_level = AST_MODULE_SUPPORT_EXTENDED,
- .load = load_module,
- .unload = unload_module,
- .load_pri = AST_MODPRI_CDR_DRIVER,
- );
+ .support_level = AST_MODULE_SUPPORT_EXTENDED,
+ .load = load_module,
+ .unload = unload_module,
+ .load_pri = AST_MODPRI_CDR_DRIVER,
+);
diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c
index c71abd0e7..6dabeff83 100644
--- a/cdr/cdr_tds.c
+++ b/cdr/cdr_tds.c
@@ -632,9 +632,9 @@ static int unload_module(void)
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "FreeTDS CDR Backend",
- .support_level = AST_MODULE_SUPPORT_EXTENDED,
- .load = load_module,
- .unload = unload_module,
- .reload = reload,
- .load_pri = AST_MODPRI_CDR_DRIVER,
- );
+ .support_level = AST_MODULE_SUPPORT_EXTENDED,
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ .load_pri = AST_MODPRI_CDR_DRIVER,
+);
diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c
index c5c4fa92b..20c0e4401 100644
--- a/cel/cel_pgsql.c
+++ b/cel/cel_pgsql.c
@@ -60,6 +60,8 @@ ASTERISK_REGISTER_FILE()
#define PGSQL_BACKEND_NAME "CEL PGSQL backend"
+#define PGSQL_MIN_VERSION_SCHEMA 70300
+
static char *config = "cel_pgsql.conf";
static char *pghostname;
@@ -69,6 +71,7 @@ static char *pgpassword;
static char *pgappname;
static char *pgdbport;
static char *table;
+static char *schema;
static int connected = 0;
/* Optimization to reduce number of memory allocations */
@@ -427,6 +430,10 @@ static int my_unload_module(void)
ast_free(table);
table = NULL;
}
+ if (schema) {
+ ast_free(schema);
+ schema = NULL;
+ }
while ((current = AST_RWLIST_REMOVE_HEAD(&psql_columns, list))) {
ast_free(current);
}
@@ -530,6 +537,16 @@ static int process_my_load_module(struct ast_config *cfg)
} else {
usegmtime = 0;
}
+ if (!(tmp = ast_variable_retrieve(cfg, "global", "schema"))) {
+ tmp = "";
+ }
+ if (schema) {
+ ast_free(schema);
+ }
+ if (!(schema = ast_strdup(tmp))) {
+ ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying schema info\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
if (option_debug) {
if (ast_strlen_zero(pghostname)) {
ast_debug(3, "cel_pgsql: using default unix socket\n");
@@ -547,23 +564,50 @@ static int process_my_load_module(struct ast_config *cfg)
pgsql_reconnect();
if (PQstatus(conn) != CONNECTION_BAD) {
- char sqlcmd[512];
- char *fname, *ftype, *flen, *fnotnull, *fdef;
- char *tableptr;
- int i, rows;
+ char sqlcmd[768];
+ char *fname, *ftype, *flen, *fnotnull, *fdef, *tablename, *tmp_tablename;
+ int i, rows, version;
ast_debug(1, "Successfully connected to PostgreSQL database.\n");
connected = 1;
+ version = PQserverVersion(conn);
/* Remove any schema name from the table */
- if ((tableptr = strrchr(table, '.'))) {
- tableptr++;
+ if ((tmp_tablename = strrchr(table, '.'))) {
+ tmp_tablename++;
} else {
- tableptr = table;
+ tmp_tablename = table;
+ }
+ tablename = ast_alloca(strlen(tmp_tablename) * 2 + 1);
+ PQescapeStringConn(conn, tablename, tmp_tablename, strlen(tmp_tablename), NULL);
+ if (version >= PGSQL_MIN_VERSION_SCHEMA) {
+ char *schemaname;
+ int lenschema;
+ lenschema = strlen(schema);
+ schemaname = ast_alloca(lenschema * 2 + 1);
+ PQescapeStringConn(conn, schemaname, schema, lenschema, NULL);
+
+ snprintf(sqlcmd, sizeof(sqlcmd),
+ "SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod "
+ "FROM (((pg_catalog.pg_class c INNER JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "
+ "AND c.relname = '%s' AND n.nspname = %s%s%s) "
+ "INNER JOIN pg_catalog.pg_attribute a ON ("
+ "NOT a.attisdropped) AND a.attnum > 0 AND a.attrelid = c.oid) "
+ "INNER JOIN pg_catalog.pg_type t ON t.oid = a.atttypid) "
+ "LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid "
+ "AND d.adnum = a.attnum "
+ "ORDER BY n.nspname, c.relname, attnum",
+ tablename,
+ lenschema == 0 ? "" : "'", lenschema == 0 ? "current_schema()" : schemaname, lenschema == 0 ? "" : "'");
+ } else {
+ snprintf(sqlcmd, sizeof(sqlcmd),
+ "SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod "
+ "FROM pg_class c, pg_type t, pg_attribute a "
+ "LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid "
+ "AND d.adnum = a.attnum WHERE c.oid = a.attrelid AND a.atttypid = t.oid "
+ "AND (a.attnum > 0) AND c.relname = '%s' ORDER BY c.relname, attnum", tablename);
}
-
/* Query the columns */
- snprintf(sqlcmd, sizeof(sqlcmd), "select a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc from pg_class c, pg_type t, pg_attribute a left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum where c.oid = a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname = '%s' order by c.relname, attnum", tableptr);
result = PQexec(conn, sqlcmd);
if (PQresultStatus(result) != PGRES_TUPLES_OK) {
pgerror = PQresultErrorMessage(result);
diff --git a/channels/sig_pri.c b/channels/sig_pri.c
index c58a3f358..71e7e23de 100644
--- a/channels/sig_pri.c
+++ b/channels/sig_pri.c
@@ -7090,10 +7090,11 @@ static void *pri_dchannel(void *vpri)
break;
}
if (pri->pvts[chanpos]->owner) {
- int do_hangup = 0;
-
snprintf(cause_str, sizeof(cause_str), "PRI PRI_EVENT_HANGUP (%d)", e->hangup.cause);
pri_queue_pvt_cause_data(pri, chanpos, cause_str, e->hangup.cause);
+ }
+ if (pri->pvts[chanpos]->owner) {
+ int do_hangup = 0;
/* Queue a BUSY instead of a hangup if our cause is appropriate */
ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->hangup.cause);
@@ -7234,10 +7235,11 @@ static void *pri_dchannel(void *vpri)
break;
}
if (pri->pvts[chanpos]->owner) {
- int do_hangup = 0;
-
snprintf(cause_str, sizeof(cause_str), "PRI PRI_EVENT_HANGUP_REQ (%d)", e->hangup.cause);
pri_queue_pvt_cause_data(pri, chanpos, cause_str, e->hangup.cause);
+ }
+ if (pri->pvts[chanpos]->owner) {
+ int do_hangup = 0;
ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->hangup.cause);
switch (ast_channel_state(pri->pvts[chanpos]->owner)) {
diff --git a/codecs/lpc10/lpcini.c b/codecs/lpc10/lpcini.c
index ebe229a5c..8efb64068 100644
--- a/codecs/lpc10/lpcini.c
+++ b/codecs/lpc10/lpcini.c
@@ -34,7 +34,8 @@ Some OSS fixes and a few lpc changes to make it actually work
-lf2c -lm (in that order)
*/
-#include <stdlib.h>
+#define WRAP_LIBC_MALLOC
+#include "asterisk.h"
#include "f2c.h"
#ifdef P_R_O_T_O_T_Y_P_E_S
diff --git a/configs/basic-pbx/extensions.conf b/configs/basic-pbx/extensions.conf
index d7fd2c3ca..e1da26185 100644
--- a/configs/basic-pbx/extensions.conf
+++ b/configs/basic-pbx/extensions.conf
@@ -145,9 +145,9 @@ exten = _25655511XX,1,Verbose(1, "External caller dialed inbound to DID ${EXTEN}
[Main-IVR]
exten = 2565551100,1,Verbose(1, "New caller, ${CALLERID(num)} dialed into the IVR.")
same = n,Answer()
- same = n(start),Background(demo-congrats)
+ same = n(start),Background(basic-pbx-ivr-main)
same = n,WaitExten(10)
- same = n,Background(demo-congrats)
+ same = n,Background(basic-pbx-ivr-main)
same = n,Hangup()
exten = 0,1,Verbose(1, "Caller ${CALLERID(num)} dialed the operator.")
diff --git a/configs/samples/cel_pgsql.conf.sample b/configs/samples/cel_pgsql.conf.sample
index 30c789e4c..13fe06926 100644
--- a/configs/samples/cel_pgsql.conf.sample
+++ b/configs/samples/cel_pgsql.conf.sample
@@ -68,4 +68,6 @@
;password=password
;user=postgres
;table=cel ;SQL table where CEL's will be inserted
+;schema=public ;Schema where CEL's table is located. Optional parameter.
+ ;If schema support is present the default value used will be current_schema().
;appname=asterisk ; Postgres application_name support (optional). Whitespace not allowed.
diff --git a/doc/.gitignore b/doc/.gitignore
index e098ec027..3461c58c5 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -1,2 +1,4 @@
core-en_US.xml
-rest-api \ No newline at end of file
+rest-api
+api
+asterisk-ng-doxygen
diff --git a/contrib/asterisk-ng-doxygen b/doc/asterisk-ng-doxygen.in
index 51a3f5d58..51a3f5d58 100644
--- a/contrib/asterisk-ng-doxygen
+++ b/doc/asterisk-ng-doxygen.in
diff --git a/doc/asterisk.8 b/doc/asterisk.8
index d566480f2..3f49a3401 100644
--- a/doc/asterisk.8
+++ b/doc/asterisk.8
@@ -232,9 +232,8 @@ then terminating when the command execution completes. Implies
supplied.
.TP
\-X
-Enables executing of includes via \fB#exec\fR directive.
-This can be useful if You want to do \fB#exec\fR inside
-\*(T<\fIasterisk.conf\fR\*(T>
+Enables executing of includes via \fB#exec\fR directive inside
+\*(T<\fIasterisk.conf\fR\*(T>.
.SH EXAMPLES
\fBasterisk\fR - Begin Asterisk as a daemon
.PP
diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h
index 6086509ab..1d778d4c5 100644
--- a/include/asterisk/astmm.h
+++ b/include/asterisk/astmm.h
@@ -95,21 +95,21 @@ void __ast_mm_init_phase_2(void);
__ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
#define calloc(a,b) \
- Do_not_use_calloc__use_ast_calloc(a,b)
+ Do_not_use_calloc__use_ast_calloc->fail(a,b)
#define malloc(a) \
- Do_not_use_malloc__use_ast_malloc(a)
+ Do_not_use_malloc__use_ast_malloc->fail(a)
#define free(a) \
- Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory(a)
+ Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a)
#define realloc(a,b) \
- Do_not_use_realloc__use_ast_realloc(a,b)
+ Do_not_use_realloc__use_ast_realloc->fail(a,b)
#define strdup(a) \
- Do_not_use_strdup__use_ast_strdup(a)
+ Do_not_use_strdup__use_ast_strdup->fail(a)
#define strndup(a,b) \
- Do_not_use_strndup__use_ast_strndup(a,b)
+ Do_not_use_strndup__use_ast_strndup->fail(a,b)
#define asprintf(a, b, c...) \
- Do_not_use_asprintf__use_ast_asprintf(a,b,c)
+ Do_not_use_asprintf__use_ast_asprintf->fail(a,b,c)
#define vasprintf(a,b,c) \
- Do_not_use_vasprintf__use_ast_vasprintf(a,b,c)
+ Do_not_use_vasprintf__use_ast_vasprintf->fail(a,b,c)
#endif
/* Provide our own definitions */
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index a08b8638c..e2709f918 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -66,8 +66,6 @@ enum ast_option_flags {
AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13),
/*! Display timestamp in CLI verbose output */
AST_OPT_FLAG_TIMESTAMP = (1 << 14),
- /*! Override config */
- AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15),
/*! Reconnect */
AST_OPT_FLAG_RECONNECT = (1 << 16),
/*! Transmit Silence during Record() and DTMF Generation */
@@ -119,7 +117,6 @@ enum ast_option_flags {
#define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)
#define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
#define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)
-#define ast_opt_override_config ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)
#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h
index 255c30b43..0a13c560b 100644
--- a/include/asterisk/vector.h
+++ b/include/asterisk/vector.h
@@ -273,6 +273,36 @@
})
/*!
+ * \brief Add an element into a sorted vector
+ *
+ * \param vec Sorted vector to add to.
+ * \param elem Element to insert.
+ * \param cmp A strcmp compatible compare function.
+ *
+ * \return 0 on success.
+ * \return Non-zero on failure.
+ *
+ * \warning Use of this macro on an unsorted vector will produce unpredictable results
+ */
+#define AST_VECTOR_ADD_SORTED(vec, elem, cmp) ({ \
+ int res = 0; \
+ size_t __idx = (vec)->current; \
+ do { \
+ if (__make_room((vec)->current, vec) != 0) { \
+ res = -1; \
+ break; \
+ } \
+ while (__idx > 0 && (cmp((vec)->elems[__idx - 1], elem) > 0)) { \
+ (vec)->elems[__idx] = (vec)->elems[__idx - 1]; \
+ __idx--; \
+ } \
+ (vec)->elems[__idx] = elem; \
+ (vec)->current++; \
+ } while (0); \
+ res; \
+})
+
+/*!
* \brief Remove an element from a vector by index.
*
* Note that elements in the vector may be reordered, so that the remove can
@@ -280,35 +310,48 @@
*
* \param vec Vector to remove from.
* \param idx Index of the element to remove.
+ * \param preserve_order Preserve the vector order.
+ *
* \return The element that was removed.
*/
-#define AST_VECTOR_REMOVE_UNORDERED(vec, idx) ({ \
- typeof((vec)->elems[0]) res; \
- size_t __idx = (idx); \
- ast_assert(__idx < (vec)->current); \
- res = (vec)->elems[__idx]; \
- (vec)->elems[__idx] = (vec)->elems[--(vec)->current]; \
+#define AST_VECTOR_REMOVE(vec, idx, preserve_ordered) ({ \
+ typeof((vec)->elems[0]) res; \
+ size_t __idx = (idx); \
+ ast_assert(__idx < (vec)->current); \
+ res = (vec)->elems[__idx]; \
+ if ((preserve_ordered)) { \
+ size_t __move; \
+ __move = ((vec)->current - (__idx) - 1) * sizeof(typeof((vec)->elems[0])); \
+ memmove(&(vec)->elems[__idx], &(vec)->elems[__idx + 1], __move); \
+ (vec)->current--; \
+ } else { \
+ (vec)->elems[__idx] = (vec)->elems[--(vec)->current]; \
+ }; \
res; \
})
/*!
+ * \brief Remove an element from an unordered vector by index.
+ *
+ * Note that elements in the vector may be reordered, so that the remove can
+ * happen in constant time.
+ *
+ * \param vec Vector to remove from.
+ * \param idx Index of the element to remove.
+ * \return The element that was removed.
+ */
+#define AST_VECTOR_REMOVE_UNORDERED(vec, idx) \
+ AST_VECTOR_REMOVE(vec, idx, 0)
+
+/*!
* \brief Remove an element from a vector by index while maintaining order.
*
* \param vec Vector to remove from.
* \param idx Index of the element to remove.
* \return The element that was removed.
*/
-#define AST_VECTOR_REMOVE_ORDERED(vec, idx) ({ \
- typeof((vec)->elems[0]) res; \
- size_t __idx = (idx); \
- size_t __move; \
- ast_assert(__idx < (vec)->current); \
- res = (vec)->elems[__idx]; \
- __move = ((vec)->current - (__idx) - 1) * sizeof(typeof((vec)->elems[0])); \
- memmove(&(vec)->elems[__idx], &(vec)->elems[__idx + 1], __move); \
- (vec)->current--; \
- res; \
-})
+#define AST_VECTOR_REMOVE_ORDERED(vec, idx) \
+ AST_VECTOR_REMOVE(vec, idx, 1)
/*!
* \brief Remove an element from a vector that matches the given comparison
@@ -421,6 +464,17 @@
#define AST_VECTOR_SIZE(vec) (vec)->current
/*!
+ * \brief Reset vector.
+ *
+ * \param vec Vector to reset.
+ * \param callback A cleanup callback or AST_VECTOR_ELEM_CLEANUP_NOOP.
+ */
+#define AST_VECTOR_RESET(vec, cleanup) ({ \
+ AST_VECTOR_CALLBACK_VOID(vec, cleanup); \
+ (vec)->current = 0; \
+})
+
+/*!
* \brief Get an address of element in a vector.
*
* \param vec Vector to query.
@@ -508,6 +562,8 @@
* \brief Execute a callback on every element in a vector returning the matching
* elements in a new vector
*
+ * This macro basically provides a filtered clone.
+ *
* \param vec Vector to operate on.
* \param callback A callback that takes at least 1 argument (the element)
* plus number of optional arguments
diff --git a/main/asterisk.c b/main/asterisk.c
index 277604bf7..53bceadfd 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2014, Digium, Inc.
+ * Copyright (C) 1999 - 2015, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
*
@@ -53,7 +53,7 @@
*
* \section copyright Copyright and Author
*
- * Copyright (C) 1999 - 2014, Digium, Inc.
+ * Copyright (C) 1999 - 2015, Digium, Inc.
* Asterisk is a <a href="http://www.digium.com/en/company/view-policy.php?id=Trademark-Policy">registered trademark</a>
* of <a rel="nofollow" href="http://www.digium.com">Digium, Inc</a>.
*
@@ -301,7 +301,7 @@ int daemon(int, int); /* defined in libresolv of all places */
/*! \brief Welcome message when starting a CLI interface */
#define WELCOME_MESSAGE \
- ast_verbose("Asterisk %s, Copyright (C) 1999 - 2014, Digium, Inc. and others.\n" \
+ ast_verbose("Asterisk %s, Copyright (C) 1999 - 2015, Digium, Inc. and others.\n" \
"Created by Mark Spencer <markster@digium.com>\n" \
"Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.\n" \
"This is free software, with components licensed under the GNU General Public\n" \
@@ -3344,7 +3344,7 @@ static int show_version(void)
static int show_cli_help(void)
{
- printf("Asterisk %s, Copyright (C) 1999 - 2014, Digium, Inc. and others.\n", ast_get_version());
+ printf("Asterisk %s, Copyright (C) 1999 - 2015, Digium, Inc. and others.\n", ast_get_version());
printf("Usage: asterisk [OPTIONS]\n");
printf("Valid Options:\n");
printf(" -V Display version number and exit\n");
@@ -3352,7 +3352,7 @@ static int show_cli_help(void)
printf(" -G <group> Run as a group other than the caller\n");
printf(" -U <user> Run as a user other than the caller\n");
printf(" -c Provide console CLI\n");
- printf(" -d Enable extra debugging\n");
+ printf(" -d Increase debugging (multiple d's = more debugging)\n");
#if HAVE_WORKING_FORK
printf(" -f Do not fork\n");
printf(" -F Always fork\n");
@@ -3375,7 +3375,7 @@ static int show_cli_help(void)
printf(" of output to the CLI\n");
printf(" -v Increase verbosity (multiple v's = more verbose)\n");
printf(" -x <cmd> Execute command <cmd> (implies -r)\n");
- printf(" -X Execute includes by default (allows #exec in asterisk.conf)\n");
+ printf(" -X Enable use of #exec in asterisk.conf\n");
printf(" -W Adjust terminal colors to compensate for a light background\n");
printf("\n");
return 0;
@@ -3385,7 +3385,6 @@ static void ast_readconfig(void)
{
struct ast_config *cfg;
struct ast_variable *v;
- char *config = DEFAULT_CONFIG_FILE;
char hostname[MAXHOSTNAMELEN] = "";
struct ast_flags config_flags = { CONFIG_FLAG_NOREALTIME };
struct {
@@ -3394,19 +3393,12 @@ static void ast_readconfig(void)
} found = { 0, 0 };
/* Default to false for security */
int live_dangerously = 0;
+ int option_debug_new = 0;
+ int option_verbose_new = 0;
/* Set default value */
option_dtmfminduration = AST_MIN_DTMF_DURATION;
- if (ast_opt_override_config) {
- cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);
- if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
- fprintf(stderr, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);
- }
- } else {
- cfg = ast_config_load2(config, "" /* core, can't reload */, config_flags);
- }
-
/* init with buildtime config */
ast_copy_string(cfg_paths.config_dir, DEFAULT_CONFIG_DIR, sizeof(cfg_paths.config_dir));
ast_copy_string(cfg_paths.spool_dir, DEFAULT_SPOOL_DIR, sizeof(cfg_paths.spool_dir));
@@ -3432,8 +3424,15 @@ static void ast_readconfig(void)
ast_set_default_eid(&ast_eid_default);
+ cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);
+
+ /* If AST_OPT_FLAG_EXEC_INCLUDES was previously enabled with -X turn it off now.
+ * Using #exec from other configs requires that it be enabled from asterisk.conf. */
+ ast_clear_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);
+
/* no asterisk.conf? no problem, use buildtime config! */
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
+ fprintf(stderr, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);
return;
}
@@ -3487,7 +3486,7 @@ static void ast_readconfig(void)
for (v = ast_variable_browse(cfg, "options"); v; v = v->next) {
/* verbose level (-v at startup) */
if (!strcasecmp(v->name, "verbose")) {
- option_verbose = atoi(v->value);
+ option_verbose_new = atoi(v->value);
/* whether or not to force timestamping in CLI verbose output. (-T at startup) */
} else if (!strcasecmp(v->name, "timestamp")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TIMESTAMP);
@@ -3496,9 +3495,9 @@ static void ast_readconfig(void)
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_EXEC_INCLUDES);
/* debug level (-d at startup) */
} else if (!strcasecmp(v->name, "debug")) {
- option_debug = 0;
- if (sscanf(v->value, "%30d", &option_debug) != 1) {
- option_debug = ast_true(v->value);
+ option_debug_new = 0;
+ if (sscanf(v->value, "%30d", &option_debug_new) != 1) {
+ option_debug_new = ast_true(v->value) ? 1 : 0;
}
} else if (!strcasecmp(v->name, "refdebug")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_REF_DEBUG);
@@ -3647,6 +3646,9 @@ static void ast_readconfig(void)
pbx_live_dangerously(live_dangerously);
}
+ option_debug += option_debug_new;
+ option_verbose += option_verbose_new;
+
ast_config_destroy(cfg);
}
@@ -3787,9 +3789,9 @@ int main(int argc, char *argv[])
int isroot = 1, rundir_exists = 0;
char *buf;
const char *runuser = NULL, *rungroup = NULL;
- char *remotesock = NULL;
int moduleresult; /*!< Result from the module load subsystem */
struct rlimit l;
+ static const char *getopt_settings = "BC:cde:FfG:ghIiL:M:mnpqRrs:TtU:VvWXx:";
/* Remember original args for restart */
if (argc > ARRAY_LEN(_argv) - 1) {
@@ -3813,11 +3815,57 @@ int main(int argc, char *argv[])
if (getenv("HOME"))
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
+
+ /* Set config file to default before checking arguments for override. */
+ ast_copy_string(cfg_paths.config_file, DEFAULT_CONFIG_FILE, sizeof(cfg_paths.config_file));
+
+ /* Process command-line options that effect asterisk.conf load. */
+ while ((c = getopt(argc, argv, getopt_settings)) != -1) {
+ switch (c) {
+ case 'X':
+ ast_set_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);
+ break;
+ case 'C':
+ ast_copy_string(cfg_paths.config_file, optarg, sizeof(cfg_paths.config_file));
+ break;
+ case 'd':
+ option_debug++;
+ break;
+ case 'h':
+ show_cli_help();
+ exit(0);
+ case 'R':
+ case 'r':
+ case 'x':
+ /* ast_opt_remote is checked during config load. This is only part of what
+ * these options do, see the second loop for the rest of the actions. */
+ ast_set_flag(&ast_options, AST_OPT_FLAG_REMOTE);
+ break;
+ case 'V':
+ show_version();
+ exit(0);
+ case 'v':
+ option_verbose++;
+ break;
+ case '?':
+ exit(1);
+ }
+ }
+
+ /* Initialize env so it is available if #exec is used in asterisk.conf. */
+ env_init();
+
+ ast_readconfig();
+
+ /* Update env to include any systemname that was set. */
+ env_init();
+
/*! \brief Check for options
*
* \todo Document these options
*/
- while ((c = getopt(argc, argv, "BC:cde:FfG:ghIiL:M:mnpqRrs:TtU:VvWXx:")) != -1) {
+ optind = 0;
+ while ((c = getopt(argc, argv, getopt_settings)) != -1) {
/*!\note Please keep the ordering here to alphabetical, capital letters
* first. This will make it easier in the future to select unused
* option flags for new features. */
@@ -3827,18 +3875,16 @@ int main(int argc, char *argv[])
ast_clear_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
break;
case 'X':
- ast_set_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);
+ /* The command-line -X option enables #exec for asterisk.conf only. */
break;
case 'C':
- ast_copy_string(cfg_paths.config_file, optarg, sizeof(cfg_paths.config_file));
- ast_set_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG);
+ /* already processed. */
break;
case 'c':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
break;
case 'd':
- option_debug++;
- ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
+ /* already processed. */
break;
#if defined(HAVE_SYSINFO)
case 'e':
@@ -3862,8 +3908,8 @@ int main(int argc, char *argv[])
ast_set_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE);
break;
case 'h':
- show_cli_help();
- exit(0);
+ /* already processed. */
+ break;
case 'I':
fprintf(stderr,
"NOTICE: The -I option is no longer needed.\n"
@@ -3901,7 +3947,9 @@ int main(int argc, char *argv[])
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
break;
case 's':
- remotesock = ast_strdupa(optarg);
+ if (ast_opt_remote) {
+ ast_copy_string((char *) cfg_paths.socket_path, optarg, sizeof(cfg_paths.socket_path));
+ }
break;
case 'T':
ast_set_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP);
@@ -3913,11 +3961,8 @@ int main(int argc, char *argv[])
runuser = ast_strdupa(optarg);
break;
case 'V':
- show_version();
- exit(0);
case 'v':
- option_verbose++;
- ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
+ /* already processed. */
break;
case 'W': /* White background */
ast_set_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
@@ -3931,7 +3976,8 @@ int main(int argc, char *argv[])
xarg = ast_strdupa(optarg);
break;
case '?':
- exit(1);
+ /* already processed. */
+ break;
}
}
@@ -3945,12 +3991,6 @@ int main(int argc, char *argv[])
}
}
- ast_readconfig();
- env_init();
-
- if (ast_opt_remote && remotesock != NULL)
- ast_copy_string((char *) cfg_paths.socket_path, remotesock, sizeof(cfg_paths.socket_path));
-
if (!ast_language_is_prefix && !ast_opt_remote) {
fprintf(stderr, "The 'languageprefix' option in asterisk.conf is deprecated; in a future release it will be removed, and your sound files will need to be organized in the 'new style' language layout.\n");
}
diff --git a/main/dns_srv.c b/main/dns_srv.c
index f5d038ae7..e4a3d8bbd 100644
--- a/main/dns_srv.c
+++ b/main/dns_srv.c
@@ -112,13 +112,15 @@ void dns_srv_sort(struct ast_dns_result *result)
struct dns_records newlist = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
while (AST_LIST_FIRST(&result->records)) {
- unsigned short cur_priority = 0;
+ unsigned short cur_priority = ((struct ast_dns_srv_record *)(AST_LIST_FIRST(&result->records)))->priority;
struct dns_records temp_list = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
- /* Find the lowest current priority to work on */
- AST_LIST_TRAVERSE(&result->records, current, list) {
- if (!cur_priority || ((struct ast_dns_srv_record *)current)->priority < cur_priority) {
- cur_priority = ((struct ast_dns_srv_record *)current)->priority;
+ /* Find the lowest current priority to work on, but if the priority is already zero there is no lower priority */
+ if (cur_priority) {
+ AST_LIST_TRAVERSE(&result->records, current, list) {
+ if (((struct ast_dns_srv_record *)current)->priority < cur_priority) {
+ cur_priority = ((struct ast_dns_srv_record *)current)->priority;
+ }
}
}
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index 0dad6060d..c858ed22f 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -102,6 +102,14 @@ struct outgoing {
};
#if defined(HAVE_INOTIFY) || defined(HAVE_KQUEUE)
+struct direntry {
+ AST_LIST_ENTRY(direntry) list;
+ time_t mtime;
+ char name[0];
+};
+
+static AST_LIST_HEAD_STATIC(dirlist, direntry);
+
static void queue_file(const char *filename, time_t when);
#endif
@@ -323,6 +331,10 @@ static int remove_from_queue(struct outgoing *o, const char *status)
char newfn[256];
const char *bname;
+#if defined(HAVE_INOTIFY) || defined(HAVE_KQUEUE)
+ struct direntry *cur;
+#endif
+
if (!ast_test_flag(&o->options, SPOOL_FLAG_ALWAYS_DELETE)) {
struct stat current_file_status;
@@ -333,6 +345,19 @@ static int remove_from_queue(struct outgoing *o, const char *status)
}
}
+#if defined(HAVE_INOTIFY) || defined(HAVE_KQUEUE)
+ AST_LIST_LOCK(&dirlist);
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&dirlist, cur, list) {
+ if (!strcmp(cur->name, o->fn)) {
+ AST_LIST_REMOVE_CURRENT(list);
+ ast_free(cur);
+ break;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ AST_LIST_UNLOCK(&dirlist);
+#endif
+
if (!ast_test_flag(&o->options, SPOOL_FLAG_ARCHIVE)) {
unlink(o->fn);
return 0;
@@ -486,14 +511,6 @@ static int scan_service(const char *fn, time_t now)
return 0;
}
-#if defined(HAVE_INOTIFY) || defined(HAVE_KQUEUE)
-struct direntry {
- AST_LIST_ENTRY(direntry) list;
- time_t mtime;
- char name[0];
-};
-
-static AST_LIST_HEAD_STATIC(dirlist, direntry);
#if defined(HAVE_INOTIFY)
/* Only one thread is accessing this list, so no lock is necessary */
@@ -501,6 +518,8 @@ static AST_LIST_HEAD_NOLOCK_STATIC(createlist, direntry);
static AST_LIST_HEAD_NOLOCK_STATIC(openlist, direntry);
#endif
+#if defined(HAVE_INOTIFY) || defined(HAVE_KQUEUE)
+
static void queue_file(const char *filename, time_t when)
{
struct stat st;
diff --git a/res/res_fax_spandsp.c b/res/res_fax_spandsp.c
index 288f91dac..42492273d 100644
--- a/res/res_fax_spandsp.c
+++ b/res/res_fax_spandsp.c
@@ -48,14 +48,16 @@
<support_level>extended</support_level>
***/
-#include "asterisk.h"
-
-ASTERISK_REGISTER_FILE()
-
+/* Include spandsp headers before asterisk.h so the inline functions can continue using
+ * malloc and free, even with MALLOC_DEBUG enabled. */
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
#include <spandsp.h>
#include <spandsp/version.h>
+#include "asterisk.h"
+
+ASTERISK_REGISTER_FILE()
+
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/strings.h"
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 62601dcad..1d43681e4 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -1270,6 +1270,7 @@ static int ast_rtp_dtls_set_configuration(struct ast_rtp_instance *instance, con
}
if (!ast_rtp_engine_srtp_is_registered()) {
+ ast_log(LOG_ERROR, "SRTP support module is not loaded or available. Try loading res_srtp.so.\n");
return -1;
}
@@ -2015,8 +2016,9 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
#ifdef HAVE_OPENSSL_SRTP
dtls_srtp_check_pending(instance, rtp, rtcp);
- /* If this is an SSL packet pass it to OpenSSL for processing */
- if ((*in >= 20) && (*in <= 64)) {
+ /* If this is an SSL packet pass it to OpenSSL for processing. RFC section for first byte value:
+ * https://tools.ietf.org/html/rfc5764#section-5.1.2 */
+ if ((*in >= 20) && (*in <= 63)) {
struct dtls_details *dtls = !rtcp ? &rtp->dtls : &rtp->rtcp->dtls;
int res = 0;
diff --git a/sounds/Makefile b/sounds/Makefile
index 13a7184ac..a726ece15 100644
--- a/sounds/Makefile
+++ b/sounds/Makefile
@@ -19,7 +19,7 @@ CMD_PREFIX?=@
SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
SOUNDS_CACHE_DIR?=
MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
-CORE_SOUNDS_VERSION:=1.4.26
+CORE_SOUNDS_VERSION:=1.4.27
EXTRA_SOUNDS_VERSION:=1.4.15
MOH_VERSION:=2.03
SOUNDS_URL:=http://downloads.asterisk.org/pub/telephony/sounds/releases
@@ -31,6 +31,7 @@ MCS:=$(subst -ES-,-es-,$(MCS))
MCS:=$(subst -RU-,-ru-,$(MCS))
MCS:=$(subst -IT-,-it-,$(MCS))
MCS:=$(subst -JA-,-ja-,$(MCS))
+MCS:=$(subst -SV-,-sv-,$(MCS))
MCS:=$(subst -WAV,-wav,$(MCS))
MCS:=$(subst -ULAW,-ulaw,$(MCS))
MCS:=$(subst -ALAW,-alaw,$(MCS))
@@ -153,6 +154,8 @@ $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ru,$(CORE_SOUNDS_
$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ja,$(CORE_SOUNDS_VERSION)))
+$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,sv,$(CORE_SOUNDS_VERSION)))
+
$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en,$(EXTRA_SOUNDS_VERSION)))
$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en_GB,$(EXTRA_SOUNDS_VERSION)))
diff --git a/sounds/sounds.xml b/sounds/sounds.xml
index 5934bb34e..547be4b4a 100644
--- a/sounds/sounds.xml
+++ b/sounds/sounds.xml
@@ -216,6 +216,33 @@
<member name="CORE-SOUNDS-JA-SIREN14" displayname="Japanese, G.722.1C (Siren14) format">
<support_level>core</support_level>
</member>
+ <member name="CORE-SOUNDS-SV-WAV" displayname="Swedish, WAV format">
+ <support_level>core</support_level>
+ </member>
+ <member name="CORE-SOUNDS-SV-ULAW" displayname="Swedish, mu-Law format">
+ <support_level>core</support_level>
+ </member>
+ <member name="CORE-SOUNDS-SV-ALAW" displayname="Swedish, a-Law format">
+ <support_level>core</support_level>
+ </member>
+ <member name="CORE-SOUNDS-SV-GSM" displayname="Swedish, GSM format">
+ <support_level>core</support_level>
+ </member>
+ <member name="CORE-SOUNDS-SV-G729" displayname="Swedish, G.729 format">
+ <support_level>core</support_level>
+ </member>
+ <member name="CORE-SOUNDS-SV-G722" displayname="Swedish, G.722 format">
+ <support_level>core</support_level>
+ </member>
+ <member name="CORE-SOUNDS-SV-SLN16" displayname="Swedish, Signed-linear 16kHz format">
+ <support_level>core</support_level>
+ </member>
+ <member name="CORE-SOUNDS-SV-SIREN7" displayname="Swedish, G.722.1 (Siren7) format">
+ <support_level>core</support_level>
+ </member>
+ <member name="CORE-SOUNDS-SV-SIREN14" displayname="Swedish, G.722.1C (Siren14) format">
+ <support_level>core</support_level>
+ </member>
</category>
<category name="MENUSELECT_MOH" displayname="Music On Hold File Packages" positive_output="yes">
<member name="MOH-OPSOUND-WAV" displayname="opsound.org Music On Hold Files, WAV format" >
diff --git a/tests/test_vector.c b/tests/test_vector.c
index bd45b0c2b..ff305b5d7 100644
--- a/tests/test_vector.c
+++ b/tests/test_vector.c
@@ -63,7 +63,9 @@ AST_TEST_DEFINE(basic_ops)
char *CCC = "CCC";
char *YYY = "YYY";
char *ZZZ = "ZZZ";
+ char CCC2[4];
+ strcpy(CCC2, "CCC");
switch (cmd) {
case TEST_INIT:
info->name = "basic";
@@ -202,6 +204,29 @@ AST_TEST_DEFINE(basic_ops)
ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 0) == CCC, rc, cleanup);
ast_test_validate_cleanup(test, cleanup_count == 1, rc, cleanup);
+ /* Test INSERT_SORTED */
+ AST_VECTOR_FREE(&sv1);
+ ast_test_validate(test, AST_VECTOR_INIT(&sv1, 0) == 0);
+
+ ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, BBB, strcmp) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, ZZZ, strcmp) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, CCC, strcmp) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, AAA, strcmp) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, CCC2, strcmp) == 0, rc, cleanup);
+
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 0) == AAA, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 1) == BBB, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 2) == CCC, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 3) == CCC2, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 4) == ZZZ, rc, cleanup);
+
+ cleanup_count = 0;
+ AST_VECTOR_RESET(&sv1, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_SIZE(&sv1) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, sv1.max >= 5, rc, cleanup);
+ ast_test_validate_cleanup(test, sv1.elems != NULL, rc, cleanup);
+ ast_test_validate_cleanup(test, cleanup_count == 5, rc, cleanup);
+
cleanup:
AST_VECTOR_FREE(&sv1);
return rc;
@@ -218,13 +243,13 @@ AST_TEST_DEFINE(basic_ops_integer)
int rc = AST_TEST_PASS;
int AAA = 1;
- int BBB = 2;
- int CCC = 3;
+ int BBB = 3;
+ int CCC = 5;
int ZZZ = 26;
switch (cmd) {
case TEST_INIT:
- info->name = "basic integer";
+ info->name = "basic_integer";
info->category = "/main/vector/";
info->summary = "Test integer vector basic ops";
info->description = "Test integer vector basic ops";
diff --git a/utils/ael_main.c b/utils/ael_main.c
index 06ba8e66e..d2c815b3b 100644
--- a/utils/ael_main.c
+++ b/utils/ael_main.c
@@ -48,7 +48,7 @@ struct namelist
struct namelist *next;
};
-struct ast_context
+struct ast_context
{
int extension_count;
char name[100];
@@ -136,7 +136,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
{
va_list vars;
va_start(vars,fmt);
-
+
printf("LOG: lev:%d file:%s line:%d func: %s ",
level, file, line, function);
vprintf(fmt, vars);
@@ -147,21 +147,21 @@ void ast_log(int level, const char *file, int line, const char *function, const
struct ast_exten *pbx_find_extension(struct ast_channel *chan,
struct ast_context *bypass,
struct pbx_find_info *q,
- const char *context,
- const char *exten,
+ const char *context,
+ const char *exten,
int priority,
- const char *label,
- const char *callerid,
+ const char *label,
+ const char *callerid,
enum ext_match_t action);
struct ast_exten *pbx_find_extension(struct ast_channel *chan,
struct ast_context *bypass,
struct pbx_find_info *q,
- const char *context,
- const char *exten,
+ const char *context,
+ const char *exten,
int priority,
- const char *label,
- const char *callerid,
+ const char *label,
+ const char *callerid,
enum ext_match_t action)
{
return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
@@ -218,7 +218,7 @@ void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char
void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count)
{
if (cp1 && *cp1)
- strncpy(cp2,cp1,AST_MAX_EXTENSION); /* Right now, this routine is ONLY being called for
+ strncpy(cp2,cp1,AST_MAX_EXTENSION); /* Right now, this routine is ONLY being called for
a possible var substitution on extension names,
so....! */
else
@@ -255,15 +255,15 @@ int ast_add_extension2(struct ast_context *con,
if( FIRST_TIME ) {
FIRST_TIME = 0;
-
+
if( globalvars )
fprintf(dumpfile,"[globals]\n");
-
+
for(n=globalvars;n;n=n->next) {
fprintf(dumpfile, "%s\n", n->name);
}
}
-
+
/* print out each extension , possibly the context header also */
if( con != last_context ) {
fprintf(dumpfile,"\n\n[%s]\n", con->name);
@@ -280,7 +280,7 @@ int ast_add_extension2(struct ast_context *con,
for(n=con->eswitches;n;n=n->next) {
fprintf(dumpfile, "eswitch => %s/%s\n", n->name, n->name2);
}
-
+
}
if( data ) {
filter_newlines((char*)data);
@@ -303,7 +303,7 @@ int ast_add_extension2(struct ast_context *con,
fprintf(dumpfile,"exten => %s,%d,%s\n", extension, priority, application);
}
}
-
+
/* since add_extension2 is responsible for the malloc'd data stuff */
free(data);
return 0;
@@ -320,7 +320,7 @@ void pbx_builtin_setvar(void *chan, void *data)
ADD_LAST(globalvars,x);
}
}
-
+
struct ast_context * ast_context_create(void **extcontexts, const char *name, const char *registrar)
{
@@ -458,7 +458,7 @@ void filter_leading_space_from_exprs(char *str)
{
/* Mainly for aesthetics */
char *t, *v, *u = str;
-
+
while ( u && *u ) {
if( *u == '$' && *(u+1) == '[' ) {
@@ -471,7 +471,7 @@ void filter_leading_space_from_exprs(char *str)
}
}
}
-
+
u++;
}
}
@@ -500,7 +500,7 @@ int main(int argc, char **argv)
int i;
struct namelist *n;
struct ast_context *lp,*lp2;
-
+
for(i=1;i<argc;i++) {
if( argv[i][0] == '-' && argv[i][1] == 'n' )
no_comp =1;
@@ -513,7 +513,7 @@ int main(int argc, char **argv)
if( argv[i][0] == '-' && argv[i][1] == 'w' )
dump_extensions =1;
}
-
+
if( !quiet ) {
printf("\n(If you find progress and other non-error messages irritating, you can use -q to suppress them)\n");
if( !no_comp )
@@ -533,30 +533,30 @@ int main(int argc, char **argv)
localized_use_conf_dir();
}
strcpy(var_dir, "/var/lib/asterisk");
-
+
if( dump_extensions ) {
dumpfile = fopen("extensions.conf.aeldump","w");
if( !dumpfile ) {
printf("\n\nSorry, cannot open extensions.conf.aeldump for writing! Correct the situation and try again!\n\n");
exit(10);
}
-
+
}
FIRST_TIME = 1;
-
+
ael_external_load_module();
-
+
ast_log(4, "ael2_parse", __LINE__, "main", "%d contexts, %d extensions, %d priorities\n", conts, extens, priors);
if( dump_extensions && dumpfile ) {
-
+
for( lp = context_list; lp; lp = lp->next ) { /* print out any contexts that didn't have any
extensions in them */
if( lp->extension_count == 0 ) {
-
+
fprintf(dumpfile,"\n\n[%s]\n", lp->name);
-
+
for(n=lp->ignorepats;n;n=n->next) {
fprintf(dumpfile, "ignorepat => %s\n", n->name);
}
@@ -572,10 +572,10 @@ int main(int argc, char **argv)
}
}
}
-
+
if( dump_extensions && dumpfile )
fclose(dumpfile);
-
+
for( lp = context_list; lp; lp = lp2 ) { /* free the ast_context structs */
lp2 = lp->next;
lp->next = 0;
@@ -587,7 +587,7 @@ int main(int argc, char **argv)
free(lp);
}
-
+
return 0;
}
diff --git a/utils/astman.c b/utils/astman.c
index 0099a13f6..50e6a8901 100644
--- a/utils/astman.c
+++ b/utils/astman.c
@@ -55,8 +55,8 @@ ASTERISK_REGISTER_FILE()
/*
* 2005.05.27 - different versions of newt define the type of the buffer
- * for the 5th argument to newtEntry() as char ** or const char ** . To
- * let the code compile cleanly with -Werror, we cast it to void * through
+ * for the 5th argument to newtEntry() as char ** or const char ** . To
+ * let the code compile cleanly with -Werror, we cast it to void * through
* _NEWT_CAST.
*/
#define _NEWT_CAST (void *)
@@ -280,7 +280,7 @@ static int process_message(struct ast_mansession *s, struct message *m)
for (x=0;x<m->hdrcount;x++) {
printf("Header: %s\n", m->headers[x]);
}
-#endif
+#endif
return 0;
}
@@ -295,8 +295,8 @@ static void rebuild_channels(newtComponent c)
newtListboxClear(c);
AST_LIST_TRAVERSE(&chans, chan, list) {
snprintf(tmpn, sizeof(tmpn), "%s (%s)", chan->name, chan->callerid);
- if (strlen(chan->exten))
- snprintf(tmp, sizeof(tmp), "%-30s %8s -> %s@%s:%s",
+ if (strlen(chan->exten))
+ snprintf(tmp, sizeof(tmp), "%-30s %8s -> %s@%s:%s",
tmpn, chan->state,
chan->exten, chan->context, chan->priority);
else
@@ -313,8 +313,8 @@ static void rebuild_channels(newtComponent c)
static int has_input(struct ast_mansession *s)
{
int x;
- for (x=1;x<s->inlen;x++)
- if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r'))
+ for (x=1;x<s->inlen;x++)
+ if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r'))
return 1;
return 0;
}
@@ -337,7 +337,7 @@ static int get_input(struct ast_mansession *s, char *output)
s->inlen -= (x + 1);
return 1;
}
- }
+ }
if (s->inlen >= sizeof(s->inbuf) - 1) {
fprintf(stderr, "Dumping long line with no return from %s: %s\n", inet_ntoa(s->sin.sin_addr), s->inbuf);
s->inlen = 0;
@@ -489,7 +489,7 @@ static void try_status(void)
show_message("Status Failed Failed", get_header(m, "Message"));
}
}
-
+
static void try_hangup(newtComponent c)
{
@@ -506,7 +506,7 @@ static void try_hangup(newtComponent c)
show_message("Hangup Failed", get_header(m, "Message"));
}
}
-
+
}
static int get_user_input(char *msg, char *buf, int buflen)
@@ -528,7 +528,7 @@ static int get_user_input(char *msg, char *buf, int buflen)
newtFormAddComponents(form, inpfield, ok, cancel, NULL);
newtFormRun(form, &es);
strncpy(buf, input, buflen - 1);
- if (es.u.co == ok)
+ if (es.u.co == ok)
res = 0;
else
res = -1;
@@ -550,7 +550,7 @@ static void try_redirect(newtComponent c)
if (chan) {
strncpy(channame, chan->name, sizeof(channame) - 1);
snprintf(tmp, sizeof(tmp), "Enter new extension for %s", channame);
- if (get_user_input(tmp, dest, sizeof(dest)))
+ if (get_user_input(tmp, dest, sizeof(dest)))
return;
if ((context = strchr(dest, '@'))) {
*context = '\0';
@@ -566,7 +566,7 @@ static void try_redirect(newtComponent c)
show_message("Hangup Failed", get_header(m, "Message"));
}
}
-
+
}
static int manage_calls(char *host)
@@ -581,23 +581,23 @@ static int manage_calls(char *host)
/* Mark: If there's one thing you learn from this code, it is this...
Never, ever fly Air France. Their customer service is absolutely
- the worst. I've never heard the words "That's not my problem" as
+ the worst. I've never heard the words "That's not my problem" as
many times as I have from their staff -- It should, without doubt
- be their corporate motto if it isn't already. Don't bother giving
+ be their corporate motto if it isn't already. Don't bother giving
them business because you're just a pain in their side and they
will be sure to let you know the first time you speak to them.
-
+
If you ever want to make me happy just tell me that you, too, will
never fly Air France again either (in spite of their excellent
- cuisine).
-
+ cuisine).
+
Update by oej: The merger with KLM has transferred this
- behaviour to KLM as well.
+ behaviour to KLM as well.
Don't bother giving them business either...
Only if you want to travel randomly without luggage, you
might pick either of them.
-
+
*/
snprintf(tmp, sizeof(tmp), "Asterisk Manager at %s", host);
newtCenteredWindow(74, 20, tmp);
@@ -610,7 +610,7 @@ static int manage_calls(char *host)
channels = newtListbox(1,1,14, NEWT_FLAG_SCROLL);
newtFormAddComponents(form, channels, redirect, hangup, quit, NULL);
newtListboxSetWidth(channels, 72);
-
+
show_doing("Getting Status", "Retrieving system status...");
try_status();
hide_doing();
@@ -654,18 +654,18 @@ static int manager_login(char *hostname)
char tmp[55];
struct hostent *hp;
int res = -1;
-
+
session.fd = socket(AF_INET, SOCK_STREAM, 0);
if (session.fd < 0) {
snprintf(tmp, sizeof(tmp), "socket() failed: %s\n", strerror(errno));
show_message("Socket failed", tmp);
return -1;
}
-
+
snprintf(tmp, sizeof(tmp), "Looking up %s\n", hostname);
show_doing("Connecting....", tmp);
-
-
+
+
hp = gethostbyname(hostname);
if (!hp) {
snprintf(tmp, sizeof(tmp), "No such address: %s\n", hostname);
@@ -685,21 +685,21 @@ static int manager_login(char *hostname)
show_message("Connect Failed", tmp);
return -1;
}
-
+
hide_doing();
-
+
login = newtButton(5, 6, "Login");
cancel = newtButton(25, 6, "Cancel");
newtCenteredWindow(40, 10, "Asterisk Manager Login");
snprintf(tmp, sizeof(tmp), "Host: %s", hostname);
label = newtLabel(4,1, tmp);
-
+
ulabel = newtLabel(4,2,"Username:");
plabel = newtLabel(4,3,"Password:");
-
+
username = newtEntry(14, 2, "", 20, _NEWT_CAST &user, 0);
password = newtEntry(14, 3, "", 20, _NEWT_CAST &pass, NEWT_FLAG_HIDDEN);
-
+
form = newtForm(NULL, NULL, 0);
newtFormAddComponents(form, username, password, login, cancel, label, ulabel, plabel,NULL);
newtFormRun(form, &es);
@@ -736,7 +736,7 @@ static int manager_login(char *hostname)
show_message("Login Failed", get_header(m, "Message"));
}
} else {
- manager_action("Login",
+ manager_action("Login",
"Username: %s\r\n"
"Secret: %s\r\n",
user, pass);
diff --git a/utils/check_expr.c b/utils/check_expr.c
index de668f691..f29363c91 100644
--- a/utils/check_expr.c
+++ b/utils/check_expr.c
@@ -145,7 +145,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
{
va_list vars;
va_start(vars,fmt);
-
+
printf("LOG: lev:%d file:%s line:%d func: %s ",
level, file, line, function);
vprintf(fmt, vars);
@@ -162,7 +162,7 @@ void parse_file(const char *fname);
void __ast_register_file(const char *file);
void __ast_register_file(const char *file) { }
#if !defined(LOW_MEMORY)
-int ast_add_profile(const char *x, uint64_t scale) { return 0;}
+int ast_add_profile(const char *x, uint64_t scale) { return 0;}
#endif
int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
{
@@ -207,7 +207,7 @@ unsigned int check_expr(char* buffer, char* error_report)
unsigned int warn_found = 0;
error_report[0] = 0;
-
+
for (cp = buffer; *cp; ++cp)
{
switch (*cp)
@@ -223,7 +223,7 @@ unsigned int check_expr(char* buffer, char* error_report)
global_lineno);
}
break;
-
+
case '>':
case '<':
case '!':
@@ -240,7 +240,7 @@ unsigned int check_expr(char* buffer, char* error_report)
++warn_found;
}
break;
-
+
case '|':
case '&':
case '=':
@@ -292,13 +292,13 @@ int check_eval(char *buffer, char *error_report)
if (*cp == '$' && *(cp+1) == '{') {
int brack_lev = 1;
char *xp= cp+2;
-
+
while (*xp) {
if (*xp == '{')
brack_lev++;
else if (*xp == '}')
brack_lev--;
-
+
if (brack_lev == 0)
break;
xp++;
@@ -306,7 +306,7 @@ int check_eval(char *buffer, char *error_report)
if (*xp == '}') {
char varname[200];
char *val;
-
+
strncpy(varname,cp+2, xp-cp-2);
varname[xp-cp-2] = 0;
cp = xp;
@@ -358,7 +358,7 @@ void parse_file(const char *fname)
int c1;
char last_char= 0;
char buffer[30000]; /* I sure hope no expr gets this big! */
-
+
if (!f) {
fprintf(stderr,"Couldn't open %s for reading... need an extensions.conf file to parse!\n",fname);
exit(20);
@@ -367,9 +367,9 @@ void parse_file(const char *fname)
fprintf(stderr,"Couldn't open 'expr2_log' file for writing... please fix and re-run!\n");
exit(21);
}
-
+
global_lineno = 1;
-
+
while ((c1 = fgetc(f)) != EOF) {
if (c1 == '\n')
global_lineno++;
@@ -380,7 +380,7 @@ void parse_file(const char *fname)
int bufcount = 0;
int retval;
char error_report[30000];
-
+
while ((c1 = fgetc(f)) != EOF) {
if (c1 == '[')
bracklev++;
@@ -392,7 +392,7 @@ void parse_file(const char *fname)
fclose(l);
printf("--- ERROR --- A newline in the middle of an expression at line %d!\n", global_lineno);
}
-
+
if (bracklev == 0)
break;
buffer[bufcount++] = c1;
@@ -404,18 +404,18 @@ void parse_file(const char *fname)
printf("--- ERROR --- EOF reached in middle of an expression at line %d!\n", global_lineno);
exit(22);
}
-
+
buffer[bufcount] = 0;
/* update stats */
global_expr_tot_size += bufcount;
global_expr_count++;
if (bufcount > global_expr_max_size)
global_expr_max_size = bufcount;
-
+
retval = check_expr(buffer, error_report); /* check_expr should bump the warning counter */
if (retval != 0) {
/* print error report */
- printf("Warning(s) at line %d, expression: $[%s]; see expr2_log file for details\n",
+ printf("Warning(s) at line %d, expression: $[%s]; see expr2_log file for details\n",
global_lineno, buffer);
fprintf(l, "%s", error_report);
}
@@ -436,7 +436,7 @@ void parse_file(const char *fname)
global_warn_count,
global_expr_max_size,
(global_expr_count) ? global_expr_tot_size/global_expr_count : 0);
-
+
fclose(f);
fclose(l);
}
@@ -446,7 +446,7 @@ int main(int argc,char **argv)
{
int argc1;
char *eq;
-
+
if (argc < 2) {
printf("check_expr -- a program to look thru extensions.conf files for $[...] expressions,\n");
printf(" and run them thru the parser, looking for problems\n");
@@ -458,7 +458,7 @@ int main(int argc,char **argv)
printf(" Note that messages about operators not being surrounded by spaces is merely to alert\n");
printf(" you to possible problems where you might be expecting those operators as part of a string.\n");
printf(" (to include operators in a string, wrap with double quotes!)\n");
-
+
exit(19);
}
global_varlist = 0;
@@ -470,7 +470,7 @@ int main(int argc,char **argv)
}
/* parse command args for x=y and set varz */
-
+
parse_file(argv[1]);
return 0;
}
diff --git a/utils/extconf.c b/utils/extconf.c
index 53347b41a..872980172 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -1,4 +1,4 @@
-/*
+/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2006, Digium, Inc.
@@ -86,7 +86,7 @@ void ast_verbose(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
#endif
#define AST_API_MODULE 1 /* gimme the inline defs! */
-struct ast_channel
+struct ast_channel
{
char x; /* basically empty! */
};
@@ -245,7 +245,7 @@ static void __attribute__((constructor)) init_empty_mutex(void)
static inline int __ast_pthread_mutex_init_attr(const char *filename, int lineno, const char *func,
const char *mutex_name, ast_mutex_t *t,
- pthread_mutexattr_t *attr)
+ pthread_mutexattr_t *attr)
{
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
int canlog = strcmp(filename, "logger.c");
@@ -464,7 +464,7 @@ static inline int __ast_pthread_mutex_unlock(const char *filename, int lineno, c
}
if ((res = pthread_mutex_unlock(&t->mutex))) {
- __ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n",
+ __ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n",
filename, lineno, func, strerror(res));
DO_THREAD_CRASH;
}
@@ -505,7 +505,7 @@ static void __attribute__((constructor)) init_##mutex(void) \
ast_mutex_init(&mutex); \
}
#else /* !AST_MUTEX_INIT_W_CONSTRUCTORS */
-/* By default, use static initialization of mutexes. */
+/* By default, use static initialization of mutexes. */
#define __AST_MUTEX_DEFINE(scope, mutex) \
scope ast_mutex_t mutex = AST_MUTEX_INIT_VALUE
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
@@ -618,7 +618,7 @@ AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
{
__asm __volatile (
" lock xaddl %0, %1 ; "
- : "+r" (v), /* 0 (result) */
+ : "+r" (v), /* 0 (result) */
"=m" (*p) /* 1 */
: "m" (*p)); /* 2 */
return (v);
@@ -864,7 +864,7 @@ char * attribute_malloc _ast_strdup(const char *str, const char *file, int linen
* message in the case that the allocation fails.
*
* ast_strndup(), unlike strndup(), can safely accept a NULL argument for the
- * string to duplicate. If a NULL argument is provided, ast_strdup will return
+ * string to duplicate. If a NULL argument is provided, ast_strdup will return
* NULL without generating any kind of error log message.
*
* The arguments and return value are the same as strndup()
@@ -1033,19 +1033,19 @@ static void LLB_ADD(char *str)
int siz = strlen(str);
if (rem < siz+1) {
lline_buffer = ast_realloc(lline_buffer, lline_buffer_size + CB_INCR + siz + 1);
- if (!lline_buffer)
+ if (!lline_buffer)
return;
lline_buffer_size += CB_INCR + siz + 1;
}
strcat(lline_buffer,str);
}
-static void CB_RESET(void )
-{
- comment_buffer[0] = 0;
+static void CB_RESET(void )
+{
+ comment_buffer[0] = 0;
lline_buffer[0] = 0;
}
-
+
/*! \brief Keep track of how many threads are currently trying to wait*() on
* a child process */
static unsigned int safe_system_level = 0;
@@ -1108,7 +1108,7 @@ int ast_safe_system(const char *s)
pid = fork();
#else
pid = vfork();
-#endif
+#endif
if (pid == 0) {
#ifdef HAVE_WORKING_FORK
@@ -1124,7 +1124,7 @@ int ast_safe_system(const char *s)
if (res > -1) {
res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
break;
- } else if (errno != EINTR)
+ } else if (errno != EINTR)
break;
}
} else {
@@ -1141,7 +1141,7 @@ int ast_safe_system(const char *s)
}
static struct ast_comment *ALLOC_COMMENT(const char *buffer)
-{
+{
struct ast_comment *x = ast_calloc(1,sizeof(struct ast_comment)+strlen(buffer)+1);
strcpy(x->cmt, buffer);
return x;
@@ -1164,7 +1164,7 @@ static struct ast_config_engine *config_engine_list;
struct ast_category {
char name[80];
int ignored; /*!< do not let user of the config see this category */
- int include_level;
+ int include_level;
char *file; /*!< the file name from whence this declaration was read */
int lineno;
struct ast_comment *precomments;
@@ -1257,7 +1257,7 @@ char *ast_trim_blanks(char *str),
if (work) {
work += strlen(work) - 1;
- /* It's tempting to only want to erase after we exit this loop,
+ /* It's tempting to only want to erase after we exit this loop,
but since ast_trim_blanks *could* receive a constant string
(which we presumably wouldn't have to touch), we shouldn't
actually set anything unless we must, and it's easier just
@@ -1286,7 +1286,7 @@ char *ast_strip(char *s),
if (s)
ast_trim_blanks(s);
return s;
-}
+}
)
@@ -1319,15 +1319,15 @@ void localized_ast_include_rename(struct ast_config *conf, const char *from_file
static struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename);
-static struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename)
+static struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename)
{
struct ast_variable *variable;
- int name_len = strlen(name) + 1;
+ int name_len = strlen(name) + 1;
if ((variable = ast_calloc(1, name_len + strlen(value) + 1 + strlen(filename) + 1 + sizeof(*variable)))) {
variable->name = variable->stuff;
- variable->value = variable->stuff + name_len;
- variable->file = variable->value + strlen(value) + 1;
+ variable->value = variable->stuff + name_len;
+ variable->file = variable->value + strlen(value) + 1;
strcpy(variable->name,name);
strcpy(variable->value,value);
strcpy(variable->file,filename);
@@ -1339,11 +1339,11 @@ static struct ast_variable *ast_variable_new(const char *name, const char *value
static struct ast_config_include *ast_include_new(struct ast_config *conf, const char *from_file, const char *included_file, int is_exec, const char *exec_file, int from_lineno, char *real_included_file_name, int real_included_file_name_size)
{
/* a file should be included ONCE. Otherwise, if one of the instances is changed,
- then all be changed. -- how do we know to include it? -- Handling modified
+ then all be changed. -- how do we know to include it? -- Handling modified
instances is possible, I'd have
to create a new master for each instance. */
struct ast_config_include *inc;
-
+
inc = ast_include_find(conf, included_file);
if (inc)
{
@@ -1352,7 +1352,7 @@ static struct ast_config_include *ast_include_new(struct ast_config *conf, const
ast_log(LOG_WARNING,"'%s', line %d: Same File included more than once! This data will be saved in %s if saved back to disk.\n", from_file, from_lineno, real_included_file_name);
} else
*real_included_file_name = 0;
-
+
inc = ast_calloc(1,sizeof(struct ast_config_include));
inc->include_location_file = ast_strdup(from_file);
inc->include_location_lineno = from_lineno;
@@ -1360,15 +1360,15 @@ static struct ast_config_include *ast_include_new(struct ast_config *conf, const
inc->included_file = ast_strdup(real_included_file_name);
else
inc->included_file = ast_strdup(included_file);
-
+
inc->exec = is_exec;
if (is_exec)
inc->exec_file = ast_strdup(exec_file);
-
+
/* attach this new struct to the conf struct */
inc->next = conf->includes;
conf->includes = inc;
-
+
return inc;
}
@@ -1377,13 +1377,13 @@ void localized_ast_include_rename(struct ast_config *conf, const char *from_file
struct ast_config_include *incl;
struct ast_category *cat;
struct ast_variable *v;
-
+
int from_len = strlen(from_file);
int to_len = strlen(to_file);
-
+
if (strcmp(from_file, to_file) == 0) /* no use wasting time if the name is the same */
return;
-
+
/* the manager code allows you to read in one config file, then
write it back out under a different name. But, the new arrangement
ties output lines to the file name. So, before you try to write
@@ -1392,7 +1392,7 @@ void localized_ast_include_rename(struct ast_config *conf, const char *from_file
*/
/* file names are on categories, includes (of course), and on variables. So,
traverse all this and swap names */
-
+
for (incl = conf->includes; incl; incl=incl->next) {
if (strcmp(incl->include_location_file,from_file) == 0) {
if (from_len >= to_len)
@@ -1523,7 +1523,7 @@ static struct ast_variable *variable_clone(const struct ast_variable *old)
return new;
}
-
+
static void ast_variables_destroy(struct ast_variable *v)
{
struct ast_variable *vn;
@@ -1538,7 +1538,7 @@ static void ast_variables_destroy(struct ast_variable *v)
static void ast_includes_destroy(struct ast_config_include *incls)
{
struct ast_config_include *incl,*inclnext;
-
+
for (incl=incls; incl; incl = inclnext) {
inclnext = incl->next;
if (incl->include_location_file)
@@ -1559,7 +1559,7 @@ static void ast_config_destroy(struct ast_config *cfg)
return;
ast_includes_destroy(cfg->includes);
-
+
cat = cfg->root;
while (cat) {
ast_variables_destroy(cat->root);
@@ -1695,7 +1695,7 @@ extern int ast_language_is_prefix;
*/
#define AST_RWLIST_RDLOCK(head) \
ast_rwlock_rdlock(&(head)->lock)
-
+
/*!
\brief Attempts to unlock a read/write based list.
\param head This is a pointer to the list head structure
@@ -1969,7 +1969,7 @@ struct { \
}
#define AST_RWLIST_ENTRY AST_LIST_ENTRY
-
+
/*!
\brief Returns the first entry contained in a list.
\param head This is a pointer to the list head structure
@@ -2381,7 +2381,7 @@ struct ast_switch {
AST_LIST_ENTRY(ast_switch) list;
const char *name; /*!< Name of the switch */
const char *description; /*!< Description of the switch */
-
+
ast_switch_f *exists;
ast_switch_f *canmatch;
ast_switch_f *exec;
@@ -2455,7 +2455,7 @@ static const char *ast_var_name(const struct ast_var_t *var)
}
/* experiment 1: see if it's easier just to use existing config code
- * to read in the extensions.conf file. In this scenario,
+ * to read in the extensions.conf file. In this scenario,
I have to rip/copy code from other modules, because they
are staticly declared as-is. A solution would be to move
the ripped code to another location and make them available
@@ -2467,7 +2467,7 @@ static void ast_log(int level, const char *file, int line, const char *function,
{
va_list vars;
va_start(vars,fmt);
-
+
printf("LOG: lev:%d file:%s line:%d func: %s ",
level, file, line, function);
vprintf(fmt, vars);
@@ -2479,7 +2479,7 @@ void __attribute__((format(printf, 1, 2))) ast_verbose(const char *fmt, ...)
{
va_list vars;
va_start(vars,fmt);
-
+
printf("VERBOSE: ");
vprintf(fmt, vars);
fflush(stdout);
@@ -2697,7 +2697,7 @@ struct ast_state_cb {
/*! \brief Structure for dial plan hints
\note Hints are pointers from an extension in the dialplan to one or
- more devices (tech/name)
+ more devices (tech/name)
- See \ref AstExtState
*/
struct ast_hint {
@@ -2725,7 +2725,7 @@ AST_LIST_HEAD(store_hints, store_hint);
#define STATUS_SUCCESS 5
static struct ast_var_t *ast_var_assign(const char *name, const char *value)
-{
+{
struct ast_var_t *var;
int name_len = strlen(name) + 1;
int value_len = strlen(value) + 1;
@@ -2737,10 +2737,10 @@ static struct ast_var_t *ast_var_assign(const char *name, const char *value)
ast_copy_string(var->name, name, name_len);
var->value = var->name + name_len;
ast_copy_string(var->value, value, value_len);
-
+
return var;
-}
-
+}
+
static void ast_var_delete(struct ast_var_t *var)
{
free(var);
@@ -3017,7 +3017,7 @@ static void null_datad(void *foo)
}
/*! \brief Find realtime engine for realtime family */
-static struct ast_config_engine *find_engine(const char *family, char *database, int dbsiz, char *table, int tabsiz)
+static struct ast_config_engine *find_engine(const char *family, char *database, int dbsiz, char *table, int tabsiz)
{
struct ast_config_engine *eng, *ret = NULL;
struct ast_config_map *map;
@@ -3040,12 +3040,12 @@ static struct ast_config_engine *find_engine(const char *family, char *database,
ret = eng;
}
}
-
-
+
+
/* if we found a mapping, but the engine is not available, then issue a warning */
if (map && !ret)
ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver);
-
+
return ret;
}
@@ -3120,7 +3120,7 @@ static void ast_category_destroy(struct ast_category *cat)
ast_variables_destroy(cat->root);
if (cat->file)
free(cat->file);
-
+
free(cat);
}
@@ -3137,7 +3137,7 @@ static struct ast_config *ast_config_internal_load(const char *filename, struct
char db[256];
char table[256];
struct ast_config_engine *loader = &text_file_engine;
- struct ast_config *result;
+ struct ast_config *result;
if (cfg->include_level == cfg->max_include_level) {
ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level);
@@ -3165,7 +3165,7 @@ static struct ast_config *ast_config_internal_load(const char *filename, struct
}
result = loader->load_func(db, table, filename, cfg, withcomments, suggested_incl_file);
- /* silence is golden
+ /* silence is golden
ast_log(LOG_WARNING, "finished internal loading file %s level=%d\n", filename, cfg->include_level);
*/
@@ -3204,7 +3204,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
return -1;
}
(*cat)->lineno = lineno;
-
+
/* add comments */
if (withcomments && comment_buffer && comment_buffer[0] ) {
newcat->precomments = ALLOC_COMMENT(comment_buffer);
@@ -3214,7 +3214,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
}
if( withcomments )
CB_RESET();
-
+
/* If there are options or categories to inherit from, process them now */
if (c) {
if (!(cur = strchr(c, ')'))) {
@@ -3241,7 +3241,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
}
} else {
struct ast_category *base;
-
+
base = category_get(cfg, cur, 1);
if (!base) {
ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile);
@@ -3264,7 +3264,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
c = ast_skip_blanks(c + 1);
if (!*c)
c = NULL;
- } else
+ } else
c = NULL;
do_include = !strcasecmp(cur, "include");
if(!do_include)
@@ -3279,7 +3279,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
if (c) {
char *cur2;
char real_inclusion_name[256];
-
+
/* Strip off leading and trailing "'s and <>'s */
while((*c == '<') || (*c == '>') || (*c == '\"')) c++;
/* Get rid of leading mess */
@@ -3294,7 +3294,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
}
/* #exec </path/to/executable>
We create a tmp file, then we #include it, then we delete it. */
- if (do_exec) {
+ if (do_exec) {
snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
ast_safe_system(cmd);
@@ -3303,26 +3303,26 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
exec_file[0] = '\0';
/* A #include */
/* ast_log(LOG_WARNING, "Reading in included file %s withcomments=%d\n", cur, withcomments); */
-
+
/* record this inclusion */
ast_include_new(cfg, configfile, cur, do_exec, cur2, lineno, real_inclusion_name, sizeof(real_inclusion_name));
-
+
do_include = ast_config_internal_load(cur, cfg, withcomments, real_inclusion_name) ? 1 : 0;
if(!ast_strlen_zero(exec_file))
unlink(exec_file);
if(!do_include)
return 0;
/* ast_log(LOG_WARNING, "Done reading in included file %s withcomments=%d\n", cur, withcomments); */
-
+
} else {
- ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n",
+ ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n",
do_exec ? "exec" : "include",
do_exec ? "/path/to/executable" : "filename",
lineno,
configfile);
}
}
- else
+ else
ast_log(LOG_WARNING, "Unknown directive '%s' at line %d of %s\n", cur, lineno, configfile);
} else {
/* Just a line (variable = value) */
@@ -3356,7 +3356,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
}
if( withcomments )
CB_RESET();
-
+
} else {
return -1;
}
@@ -3394,7 +3394,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
struct ast_category *cat = NULL;
int count = 0;
struct stat statbuf;
-
+
cat = ast_config_get_current_category(cfg);
if (filename[0] == '/') {
@@ -3409,7 +3409,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
if (withcomments && cfg && cfg->include_level < 2 ) {
CB_INIT();
}
-
+
#ifdef AST_INCLUDE_GLOB
{
int glob_ret;
@@ -3460,17 +3460,17 @@ static struct ast_config *config_text_file_load(const char *database, const char
while(!feof(f)) {
lineno++;
if (fgets(buf, sizeof(buf), f)) {
- if ( withcomments ) {
+ if ( withcomments ) {
CB_ADD(lline_buffer); /* add the current lline buffer to the comment buffer */
lline_buffer[0] = 0; /* erase the lline buffer */
}
-
+
new_buf = buf;
- if (comment)
+ if (comment)
process_buf = NULL;
else
process_buf = buf;
-
+
while ((comment_p = strchr(new_buf, COMMENT_META))) {
if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
/* Yuck, gotta memmove */
@@ -3502,7 +3502,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
CB_ADD(";");
CB_ADD_LEN(oldptr+1,new_buf-oldptr-1);
}
-
+
memmove(oldptr, new_buf, strlen(new_buf) + 1);
new_buf = oldptr;
} else
@@ -3510,12 +3510,12 @@ static struct ast_config *config_text_file_load(const char *database, const char
}
} else {
if (!comment) {
- /* If ; is found, and we are not nested in a comment,
+ /* If ; is found, and we are not nested in a comment,
we immediately stop all comment processing */
if ( withcomments ) {
LLB_ADD(comment_p);
}
- *comment_p = '\0';
+ *comment_p = '\0';
new_buf = comment_p;
} else
new_buf = comment_p + 1;
@@ -3525,7 +3525,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
{
CB_ADD(buf); /* the whole line is a comment, store it */
}
-
+
if (process_buf) {
char *stripped_process_buf = ast_strip(process_buf);
if (!ast_strlen_zero(stripped_process_buf)) {
@@ -3537,7 +3537,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
}
}
}
- fclose(f);
+ fclose(f);
} while(0);
if (comment) {
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
@@ -3551,12 +3551,12 @@ static struct ast_config *config_text_file_load(const char *database, const char
}
#endif
if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
- if (comment_buffer) {
+ if (comment_buffer) {
free(comment_buffer);
free(lline_buffer);
- comment_buffer=0;
- lline_buffer=0;
- comment_buffer_size=0;
+ comment_buffer=0;
+ lline_buffer=0;
+ comment_buffer_size=0;
lline_buffer_size=0;
}
}
@@ -3569,7 +3569,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
static struct ast_config *ast_config_new(void) ;
-static struct ast_config *ast_config_new(void)
+static struct ast_config *ast_config_new(void)
{
struct ast_config *config;
@@ -3622,7 +3622,7 @@ static struct ast_category *next_available_category(struct ast_category *cat)
}
static char *ast_category_browse(struct ast_config *config, const char *prev)
-{
+{
struct ast_category *cat = NULL;
if (prev && config->last_browse && (config->last_browse->name == prev))
@@ -3645,7 +3645,7 @@ static char *ast_category_browse(struct ast_config *config, const char *prev)
}
}
}
-
+
if (cat)
cat = next_available_category(cat);
@@ -3666,21 +3666,21 @@ void ast_config_set_current_category(struct ast_config *cfg, const struct ast_ca
/* NOTE: categories and variables each have a file and lineno attribute. On a save operation, these are used to determine
which file and line number to write out to. Thus, an entire hierarchy of config files (via #include statements) can be
recreated. BUT, care must be taken to make sure that every cat and var has the proper file name stored, or you may
- be shocked and mystified as to why things are not showing up in the files!
-
+ be shocked and mystified as to why things are not showing up in the files!
+
Also, All #include/#exec statements are recorded in the "includes" LL in the ast_config structure. The file name
and line number are stored for each include, plus the name of the file included, so that these statements may be
- included in the output files on a file_save operation.
-
+ included in the output files on a file_save operation.
+
The lineno's are really just for relative placement in the file. There is no attempt to make sure that blank lines
are included to keep the lineno's the same between input and output. The lineno fields are used mainly to determine
the position of the #include and #exec directives. So, blank lines tend to disappear from a read/rewrite operation,
and a header gets added.
-
+
vars and category heads are output in the order they are stored in the config file. So, if the software
shuffles these at all, then the placement of #include directives might get a little mixed up, because the
file/lineno data probably won't get changed.
-
+
*/
static void gen_header(FILE *f1, const char *configfile, const char *fn, const char *generator)
@@ -3689,7 +3689,7 @@ static void gen_header(FILE *f1, const char *configfile, const char *fn, const c
time_t t;
time(&t);
ast_copy_string(date, ctime(&t), sizeof(date));
-
+
fprintf(f1, ";!\n");
fprintf(f1, ";! Automatically generated configuration file\n");
if (strcmp(configfile, fn))
@@ -3708,7 +3708,7 @@ static void set_fn(char *fn, int fn_size, const char *file, const char *configfi
ast_copy_string(fn, configfile, fn_size);
else
snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
- } else if (file[0] == '/')
+ } else if (file[0] == '/')
ast_copy_string(fn, file, fn_size);
else
snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file);
@@ -3725,20 +3725,20 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
struct ast_comment *cmt;
struct ast_config_include *incl;
int blanklines = 0;
-
+
/* reset all the output flags, in case this isn't our first time saving this data */
-
+
for (incl=cfg->includes; incl; incl = incl->next)
incl->output = 0;
-
+
/* go thru all the inclusions and make sure all the files involved (configfile plus all its inclusions)
are all truncated to zero bytes and have that nice header*/
-
+
for (incl=cfg->includes; incl; incl = incl->next)
{
if (!incl->exec) { /* leave the execs alone -- we'll write out the #exec directives, but won't zero out the include files or exec files*/
FILE *f1;
-
+
set_fn(fn, sizeof(fn), incl->included_file, configfile); /* normally, fn is just set to incl->included_file, prepended with config dir if relative */
f1 = fopen(fn,"w");
if (f1) {
@@ -3749,24 +3749,24 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
}
}
}
-
+
set_fn(fn, sizeof(fn), 0, configfile); /* just set fn to absolute ver of configfile */
-#ifdef __CYGWIN__
+#ifdef __CYGWIN__
if ((f = fopen(fn, "w+"))) {
#else
if ((f = fopen(fn, "w"))) {
-#endif
+#endif
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Saving '%s': ", fn);
gen_header(f, configfile, fn, generator);
cat = cfg->root;
fclose(f);
-
+
/* from here out, we open each involved file and concat the stuff we need to add to the end and immediately close... */
- /* since each var, cat, and associated comments can come from any file, we have to be
+ /* since each var, cat, and associated comments can come from any file, we have to be
mobile, and open each file, print, and close it on an entry-by-entry basis */
-
+
while(cat) {
set_fn(fn, sizeof(fn), cat->file, configfile);
f = fopen(fn, "a");
@@ -3775,7 +3775,7 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
return -1;
}
-
+
/* dump any includes that happen before this category header */
for (incl=cfg->includes; incl; incl = incl->next) {
if (strcmp(incl->include_location_file, cat->file) == 0){
@@ -3788,7 +3788,7 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
}
}
}
-
+
/* Dump section with any appropriate comment */
for (cmt = cat->precomments; cmt; cmt=cmt->next) {
if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
@@ -3803,7 +3803,7 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
if (!cat->sameline)
fprintf(f,"\n");
fclose(f);
-
+
var = cat->root;
while(var) {
set_fn(fn, sizeof(fn), var->file, configfile);
@@ -3813,7 +3813,7 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
return -1;
}
-
+
/* dump any includes that happen before this category header */
for (incl=cfg->includes; incl; incl = incl->next) {
if (strcmp(incl->include_location_file, var->file) == 0){
@@ -3826,24 +3826,24 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
}
}
}
-
+
for (cmt = var->precomments; cmt; cmt=cmt->next) {
if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
fprintf(f,"%s", cmt->cmt);
}
- if (var->sameline)
+ if (var->sameline)
fprintf(f, "%s %s %s %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt);
- else
+ else
fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value);
if (var->blanklines) {
blanklines = var->blanklines;
while (blanklines--)
fprintf(f, "\n");
}
-
+
fclose(f);
-
-
+
+
var = var->next;
}
cat = cat->next;
@@ -3860,7 +3860,7 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
/* Now, for files with trailing #include/#exec statements,
we have to make sure every entry is output */
-
+
for (incl=cfg->includes; incl; incl = incl->next) {
if (!incl->output) {
/* open the respective file */
@@ -3871,7 +3871,7 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
return -1;
}
-
+
/* output the respective include */
if (incl->exec)
fprintf(f,"#exec \"%s\"\n", incl->exec_file);
@@ -3881,7 +3881,7 @@ int localized_config_text_file_save(const char *configfile, const struct ast_con
incl->output = 1;
}
}
-
+
return 0;
}
@@ -4207,7 +4207,7 @@ static int ext_cmp1(const char **p)
break;
}
/* locate end of set */
- end = strchr(*p, ']');
+ end = strchr(*p, ']');
if (end == NULL) {
ast_log(LOG_WARNING, "Wrong usage of [] in the extension\n");
@@ -4566,24 +4566,24 @@ static inline int include_valid(struct ast_include *i)
static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
- struct ast_context *bypass,
+ struct ast_context *bypass,
struct pbx_find_info *q,
- const char *context,
- const char *exten,
+ const char *context,
+ const char *exten,
int priority,
- const char *label,
- const char *callerid,
+ const char *label,
+ const char *callerid,
enum ext_match_t action);
static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
- struct ast_context *bypass,
+ struct ast_context *bypass,
struct pbx_find_info *q,
- const char *context,
- const char *exten,
+ const char *context,
+ const char *exten,
int priority,
- const char *label,
- const char *callerid,
+ const char *label,
+ const char *callerid,
enum ext_match_t action)
{
int x;
@@ -4667,7 +4667,7 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
continue;
}
/* No need to Substitute variables now; we shouldn't be here if there's any */
-
+
/* equivalent of extension_match_core() at the switch level */
if (action == E_CANMATCH)
aswf = asw->canmatch;
@@ -4701,20 +4701,20 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
struct ast_exten *localized_find_extension(struct ast_context *bypass,
struct pbx_find_info *q,
- const char *context,
- const char *exten,
+ const char *context,
+ const char *exten,
int priority,
- const char *label,
- const char *callerid,
+ const char *label,
+ const char *callerid,
enum ext_match_t action);
struct ast_exten *localized_find_extension(struct ast_context *bypass,
struct pbx_find_info *q,
- const char *context,
- const char *exten,
+ const char *context,
+ const char *exten,
int priority,
- const char *label,
- const char *callerid,
+ const char *label,
+ const char *callerid,
enum ext_match_t action)
{
return pbx_find_extension(NULL, bypass, q, context, exten, priority, label, callerid, action);
@@ -5328,7 +5328,7 @@ static void pbx_retrieve_variable(struct ast_channel *c, const char *var, char *
int offset, length;
int i, need_substring;
struct varshead *places[2] = { headp, &globals }; /* list of places where we may look */
-
+
/*
* Make a copy of var because parse_variable_name() modifies the string.
* Then if called directly, we might need to run substring() on the result;
@@ -5336,7 +5336,7 @@ static void pbx_retrieve_variable(struct ast_channel *c, const char *var, char *
*/
tmpvar = ast_strdupa(var); /* parse_variable_name modifies the string */
need_substring = parse_variable_name(tmpvar, &offset, &length, &i /* ignored */);
-
+
/*
* Look first into predefined variables, then into variable lists.
* Variable 's' points to the result, according to the following rules:
@@ -5357,7 +5357,7 @@ static void pbx_retrieve_variable(struct ast_channel *c, const char *var, char *
if (!strcmp(var, "EPOCH")) {
snprintf(workspace, workspacelen, "%u",(int)time(NULL));
}
-
+
s = workspace;
}
/* if not found, look into chanvars or global vars */
@@ -5600,11 +5600,11 @@ static int pbx_load_config(const char *config_file)
autofallthrough_config = ast_true(aft);
clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", "clearglobalvars"));
- if ((cxt = ast_variable_retrieve(cfg, "general", "userscontext")))
+ if ((cxt = ast_variable_retrieve(cfg, "general", "userscontext")))
ast_copy_string(userscontext, cxt, sizeof(userscontext));
else
ast_copy_string(userscontext, "default", sizeof(userscontext));
-
+
for (v = ast_variable_browse(cfg, "globals"); v; v = v->next) {
memset(realvalue, 0, sizeof(realvalue));
pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
@@ -5905,7 +5905,7 @@ int localized_pbx_load_module(void)
printf("Context: %s\n", con->name);
}
printf("=========\n");
-
+
return 0;
}
diff --git a/utils/frame.c b/utils/frame.c
index 62dc5f9f0..6752f4a7d 100644
--- a/utils/frame.c
+++ b/utils/frame.c
@@ -7,8 +7,8 @@
* Name: frame.c
* Version: see static char *standardversion, below.
* Author: Mark Roberts <mark@manumark.de>
- * Michael Labuschke <michael@labuschke.de> sys_errlist fixes
- *
+ * Michael Labuschke <michael@labuschke.de> sys_errlist fixes
+ *
****************************************************************************/
/****************************************************************************
* These are useful functions that all DSP programs might find handy
@@ -850,7 +850,7 @@ void parseargs( int argcount, char *args[], int fileswitch)
}
/*-------------------------------------------------*
- * Set samplefrequency, width, wavout,
+ * Set samplefrequency, width, wavout,
*-------------------------------------------------*/
parseintarg( argcount, args, "f", &samplefrequency);
wavout = parseswitcharg( argcount, args, "h");
diff --git a/utils/frame.h b/utils/frame.h
index a07c605ec..4bbc2199b 100644
--- a/utils/frame.h
+++ b/utils/frame.h
@@ -102,7 +102,7 @@ extern int getremainingfilelength( FILE *anyin, long *result);
void readpkheader( FILE *anyin);
/* -----------------------------------------------------------------------
- Read a .WAV header from 'anyin'.
+ Read a .WAV header from 'anyin'.
If it is recognised, the data is used.
Otherwise, we assume it's PCM-data and ignore the header.
The global variable 'iswav' is set on success, otherwise cleared.
diff --git a/utils/muted.c b/utils/muted.c
index a78312e28..ee1de7f54 100644
--- a/utils/muted.c
+++ b/utils/muted.c
@@ -5,7 +5,7 @@
*
* Mark Spencer <markster@digium.com>
*
- * Updated for Mac OSX CoreAudio
+ * Updated for Mac OSX CoreAudio
* by Josh Roberson <josh@asteriasgi.com>
*
* See http://www.asterisk.org for more information about
@@ -25,7 +25,7 @@
*
* \author Mark Spencer <markster@digium.com>
*
- * Updated for Mac OSX CoreAudio
+ * Updated for Mac OSX CoreAudio
* \arg Josh Roberson <josh@asteriasgi.com>
*
* \note Specially written for Malcolm Davenport, but I think I'll use it too
@@ -51,7 +51,7 @@
#include "asterisk/autoconfig.h"
#ifdef __Darwin__
-#include <CoreAudio/AudioHardware.h>
+#include <CoreAudio/AudioHardware.h>
#include <sys/types.h>
#include <pwd.h>
#include <sys/stat.h>
@@ -117,7 +117,7 @@ static void add_channel(char *tech, char *location)
chan->next = channels;
channels = chan;
}
-
+
}
static int load_config(void)
@@ -176,7 +176,7 @@ static int load_config(void)
} else if (!strcasecmp(buf, "mutelevel")) {
if (val && (sscanf(val, "%3d", &x) == 1) && (x > -1) && (x < 101)) {
mutelevel = x;
- } else
+ } else
fprintf(stderr, "mutelevel must be a number from 0 (most muted) to 100 (no mute) at line %d\n", lineno);
} else if (!strcasecmp(buf, "channel")) {
if (val && strlen(val)) {
@@ -199,7 +199,7 @@ static int load_config(void)
fprintf(stderr, "no 'host' specification in config file\n");
else if (!strlen(user))
fprintf(stderr, "no 'user' specification in config file\n");
- else if (!channels)
+ else if (!channels)
fprintf(stderr, "no 'channel' specifications in config file\n");
else
return 0;
@@ -286,7 +286,7 @@ static int login_asterisk(void)
fprintf(stderr, "disconnected (1)\n");
return -1;
}
- fprintf(astf,
+ fprintf(astf,
"Action: Login\r\n"
"Username: %s\r\n"
"Secret: %s\r\n\r\n", user, pass);
@@ -304,7 +304,7 @@ static int login_asterisk(void)
fprintf(stderr, "disconnected (3)\n");
return -1;
}
- fprintf(astf,
+ fprintf(astf,
"Action: Status\r\n\r\n");
if (!(welcome = get_line())) {
fprintf(stderr, "disconnected (4)\n");
@@ -404,7 +404,7 @@ static int setvol(float vol)
{
#ifndef __Darwin__
if (ioctl(mixfd, MIXER_WRITE(mixchan), &vol)) {
-#else
+#else
float volumeL = vol;
float volumeR = vol;
OSStatus err;
@@ -462,7 +462,7 @@ static float mutedlevel(float orig, float level)
master = level * master / 100.0;
return master;
#endif
-
+
}
static void mute(void)
@@ -479,7 +479,7 @@ static void mute(void)
vol = getvol();
oldvol = vol;
if (smoothfade)
-#ifdef __Darwin__
+#ifdef __Darwin__
start = mutelevel;
#else
start = 100;
@@ -587,7 +587,7 @@ static void append_sub(struct channel *chan, char *name)
struct subchannel *sub;
sub = chan->subs;
while(sub) {
- if (!strcasecmp(sub->name, name))
+ if (!strcasecmp(sub->name, name))
return;
sub = sub->next;
}
@@ -650,7 +650,7 @@ static int wait_event(void)
strncpy(oldname, resp + strlen("Oldname: "), sizeof(oldname) - 1);
}
if (strlen(channel)) {
- if (!strcasecmp(event, "Hangup"))
+ if (!strcasecmp(event, "Hangup"))
hangup_chan(channel);
else
offhook_chan(channel);
@@ -711,7 +711,7 @@ int main(int argc, char *argv[])
exit(1);
}
if (login_asterisk()) {
-#ifndef __Darwin__
+#ifndef __Darwin__
close(mixfd);
#endif
fclose(astf);
diff --git a/utils/smsq.c b/utils/smsq.c
index 21ab80d04..051609797 100644
--- a/utils/smsq.c
+++ b/utils/smsq.c
@@ -41,7 +41,7 @@
/*!
* \brief reads next USC character from null terminated UTF-8 string and advanced pointer
* for non valid UTF-8 sequences.
- * \return character as is Does \b NOT advance pointer for null termination
+ * \return character as is Does \b NOT advance pointer for null termination
*/
static int utf8decode (unsigned char **pp)
{
@@ -92,12 +92,12 @@ static int utf8decode (unsigned char **pp)
return *p; /* not sensible */
}
-/*!
+/*!
* \brief check for any queued messages in specific queue (queue="" means any queue)
* \param dir,queue,subaddress,channel,callerid,wait,delay,retries,concurrent
* \retval 0 if nothing queued
* \retval 1 if queued and outgoing set up OK
- * \retval 2 of outgoing exists
+ * \retval 2 of outgoing exists
*/
static char txqcheck (char *dir, char *queue, char subaddress, char *channel, char *callerid, int wait, int delay, int retries, int concurrent)
{
@@ -193,7 +193,7 @@ static char txqcheck (char *dir, char *queue, char subaddress, char *channel, ch
return 2;
}
-/*!
+/*!
* \brief Process received queue entries
* Run through a process, setting environment variables
*/
diff --git a/utils/streamplayer.c b/utils/streamplayer.c
index 6c70b0840..809bd64b8 100644
--- a/utils/streamplayer.c
+++ b/utils/streamplayer.c
@@ -19,7 +19,7 @@
/*!
* \file
* \author Russell Bryant <russell@digium.com>
- *
+ *
* \brief A utility for reading from a raw TCP stream
*
* This application is intended for use when a raw TCP stream is desired to be
@@ -84,33 +84,33 @@ int main(int argc, char *argv[])
}
memset(&sin, 0, sizeof(sin));
-
+
sin.sin_family = AF_INET;
sin.sin_port = htons(atoi(argv[2]));
memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
-
+
s = socket(AF_INET, SOCK_STREAM, 0);
-
+
if (s < 0) {
fprintf(stderr, "Unable to allocate socket!\n");
exit(1);
- }
+ }
res = connect(s, (struct sockaddr *)&sin, sizeof(sin));
-
+
if (res) {
fprintf(stderr, "Unable to connect to host!\n");
close(s);
- exit(1);
+ exit(1);
}
while (1) {
res = read(s, buf, sizeof(buf));
if (res < 1)
- break;
-
- memset(&tv, 0, sizeof(tv));
+ break;
+
+ memset(&tv, 0, sizeof(tv));
FD_ZERO(&wfds);
FD_SET(1, &wfds);