/* * Name: whois.rexx 1.0 (18.02.01) * Description: simple whois client with localization support * */ signal on break_c l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit l="locale.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit prg=ProgramName("NOEXT") call getStrings if ~open(stderr,"CONSOLE:","W") then stderr="STDOUT" if AddLibrary("rexxsupport.library","rxsocket.library")~=0 then call err strings.ERRCANTFIND "'"result"'",1 parm.0.value="rs.internic.net" if ~RMH_ReadArgs("HOST/K,TO/K,KEY/A/F") then do call PrintFault() exit end if parm.1.flag then do if ~open(out,parm.1.value,"W") then do call PrintFault() exit end end else out="STDOUT" s=socket("INET","STREAM") if s<0 then call err strings.ERRNOSOCKECT remote.addraddr=resolve(parm.0.value) if remote.addraddr=="-1" then call err strings.ERRNOHOST "<"parm.0.value">",0 remote.addrport=43 if connect(s,"REMOTE")<0 then call err strings.ERRCANTCONNECT "<"parm.0.value">" req="WHOIS" parm.2.value"D0A"x if send(s,req)~=length(req) then call err strings.ERRSEND call writeln(out,strings.MSGRESULT "'"parm.2.value"'") r=1 do while r>0 r=recv(s,"BUF",256) if r>0 then call writech(out,buf) end if r<0 then call err strings.ERRRECV exit break_c: say call err "break" exit err: parse arg msg,ntdoerr if ntdoerr~=0 then msg=msg "("ErrorString()")" call writeln(stderr,prg":" msg) exit getStrings: procedure expose prg strings. catalog=OpenCatalog(prg".catalog","english",0) strings.ERRCANTFIND=GetCatalogStr(catalog,1,"can't find") strings.ERRNOSOCKET=GetCatalogStr(catalog,2,"can't create socket") strings.ERRNOHOST=GetCatalogStr(catalog,3,"host not found") strings.ERRCANTCONNECT=GetCatalogStr(catalog,4,"can't connect to") strings.ERRSEND=GetCatalogStr(catalog,5,"error while sending request") strings.MSGRESULT=GetCatalogStr(catalog,6,"Whois results for") strings.ERRRECV=GetCatalogStr(catalog,7,"error while receiving") call CloseCatalog(catalog); return