Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/azatoth/minidlna.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Maggard <jmaggard@users.sourceforce.net>2012-02-28 11:36:14 +0400
committerJustin Maggard <jmaggard@users.sourceforce.net>2012-02-28 11:36:14 +0400
commitce504948ca1e0c9d6309a39ce01717ba5f5a60a1 (patch)
tree84f831f47977deb8dd6baeaf040556ef8c69be12
parent3e90c59e258cb3e221a34c4b6942d89158c7f138 (diff)
* Improve handling of the media_dir setting.
-rw-r--r--minidlna.c77
-rw-r--r--options.c3
-rw-r--r--utils.h2
3 files changed, 42 insertions, 40 deletions
diff --git a/minidlna.c b/minidlna.c
index 57b0613..958e315 100644
--- a/minidlna.c
+++ b/minidlna.c
@@ -447,52 +447,51 @@ init(int argc, char * * argv)
break;
case UPNPMEDIADIR:
type = ALL_MEDIA;
- char * myval = NULL;
- switch( ary_options[i].value[0] )
+ path = ary_options[i].value;
+ if( *path && (path[1] == ',') && (access(path, F_OK) != 0) )
{
- case 'A':
- case 'a':
- if( ary_options[i].value[0] == 'A' || ary_options[i].value[0] == 'a' )
+ switch( *path )
+ {
+ case 'A':
+ case 'a':
type = AUDIO_ONLY;
- case 'V':
- case 'v':
- if( ary_options[i].value[0] == 'V' || ary_options[i].value[0] == 'v' )
+ break;
+ case 'V':
+ case 'v':
type = VIDEO_ONLY;
- case 'P':
- case 'p':
- if( ary_options[i].value[0] == 'P' || ary_options[i].value[0] == 'p' )
+ break;
+ case 'P':
+ case 'p':
type = IMAGES_ONLY;
- myval = index(ary_options[i].value, '/');
- case '/':
- path = realpath(myval ? myval:ary_options[i].value, buf);
- if( !path )
- path = (myval ? myval:ary_options[i].value);
- if( access(path, F_OK) != 0 )
- {
- DPRINTF(E_ERROR, L_GENERAL, "Media directory \"%s\" not accessible! [%s]\n",
- path, strerror(errno));
+ break;
+ default:
+ DPRINTF(E_FATAL, L_GENERAL, "Media directory entry not understood [%s]\n",
+ ary_options[i].value);
break;
}
- struct media_dir_s * this_dir = calloc(1, sizeof(struct media_dir_s));
- this_dir->path = strdup(path);
- this_dir->type = type;
- if( !media_dirs )
- {
- media_dirs = this_dir;
- }
- else
- {
- struct media_dir_s * all_dirs = media_dirs;
- while( all_dirs->next )
- all_dirs = all_dirs->next;
- all_dirs->next = this_dir;
- }
- break;
- default:
- DPRINTF(E_ERROR, L_GENERAL, "Media directory entry not understood! [%s]\n",
- ary_options[i].value);
+ path += 2;
+ }
+ path = realpath(path, buf);
+ if( !path || access(path, F_OK) != 0 )
+ {
+ DPRINTF(E_ERROR, L_GENERAL, "Media directory \"%s\" not accessible [%s]\n",
+ ary_options[i].value, strerror(errno));
break;
}
+ struct media_dir_s * this_dir = calloc(1, sizeof(struct media_dir_s));
+ this_dir->path = strdup(path);
+ this_dir->type = type;
+ if( !media_dirs )
+ {
+ media_dirs = this_dir;
+ }
+ else
+ {
+ struct media_dir_s * all_dirs = media_dirs;
+ while( all_dirs->next )
+ all_dirs = all_dirs->next;
+ all_dirs->next = this_dir;
+ }
break;
case UPNPALBUMART_NAMES:
for( string = ary_options[i].value; (word = strtok(string, "/")); string = NULL )
@@ -1037,7 +1036,7 @@ main(int argc, char * * argv)
}
else
{
- /* the comparaison is not very precise but who cares ? */
+ /* the comparison is not very precise but who cares ? */
if(timeofday.tv_sec >= (lastnotifytime.tv_sec + runtime_vars.notify_interval))
{
SendSSDPNotifies2(snotify,
diff --git a/options.c b/options.c
index 74b8254..fa28f0b 100644
--- a/options.c
+++ b/options.c
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <ctype.h>
#include "options.h"
+#include "utils.h"
#include "upnpglobalvars.h"
struct option * ary_options = NULL;
@@ -169,7 +170,7 @@ readoptionsfile(const char * fname)
ary_options = (struct option *)t;
ary_options[num_options-1].id = id;
- strncpy(ary_options[num_options-1].value, value, MAX_OPTION_VALUE_LEN);
+ strncpyt(ary_options[num_options-1].value, value, MAX_OPTION_VALUE_LEN);
}
}
diff --git a/utils.h b/utils.h
index fbd0a91..48954bc 100644
--- a/utils.h
+++ b/utils.h
@@ -24,6 +24,8 @@
#ifndef __UTILS_H__
#define __UTILS_H__
+#include "minidlnatypes.h"
+
int
strcatf(struct string_s *str, char *fmt, ...);