[b2f9d3]: gen_playlist.c Maximize Restore History

Download this file

gen_playlist.c    101 lines (76 with data), 2.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
/*
***************************************************************************
*
* Author: Georg Ottinger
*
* Copyright (C) 2012 Georg Ottinger
*
* georg@otelo.or.at
*
***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
***************************************************************************
*
* This version of GPL is at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
*
***************************************************************************
*/
#include <stdio.h>
#include <string.h>
#define PLAYLIST "/mnt/flash/www/playlist.m3u"
#define INDEXFILE "/mnt/flash/www/index"
int main()
{
char line[100];
char *ip,*end;
FILE *fp;
fgets(line, 100, stdin);
ip = strchr(line, ':');
if(!ip)
{
fprintf(stderr,"No IPv4-Address found!\n");
return -1;
}
ip++;
end=strchr(ip,' ');
if(end)
{
*end = 0;
} else {
fprintf(stderr,"Space not found!\n");
return -1;
}
printf("IP Addr: %s\n",ip);
fp = fopen(PLAYLIST,"w");
if(!fp)
{
fprintf(stderr, "Couldn't open "PLAYLIST"!\n");
return -1;
}
fprintf(fp,"#EXTINF:-1,(01:00) OggStreamer - Live\n");
fprintf(fp,"http://%s:3000/stream.ogg\n",ip);
fclose(fp);
system("cp "INDEXFILE".header "INDEXFILE".html");
fp = fopen(INDEXFILE".html","a");
if(!fp)
{
fprintf(stderr, "Couldn't open "INDEXFILE".html!\n");
return -1;
}
fprintf(fp, "%s",ip);
fclose(fp);
system("cat "INDEXFILE".footer >>"INDEXFILE".html");
}