home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
chang09m.zip
/
ihave.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-08-10
|
3KB
|
126 lines
/* Implements posting with IHAVE command */
if RxFuncQuery("SockLoadFuncs") then do
rc = RxFuncAdd("SockLoadFuncs", "rxSock", "SockLoadFuncs")
rc = SockLoadFuncs()
end /* Do */
crLf = d2c(13) || d2c(10)
tmpFName = "ihavetmp.!@#"
'@erase' tmpFName '2>nul'
call stream "inews.log", "c", "seek <0"
fromID = ""
newsGroups = ""
interval = time('E')
seqNo = lineIn("SEQF")
nntp_neighbor = VALUE('NNTPNEIGHBOR',,'OS2ENVIRONMENT')
hostAddr = SockGetHostID()
rc = SockGetHostByAddr(hostAddr, host.!)
message_id = "<D"date('S')"T"time('S')"X"seqNo"@"host.!name">"
call rewrite
rc =SockGetHostByName(nntp_neighbor, "host.!")
if (rc = 0) then do
call lineOut "inews.log", "Unable to resolve name of nntp neighbor."
exit 1
end
server = host.!addr
sock = SockSocket("AF_INET", "SOCK_STREAM", "IPPROTO_TCP")
if (sock = -1) then do
call lineOut "inews.log", "Error opening socket: " errno
exit errno
end
server.!family = "AF_INET"
server.!port = 119
server.!addr = server
rc = SockConnect(sock, "server.!")
if (sock = -1) then do
call lineOut "inews.log", "Error connecting socket: " errno
exit errno
end
rc = SockRecv(sock, "data", 8000)
rc = SockSend(sock, "ihave" message_id || crLf)
rc = SockRecv(sock, "data", 8000)
parse var data sockRc '0D'x restOfLine
parse var sockRc sockRc ' ' junk
if (sockRc \= 335) then do
call lineOut "inews.log", date("U") time(),
"Error IHAVE refused:" sockRc
rc = SockClose(sock)
exit sockRc
end
inLine = lineIn(tmpFName)
do while lines(tmpFName) > 0
rc = SockSend(sock, inLine || crLf)
inLine = lineIn(tmpFName)
end
rc = SockSend(sock, "."||crLf)
rc = SockRecv(sock, "data", 8000)
call stream tmpFName, "Command", "Close"
parse var data sockRc '0D'x restOfLine
parse var sockRc sockRc ' ' junk
call lineOut "inews.log", date("U") time() "IHAVE (6/13/95)"
call lineOut "inews.log", date("U") time() "IHAVE spooling news to",
newsGroups "from" fromID
interval = time("E")
if (sockRc = 235) then do
'@rnews <'||tmpFName
call lineOut "inews.log", date("U") time(),
"IHAVE processed 1 article in" strip(time("E"),,'0'),
"seconds"
call lineOut "inews.log", ""
end /* Do */
else do
call lineOut "inews.log", date("U") time(),
"Error IHAVE refused:" sockRc
'@erase' tmpFName '2>nul'
rc = SockClose(sock)
exit sockRc
end /* Do */
'@erase' tmpFName '2>nul'
rc = SockClose(sock)
exit
rewrite: procedure expose message_id tmpFName fromID newsGroups
inLine = lineIn()
do while inLine <> ''
parse var inLine lineType ':' lineValue
call lineOut tmpFName, inLine
if lineType = "Newsgroups" then
newsGroups = lineValue
if lineType = "From" then
fromID = lineValue
if lineType = "Subject" then do
call lineOut tmpFname, "Date:" date() time()
call lineOut tmpFName, "Message-ID:" message_id
call lineOut tmpFName, "Path: kserver!not-for-mail"
end
inLine = lineIn()
end /* do */
do while lines() > 0
call lineOut tmpFName, inLine
inLine = lineIn()
end /* do */
call stream tmpFName, 'Command', 'Close'
return