* Code cleanup.

This commit is contained in:
Justin Maggard 2009-01-31 00:25:03 +00:00
parent 68ba24f255
commit 7e30949498
17 changed files with 54 additions and 114 deletions

View File

@ -76,29 +76,29 @@ depend: config.h
# DO NOT DELETE
minidlna.o: config.h upnpglobalvars.h miniupnpdtypes.h
minidlna.o: upnphttp.h upnpdescgen.h miniupnpdpath.h getifaddr.h upnpsoap.h
minidlna.o: config.h upnpglobalvars.h minidlnatypes.h
minidlna.o: upnphttp.h upnpdescgen.h minidlnapath.h getifaddr.h upnpsoap.h
minidlna.o: options.h minissdp.h daemonize.h upnpevents.h
minidlna.o: commonrdr.h
upnphttp.o: config.h upnphttp.h upnpdescgen.h miniupnpdpath.h upnpsoap.h
upnphttp.o: config.h upnphttp.h upnpdescgen.h minidlnapath.h upnpsoap.h
upnphttp.o: upnpevents.h
upnpdescgen.o: config.h upnpdescgen.h miniupnpdpath.h upnpglobalvars.h
upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h
upnpsoap.o: config.h upnpglobalvars.h miniupnpdtypes.h
upnpdescgen.o: config.h upnpdescgen.h minidlnapath.h upnpglobalvars.h
upnpdescgen.o: minidlnatypes.h upnpdescstrings.h
upnpsoap.o: config.h upnpglobalvars.h minidlnatypes.h
upnpsoap.o: upnphttp.h upnpsoap.h upnpreplyparse.h getifaddr.h
upnpreplyparse.o: upnpreplyparse.h minixml.h
minixml.o: minixml.h
getifaddr.o: getifaddr.h
daemonize.o: daemonize.h config.h
upnpglobalvars.o: config.h upnpglobalvars.h
upnpglobalvars.o: miniupnpdtypes.h
upnpglobalvars.o: minidlnatypes.h
options.o: options.h config.h upnpglobalvars.h
options.o: miniupnpdtypes.h
minissdp.o: config.h upnpdescstrings.h miniupnpdpath.h upnphttp.h
minissdp.o: upnpglobalvars.h miniupnpdtypes.h minissdp.h
upnpevents.o: config.h upnpevents.h miniupnpdpath.h upnpglobalvars.h
upnpevents.o: miniupnpdtypes.h upnpdescgen.h
options.o: minidlnatypes.h
minissdp.o: config.h upnpdescstrings.h minidlnapath.h upnphttp.h
minissdp.o: upnpglobalvars.h minidlnatypes.h minissdp.h
upnpevents.o: config.h upnpevents.h minidlnapath.h upnpglobalvars.h
upnpevents.o: minidlnatypes.h upnpdescgen.h
netfilter/iptcrdr.o: netfilter/iptcrdr.h commonrdr.h config.h
testupnpdescgen.o: config.h upnpdescgen.h
upnpdescgen.o: config.h upnpdescgen.h miniupnpdpath.h upnpglobalvars.h
upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h
upnpdescgen.o: config.h upnpdescgen.h minidlnapath.h upnpglobalvars.h
upnpdescgen.o: minidlnatypes.h upnpdescstrings.h

View File

@ -133,20 +133,11 @@ echo "/* The cache duration is indicated in seconds */" >> ${CONFIGFILE}
echo "#define GETIFSTATS_CACHING_DURATION 2" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}
echo "/* Uncomment the following line to enable multiple external ip support */" >> ${CONFIGFILE}
echo "/* note : Thas is EXPERIMENTAL, do not use that unless you know perfectly what you are doing */" >> ${CONFIGFILE}
echo "/*#define MULTIPLE_EXTERNAL_IP*/" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}
echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE}
echo " * of BSD daemon() */" >> ${CONFIGFILE}
echo "#define USE_DAEMON" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}
echo "/* Uncomment the following line to enable lease file support */" >> ${CONFIGFILE}
echo "/*#define ENABLE_LEASEFILE*/" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}
echo "/* Experimental UPnP Events support. */" >> ${CONFIGFILE}
echo "#define ENABLE_EVENTS" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}

View File

@ -39,12 +39,12 @@
#include "upnpglobalvars.h"
#include "upnphttp.h"
#include "upnpdescgen.h"
#include "miniupnpdpath.h"
#include "minidlnapath.h"
#include "getifaddr.h"
#include "upnpsoap.h"
#include "options.h"
#include "minissdp.h"
#include "miniupnpdtypes.h"
#include "minidlnatypes.h"
#include "daemonize.h"
#include "upnpevents.h"
#include "scanner.h"
@ -148,9 +148,6 @@ struct runtime_vars {
/*struct lan_addr_s lan_addr[MAX_LAN_ADDR];*/
int port; /* HTTP Port */
int notify_interval; /* seconds between SSDP announces */
/* unused rules cleaning related variables : */
int clean_ruleset_threshold; /* threshold for removing unused rules */
int clean_ruleset_interval; /* (minimum) interval between checks */
};
/* parselanaddr()
@ -188,23 +185,6 @@ parselanaddr(struct lan_addr_s * lan_addr, const char * str)
return -1;
}
lan_addr->mask.s_addr = htonl(nbits ? (0xffffffff << (32 - nbits)) : 0);
#ifdef MULTIPLE_EXTERNAL_IP
while(*p && isspace(*p))
p++;
if(*p) {
n = 0;
while(p[n] && !isspace(*p))
n++;
if(n<=15) {
memcpy(lan_addr->ext_ip_str, p, n);
lan_addr->ext_ip_str[n] = '\0';
if(!inet_aton(lan_addr->ext_ip_str, &lan_addr->ext_ip_addr)) {
/* error */
fprintf(stderr, "Error parsing address : %s\n", lan_addr->ext_ip_str);
}
}
}
#endif
return 0;
}
@ -293,8 +273,6 @@ init(int argc, char * * argv, struct runtime_vars * v)
n_lan_addr++;
v->port = -1;
v->notify_interval = 30; /* seconds between SSDP announces */
v->clean_ruleset_threshold = 20;
v->clean_ruleset_interval = 0; /* interval between ruleset check. 0=disabled */
/* read options file first since
* command line arguments have final say */
@ -349,22 +327,10 @@ init(int argc, char * * argv, struct runtime_vars * v)
strncpy(modelnumber, ary_options[i].value, MODELNUMBER_MAX_LEN);
modelnumber[MODELNUMBER_MAX_LEN-1] = '\0';
break;
case UPNPCLEANTHRESHOLD:
v->clean_ruleset_threshold = atoi(ary_options[i].value);
break;
case UPNPCLEANINTERVAL:
v->clean_ruleset_interval = atoi(ary_options[i].value);
break;
case UPNPSECUREMODE:
if(strcmp(ary_options[i].value, "yes") == 0)
SETFLAG(SECUREMODEMASK);
break;
#ifdef ENABLE_LEASEFILE
case UPNPLEASEFILE:
lease_file = ary_options[i].value;
remove(lease_file);
break;
#endif
case UPNPFRIENDLYNAME:
strncpy(friendly_name, ary_options[i].value, FRIENDLYNAME_MAX_LEN);
friendly_name[FRIENDLYNAME_MAX_LEN-1] = '\0';

View File

@ -9,9 +9,6 @@ media_dir=/opt
# set this if you want to customize the name that shows up on your clients
#friendly_name=My DLNA Server
# lease file location
#lease_file=/var/log/upnp.leases
# "secure" mode : UPnP client are allowed to add mappings only
# to their IP
secure_mode=no
@ -25,8 +22,6 @@ system_uptime=no
# notify interval in seconds. default is 30 seconds.
notify_interval=900
clean_ruleset_interval=600
# serial and model number the daemon will report to clients
# in its XML description
serial=12345678

View File

@ -9,9 +9,9 @@
#include "config.h"
/* Paths and other URLs in the miniupnpd http server */
/* Paths and other URLs in the minidlna http server */
#define ROOTDESC_PATH "/rootDesc.xml"
#define ROOTDESC_PATH "/rootDesc.xml"
#define CONTENTDIRECTORY_PATH "/ContentDir.xml"
#define CONTENTDIRECTORY_CONTROLURL "/ctl/ContentDir"

View File

@ -14,10 +14,6 @@
struct lan_addr_s {
char str[16]; /* example: 192.168.0.1 */
struct in_addr addr, mask; /* ip/mask */
#ifdef MULTIPLE_EXTERNAL_IP
char ext_ip_str[16];
struct in_addr ext_ip_addr;
#endif
};
#endif

View File

@ -14,7 +14,7 @@
#include <syslog.h>
#include "config.h"
#include "upnpdescstrings.h"
#include "miniupnpdpath.h"
#include "minidlnapath.h"
#include "upnphttp.h"
#include "upnpglobalvars.h"
#include "minissdp.h"

View File

@ -6,7 +6,7 @@
#ifndef __MINISSDP_H__
#define __MINISSDP_H__
/*#include "miniupnpdtypes.h"*/
/*#include "minidlnatypes.h"*/
int
OpenAndConfSSDPReceiveSocket();

View File

@ -32,12 +32,7 @@ static const struct {
{ UPNPUUID, "uuid"},
{ UPNPSERIAL, "serial"},
{ UPNPMODEL_NUMBER, "model_number"},
{ UPNPCLEANTHRESHOLD, "clean_ruleset_threshold"},
{ UPNPCLEANINTERVAL, "clean_ruleset_interval"},
{ UPNPENABLE, "enable_upnp"},
#ifdef ENABLE_LEASEFILE
{ UPNPLEASEFILE, "lease_file"},
#endif
{ UPNPFRIENDLYNAME, "friendly_name"},
{ UPNPMEDIADIR, "media_dir"},
{ UPNPSECUREMODE, "secure_mode"}

View File

@ -24,13 +24,8 @@ enum upnpconfigoptions {
UPNPUUID, /* uuid */
UPNPSERIAL, /* serial */
UPNPMODEL_NUMBER, /* model_number */
UPNPCLEANTHRESHOLD, /* clean_ruleset_threshold */
UPNPCLEANINTERVAL, /* clean_ruleset_interval */
UPNPENABLENATPMP, /* enable_natpmp */
UPNPSECUREMODE, /* secure_mode */
#ifdef ENABLE_LEASEFILE
UPNPLEASEFILE, /* lease_file */
#endif
UPNPFRIENDLYNAME, /* how the system should show up to DLNA clients */
UPNPMEDIADIR, /* directory to search for UPnP-A/V content */
UPNPENABLE /* enable_upnp */

View File

@ -525,6 +525,36 @@ sql_failed:
return (ret != SQLITE_OK);
}
int
filter_audio(const struct dirent *d)
{
return ( (*d->d_name != '.') &&
((d->d_type == DT_DIR) ||
((d->d_type == DT_REG) &&
is_audio(d->d_name) )
) );
}
int
filter_video(const struct dirent *d)
{
return ( (*d->d_name != '.') &&
((d->d_type == DT_DIR) ||
((d->d_type == DT_REG) &&
is_video(d->d_name) )
) );
}
int
filter_images(const struct dirent *d)
{
return ( (*d->d_name != '.') &&
((d->d_type == DT_DIR) ||
((d->d_type == DT_REG) &&
is_image(d->d_name) )
) );
}
int
filter_media(const struct dirent *d)
{

View File

@ -18,8 +18,6 @@ char serialnumber[] = "12345678";
char modelnumber[] = "1";
char presentationurl[] = "http://192.168.0.1:8080/";
char * use_ext_ip_addr = NULL;
int getifaddr(const char * ifname, char * buf, int len)
{
strncpy(buf, "1.2.3.4", len);

View File

@ -16,7 +16,7 @@
#include "getifaddr.h"
#endif
#include "upnpdescgen.h"
#include "miniupnpdpath.h"
#include "minidlnapath.h"
#include "upnpglobalvars.h"
#include "upnpdescstrings.h"

View File

@ -20,7 +20,7 @@
#include <errno.h>
#include "config.h"
#include "upnpevents.h"
#include "miniupnpdpath.h"
#include "minidlnapath.h"
#include "upnpglobalvars.h"
#include "upnpdescgen.h"

View File

@ -11,15 +11,6 @@
#include "config.h"
#include "upnpglobalvars.h"
/* file to store leases */
#ifdef ENABLE_LEASEFILE
const char* lease_file = 0;
#endif
/* forced ip address to use for this interface
* when NULL, getifaddr() is used */
const char * use_ext_ip_addr = 0;
/* LAN address */
/*const char * listen_addr = 0;*/
@ -48,10 +39,6 @@ char modelnumber[MODELNUMBER_MAX_LEN] = "1";
* http://nnn.nnn.nnn.nnn:ppppp/ => max 30 bytes including terminating 0 */
char presentationurl[PRESENTATIONURL_MAX_LEN];
/* UPnP permission rules : */
struct upnpperm * upnppermlist = 0;
unsigned int num_upnpperm = 0;
int n_lan_addr = 0;
struct lan_addr_s lan_addr[MAX_LAN_ADDR];

View File

@ -8,7 +8,7 @@
#define __UPNPGLOBALVARS_H__
#include <time.h>
#include "miniupnpdtypes.h"
#include "minidlnatypes.h"
#include "config.h"
#include <sqlite3.h>
@ -44,15 +44,6 @@
"http-get:*:video/dvd:*," \
"http-get:*:video/x-ms-wmv:*"
/* file to store all leases */
#ifdef ENABLE_LEASEFILE
extern const char * lease_file;
#endif
/* forced ip address to use for this interface
* when NULL, getifaddr() is used */
extern const char * use_ext_ip_addr;
/* statup time */
extern time_t startup_time;
@ -80,10 +71,6 @@ extern char modelnumber[];
#define PRESENTATIONURL_MAX_LEN (64)
extern char presentationurl[];
/* UPnP permission rules : */
extern struct upnpperm * upnppermlist;
extern unsigned int num_upnpperm;
/* lan addresses */
/* MAX_LAN_ADDR : maximum number of interfaces
* to listen to SSDP traffic */

View File

@ -22,7 +22,7 @@
#include "config.h"
#include "upnphttp.h"
#include "upnpdescgen.h"
#include "miniupnpdpath.h"
#include "minidlnapath.h"
#include "upnpsoap.h"
#include "upnpevents.h"