/* YamNet Rewritted (almost)

    $VER: YamNet 3.07 by Alfredo Soro (31 Dic 1996 - 04:00)

*/

if ~show('l','rexxsupport.library')
then do
 call addlib('rexxsupport.library',0,-30)
end
if ~show('l','rexxtricks.library')
then do
 call addlib('rexxtricks.library',0,-30)
end
if ~show('l','rexxtricks.library')
then do
 Say 'Rexxtricks.library??  -- VERSION: 38.6+'
 EXIT
END

if ~show('l','rexxextra.library')
then do
 call addlib('rexxextra.library',0,-30)
END


IF ~show(l,"rexxreqtools.library") THEN IF ~addlib("rexxreqtools.library", 0, -30, 0)
then do
 Call Textos('#' , 'rexxreqtools.library no encontrada en LIBS:' , 'rexxreqtools.library not found in LIBS:')
 EXIT 10
end

options failat 99
options cache
OPTIONS RESULTS
SIGNAL ON BREAK_C
SIGNAL ON BREAK_D
SIGNAL ON BREAK_E
SIGNAL ON BREAK_F
SIGNAL ON HALT
SIGNAL OFF SYNTAX
SIGNAL OFF ERROR
SIGNAL OFF NOVALUE
call time 'r'

/* trace results */

Say ''
Say '[41;32m YamNet [42;31mv3.07[40;31m - by Alfredo Soro - 31 Dic 1996 - 04:00 [0m'

NL = d2c(10)
atra = d2c(8)
lin = NL
remanda = 0
reborra = 65532
yamcheck = 0
rehoy = date('b')
safe = 0
elrre = 0
borros = 0
quienes = ''
deteta = 0
PURGE = 0
FUERA = 0
purgy = 0
nogui = 0
NOHIDE = 0
LANG = ''
LOGFIL = ''
LOGLEV = ''
INBO = ''
OUTBO = ''
TEMP = ''
LANG = ''
ZONAS = 0
NODOS = 0
DROP UUMOD.
DROP TOPGP.
DROP ELNO.
DROP LADRE.
DROP SUBZ.
DROP SUBJ.
DROP SUBNO.
DROP LLAMADA.
DROP recinu.

if ~exists('c:fscode')
then do
 Say 'c:FSCode ???'
 EXIT
end

if ~exists('c:base64encode')
then do
 Say 'c:Base64Encode ???'
 EXIT
end

if ~exists('c:base64decode')
then do
 Say 'c:Base64Decode ???'
 EXIT
end

if ~exists('s:YamNet.cfg')
then do
 Say 'S:YamNet.cfg?'
 Call PREFS
 Call LOGFPREFS
 CALL YQPREFS
 CALL INPREFS
 CALL OUTPREFS
 CALL LOGLPREFS
 CALL NODPREFS
 CALL MODPREFS
 CALL SNODPREFS
 CALL ONLYFLOPREFS
 CALL TEMPPREFS
 CALL NOHIDEPREFS
 CALL YAMCHECKPREFS
 CALL PURGEPREFS
 CALL GRABACFG
end

LEEPREFS:

Call open('YNCFG','S:YamNet.cfg','R')
cambiadas = 0

Do until EOF('YNCFG')

 lectura = readln('YNCFG')
 pasa = 0

 if left(lectura,1) = ';' then pasa = 1

 if pasa = 0 & upper(word(lectura,1)) = 'LANG'
 then do
  pasa = 1
  LANG = UPPER(right(lectura,length(lectura)-7))
  if LANG ~= 'ESPAÑOL' & LANG ~= 'ENGLISH'
  then do
   cambiadas = cambiadas + 1
   LLAMADA = 'LENPREFS'
  end
 end

 if pasa = 0 & UPPER(Left(lectura,6)) = 'LOG = '
 then do
  pasa = 1
  LOGFIL = right(lectura,length(lectura)-6)
  pazlo = ''
  pospaz = ''
  do clo = 1 to length(logfil)
   pazlo = pazlo || right(left(logfil,clo),1)
   if right(left(logfil,clo),1) = ':' then pospaz = pazlo
   if right(left(logfil,clo),1) = '/' then pospaz = pazlo
  end
  if pospaz ~= '' & ~exists(pospaz) then pospaz = ''
  if pospaz = ''
  then do
   cambiadas = cambiadas + 1
   LLAMADA = 'LOGFPREFS'
  end
 end

 if pasa = 0 & UPPER(Left(lectura,7)) = 'TEMP = '
 then do
  TEMP = RIGHT(lectura,length(lectura)-7)
  TEm = TEMP'/'
  if right(TEMP,1) = ':' then TEm = TEMP
  if right(TEMP,1) = '/' then TEm = TEMP
  TEMP = TEm
  pasa = 1
  if ~exists(TEMP)
  then do
   cambiadas = cambiadas + 1
   LLAMADA.cambiadas = 'TEMPPREFS'
  end
 end

 if pasa = 0 & UPPER(Left(lectura,11)) = 'LOGLEVEL = '
 then do
  pasa = 1
  LOGLEV = subword(lectura,3,1)
  if LOGLEV = '0' then LOGLEV = 0
  if LOGLEV = '1' then LOGLEV = 1
  if LOGLEV = '2' then LOGLEV = 2
  if LOGLEV = '3' then LOGLEV = 3
  if LOGLEV = '4' then LOGLEV = 4
  if loglev ~= 0 & loglev ~= 1 & loglev ~= 2 & loglev ~= 3 & loglev ~= 4
  then do
   cambiadas = cambiadas + 1
   LLAMADA = 'LOGLPREFS'
  end
 end

 if pasa = 0 & UPPER(Left(lectura,6)) = 'NOHIDE'
 then do
  NOHIDE = 1
 end

 if pasa = 0 & UPPER(Left(lectura,11)) = 'OUTBOUND = '
 then do
  OUTBO = right(lectura,length(lectura)-11)
  outb = OUTBO'/'
  if right(OUTBO,1) = ':' then outb = OUTBO
  if right(OUTBO,1) = '/' then outb = OUTBO
  OUTBO = outb
  pasa = 1
  if ~exists(outbo)
  then do
   cambiadas = cambiadas + 1
   LLAMADA.cambiadas = 'OUTPREFS'
  end
 end

 if pasa = 0 & ONLYFLO ~= 1 then ONLYFLO = 0
 if pasa = 0 & UPPER(Left(lectura,7)) = 'ONLYFLO'
 then do
  ONLYFLO = 1
  pasa = 1
 end

 if pasa = 0 & UPPER(Left(lectura,10)) = 'INBOUND = '
 then do
  INBO = right(lectura,length(lectura)-10)
  INb = INBO'/'
  if right(INBO,1) = ':' then INb = INBO
  if right(INBO,1) = '/' then INb = INBO
  INBO = INb
  pasa = 1
  if ~exists(inbo)
  then do
   cambiadas = cambiadas + 1
   LLAMADA.cambiadas = 'INPREFS'
  end
 end

 if pasa = 0 & upper(left(lectura,8)) = 'YAMCHECK'
 Then do
  YamCheck = 1
  pasa = 1
 end

 if pasa = 0 & upper(left(lectura,5)) = 'PURGE'
 Then do
  PURGY = 1
  pasa = 1
 end

 if pasa = 0 & upper(left(lectura,9))= 'RESEND = '
 then do
  pasa = 1
  remanda = word(lectura,3)
  if ~datatype(remanda,'N')
  then do
   cambiadas = cambiadas + 1
   LLAMADA.cambiadas = 'REMAPREFS'
  end
 end

 if pasa = 0 & upper(left(lectura,9))= 'DELETE = '
 then do
  pasa = 1
  reborra = word(lectura,3)
  if ~datatype(reborra,'N')
  then do
   cambiadas = cambiadas + 1
   LLAMADA.cambiadas = 'REBOPREFS'
  end
 end

 if pasa = 0 & upper(left(lectura,10))= 'SUBZONA = '
 then do
  pasa = 1
  zonas = zonas + 1
  SUBZ.zonas = SUBWORD(lectura,3,1)
  SUBJ.zonas = SUBWORD(lectura,4,1)
 end

 if pasa = 0 & upper(left(lectura,7))= 'NODO = '
 then do
  nodos = nodos + 1
  ELNO.nodos = SUBWORD(lectura,3,1)
  ELNODO.nodos = SUBWORD(lectura,3,1)
  LADRE.nodos = SUBWORD(lectura,4,1)
  UUMOD.nodos = SUBWORD(lectura,5,1)
  if upper(UUMOD.nodos) = 'PGP' then TOPGP.nodos = RIGHT(lectura,(length(lectura)-1)-length(subword(lectura,1,5)))
  if upper(UUMOD.nodos) ~= 'PGP' & upper(UUMOD.nodos) ~= 'FSCODE' & upper(UUMOD.nodos) ~= 'UUIN' & upper(UUMOD.nodos) ~= 'MIME' then CALL PMODPREFS
 end
end

IF LANG = ''
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'LENPREFS'
end

IF LOGFIL = ''
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'LOGFPREFS'
end

IF LOGLEV = ''
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'LOGLPREFS'
end

IF INBO = ''
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'INPREFS'
end

IF TEMP = ''
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'TEMPPREFS'
end

IF OUTBO = ''
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'OUTPREFS'
end

if remanda = 0
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'REMAPREFS'
end

if reborra = 65532
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'REBOPREFS'
end

IF Nodos = 0
then do
 cambiadas = cambiadas + 1
 LLAMADA.cambiadas = 'NODPREFS'
end

IF zonas = 0
then do
 if LANG = 'ESPAÑOL' then say '*** SUBZONA: No hay ninguna Zona y Subject definidos en S:YamNet.cfg'
 if LANG = 'ESPAÑOL' then say ' *** Programa interrumpido!!'
 if LANG = 'ENGLISH' then say "*** SUBZONA: There isn't any NetZone & Subject defined in S:YamNet.cfg"
 if LANG = 'ENGLISH' then say ' *** Program aborted!!'
 EXIT
END

Call close('YNCFG')

if cambiadas ~= 0
then do
 IF LANG = '' then call LENPREFS
 do a = 1 to cambiadas
  if LLAMADA.a = 'LOGFPREFS' then CALL LOGFPREFS
  if LLAMADA.a = 'REMAPREFS' then CALL REMAPREFS
  if LLAMADA.a = 'REBOPREFS' then CALL REBOPREFS
  if LLAMADA.a = 'YQPREFS' then CALL YQPREFS
  if LLAMADA.a = 'INPREFS' then CALL INPREFS
  if LLAMADA.a = 'OUTPREFS' then CALL OUTPREFS
  if LLAMADA.a = 'TEMPPREFS' then CALL TEMPPREFS
  if LLAMADA.a = 'LOGLPREFS' then CALL LOGLPREFS
  if LLAMADA.a = 'PGPPREFS' then CALL PGPPREFS
  if LLAMADA.a = 'NODPREFS' then CALL NODPREFS
 end
 CALL GRABACFG
end

do mirs = 1 to nodos
 SUBNO.mirs = ''
 pcone = 0
 zono = ''
 pand = ''
 do until pand = '.'
  pcone = pcone + 1
  pand = Right(Left(ELNO.mirs,pcone),1)
  if pand ~= '.' then zono = zono || pand
 end
 parando = ''
 lasz = 0
 do until parando = 'ya'
  lasz = lasz +1
  lazo = SUBZ.lasz
  if zono = lazo
  THEN DO
   SUBNO.mirs = SUBJ.lasz
   parando = 'ya'
  end
  if lasz = zonas then parando = 'ya'
 end

 if SUBNO.mirs = ''
 then do
  if LANG = 'ESPAÑOL' then say '*** SUBZONA: Falta definicion de Zona-Subject para el NODO: '||ELNO.mirs
  if LANG = 'ESPAÑOL' then say ' *** Programa interrumpido!!'
  if LANG = 'ENGLISH' then say '*** SUBZONA: Missing ZONE-SUBJECT definition for Node:'||ELNO.mirs
  if LANG = 'ENGLISH' then say ' *** Program aborted!!'
  EXIT
 end
end

/* INICIO */

parse arg accion segur congui

if upper(accion) = 'GENDAT'
then do
 call GENERADAT
 EXIT
end

if upper(accion) = 'GUI' | upper(segur) = 'GUI' | upper(congui) = 'GUI' then nogui = 1
if upper(accion) = 'PURGE' then purge = 1
if upper(accion) = 'OUT' Then fuera = 1
if upper(accion) = 'SAFE' | upper(segur) = 'SAFE' | upper(congui) = 'SAFE' then safe = 1

if upper(accion) ~= 'GUI' & upper(accion) ~= 'SAFE' & upper(accion) ~= 'PURGE' & upper(accion) ~= 'OUT' & accion ~= '' then usal = 1
if upper(segur) ~= 'GUI' & upper(segur) ~= 'SAFE' & segur ~= '' then usal = 1
if upper(congui) ~= 'GUI' & upper(congui) ~= 'SAFE' & congui ~= '' then usal = 1
if accion ~= ''
then do
 if upper(accion) = upper(segur) | upper(accion) = upper(congui) then usal = 1
end
if segur ~= '' then if upper(segur) = upper(congui) then usal = 1

if usal = 1
then do
 IF Upper(LANG) = 'ESPAÑOL'
 then do
  say 'Usar:        YamNet [PURGE/S|OUT/S] [SAFE/S] [GUI/S]'lin||lin'1-> YamNet'lin' Procesa a INBOUND mensajes RECIBIDOS en YAM de YamNet'lin'Escribe un recibo y borra mensajes enviados al encontrar'lin'un recibo remitido por otro YamNet.'lin||lin' Si recibe un encode estropeado manda un Resend-Request,'
  Say 'y si recibe un mensaje Resend-Request trata de enviar el'lin'mensaje, previamente enviado, de nuevo a su destinatario.'lin||lin'2-> YamNet SAFE'lin'   No borra ficheros tras procesarlos.'lin||lin'3-> YamNet PURGE'
  Say '   Busca unicamente comprobantes ENVIADOS en el YAM y los borra'lin||lin'4-> YamNet OUT'lin'   Traslada (uuencodea) paquetes de correo y (solo copia) ficheros de'lin'OUTBOUND a su destino por YAM.'lin||lin' >> GUI (al final) Permite al usuario elegir las opciones pulsando un boton.'
 end
 IF Upper(LANG) = 'ENGLISH'
 then do
  say 'Usage:        YamNet [PURGE/S|OUT/S] [SAFE/S] [NOGUI/S]'lin||lin'1-> YamNet'lin' It sends to INBOUND files of messages at INCOMING in YAM received from'lin'one YamNet (YamGate or similar) then writes one receipt. And deletes'lin"the sended messages if finds another YamNet's(or similar) receipts."lin||lin'2-> YamNet SAFE'
  say '   It does NOT deletes any files after process it.'lin||lin'3-> YamNet PURGE'lin'   Only search SENT receipts in YAM and delete it'lin||lin'4-> YamNet OUT'lin'   Move (uuencode) mail bundles & files(only copy) from OUTBOUND'lin'  to his destination using YAM.'lin||lin' >> NOGUI (at the end) Says to program do not do questions to user.'
 end
 EXIT
end

if purge = 1 & safe = 1
then do
 IF Upper(LANG) = 'ESPAÑOL' then Say 'ERROR: No pueden usarse los argumentos PURGE y SAFE simultaneamente.'
 IF Upper(LANG) = 'ENGLISH' then Say 'ERROR: Cannot be used PURGE & SAFE arguments at same time.'
 EXIT
end

if nogui = 1
then do
 address command('run >NIL: <NIL: YNetGUI')
 EXIT
end

Call Textos('!' , 'YamNet V3.07 Empezando a procesar' , 'YamNet V3.07 Starting to process')

if exists(TEMP'YamNet.SAFE')
then do
 deteta = 1
 Call Textos('#' , 'Fichero ['TEMP'YamNet.SAFE] detectado!','['TEMP'YamNet.SAFE] file detected!')
 Call SubTextos('borralo antes de ejecutar YamNet' , 'Delete it befere running YamNet')
 Call AnteSalir
 EXIT
end

IF YAMCHECK = 1
then do
 IF SHOW('Ports','YAM')
 THEN DO
  ELYAM = 'Tareauno'
  Call Tareauno
  TRASTUNO:
 end
 IF ~SHOW('Ports','YAM')
 THEN DO
  Address Command('Run <NIL: >NIL: YAM:YAM')
  Address Command('WaitForPort YAM')
 END
 if exists('env:YamCheck')
 then do
  ELYAM = 'Tareados'
  Call Tareados
  TRASTDOS:
 end
end
IF YAMCHECK = 0
then do
 IF ~SHOW('Ports','YAM')
 THEN DO
  Address Command('Run <NIL: >NIL: YAM:YAM NOCHECK')
  Address Command('WaitForPort YAM')
 END
end

ADDRESS YAM

if purge = 1
then do
 ELYAM = 'Infierno'
 Call INFIERNO
SIGUINFER:
 Call Borrados
 Exit
end

if Fuera = 1
then do
 Call SOLOFUERA
 TRASLO:
 Call Borrados
 EXIT
end
ELYAM = 'Observin'
Call OBSERVIN
TRASOBSER:
If YamCheck = 1
then do
 if exists('env:YamCheck')
 then do
  mailsendall

  setfolder 1
  ope = 0
  do until ope = 1
   getfolderinfo MAX
   ele = RESULT
   if ele = 0 then ope = 1
  end
  Call Delete('ENV:YamCheck')
 end
end
if purgy = 1 then Call INFIERNO
if borros = 1 then call borrados
Call AnteSalir
EXIT

 Tareauno:
  SIGNAL ON SYNTAX
  mailcheck
  perel = RESULT
  SIGNAL OFF SYNTAX
  if perel = -1
  then do
   call Textos('#' , 'YAMCHECK configurado sin estar conectado!' , 'YAMCHECK is configured with NO connection')
   Call Textos('!' , 'ABORTANDO!!' , 'ABORTING!!')   
   Call AnteSalir
   EXIT
  end
  call delay(100)
 RETURN
 EXIT

 Tareados:
  SIGNAL ON SYNTAX
  mailsendall
  SIGNAL OFF SYNTAX
  CALL Delete('ENV:YamCheck')
 RETURN
 EXIT

OBSERVIN:

 SIGNAL ON SYNTAX
 setfolder 0
 SIGNAL OFF SYNTAX
 GetFolderInfo MAX
 datos = RESULT

 Do li=0 to datos-1
  nohacer = 0
  setfolder 0
  SetMail li
  GetMailInfo SUB
  subje = RESULT
  GetMailInfo FRO
  Vienede = RESULT
  lared = ''
  e = 0
  mir = 0
  do until e = 1
   mir = mir + 1
   if word(subje,1) = word(SUBJ.mir,1)
   then do
    lared = subje
    tadon = SUBZ.mir
    e = 1
   end
   if mir = zonas then e = 1
  end
  if lared = ''
  then do
   IF LOGLEV = 1 | LOGLEV = 4
   then do
    IF LANG = 'ESPAÑOL' then say ' - 'date()' 'time()'  Observando e-mail de: 'left(vienede' - 'subje,26)
    IF LANG = 'ENGLISH' then say ' - 'date()' 'time()'  Checking e-mail from: 'left(vienede' - 'subje,26)
   end
   IF LOGLEV = 2 | LOGLEV = 4
   then do
    IF LANG = 'ESPAÑOL' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Observando e-mail de: 'vienede' - 'subje'"')
    IF LANG = 'ENGLISH' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Checking e-mail from: 'vienede' - 'subje'"')
   end
  end
  if lared ~= ''
  then do
   IF LOGLEV = 1 | LOGLEV = 4
   then do
    IF LANG = 'ESPAÑOL' then say ' - 'date()' 'time()'  Observando e-mail de: 'vienede' - 'word(subje,1)' [42;31m'word(subje,2)'[0m 'subword(subje,3)
    IF LANG = 'ENGLISH' then say ' - 'date()' 'time()'  Checking e-mail from: 'vienede' - 'word(subje,1)' [42;31m'word(subje,2)'[0m 'subword(subje,3)
   end
   IF LOGLEV = 2 | LOGLEV = 4
   then do
    IF LANG = 'ESPAÑOL' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Observando e-mail de: 'vienede' - 'subje'"')
    IF LANG = 'ENGLISH' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Checking e-mail from: 'vienede' - 'subje'"')
   end

   Call SACALIN
  end
  if left(subje,15) = 'Resend Request:' then Call Reenviacepta
 end
 Call Delete(TEMP'compyam')

RETURN

EXIT

SACALIN:

 Call Textos('>' , 'Detectado mensaje para mover binario' , 'Message detected to move binary file')
 Call SUBTextos('a 'INBO' desde: 'word(lared,1) , 'to 'INBO' from: 'word(lared,1))
 GetMailInfo FIL
 fichero = RESULT
 if exists(fichero)
 then do 
  if words(subje) = 3 then Call YAMUDT
  if words(subje) = 4 then call YAMING
  if words(subje) ~= 3 & words(subje) ~= 4
  then do
   Call Textos('!' , 'Mensaje con SUBJECT configurado pero sin correo' , 'Message with configured SUBJECT but without mail')
  end
 end

RETURN

YAMING:

if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
if ~exists(TEMP'YamNet') then Call Makedir(TEMP'YamNet')
dirname = TEMP'YamNet'
olddir = pragma('d', dirname)


IF word(subje,4) = 'FSCODE'
then do
 Call MAXTextos('%' , 'Intentandolo con FSCode' , 'Trying it with FSCode')
 CALL DEMAILEA
 Address Command('echo >'TEMP'yach `c:FSCODE 'fichero'`')
 Call pragma('d', olddir)
 call open('tyac',TEMP'yach','R')
 lalalala = readln('tyac')
 call close('tyac')
 call delete(TEMP'yach')
 if right(lalalala,13) = 'no start line'
 then do
  if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
 end
end


if word(subje,4) = 'MIME'
then do
 Call MAXTextos('%' , 'Intentandolo con MIME' , 'Trying it with MIME')
 CALL DEMAILEA
 Address Command('base64decode >'TEMP'yare 'fichero' 'TEMP'yamnet')
 Call pragma('d', olddir)
 Call open('yare',TEMP'yare','R')
 nuevo = 0
 larespu = readln('yare')
 if word(larespu,2) = 'bytes' then nuevo = 1
 if larespu = 'No filename found in MIME header' then nuevo = 0
 Call Close('yare')
 Call Delete(TEMP'Yare')
 if nuevo = 0 then if ~exists(TEMP'yamnet/'word(subje,2)) THEN nuevo = 1
end

if word(subje,4) = 'PGP'
then do
 if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
 Call Makedir(TEMP'YamNet')
 dirname = TEMP'YamNet'
 olddir = pragma('d', dirname)
 Call PREPEGEPE
 CALL DEMAILEA
 Address Command(elppa'PGP -p >nil: 'fichero)
 elopo = RC
 Call pragma('d', olddir)
 nohacer = 0
 if elopo ~= 0 then nohacer = 1
end

if WORD(subje,4) = 'UUIN'
then do
 if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
 Call Makedir(TEMP'YamNet')
 Call MAXTextos('%' , 'Intentandolo con UUDECODE()' , 'Trying it with UUDECODE()')
 CALL DEMAILEA
 Address Command('c:UUOUT 'fichero' 'TEMP'YamNet')
 if ~exists(temp'yamnet/'word(subje,2)) THEN nuevo = 1
end

fiche = word(subje,2)

if ~exists(temp'yamnet/'fiche) then call FALLITO
if exists(temp'yamnet/'fiche)
then do
 tnu = CRC32(temp'yamnet/'fiche)
 tama = tnu
 if tnu ~= word(subje,3)
 then do
  CALL FALLITO
 end
 if tnu = word(subje,3)
 then do
  rnomb = fiche
  if exists(INBO||fiche)
  then do
   pi = 0
   parpar = 0
   do until parpar = 1
    pi = pi + 1
    rnomb = fiche||','pi
    if ~exists(INBO||rnomb) then parpar = 1
   end
  end
  Address Command('copy >NIL: 'temp'yamnet/'fiche' 'INBO||rnomb)
  IF LOGLEV = 1 | LOGLEV = 4
  then do
   IF LANG = 'ESPAÑOL' then say ' < 'date()' 'time()'  'INBO'[42;31m'rnomb'[0m ...preparado.'
   IF LANG = 'ENGLISH' then say ' < 'date()' 'time()'  'INBO'[42;31m'rnomb'[0m ...ready.'
  end
  IF LOGLEV = 2 | LOGLEV = 4
  then do
   IF LANG = 'ESPAÑOL' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  'INBO||rnomb' ...preparado."')
   IF LANG = 'ENGLISH' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  'INBO||rnomb' ...preparado."')
  end

  if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
  Call HacerRecibo
  if safe = 0
  then do
   Call Delete(autenfichero)
   Call Delete(fichero)
   borros = 1
  end
  if safe ~= 0
  then do
   Call IniSafe
   Address Command('echo >>'TEMP'YamNet.SAFE "delete 'fichero'"')
   Address Command('echo >>'TEMP'YamNet.SAFE "delete 'autenfichero'"')
  end

  IF LOGLEV = 1 | LOGLEV = 4
  then do
   e = 0
   quienes = ''
   do pompom = 1 to Nodos
    If upper(LADRE.pompom) = upper(word(vienede,1)) & left(ELNO.pompom,length(tadon)) = tadon then quienes = ELNO.pompom
   end
   if quienes = '' then quienes = word(vienede,words(vienede))
   IF UPPER(LANG) = 'ESPAÑOL' then say ' - 'date()' 'time()'  Desde: 'quienes' - CRC32: 'tama
   IF UPPER(LANG) = 'ENGLISH' then say ' - 'date()' 'time()'  From: 'quienes' - CRC32: 'tama
  end
  IF LOGLEV = 2 | LOGLEV = 4
  then do
   if LOGLEV = 2
   then do
    eee = 0
    pompom = 0
    do until eee = 1
     pompom = pompom + 1
     If upper(LADRE.pompom) = upper(word(vienede,1)) & left(ELNO.pompom,length(tadon)) = tadon
     then do
      quienes = ELNO.pompom
      eee = 1
     end
     if pompom = Nodos then eee = 1
    end
   end
   if quienes = '' then quienes = word(vienede,words(vienede))
   IF UPPER(LANG) = 'ESPAÑOL' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Desde: 'quienes' - CRC32: 'tama'"')
   IF UPPER(LANG) = 'ENGLISH' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  From: 'quienes' - CRC32: 'tama'"')
  end
 end
end

RETURN

PREPEGEPE:

 elppa = ''
 Address Command('which >'TEMP'YamNetPGP PGP')
 if READFILE(TEMP'YamNetPGP','mipgp')
 then do
  if mipgp.0 > 0 then elppa = left(mipgp.1,length(mipgp.1)-3)
  IF mipgp.0 = 0 then elppa = ''
 end
 Call Delete(TEMP'YamNetPGP')
 if exists('env:PGPPATH')
 then do
  call open('ppa','env:pgppath','R')
  elppa = readln('ppa')
  Call Close('ppa')
  if right(elppa,1) ~= ':' & right(elppa,1) ~= '/' then elppa = elppa||'/'
 end
 if elppa = '' then Call Textos('#' , 'ERROR: PGP No instalado!!' , 'ERROR: PGP not installed!!')
 Call MAXTextos('%' , 'Intentandolo con PGP' , 'Trying it with PGP')
RETURN

EXIT

BORRADOS:

if borros = 1
then do
 Setfolder 0
 mailupdate
 Setfolder 2
 mailupdate
 If YamCheck = 1
 then do
  if exists('env:YamCheck')
  then do
   ELYAM = 'Yacheche'
   Yacheche:
   SIGNAL ON SYNTAX
   mailsendall
   SIGNAL OFF SYNTAX
   setfolder 1
   ope = 0
   do until ope = 1
    getfolderinfo MAX
    ele = RESULT
    if ele = 0 then ope =1
   end
   Call Delete('ENV:YamCheck')
  end
 end
end

Call AnteSalir
EXIT

FUERADOR:

 if upper(UUMOD.elgate) = 'UUIN'
 then do
  Call MRENOP
  elasci = pakter'.uaa'
  Address Command('delete >nil: t:YamOut ALL QUIET NOREQ FORCE')
  Call Makedir('t:YamOut')
  Address Command('copy >NIL: 'pakter' 'renpakter)
  If UUENCODE(renpakter,pakter,,'S') Then Call Lasvaris
  nohayfallos = 0
  if exists(elasci)
  then do
   nohayfallos = 1
   Address Command('echo >>'elasci' " "')
   if LANG = 'ESPAÑOL' then Address Command('echo >>'elasci' "--- Generado con YamNet V3.07 - Alfredo Soro (03 Sep 96 - 20:50)"')
   if LANG = 'ENGLISH' then Address Command('echo >>'elasci' "--- Generated with YamNet V3.07 - by Alfredo Soro (03 Sep 96 - 20:50)"')
   if LANG = 'ESPAÑOL' then Address Command('echo >t:joi "Correo de la Red: 'SUBNO.elgate'"')
   if LANG = 'ENGLISH' then Address Command('echo >t:joi "Mail from the net: 'SUBNO.elgate'"')
   Address Command('echo >>t:joi " "')
   Address Command('Join t:joi 'elasci' AS=t:joined')
   Call Delete('t:joi')
   Address Command('copy t:joined 'elasci' QUIET')
   Call Delete('t:joined')
  end
 end

 if upper(UUMOD.elgate) = 'MIME'
 then do
  Call MRENOP
  elasci = pakter'.mime'
  Address Command('delete >nil: t:YamOut ALL QUIET NOREQ FORCE')
  Call Makedir('t:YamOut')
  Address Command('copy >NIL: 'pakter' 'renpakter)
  Address Command('base64encode >t:nore 'renpakter' 'pakter'.mime')
  Call Open('nore','T:nore','R')
  nosenco = readln('nore')
  Call Close('nore')
  Call Delete('t:nore')
  if word(nosenco,2) = 'bytes' then Call LasVaris
  nohayfallos = 0
  if exists(elasci)
  then do
   nohayfallos = 1
   Address Command('echo >>'elasci' " "')
   if LANG = 'ESPAÑOL' then Address Command('echo >>'elasci' "--- Generado con YamNet V3.07 - Alfredo Soro (03 Sep 96 - 20:50)"')
   if LANG = 'ENGLISH' then Address Command('echo >>'elasci' "--- Generated with YamNet V3.07 - by Alfredo Soro (03 Sep 96 - 20:50)"')
   if LANG = 'ESPAÑOL' then Address Command('echo >t:joi "Correo de la Red: 'SUBNO.elgate'"')
   if LANG = 'ENGLISH' then Address Command('echo >t:joi "Mail from the net: 'SUBNO.elgate'"')
   Address Command('echo >>t:joi " "')
   Address Command('Join t:joi 'elasci' AS=t:joined')
   Call Delete('t:joi')
   Address Command('copy t:joined 'elasci' QUIET')
   Call Delete('t:joined')
  end
 end

 if upper(UUMOD.elgate) = 'FSCODE'
 then do
  Call MRENOP
  elasci = pakter'.asc'
  Address Command('delete >nil: t:YamOut ALL QUIET NOREQ FORCE')
  Address Command('makedir >NIL: t:YamOut')
  Address Command('copy >NIL: 'pakter' 'renpakter)
  Address Command('c:fscode 'renpakter' 'elasci' E')
  Call Lasvaris
  nohayfallos = 0
  if exists(elasci)
  then do
   nohayfallos = 1
   Address Command('echo >>'elasci' " "')
   if LANG = 'ESPAÑOL' then Address Command('echo >>'elasci' "--- Generado con YamNet V3.07 - Alfredo Soro (03 Sep 96 - 20:50)"')
   if LANG = 'ENGLISH' then Address Command('echo >>'elasci' "--- Generated with YamNet V3.07 - by Alfredo Soro (03 Sep 96 - 20:50)"')
   if LANG = 'ESPAÑOL' then Address Command('echo >t:joi "Correo de la Red: 'SUBNO.elgate'"')
   if LANG = 'ENGLISH' then Address Command('echo >t:joi "Mail from the net: 'SUBNO.elgate'"')
   Address Command('echo >>t:joi " "')
   Address Command('Join t:joi 'elasci' AS=t:joined')
   Call Delete('t:joi')
   Address Command('copy t:joined 'elasci' QUIET')
   Call Delete('t:joined')
  end
 end

 if upper(UUMOD.elgate) = 'PGP'
 then do
  Address Command('delete >NIL: T:YamOut ALL QUIET NOREQ FORCE')
  Address Command('makedir >NIL: t:YamOut')
  Call MRENOP
  elasci = renpakter'.asc'
  if exists('env:PGPPATH')
  then do
   call open('ppa','env:pgppath','R')
   elppa = readln('ppa')
   Call Close('ppa')
   if right(elppa,1) ~= ':' & right(elppa,1) ~= '/' then elppa = elppa||'/'
   if LANG='ESPAÑOL' then Address Command(elppa'PGP >NIL: -ea "+comment=Correo de la Red: 'SUBNO.elgate'" 'renpakter' 'TOPGP.elgate)
   if LANG='ENGLISH' then Address Command(elppa'PGP >NIL: -ea "+comment=Mail from the net: 'SUBNO.elgate'" 'renpakter' 'TOPGP.elgate)
   Call Lasvaris
  end
  if ~exists('env:PGPPATH')
  then do
   if LANG='ESPAÑOL' then Address Command('PGP >NIL: -ea "+comment=Correo de la Red: 'SUBNO.elgate'" 'renpakter' 'TOPGP.elgate)
   if LANG='ENGLISH' then Address Command('PGP >NIL: -ea "+comment=Mail from the net: 'SUBNO.elgate'" 'renpakter' 'TOPGP.elgate)
   Call Lasvaris
  end
  nohayfallos = 0
  if exists(elasci)
  then do
   nohayfallos = 1
   Address Command('echo >>'elasci' "&end 'elrenom' 'elcerr'"')
   Address Command('echo >>'elasci' " "')
   if LANG = 'ESPAÑOL' then Address Command('echo >>'elasci' "--- Generado con YamNet V3.07 - Alfredo Soro (03 Sep 96 - 20:50)"')
   if LANG = 'ENGLISH' then Address Command('echo >>'elasci' "--- Generated with YamNet V3.07 - by Alfredo Soro (03 Sep 96 - 20:50)"')
  end
 end

 if nohayfallos = 1
 then do
  elmodote = upper(UUMOD.elgate)
  if elmodote = 'UUIN' then elmodote = 'UUIN'
  writemailto LADRE.elgate
  'writesubject "'SUBNO.elgate' 'elrenom' 'elcerr' 'elmodote'"'
  writeletter elasci
  'writeattach ""'
  writequeue
  Address Command('ECHO >ENV:YAMCHECK "MAIL ready to LAUNCH"')
  Call Delete(elasci)
  Address Command('delete >NIL: t:YamOut ALL QUIET NOREQ FORCE')

  call secumita

  IF LOGLEV = 1 | LOGLEV = 4
  then do
   IF LANG = 'ESPAÑOL' then say ' - 'date()' 'time()'  Enviado binario de: 'elsecuta' bytes. A: 'ELNO.elgate
   IF LANG = 'ENGLISH' then say ' - 'date()' 'time()'  Binary sent of: 'elsecuta' bytes. To: 'ELNO.elgate
  end
  IF LOGLEV = 2 | LOGLEV = 4
  then do
   IF LANG = 'ESPAÑOL' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Enviado binario de: 'elsecuta' bytes. A: 'ELNO.elgate'"')
   IF LANG = 'ENGLISH' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Binary sent of: 'elsecuta' bytes. To: 'ELNO.elgate'"')
  end

  Call creadat
  address command('echo >>YAM:YamNet.dat "0 'rehoy' 'SUBNO.elgate' 'elrenom' 'elsecuta' 'elcerr' 'LADRE.elgate'"')
  address command('rename "'pakter'" "'OUTBO'YamNet/'crc32(pakter)||filepart(renpakter)'"')
  call textos('+' , 'Almacenado fichero: 'pakter , 'Stored file: 'pakter)
 end
 
RETURN

Say '--->>> Es imposible que este texto pueda mostrarse <<<---'
EXIT

Secumita:

 address command('list >t:secutama 'pakter' LFORMAT=%l')
 call open('stm','T:Secutama','R')
 elsecuta = readln('stm')
 call close('stm')
 Call Delete('t:secutama')

RETURN

creadat:

 if ~exists('YAM:YamNet.dat')
 then do
  if UPPER(LANG) = 'ESPAÑOL' then address command('ECHO >YAM:YamNet.dat "RE-Enviado Fecha Red Fichero Tamaño CRC Destinatario"')
  if UPPER(LANG) = 'ENGLISH' then address command('ECHO >YAM:YamNet.dat "RE-Sent Date Network Filename Size CRC Address"')
 end

RETURN

SOLOFUERA:

 If exists('yam:YamNet.dat')
 then do
  Call textos('o' , 'Examinando antiguedad de ficheros enviados' , 'Watching the age of sent files')
  call open('YNT','Yam:YamNet.dat','R')
  prima = READLN('YNT')
  Drop asecu.
  secuni = 0
  secumbiado = 0
  DO UNTIL EOF('YNT')
   secu = READLN('YNT')
   if secu ~= '' then secuni = secuni + 1
   asecu.secuni = secu
   if datatype(word(secu,2),'N')
   then do
    if rehoy >= word(secu,2)+remanda
    then do
     LADI = word(secu,7)
     SUBREMA = word(secu,3)' 'word(secu,4)' 'word(secu,6)
     remonombre = word(secu,4)
     remocerr = word(secu,6)
     Call REMANFICHERO
     asecu.secuni = word(secu,1)+1' 'date("b")' 'subword(secu,3)
     secumbiado = 1
    end
   end
  end
  Call CLOSE('YNT')
  if secumbiado = 1
  then do
   Call open('YWN','YAM:YamNet.dat','W')
   Call WriteLN('YWN',prima)
   do secusecu = 1 to secuni
    Call WriteLN('YWN',asecu.secusecu)
   end
   Call Close('YWN')
  end
 end

 Do elgate = 1 to Nodos
  call textos('+' , 'Buscando archivos para el nodo: 'ELNODO.elgate , 'Looking for bundles to: 'ELNODO.elgate)
  remiralo = 'flo'
  Call Miralo FLO
  TRASFLO:
  if onlyflo = 0
  then do
   remiralo = 'hlo'
   Call Miralo HLO
   TRASHLO:
   remiralo = 'clo'
   Call Miralo CLO
   TRASCLO: 
   remiralo = 'dlo'
   Call Miralo DLO
   TRASDLO:
   remiralo = 'slo'
  end
  if exists(OUTBO||ELNODO.elgate||'.OUT')
  then do
   pakter = OUTBO||ELNODO.elgate||'.OUT'
   call FUERADOR
  end
  if onlyflo = 0
  then do
   if exists(OUTBO||ELNODO.elgate||'.DUT')
   then do
    pakter = OUTBO||ELNODO.elgate||'.DUT'
    call FUERADOR
   end
   if exists(OUTBO||ELNODO.elgate||'.CUT')
   then do
    pakter = OUTBO||ELNODO.elgate||'.CUT'
    call FUERADOR
   end
   if exists(OUTBO||ELNODO.elgate||'.HUT')
   then do
    pakter = OUTBO||ELNODO.elgate||'.HUT'
    call FUERADOR
   end
  end
 end
RETURN
EXIT

MIRALO:
 parse arg loque
 if exists(OUTBO||ELNODO.elgate||'.'loque)
 then do
  call textos('+' , 'Examinando fichero 'loque' para: 'ELNODO.elgate , 'Scanning 'loque' file for: 'ELNODO.elgate)

  call open('miraflo',OUTBO||ELNODO.elgate||'.'loque,'R')

  do until eof('miraflo')
   lalou = readln('miraflo')
   pakter = lalou
   if length(pakter) < 3 then pakter =''

   if left(lalou,1) = '#' | left(lalou,1) = '^' | left(lalou,1) = '-'
   then do
    pakter = right(lalou,length(lalou)-1)
   end

   if length(pakter) ~= 0 & left(lalou,1) ~= '~'
   then do
    if ~exists(pakter) then call textos('#' , 'No encontrado -'pakter'- ['ELNODO.elgate']' , 'File not found -'pakter'- ['ELNODO.elgate']')
    nohayfallos = 0
    if exists(pakter) & length(pakter) ~= 0
    then do
     if upper(UUMOD.elgate) = 'UUIN'
     then do
      renpakter = pakter
      elasci = pakter'.uaa'
      if left(right(pakter,3),2) = 'MO' | left(right(pakter,3),2) = 'TU' | left(right(pakter,3),2) = 'WE' | left(right(pakter,3),2) = 'TH' | left(right(pakter,3),2) = 'FR' | left(right(pakter,3),2) = 'SA' | left(right(pakter,3),2) = 'SU'
      then do
       if right(pakter,1) = '0' | right(pakter,1) = '1' | right(pakter,1) = '2' | right(pakter,1) = '3' | right(pakter,1) = '4' | right(pakter,1) = '5' | right(pakter,1) = '6' | right(pakter,1) = '7' | right(pakter,1) = '8' | right(pakter,1) = '9'
       then do
        call MRPA
       end
      end
      if exists(TEMP'YamOut') then Address Command('delete >nil: 'TEMP'YamOut ALL QUIET NOREQ FORCE')
      Call Makedir(TEMP'YamOut')
      Address Command('copy >NIL: 'pakter' 'renpakter)
      IF UUENCODE(renpakter,pakter,,'S') then Call Lasvaris
      nohayfallos = 0
      if exists(elasci)
      then do
       nohayfallos = 1
       Address Command('echo >>'elasci' " "')
       Call GESP
       IF UPPER(LANG) = 'ESPAÑOL' then Address Command('echo >t:joi "Correo de la Red: 'SUBNO.elgate'"')
       IF UPPER(LANG) = 'ENGLISH' then Address Command('echo >t:joi "Mail from the net: 'SUBNO.elgate'"')
       Address Command('echo >>t:joi " "')
       Address Command('Join t:joi 'elasci' AS=t:joined')
       Call Delete('t:joi')
       Address Command('copy t:joined 'elasci' QUIET')
       Call Delete('t:joined')
      end
     end


     if upper(UUMOD.elgate) = 'MIME'
     then do
      renpakter = pakter
      elasci = pakter'.mime'
      if left(right(pakter,3),2) = 'MO' | left(right(pakter,3),2) = 'TU' | left(right(pakter,3),2) = 'WE' | left(right(pakter,3),2) = 'TH' | left(right(pakter,3),2) = 'FR' | left(right(pakter,3),2) = 'SA' | left(right(pakter,3),2) = 'SU'
      then do
       if right(pakter,1) = '0' | right(pakter,1) = '1' | right(pakter,1) = '2' | right(pakter,1) = '3' | right(pakter,1) = '4' | right(pakter,1) = '5' | right(pakter,1) = '6' | right(pakter,1) = '7' | right(pakter,1) = '8' | right(pakter,1) = '9'
       then do
        Call MRPA
       end
      end
      if exists(TEMP'YamOut') then Address Command('delete >nil: 'TEMP'YamOut ALL QUIET NOREQ FORCE')
      Call Makedir(TEMP'YamOut')
      Address Command('copy >NIL: 'pakter' 'renpakter)
      Address Command('base64encode >'TEMP'nore 'renpakter' 'pakter'.mime')
      Call Open('nore',TEMP'nore','R')
      nosenco = readln('nore')
      Call Close('nore')
      Call Delete(TEMP'nore')
      if word(nosenco,2) = 'bytes' then Call LasVaris
      nohayfallos = 0
      if exists(elasci)
      then do
       nohayfallos = 1
       Call GESP
       IF UPPER(LANG) = 'ESPAÑOL' then Address Command('echo >t:joi "Correo de la Red: 'SUBNO.elgate'"')
       IF UPPER(LANG) = 'ENGLISH' then Address Command('echo >t:joi "Mail from the net: 'SUBNO.elgate'"')
       Address Command('echo >>t:joi " "')
       Address Command('Join t:joi 'elasci' AS=t:joined')
       Call Delete('t:joi')
       Address Command('copy t:joined 'elasci' QUIET')
       Call Delete('t:joined')
      end
     end


     if upper(UUMOD.elgate) = 'FSCODE'
     then do
      renpakter = pakter
      elasci = pakter'.asc'
      if left(right(pakter,3),2) = 'MO' | left(right(pakter,3),2) = 'TU' | left(right(pakter,3),2) = 'WE' | left(right(pakter,3),2) = 'TH' | left(right(pakter,3),2) = 'FR' | left(right(pakter,3),2) = 'SA' | left(right(pakter,3),2) = 'SU'
      then do
       if right(pakter,1) = '0' | right(pakter,1) = '1' | right(pakter,1) = '2' | right(pakter,1) = '3' | right(pakter,1) = '4' | right(pakter,1) = '5' | right(pakter,1) = '6' | right(pakter,1) = '7' | right(pakter,1) = '8' | right(pakter,1) = '9'
       then do
        CALL MRPA
        elasci = renpakter'.asc'
       end
      end
      if exists(TEMP'YamOut') then Address Command('delete >nil: 'TEMP'YamOut ALL QUIET NOREQ FORCE')
      Address Command('makedir >NIL: 'TEMP'YamOut')
      Address Command('copy >NIL: 'pakter' 'renpakter)
      Address Command('c:fscode 'renpakter' 'elasci' E')
      Call Lasvaris
      nohayfallos = 0
      if exists(elasci)
      then do
       nohayfallos = 1
       Call GESP
       IF UPPER(LANG) = 'ESPAÑOL' then Address Command('echo >t:joi "Correo de la Red: 'SUBNO.elgate'"')
       IF UPPER(LANG) = 'ENGLISH' then Address Command('echo >t:joi "Mail from the net: 'SUBNO.elgate'"')
       Address Command('echo >>t:joi " "')
       Address Command('Join t:joi 'elasci' AS=t:joined')
       Call Delete('t:joi')
       Address Command('copy t:joined 'elasci' QUIET')
       Call Delete('t:joined')
      end
     end

     if upper(UUMOD.elgate) = 'PGP'
     then do
      renpakter = pakter
      elasci = renpakter'.asc'
      if left(right(pakter,3),2) = 'MO' | left(right(pakter,3),2) = 'TU' | left(right(pakter,3),2) = 'WE' | left(right(pakter,3),2) = 'TH' | left(right(pakter,3),2) = 'FR' | left(right(pakter,3),2) = 'SA' | left(right(pakter,3),2) = 'SU'
      then do
       if right(pakter,1) = '0' | right(pakter,1) = '1' | right(pakter,1) = '2' | right(pakter,1) = '3' | right(pakter,1) = '4' | right(pakter,1) = '5' | right(pakter,1) = '6' | right(pakter,1) = '7' | right(pakter,1) = '8' | right(pakter,1) = '9'
       then do
        CALL MRPA
        elasci = renpakter'.asc'
       end
      end
      if exists(TEMP'YamOut') then Address Command('delete >nil: 'TEMP'YamOut ALL QUIET NOREQ FORCE')
      Address Command('makedir >NIL: 'TEMP'YamOut')
      Address Command('copy >NIL: 'pakter' 'renpakter)

      if exists('env:PGPPATH')
      then do
       call open('ppa','env:pgppath','R')
       elppa = readln('ppa')
       Call Close('ppa')
       if right(elppa,1) ~= ':' & right(elppa,1) ~= '/' then elppa = elppa||'/'
       if LANG='ESPAÑOL' then Address Command(elppa'PGP >NIL: -ea "+comment=Correo de la Red: 'SUBNO.elgate'" 'renpakter' 'TOPGP.elgate)
       if LANG='ENGLISH' then Address Command(elppa'PGP >NIL: -ea "+comment=Mail from the net: 'SUBNO.elgate'" 'renpakter' 'TOPGP.elgate)
       Call Lasvaris
      end
      if ~exists('env:PGPPATH')
      then do
       if LANG='ESPAÑOL' then Address Command('PGP >NIL: -ea "+comment=Correo de la Red: 'SUBNO.elgate'" 'renpakter' 'TOPGP.elgate)
       if LANG='ENGLISH' then Address Command('PGP >NIL: -ea "+comment=Mail from the net: 'SUBNO.elgate'" 'renpakter' 'TOPGP.elgate)
       Call Lasvaris
      end
      nohayfallos = 0
      if exists(elasci)
      then do
       nohayfallos = 1
       Address Command('echo >>'elasci' "&end 'elrenom' 'elcerr'"')
       Call GESP
      end
     end

     if nohayfallos = 1
     then do
      elmodote = upper(UUMOD.elgate)
      if elmodote = 'UUIN' then elmodote = 'UUIN'
     Escribello:
      ELYAM = 'Escribello'
      SIGNAL ON SYNTAX
      IF NOHIDE = 0 then HIDE
      MailWrite
      writemailto LADRE.elgate
      SIGNAL OFF SYNTAX
      'writesubject "'SUBNO.elgate' 'elrenom' 'elcerr' 'elmodote'"'
      writeletter elasci
      writequeue
      Address Command('ECHO >ENV:YAMCHECK "MAIL ready to LAUNCH"')
      Call Delete(elasci)
      If exists(TEMP'YamOut') then Address Command('delete >NIL: 'TEMP'YamOut ALL QUIET NOREQ FORCE')

      Call secumita

      IF LOGLEV = 1 | LOGLEV = 4
      then do
       IF UPPER(LANG) = 'ESPAÑOL' then say ' - 'date()' 'time()'  Enviado binario con CRC32: 'elcerr' A: 'ELNO.elgate
       IF UPPER(LANG) = 'ENGLISH' then say ' - 'date()' 'time()'  Binary sent with CRC32: 'elcerr' To: 'ELNO.elgate
      end
      IF LOGLEV = 2 | LOGLEV = 4
      then do
       IF UPPER(LANG) = 'ESPAÑOL' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Enviado binario con CRC32: 'elcerr' A: 'ELNO.elgate'"')
       IF UPPER(LANG) = 'ENGLISH' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Binary sent with CRC32: 'elcerr' To: 'ELNO.elgate'"')
      end

      Call creadat
      address command('echo >>YAM:YamNet.dat "0 'rehoy' 'SUBNO.elgate' 'elrenom' 'elsecuta' 'elcerr' 'LADRE.elgate'"')
      if safe = 0
      then do
       if left(lalou,1) = '#'
       then do
        address command('rename "'pakter'" "'OUTBO'YamNet/'crc32(pakter)||filepart(renpakter)'"')
        Address Command('echo >'pakter' NOLINE')
       end
      end
      if safe ~= 0
      then do
       if left(lalou,1) = '#'
       then do
        call IniSafe
        address command('rename "'pakter'" "'OUTBO'YamNet/'crc32(pakter)||filepart(renpakter)'"')
        Address Command('echo >>'TEMP'YamNet.SAFE "Echo >'pakter' NOLINE"')
       end
      end
      if left(lalou,1) = '^'
      then do
       address command('rename "'pakter'" "'OUTBO'YamNet/'crc32(pakter)||filepart(renpakter)'"')
       Call Textos('+' , 'Almacenado fichero: 'pakter , 'Stored file: 'pakter)
      end

      if left(lalou,1) = '-'
      then do
       address command('rename "'pakter'" "'OUTBO'YamNet/'crc32(pakter)||filepart(renpakter)'"')
      end
     end
    end
   end
   if left(lalou,1) = '~' then Call Textos('#' , 'Fichero 'pakter' marcado en el 'loque' como ya enviado' , 'File 'pakter' marked in 'loque' as already sent')
  end
  call close('miraflo')
  Call Textos('#' , 'Fichero 'OUTBO||ELNODO.elgate||'.'loque' procesado' , 'File 'OUTBO||ELNODO.elgate||'.'loque' processed')

  if safe = 0
  then do
   Call Delete(OUTBO||ELNODO.elgate||'.'loque)
   Call Textos('#' , 'Fichero 'OUTBO||ELNODO.elgate||'.'loque' eliminado' , 'File 'OUTBO||ELNODO.elgate||'.'loque' deleted')
  end
  if safe ~= 0
  then do
   Call IniSafe
   Address Command('echo >>'TEMP'YamNet.SAFE "delete 'OUTBO||ELNODO.elgate||'.'loque'"')
  end

 end
return

EXIT


GESP:

 Address Command('echo >>'elasci' "-- "')
 Address Command('echo >>'elasci' ""')
 IF upper(LANG) = 'ESPAÑOL' then Address Command('echo >>'elasci' "--- Generado con YamNet V3.07 - Alfredo Soro (31 Dic 96 - 04:00)"')
 IF upper(LANG) = 'ENGLISH' then Address Command('echo >>'elasci' "--- Generated with YamNet V3.07 - by Alfredo Soro (31 Dic 96 - 04:00)"')

RETURN

MRPA:

 Call RPAK
 if exists(OUTBO'YamNet/'crc32(pakter)||filepart(renpakter))
 then do
  do until ~exists(OUTBO'YamNet/'crc32(pakter)||filepart(renpakter))
   Call RPAK
  end
 end

RETURN

MRENOP:

 Call RENOPKT
 if exists(OUTBO'YamNet/'crc32(pakter)||filepart(renpakter))
 then do
  do until ~exists(OUTBO'YamNet/'crc32(pakter)||filepart(renpakter))
   Call RENOPKT
  end
 end

RETURN

RPAK:
Call RENOP
renpakter = renpakter||'.'right(pakter,3)
RETURN

RENOPKT:
Call RENOP
renpakter = renpakter'.PKT'
RETURN

RENOP:
renpakter = TEMP'YamOut/'d2x(right(time('s'),1)+rand(0,6))||d2x(rand(0,15))||d2x(right(date(d),1)+rand(0,6))||d2x(rand(0,15))||d2x(right(date(d),1)+rand(0,14-(right(date(d),1))))||d2x(left(time('e'),1)+rand(0,6))||d2x(left(right(time('e'),2),1)+rand(0,6))||d2x(right(time('e'),1)+rand(0,6))
RETURN

EXIT


PREFS:

Say ''
Say ' Activating PREFS routine - Activando rutina de PREFERENCIAS'
Say ''

LENPREFS:

primera = rtezrequest("Language     Idioma", " ENGLISH | ESPAÑOL ", '     YamNet   Prefs')

if primera = 0 then LANG = 'Español'
if primera = 1 then LANG = 'English'

RETURN

LOGFPREFS:

 IF Upper(LANG) = 'ESPAÑOL' then directo = '¿Fichero de reporte/log para YamNet?'
 IF Upper(LANG) = 'ENGLISH' then directo = 'Logfile for YamNet?'
 segunda = rtfilerequest("ram:", "YamNet.log", directo)

 if segunda = '' then segunda = 'Ram:YamNet.log'
 LOGFIL = segunda

RETURN

REMAPREFS:

 If Upper(LANG) = 'ESPAÑOL' then remanca = '¿Cuantos días hay que esperar respuesta'||NL||'     antes de RE-ENVIAR un archivo?'
 If Upper(LANG) = 'ENGLISH' then remanca = '¿How many days must to wait for an answer'||NL'      before RE-SEND a bundle-file?'
 remanda = 0
 do until remanda > 0
  remanda = rtgetlong(15,remanca," YamNet PREFS V3.07")
 end
RETURN

REBOPREFS:

 If Upper(LANG) = 'ESPAÑOL' then remanca = '¿Cuantos días hay que esperar respuesta'||NL||'      antes de BORRAR un archivo?'
 If Upper(LANG) = 'ENGLISH' then remanca = '¿How many days must to wait for an answer'||NL'     before DELETE a bundle-file?'
 reborra = 'F'
 do until datatype(reborra,'N')
  reborra = rtgetlong(28,remanca," YamNet PREFS V3.07")
 end

RETURN

INPREFS:

 IF Upper(LANG) = 'ESPAÑOL' then mensa = '¿Directorio Inbound?'
 IF Upper(LANG) = 'ENGLISH' then mensa = 'Inbound directory?'
 conti = 0
 do until conti = 1
  cuarta = rtgetstring("Inbound:",mensa," YamNet PREFS V3.07")
  if cuarta ~= '' then if exists(cuarta) then conti = 1
  if conti ~= 1
  then do
   IF Upper(LANG) = 'ESPAÑOL' then mensa = 'Directorio no asignado o creado. ¿Directorio Inbound?'
   IF Upper(LANG) = 'ENGLISH' then mensa = 'Directory not assigned or created. Inbound Directory?'
  end
 end
 INBO = cuarta
 inb = INBO'/'
 if right(INBO,1) = ':' then inb = INBO
 if right(INBO,1) = '/' then inb = INBO
 INBO = inb

RETURN

OUTPREFS:

 IF Upper(LANG) = 'ESPAÑOL' then mensa = '¿Directorio Outbound?'
 IF Upper(LANG) = 'ENGLISH' then mensa = 'Outbound directory?'
 conti = 0
 do until conti = 1
  quinta = rtgetstring("Outbound:",mensa," YamNet PREFS V3.07")
  if quinta ~= '' then if exists(quinta) then conti = 1
  if conti ~= 1
  then do
   IF Upper(LANG) = 'ESPAÑOL' then mensa = 'Directorio no asignado o creado. ¿Directorio Outbound?'
   IF Upper(LANG) = 'ENGLISH' then mensa = 'Directory not assigned or created. Outbound Directory?'
  end
 end
 OUTBO = quinta
 outb = OUTBO'/'
 if right(OUTBO,1) = ':' then outb = OUTBO
 if right(OUTBO,1) = '/' then outb = OUTBO
 OUTBO = outb

RETURN

TEMPPREFS:

 IF Upper(LANG) = 'ESPAÑOL' then mensa = '¿Directorio temporal? P.Ej: T:'||NL||'o Dh1:t/ con poca memoria'
 IF Upper(LANG) = 'ENGLISH' then mensa = 'Temporal directory? p.e: T:'||NL||'or DH1:T/ if you have low memory'
 conti = 0
 do until conti = 1
  nosecuarta = rtgetstring("T:",mensa," YamNet PREFS V3.07")
  if nosecuarta ~= '' then if exists(nosecuarta) then conti = 1
  if conti ~= 1
  then do
   IF Upper(LANG) = 'ESPAÑOL' then mensa = 'Directorio no asignado o creado. ¿Directorio temporal?'
   IF Upper(LANG) = 'ENGLISH' then mensa = 'Directory not assigned or created. Temporal directory?'
  end
 end
 TEMP = nosecuarta
 tem = TEMP'/'
 if right(TEMP,1) = ':' then TEm = TEMP
 if right(TEMP,1) = '/' then TEm = TEMP
 TEMP = TEm

RETURN

LOGLPREFS:

 IF Upper(LANG) = 'ESPAÑOL'
 then do
  sexta = rtezrequest("Nivel de información en Ventana/Fichero?", "Normal-V.|Normal-F.|Parcial-V.yF.|Total-V.yF.|Ninguna", ' YamNet PREFS V3.07')
  LOGLEV = sexta
 end

 IF Upper(LANG) = 'ENGLISH'
 then do
  sexta = rtezrequest("Information level in _W_indow/log_F_ile?", "Normal-W.|Normal-F.|Partial-W.&F.|Total-W.&F.|None", ' YamNet PREFS V3.07')
  LOGLEV = sexta
 end

RETURN

PGPPREFS:

 if ~exists('env:PGPPASS')
 then do
  IF Upper(LANG) = 'ENGLISH'
  then do
   septima = rtezrequest("Do you pretend to receive PGPed mails?", "Yes|No", ' YamNet PREFS V3.07')
   if septima = '1'
   then do
    saldelbucle = 0
    do until saldelbucle = 1
     octava = rtgetstring("a partridge in a pear tree","Type in your PGP passphrase"," PGP PREFS")
     novena = rtgetstring("","Re-Type your PGP passphrase, again."," PGP PREFS")
     if octava = novena
     then do
      address command('setenv PGPPASS 'octava)
      address command('copy >NIL: env:PGPPASS envarc: CLONE')
      saldelbucle = 1
     end
    end
   end
  end

  IF Upper(LANG) = 'ESPAÑOL'
  then do
   septima = rtezrequest("Pretendes recibir correo PGPeado?", "Si|No", ' YamNet PREFS V3.07')
   if septima = '1'
   then do
    saldelbucle = 0
    do until saldelbucle = 1
     octava = rtgetstring("dabale arroz a la zorra el abad","Teclea dentro tu frase clave de PGP"," PGP PREFS")
     novena = rtgetstring("","Teclea tu frase clave de PGP, de nuevo."," PGP PREFS")
     if octava = novena
     then do
      address command('setenv PGPPASS 'octava)
      address command('copy >NIL: env:PGPPASS envarc: CLONE')
      saldelbucle = 1
     end
    end
   end
  end
 end

RETURN

NODPREFS:

 saldremos = 0
 DO until saldremos = 1

  IF Upper(LANG) = 'ENGLISH' then mensa = 'Type in fido-ZONE number for point/node'||NL||' to receive mails from. (p.e.: 2 [of 2:345/67.0])'
  IF Upper(LANG) = 'ESPAÑOL' then mensa = 'Teclea el numero de ZONA-fido del punto/nodo del que'||NL||' recibir correo. (p.ej.: 2 [de 2:345/67.0])'
  IF Upper(LANG) = 'ESPAÑOL' then ies = 'Vacio para terminar!'
  IF Upper(LANG) = 'ENGLISH' then ies = 'Empty to end!'
  ultimo = rtgetlong(,mensa,' YamNet PREFS V3.07 ['ies']')
  if ultimo = '' then saldremos = 1
  if saldremos ~= 1
  then do
   exiss = 0
   do ele = 1 to zonas
    if SUBZ.ele = ultimo then exiss = 1
   end
   if exiss = 0
   then do
    zonas = zonas + 1
    SUBZ.zonas = ultimo
    IF Upper(LANG) = 'ENGLISH' then cualzo = 'Subject for mails of 'ultimo' Network? [p.e.: FidoE-Mail]'
    IF Upper(LANG) = 'ESPAÑOL' then cualzo = 'Subject para mensajes de la red 'ultimo'? [P.ej.: FidoE-Mail]'
    eltemz = ''
    do until eltemz ~= ''
     eltemz = rtgetstring("",cualzo," YamNet PREFS V3.07")
    end
    SUBJ.zonas = eltemz
   end

   elnez = ''
   do until elnez ~= ''
    elnez = rtgetlong(,'Network? (p.e: 345 [2:345/67.0]'," YamNet PREFS V3.07")
   end

   oligoelemento = ''
   IF Upper(LANG) = 'ESPAÑOL' then nodesp = '¿Nodo? (p.ej.: 67 [en 2:345/67.0]'
   IF Upper(LANG) = 'ENGLISH' then nodesp = 'Node? (p.e.: 67 [from 2:345/67.0]'
   do until oligoelemento ~= ''
    oligoelemento = rtgetlong(,nodesp," YamNet PREFS V3.07")
   end

   xal = 0
   plusis = 0

   do until xal = 1
    IF Upper(LANG) = 'ENGLISH' then puesp = 'Point Number for 'ultimo':'elnez'/'oligoelemento'? [Empty to end]'
    IF Upper(LANG) = 'ESPAÑOL' then puesp = '¿Número de punto para 'ultimo':'elnez'/'oligoelemento'? [Vacio para terminar]'
    raspuntin = rtgetlong(,puesp," YamNet PREFS V3.07")

    if raspuntin = ''
    then do
     xal = 1
     if plusis = 0 then raspuntin = 0
    end

    if raspuntin ~= ''
    then do
     plusis = plusis + 1
     nodos = nodos + 1
     ELNO.nodos = ultimo'.'elnez'.'oligoelemento'.'raspuntin
     IF Upper(LANG) = 'ESPAÑOL' then nomesp = '¿Dirección de email de 'ultimo':'elnez'/'oligoelemento'.'raspuntin'? p.ej.: asoro@redestb.es'
     IF Upper(LANG) = 'ENGLISH' then nomesp = ultimo':'elnez'/'oligoelemento'.'raspuntin' e-mail address? p.e.: asoro@redestb.es'
     LADRE.nodos = rtgetstring("",nomesp,' YamNet PREFS V3.07')
     CALL MODPREFS
    end
   end
  end
 end

RETURN

ONLYFLOPREFS:

 IF Upper(LANG) = 'ESPAÑOL'
 then do
  lonles = 'Procesar solo ficheros FLO[Normal], o procesar tambien'||NL||'ficheros HLO[Puntos/Downlinks], DLO[Directos] y CLOs[Crash]?'
  reonls = 'Todo|Solo los FLO'
 end
 IF Upper(LANG) = 'ENGLISH'
 then do
  lonles = 'Process only FLO[Normal] files?, or process also'||NL||'HLO[Points/Downlinks], DLO[Direct] & CLOs[Crash] files?'
  reonls = 'All|Only FLO files'
 end

 onlyfl = rtezrequest(lonles,reonls,' YamNet PREFS V3.07')

 if onlyfl = 0 then onlyflo = 1
 if onlyfl = 1 then onlyflo = 0

RETURN

NOHIDEPREFS:

 IF Upper(LANG) = 'ESPAÑOL'
 then do
  yales = '¿Ocultar YAM mientras YamNet escribe?'
  reyac = 'No|Si'
 end
 IF Upper(LANG) = 'ENGLISH'
 then do
  yales = 'Hide YAM while YamNet is writing'
  reyac = 'No|Yes'
 end

 yamche = rtezrequest(yales,reyac,' YamNet PREFS V3.07')

 if yamche = 0 then NOHIDE = 1
 if yamche = 1 then NOHIDE = 0

RETURN



YAMCHECKPREFS:

 IF Upper(LANG) = 'ESPAÑOL'
 then do
  yales = '¿Recoger y enviar correo al ejecutar YamNet?'||NL||'[Se debe estar conectado a internet antes de ejecutarlo]'
  reyac = 'No|Si'
 end
 IF Upper(LANG) = 'ENGLISH'
 then do
  yales = 'Send & Get e-mail when YamNet is executed?'||NL||'[Must be conected to internet before execute it]'
  reyac = 'No|Yes'
 end

 yamche = rtezrequest(yales,reyac,' YamNet PREFS V3.07')

 if yamche = 0 then yamcheck = 1
 if yamche = 1 then yamcheck = 0

RETURN

PURGEPREFS:

 IF Upper(LANG) = 'ESPAÑOL'
 then do
  purles = '¿Borrar siempre mensajes viejos generados por YamNet?'
  repur = 'SI|No'
 end
 IF Upper(LANG) = 'ENGLISH'
 then do
  purles = 'Always delete old messages generated by YamNet?'
  repur = 'YES|No'
 end

 purg = rtezrequest(purles,repur,' YamNet PREFS V3.07')

 PURGY = purg

RETURN

GRABACFG:

 Call open('ycg','S:YamNet.cfg','W')
 CALL WriteLN('ycg', ";YamNet V3.07 config")

 do el = 1 to nodos
  if UUMOD.el = 'PGP' then CALL WriteLN('ycg','NODO = 'ELNO.el' 'LADRE.el' 'UUMOD.el' 'TOPGP.el)
  if UUMOD.el ~= 'PGP' then CALL WriteLN('ycg','NODO = 'ELNO.el' 'LADRE.el' 'UUMOD.el)
 end

 do sel = 1 to zonas
  CALL WriteLN('ycg','SUBZONA = 'SUBZ.sel' 'SUBJ.sel)
 end

 CALL WriteLN('ycg','INBOUND = 'INBO)
 CALL WriteLN('ycg','OUTBOUND = 'OUTBO)
 CALL WriteLN('ycg','LANG = 'LANG)
 CALL WriteLN('ycg','LOG = 'LOGFIL)
 CALL WriteLN('ycg','TEMP = 'TEMP)
 CALL WriteLN('ycg','LOGLEVEL = 'LOGLEV)
 CALL WriteLN('ycg','RESEND = 'remanda)
 CALL WriteLN('ycg','DELETE = 'reborra)
 IF ONLYFLO = 1 then CALL WriteLN('ycg','ONLYFLO')
 IF NOHIDE = 1 then CALL WriteLN('ycf','NOHIDE')
 IF YAMCHECK = 1 then CALL WriteLN('ycg','YAMCHECK')
 IF PURGY = 1 then CALL WriteLN('ycg','PURGE')
 Call CLOSE('ycg')

RETURN

Say 'SI SALE ESTO, HAY UN ERROR'

EXIT

Textos:
 parse arg signo , espan , engli
 sdt = ' 'signo' 'date()' 'time()'  '
 IF LOGLEV = 1 | LOGLEV = 3 | LOGLEV = 4
 then do
  if LANG='ESPAÑOL' Then Say sdt||espan
  if LANG='ENGLISH' Then Say sdt||engli
 end
 IF LOGLEV = 2 | LOGLEV = 3 | LOGLEV = 4
 then do
  if LANG='ESPAÑOL' Then Address Command('echo >>t:logyamnet.tmp "'sdt||espan'"')
  if LANG='ENGLISH' Then Address Command('echo >>t:logyamnet.tmp "'sdt||engli'"')
 end
RETURN

EXIT

SUBTextos:
 parse arg espan , engli
 IF LOGLEV = 1 | LOGLEV = 3 | LOGLEV = 4
 then do
  if LANG='ESPAÑOL' Then Say '                          'espan
  if LANG='ENGLISH' Then Say '                          'engli
 end
 IF LOGLEV = 2 | LOGLEV = 3 | LOGLEV = 4
 then do
  if LANG='ESPAÑOL' Then Address Command('echo >>t:logyamnet.tmp "                        'espan'"')
  if LANG='ENGLISH' Then Address Command('echo >>t:logyamnet.tmp "                        'engli'"')
 end
RETURN

EXIT

MAXTextos:
 parse arg signo , espan , engli
 sdt = ' 'signo' 'date()' 'time()'  '
 IF LOGLEV = 1 | LOGLEV = 4
 then do
  if LANG='ESPAÑOL' Then Say sdt||espan
  if LANG='ENGLISH' Then Say sdt||engli
 end
 IF LOGLEV = 2 | LOGLEV = 4
 then do
  if LANG='ESPAÑOL' Then Address Command('echo >>t:logyamnet.tmp "'sdt||espan'"')
  if LANG='ENGLISH' Then Address Command('echo >>t:logyamnet.tmp "'sdt||engli'"')
 end
RETURN

EXIT

MODPREFS:

 IF Upper(LANG) = 'ESPAÑOL' then mesp = '¿Método de codificación para el link: 'ultimo':'elnez'/'oligoelemento'.'raspuntin'?'
 IF Upper(LANG) = 'ENGLISH' then mesp = 'Encode method for link: 'ultimo':'elnez'/'oligoelemento'.'raspuntin'?'
 metodo = rtezrequest(mesp, "MIME|PGP|UUIN|FSCODE", ' YamNet PREFS V3.07')
 if metodo = 1 then UUMOD.nodos = 'MIME'
 if metodo = 2 then UUMOD.nodos = 'PGP'
 if metodo = 3 then UUMOD.nodos = 'UUIN'
 if metodo = 0 then UUMOD.nodos = 'FSCODE'
 IF Upper(LANG) = 'ESPAÑOL' then aquies = '¿Nombre a quien van dirigidos los mensajes PGP del link?'
 IF Upper(LANG) = 'ENGLISH' then aquies = 'Name to use in PGP messages addressed to this link?'
 if metodo = 2 then TOPGP.nodos = '"'rtgetstring("",aquies," YamNet PREFS V3.07")'"'

RETURN

PMODPREFS:

 IF Upper(LANG) = 'ESPAÑOL' then mesp = '¿Método de codificación para el link: 'ELNO.nodos'?'
 IF Upper(LANG) = 'ENGLISH' then mesp = 'Encode method for link: 'ultimo':'elnez'/'oligoelemento'.'raspuntin'?'
 metodo = rtezrequest(mesp, "MIME|PGP|UUIN|FSCODE", ' YamNet PREFS V3.07')
 if metodo = 1 then UUMOD.nodos = 'MIME'
 if metodo = 2 then UUMOD.nodos = 'PGP'
 if metodo = 3 then UUMOD.nodos = 'UUIN'
 if metodo = 0 then UUMOD.nodos = 'FSCODE'
 IF Upper(LANG) = 'ESPAÑOL' then aquies = '¿Nombre a quien van dirigidos los mensajes PGP del link?'
 IF Upper(LANG) = 'ENGLISH' then aquies = 'Name to use in PGP messages addressed to this link?'
 if metodo = 2 then TOPGP.nodos = '"'rtgetstring("",aquies," YamNet PREFS V3.07")'"'

RETURN
EXIT

Lasvaris:

elcerr = CRC32(renpakter)
elrenom = filepart(renpakter)
RETURN

EXIT

AnteSalir:

if exists(temp'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')

if deteta = 0
then do
 If exists(TEMP'YamNet.Safe')
 then do
  if borros = 1
  then do
   elcomando = "echo >>"||TEMP||"YamNet.SAFE Rx 'ADDRESS YAM("
   otro = elcomando'"setfolder 0")'
   Address Command(otro"'")
   elcomando = "echo >>"||TEMP||"YamNet.SAFE Rx 'ADDRESS YAM("
   otro = elcomando'"mailupdate")'
   Address Command(otro"'")
  end
  Address Command('echo >>'TEMP'YamNet.SAFE Run Delete 'TEMP'YamNet.SAFE')
  Call Textos('&' , 'SAFE: ha generado el fichero ['TEMP'YamNet.SAFE]' , 'SAFE: has generated file ['TEMP'YamNet.SAFE]')
  Address Command('type 'TEMP'YamNet.SAFE')
 end
end

Call Textos('!' , 'Proceso terminado.' , 'Process ended.')
Address Command('type >>'LOGFIL' t:logyamnet.tmp')
Call Delete('t:logyamnet.tmp')
RETURN

EXIT

IniSafe:

if ~exists(TEMP'YamNet.SAFE')
then do
 IF UPPER(LANG) = 'ESPAÑOL' then Address Command('echo >'TEMP'YamNet.SAFE ";['TEMP'YamNet.SAFE] - Ejecuta esto antes de volver a usar YamNet"')
 IF UPPER(LANG) = 'ENGLISH' then Address Command('echo >'TEMP'YamNet.SAFE ";['TEMP'YamNet.SAFE] - Execute this before use YamNet again"')
 Address Command('echo >>'TEMP'YamNet.SAFE ""')
 Address Command('echo >>'TEMP'YamNet.SAFE Failat 21')
end
RETURN

EXIT

HacerRecibo:

 IF UPPER(LANG) = 'ESPAÑOL'
 then do
  Address Command('echo >t:compyam "Este mensaje confirma que ha sido"')
  Address Command('echo >>t:compyam "correctamente procesado, el fichero:"')
  Address Command('echo >>t:compyam "'fiche'"')
  Address Command('echo >>t:compyam "CRC32: 'tnu'"')
 end
 IF UPPER(LANG) = 'ENGLISH'
 then do
  Address Command('echo >t:compyam "This message is to confirm that have been"')
  Address Command('echo >>t:compyam "correctly processed, the file:"')
  Address Command('echo >>t:compyam "'fiche'"')
  Address Command('echo >>t:compyam "CRC32: 'tnu'"')
 end
 Address Command('echo >>t:compyam " "')
 Address Command('echo >>t:compyam " YamNet VER: 3.07 by Alfredo Soro (31 Dic 1996 - 04:00)"')
 ADDRESS YAM
 if NOHIDE = 0 then Hide
 MailWrite
 writemailto word(vienede,words(vienede))
 COMPROSUBJE = '"RECIBI: 'word(subje,1)' 'fiche' 'tnu'"'
 'writesubject 'COMPROSUBJE
 writeletter 't:compyam'
 writequeue
 Address Command('ECHO >ENV:YAMCHECK "Receipt(s) Ready to LAUNCH"')
 Call Delete('t:compyam')
RETURN
EXIT

Reenviacepta:

if ~exists('YAM:YamNet.dat')
then do
 Call Textos('X' , 'Petición de RE-ENVIO erronea. YamNet.dat no existe.' , 'RESEND Request error. YamNet.dat not found')
end

if exists('YAM:YamNet.dat')
then do
 rechazo = 1
 anelrre = elrre
 GetMailInfo FIL
 remofichero = RESULT
 GetMailInfo FRO
 removiene = RESULT
 parse var removiene '<'nmcadena'>'
 if nmcadena = '' then nmcadena = removiene
 removiene = nmcadena
 LADI = removiene
 SUBREMA = word(subje,3)' 'word(subje,4)' 'word(subje,6)
 remonombre = word(subje,4)
 recinombre = 'NULL'
 recitama = 'NULL'
 Call Textos('+' , 'Recibida petición de reenvio de: [42;31m'remonombre'[0m' , 'Received resend request of: [42;31m'remonombre'[0m')
 remocerr = word(subje,5)

 Call Open('YND','YAM:YamNet.dat','R')
 prima = readln('YND') 
 drop sesecu.
 sesecunu = 0
 sesecumbi = 0
 do until EOF('YND')
  sesecunu = sesecunu + 1
  nmet = readln('YND')
  sesecu.sesecunu = nmet
  if word(nmet,3) = word(subje,3) & word(nmet,4) = remonombre & word(nmet,6) = remocerr & word(nmet,7) = removiene
  then do
   rechazo = 0
   CALL REMANFICHERO
   sesecu.sesecunu = word(nmet,1)+1' 'date("b")' 'subword(nmet,3)
   sesecumbi = 1
  end 
 end

 Call CLOSE('YND')
 if sesecumbi = 1
 then do
  Call open('YWN','YAM:YamNet.dat','W')
  Call WriteLN('YWN',prima)
  do secusecu = 1 to sesecunu
   if sesecu.secusecu ~= '' then Call WriteLN('YWN',sesecu.secusecu)
  end
  Call Close('YWN')
 end

 if safe = 0
 then do
  Call Delete(remofichero)
  quesera = 1
  borros = 1
  elrre = elrre +1
  recinu.elrre = recio
  Call Textos('-' , 'Petición BORRADA.' , 'Request DELETED.')
 end
 if safe ~= 0
 then do
  Call IniSafe
  Address Command('echo >>'TEMP'YamNet.SAFE "delete 'remofichero'"')
 end
end
if rechazo = 1 then call Textos('#' , 'Imposible Re-Enviar! Fichero original no encontrado' , 'Original file not found. Re-Sending impossible!')
RETURN

EXIT

HazResendReq:

 IF UPPER(LANG) = 'ESPAÑOL'
 then do
  Address Command('echo >t:compyam "Este mensaje avisa de que ha sido"')
  Address Command('echo >>t:compyam "incorrectamente recibido, el fichero:"')
  Address Command('echo >>t:compyam "'word(subje,2)'"')
  Address Command('echo >>t:compyam "CRC32: 'word(subje,3)'"')
 end
 IF UPPER(LANG) = 'ENGLISH'
 then do
  Address Command('echo >t:compyam "This message announces that have been"')
  Address Command('echo >>t:compyam "uncorrectly received, the file:"')
  Address Command('echo >>t:compyam "'word(subje,2)'"')
  Address Command('echo >>t:compyam "CRC32: 'word(subje,3)'"')
 end
 Address Command('echo >>t:compyam " "')
 Address Command('echo >>t:compyam " YamNet VER: 3.07 by Alfredo Soro (31 Dic 1996 - 04:00)"')
 ADDRESS YAM
 IF NOHIDE = 0 then Hide
 MailWrite
 writemailto word(vienede,words(vienede))
 COMPROSUBJE = '"Resend Request: 'word(subje,1)' 'word(subje,2)' 'word(subje,3)'"'
 'writesubject 'COMPROSUBJE
 writeletter 't:compyam'
 writequeue
 Address Command('ECHO >ENV:YAMCHECK "Receipt(s) Ready to LAUNCH"')
 Call Delete('t:compyam')
RETURN
EXIT

REMANFICHERO:

if exists(OUTBO'YamNet/'remocerr||remonombre)
then do
 if exists(OUTBO'YamNet/'remonombre) then call Delete(OUTBO'YamNet/'remonombre)
 address command('rename "'OUTBO'YamNet/'remocerr||remonombre'" "'OUTBO'YamNet/'remonombre'"')
 numetodo = ''
 nmetnu = 0
 aeio = 0
 Do until numetodo ~= '' | aeio = 1
  nmetnu = nmetnu + 1
  if LADRE.nmetnu = removiene then numetodo = UUMOD.nmetnu
  if nmetnu = nodos then aeio = 1
 end

 if numetodo = 'UUIN'
 then do
  renumeter = remonombre
  elnuasi = TEMP'YamOut/'remonombre'.uaa'
  Call Makedir(TEMP'YamOut')
  IF UUENCODE(TEMP'YamOut/'remonombre,OUTBO'YamNet/'remonombre,,'S')
  then do
   elcerrece = CRC32(OUTBO'YamNet/'remonombre)
   nohayfallos = 0
   SUBREMA = SUBREMA' UUIN'
   Call Crealnuasi
  end
 end

 if numetodo = 'MIME'
 then do
  renumeter = remonombre
  elnuasi = TEMP'YamOut/'remonombre'.mime'
  if exists(TEMP'YamOut') then Address Command('delete >nil: 'TEMP'YamOut ALL QUIET NOREQ FORCE')
  Call Makedir(TEMP'YamOut')
  Address Command('base64encode >'TEMP'nore 'OUTBO'YamNet/'remonombre' 'elnuasi)
  Call Open('nore',TEMP'nore','R')
  nosenco = READLN('nore')
  Call Close('nore')
  Call Delete(TEMP'nore')
  if word(nosenco,2) = 'bytes' then elcerrece = CRC32(OUTBO'YamNet/'remonombre)
  nohayfallos = 0
  SUBREMA = SUBREMA' MIME'
  Call Crealnuasi
 end

 if numetodo = 'FSCODE'
 then do
  renumeter = remonombre
  elnuasi = TEMP'YamOut/'remonombre'.asc'
  if exists(TEMP'YamOut') then Address Command('delete >nil: 'TEMP'YamOut ALL QUIET NOREQ FORCE')
  Call Makedir(TEMP'YamOut')
  Address Command('c:fscode OUTBO'yamnet/'remonombre 'elnuasi' E')
  elcerrece = CRC32(OUTBO'YamNet/'remonombre)
  nohayfallos = 0
  SUBREMA = SUBREMA' FSCODE'
  Call Crealnuasi
 end

 if numetodo = 'PGP'
 then do
  renumeter = remonombre
  elnuasi = OUTBO'YamNet/'remonombre'.asc'
  if exists(TEMP'YamOut') then Address Command('delete >nil: 'TEMP'YamOut ALL QUIET NOREQ FORCE')
  Call Makedir(TEMP'YamOut')

  if exists('env:PGPPATH')
  then do
   call open('ppa','env:pgppath','R')
   elppa = readln('ppa')
   Call Close('ppa')
   if right(elppa,1) ~= ':' & right(elppa,1) ~= '/' then elppa = elppa||'/'
   if LANG='ESPAÑOL' then Address Command(elppa'PGP >NIL: -ea "+comment=Correo de la Red: 'word(subje,3)'" 'remonombre' 'TOPGP.nmetnu)
   if LANG='ENGLISH' then Address Command(elppa'PGP >NIL: -ea "+comment=Mail from the net: 'word(subje,3)'" 'remonombre' 'TOPGP.nmetnu)
   elcerrece = CRC32(OUTBO'YamNet/'remonombre)
  end
  if ~exists('env:PGPPATH')
  then do
   if LANG='ESPAÑOL' then Address Command('PGP >NIL: -ea "+comment=Correo de la Red: 'word(subje,3)'" 'remonombre' 'TOPGP.nmetnu)
   if LANG='ENGLISH' then Address Command('PGP >NIL: -ea "+comment=Mail from the net: 'word(subje,3)'" 'remonombre' 'TOPGP.nmetnu)
   elcerrece = CRC32(OUTBO'YamNet/'remonombre)
  end
  nohayfallos = 0
  SUBREMA = SUBREMA' PGP'
  Call Crealnuasi
 end

 if nohayfallos = 1
 then do
  if numetodo = 'UUIN' then elmodete = 'UUIN'
  Escring:
  ELYAM = 'Escring'
  SIGNAL ON SYNTAX
  IF NOHIDE = 0 then HIDE
  MailWrite
  writemailto LADI
  'writesubject 'SUBREMA
  writeletter elnuasi
  writequeue
  Address Command('ECHO >ENV:YAMCHECK "Message(s) Ready to LAUNCH"')
  Call Delete(elnuasi)
  address command('rename "'OUTBO'YamNet/'remonombre'" "'OUTBO'YamNet/'remocerr||remonombre'"')
 end
end
RETURN

Crealnuasi:

 if exists(elnuasi)
 then do
  nohayfalos = 1
  address command('echo >>'elnuasi' " "')
  address command('echo >>'elnuasi' "-- "')
  address command('echo >>'elnuasi' ""')
  IF UPPER(LANG) = 'ESPAÑOL' then Address Command('echo >>'elnuasi' "--- Re-Enviado con YamNet V3.07 - Alfredo Soro (31 Dic 96 - 04:00)"')
  IF UPPER(LANG) = 'ENGLISH' then Address Command('echo >>'elnuasi' "--- Re-Sent with YamNet V3.07 - Alfredo Soro (31 Dic 96 - 04:00)')
  if LANG = 'ESPAÑOL' then Address Command('echo >t:joi "Correo de la Red: 'word(subje,3)'"')
  if LANG = 'ENGLISH' then Address Command('echo >t:joi "Mail from network: 'word(subje,3)'"')
  Address Command('echo >>t:joi " "')
  Address Command('Join t:joi 'elnuasi' AS='TEMP'joined')
  Call Delete('T:Joi')
  Address command('Copy 'TEMP'joined 'elnuasi' QUIET')
  Call Delete(TEMP'joined')
 end
RETURN

CONVIDENTRO:

Drop eltruco.
Call Textos('°' , 'Sustituyendo signos del mensaje por puntos' , 'Replacing message characters to points')
Call Readfile(fichero,'eltruco')
croa = 0
drop elnuevo.
elnuevo.0 = eltruco.0
do until croa = eltruco.0
 croa = croa +1
 elnuevo.croa = translate(eltruco.croa,'.','°')
end
call writefile(fichero,'elnuevo')
borros = 1
RETURN
EXIT

DEMAILEA:

 Call Textos('!' , 'Reconvirtiendo ISO-8859-1 a Latin normal de Amiga' , 'Re-converting ISO-8859-1 to normal Amiga Latin chars')
 autenfichero = fichero
 Call Makedir(TEMP'YamConv')
 fichero = TEMP'YamConv/'FILEPART(autenfichero)
 otrofichero = TEMP'YamConv/'FILEPART(autenfichero)'.lat'
 Call open('aufi',autenfichero,'R')
 Call open('ficu',otrofichero,'W')

 CALL LOMISMO

 Call close('aufi')
 Call close('ficu')

 Call open('lufi',otrofichero,'R')
 Call open('ficu',fichero,'W')
 do until eof('lufi')
  anda = readch('lufi',5000)
  if right(anda,1) = '=' then anda = anda||readch('lufi',2)
  if right(anda,1) = '=' then anda = anda||readch('lufi',2)
  if right(anda,2) = '=2' | right(anda,2) = '=3' then anda = anda||readch('lufi',1)
  andb = replace('.','=2E',anda)
  andc = replace('=','=3D',andb)
  call writech('ficu',andc)
 end
 Call Close('ficu')
 Call Close('lufi')
 Call Delete(otrofichero)

 IF LOGLEV = 4 then address command('echo "'atra'" NOLINE')

RETURN

EXIT

LOMISMO:

 suma = 0
 convd = ''
 alemo = 0
 ale = 0
 nue = 0

 IF LOGLEV = 4 then address command('echo " " NOLINE')

 do until eof('aufi')
  if suma = 0 then conva = readln('aufi')
  if suma = 1 then conva = convb||readln('aufi')
  convb = conva
  if suma = 0 & right(conva,1) = '=' then convb = left(conva,length(conva)-1)
  if convb = conva
  then do
   Call writeln('ficu',convb)
   suma = 0
   alemo = alemo + 1
  end
  if convb ~= conva
  then do
   suma = 1
  end

  IF alemo > 250 & right(alemo/2,2) ~= '.5' & LOGLEV = 4
  then do
   if ale = 0 & nue = 0
   then do
    address command('echo "'atra'|" NOLINE')
    ale = 1
    nue = 1
   end
   if nue = 0 & ale = 1
   then do
    address command('echo "'atra'-" NOLINE')
    ale = 0
   end
   nue = 0
  end
 end

 if suma = 1 then Call writeln('ficu',convb)


RETURN

EXIT

INFIERNA:

 if exists('YAM:YamNet.dat')
 then do
  Call Textos('#' , 'Comprobando RECIBIs' , 'Checking 'RECIBI' Receipts')
  SIGNAL ON SYNTAX
  ADDRESS YAM
  setfolder 0
  SIGNAL OFF SYNTAX
  GetFolderInfo MAX
  datos = RESULT
  DROP emoviene.
  DROP emofichero.
  DROP emonombre.
  DROP emocerr.
  DROP emosubje.
  reborros = 0
  inicial = 0
  inicial = inicial - 1
  Do li=0 to datos-1
   nohacer = 0
   setfolder 0
   ellibo = (datos-1)-li
   SetMail ellibo
   GetMailInfo SUB
   subje = RESULT
   GetMailInfo FRO
   Vienede = RESULT
   if left(subje,7) = 'RECIBI:'
   then do
    inicial = inicial + 1
    GetMailInfo FIL
    emofichero.inicial = RESULT
    GetMailInfo FRO
    emoviene.inicial = RESULT
    emonombre.inicial = word(subje,3)
    Call Textos('+' , 'Recibido comprobante por el fichero: 'emonombre.inicial , 'Received receipt for the file: 'emonombre.inicial)
    emocerr.inicial = word(subje,4)
    emosubje.inicial = word(subje,2)
   end
  end
  recisbis = 0
  if inicial ~= -1
  then do
   call open('YRD','YAM:YamNet.dat','R') 
   laprima = ReadLN('YRD')
   secambios = 0
   elrre = 0
   puli = 0
   DROP quesito.
   Do until eof('YRD')
    nocompro = 0
    secureci = readln('YRD')
    quesilova = 1
    if datatype(word(secureci,1),'N')   
    then do
     paratese = 0
     aye = -1
     do until paratese = 1
      aye = aye + 1
      parse var emoviene.aye '<'nmcadena'>'
      if nmcadena = '' then nmcadena = emoviene.aye
      aladi = nmcadena
      if word(secureci,6) = emocerr.aye & word(secureci,4) = emonombre.aye & word(secureci,3) = emosubje.aye & word(secureci,7) = aladi
      then do
       quesilova = 0
       secambios = 1
       recisbis = recisbis + 1
       Call Delete(emofichero.aye)
       Call Delete(OUTBO'YamNet/'emocerr.aye||emonombre.aye)
       reborros = 1
       Call Textos('#' , 'Comprobante y archivo original: BORRADOS.' , 'Receipt and original file: DELETED.')
       paratese = 1
      end
      if aye = inicial then paratese = 1
     end
    end 
    if quesilova = 1
    then do
     puli = puli + 1
     quesito.puli = secureci
    end
   end
   Call Close('YRD')
   if secambios = 1
   then do
    Call Open('YTD','Yam:YamNet.dat','W')
    Call WriteLN('YTD',laprima)
    do sssecu = 1 to puli
     if quesito.sssecu ~= '' then Call WriteLN('YTD',quesito.sssecu)
    end
    Call Close('YTD')
   end
   if reborros = 1
   then do
    setfolder 0
    mailupdate
   end
  end
  if (inicial+1)-recisbis ~= 0 then Call Textos('#' , (inicial+1)-recisbis' Ficheros de RECIBI no se encontraron' , (inicial+1)-recisbis' files of receipts were not found')
  Call MAXTextos('!' , recisbis' ficheros con su recibi BORRADOS.' , recisbis' files with its receipt DELETED.')
 end
 
RETURN
EXIT

BORRAPORFECHA:

tercuss = 0
DROP ternued.

If exists('YAM:YamNet.dat')
then do
 tercubo = 0
 Call Open('YBF','Yam:YamNet.dat','R')
 primepa = ReadLN('YBF')
 cams = 0
 do until EOF('YBF')
  secupa = ReadLN('YBF')
  recam = 0
  if datatype(word(secupa,2),'N')
  then do
   multipud = 0
   remola = 0
   if datatype(word(secupa,1),'N') then multipud = word(secupa,1)
   if multipud ~= 0 then remola = multipud*remanda
   if (word(secupa,2)+reborra)-remola <= rehoy
   then do
    cams = 1
    recam = 1
    if safe = 0
    then do
     tercubo = tercubo + 1
     Call Delete(OUTBO'YamNet/'word(secupa,6)||word(secupa,4))
     Call Textos('-' , 'Borrado fichero [42;31m'word(secupa,6)'[0m por antigudad' , 'Deleted file [42;31m'word(secupa,6)'[0m by age')
    end
    if safe = 1
    then do
     Call IniSafe
     Address command('Echo 'TEMP'YamNet.SAFE "delete 'OUTBO'YamNet/'word(secupa,6)||word(secupa,4)'"')
     Call Textos('-' , 'Simulado borrado de fichero [42;31m'word(secupa,6)'[0m' , 'Simulated deleting of file [42;31m'word(secupa,6)'[0m')
    end
   end 
   if recam = 0
   then do
    tercuss = tercuss + 1
    ternued.tercuss = secupa
   end
  end
 end
 Call Close('YBF')
 if cams = 1
 then do
  Call Open('NYD','YAM:YamNet.dat','W')
  Call WriteLN('NYD',primepa)
  do tertercu = 1 to tercuss
   if ternued.tertercu ~= '' then Call WriteLN('NYD',ternued.tertercu)
  end
  Call Close('NYD')
 end
 Call Textos('+', 'Borrados 'tercubo' ficheros almacenados por antiguedad' , 'Deleted 'tercubo' stored files by age')
end

RETURN
EXIT

INFIERNO:

 Call BORRAPORFECHA
 Call INFIERNA
 SIGNAL ON SYNTAX
 setfolder 2
 Call Textos('+', 'Purgando correo enviado' , 'Purging sent mail')
 SIGNAL OFF SYNTAX
 GetFolderInfo MAX
 tercudatos = RESULT
 refilis = 0
 purgados =  0
 call OZONADOR
 do tercua = 0 to tercudatos-1
  setfolder 2
  setmail tercua
  getmailinfo SUB
  tercusub = RESULT
  if left(tercusub,7) = 'RECIBI:' | left(tercusub,15) = 'Resend Request:'
  then do
   GetMailInfo FIL
   tercufil = RESULT
   IF SAFE = 0
   then do
    Call Delete(tercufil)
    purgados = purgados + 1
    Call Textos('-' , 'Borrado viejo recibo o peticion de reenvio' , 'Deleted old sent receipt or resending request')
    borros = 1  
   end
   if safe ~= 0
   then do
    Call Inisafe
    Address Command('echo >>'TEMP'YamNet.SAFE "delete 'tercufil'"')
    purgados = purgados + 1
    Call Textos('-' , 'SIMULADO borrado viejo recibo o peticion de reenvio' , 'Simulating that receipt or resend request is deleted')
   end
  end
  if upper(word(tercusub,1)) ~= 'RE:'
  then do
   nomastercu = 0
   tercuuu = 0
   do until nomastercu = 1
    tercuuu = tercuuu + 1
    if word(tercusub,1) = tercuz.tercuuu
    then do
     GetMailInfo Fil
     tercufilu = RESULT
     refilis = refilis + 1
     if safe = 0
     then do
      borros = 1
      Call Delete(tercufilu)
      Call Textos('#' , 'Fichero ya enviado BORRADO.' , 'DELETED already sent File.')
      nomastercu = 1
     end
     if safe ~= 0
     then do
      borros = 1
      Address Command('echo >>'TEMP'YamNet.SAFE "delete 'tercufilu'"')
      Call Textos('#' , 'Simulado borrado de fichero ya enviado.' , 'Simulated DELETING of already sent File.')
      nomastercu = 1
     end
    end
    if tercuuu = tercun then nomastercu = 1
   end
  end
 end
 Call Textos('-' , 'BORRADOS 'purgados' recibos o requests y 'refilis' ficheros ya enviados' , 'DELETED 'purgados' receipts or requests & 'refilis' bundles already sent')

RETURN

OZONADOR:

 terka = 0
 tercun = 0
 DROP tercuz.
 do tercue = 1 to zonas
  ui = SUBJ.tercue
  nolotercu = 0
  do tercucu = 1 to tercun
   if tercuz.tercucu = ui then nolotercu = 1
  end
  if nolotercu = 0
  then do
   tercun = tercun + 1
   tercuz.tercun = ui
  end
 end
RETURN

EXIT

YAMUDT:

Call Textos('!' , 'Mensaje generado con vieja version de YamNet' , 'Message generated with old version of YamNet')
Call MAXTextos('%' , 'Intentandolo con FSCode' , 'Trying it with FSCode')

if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
if ~exists(TEMP'YamNet') then Call Makedir(TEMP'YamNet')
dirname = TEMP'YamNet'
olddir = pragma('d', dirname)

if searchpattern(fichero,'°') ~= -1 then Call CONVIDENTRO

Address Command('echo >'TEMP'yach `c:FSCODE 'fichero'`')
Call pragma('d', olddir)
call open('tyac',TEMP'yach','R')
lalalala = readln('tyac')
call close('tyac')
call delete(TEMP'yach')
if right(lalalala,13) = 'no start line'
then do
 if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
 Call Makedir(TEMP'YamNet')
 Call MAXTextos('%' , 'Intentandolo con MIME' , 'Trying it with MIME')
 Address Command('base64decode >'TEMP'yare 'fichero' 'TEMP'yamnet')
 Call open('yare',TEMP'yare','R')
 nuevo = 0
 larespu = readln('yare') if word(larespu,2) = 'bytes' then nuevo = 1
 if larespu = 'No filename found in MIME header' then nuevo = 0
 Call Close('yare')
 Call Delete(TEMP'Yare')
 if nuevo = 0 then if ~exists(TEMP'yamnet/'word(subje,2)) THEN nuevo = 1
 if nuevo ~= 0
 then do
  if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
  Call Makedir(TEMP'YamNet')
  nuevo = 1
  Call MAXTextos('%' , 'Intentandolo con UUDECODE()' , 'Trying it with UUDECODE()')
  If UUDECODE(fichero,TEMP'YamNet') then nuevo = 0

  if nuevo = 0 then if ~exists(TEMP'yamnet/'word(subje,2)) THEN nuevo = 1
  if nuevo ~= 0
  then do
   if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
   Call Makedir(TEMP'YamNet')
   dirname = TEMP'YamNet'
   olddir = pragma('d', dirname)
   elppa = ''
   Address Command('which >'TEMP'YamNetPGP PGP')
   if READFILE(TEMP'YamNetPGP','mipgp')
   then do
    if mipgp.0 > 0 then elppa = left(mipgp.1,length(mipgp.1)-3)
    IF mipgp.0 = 0 then elppa = ''
   end
   Call Delete(TEMP'YamNetPGP')
   if exists('env:PGPPATH')
   then do
    call open('ppa','env:pgppath','R')
    elppa = readln('ppa')
    Call Close('ppa')
    if right(elppa,1) ~= ':' & right(elppa,1) ~= '/' then elppa = elppa||'/'
   end
   if elppa = '' then Call Textos('#' , 'ERROR: PGP No instalado!!' , 'ERROR: PGP not installed!!')
   Call MAXTextos('%' , 'Intentandolo con PGP' , 'Trying it with PGP')
   Address Command(elppa'PGP -p >nil: 'fichero)
   elopo = RC
   Call pragma('d', olddir)
   nohacer = 0
   if elopo ~= 0 then nohacer = 1
  end
 end
end

if exists(TEMP'yamnet')
then do
 Address Command('list >'TEMP'mirami 'TEMP'YamNet LFORMAT="%n %l"')
 call open('tmiram',TEMP'mirami','R')
 tmi = readln('tmiram')
 call close('tmiram')
 Call Delete(TEMP'mirami')
 tnu = word(tmi,2)
 fiche = word(tmi,1)
 if tnu = 'empty' then nohacer = 1
 if tnu ~= word(lared,3) & word(lared,3) ~= '' then nohacer = 1
end

if nohacer = 1
then do
 Call Textos('#' , 'Fallo en decodificacion. Pidiendo Re-Envio!' , 'Decoding Error. Requesting a Re-Sending')
 mopa = 0
 al = 0
 do until mopa = 1
  nomb = right('00'al,2)
  al = al + 1
  if ~exists(TEMP'YamNet.CHECK'nomb) then mopa = 1
 end
 Address Command('copy 'fichero' 'TEMP'YamNet.CHECK'nomb)
 if safe = 0
 then do
  Call Delete(fichero)
  borros = 1
 end
 if safe ~= 0
 then do
  Call IniSafe
  Address Command('echo >>'TEMP'YamNet.SAFE "delete 'fichero'"')
 end

 Call Textos('%' , 'Guarda el fichero ['TEMP'YamNet.CHECK'nomb'] para comparar' , 'Save the file ['TEMP'YamNet.CHECK'nomb'] to compare')
 call HazResendReq
end 

if nohacer = 2
then do
 mopa = 0
 al = 0
 do until mopa = 1
  nomb = right('00'al,2)
  al = al + 1
  if ~exists(TEMP'YamNet.CHECK'nomb) then mopa = 1
 end
 Address Command('copy 'fichero' 'TEMP'YamNet.CHECK'nomb)
 if safe = 0
 then do
  Call Delete(fichero)
  Call Textos('#' , 'Borrado mensaje sin fichero codificado' , 'Message without encoded file Deleted')
  borros = 1
 end
 if safe ~= 0
 then do
  Call IniSafe
  Address Command('echo >>'TEMP'YamNet.SAFE "delete 'fichero'"')
 end
 Call Textos('%' , 'Puedes examinar el mensaje en el fichero ['TEMP'YamNet.CHECK'nomb']' , 'You can look into the message in file ['TEMP'YamNet.CHECK'nomb']')
end 

if nohacer = 0
then do
 rnomb = fiche
 if exists(INBO||fiche)
 then do
  pi = 0
  parpar = 0
  do until parpar = 1
   pi = pi + 1
   rnomb = fiche||','pi
   if ~exists(INBO||rnomb) then parpar = 1
  end
 end

 Address Command('copy >NIL: 'TEMP'yamnet/'fiche' 'INBO||rnomb)
 Call Textos('<' , INBO||rnomb' ...preparado.' , INBO||rnomb' ...ready.')
 tama = tnu
 if tama ~= word(lared,3) then Call Textos('#' , '¡El fichero recibido fue generado con YamNet mas viejo!' , 'Received file was generated with older YamNet!')
 if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')

 IF LOGLEV = 1 | LOGLEV = 4
 then do
  e = 0
  quienes = ''
  do pompom = 1 to Nodos
   If upper(LADRE.pompom) = upper(word(vienede,1)) & left(ELNO.pompom,length(tadon)) = tadon then quienes = ELNO.pompom
  end
  if quienes = '' then quienes = word(vienede,words(vienede))
  IF UPPER(LANG) = 'ESPAÑOL' then say ' - 'date()' 'time()'  Desde: 'quienes' - CRC32: 'tama
  IF UPPER(LANG) = 'ENGLISH' then say ' - 'date()' 'time()'  From: 'quienes' - CRC32: 'tama
 end
 IF LOGLEV = 2 | LOGLEV = 4
 then do
  if LOGLEV = 2
  then do
   eee = 0
   pompom = 0
   do until eee = 1
    pompom = pompom + 1
    If upper(LADRE.pompom) = upper(word(vienede,1)) & left(ELNO.pompom,length(tadon)) = tadon
    then do
     quienes = ELNO.pompom
     eee = 1
    end
    if pompom = Nodos then eee = 1
   end
  end
  if quienes = '' then quienes = word(vienede,words(vienede))
  IF UPPER(LANG) = 'ESPAÑOL' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  Desde: 'quienes' - CRC32: 'tama'"')
  IF UPPER(LANG) = 'ENGLISH' then Address Command('echo >>t:logyamnet.tmp " - 'date()' 'time()'  From: 'quienes' - CRC32: 'tama'"')
 end

 Call HacerRecibo

 if safe = 0
 then do
  Call Delete(fichero)
  borros = 1
 end
 if safe ~= 0
 then do
  Call IniSafe
  Address Command('echo >>'TEMP'YamNet.SAFE "delete 'fichero'"')
 end
end
RETURN

EXIT

GENERADAT:

/* YamNet.dat generator ASL 26/11/96 */

Call Textos( '!', 'YAM:YamNet.dat Generator en proceso' , 'Generating YAM:YamNet.dat')
IF ~SHOW('Ports','YAM')
THEN DO
 Address Command('Run <NIL: >NIL: YAM:YAM')
 Address Command('WaitForPort YAM')
END

borros = 0
Call Ozonador

SIGNAL ON SYNTAX
ADDRESS YAM
setfolder 2
Getfolderinfo MAX
numer = RESULT
SIGNAL OFF SYNTAX
andaya = 0
sususus = -1
Do until andaya = 1
 sususus = sususus + 1
 setfolder 2
 setmail sususus
 getmailinfo SUB
 sujeto = RESULT
 if word(sujeto,1) ~= 'RE:'
 then do
  paparara = 0
  sumadero = 0
  do until paparara = 1
   sumadero = sumadero + 1
   if word(sujeto,1) = tercuz.sumadero
   then do
    call LAODISEA
    paparara = 1
   end
   if sumadero = tercun then paparara = 1
  end
 end
 if sususus = (numer - 1) then andaya = 1
end

if borros = 1
then do
 setfolder 2
 mailupdate
end

Call Textos('-', 'Proceso terminado' , 'Process ended')

RETURN

LAODISEA:

 Getmailinfo FIL
 ILFIC = RESULT

 fichero = ILFIC
 CALL DEMAILEA
 nuevo = 0
 if exists(TEMP'yamnet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
 Call Makedir(TEMP'YamNet')
 dirname = TEMP'YamNet'
 olddir = pragma('d', dirname)

 IF word(sujeto,4) = 'UUIN'
 then do
  If UUDECODE(fichero,TEMP'YamNet') then nuevo = 1
  if nuevo = 1 & ~exists(TEMP'YamNet/'word(sujeto,2)) then nuevo = 0
 end
 IF word(sujeto,4) = 'FSCODE'
 then do
  Address Command('echo >'TEMP'yach `c:FSCODE 'fichero'`')
  nuevo = 1
  call open('tyac',TEMP'yach','R')
  lalalala = readln('tyac')
  call close('tyac')
  call delete(TEMP'yach')
  if right(lalalala,13) = 'no start line'
  then do
   if exists(TEMP'YamNet') then Address Command('delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
   nuevo = 0
  end
 end

 IF word(sujeto,4) = 'MIME'
 then do
  address command('base64decode >'TEMP'yare 'fichero' 'TEMP'YamNet')
  Call open('yare',TEMP'yare','R')
  larespu = readln('yare')
  if word(larespu,2) = 'bytes' then nuevo = 1
  if larespu = 'No filename found in MIME header' then nuevo = 0
  Call Close('yare')
  Call Delete(TEMP'Yare')
  if nuevo = 1 then if ~exists(TEMP'yamnet/'word(sujeto,2)) THEN nuevo = 0
 end

 IF word(sujeto,4) = 'PGP'
 then do
  Call PREPEGEPE
  Address command(elppa'PGP -p >nil: 'fichero)
  elopo = RC
  nuevo = 1
  if elopo ~= 0 then nuevo = 0
 end

 Call pragma('d', olddir)

 if nuevo = 1
 then do
  if ~exists(OUTBO'YamNet') then Makedir(OUTBO'YamNet')
  address command('Copy >NIL: 'TEMP'YamNet/'word(sujeto,2)' 'OUTBO'YamNet/'CRC32(TEMP'YamNet/'word(sujeto,2))||word(sujeto,2))
  Call Creadat
  pakter = TEMP'YamNet/'word(sujeto,2)
  call secumita
  GetMailInfo TO
  removiene = RESULT
  parse var removiene '<'nmcadena'>'
  if nmcadena = '' then nmcadena = removiene
  removiene = nmcadena
  LADI = removiene
  address command('echo >>YAM:YamNet.dat "0 'rehoy' 'word(sujeto,1)' 'word(sujeto,2)' 'elsecuta' 'CRC32(TEMP'YamNet/'word(sujeto,2))' 'LADI'"')
  Call Delete(ILFIC)
  Address command('delete >NIL: 'TEMP'YamConv ALL QUIET FORCE')
  Address command('delete >NIL: 'TEMP'YamNet ALL QUIET FORCE')
  call textos('+' , word(sujeto,2)||' almacenado en 'OUTBO'YamNet.' , word(sujeto,2)||' stored in 'OUTBO'YamNet')
  borros = 1
 end

 if nuevo = 0
 then do
  Call Textos('x' , 'Fallo al decodificar mensaje!' , 'Error decoding message')
 end

RETURN

FALLITO:

  Call Textos('#' , 'Fallo en decodificacion. Pidiendo Re-Envio!' , 'Decoding Error. Requesting a Re-Sending')
  mopa = 0
  al = 0
  do until mopa = 1
   nomb = right('00'al,2)
   al = al + 1
   if ~exists(TEMP'YamNet.CHECK'nomb) then mopa = 1
  end
  Address Command('copy 'fichero' 'TEMP'YamNet.CHECK'nomb)
  if safe = 0
  then do
   Call Delete(fichero)
   Call Delete(autenfichero)
   If exists(TEMP'YamConv') then Address command('Delete >NIL: 'TEMP'YamConv ALL QUIET NOREQ FORCE')
   If exists(TEMP'YamConFI') then Address command('Delete >NIL: 'TEMP'YamConFI ALL QUIET NOREQ FORCE')
   If exists(TEMP'YamNet') then Address command('Delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE')
   borros = 1
  end
  if safe ~= 0
  then do
   Call IniSafe
   Address Command('echo >>'TEMP'YamNet.SAFE "delete 'fichero'"')
   Address Command('echo >>'TEMP'YamNet.SAFE "delete 'autenfichero'"')
   Address Command('echo >>'TEMP'YamNet.SAFE "Delete >NIL: 'TEMP'YamNet ALL QUIET NOREQ FORCE"')
   Address Command('echo >>'TEMP'YamNet.SAFE "Delete >NIL: 'TEMP'YamConv ALL QUIET NOREQ FORCE"')
   Address Command('echo >>'TEMP'YamNet.SAFE "Delete >NIL: 'TEMP'YamConFI ALL QUIET NOREQ FORCE"')
  end
  Call Textos('%' , 'Guarda el fichero ['TEMP'YamNet.CHECK'nomb'] para comparar' , 'Save the file ['TEMP'YamNet.CHECK'nomb'] to compare')
  call HazResendReq

RETURN

HALT:
say '*** BREAK'
CALL SALIR
BREAK_C:
say '*** BREAK'
CALL SALIR
BREAK_D:
say '*** BREAK'
CALL SALIR
BREAK_E:
say '*** BREAK'
CALL SALIR
BREAK_F:
say '*** BREAK'
CALL SALIR

SALIR:

say '** END **'
Call AnteSalir
EXIT

ERROR:
 riesco = RC
 riesv = errortext(riesco)
 Say 'RC V = ['riesv']'
EXIT

SYNTAX:
 riesco = RC
 riesv = errortext(riesco)
 Call Textos('*' , 'EL YAM no esta inicializado. Esperando un poco mas' , 'YAM not initialized, yet. Waiting a little more')
 Call Delay(250)
 if ELYAM = 'Tareauno'
 then do
  Call Tareauno
  Call TRASTUNO
  EXIT
 end
 If ELYAM = 'Tareados'
 then do
  Call Tareados
  Call TRASTDOS
  EXIT
 end
 If ELYAM = 'Infierno'
 then do
  Call Infierno
  Call SIGUINFER
  EXIT
 end
 If ELYAM = 'Observin'
 then do
  Call Observin
  Call TRASOBSER
  EXIT
 end
 If ELYAM = 'Escribello'
 then do
  Call Escribello
  if remiralo = 'flo' then Call trasflo
  if remiralo = 'hlo' then Call trashlo
  if remiralo = 'clo' then Call trasclo
  if remiralo = 'dlo' then Call trasdlo
  if remiralo = 'slo' then Call traslo
  Say 'Bad programed.. Sorry!'
  EXIT
 end
 if ELYAM = 'Yacheche'
 then do
  call Yacheche
  EXIT
 end
 if ELYAM = 'Yachecho'
 then do
  call Yachecho
  EXIT
 end
 Say 'RC V = ['riesv']'
EXIT

NOVALUE:

 Say RESULT
 Say RC
EXIT
