home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1997 #5 / AmigaPlus_Extra-CD_5-97.iso / online-tools / mail / ems / rexx / areafix.ems next >
Text File  |  1993-08-30  |  25KB  |  887 lines

  1. /****************************/
  2. /* Handles AreaFix requests */
  3. /***************************************/
  4. /* $VER: AreaFix.ems 1.0 (29.08.93)    */
  5. /***************************************/
  6.  
  7. options results
  8. signal on error
  9. signal on syntax
  10.  
  11. if( ~show( 'l', "ems_rexx.library" ) ) then
  12. do
  13.    if( ~addlib( "ems_rexx.library", 0, -30, 0 ) )then
  14.    do
  15.       say "Could not open ems_rexx.library"
  16.       exit 10
  17.    end
  18. end
  19.  
  20.  
  21. /* Checks if the system uses another AreaFix program */
  22. if EMS_Switch_Local( 'USE_INTERNAL_AREAFIX' ) ~= 'ON' then call QuitAreafix
  23.  
  24. /****************************/
  25. /* Initialize some stuff... */
  26. /****************************/
  27. aliases.0        = 0
  28. areas_mail.0     = 0
  29. areas_doexport.0 = 0
  30. forwards.0       = 0
  31. writeback.0      = 'NO'  /* Links */
  32. writeback.1      = 'NO'  /* Nodes */
  33. writeback.2      = 'NO'  /* Areas */
  34. delete_msg       = EMS_Switch_Local( 'NO_KEEP_AREAFIX' )
  35.  
  36. call EMS_Nodes( 'nodes' )
  37.  
  38.  
  39. /*
  40. ** Split the AREAFIX_NAME.
  41. */
  42. name_1 = EMS_Var_Local( 'AREAFIX_NAME' )
  43.  
  44. do while length( name_1 ) ~= 0
  45.  
  46.    parse var name_1 name_2 name_1
  47.  
  48.    if length( name_2 ) ~= 0 then call EMS_Add_To_Stem( 'aliases', name_2 )
  49.  
  50. end
  51.  
  52.  
  53. /*
  54. ** Search for areas of type MAIL
  55. */
  56. call EMS_Areas_Mail( 'a' )
  57. do i=1 to a.0
  58.  
  59.    addr = EMS_Area_Address( a.i )
  60.  
  61.    if EMS_Address_IsPOINT( addr ) = 'FALSE' then call EMS_Add_To_Stem( 'areas_mail', a.i )
  62.  
  63. end
  64. drop a.
  65.  
  66.  
  67. do i=1 to areas_mail.0
  68.  
  69.    call FindAreaFixMsgs( areas_mail.i )
  70.  
  71.    if msgs.0 ~= 0 then call EMS_Log_Print( 2, 'AreaFix: found' msgs.0 'unprocessed request(s)' )
  72.  
  73.    do j=1 to msgs.0
  74.  
  75.       msg_pwd        = ''
  76.       msg_addr       = ''
  77.       msg_addr_real  = ''
  78.       msg_subject    = ''
  79.       msg_requests.0 = 0
  80.       msg_reports.0  = 0
  81.       msg_actions.0  = 'OFF' /* Help        */
  82.       msg_actions.1  = 'OFF' /* Rescan      */
  83.       msg_actions.2  = 'OFF' /* List        */
  84.       msg_actions.3  = 'OFF' /* Query       */
  85.       msg_actions.4  = 'OFF' /* Unlinked    */
  86.       msg_actions.5  = ''    /* Compress    */
  87.       msg_actions.6  = ''    /* PWD         */
  88.       msg_actions.7  = 'OFF' /* Pause       */
  89.       msg_actions.8  = 'OFF' /* Resume      */
  90.       msg_actions.9  = ''    /* Notify      */
  91.  
  92.                              /* Filter:     */
  93.       msg_rescan.0   = ''    /* From        */
  94.       msg_rescan.1   = ''    /* To          */
  95.       msg_rescan.2   = ''    /* Subject     */
  96.       msg_rescan.3   = ''    /* Date        */
  97.       msg_rescan.4   = 'OFF' /* ALL         */
  98.  
  99.       /* Reads requests */
  100.       if ParseMsg( areas_mail.i, msgs.j ) = 1 then
  101.       do
  102.  
  103.          call EMS_Log_Print( 2, 'AreaFix: processing request from' msg_addr_real 'for' msg_addr )
  104.  
  105.          if EMS_Node_Check( msg_addr ) ~= 'OK' then
  106.          do
  107.             call EMS_Log_Print( 2, 'AreaFix: unknown system' )
  108.  
  109.             call WrongPassword()
  110.             call SendReport( i, 'NO' )
  111.             iterate
  112.          end
  113.  
  114.          /* Checks password */
  115.          node_pwd = EMS_Node_Areafix_Pwd_In( msg_addr )
  116.  
  117.          if node_pwd ~= '' & upper( node_pwd ) ~= upper( msg_pwd ) then
  118.          do
  119.  
  120.             call EMS_Log_Print( 2, 'AreaFix: wrong password' )
  121.  
  122.             call WrongPassword()
  123.             call SendReport( i, 'NO' )
  124.             iterate
  125.  
  126.          end
  127.  
  128.          if msg_actions.5 ~= '' & msg_actions.5 ~= '?' then
  129.          do
  130.  
  131.             call EMS_Archivers( 'packers' )
  132.  
  133.             do k=1 to packers.0
  134.  
  135.                if packers.k = msg_actions.5 then
  136.                do
  137.                   call EMS_Node_Archiver( msg_addr, packers.k ); writeback.1 = 'YES'
  138.                   leave
  139.                end
  140.  
  141.             end
  142.  
  143.             drop packers.
  144.  
  145.          end
  146.  
  147.          if msg_actions.6 ~= ''   then do; call EMS_Node_Areafix_Pwd_In( msg_addr, msg_actions.6 ); writeback.1 = 'YES'; end
  148.          if msg_actions.7  = 'ON' then do; call EMS_Areafix_Passivate(   msg_addr                ); writeback.0 = 'YES'; end
  149.          if msg_actions.8  = 'ON' then do; call EMS_Areafix_Activate(    msg_addr                ); writeback.0 = 'YES'; end
  150.          if msg_actions.9 ~= ''   then do; call EMS_Node_Areafix_Notify( msg_addr, msg_actions.9 ); writeback.1 = 'YES'; end
  151.  
  152.          do k=1 to msg_requests.0
  153.  
  154.             name = msg_requests.k
  155.  
  156.             if left( name, 1 ) = '-' then
  157.             do
  158.                name = delstr( name, 1, 1 )
  159.  
  160.                if EMS_Search_In_Stem( 'areas_mail', name ) ~= 0 then
  161.                do
  162.                   msg_reports.k = 'Hard link: not removed'
  163.                   iterate
  164.                end
  165.  
  166.                linked = EMS_Areafix_Node_IsLinked( msg_addr, name )
  167.  
  168.                if linked = 'NO' then
  169.                do
  170.                   msg_reports.k = 'Not linked'
  171.                   iterate
  172.                end
  173.  
  174.                call EMS_Areafix_Node_Delete( msg_addr, name )
  175.                msg_reports.k = 'Removed'
  176.                writeback.0   = 'YES'
  177.                iterate
  178.  
  179.             end
  180.  
  181.             linked = EMS_Areafix_Node_IsLinked( msg_addr, name )
  182.  
  183.             if linked = 'NO' then
  184.             do
  185.  
  186.                if EMS_Area_Check( name ) = 'UNKNOWN' then
  187.                do
  188.  
  189.                   if EMS_Node_CanCreateAreas( msg_addr ) = 'TRUE' then
  190.                   do
  191.  
  192.                      call EMS_Area_Create( name, 'ECHO' )
  193.                      call FindAreaOnOtherSystems( name )
  194.                      writeback.2 = 'YES'
  195.  
  196.                   end
  197.                   else
  198.                   do
  199.                      msg_reports.k = 'Not found'
  200.                      iterate
  201.                   end
  202.  
  203.                end
  204.  
  205.                /*
  206.                ** Verify access permission.
  207.                */
  208.                if EMS_Areafix_Node_MatchGroup( msg_addr, name ) = 'FALSE' then
  209.                do
  210.                   msg_reports.k = 'Not found'
  211.                   iterate
  212.                end
  213.  
  214.                call EMS_Areafix_Node_Add( msg_addr, name )
  215.                msg_reports.k = 'Linked'
  216.                writeback.0   = 'YES'
  217.  
  218.             end
  219.  
  220.             if linked = 'PASSIVE' then
  221.             do
  222.  
  223.                call EMS_Areafix_Activate( msg_addr, name )
  224.  
  225.                msg_reports.k = 'Reactivated'
  226.                writeback.0   = 'YES'
  227.  
  228.             end
  229.  
  230.             if linked = 'ACTIVE' then
  231.             do
  232.  
  233.                msg_reports.k = 'Yet linked'
  234.  
  235.             end
  236.  
  237.             if msg_actions.1 = 'ON' then call DoRescan( name, k )
  238.  
  239.          end
  240.  
  241.          if EMS_Node_Areafix_Notify( msg_addr ) = 'FALSE' then iterate
  242.  
  243.          call SendReport( i, 'YES' )
  244.  
  245.          if delete_msg = 'ON' then call EMS_Area_Item_Delete( areas_mail.i, 'MSG', msgs.j )
  246.  
  247.       end
  248.  
  249.    end
  250.  
  251. end
  252.  
  253. call SendForward()
  254.  
  255. areas_to_export = ''
  256.  
  257. do i=1 to areas_mail.0
  258.  
  259.    if areas_doexport.i = 'YES' then areas_to_export = areas_to_export areas_mail.i
  260.  
  261. end
  262.  
  263. if areas_to_export ~= '' then call EMS_Tosser_Export( areas_to_export )
  264.  
  265. QuitAreafix:
  266.  
  267. if writeback.0 = 'YES' then call EMS_Cfg_Write( 'cfg_link_ems' )
  268. if writeback.1 = 'YES' then call EMS_Cfg_Write( 'cfg_node_ems' )
  269. if writeback.2 = 'YES' then call EMS_Cfg_Write( 'cfg_area_ems' )
  270.  
  271. call EMS_FreeScriptData()
  272. return 0
  273.  
  274.  
  275. error:
  276. syntax:
  277.  
  278. error_text = EMS_LastError()
  279.  
  280. if error_text = '' then error_text = rc ErrorText( rc )
  281.  
  282. say '| ***BREAK: error at' sigl error_text
  283.  
  284. call EMS_FreeScriptData()
  285. exit rc
  286.  
  287.  
  288. FindAreaFixMsgs: procedure EXPOSE aliases. msgs.
  289.  
  290.    parse arg area
  291.  
  292.    /* Set the search on every message and only on field TOUSER */
  293.    call EMS_Switch_Local( 'SEARCH_ALL'    , 'ON' )
  294.    call EMS_Switch_Local( 'SEARCH_ON_TO'  , 'ON' )
  295.    call EMS_Switch_Local( 'IGNORE_FROM'   , 'ON' )
  296.    call EMS_Switch_Local( 'IGNORE_SUBJECT', 'ON' )
  297.    call EMS_Switch_Local( 'IGNORE_DATE'   , 'ON' )
  298.    call EMS_Switch_Local( 'IGNORE_TEXT'   , 'ON' )
  299.  
  300.    drop msgs.
  301.    msgs.0 = 0
  302.  
  303.    /*
  304.    ** Searches all messages addressed to AreaFix (or aliases) and
  305.    ** without the RCV flag set (not already processed).
  306.    */
  307.    do i=1 to aliases.0
  308.  
  309.       call EMS_Database_Search( area, 'MSG', 'a', aliases.i )
  310.  
  311.       do j=1 to a.0
  312.  
  313.          if EMS_Area_Item_Flag( area, 'MSG', a.j, 'RCV' ) ~= 'ON' then call EMS_Add_To_Stem( 'msgs', a.j )
  314.  
  315.       end
  316.  
  317.    end
  318.  
  319.    return 0
  320.  
  321.  
  322. DoRescan: procedure EXPOSE msg_addr msg_reports. msg_rescan.
  323.  
  324.    parse arg name , req_num 
  325.  
  326.    msg_reports.req_num = msg_reports.req_num 'and rescanned'
  327.  
  328.    if msg_rescan.4 = 'ON' then opt = 'FORCE'
  329.    else                        opt = ''
  330.  
  331.    call EMS_Tosser_Rescan( name, msg_addr, opt, msg_rescan.0, msg_rescan.1, msg_rescan.2, msg_rescan.3 )
  332.  
  333.    return 0
  334.  
  335.  
  336. WrongPassword: procedure EXPOSE msg_requests. msg_reports.
  337.  
  338.    do i=1 to msg_requests.0
  339.       msg_reports.i = 'Wrong password'
  340.    end
  341.  
  342.    return 0
  343.  
  344.  
  345. SendReport: procedure EXPOSE msg_from msg_addr msg_addr_real areas_mail. areas_doexport. ,
  346.                              msg_requests. msg_reports. msg_actions.
  347.                              
  348.  
  349.    parse arg area_num , ok
  350.  
  351.    area = areas_mail.area_num
  352.  
  353.    if EMS_Address_Compare( msg_addr, msg_addr_real ) = 'TRUE' then subject = 'Report about your requests'
  354.    else                                                            subject = 'Report about requests for' msg_addr
  355.  
  356.    call EMS_Areas( 'areas' )
  357.  
  358.    call EMS_Item_Alloc(               'reply', area, 'MSG'              )
  359.    call EMS_Item_Header_From(         'reply', 'AreaFix Robot'          )
  360.    call EMS_Item_Header_Address_From( 'reply', EMS_Area_Address( area ) )
  361.    call EMS_Item_Header_To(           'reply', msg_from                 )
  362.    call EMS_Item_Header_Address_To(   'reply', msg_addr_real            )
  363.    call EMS_Item_Header_Subject(      'reply', subject                  )
  364.  
  365.    if msg_requests.0 ~= 0 then
  366.    do
  367.  
  368.       max1 = 0
  369.       max2 = 0
  370.       do i=1 to msg_requests.0
  371.  
  372.          name = msg_requests.i
  373.          len  = length( name ) + 1
  374.  
  375.          if left( name, 1 ) ~= '-' then len  = len + 1
  376.          if len > max1             then max1 = len
  377.  
  378.          len = length( msg_reports.i ) + 1
  379.  
  380.          if len > max2 then max2 = len
  381.  
  382.       end
  383.  
  384.       if max1 < 27 then max1 = 27
  385.       if max2 < 27 then max2 = 27
  386.  
  387.       call PrintMsg( ' AREA:' || copies( ' ', max1 - 4 ) || 'STATUS:'                        )
  388.       call PrintMsg(             copies( '-', max1     ) || '  '      || copies( '-', max2 ) )
  389.  
  390.       do i=1 to msg_requests.0
  391.  
  392.          area_report = msg_requests.i || ' '
  393.  
  394.          if left( area_report, 1 ) ~= '-' then area_report = ' ' || area_report
  395.  
  396.          call PrintMsg( area_report || copies( '.', max1 - length( area_report ) ) || '  ' || msg_reports.i || '.' )
  397.  
  398.       end
  399.  
  400.       call PrintMsg( '' )
  401.       call PrintMsg( '' )
  402.  
  403.    end
  404.  
  405.    /*
  406.    ** Help: send a list of available ArexFix commands.
  407.    */
  408.    if msg_actions.0 = 'ON' then
  409.    do
  410.  
  411.       call PrintMsgUnderline( 'Help on AreaFix commands:' )
  412.  
  413.       call PrintMsg( '[+]<areaname>        Connect an area.'                                        )
  414.       call PrintMsg( '-<areaname>          Disconnect an area.'                                     )
  415.       call PrintMsg( '%HELP                Request this help text.'                                 )
  416.       call PrintMsg( '%RESCAN              Rescan requested areas.'                                 )
  417.       call PrintMsg( '%LIST                Request a list of areas available to you.'               )
  418.       call PrintMsg( '%QUERY               Request a list of areas to which you are connected.'     )
  419.       call PrintMsg( '%UNLINKED            Request a list of areas to which you are not connected.' )
  420.       call PrintMsg( '%COMPRESS <method>   Change the compression program.'                         )
  421.       call PrintMsg( '%COMPRESS ?          Request a list of available compression programs.'       )
  422.       call PrintMsg( '%PWD <password>      Change AreaFix password.'                                )
  423.       call PrintMsg( '%PAUSE               Temporary suspend all connected areas.'                  )
  424.       call PrintMsg( '%RESUME              Resume all temporary suspended areas.'                   )
  425.       call PrintMsg( '%NOTIFY [ON/OFF]     Enable/disable notify messages.'                         )
  426.       call PrintMsg( '%FROM <address>      Remote maintenance.'                                     )
  427.       call PrintMsg( '+F <pattern>         Rescan filter on FROM    field of messages.'             )
  428.       call PrintMsg( '+T <pattern>         Rescan filter on TO      field of messages.'             )
  429.       call PrintMsg( '+S <pattern>         Rescan filter on SUBJECT field of messages.'             )
  430.       call PrintMsg( '+D <num of days>     Rescan filter on age of messages.'                       )
  431.       call PrintMsg( '+R                   Rescan all the messages, not only unread.'               )
  432.       call PrintMsg( '[---]                Everything below the tear line is ignored.'              )
  433.       call PrintMsg( ''                                                                             )
  434.       call PrintMsg( ''                                                                             )
  435.  
  436.    end
  437.  
  438.    /*
  439.    ** List: send a list with description of available areas for 'msg_addr'
  440.    */
  441.    if msg_actions.2 = 'ON' then
  442.    do
  443.  
  444.       drop list_areas.
  445.       drop list_desc.
  446.  
  447.       list_areas.0 = 0
  448.       list_desc.0  = 0
  449.       len_name     = 0
  450.  
  451.       do i=1 to areas.0
  452.  
  453.          if upper( EMS_Area_Type( areas.i ) ) = 'MAIL' then iterate
  454.  
  455.          if EMS_Areafix_Node_MatchGroup( msg_addr, areas.i ) ~= 'TRUE' then iterate
  456.  
  457.          desc = EMS_Area_Msg_Description( areas.i )
  458.  
  459.          if desc ~= '' then
  460.          do
  461.             call EMS_Add_To_Stem( 'list_areas', areas.i )
  462.             call EMS_Add_To_Stem( 'list_desc' , desc    )
  463.          end
  464.  
  465.       end
  466.  
  467.       if list_areas.0 ~= 0 then
  468.       do
  469.  
  470.          call PrintMsgUnderline( 'Short description of areas:' )
  471.  
  472.          call EMS_Calc_Stem_Width( 'list_areas', 'ADAPT' )
  473.  
  474.          do i=1 to list_areas.0
  475.  
  476.             list_areas.i = '  ' list_areas.i ':' list_desc.i
  477.  
  478.          end
  479.  
  480.          call EMS_Sort_Stem( 'list_areas' )
  481.  
  482.          do i=1 to list_areas.0
  483.  
  484.             call PrintMsg( list_areas.i )
  485.  
  486.          end
  487.  
  488.          call PrintMsg( ''                          )
  489.          call PrintMsg( 'Total found:' list_areas.0 )
  490.          call PrintMsg( ''                          )
  491.          call PrintMsg( ''                          )
  492.  
  493.       end
  494.  
  495.    end
  496.  
  497.    /*
  498.    ** Query: send a list of active or linkable areas.
  499.    */
  500.    if msg_actions.3 = 'ON' then
  501.    do
  502.  
  503.       drop list_areas.
  504.  
  505.       list_areas.0 = 0
  506.  
  507.       do i=1 to areas.0
  508.  
  509.          if upper( EMS_Area_Type( areas.i ) ) = 'MAIL' then iterate
  510.  
  511.          linked = EMS_Areafix_Node_IsLinked(   msg_addr, areas.i )
  512.          match  = EMS_Areafix_Node_MatchGroup( msg_addr, areas.i )
  513.  
  514.          if linked ~= 'NO' | match = 'TRUE' then call EMS_Add_To_Stem( 'list_areas', areas.i )
  515.  
  516.       end
  517.  
  518.       call PrintMsgUnderline( 'List of available areas for' msg_addr ':' )
  519.  
  520.       call EMS_Sort_Stem( 'list_areas' )
  521.  
  522.       do i=1 to list_areas.0
  523.  
  524.          if EMS_Areafix_Node_IsLinked( msg_addr, list_areas.i ) ~= 'NO' then pre = ' *'
  525.          else                                                                pre = '  '
  526.  
  527.          call PrintMsg( pre list_areas.i )
  528.  
  529.       end
  530.  
  531.       call PrintMsg( ''                                                           )
  532.       call PrintMsg( 'Total found:' list_areas.0                                  )
  533.       call PrintMsg( "Note: a '*' indicates you're already active for that echo." )
  534.       call PrintMsg( ''                                                           )
  535.       call PrintMsg( ''                                                           )
  536.  
  537.    end
  538.  
  539.    /*
  540.    ** Unlinked: send a list of linkable but unlinked areas.
  541.    */
  542.    if msg_actions.4 = 'ON' then
  543.    do
  544.  
  545.       drop list_areas.
  546.  
  547.       list_areas.0  = 0
  548.  
  549.       do i=1 to areas.0
  550.  
  551.          if upper( EMS_Area_Type( areas.i ) ) = 'MAIL' then iterate
  552.  
  553.          if EMS_Areafix_Node_IsLinked(   msg_addr, areas.i ) ~= 'NO'   then iterate
  554.          if EMS_Areafix_Node_MatchGroup( msg_addr, areas.i ) ~= 'TRUE' then iterate
  555.  
  556.          call EMS_Add_To_Stem( 'list_areas', areas.i )
  557.  
  558.       end
  559.  
  560.       call PrintMsgUnderline( 'List of unlinked available areas for' msg_addr ':' )
  561.  
  562.       call EMS_Sort_Stem( 'list_areas' )
  563.  
  564.       do i=1 to list_areas.0
  565.  
  566.          call PrintMsg( '  ' list_areas.i )
  567.  
  568.       end
  569.  
  570.       call PrintMsg( ''                          )
  571.       call PrintMsg( 'Total found:' list_areas.0 )
  572.       call PrintMsg( ''                          )
  573.       call PrintMsg( ''                          )
  574.  
  575.    end
  576.  
  577.    /*
  578.    ** Compress: send a list of available archivers.m
  579.    */
  580.    if msg_actions.5 = '?' then
  581.    do
  582.  
  583.       active = upper( EMS_Node_Archiver( msg_addr ) )
  584.  
  585.       call EMS_Archivers( 'list_packers' )
  586.  
  587.       call PrintMsgUnderline( 'List of available compression programs:' )
  588.  
  589.       do i=1 to list_packers.0
  590.  
  591.          if upper( list_packers.i ) = active then pre = ' *'
  592.          else                                     pre = '  '
  593.  
  594.          call PrintMsg( pre list_packers.i )
  595.  
  596.       end
  597.  
  598.       call PrintMsg( ''                                        )
  599.       call PrintMsg( "Note: a '*' indicates active selection." )
  600.       call PrintMsg( ''                                        )
  601.       call PrintMsg( ''                                        )
  602.  
  603.    end
  604.  
  605.  
  606.    if ok = 'YES' & msg_actions.7 = 'ON' then
  607.    do
  608.  
  609.       call EMS_Areafix_Node_Links_Get( msg_addr, '', 'list_areas' )
  610.  
  611.       call PrintMsgUnderline( 'Paused all the areas:' )
  612.  
  613.       call EMS_Sort_Stem( 'list_areas' )
  614.  
  615.       do i=1 to list_areas.0
  616.  
  617.          call PrintMsg( '  ' list_areas.i )
  618.  
  619.       end
  620.  
  621.       call PrintMsg( '' )
  622.  
  623.    end
  624.  
  625.  
  626.    if ok = 'YES' & msg_actions.8 = 'ON' then
  627.    do
  628.  
  629.       call EMS_Areafix_Node_Links_Get( msg_addr, 'list_areas', '' )
  630.  
  631.       call PrintMsgUnderline( 'Resumed all the areas:' )
  632.  
  633.       call EMS_Sort_Stem( 'list_areas' )
  634.  
  635.       do i=1 to list_areas.0
  636.  
  637.          call PrintMsg( '  ' list_areas.i )
  638.  
  639.       end
  640.  
  641.       call PrintMsg( '' )
  642.  
  643.    end
  644.  
  645.    call PrintMsg( '--- EMS AreaFix v1.0' )
  646.  
  647.    call EMS_Item_Header_Flag( 'reply', 'PVT', 'TRUE' )
  648.  
  649.    call EMS_Item_Write( 'reply' )
  650.    call EMS_Item_Free(  'reply' )
  651.  
  652.    areas_doexport.area_num = 'YES'
  653.  
  654.    return 0
  655.  
  656.  
  657. SendForward: procedure EXPOSE forwards. areas_doexport. aliases.
  658.  
  659.    do i=1 to forwards.0
  660.  
  661.       forward_name = EMS_Node_Areafix_Name( forwards.i.0 )
  662.  
  663.       if forward_name = '' then forward_name = aliases.0
  664.  
  665.       aka_addr  = EMS_Aka_Nearer(   forwards.i.0 )
  666.       area_name = EMS_Area_Address( areas_mail.1 )
  667.  
  668.       do j=1 to areas_mail.0
  669.  
  670.          area_addr = EMS_Area_Address( areas_mail.j )
  671.  
  672.          if EMS_Address_Compare( area_addr, aka_addr ) = 'TRUE' then area_name = areas_mail.j
  673.  
  674.       end
  675.  
  676.       area_addr = EMS_Area_Address( area_name )
  677.  
  678.       call EMS_Item_Alloc( 'forward', area_name, 'MSG' )
  679.  
  680.       call EMS_Item_Header_From(         'forward', 'AreaFix on'              area_addr      )
  681.       call EMS_Item_Header_Address_From( 'forward',                           area_addr      )
  682.       call EMS_Item_Header_To(           'forward',                           forward_name   )
  683.       call EMS_Item_Header_Address_To(   'forward',                           forwards.i.0   )
  684.       call EMS_Item_Header_Subject(      'forward', EMS_Node_Areafix_Pwd_Out( forwards.i.0 ) )
  685.       call EMS_Item_Header_Flag(         'forward', 'PVT', 'ON'                              )
  686.  
  687.       call EMS_Item_Lines_Set(           'forward', 'TEXT', 'forwards.' || i || '.1'         )
  688.       call EMS_Item_Line_Add_Tail(       'forward', 'TEXT', '---'                            )
  689.  
  690.       call EMS_Item_Write( 'forward' )
  691.       call EMS_Item_Free(  'forward' )
  692.  
  693.       call EMS_Add_To_Stem( 'areas_doexport', area_name, 'UNIQUE' )
  694.  
  695.    end
  696.  
  697.    return 0
  698.  
  699.  
  700. PrintMsgUnderline: procedure
  701.  
  702.    parse arg line
  703.  
  704.    if length( line ) = 0 then return 0
  705.  
  706.    call PrintMsg(                      line     )
  707.    call PrintMsg( copies( '-', length( line ) ) )
  708.    call PrintMsg( ''                            )
  709.  
  710.    return 0
  711.  
  712.  
  713. PrintMsg: procedure
  714.  
  715.    parse arg line
  716.  
  717.    call EMS_Item_Line_Add_Tail( 'reply', 'TEXT', line )
  718.  
  719.    return 0
  720.  
  721.  
  722. ParseMsg: procedure EXPOSE msg_from msg_addr msg_addr_real msg_subject msg_pwd ,
  723.                            msg_requests. msg_reports. msg_actions. msg_rescan.
  724.  
  725.    parse arg area , num
  726.  
  727.    call EMS_Area_Item_Flag( area, 'MSG', num, 'RCV', 'ON' )
  728.  
  729.    call EMS_Item_Alloc(     'msg', area, 'MSG', num )
  730.    call EMS_Item_Lines_Get( 'msg', 'TEXT', 'lines'  )
  731.  
  732.    msg_from      = EMS_Item_Header_From(         'msg' )
  733.    msg_addr_real = EMS_Item_Header_Address_From( 'msg' ); msg_addr = msg_addr_real
  734.    msg_subject   = EMS_Item_Header_Subject(      'msg' )
  735.  
  736.    call EMS_Item_Free( 'msg' )
  737.  
  738.    if EMS_Aka_Check( msg_addr ) = 'OK' then return 0
  739.  
  740.    /* Splits password from modifiers */
  741.    parse var msg_subject msg_pwd msg_subject
  742.  
  743.    do while length( msg_subject ) ~= 0
  744.  
  745.       parse var msg_subject opt msg_subject
  746.  
  747.       opt = upper( opt )
  748.  
  749.       select
  750.          when opt = '-R' then msg_actions.1 = 'ON'
  751.          when opt = '-L' then msg_actions.2 = 'ON'
  752.          when opt = '-Q' then msg_actions.3 = 'ON'
  753.          otherwise            nop
  754.       end
  755.  
  756.    end
  757.  
  758.  
  759.    do i=1 to lines.0
  760.  
  761.       line = strip( lines.i, 'B' )
  762.  
  763.       do while length( line ) ~= 0
  764.  
  765.          parse var line name line
  766.  
  767.          name = upper( name )
  768.  
  769.          if left( name, 3 ) =  '---' then leave i
  770.  
  771.          if left( name, 1 ) = '+' then
  772.          do
  773.  
  774.             select
  775.                when name = '+F' then do; parse var line msg_rescan.0 line  ; msg_actions.1 = 'ON'; iterate; end
  776.                when name = '+T' then do; parse var line msg_rescan.1 line  ; msg_actions.1 = 'ON'; iterate; end
  777.                when name = '+S' then do; parse var line msg_rescan.2 line  ; msg_actions.1 = 'ON'; iterate; end
  778.                when name = '+D' then do; parse var line msg_rescan.3 line  ; msg_actions.1 = 'ON'; iterate; end
  779.                when name = '+R' then do;                msg_rescan.4 = 'ON'; msg_actions.1 = 'ON'; iterate; end
  780.                otherwise        nop
  781.             end
  782.  
  783.          end
  784.  
  785.          if left( name, 1 ) = '%' then
  786.          do
  787.  
  788.             select
  789.                when name = '%HELP'     then do;                msg_actions.0 = 'ON'; iterate; end
  790.                when name = '%RESCAN'   then do;                msg_actions.1 = 'ON'; iterate; end
  791.                when name = '%LIST'     then do;                msg_actions.2 = 'ON'; iterate; end
  792.                when name = '%QUERY'    then do;                msg_actions.3 = 'ON'; iterate; end
  793.                when name = '%UNLINKED' then do;                msg_actions.4 = 'ON'; iterate; end
  794.                when name = '%COMPRESS' then do; parse var line msg_actions.5   line; iterate; end
  795.                when name = '%PWD'      then do; parse var line msg_actions.6   line; iterate; end
  796.                when name = '%PAUSE'    then do;                msg_actions.7 = 'ON'; iterate; end
  797.                when name = '%RESUME'   then do;                msg_actions.8 = 'ON'; iterate; end
  798.                when name = '%NOTIFY'   then do; parse var line msg_actions.9   line; iterate; end
  799.                when name = '%FROM'     then do; parse var line msg_addr        line; iterate; end
  800.                otherwise               nop
  801.             end
  802.  
  803.          end
  804.  
  805.          if left( name, 1 ) = '+' then name = substr( name, 2 )
  806.  
  807.          call EMS_Add_To_Stem( 'msg_requests', name, 'UNIQUE' )
  808.  
  809.       end
  810.  
  811.    end
  812.  
  813.    msg_addr = EMS_FullAddress( area, msg_addr ); if msg_addr = '' then msg_addr = msg_addr_real
  814.  
  815.    msg_actions.9 = upper( msg_actions.9 ); if msg_actions.9 ~= 'ON' & msg_actions.9 ~= 'OFF' then msg_actions.9 = ''
  816.  
  817.    return 1
  818.  
  819.  
  820. FindAreaOnOtherSystems: procedure EXPOSE nodes. forwards.
  821.  
  822.    parse arg name
  823.  
  824.    do i=1 to nodes.0
  825.  
  826.       list = EMS_Node_Areafix_EchoList( nodes.i )
  827.       if list ~= '' & ScanFileForName( list, name ) = 1 then leave
  828.  
  829.       list = EMS_Node_Areafix_FileList( nodes.i )
  830.       if list ~= '' & ScanFileForName( list, name ) = 1 then leave
  831.  
  832.    end
  833.  
  834.    if i > nodes.0 then return 0
  835.  
  836.    do j=1 to forwards.0
  837.  
  838.       if EMS_Address_Compare( forwards.j.0, nodes.i ) = 'TRUE' then leave
  839.  
  840.    end
  841.  
  842.    if j > forwards.0 then
  843.    do
  844.       forwards.0     = j
  845.       forwards.j.0   = nodes.i
  846.       forwards.j.1.0 = 0
  847.    end
  848.  
  849.    call EMS_Areafix_Node_Add( forwards.j.0, name )
  850.  
  851.    call EMS_Add_To_Stem( 'forwards.' || j || '.1', name, 'UNIQUE' )
  852.  
  853.    return 0
  854.  
  855.  
  856. ScanFileForName: procedure
  857.  
  858.    parse arg file , match
  859.  
  860.    if ~open( 'file', file ) then return 0
  861.  
  862.    match = upper( match )
  863.  
  864.    do while ~eof( 'file' )
  865.  
  866.       line = readln( 'file' )
  867.  
  868.       do while length( line ) ~= 0
  869.  
  870.          parse var line name line
  871.  
  872.          if match = upper( name ) then
  873.          do
  874.  
  875.             call close( 'file' )
  876.             return 1
  877.  
  878.          end
  879.  
  880.       end
  881.  
  882.    end
  883.  
  884.    call close( 'file' )
  885.  
  886.    return 0
  887.