X-Git-Url: http://royale.zerezo.com/git/?p=FAPG;a=blobdiff_plain;f=fapg.c;fp=fapg.c;h=a72d4e7683d8ab5e2ec964f43af7a6fa3a9679f1;hp=ea50917948a613876062e88d00a24cf54698b563;hb=389b0b695d6dd0e98f3ad67a47d6f6e48ed1b62e;hpb=57a557c838aebd9b7fbd1344f6fcb86b7d5da7fd diff --git a/fapg.c b/fapg.c index ea50917..a72d4e7 100644 --- a/fapg.c +++ b/fapg.c @@ -38,7 +38,7 @@ #include #include "genres.h" -#define VERSION "0.37" +#define VERSION "0.38" #define MP3_BASE 1024 #define OGG_BASE 1024*10 #define MAX 1024*200 /* 200ko for ID3 with JPEG images in it */ @@ -218,7 +218,7 @@ unsigned char *iso2web[256] = { void usage() { fprintf(stderr, - "Usage >> fapg [-b|--backslash] [-d|--debug] [-f|--format=m3u|pls|html|rss|pla] [-g|--genre=#:#:...] [-n|--nohardlink] [-o|--output=/path/to/file.m3u] [-p|--prefix=/the/prefix] [-r|--recursive] [-w|--windows] [-c|--command=] [-x|--exclude=#:#:...] [-s|--stdin] /path/to/mp3/dir1 [/path/to/mp3/dir2 ...]\n"); + "Usage >> fapg [-b|--backslash] [-d|--debug] [-f|--format=m3u|pls|html|rss|pla|txx] [-g|--genre=#:#:...] [-n|--nohardlink] [-o|--output=/path/to/file.m3u] [-p|--prefix=/the/prefix] [-r|--recursive] [-w|--windows] [-c|--command=] [-x|--exclude=#:#:...] [-s|--stdin] /path/to/mp3/dir1 [/path/to/mp3/dir2 ...]\n"); exit(1); } @@ -267,6 +267,122 @@ void myputstr(const char *c) } } +void txxputheader(const char *c) +{ + int cnt = 0; + + while(*c != 0) { + myputchar(*c); + cnt++; + c++; + } + + while(cnt < 512) { + putchar('\0'); + cnt++; + } +} + +void txxputnameoffset(const char *c) +{ + int pos = 0; + int cnt = 0; + char b; + unsigned char *prefx; + + prefx = prefix; + + if(*prefx != 0) { + while(*prefx != 0) { + if(*prefx == '/') { + pos = cnt; + } + cnt++; + prefx++; + } + + cnt--; // skip the leading dot of the filepath + } + + while(*c != 0) { + if(*c == '/') { + pos = cnt; + } + cnt++; + c++; + } + + pos += 2; + + b = (pos & 0xFF00) >> 8; + putchar(b); + b = (pos & 0x00FF); + putchar(b); +} + +void txxputstr(const char *c) +{ + int cnt = 0; + int pos; + unsigned char *prefx; + + txxputnameoffset(c); + + prefx = prefix; + fprintf(stderr, "prefix: '%s'\n", prefx); + + if(*prefx != 0) { + while(*prefx != 0) { + myputchar('\0'); + cnt++; + + if(*prefx == '/') + putchar(separator); + else + myputchar(*prefx); + cnt++; + + prefx++; + } + + c++; // skip the leading dot + } + + while(*c != 0) { + myputchar('\0'); + cnt++; + + if(*c == '/') + putchar(separator); + else + myputchar(*c); + cnt++; + + c++; + } + + while(cnt < 510) { + myputchar('\0'); + cnt++; + } +} + +void txxputcounter(int c) +{ + int b; + + rewind(stdout); + + b = (c & 0xFF000000) >> 24; + putchar(b); + b = (c & 0x00FF0000) >> 16; + putchar(b); + b = (c & 0x0000FF00) >> 8; + putchar(b); + b = (c & 0x000000FF); + putchar(b); +} + /* remove spaces at beginning and end of string */ void trim(char *c) { @@ -423,6 +539,8 @@ void parse_options(int argc, char **argv) format = 3; else if(strcmp(optarg, "pla") == 0) format = 4; + else if(strcmp(optarg, "txx") == 0) + format = 5; else usage(); break; @@ -1076,6 +1194,9 @@ void parse_file(unsigned char *newpath) myplaputstr(newpath); myplaputstr(eol); break; + case 5: //t-series playlist + txxputstr(newpath); + break; } } } @@ -1177,6 +1298,11 @@ int main(int argc, char **argv) eol = "\r\n"; myplaputstr("PLP PLAYLIST\r\nVERSION 1.20\r\n\r\n"); } + break; + case 5: + { + txxputheader(" iriver UMS PLA"); + } } if(fromstdin) { unsigned char path[PATH_MAX]; @@ -1204,6 +1330,9 @@ int main(int argc, char **argv) case 3: printf(" %s%s", eol, eol); break; + case 5: + txxputcounter(counter); + break; } if(genrelist) free(genrelist);