| tvkaista-0.95/Makefile | | tvkaista-0.961/Makefile |
| 5 | | 5 | |
| 6 | all: tvkaista_gtkui | 6 | all: tvkaista_gtkui |
| 7 | | 7 | |
| 8 | tvkaista_gtkui: tvkaista_gtkui.c tvkaista-helper.pl | 8 | tvkaista_gtkui: tvkaista_gtkui.c |
| 9 | perl -c tvkaista-helper.pl | 9 | perl -c tvkaista-helper.pl |
| 10 | sh tvkaista_gtkui.c | 10 | sh tvkaista_gtkui.c |
| 11 | | 11 | |
| 15 | | 15 | |
| 16 | install: tvkaista_gtkui | 16 | install: tvkaista_gtkui |
| 17 | test -d "$$HOME"/.tvkaista || mkdir "$$HOME/".tvkaista | 17 | test -d "$$HOME"/.tvkaista || mkdir "$$HOME/".tvkaista |
| 18 | # cp tvkaista.sh "$$HOME"/.tvkaista | 18 | cp tvkaista.sh "$$HOME"/.tvkaista |
| 19 | cp tvkaista_gtkui "$$HOME"/.tvkaista | 19 | cp tvkaista_gtkui "$$HOME"/.tvkaista |
| 20 | # cp tvkaista-helper.pl "$$HOME"/.tvkaista | 20 | cp tvkaista-helper.pl "$$HOME"/.tvkaista |
| 21 | cp tvkaista.png "$$HOME"/.tvkaista | 21 | cp tvkaista.png "$$HOME"/.tvkaista |
| | 22 | cp tvkaista.menu "$$HOME"/.tvkaista |
| 22 | sed 's|$$dest|'"$$HOME/.tvkaista|" tvkaista.desktop \ | 23 | sed 's|$$dest|'"$$HOME/.tvkaista|" tvkaista.desktop \ |
| 23 | > "$$HOME"/.tvkaista/tvkaista.desktop | 24 | > "$$HOME"/.tvkaista/tvkaista.desktop |
| 24 | rm -f "$$HOME"/bin/tvkaista_gtk "$$HOME"/.tvkaista/tvkaista_gtk | 25 | rm -f "$$HOME"/bin/tvkaista_gtk "$$HOME"/bin/tvkaista_gtkui \ |
| | 26 | "$$HOME"/.tvkaista/tvkaista_gtk |
| 25 | test ! -d "$$HOME"/bin \ | 27 | test ! -d "$$HOME"/bin \ |
| 26 | || ln -sf ../.tvkaista/tvkaista_gtkui "$$HOME"/bin | 28 | || ln -sf ../.tvkaista/tvkaista.sh "$$HOME"/bin |
| 27 | test ! -d "$$HOME"/Desktop \ | 29 | test ! -d "$$HOME"/Desktop \ |
| 28 | || ln -sf ../.tvkaista/tvkaista.desktop "$$HOME"/Desktop | 30 | || ln -sf ../.tvkaista/tvkaista.desktop "$$HOME"/Desktop |
| 29 | test ! -d "$$HOME"/Työpöytä \ | 31 | test ! -d "$$HOME"/Työpöytä \ |
| 30 | || ln -sf ../.tvkaista/tvkaista.desktop "$$HOME"/Työpöytä | 32 | || ln -sf ../.tvkaista/tvkaista.desktop "$$HOME"/Työpöytä |
| | 33 | test -d "$$HOME"/.menu || mkdir "$$HOME"/.menu |
| | 34 | ln -sf ../.tvkaista/tvkaista.menu "$$HOME"/.menu/tvkaista |
| 31 | | 35 | |
| 32 | gitlog: $(VERSION_CONTROLLED) | 36 | gitlog: $(VERSION_CONTROLLED) |
| 33 | git log --name-status > $@ | 37 | git log --name-status > $@ |
| tvkaista-0.95/tvkaista-helper.pl | | tvkaista-0.961/tvkaista-helper.pl |
| 4 | # Author: Tomi Ollila -- too ät iki piste fi | 4 | # Author: Tomi Ollila -- too ät iki piste fi |
| 5 | # | 5 | # |
| 6 | # Created: Sat Feb 07 21:29:53 EET 2009 too | 6 | # Created: Sat Feb 07 21:29:53 EET 2009 too |
| 7 | # Last modified: Sun 26 Apr 2009 12:46:56 EEST too | 7 | # Last modified: Tue 28 Apr 2009 20:40:41 EEST too |
| 8 | | 8 | |
| 9 | #PERL_UNICODE=SD perl tvkaista-helper.pl 1 update | 9 | #PERL_UNICODE=SD perl tvkaista-helper.pl 1 update |
| | 10 | #or perl -CSD perl tvkaista-helper.pl 1 list |
| 10 | | 11 | |
| 11 | #noupdate: not yes | | |
| 12 | | 12 | |
| 13 | use strict; | 13 | use strict; |
| 14 | use warnings; | 14 | use warnings; |
| 34 | open STDOUT, ">>&$dfd" if ($dfd > 1); | 34 | open STDOUT, ">>&$dfd" if ($dfd > 1); |
| 35 | } | 35 | } |
| 36 | else { usage; } | 36 | else { usage; } |
| 37 | my $recdir = '../recordings'; | 37 | |
| | 38 | my $recdir = 'tallenteet'; |
| 38 | if (-e $recdir) | 39 | if (-e $recdir) |
| 39 | { | 40 | { |
| 40 | die "'$recdir': not a directory.\n" unless -d $recdir; | 41 | die "'$recdir': not a directory.\n" unless -d $recdir; |
| 41 | } | 42 | } |
| 42 | else { mkdir $recdir or die "Can not create '$recdir': $!\n"; } | 43 | else { mkdir $recdir or die "Can not create '$recdir': $!\n"; } |
| | 44 | |
| | 45 | mkdir 2, 0755; |
| 43 | | 46 | |
| 44 | my ($date, $time); | 47 | my ($date, $time); |
| 45 | sub getdatetime() | 48 | sub getdatetime() |
| 51 | } | 54 | } |
| 52 | getdatetime; | 55 | getdatetime; |
| 53 | | 56 | |
| 54 | unless (-d "logs.$date") { | 57 | unless (-d "2/logs.$date") { |
| 55 | mkdir "logs.$date"; | 58 | mkdir "2/logs.$date"; |
| 56 | unlink 'today'; | 59 | unlink '2/today'; |
| 57 | symlink "logs.$date", 'today'; | 60 | symlink "logs.$date", '2/today'; |
| 58 | } | 61 | } |
| 59 | | 62 | |
| 60 | my ($username, $password, $b64cred) = ('', '', ''); | 63 | my ($username, $password, $b64cred) = ('', '', ''); |
| 81 | print "\n"; | 84 | print "\n"; |
| 82 | system 'stty', 'echo'; | 85 | system 'stty', 'echo'; |
| 83 | | 86 | |
| 84 | open O, '>', 'tunnus' or die $!; | 87 | open O, '>', '2/tunnus' or die $!; |
| 85 | print O "tunnus = $username\nsalasana = $password\n"; | 88 | print O "tunnus = $username\nsalasana = $password\n"; |
| 86 | close O; | 89 | close O; |
| 87 | $b64cred = encode_base64 "$username:$password", ''; | 90 | $b64cred = encode_base64 "$username:$password", ''; |
| 161 | | 164 | |
| 162 | sub update () | 165 | sub update () |
| 163 | { | 166 | { |
| 164 | feedwget "today/channels-$time.rss", 'http://www.tvkaista.fi/feed/'; | 167 | feedwget "2/today/channels-$time.rss", 'http://www.tvkaista.fi/feed/'; |
| 165 | return 0 if -z "today/channels-$time.rss"; | 168 | return 0 if -z "2/today/channels-$time.rss"; |
| 166 | open I, '<', "today/channels-$time.rss" or die $!; | 169 | open I, '<', "2/today/channels-$time.rss" or die $!; |
| 167 | my (@channels, $linktail, $c); | 170 | my (@channels, $linktail, $c); |
| 168 | while (<I>) { last if /<ttl>/; } | 171 | while (<I>) { last if /<ttl>/; } |
| 169 | while (<I>) { | 172 | while (<I>) { |
| 178 | push @urls, "http://www.tvkaista.fi/feed/channels/$_/flv.rss" | 181 | push @urls, "http://www.tvkaista.fi/feed/channels/$_/flv.rss" |
| 179 | foreach (@channels); | 182 | foreach (@channels); |
| 180 | | 183 | |
| 181 | feedwget "today/a-$time-now.rss", @urls; | 184 | feedwget "2/today/a-$time-now.rss", @urls; |
| 182 | | 185 | |
| 183 | open I, '<', "today/a-$time-now.rss" or die $!; | 186 | open I, '<', "2/today/a-$time-now.rss" or die $!; |
| 184 | fillprograms; | 187 | fillprograms; |
| 185 | close I; | 188 | close I; |
| 186 | | 189 | |
| 188 | my @sorted = sort { $a->[0] <=> $b->[0] } @programs; | 191 | my @sorted = sort { $a->[0] <=> $b->[0] } @programs; |
| 189 | @programs = (); | 192 | @programs = (); |
| 190 | my @di = dateinfo $daysecs; | 193 | my @di = dateinfo $daysecs; |
| 191 | my $outputfile = sprintf("program_%d-%02d-%02d", | 194 | my $outputfile = sprintf("2/program_%d-%02d-%02d", |
| 192 | $di[4] + 1900, $di[3] + 1, $di[2]); | 195 | $di[4] + 1900, $di[3] + 1, $di[2]); |
| 193 | | 196 | |
| 194 | open O, '>', $outputfile or die $!; | 197 | open O, '>', $outputfile or die $!; |
| 198 | @di = dateinfo $_->[0]; | 201 | @di = dateinfo $_->[0]; |
| 199 | if ($fnd && $di[0] ge "0500") { | 202 | if ($fnd && $di[0] ge "0500") { |
| 200 | close O; | 203 | close O; |
| 201 | open O, '>', sprintf("program_%d-%02d-%02d", | 204 | open O, '>', sprintf("2/program_%d-%02d-%02d", |
| 202 | $di[4] + 1900, $di[3] + 1, $di[2]) or die $!; | 205 | $di[4] + 1900, $di[3] + 1, $di[2]) or die $!; |
| 203 | $fnd = 0; | 206 | $fnd = 0; |
| 204 | $pday = ''; | 207 | $pday = ''; |
| 220 | @urls = (); | 223 | @urls = (); |
| 221 | @di = dateinfo $daysecs; $di[4] += 1900; $di[3]++; | 224 | @di = dateinfo $daysecs; $di[4] += 1900; $di[3]++; |
| 222 | | 225 | |
| 223 | $outputfile = sprintf("program_%d-%02d-%02d",$di[4],$di[3],$di[2]); | 226 | $outputfile = sprintf("2/program_%d-%02d-%02d",$di[4],$di[3],$di[2]); |
| 224 | my @fst = stat $outputfile; | 227 | my @fst = stat $outputfile; |
| 225 | next if (defined $fst[9] &&$fst[9] > $daysecs); # recent enough. | 228 | next if (defined $fst[9] &&$fst[9] > $daysecs); # recent enough. |
| 226 | | 229 | |
| 228 | . "/channels/$_/flv.rss" foreach (@channels); | 231 | . "/channels/$_/flv.rss" foreach (@channels); |
| 229 | | 232 | |
| 230 | getdatetime; | 233 | getdatetime; |
| 231 | feedwget "today/a-$di[3]-$di[2]-$time.rss", @urls; | 234 | feedwget "2/today/a-$di[3]-$di[2]-$time.rss", @urls; |
| 232 | last WHILE unless -s "today/a-$di[3]-$di[2]-$time.rss"; | 235 | last WHILE unless -s "2/today/a-$di[3]-$di[2]-$time.rss"; |
| 233 | | 236 | |
| 234 | open I, '<', "today/a-$di[3]-$di[2]-$time.rss" or die $!; | 237 | open I, '<', "2/today/a-$di[3]-$di[2]-$time.rss" or die $!; |
| 235 | fillprograms; | 238 | fillprograms; |
| 236 | close I; | 239 | close I; |
| 237 | | 240 | |
| 260 | { | 263 | { |
| 261 | mkpw 1 if ($username eq '' or $password eq ''); | 264 | mkpw 1 if ($username eq '' or $password eq ''); |
| 262 | getdatetime; | 265 | getdatetime; |
| 263 | recwget "today/login-$time.html", 'http://www.tvkaista.fi/netpvr/Login', | 266 | recwget "2/today/login-$time.html", 'http://www.tvkaista.fi/netpvr/Login', |
| 264 | '--save-cookies', "cookies-$date-$time.txt", '--keep-session-cookies', | 267 | '--save-cookies', "cookies-$date-$time.txt", '--keep-session-cookies', |
| 265 | '--max-redirect=0', | 268 | '--max-redirect=0', |
| 266 | '--post-data', | 269 | '--post-data', |
| 268 | unlink 'cookies.txt'; | 271 | unlink 'cookies.txt'; |
| 269 | symlink "cookies-$date-$time.txt", 'cookies.txt'; | 272 | symlink "cookies-$date-$time.txt", 'cookies.txt'; |
| 270 | | 273 | |
| 271 | return -z "today/login-$time.html"; | 274 | return -z "2/today/login-$time.html"; |
| 272 | } | 275 | } |
| 273 | | 276 | |
| 274 | sub getpw () | 277 | sub getpw () |
| 275 | { | 278 | { |
| 276 | if (-f 'tunnus') { | 279 | if (-f '2/tunnus') { |
| 277 | open I, '<', 'tunnus'; | 280 | open I, '<', '2/tunnus'; |
| 278 | while (<I>) { | 281 | while (<I>) { |
| 279 | $username = $1 if /^\s*tunnus\s*=\s*(\S+)/; | 282 | $username = $1 if /^\s*tunnus\s*=\s*(\S+)/; |
| 280 | $password = $1 if /^\s*salasana\s*=\s*(\S+)/; | 283 | $password = $1 if /^\s*salasana\s*=\s*(\S+)/; |
| 288 | } | 291 | } |
| 289 | } | 292 | } |
| 290 | | 293 | |
| 291 | sub getsrt($) | 294 | sub getsrt($$) |
| 292 | { | 295 | { |
| 293 | #http://www.tvkaista.fi/netpvr/Download/774338.srt | 296 | #http://www.tvkaista.fi/netpvr/Download/774338.srt |
| 294 | | 297 | |
| 295 | my $tof = "../recordings/$ARGV[3].srt.wip"; | 298 | my $tof = "$_[0].srt"; |
| 296 | | 299 | |
| 297 | recwget $tof, "http://www.tvkaista.fi/netpvr/Download/$ARGV[3].srt", | 300 | recwget $tof, "http://www.tvkaista.fi/netpvr/Download/$_[0].srt", |
| 298 | '--load-cookies', 'cookies.txt'; | 301 | '--load-cookies', '2/cookies.txt'; |
| 299 | | 302 | |
| 300 | open I, '<', $tof or return ( $ARGV[3], 0 ); | 303 | open I, '<', $tof or return ( $_[0], 0 ); |
| 301 | | 304 | |
| 302 | my ($namepfx, $haveit, $conlen) = ($ARGV[3], 0, -1); | 305 | my ($namepfx, $haveit, $conlen) = ($_[0], 0, -1); |
| 303 | while (<I>) { | 306 | while (<I>) { |
| 304 | $namepfx = $1, $haveit = 1 if /^Content-Disp.*filename=(.*).srt\s*$/; | 307 | $namepfx = $1, $haveit = 1 if /^Content-Disp.*filename=(.*).srt\s*$/; |
| 305 | $conlen = $1 if /^Content-Length:\s+(\d+)/; | 308 | $conlen = $1 if /^Content-Length:\s+(\d+)/; |
| 307 | } | 310 | } |
| 308 | close I; | 311 | close I; |
| 309 | if ($conlen > 0) { | 312 | if ($conlen > 0) { |
| | 313 | $namepfx = 'tekstitys' if $_[1] ne 'wget'; |
| 310 | rename $tof, "../recordings/$namepfx.srt"; } | 314 | rename $tof, "$namepfx.srt"; } |
| 311 | else { | 315 | else { |
| 312 | unlink $tof; } | 316 | unlink $tof; } |
| 313 | | 317 | |
| 322 | | 326 | |
| 323 | getpw; | 327 | getpw; |
| 324 | | 328 | |
| 325 | my $pagename = "today/play-$time.html"; | 329 | my $pagename = "2/today/play-$time.html"; |
| 326 | | 330 | |
| 327 | my $format = $speeds{$ARGV[4]}; | 331 | my $format = $speeds{$ARGV[4]}; |
| 328 | recwget $pagename, | 332 | recwget $pagename, |
| 329 | "http://www.tvkaista.fi/netpvr/VLC?id=$ARGV[3]&format=$format", | 333 | "http://www.tvkaista.fi/netpvr/VLC?id=$ARGV[3]&format=$format", |
| 330 | '--load-cookies', 'cookies.txt'; | 334 | '--load-cookies', '2/cookies.txt'; |
| 331 | | 335 | |
| 332 | open I, '<', $pagename or die "Can not open '$pagename': $!\n"; | 336 | open I, '<', $pagename or die "Can not open '$pagename': $!\n"; |
| 333 | my $url; | 337 | my $url; |
| 340 | die "No content found!\n"; | 344 | die "No content found!\n"; |
| 341 | } | 345 | } |
| 342 | | 346 | |
| 343 | my ($namepfx, $srtflen) = getsrt($ARGV[3]); | | |
| 344 | chdir $recdir; | 347 | chdir $recdir; |
| | 348 | my ($namepfx, $srtflen) = getsrt($ARGV[3], $ARGV[2]); |
| 345 | | 349 | |
| 346 | my @list = ( $ARGV[2] ); | 350 | my @list = ( $ARGV[2] ); |
| 347 | if ($ARGV[2] eq 'wget') { | 351 | if ($ARGV[2] eq 'wget') { |
| 363 | system @list or warn "system(): $!\n"; | 367 | system @list or warn "system(): $!\n"; |
| 364 | print "Executed @list\n"; | 368 | print "Executed @list\n"; |
| 365 | | 369 | |
| 366 | unlink "$namepfx.srt" if $srtflen > 0 && ($ARGV[2] ne 'wget'); | 370 | unlink "$namepfx.srt" if $srtflen > 0 && $ARGV[2] ne 'wget'; |
| 367 | | 371 | |
| 368 | # add more checks & cleanups | 372 | # add more checks & cleanups |
| 369 | exit 0; | 373 | exit 0; |
| 401 | # "list" (and "update" too) | 405 | # "list" (and "update" too) |
| 402 | select STDOUT; | 406 | select STDOUT; |
| 403 | | 407 | |
| 404 | my @prgfiles = <program_*[0-9]>; | 408 | my @prgfiles = <2/program_*[0-9]>; |
| 405 | unlink shift @prgfiles while defined $prgfiles[15]; | 409 | unlink shift @prgfiles while defined $prgfiles[15]; |
| 406 | foreach (@prgfiles) | 410 | foreach (@prgfiles) |
| 407 | { | 411 | { |
| tvkaista-0.95/tvkaista_gtkui.c | | tvkaista-0.961/tvkaista_gtkui.c |
| 1 | #if 0 /* -*- mode: c; c-file-style: "stroustrup"; tab-width: 8; -*- | 1 | #if 0 /* -*- mode: c; c-file-style: "stroustrup"; tab-width: 8; -*- |
| | 2 | |
| 2 | set -e; TRG=`basename $0 .c`; rm -f "$TRG" | 3 | set -e; TRG=`basename $0 .c`; rm -f "$TRG" |
| 3 | WARN="-Wall -Wno-long-long -Wstrict-prototypes -pedantic" | 4 | WARN="-Wall -Wno-long-long -Wstrict-prototypes -pedantic" |
| 4 | WARN="$WARN -Wcast-align -Wpointer-arith " # -Wfloat-equal #-Werror | 5 | WARN="$WARN -Wcast-align -Wpointer-arith " # -Wfloat-equal #-Werror |
| 5 | WARN="$WARN -W -Wwrite-strings -Wcast-qual -Wshadow" # -Wconversion | 6 | WARN="$WARN -W -Wwrite-strings -Wcast-qual -Wshadow" # -Wconversion |
| 6 | X=`pkg-config --cflags --libs gtk+-2.0` | 7 | X=`pkg-config --cflags --libs gtk+-2.0` |
| 7 | gzip -9 -c < tvkaista-helper.pl > helper.gz | | |
| 8 | { echo 'const unsigned char helpercode[] = {' | | |
| 9 | perl -e 'printf("0x%x,\n", ord $_) while read STDIN, $_, 1' < helper.gz | | |
| 10 | #perl -pe 's/./sprintf"0x%x,\n",ord $&/ge' helper.gz | | |
| 11 | echo '}; const unsigned int helpercode_size = sizeof helpercode;'; | | |
| 12 | echo const unsigned int helpercode_full_size = `stat -c %s tvkaista-helper.pl`\; | | |
| 13 | } > helper.c | | |
| 14 | case $1 in '') set x -O2 ### set x -ggdb; | 8 | case $1 in '') set x -O2 ### set x -ggdb; |
| 15 | shift ;; esac; | 9 | shift ;; esac; |
| 16 | set -x; ${CC:-gcc} -std=gnu99 $WARN "$@" helper.c -o "$TRG" "$0" \ | 10 | set -x; ${CC:-gcc} -std=gnu99 $WARN "$@" -o "$TRG" "$0" -DCDATE="\"`date`\"" $X |
| 17 | -DCDATE="\"`date`\"" $X | | |
| 18 | exit $? | 11 | exit $? |
| | 12 | |
| 19 | */ | 13 | */ |
| 20 | #endif | 14 | #endif |
| 21 | /* | 15 | /* |
| 24 | * Author: Tomi Ollila -- too ät iki piste fi | 18 | * Author: Tomi Ollila -- too ät iki piste fi |
| 25 | * | 19 | * |
| 26 | * Copyright (c) 2009 Tomi Ollila | 20 | * Copyright (c) 2009 Tomi Ollila |
| 27 | * Copyright (c) 2009 | | |
| 28 | * All rights reserved | 21 | * All rights reserved |
| 29 | * | 22 | * |
| 30 | * Created: Tue Feb 03 19:04:43 EET 2009 too | 23 | * Created: Tue Feb 03 19:04:43 EET 2009 too |
| 47 | | 40 | |
| 48 | #include <signal.h> | 41 | #include <signal.h> |
| 49 | #include <errno.h> | 42 | #include <errno.h> |
| 50 | | | |
| 51 | extern const unsigned char helpercode[]; | | |
| 52 | extern const unsigned int helpercode_size; | | |
| 53 | extern const unsigned int helpercode_full_size; | | |
| 54 | | 43 | |
| 55 | #define null ((void*)0) | 44 | #define null ((void*)0) |
| 56 | | 45 | |
| 118 | char * path; | 107 | char * path; |
| 119 | char compare[MAXSEARCHLEN + 2]; | 108 | char compare[MAXSEARCHLEN + 2]; |
| 120 | // max 32 for now (14 is current maximum in tvkaista). | 109 | // max 32 for now (14 is current maximum in tvkaista). |
| 121 | char prgfile[32][sizeof "program_2009-mm-dd"]; | 110 | char prgfile[32][sizeof "2/program_2009-mm-dd"]; |
| 122 | int prgfd[32]; | 111 | int prgfd[32]; |
| 123 | PrgInfo * prgbuffers[100]; // up to 100 000 programs. | 112 | PrgInfo * prgbuffers[100]; // up to 100 000 programs. |
| 124 | int previndx; | 113 | int previndx; |
| 135 | } W; | 124 | } W; |
| 136 | | 125 | |
| 137 | // XXX make better later... | 126 | // XXX make better later... |
| 138 | const char G_helper[] = "./tvkaista-helper02.pl"; | 127 | const char G_helper[] = "./tvkaista-helper.pl"; |
| 139 | | 128 | |
| 140 | void init_G(void) | 129 | void init_G(void) |
| 141 | { | 130 | { |
| 796 | aHBox(/* <- homogeneous spacing */ false, 2, | 785 | aHBox(/* <- homogeneous spacing */ false, 2, |
| 797 | aButton("Päivitä", update_pressed, null), | 786 | aButton("Päivitä", update_pressed, null), |
| 798 | /* ^^ expand fill padding */ false, true, 2, | 787 | /* ^^ expand fill padding */ false, true, 2, |
| 799 | aButton("Esitä", play_pressed, null), | 788 | aButton("Katso", play_pressed, null), |
| 800 | /* ^^ expand fill padding */ false, true, 2, | 789 | /* ^^ expand fill padding */ false, true, 2, |
| 801 | aButton("Tallenna", save_pressed, null), | 790 | aButton("Tallenna", save_pressed, null), |
| 802 | /* ^^ expand fill padding */ false, true, 2, | 791 | /* ^^ expand fill padding */ false, true, 2, |
| 839 | // gtk_widget_show_all(W.w); | 828 | // gtk_widget_show_all(W.w); |
| 840 | } | 829 | } |
| 841 | | 830 | |
| 842 | void output_pl(void) | | |
| 843 | { | | |
| 844 | char path[512]; | | |
| 845 | struct stat st; | | |
| 846 | const char * home = getenv("HOME"); | | |
| 847 | | | |
| 848 | if (strlen(home) > 128) | | |
| 849 | die("Home directory path too long\n"); | | |
| 850 | | | |
| 851 | sprintf(path, "%s/.tvkaista/2/tvkaista-helper02.pl", home); | | |
| 852 | | | |
| 853 | //putenv("SHELL=/bin/sh"); | | |
| 854 | setenv("SHELL", "/bin/sh", 1); | | |
| 855 | if (system("tvdir=\"$HOME\"/.tvkaista/2;\n" | | |
| 856 | "test -d \"$tvdir\" || mkdir \"$tvdir\";\n" | | |
| 857 | "helper=\"$tvdir\"/tvkaista-helper02.pl\n" | | |
| 858 | "test -x \"$helper\" || exit 1;\n" | | |
| 859 | "exec grep '^#noupdate: yes' \"$helper\" >/dev/null 2>&1\n" | | |
| 860 | ) != 0) { | | |
| 861 | FILE * fh; | | |
| 862 | fh = popen("gzip -dc > \"$HOME\"/.tvkaista/2/tvkaista-helper02.pl", | | |
| 863 | "w"); | | |
| 864 | if (fh == null) | | |
| 865 | die("popen():"); | | |
| 866 | if (fwrite(helpercode, 1, helpercode_size, fh) != helpercode_size) | | |
| 867 | die("fwrite():"); | | |
| 868 | pclose(fh); | | |
| 869 | chmod(path, 0755); | | |
| 870 | } | | |
| 871 | if (stat(path, &st) < 0) | | |
| 872 | die("stat():"); | | |
| 873 | if ((st.st_mode & 0777) != 0755) | | |
| 874 | die("st.st_mode (%0) != 0755\n", st.st_mode); | | |
| 875 | if (st.st_size != (int)helpercode_full_size) { | | |
| 876 | die("helpercode == %ld, not %d\n", st.st_size, helpercode_full_size); | | |
| 877 | } | | |
| 878 | sprintf(path, "%s/.tvkaista/2", home); | | |
| 879 | if (chdir(path) < 0) | | |
| 880 | die("chdir():"); | | |
| 881 | } | | |
| 882 | | 831 | |
| 883 | | 832 | |
| 884 | int main(int argc, char *argv[]) | 833 | int main(int argc, char *argv[]) |
| 887 | init_G(); | 836 | init_G(); |
| 888 | gtk_init(&argc, &argv); | 837 | gtk_init(&argc, &argv); |
| 889 | setenv("PERL_UNICODE", "SD", 1); | 838 | setenv("PERL_UNICODE", "SD", 1); |
| 890 | output_pl(); | | |
| 891 | gui(); | 839 | gui(); |
| 892 | gtk_main(); | 840 | gtk_main(); |
| 893 | return 0; | 841 | return 0; |