The entries 2004/hibachi and 2005/mynx have unobfuscated code now. 2004/hibachi has a configure script that is used along the lines of the original entry (with some adjustments and fixes) and the hibachi.alt.c had to have ctype.h included too. The directory src/localhost was copied to src-alt/localhost but the rest of src/ was from Anthony. The Makefile had to be updated to build this version. 2005/mynx does have a configure script but it is, just like the original entry, unused and so the unobfuscated (in source-alt/) is also unused. The mynx.alt.c was changed to mynx.alt2.c and the unobfuscated code was made mynx.alt.c. Updated manifest, rebuilt .entry.json and index.html files. After a question is answered and taken care of (in one of 199[1-3]/ant - not sure which one) issue #2513 can possibly be closed as complete (though the manifest updates will have to be looked at more when 2004 and 2005 are reviewed).
78 lines
1.9 KiB
Plaintext
78 lines
1.9 KiB
Plaintext
#!@perl_exe@
|
|
#
|
|
# yahoo-ticker.pl
|
|
#
|
|
# Copyright 1998 by Anthony Howe. All rights reserved.
|
|
#
|
|
# Usage: yahoo-ticker.pl?<symbol>
|
|
#
|
|
|
|
##########################################################################
|
|
# Nothing to be configured below this point.
|
|
##########################################################################
|
|
|
|
use Socket;
|
|
|
|
# WORK-AROUND 1.
|
|
# BAH! Some Perl implementations (for Windows) are not created equal.
|
|
# Force I/O flushes after each read/write operation.
|
|
|
|
$| = 1;
|
|
|
|
#########################################################################
|
|
# Open connection to URL.
|
|
#########################################################################
|
|
|
|
my ($symbol) = $ENV{'QUERY_STRING'} =~ /\??(.*)/;
|
|
|
|
# Figure out who we have to call.
|
|
#($host, $port, $path) = ($url =~ m!http://([^:/]+)(?:\:(\d*))?(/.*)!);
|
|
|
|
$host = "finance.yahoo.com";
|
|
$port = 80 unless defined $port;
|
|
$path = "/q?s=$symbol";
|
|
|
|
# Get a socket...
|
|
unless (socket(HTTP, PF_INET, SOCK_STREAM, getprotobyname('tcp'))) {
|
|
print("[CGI failed ($!)]\n");
|
|
exit(0);
|
|
}
|
|
|
|
# ...set socket to be line buffered...
|
|
select( (select(HTTP), $| = 1)[0] );
|
|
|
|
# .. make the connection.
|
|
unless (connect(HTTP, sockaddr_in($port, inet_aton("$host")))) {
|
|
print("[CGI failed ($!)]\n");
|
|
exit(0);
|
|
}
|
|
|
|
print HTTP "GET $path HTTP/1.0\nHost: $host\n\n";
|
|
|
|
while (<HTTP>) {
|
|
# Last trade price line.
|
|
if (m!>Last Trade:<!) {
|
|
($price) = (m!Last Trade:</td><td class="yfnc_tabledata1"><big><b>(\d+\.\d+)</b></big></td>!);
|
|
}
|
|
|
|
if (m!>Trade Time:<!) {
|
|
($last) = (m!Trade Time:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
|
}
|
|
|
|
if (m!>Volume:<!) {
|
|
($volume) = (m!Volume:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
|
}
|
|
}
|
|
|
|
close(HTTP);
|
|
|
|
print "HTTP/1.0 200 OK\n";
|
|
print "Content-Type: text/javascript\n\n";
|
|
|
|
print "var ticker = new Array();\n";
|
|
print "ticker['price'] = $price;\n";
|
|
print "ticker['volume'] = \"$volume\";\n";
|
|
print "ticker['last'] = \"$last\";\n";
|
|
|
|
exit 0;
|