mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 11:58:40 +00:00
support relative paths in musiconhold.conf, which makes moh work by default when Asterisk was configured using --prefix and 'make samples' is run
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@149917 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -33,6 +33,8 @@ Miscellaneous
|
|||||||
as previously used on the last "exten" line. For example:
|
as previously used on the last "exten" line. For example:
|
||||||
exten => 123,1,NoOp(something)
|
exten => 123,1,NoOp(something)
|
||||||
same => n,SomethingElse()
|
same => n,SomethingElse()
|
||||||
|
* musiconhold.conf classes of type 'files' can now use relative directory paths,
|
||||||
|
which are interpreted as relative to the astvarlibdir setting in asterisk.conf.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
--- Functionality changes from Asterisk 1.6.0 to Asterisk 1.6.1 -------------
|
--- Functionality changes from Asterisk 1.6.0 to Asterisk 1.6.1 -------------
|
||||||
|
|||||||
@@ -29,6 +29,11 @@
|
|||||||
; Files can be present in as many formats as you wish, and the
|
; Files can be present in as many formats as you wish, and the
|
||||||
; 'best' format will be chosen at playback time.
|
; 'best' format will be chosen at playback time.
|
||||||
;
|
;
|
||||||
|
; The path specified can be either an absolute path (starts with '/'),
|
||||||
|
; or a relative path; relative paths are interpreted as being relative
|
||||||
|
; to the 'astvarlibdir' in asterisk.conf, which defaults to
|
||||||
|
; /var/lib/asterisk.
|
||||||
|
;
|
||||||
; NOTE:
|
; NOTE:
|
||||||
; If you are not using "autoload" in modules.conf, then you
|
; If you are not using "autoload" in modules.conf, then you
|
||||||
; must ensure that the format modules for any formats you wish
|
; must ensure that the format modules for any formats you wish
|
||||||
@@ -39,11 +44,11 @@
|
|||||||
|
|
||||||
[default]
|
[default]
|
||||||
mode=files
|
mode=files
|
||||||
directory=/var/lib/asterisk/moh
|
directory=moh
|
||||||
;
|
;
|
||||||
;[native-random]
|
;[native-random]
|
||||||
;mode=files
|
;mode=files
|
||||||
;directory=/var/lib/asterisk/moh
|
;directory=moh
|
||||||
;digit=# ; If this option is set for a class, then when callers are
|
;digit=# ; If this option is set for a class, then when callers are
|
||||||
; ; listening to music on hold, they can press this digit, and
|
; ; listening to music on hold, they can press this digit, and
|
||||||
; ; they will switch to listening to this music class.
|
; ; they will switch to listening to this music class.
|
||||||
@@ -51,7 +56,7 @@ directory=/var/lib/asterisk/moh
|
|||||||
|
|
||||||
;[native-alphabetical]
|
;[native-alphabetical]
|
||||||
;mode=files
|
;mode=files
|
||||||
;directory=/var/lib/asterisk/moh
|
;directory=moh
|
||||||
;sort=alpha ; Sort the files in alphabetical order. If this option is
|
;sort=alpha ; Sort the files in alphabetical order. If this option is
|
||||||
; ; not specified, the sort order is undefined.
|
; ; not specified, the sort order is undefined.
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/stringfields.h"
|
#include "asterisk/stringfields.h"
|
||||||
#include "asterisk/linkedlists.h"
|
#include "asterisk/linkedlists.h"
|
||||||
#include "asterisk/manager.h"
|
#include "asterisk/manager.h"
|
||||||
|
#include "asterisk/paths.h"
|
||||||
|
|
||||||
#define INITIAL_NUM_FILES 8
|
#define INITIAL_NUM_FILES 8
|
||||||
|
|
||||||
@@ -906,6 +907,7 @@ static int moh_scan_files(struct mohclass *class) {
|
|||||||
|
|
||||||
DIR *files_DIR;
|
DIR *files_DIR;
|
||||||
struct dirent *files_dirent;
|
struct dirent *files_dirent;
|
||||||
|
char dir_path[PATH_MAX];
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
char filepath[PATH_MAX];
|
char filepath[PATH_MAX];
|
||||||
char *ext;
|
char *ext;
|
||||||
@@ -913,9 +915,17 @@ static int moh_scan_files(struct mohclass *class) {
|
|||||||
int dirnamelen;
|
int dirnamelen;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
files_DIR = opendir(class->dir);
|
if (class->dir[0] != '/') {
|
||||||
|
ast_copy_string(dir_path, ast_config_AST_VAR_DIR, sizeof(dir_path));
|
||||||
|
strncat(dir_path, "/", sizeof(dir_path));
|
||||||
|
strncat(dir_path, class->dir, sizeof(dir_path));
|
||||||
|
} else {
|
||||||
|
ast_copy_string(dir_path, class->dir, sizeof(dir_path));
|
||||||
|
}
|
||||||
|
ast_debug(4, "Scanning '%s' for files for class '%s'\n", dir_path, class->name);
|
||||||
|
files_DIR = opendir(dir_path);
|
||||||
if (!files_DIR) {
|
if (!files_DIR) {
|
||||||
ast_log(LOG_WARNING, "Cannot open dir %s or dir does not exist\n", class->dir);
|
ast_log(LOG_WARNING, "Cannot open dir %s or dir does not exist\n", dir_path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,9 +933,9 @@ static int moh_scan_files(struct mohclass *class) {
|
|||||||
ast_free(class->filearray[i]);
|
ast_free(class->filearray[i]);
|
||||||
|
|
||||||
class->total_files = 0;
|
class->total_files = 0;
|
||||||
dirnamelen = strlen(class->dir) + 2;
|
dirnamelen = strlen(dir_path) + 2;
|
||||||
getcwd(path, sizeof(path));
|
getcwd(path, sizeof(path));
|
||||||
chdir(class->dir);
|
chdir(dir_path);
|
||||||
while ((files_dirent = readdir(files_DIR))) {
|
while ((files_dirent = readdir(files_DIR))) {
|
||||||
/* The file name must be at least long enough to have the file type extension */
|
/* The file name must be at least long enough to have the file type extension */
|
||||||
if ((strlen(files_dirent->d_name) < 4))
|
if ((strlen(files_dirent->d_name) < 4))
|
||||||
@@ -939,7 +949,7 @@ static int moh_scan_files(struct mohclass *class) {
|
|||||||
if (!strchr(files_dirent->d_name, '.'))
|
if (!strchr(files_dirent->d_name, '.'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snprintf(filepath, sizeof(filepath), "%s/%s", class->dir, files_dirent->d_name);
|
snprintf(filepath, sizeof(filepath), "%s/%s", dir_path, files_dirent->d_name);
|
||||||
|
|
||||||
if (stat(filepath, &statbuf))
|
if (stat(filepath, &statbuf))
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user