1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-04 05:22:40 +00:00

(trunk libT) #1595: Always search in PACKAGE_DATA_DIR when serving Web files

This commit is contained in:
Charles Kerr 2008-12-14 01:19:50 +00:00
parent 02521f4bf8
commit d52631cb67

View file

@ -10,6 +10,8 @@
* $Id$ * $Id$
*/ */
#include <event.h>
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
#include <shlobj.h> /* for CSIDL_APPDATA, CSIDL_MYDOCUMENTS */ #include <shlobj.h> /* for CSIDL_APPDATA, CSIDL_MYDOCUMENTS */
@ -552,19 +554,26 @@ tr_getClutchDir( const tr_session * session UNUSED )
} }
/* XDG_DATA_DIRS are the backup directories */ /* XDG_DATA_DIRS are the backup directories */
tmp = getenv( "XDG_DATA_DIRS" ); {
if( !tmp || !*tmp ) struct evbuffer * buf = evbuffer_new( );
tmp = PACKAGE_DATA_DIR ":/usr/local/share/:/usr/share/"; evbuffer_add_printf( buf, "%s:", PACKAGE_DATA_DIR );
if(( tmp = getenv( "XDG_DATA_DIRS" )))
evbuffer_add_printf( buf, "%s:", tmp );
evbuffer_add_printf( buf, "%s:", "/usr/local/share" );
evbuffer_add_printf( buf, "%s:", "/usr/share" );
tmp = (const char*) EVBUFFER_DATA( buf );
while( tmp && *tmp ) { while( tmp && *tmp ) {
const char * end = strchr( tmp, ':' ); const char * end = strchr( tmp, ':' );
if( end ) { if( end ) {
tr_list_append( &candidates, tr_strndup( tmp, end - tmp ) ); tr_list_append( &candidates, tr_strndup( tmp, end - tmp ) );
tmp = end + 1; tmp = end + 1;
} else { } else if( tmp && *tmp ) {
tr_list_append( &candidates, tr_strdup( tmp ) ); tr_list_append( &candidates, tr_strdup( tmp ) );
break; break;
} }
} }
evbuffer_free( buf );
}
/* walk through the candidates & look for a match */ /* walk through the candidates & look for a match */
for( l=candidates; l; l=l->next ) { for( l=candidates; l; l=l->next ) {