6 * FAPG means Fast Audio Playlist Generator.
7 * It is a tool to generate list of audio files (Wav, MP3, Ogg, etc)
8 * in various formats (M3U, PLS, HTML, etc).
9 * It is very usefull if you have a large amount of audio files
10 * and you want to quickly and frequently build a playlist.
12 * Copyright (C) 2003-2004 Antoine Jacquet <royale@zerezo.com>
13 * http://royale.zerezo.com/fapg/
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include <sys/types.h>
46 #define OGG_BASE 1024*10
47 #define MAX 1024*200 /* 200ko for ID3 with JPEG images in it */
50 int format=0; /* 0 = m3u ; 1 = pls ; 2 = html ; 3 = rss */
52 unsigned char *prefix="";
53 unsigned char *base="";
54 unsigned char *dir="";
55 unsigned char *hostname="fritzserver.de";
56 unsigned char *referal="http://www.explaining.text.org/select.php?title=";
62 unsigned char *eol="\n";
63 unsigned char buffer[MAX];
67 unsigned char artist[1024];
68 unsigned char title[1024];
69 unsigned char genrebuf[1024];
70 unsigned char genre=0;
73 unsigned char unix2dos[256]={0,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,70,35,36,37,38,39,40,41,82,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,84,59,36,61,65,71,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,36,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,36,125,126,127,199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,131,225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187,166,166,166,166,166,193,194,192,169,166,166,43,43,162,165,43,43,45,45,43,45,43,227,195,43,43,45,45,166,45,43,164,240,208,202,203,200,105,205,206,207,43,43,166,220,166,204,175,211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180,173,177,61,190,182,167,247,184,176,168,183,185,179,178,166,160};
77 fprintf(stderr,"Usage >> fapg [-b|--backslash] [-d|--debug] [-f|--format=m3u|pls|html|rss] [-g|--genre=#:#:...] [-n|--nohardlink] [-o|--output=/path/to/file.m3u] [-p|--prefix=/the/prefix] [-r|--recursive] [-w|--windows] [-x|--exclude=#:#:...] /path/to/mp3/dir1 [/path/to/mp3/dir2 ...]\n");
81 const char*reflink(const char*title)
85 buffer=malloc(strlen(title)+strlen(referal)+2);
86 strcpy(buffer,referal);
88 for(i=strlen(referal);i<strlen(buffer);i++)
92 case ' ': buffer[i]='+'; break;
99 void parse_options(int argc,char **argv)
101 static char const short_options[]="bdf:g:lo:np:rwx:";
102 static struct option long_options[]=
104 {"backslash",no_argument,NULL,'b'},
105 {"debug",no_argument,NULL,'d'},
106 {"format",required_argument,NULL,'f'},
107 {"genre",required_argument,NULL,'g'},
108 {"nohardlink",no_argument,NULL,'n'},
109 {"output",required_argument,NULL,'o'},
110 {"prefix",required_argument,NULL,'p'},
111 {"recursive",no_argument,NULL,'r'},
112 {"windows",no_argument,NULL,'w'},
113 {"exclude",required_argument,NULL,'x'}
117 while ((c=getopt_long(argc,argv,short_options,long_options,&option_index))!=-1)
128 if (strcmp(optarg,"m3u")==0) format=0; else
129 if (strcmp(optarg,"pls")==0) format=1; else
130 if (strcmp(optarg,"html")==0) format=2; else
131 if (strcmp(optarg,"rss")==0) format=3; else
135 if (genrelist==NULL) genrelist=calloc(257,sizeof(char)); /* allow multiple includes/excludes */
136 if (genrelist==NULL) { fprintf(stderr,"Error >> unable to allocate cleared memory\n"); exit(2); }
140 while (n<strlen(optarg))
142 if (debug) fprintf(stderr,"Debug >> genrelist entry activting : %d\n",atoi(&optarg[n]));
143 genrelist[atoi(&optarg[n])]=1;
144 while (isdigit(optarg[n++]));
153 if (fopen(optarg,"w")==NULL) { fprintf(stderr,"Error >> unable to open output file : %s\n",optarg); exit(2); }
156 prefix=malloc(strlen(optarg)+1);
157 strcpy(prefix,optarg);
158 base=malloc(strlen(prefix)+1);
160 dir=strchr(base,'/');
161 if( (dir!=NULL) && (dir[1]=='/') ) dir=strchr(dir+2,'/');
162 if (dir!=NULL) *dir++=0; else dir="";
163 /* if prefix is a weblink, base is the baselink, dir is the path */
173 if (genrelist==NULL) /* allow multiple includes/excludes - not recommended (confusing) but possible */
176 genrelist=calloc(257,sizeof(char));
177 while (n<256) genrelist[n++]=1;
179 if (genrelist==NULL) { fprintf(stderr,"Error >> unable to allocate cleared memory\n"); exit(2); }
183 while (n<strlen(optarg))
185 if (debug) fprintf(stderr,"Debug >> genrelist entry activting : %d\n",atoi(&optarg[n]));
186 genrelist[atoi(&optarg[n])]=0;
187 while (isdigit(optarg[n++]));
195 /* hostname = getenv("HOSTNAME"); */
198 genrelist=calloc(257,sizeof(char));
199 if (genrelist==NULL) { fprintf(stderr,"Error >> unable to allocate cleared memory\n"); exit(2); }
203 while (n<256) genrelist[n++]=1;
208 void parse_mp3(unsigned char *file)
210 int bitrates[2][3][15]=
211 {{{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448},
212 {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384},
213 {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}},
214 {{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
215 {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
216 {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}}};
223 if (debug) fprintf(stderr,"Debug >> parsing mp3 : %s\n",file);
226 if ((fic=fopen(file,"r"))==NULL) { fprintf(stderr,"Warning >> can't open file : %s\n",file); return; }
227 lus=fread(buffer,1,MP3_BASE,fic);
231 if (buffer[0]=='I' && buffer[1]=='D' && buffer[2]=='3')
236 if (version<2 || version>4)
237 fprintf(stderr,"Warning >> ID3 v2.%d not implemented ! trying anyway : %s\n",version,file);
239 fprintf(stderr,"Warning >> specials headers not implemented (%d) ! trying anyway : %s\n",*(buffer+5),file);
241 size=(*c<<21)+(*(c+1)<<14)+(*(c+2)<<7)+(*(c+3));
242 /* read more header */
245 lus+=fread(buffer+lus,1,MAX-lus,fic);
246 fprintf(stderr,"Warning >> ID3 header is huge (%d bytes) ! trying anyway : %s\n",size,file);
249 lus+=fread(buffer+lus,1,size,fic);
250 if (size>lus) size=lus;
252 if (version==2) while (c<buffer+size)
254 int size=(*(c+3)<<16)+(*(c+4)<<8)+(*(c+5));
256 if (strncmp(c,"TT2",3)==0)
258 strncpy(title,c+7,size-1);
261 if (strncmp(c,"TP1",3)==0)
263 strncpy(artist,c+7,size-1);
266 if (strncmp(c,"TCO",3)==0)
268 /* strncpy(genrebuf,c+7,size-1);*/
269 /* genrebuf[size-1]='\0'; */
270 /* genre=atoi(&genrebuf[1]); */
275 if (version==3 || version==4) while (c<buffer+size)
277 int size=(*(c+4)<<24)+(*(c+5)<<16)+(*(c+6)<<8)+(*(c+7));
279 if (strncmp(c,"TIT2",4)==0)
281 strncpy(title,c+11,size-1);
284 if (strncmp(c,"TPE1",4)==0)
286 strncpy(artist,c+11,size-1);
289 if (strncmp(c,"TCON",4)==0)
291 /* strncpy(genrebuf,c+11,size-1); */
292 /* genrebuf[size-1]='\0'; */
293 /* genre=atoi(&genrebuf[1]); */
300 while (c<buffer+lus-10)
302 if (*c==0xFF && (*(c+1)&0xF0)==0xF0)
308 version=2-(*(c+1)>>3&1);
310 bitrate_index=*(c+2)>>4&0xF;
311 if (version>=1 && version<=2 && lay-1>=0 && lay-1<=2 && bitrate_index>=0 && bitrate_index<=14)
312 bitrate=bitrates[version-1][lay-1][bitrate_index];
317 fseek(fic,0,SEEK_END);
318 duration=(ftell(fic)+buffer-c)/125/bitrate;
328 if (strlen(artist)==0 && strlen(title)==0)
330 fseek(fic,-128,SEEK_END);
331 lus=fread(buffer,1,128,fic);
332 if (lus==128 && buffer[0]=='T' && buffer[1]=='A' && buffer[2]=='G')
334 strncpy(title,buffer+3,30);
337 while (c>title && *c==' ') *(c--)='\0';
338 strncpy(artist,buffer+33,30);
341 while (c>artist && *c==' ') *(c--)='\0';
342 /* strncpy(album,buffer+65,30); */
343 /* strncpy(year,buffer+97,4); */
344 /* strncpy(comment,buffer+101,30); */
345 /* strncpy(genrebuf,buffer+127,1); genre[1]=0; */
353 void parse_ogg(unsigned char *file)
361 if (debug) fprintf(stderr,"Debug >> parsing ogg : %s\n",file);
364 if ((fic=fopen(file,"r"))==NULL) { fprintf(stderr,"Warning >> can't open file : %s\n",file); return; }
365 lus=fread(buffer,1,OGG_BASE,fic);
368 if (buffer[0]!='O' && buffer[1]!='g' && buffer[2]!='g')
370 fprintf(stderr,"Warning >> not a Ogg header : %s\n",file);
375 sample_rate=(*c)+(*(c+1)<<8)+(*(c+2)<<16)+(*(c+3)<<24);
377 while (c<buffer+lus-10)
380 if (strncasecmp(c,"TITLE=",6)==0)
382 size=*(c-4)+(*(c-3)<<8)+(*(c-2)<<16)+(*(c-1)<<24);
383 strncpy(title,c+6,size-6);
387 if (strncasecmp(c,"ARTIST=",7)==0)
389 size=*(c-4)+(*(c-3)<<8)+(*(c-2)<<16)+(*(c-1)<<24);
390 strncpy(artist,c+7,size-7);
394 if (strncasecmp(c,"GENRE=",6)==0)
397 size=*(c-4)+(*(c-3)<<8)+(*(c-2)<<16)+(*(c-1)<<24);
398 strncpy(genrebuf,c+6,size-6);
399 genrebuf[size-6]='\0';
401 for(i=0;i<ID3_NR_OF_V1_GENRES;i++)
403 if (strcasecmp(ID3_v1_genre_description[i],genrebuf)==0)
408 if (i==ID3_NR_OF_V1_GENRES) genre=0;
414 fseek(fic,-OGG_BASE,SEEK_END);
415 lus=fread(buffer,1,OGG_BASE,fic);
417 while (strncmp(c,"OggS",4)!=0 && c>buffer) c--;
421 samples=(*c)+(*(c+1)<<8)+(*(c+2)<<16)+(*(c+3)<<24);
422 duration=samples/sample_rate;
428 void parse_mpc(unsigned char *file)
433 int sample_rates[4]={44100,48000,37800,32000};
438 if (debug) fprintf(stderr,"Debug >> parsing mpc : %s\n",file);
441 if ((fic=fopen(file,"r"))==NULL) { fprintf(stderr,"Warning >> can't open file : %s\n",file); return; }
442 lus=fread(buffer,1,12,fic);
445 if (buffer[0]!='M' && buffer[1]!='P' && buffer[2]!='+')
447 fprintf(stderr,"Warning >> not a Musepack header : %s\n",file);
454 fprintf(stderr,"Warning >> only Musepack SV7 supported : %s\n",file);
460 frame_count=(*c)+(*(c+1)<<8)+(*(c+2)<<16)+(*(c+3)<<24);
462 duration=frame_count*1152/sample_rates[*c&3];
464 /* try APETAGEX footer */
465 fseek(fic,-32,SEEK_END);
466 lus=fread(buffer,1,32,fic);
467 if (lus==32 && strncmp(buffer,"APETAGEX",8)==0)
470 size=(*c)+(*(c+1)<<8)+(*(c+2)<<16)+(*(c+3)<<24);
473 items=(*c)+(*(c+1)<<8)+(*(c+2)<<16)+(*(c+3)<<24);
474 fseek(fic,-size,SEEK_END);
475 lus=fread(buffer,1,size,fic);
476 if (lus==size && strncmp(buffer,"APETAGEX",8)==0)
481 size=(*c)+(*(c+1)<<8)+(*(c+2)<<16)+(*(c+3)<<24);
483 if (strcasecmp(c,"TITLE")==0)
485 strncpy(title,c+6,size);
488 if (strcasecmp(c,"ARTIST")==0)
490 strncpy(artist,c+7,size);
493 if (strcasecmp(c,"GENRE")==0)
495 for(i=0;i<ID3_NR_OF_V1_GENRES;i++)
497 strncpy(genrebuf,c+6,size);
499 if (strcasecmp(ID3_v1_genre_description[i],genrebuf)==0)
504 if (i==ID3_NR_OF_V1_GENRES) genre=0;
516 #define MAXINO (1<<24)
517 #define INOTYP unsigned long
518 #define regbit_qry(x,y) ( x[( (y) / sizeof(INOTYP) )] & 1<<( (y) % sizeof(INOTYP) ) )
519 #define regbit_set(x,y) ( x[( (y) / sizeof(INOTYP) )] |= 1<<( (y) % sizeof(INOTYP) ) )
521 int hlink_check(struct stat*info)
524 * for speed this subroutine should only be called
525 * - if the file has more than one hardlink
526 * - if the file is a resolved softlink
528 /* the persistent variables */
529 static INOTYP *list[FSN];
530 static dev_t name[FSN];
531 /* some temporary variables */
532 int fsn, is_registered=0;
534 /* assertions - in case parameters are lowered for less memory usage */
536 assert((info->st_ino)/sizeof(INOTYP)<MAXINO);
538 /* search which internal registration number is used for this filesystem */
539 for( fsn=0; (name[fsn]!=(info->st_dev)) && (name[fsn]!=0) ; fsn++);
541 /* if file system is not registered yet, do it and leave */
544 name[fsn] = (info->st_dev);
545 /* provide space for the bitmap that maps the inodes of this file system */
546 list[fsn] = (INOTYP*)calloc(MAXINO,sizeof(INOTYP));
547 /* no comparison is needed in empty lists ... return */
548 if(debug) fprintf(stderr, "Debug >> Linked >> Init List %04x @mem %04lx\n", (int)name[fsn], (long)&list[fsn] );
551 /* this looks more complicated than it really is */
552 /* the idea is very simple:
553 * provide a bitmap that maps all inodes of a file system
554 * to mark all files that have already been visited.
555 * If it is already visited, do not add it to the playlist
558 * The difficulty is as follows:
559 * struct inode_bitmap { char registered:1; } bitmap[1<<MAXINO];
560 * would be byte-aligned and would allocate at least eight times the needed space.
561 * Feel free to change the definitions that are involved here, if you know better.
563 if( regbit_qry( list[fsn], (info->st_ino) ) ) is_registered=1;
564 else regbit_set( list[fsn], (info->st_ino) );
566 * the debug expression is more complicated then the working stuff
569 fprintf(stderr, "Debug >> Linked >> DEV %04x INO %06x => "
570 "list[%02x][%04x] = %04x & %04x --> %s registered\n",
571 (int)info->st_dev, (int)info->st_ino, fsn, (int)((info->st_ino)/sizeof(INOTYP)),
572 (int)list[fsn][(info->st_ino)/sizeof(INOTYP)],
573 1<<((info->st_ino)%sizeof(INOTYP)), is_registered?"Already":"Not" );
575 return is_registered;
579 void parse_file(unsigned char *newpath)
582 unsigned char ext[5];
585 void print_faketitle()
587 c=newpath+strlen(newpath);
588 while (c>newpath && *c!='/') c--;
589 while (c<newpath+strlen(newpath)-5)
592 if (*c=='_') putchar(' '); else if (windows) putchar(unix2dos[*c]); else putchar(*c);
601 /* remove leading "./" when parsing current directory */
602 if (*c=='.' && *(c+1)=='/') { c+=2; last='/'; }
605 /* remove double "//" when parsing a directory ending with a "/" */
606 if (last=='/' && *c=='/') continue;
608 if (*c=='/') putchar(separator); else if (windows) putchar(unix2dos[*c]); else putchar(*c);
612 for (j=0;j<5;j++) ext[j]=tolower(newpath[strlen(newpath)-4+j]);
616 if (strcmp(".mp2",ext)==0) { duration=-1; parse_mp3(newpath); }
617 if (strcmp(".mp3",ext)==0) { duration=-1; parse_mp3(newpath); }
618 if (strcmp(".mpc",ext)==0) { duration=-1; parse_mpc(newpath); }
619 if (strcmp(".mp+",ext)==0) { duration=-1; parse_mpc(newpath); }
620 if (strcmp(".ogg",ext)==0) { duration=-1; parse_ogg(newpath); }
621 if (strcmp(".wav",ext)==0) { duration=-1; /* parse_wav(newpath); */ }
623 if (duration!=-2 && genrelist[genre]) /* is it an audio file ? */
631 printf("#EXTINF:%d,",duration);
632 if (strlen(artist)==0 && strlen(title)==0) print_faketitle();
633 else printf("%s - %s",artist,title);
640 printf("File%d=",counter);
643 printf("Title%d=",counter);
644 if (strlen(artist)==0 && strlen(title)==0) print_faketitle();
645 else printf("%s - %s",artist,title);
647 if (duration!=-1) printf("Length%d=%d%s",counter,duration,eol);
650 printf("<tr><td>%d</td><td>%s</td><td>%s</td><td>",counter,artist,title);
651 if (duration==-1) printf("?"); else printf("%d:%s%d",duration/60,duration%60<10?"0":"",duration%60);
652 printf("</td></tr>%s",eol);
658 char timebuffer[256];
659 strftime(timebuffer,255, "%a %d %b %Y %T %Z", localtime(&zeit) ); /* ctime() had a trailing CR */
660 printf("\t<item>%s",eol);
661 if (strlen(artist)==0 && strlen(title)==0)
663 /* find a better solution for this */
664 printf("\t\t<author>%s</author>%s\t\t<title>%s</title>%s",newpath,eol, newpath,eol );
666 else printf("\t\t<author>%s</author>%s\t\t<title>%s</title>%s",artist,eol, title,eol );
667 /* you might want to add more into description --> look for a smart, not a fast program */
668 printf("\t\t<description><![CDATA[<h4>%s</h4><h5>%s</h5><a href=\"",title,artist);
670 printf("\">Direct Link to Audiofile</a><br>]]></description>%s",eol);
672 printf("\t\t<link>%s</link>%s",reflink(title),eol);
674 printf("\t\t<pubDate>%s</pubDate>%s",timebuffer,eol);
675 printf("\t\t<enclosure url=\"");
677 printf("\" length=\"%d\" type=\"audio/mpeg\"/>%s\t\t<guid>",duration, eol);
679 printf("</guid>%s",eol );
680 printf("\t\t<itunes:duration>%d:%d:%d</itunes:duration>%s",duration/3600,(duration/60)%60,duration%60,eol);
681 printf("\t\t<itunes:author>%s</itunes:author>%s", artist, eol);
682 printf("\t</item>%s",eol );
689 void parse_directory(unsigned char *path)
692 struct dirent **namelist;
693 unsigned char newpath[PATH_MAX];
697 fprintf(stderr,"Debug >> parsing directory : %s\n",path);
698 if (stat(path,&infos)!=0)
700 fprintf(stderr,"Warning >> can't stat entry : %s\n",path);
703 /* check if it is a filename */
704 if (S_ISREG(infos.st_mode) || S_ISLNK(infos.st_mode))
709 /* must be a directory - or something unusable like pipe, socket, etc */
710 if ((n=scandir(path,&namelist,0,alphasort))<0)
712 fprintf(stderr,"Warning >> can't open directory : %s\n",path);
717 sprintf(newpath,"%s/%s",path,namelist[i]->d_name);
719 if (stat(newpath,&infos)!=0)
721 fprintf(stderr,"Warning >> can't stat entry : %s\n",newpath);
724 if (recursive && S_ISDIR(infos.st_mode)
725 && strcmp(namelist[i]->d_name,".")!=0
726 && strcmp(namelist[i]->d_name,"..")!=0) parse_directory(newpath);
727 /* hlink_check() might be applied more selective ... avoidhlink is only a simple prereq */
728 if (S_ISREG(infos.st_mode) && ! ( avoidhlinked && hlink_check(&infos) ) )
737 int main(int argc,char **argv)
739 parse_options(argc,argv);
740 if (optind==argc) usage();
744 printf("#EXTM3U%s",eol);
747 printf("[playlist]%s",eol);
750 printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">%s%s<html>%s%s<head>%s<title>Playlist generated by FAPG " VERSION "</title>%s<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />%s<style type=\"text/css\">%s<!--%s%sbody,td,tr {%s font-family: Verdana, Arial, Helvetica, sans-serif;%s font-size: 12px;%s color: #000000;%s}%s%sbody {%s background: #ffffff;%s}%s%sth {%s text-align: center;%s background: #ffcccc;%s padding-left: 15px;%s padding-right: 15px;%s border: 1px #dd8888 solid;%s}%s%std {%s text-align: center;%s background: #eeeeee;%s padding-left: 15px;%s padding-right: 15px;%s border: 1px #cccccc solid;%s}%s%sh1 {%s font-size: 25px;%s}%s%sp {%s font-size: 10px;%s}%s%sa {%s color: #993333;%s text-decoration: none;%s}%s%sa:hover {%s text-decoration: underline;%s}%s%s-->%s</style>%s</head>%s%s<body>%s%s<h1>Playlist</h1>%s%s<table>%s<tr><th>Entry</th><th>Artist</th><th>Title</th><th>Length</th></tr>%s",eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol,eol);
755 char timebuffer[256];
756 strftime(timebuffer,255, "%a %d %b %Y %T %Z", localtime(&zeit) );
757 printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>%s<!-- generator=\"FAPG " VERSION " -->%s<rss xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" version=\"2.0\">%s <channel>%s\t<title>%s - %s</title>%s\t<description>Directory Tree %s</description>%s\t<link>%s</link>%s\t<itunes:image href=\"%s/rss/podcast.jpg\"/>%s\t<lastBuildDate>%s</lastBuildDate>%s\t<generator>FAPG " VERSION "</generator>%s\t<image>%s\t\t<url>%s/podcast.jpg</url>%s\t\t<title>Server Logo</title>%s\t\t<link>%s</link>%s\t\t<description>Feed provided by FAPG. Click to visit.</description>%s\t</image>%s\t<itunes:owner>%s\t\t<itunes:name>Admin %s</itunes:name>%s\t\t<itunes:email>podcast@%s</itunes:email>%s\t</itunes:owner>%s\t<category>Various</category>%s\t<itunes:subtitle>Directory Tree %s</itunes:subtitle>%s\t<itunes:author>%s</itunes:author>%s\t<copyright>unknown</copyright>%s\t<language>%s</language>%s\t<itunes:explicit>No</itunes:explicit>%s\t<ttl>1800</ttl>%s",eol,eol,eol,eol,hostname,dir,eol,prefix,eol,base,eol,prefix,eol,timebuffer,eol,eol,eol,base,eol,eol,base,eol,eol,eol,eol,base,eol,hostname,eol,eol,eol,dir,eol,getenv("LOGNAME"),eol,eol,getenv("LANG"),eol,eol,eol);
761 for (;optind<argc;optind++)
764 /* activating skip means that all given path components are stripped */
765 /* in consequence a list of subdirs is always mapped to the same prefix */
766 /* a recommended workaround is to move to the desired subdir and avoid absolute directories in the list */
767 if (strlen(prefix)!=0) skip=strlen(argv[optind]);
769 parse_directory(argv[optind]);
774 printf("NumberOfEntries=%d%sVersion=2%s",counter,eol,eol);
777 printf("</table>%s%s<p>Playlist generated by <a href=\"http://royale.zerezo.com/fapg/\">FAPG " VERSION "</a></p>%s%s</body>%s%s</html>",eol,eol,eol,eol,eol,eol);
780 printf(" </channel>%s</rss>%s",eol,eol);
783 if (genrelist) free(genrelist);