Commit 8c8a0edc authored by Clément Stenac's avatar Clément Stenac

* > It apparenly doesn't like comments on the same line as parameters

  Now, it does, provided they begin with a '#'

* Little code cleanup
parent beac3bc9
# sap.cfg - Configuration file of the mini SAP server
[global]
# TTL (Time To Live) of the SAP announces
ttl=15
ttl=15 # TTL (Time To Live) of the SAP announces
# Then you should have one "[program]" section per program announced
[program]
# Name of the program (as will show up in the VLC playlist)
name=TV1
# Name of the streaming entity
user=videolan
# Name of the streaming machine
machine=vlcs.via.ecp.fr
# Site of the streaming entity
site=www.videolan.org
# Multicast IP address of the program
address=239.255.12.12
name=TV1 # Name of the program (as will show up in the VLC playlist)
user=videolan # Name of the streaming entity
machine=vlcs.via.ecp.fr # Name of the streaming machine
site=www.videolan.org # Site of the streaming entity
address=239.255.12.12 # Multicast IP address of the program
[program]
name=TV2
......
......@@ -40,7 +40,7 @@
#define DEFAULT_CONF "/etc/sap.cfg"
unsigned int ttl=10;
unsigned int ttl=10; // Default TTL
struct prog
{
......@@ -94,7 +94,18 @@ void itemlist::add(prog *itemp)
nbr++;
}
void strgeta(char *source,char *dest,char delim)
void strgetb(char *source,char *dest,char delim) // Get what is before delim in source and puts it into dest
{
unsigned long i = 0;
while(source[i] != delim && i < strlen(source))
{
dest[i]=source[i];
i++;
}
dest[i]=0;
}
void strgeta(char *source,char *dest,char delim) // Get what is after delim in source and puts it into dest
{
unsigned long i=0,j=0;
dest[0]=0;
......@@ -144,6 +155,8 @@ int parse(char *path,itemlist *progs)
break;
}
strgetb(ligne,ligne,'#');
if(strstr(ligne,"ttl=")) {strgeta(ligne,tligne,'=');ttl=atoi(tligne);}
if(strstr(ligne,"[program]"))
{
......@@ -194,13 +207,13 @@ int parse(char *path,itemlist *progs)
return(0);
}
// Main function
/*************************************************
* The main function
*************************************************/
int main(int argc, char *argv[])
{
struct sockaddr_in addr;
int fd;
// int cnt;
// struct ip_mreq mreq;
int result;
char getopt_string[128];
char conffile[256];
......@@ -221,7 +234,8 @@ int main(int argc, char *argv[])
}
// Get the programs
printf("Parsing configuration file\n");
if(parse(conffile,progs)) return(-1);
if(parse(conffile,progs))
return(-1);
printf("%ld programs loaded\n",progs->count());
printf("Packet TTL set to %i\n",ttl);
prog *pp;
......@@ -243,7 +257,10 @@ int main(int argc, char *argv[])
// Start sending
printf("Socket ready, sending started\n");
if(godaemon) {printf("Forking\n");daemon(0,0);}
if(godaemon)
{
printf("Forking\n");daemon(0,0);
}
while(1)
{
pp=progs->getfirst();
......@@ -277,6 +294,6 @@ int main(int argc, char *argv[])
}
pp=pp->Next;
}
sleep(1);
sleep(1); // Wait 1 second between each sending
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment