mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-14 08:39:31 +02:00
2016-08-06 Fred Gleason <fredg@paravelsystems.com>
* Refactored 'rlm/rlm_walltime.c' to use http PUTs.
This commit is contained in:
parent
7d9fcfb8e5
commit
6d236f0605
@ -15460,3 +15460,5 @@
|
||||
2016-08-05 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Updated 'NEWS'.
|
||||
* Incremented the package version to 2.15.1.
|
||||
2016-08-06 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Refactored 'rlm/rlm_walltime.c' to use http PUTs.
|
||||
|
@ -19,10 +19,10 @@
|
||||
; The IP address of the Walltime clock, in dotted-quad notation.
|
||||
IpAddress=192.168.21.100
|
||||
|
||||
; UDP Port
|
||||
; Password
|
||||
;
|
||||
; The UDP port number of the remote UDP port, in the range 0 - 65,535.
|
||||
UdpPort=6060
|
||||
; The password to use when sending HTML updates.
|
||||
Password=crackme
|
||||
|
||||
; Format String. The template for the HTML sent to the Walltime web display
|
||||
; each time RDAirPlay changes play state, including any wildcards as
|
||||
@ -31,7 +31,7 @@ UdpPort=6060
|
||||
; The list of available wildcards can be found in the 'metadata_wildcards.txt'
|
||||
; file in the Rivendell documentation directory.
|
||||
;
|
||||
FormatString=<body bgcolor="#000000"><table cellspacing="2" cellpadding="2" border="0"><tr><td> </td></tr><tr><td> </td></tr><tr><td><font size="6" color="white">%t</font>></td></tr><tr><td> </td></tr><tr><td><font size="5" color="red">%a</font><td></tr></table></body>
|
||||
FormatString=<body bgcolor="#000000"><table cellspacing="2" cellpadding="2" border="0"><tr><td> </td></tr><tr><td> </td></tr><tr><td><font size="6" color="white">%t</font></td></tr><tr><td> </td></tr><tr><td><font size="5" color="red">%a</font><td></tr></table></body>
|
||||
|
||||
; Host Address.
|
||||
;
|
||||
|
@ -28,11 +28,13 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <rlm/rlm.h>
|
||||
|
||||
int rlm_walltime_devs;
|
||||
char *rlm_walltime_addresses;
|
||||
uint16_t *rlm_walltime_ports;
|
||||
char *rlm_walltime_passwords;
|
||||
char *rlm_walltime_formats;
|
||||
char *rlm_walltime_host_addresses;
|
||||
int *rlm_walltime_masters;
|
||||
@ -77,7 +79,7 @@ void rlm_walltime_RLMStart(void *ptr,const char *arg)
|
||||
|
||||
rlm_walltime_devs=0;
|
||||
rlm_walltime_addresses=NULL;
|
||||
rlm_walltime_ports=NULL;
|
||||
rlm_walltime_passwords=NULL;
|
||||
rlm_walltime_formats=NULL;
|
||||
rlm_walltime_host_addresses=NULL;
|
||||
rlm_walltime_masters=NULL;
|
||||
@ -94,9 +96,9 @@ void rlm_walltime_RLMStart(void *ptr,const char *arg)
|
||||
rlm_walltime_addresses=
|
||||
realloc(rlm_walltime_addresses,(rlm_walltime_devs+1)*(rlm_walltime_devs+1)*16);
|
||||
strcpy(rlm_walltime_addresses+16*rlm_walltime_devs,address);
|
||||
rlm_walltime_ports=realloc(rlm_walltime_ports,(rlm_walltime_devs+1)*sizeof(uint16_t));
|
||||
rlm_walltime_ports[rlm_walltime_devs]=
|
||||
RLMGetIntegerValue(ptr,arg,section,"UdpPort",0);
|
||||
rlm_walltime_passwords=realloc(rlm_walltime_passwords,(rlm_walltime_devs+1)*1024);
|
||||
strncpy(rlm_walltime_passwords+1024*rlm_walltime_devs,
|
||||
RLMGetStringValue(ptr,arg,section,"Password",""),1023);
|
||||
rlm_walltime_formats=realloc(rlm_walltime_formats,(rlm_walltime_devs+1)*8192);
|
||||
strncpy(rlm_walltime_formats+8192*rlm_walltime_devs,
|
||||
RLMGetStringValue(ptr,arg,section,"FormatString",""),8192);
|
||||
@ -117,8 +119,7 @@ void rlm_walltime_RLMStart(void *ptr,const char *arg)
|
||||
(rlm_walltime_devs+1)*sizeof(int));
|
||||
rlm_walltime_aux2s[rlm_walltime_devs]=
|
||||
rlm_walltime_GetLogStatus(ptr,arg,section,"Aux2Log");
|
||||
sprintf(errtext,"rlm_walltime: configured destination \"%s:%d\"",address,
|
||||
rlm_walltime_ports[rlm_walltime_devs]);
|
||||
sprintf(errtext,"rlm_walltime: configured destination \"%s\"",address);
|
||||
rlm_walltime_devs++;
|
||||
RLMLog(ptr,LOG_INFO,errtext);
|
||||
sprintf(section,"Walltime%d",i++);
|
||||
@ -130,7 +131,7 @@ void rlm_walltime_RLMStart(void *ptr,const char *arg)
|
||||
void rlm_walltime_RLMFree(void *ptr)
|
||||
{
|
||||
free(rlm_walltime_addresses);
|
||||
free(rlm_walltime_ports);
|
||||
free(rlm_walltime_passwords);
|
||||
free(rlm_walltime_formats);
|
||||
free(rlm_walltime_host_addresses);
|
||||
free(rlm_walltime_masters);
|
||||
@ -146,8 +147,11 @@ void rlm_walltime_RLMPadDataSent(void *ptr,const struct rlm_svc *svc,
|
||||
{
|
||||
int i;
|
||||
int flag=0;
|
||||
char timer[1500];
|
||||
FILE *f;
|
||||
char tempfile[256];
|
||||
int fd=-1;
|
||||
char url[1024];
|
||||
char password[1024];
|
||||
|
||||
for(i=0;i<rlm_walltime_devs;i++) {
|
||||
switch(log->log_mach) {
|
||||
@ -164,26 +168,32 @@ void rlm_walltime_RLMPadDataSent(void *ptr,const struct rlm_svc *svc,
|
||||
break;
|
||||
}
|
||||
if((flag==1)||((flag==2)&&(log->log_onair!=0))) {
|
||||
f=fopen("/var/www/html/walltime/walltime.html","w");
|
||||
if(now->rlm_len==0) {
|
||||
snprintf(timer,1500,
|
||||
"SP!RS!WU http://%s/walltime/walltime.html!",
|
||||
strncpy(tempfile,"/tmp/walltimeXXXXXX",256);
|
||||
if((fd=mkstemp(tempfile))>0) {
|
||||
f=fdopen(fd,"w");
|
||||
if(now->rlm_len==0) {
|
||||
fprintf(f,"<body bgcolor=\"#000000\"> </body>");
|
||||
}
|
||||
else {
|
||||
fprintf(f,"%s\n",
|
||||
RLMResolveNowNextEncoded(ptr,now,next,rlm_walltime_formats+8192*i,
|
||||
RLM_ENCODE_XML));
|
||||
}
|
||||
fclose(f);
|
||||
snprintf(url,1024,"http://%s/webwidget",
|
||||
rlm_walltime_host_addresses+16*i);
|
||||
fprintf(f,"<body bgcolor=\"#000000\"> </body>");
|
||||
snprintf(password,1024,"user:%s",rlm_walltime_passwords+1024*i);
|
||||
if(fork()==0) {
|
||||
execlp("curl","curl","-u",password,"-o","/dev/null","-s","-T",
|
||||
tempfile,url,(char *)NULL);
|
||||
RLMLog(ptr,LOG_WARNING,"rlm_icecast2: unable to execute curl(1)");
|
||||
exit(0);
|
||||
}
|
||||
RLMLog(ptr,LOG_INFO,"rlm_walltime: sending pad update!");
|
||||
}
|
||||
else {
|
||||
snprintf(timer,1500,
|
||||
"SM D!PS %d!ST!WU http://%s/walltime/walltime.html!",
|
||||
now->rlm_len/1000,
|
||||
rlm_walltime_host_addresses+16*i);
|
||||
fprintf(f,"%s\n",
|
||||
RLMResolveNowNextEncoded(ptr,now,next,rlm_walltime_formats+8192*i,
|
||||
RLM_ENCODE_XML));
|
||||
}
|
||||
fclose(f);
|
||||
RLMSendUdp(ptr,rlm_walltime_addresses+i*16,rlm_walltime_ports[i],
|
||||
timer,strlen(timer));
|
||||
RLMLog(ptr,LOG_INFO,"rlm_walltime: sending pad update!");
|
||||
}
|
||||
else {
|
||||
RLMLog(ptr,LOG_WARNING,"rlm_walltime: unable to create temp file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user