home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lora299s.zip / UTILITY.CPP < prev    next >
C/C++ Source or Header  |  1997-05-26  |  53KB  |  1,467 lines

  1.  
  2. // ----------------------------------------------------------------------
  3. // LoraBBS Professional Edition - Version 3.00.5
  4. // Copyright (c) 1996 by Marco Maccaferri. All rights reserved.
  5. //
  6. // History:
  7. //    06/06/96 - Initial coding.
  8. // ----------------------------------------------------------------------
  9.  
  10. #include "_ldefs.h"
  11. #include "msgbase.h"
  12. #include "lorawin.h"
  13.  
  14. enum {
  15.    ALREADY_LINKED = 2,
  16.    NOT_FOUND
  17. };
  18.  
  19. TAreaManager::TAreaManager (void)
  20. {
  21.    Log = NULL;
  22.    EchoLink = NULL;
  23. }
  24.  
  25. TAreaManager::~TAreaManager (void)
  26. {
  27. }
  28.  
  29. VOID TAreaManager::MsgFooter (VOID)
  30. {
  31.    CHAR Temp[96];
  32.  
  33.    Text.Add ("");
  34.    sprintf (Temp, "--- %s v%s", NAME, VERSION);
  35.    Text.Add (Temp);
  36. }
  37.  
  38. VOID TAreaManager::MsgHeader (VOID)
  39. {
  40.    CHAR Temp[96];
  41.    class TAddress From, To;
  42.  
  43.    From.Parse (Msg->FromAddress);
  44.    To.Parse (Msg->ToAddress);
  45.  
  46.    if (From.Zone != To.Zone) {
  47.       sprintf (Temp, "\001INTL %u:%u/%u %u:%u/%u", To.Zone, To.Net, To.Node, From.Zone, From.Net, From.Node);
  48.       Text.Add (Temp);
  49.    }
  50.    if (From.Point != 0) {
  51.       sprintf (Temp, "\001FMPT %u", From.Point);
  52.       Text.Add (Temp);
  53.    }
  54.    if (To.Point != 0) {
  55.       sprintf (Temp, "\001TOPT %u", To.Point);
  56.       Text.Add (Temp);
  57.    }
  58.  
  59.    sprintf (Temp, "\001MSGID: %s %08lx", Msg->ToAddress, time (NULL));
  60.    Text.Add (Temp);
  61.    sprintf (Temp, "\001PID: %s", NAME);
  62.    Text.Insert (Temp, (USHORT)(strlen (Temp) + 1));
  63. }
  64.  
  65. USHORT TAreaManager::SetPacker (PSZ Cmd)
  66. {
  67.    USHORT RetVal = FALSE;
  68.    CHAR Temp[128];
  69.    class TPacker *Packer;
  70.    class TNodes *Nodes;
  71.  
  72.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  73.       if (Nodes->Read (Msg->FromAddress) == TRUE) {
  74.          if ((Packer = new TPacker (Cfg->SystemPath)) != NULL) {
  75.             if (Packer->Read (Cmd) == TRUE) {
  76.                strcpy (Nodes->Packer, Cmd);
  77.                Nodes->Update ();
  78.                sprintf (Temp, "Compressor set to %s (%s).", Packer->Display, strupr (Cmd));
  79.                RetVal = TRUE;
  80.             }
  81.             delete Packer;
  82.          }
  83.       }
  84.       delete Nodes;
  85.    }
  86.  
  87.    if (RetVal == FALSE)
  88.       sprintf (Temp, "The compressor %s was not found.", strupr (Cmd));
  89.    Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  90.  
  91.    return (RetVal);
  92. }
  93.  
  94. VOID TAreaManager::ImportAreasBBS (VOID)
  95. {
  96.    #define MAX_LINECHAR 2048
  97.    int i, counter, existing;
  98.    FILE *fp = fopen (Cfg->AreasBBS, "rt");
  99.    CHAR *lpTemp = (CHAR *)malloc (MAX_LINECHAR + 1);
  100.    CHAR *lpPath, *lpTag, *lpLink, Name[16];
  101.    class TMsgData *MsgData = new TMsgData (Cfg->SystemPath);
  102.    class TEchoLink *EchoLink = new TEchoLink (Cfg->SystemPath);
  103.  
  104.    counter = 0;
  105.    existing = 0;
  106.    if (Log != NULL)
  107.       Log->Write ("+Import areas from %s", Cfg->AreasBBS);
  108.  
  109.    if (fp != NULL && lpTemp != NULL && MsgData != NULL && EchoLink != NULL) {
  110.       fgets (lpTemp, MAX_LINECHAR, fp);
  111.       while (fgets (lpTemp, MAX_LINECHAR, fp) != NULL) {
  112.          lpTemp[strlen (lpTemp) - 1] = '\0';
  113.          if (lpTemp[0] == ';' || lpTemp[0] == '\0')
  114.             continue;
  115.          if ((lpPath = strtok (lpTemp, " ")) != NULL) {
  116.             if ((lpTag = strtok (NULL, " ")) != NULL) {
  117.                if (MsgData->ReadEcho (lpTag) == FALSE) {
  118.                   i = 1;
  119.                   do {
  120.                      sprintf (Name, "newarea%d", i++);
  121.                   } while (MsgData->Read (Name) == TRUE);
  122.  
  123.                   MsgData->New ();
  124.                   strcpy (MsgData->Key, Name);
  125.                   sprintf (MsgData->Display, "Imported area %s", lpTag);
  126.                   strcpy (MsgData->EchoTag, lpTag);
  127.                   if (lpPath[0] == '$') {
  128.                      MsgData->Storage = ST_SQUISH;
  129.                      lpPath++;
  130.                   }
  131.                   else if (lpPath[0] == '!') {
  132.                      MsgData->Storage = ST_JAM;
  133.                      lpPath++;
  134.                   }
  135.                   else if (lpPath[0] == '=') {
  136.                      MsgData->Storage = ST_SQUISH;
  137.                      lpPath++;
  138.                   }
  139.                   else if (isdigit (lpPath[0]))
  140.                      MsgData->Storage = ST_HUDSON;
  141.                   else
  142.                      MsgData->Storage = ST_FIDO;
  143.                   MsgData->EchoMail = TRUE;
  144.                   MsgData->Add ();
  145.                }
  146.                else
  147.                   existing++;
  148.  
  149.                EchoLink->Load (lpTag);
  150.                EchoLink->Clear ();
  151.                if ((lpLink = strtok (NULL, "")) != NULL)
  152.                   EchoLink->AddString (lpLink);
  153.                EchoLink->Save ();
  154.  
  155.                counter++;
  156.             }
  157.          }
  158.       }
  159.    }
  160.  
  161.    if (Log != NULL)
  162.       Log->Write (":%d area(s) readed, %d new", counter, counter - existing);
  163.  
  164.    if (EchoLink != NULL)
  165.       delete EchoLink;
  166.    if (MsgData != NULL)
  167.       delete MsgData;
  168.    if (lpTemp != NULL)
  169.       free (lpTemp);
  170.    if (fp != NULL)
  171.       fclose (fp);
  172. }
  173.  
  174. VOID TAreaManager::UpdateAreasBBS (VOID)
  175. {
  176.    FILE *fp;
  177.    int counter = 0;
  178.    class TMsgData *MsgData;
  179.    class TEchoLink *EchoLink;
  180.  
  181.    if (Log != NULL)
  182.       Log->Write ("+Updating %s", Cfg->AreasBBS);
  183.  
  184.    if ((fp = fopen (Cfg->AreasBBS, "wt")) != NULL) {
  185.       fprintf (fp, "%s ! %s\n;\n", Cfg->SystemName, Cfg->SysopName);
  186.       if ((EchoLink = new TEchoLink (Cfg->SystemPath)) != NULL) {
  187.          if ((MsgData = new TMsgData (Cfg->SystemPath)) != NULL) {
  188.             if (MsgData->First () == TRUE)
  189.                do {
  190.                   if (MsgData->EchoMail == TRUE && MsgData->EchoTag[0] != '\0') {
  191.                      if (MsgData->Storage == ST_SQUISH)
  192.                         fprintf (fp, "$%-30s", MsgData->Path);
  193.                      else if (MsgData->Storage == ST_JAM)
  194.                         fprintf (fp, "!%-30s", MsgData->Path);
  195.                      else if (MsgData->Storage == ST_ADEPT)
  196.                         fprintf (fp, "=%-30s", MsgData->Path);
  197.                      else if (MsgData->Storage == ST_FIDO)
  198.                         fprintf (fp, "%-30s ", MsgData->Path);
  199.                      else if (MsgData->Storage == ST_HUDSON)
  200.                         fprintf (fp, "%-30d ", MsgData->Board);
  201.                      EchoLink->Load (MsgData->EchoTag);
  202.                      fprintf (fp, " %-30s", MsgData->EchoTag);
  203.                      if (EchoLink->First () == TRUE)
  204.                         do {
  205.                            fprintf (fp, " %s", EchoLink->Address);
  206.                         } while (EchoLink->Next () == TRUE);
  207.                      fprintf (fp, "\n");
  208.                      counter++;
  209.                   }
  210.                } while (MsgData->Next () == TRUE);
  211.             delete MsgData;
  212.          }
  213.          delete EchoLink;
  214.       }
  215.       fprintf (fp, ";\n");
  216.       fclose (fp);
  217.    }
  218.  
  219.    if (Log != NULL)
  220.       Log->Write (":%d area(s) exported", counter);
  221. }
  222.  
  223. USHORT TAreaManager::Passive (PSZ address, USHORT flag)
  224. {
  225.    USHORT RetVal = FALSE;
  226.    CHAR Temp[96];
  227.  
  228.    if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  229.       if (Data->First () == TRUE)
  230.          do {
  231.             if (Data->EchoMail == TRUE && Data->EchoTag[0] != '\0') {
  232.                EchoLink->Load (Data->EchoTag);
  233.                if (EchoLink->Check (address) == TRUE) {
  234.                   if (EchoLink->Passive != flag) {
  235.                      EchoLink->Passive = (UCHAR)flag;
  236.                      EchoLink->Update ();
  237.                      EchoLink->Save ();
  238.                      sprintf (Temp, "Area %s is now %s.", strupr (Data->EchoTag), (flag == TRUE) ? "passive" : "active");
  239.                   }
  240.                   else
  241.                      sprintf (Temp, "Area %s already %s.", strupr (Data->EchoTag), (flag == TRUE) ? "passive" : "active");
  242.                   Text.Add (Temp);
  243.                   RetVal = TRUE;
  244.                }
  245.             }
  246.          } while (Data->Next () == TRUE);
  247.       delete Data;
  248.    }
  249.  
  250.    return (RetVal);
  251. }
  252.  
  253. ///////////////////////////////////////////////////////////////////////////////
  254. // Rimuove tutte le aree agganciate ad un nodo                               //
  255. ///////////////////////////////////////////////////////////////////////////////
  256. USHORT TAreaManager::RemoveAll (PSZ address)
  257. {
  258.    USHORT RetVal = FALSE, DoDelete = FALSE;
  259.    CHAR Temp[96];
  260.  
  261.    if (EchoLink == NULL) {
  262.       EchoLink = new TEchoLink (Cfg->SystemPath);
  263.       DoDelete = TRUE;
  264.    }
  265.  
  266.    if (EchoLink != NULL) {
  267.       if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  268.          if (Data->First () == TRUE)
  269.             do {
  270.                if (Data->EchoMail == TRUE && Data->EchoTag[0] != '\0') {
  271.                   EchoLink->Load (Data->EchoTag);
  272.                   if (EchoLink->Check (address) == TRUE) {
  273.                      EchoLink->Delete ();
  274.                      EchoLink->Save ();
  275.                      sprintf (Temp, "Area %s has been removed.", strupr (Data->EchoTag));
  276.                      Text.Add (Temp);
  277.                      RetVal = TRUE;
  278.                   }
  279.                }
  280.             } while (Data->Next () == TRUE);
  281.          delete Data;
  282.       }
  283.    }
  284.  
  285.    if (EchoLink != NULL && DoDelete == TRUE) {
  286.       delete EchoLink;
  287.       EchoLink = NULL;
  288.    }
  289.  
  290.    return (RetVal);
  291. }
  292.  
  293. ///////////////////////////////////////////////////////////////////////////////
  294. // Imposta la password di sessione                                           //
  295. ///////////////////////////////////////////////////////////////////////////////
  296. USHORT TAreaManager::SetSessionPwd (PSZ address, PSZ pwd)
  297. {
  298.    USHORT RetVal = FALSE;
  299.  
  300.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  301.       if (Nodes->Read (address) == TRUE) {
  302.          strcpy (Nodes->SessionPwd, pwd);
  303.          Nodes->Update ();
  304.          RetVal = TRUE;
  305.       }
  306.       delete Nodes;
  307.    }
  308.  
  309.    return (RetVal);
  310. }
  311.  
  312. USHORT TAreaManager::SetPwd (PSZ address, PSZ pwd)
  313. {
  314.    USHORT RetVal = FALSE;
  315.  
  316.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  317.       if (Nodes->Read (address) == TRUE) {
  318.          strcpy (Nodes->AreaMgrPwd, pwd);
  319.          Nodes->Update ();
  320.          RetVal = TRUE;
  321.       }
  322.       delete Nodes;
  323.    }
  324.  
  325.    return (RetVal);
  326. }
  327.  
  328. USHORT TAreaManager::SetPacketPwd (PSZ address, PSZ pwd)
  329. {
  330.    USHORT RetVal = FALSE;
  331.  
  332.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  333.       if (Nodes->Read (address) == TRUE) {
  334.          if (pwd == NULL)
  335.             Nodes->InPktPwd[0] = Nodes->OutPktPwd[0] = '\0';
  336.          else {
  337.             strcpy (Nodes->InPktPwd, pwd);
  338.             strcpy (Nodes->OutPktPwd, pwd);
  339.          }
  340.          Nodes->Update ();
  341.          RetVal = TRUE;
  342.       }
  343.       delete Nodes;
  344.    }
  345.  
  346.    return (RetVal);
  347. }
  348.  
  349. USHORT TAreaManager::SetInPacketPwd (PSZ address, PSZ pwd)
  350. {
  351.    USHORT RetVal = FALSE;
  352.  
  353.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  354.       if (Nodes->Read (address) == TRUE) {
  355.          if (pwd == NULL)
  356.             Nodes->OutPktPwd[0] = '\0';
  357.          else
  358.             strcpy (Nodes->OutPktPwd, pwd);
  359.          Nodes->Update ();
  360.          RetVal = TRUE;
  361.       }
  362.       delete Nodes;
  363.    }
  364.  
  365.    return (RetVal);
  366. }
  367.  
  368. USHORT TAreaManager::SetOutPacketPwd (PSZ address, PSZ pwd)
  369. {
  370.    USHORT RetVal = FALSE;
  371.  
  372.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  373.       if (Nodes->Read (address) == TRUE) {
  374.          if (pwd == NULL)
  375.             Nodes->InPktPwd[0] = '\0';
  376.          else
  377.             strcpy (Nodes->InPktPwd, pwd);
  378.          Nodes->Update ();
  379.          RetVal = TRUE;
  380.       }
  381.       delete Nodes;
  382.    }
  383.  
  384.    return (RetVal);
  385. }
  386.  
  387. ///////////////////////////////////////////////////////////////////////////////
  388. // Aggancia un'area ad un nuodo                                              //
  389. ///////////////////////////////////////////////////////////////////////////////
  390. USHORT TAreaManager::AddArea (PSZ address, PSZ area)
  391. {
  392.    USHORT RetVal = FALSE, DoDelete = FALSE;
  393.    class TNodes *Nodes;
  394.    class TMsgData *Data;
  395.  
  396.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  397.       if (Nodes->Read (Msg->FromAddress) == TRUE) {
  398.          if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  399.             if (Data->ReadEcho (area) == TRUE) {
  400.                if (Nodes->Level < Data->Level)
  401.                   RetVal = NOT_FOUND;
  402.                if ((Nodes->AccessFlags & Data->Flags) != Data->Flags)
  403.                   RetVal = NOT_FOUND;
  404.                if ((Nodes->DenyFlags & Data->DenyFlags) != Data->DenyFlags && Data->DenyFlags != 0L)
  405.                   RetVal = NOT_FOUND;
  406.                if (Log != NULL && RetVal == NOT_FOUND)
  407.                   Log->Write ("!Area %s not accessible to node", area);
  408.             }
  409.             else
  410.                RetVal = NOT_FOUND;
  411.             delete Data;
  412.          }
  413.       }
  414.       delete Nodes;
  415.    }
  416.  
  417.    if (RetVal == NOT_FOUND)
  418.       return (RetVal);
  419.  
  420.    ///////////////////////////////////////////////////////////////////////////////
  421.    // Si assicura che la classe EchoLink sia accessibile                        //
  422.    ///////////////////////////////////////////////////////////////////////////////
  423.    if (EchoLink == NULL) {
  424.       EchoLink = new TEchoLink (Cfg->SystemPath);
  425.       DoDelete = TRUE;
  426.    }
  427.  
  428.    if (EchoLink != NULL) {
  429.       EchoLink->Load (area);
  430.       if (EchoLink->First () == TRUE) {
  431.          if (EchoLink->Check (address) == TRUE)
  432.             RetVal = ALREADY_LINKED;
  433.          else {
  434.             EchoLink->AddString (address);
  435.             EchoLink->Save ();
  436.             RetVal = TRUE;
  437.          }
  438.       }
  439.       else {
  440.          ///////////////////////////////////////////////////////////////////////////////
  441.          // Se non trova l'area negli echolink, ne verifica l'esistenza               //
  442.          ///////////////////////////////////////////////////////////////////////////////
  443.          RetVal = NOT_FOUND;
  444.          if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  445.             if (Data->ReadEcho (area) == TRUE) {
  446.                EchoLink->Load (area);
  447.                EchoLink->AddString (address);
  448.                EchoLink->Save ();
  449.                RetVal = TRUE;
  450.             }
  451.             delete Data;
  452.          }
  453.       }
  454.    }
  455.  
  456.    if (EchoLink != NULL && DoDelete == TRUE) {
  457.       delete EchoLink;
  458.       EchoLink = NULL;
  459.    }
  460.  
  461.    return (RetVal);
  462. }
  463.  
  464. USHORT TAreaManager::RemoveArea (PSZ address, PSZ area)
  465. {
  466.    USHORT RetVal = FALSE, DoDelete = FALSE;
  467.  
  468.    if (EchoLink == NULL) {
  469.       EchoLink = new TEchoLink (Cfg->SystemPath);
  470.       DoDelete = TRUE;
  471.    }
  472.  
  473.    if (EchoLink != NULL) {
  474.       EchoLink->Load (area);
  475.       if (EchoLink->First () == TRUE) {
  476.          if (EchoLink->Check (address) == TRUE) {
  477.             EchoLink->Delete ();
  478.             EchoLink->Save ();
  479.             RetVal = TRUE;
  480.          }
  481.       }
  482.    }
  483.  
  484.    if (EchoLink != NULL && DoDelete == TRUE) {
  485.       delete EchoLink;
  486.       EchoLink = NULL;
  487.    }
  488.  
  489.    return (RetVal);
  490. }
  491.  
  492. VOID TAreaManager::ProcessAreafix (VOID)
  493. {
  494.    FILE *fp;
  495.    USHORT i, Ok, DoList, DoRescan, DoLinked, DoUnlinked, CanMaint;
  496.    USHORT DoListPacker, DoReport, DoHelp, Level, CanRename;
  497.    ULONG AccessFlags, DenyFlags;
  498.    CHAR Address[48], Temp[96], *Password, *p;
  499.    ULONG Total;
  500. //   class TPacker *Packer;
  501.  
  502.    CanMaint = FALSE;
  503.  
  504.    strcpy (Address, Msg->FromAddress);
  505.    if (Log != NULL)
  506.       Log->Write ("#Process AreaMgr requests for %s", Address);
  507.  
  508.    strcpy (Temp, Msg->Subject);
  509.    if ((Password = strtok (Temp, " ")) == NULL)
  510.       Password = "";
  511.  
  512.    Ok = FALSE;
  513.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  514.       if (Nodes->Read (Address) == TRUE) {
  515.          Level = Nodes->Level;
  516.          AccessFlags = Nodes->AccessFlags;
  517.          DenyFlags = Nodes->DenyFlags;
  518.          CanMaint = Nodes->EchoMaint;
  519.          CanRename = Nodes->ChangeEchoTag;
  520.          if (!stricmp (Password, Nodes->AreaMgrPwd))
  521.             Ok = TRUE;
  522.       }
  523.       delete Nodes;
  524.    }
  525.  
  526.    if (Ok == TRUE) {
  527.       DoList = DoRescan = DoLinked = DoUnlinked = FALSE;
  528.       DoHelp = DoListPacker = FALSE;
  529.       DoReport = FALSE;
  530.  
  531.       strcpy (Temp, Msg->Subject);
  532.       if ((p = strtok (Temp, " ")) != NULL) {
  533.          while ((p = strtok (NULL, " ")) != NULL) {
  534.             if (!stricmp (p, "-l"))
  535.                DoList = TRUE;
  536.             else if (!stricmp (p, "-r"))
  537.                DoRescan = TRUE;
  538.          }
  539.       }
  540.  
  541.       Text.Clear ();
  542.       MsgHeader ();
  543.  
  544.       sprintf (Temp, "Following is a summary from %s of changes in Echomail topology:", Msg->ToAddress);
  545.       Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  546.       Text.Add ("");
  547.  
  548.       if ((EchoLink = new TEchoLink (Cfg->SystemPath)) != NULL) {
  549.          if ((p = (CHAR *)Msg->Text.First ()) != NULL)
  550.             do {
  551.                if ((p = strtok (p, " ")) != NULL) {
  552.                   if (*p == '%') {
  553.                      if (!stricmp (p, "%rescan"))
  554.                         DoRescan = TRUE;
  555.                      else if (!stricmp (p, "%help"))
  556.                         DoHelp = TRUE;
  557.                      else if (!stricmp (p, "%list"))
  558.                         DoList = TRUE;
  559.                      else if (!stricmp (p, "%unlinked"))
  560.                         DoUnlinked = TRUE;
  561.                      else if (!stricmp (p, "%linked") || !stricmp (p, "%query"))
  562.                         DoLinked = TRUE;
  563.                      else if (!stricmp (p, "%from")) {
  564.                         if (CanMaint == TRUE) {
  565.                            strcpy (Address, &p[6]);
  566.                            if (Log != NULL)
  567.                               Log->Write ("#Remote maintenance for %s", Address);
  568.                            sprintf (Temp, "Remote maintenance for %s", Address);
  569.                         }
  570.                         else
  571.                            sprintf (Temp, "Remote maintenance not allowed");
  572.                         Text.Add (Temp);
  573.                      }
  574.                      else if (!stricmp (p, "%packer")) {
  575.                         if ((p = strtok (NULL, " ")) != NULL)
  576.                            SetPacker (p);
  577.                         else
  578.                            DoListPacker = TRUE;
  579.                      }
  580.                      else if (!stricmp (p, "%passive")) {
  581.                         if (Passive (Address, TRUE) == TRUE)
  582.                            DoReport = TRUE;
  583.                      }
  584.                      else if (!stricmp (p, "%active")) {
  585.                         if (Passive (Address, FALSE) == TRUE)
  586.                            DoReport = TRUE;
  587.                      }
  588.                      else if (!stricmp (p, "%-all")) {
  589.                         if (RemoveAll (Address) == TRUE)
  590.                            DoReport = TRUE;
  591.                      }
  592.                      else if (!stricmp (p, "%pwd")) {
  593.                         if ((p = strtok (NULL, " ")) != NULL) {
  594.                            if (SetPwd (Address, p) == TRUE)
  595.                               DoReport = TRUE;
  596.                         }
  597.                      }
  598.                      else if (!stricmp (p, "%sessionpwd")) {
  599.                         if ((p = strtok (NULL, " ")) != NULL) {
  600.                            if (SetSessionPwd (Address, p) == TRUE)
  601.                               DoReport = TRUE;
  602.                         }
  603.                      }
  604.                      else if (!stricmp (p, "%pktpwd")) {
  605.                         p = strtok (NULL, " ");
  606.                         if (SetPacketPwd (Address, p) == TRUE)
  607.                            DoReport = TRUE;
  608.                      }
  609.                      else if (!stricmp (p, "%inpktpwd")) {
  610.                         p = strtok (NULL, " ");
  611.                         if (SetInPacketPwd (Address, p) == TRUE)
  612.                            DoReport = TRUE;
  613.                      }
  614.                      else if (!stricmp (p, "%outpktpwd")) {
  615.                         p = strtok (NULL, " ");
  616.                         if (SetOutPacketPwd (Address, p) == TRUE)
  617.                            DoReport = TRUE;
  618.                      }
  619.                   }
  620.                   else if (*p == '#') {
  621.                      if (CanRename == TRUE) {
  622.                         if ((p = strtok (NULL, " :")) != NULL) {
  623.                            if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  624.                               if (Data->ReadEcho (p) == TRUE) {
  625.                                  if ((p = strtok (NULL, " :")) != NULL) {
  626.                                     if (Log != NULL)
  627.                                        Log->Write ("#Area %s changed to %s", Data->EchoTag, p);
  628.                                     sprintf (Temp, "Area %s changed to %s", Data->EchoTag, p);
  629.                                     Text.Add (Temp);
  630.                                     // Cambia il tag nel file dei forward
  631.                                     EchoLink->Change (Data->EchoTag, p);
  632.                                     // Cambia il tag nella configurazione dell'area
  633.                                     strcpy (Data->EchoTag, p);
  634.                                     Data->Update ();
  635.                                  }
  636.                               }
  637.                               delete Data;
  638.                            }
  639.                         }
  640.                      }
  641.                      else
  642.                         Text.Add ("Remote maintenance not allowed");
  643.                   }
  644.                   else if (*p == '-' && strcmp (p, "---")) {
  645.                      p++;
  646.                      if (RemoveArea (Address, p) == FALSE)
  647.                         sprintf (Temp, "Area %s never linked.", strupr (p));
  648.                      else
  649.                         sprintf (Temp, "Area %s has been removed.", strupr (p));
  650.                      Text.Add (Temp);
  651.                      DoReport = TRUE;
  652.                   }
  653.                   else if (*p != '\0' && strcmp (p, "---") && *p != '\001') {
  654.                      if (*p == '+')
  655.                         p++;
  656.                      if ((i = AddArea (Address, p)) == TRUE)
  657.                         sprintf (Temp, "Area %s has been added.\n", strupr (p));
  658.                      else if (i == NOT_FOUND)
  659.                         sprintf (Temp, "Area %s not found.\n", strupr (p));
  660.                      else if (i == ALREADY_LINKED)
  661.                         sprintf (Temp, "Area %s already linked.\n", strupr (p));
  662.                      Text.Add (Temp);
  663.                      DoReport = TRUE;
  664.                   }
  665.                }
  666.             } while ((p = (CHAR *)Msg->Text.Next ()) != NULL);
  667.          delete EchoLink;
  668.       }
  669.  
  670.       strcpy (Temp, Msg->FromAddress);
  671.       strcpy (Msg->FromAddress, Msg->ToAddress);
  672.       strcpy (Msg->ToAddress, Temp);
  673.       strcpy (Msg->To, Msg->From);
  674.       strcpy (Msg->From, "Echo Manager");
  675.  
  676.       if (DoReport == TRUE) {
  677.          MsgFooter ();
  678.          strcpy (Msg->Subject, "EchoMail changes report");
  679.          Msg->Text.Clear ();
  680.          Msg->Local = TRUE;
  681.          Msg->Crash = Msg->Direct = Msg->Hold = FALSE;
  682.          Msg->Sent = FALSE;
  683.          Msg->Add (Text);
  684.  
  685.          // Invia le notifiche dei cambiamenti ai nodi indicati
  686.          if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  687.             strcpy (Temp, Msg->ToAddress);
  688.             if (Nodes->First () == TRUE)
  689.                do {
  690.                   if (Nodes->NotifyAreafix == TRUE && stricmp (Temp, Nodes->Address)) {
  691.                      strcpy (Msg->To, Nodes->SysopName);
  692.                      if (Msg->To[0] == '\0')
  693.                         strcpy (Msg->To, "Sysop");
  694.                      strcpy (Msg->ToAddress, Nodes->Address);
  695.                      Msg->Add (Text);
  696.                      if (Log != NULL)
  697.                         Log->Write ("-Sent notification to %s (%s)", Msg->To, Msg->ToAddress);
  698.                   }
  699.                } while (Nodes->Next () == TRUE);
  700.             delete Nodes;
  701.          }
  702.  
  703.          if (Cfg->UpdateAreasBBS == TRUE)
  704.             UpdateAreasBBS ();
  705.       }
  706.  
  707.       if (DoList == TRUE) {
  708.          Total = 0L;
  709.          strcpy (Msg->Subject, "List of available echomail areas");
  710.          Text.Clear ();
  711.          MsgHeader ();
  712.  
  713.          sprintf (Temp, "Area(s) available to %s:", Msg->ToAddress);
  714.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  715.          Text.Add ("");
  716.          if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  717.             if (Data->First () == TRUE)
  718.                do {
  719.                   if (Level < Data->Level)
  720.                      continue;
  721.                   if ((AccessFlags & Data->Flags) != Data->Flags)
  722.                      continue;
  723.                   if ((DenyFlags & Data->DenyFlags) != Data->DenyFlags && Data->DenyFlags != 0L)
  724.                      continue;
  725.                   if (Data->EchoMail == TRUE && Data->EchoTag[0] != '\0') {
  726.                      sprintf (Temp, "%-30.30s %.48s", Data->EchoTag, Data->Display);
  727.                      Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  728.                      Total++;
  729.                   }
  730.                } while (Data->Next () == TRUE);
  731.             delete Data;
  732.          }
  733.          Text.Add ("");
  734.          sprintf (Temp, "%lu available area(s).", Total);
  735.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  736.  
  737.          MsgFooter ();
  738.          Msg->Add (Text);
  739.       }
  740.  
  741.       if (DoLinked == TRUE) {
  742.          strcpy (Msg->Subject, "List of linked echomail areas");
  743.          Text.Clear ();
  744.          MsgHeader ();
  745.  
  746.          sprintf (Temp, "%s is now linked to the following area(s):", Msg->ToAddress);
  747.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  748.          Text.Add ("");
  749.          Total = 0L;
  750.          if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  751.             EchoLink = new TEchoLink (Cfg->SystemPath);
  752.             if (Data->First () == TRUE)
  753.                do {
  754.                   if (Data->EchoMail == TRUE && Data->EchoTag[0] != '\0' && EchoLink != NULL) {
  755.                      EchoLink->Load (Data->EchoTag);
  756.                      if (EchoLink->Check (Msg->ToAddress) == TRUE) {
  757.                         sprintf (Temp, "%-30.30s %.48s", Data->EchoTag, Data->Display);
  758.                         Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  759.                         Total++;
  760.                      }
  761.                   }
  762.                } while (Data->Next () == TRUE);
  763.             if (EchoLink != NULL)
  764.                delete EchoLink;
  765.             delete Data;
  766.          }
  767.          Text.Add ("");
  768.          sprintf (Temp, "%lu linked area(s).", Total);
  769.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  770.  
  771.          MsgFooter ();
  772.          Msg->Add (Text);
  773.       }
  774.  
  775.       if (DoUnlinked == TRUE) {
  776.          strcpy (Msg->Subject, "List of unlinked echomail areas");
  777.          Text.Clear ();
  778.          MsgHeader ();
  779.  
  780.          sprintf (Temp, "Area(s) not linked to %s:", Msg->ToAddress);
  781.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  782.          Text.Add ("");
  783.          Total = 0L;
  784.          if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  785.             EchoLink = new TEchoLink (Cfg->SystemPath);
  786.             if (Data->First () == TRUE)
  787.                do {
  788.                   if (Level < Data->Level)
  789.                      continue;
  790.                   if ((AccessFlags & Data->Flags) != Data->Flags)
  791.                      continue;
  792.                   if ((DenyFlags & Data->DenyFlags) != Data->DenyFlags && Data->DenyFlags != 0L)
  793.                      continue;
  794.                   if (Data->EchoMail == TRUE && Data->EchoTag[0] != '\0' && EchoLink != NULL) {
  795.                      EchoLink->Load (Data->EchoTag);
  796.                      if (EchoLink->Check (Msg->ToAddress) == FALSE) {
  797.                         sprintf (Temp, "%-30.30s %.48s", Data->EchoTag, Data->Display);
  798.                         Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  799.                         Total++;
  800.                      }
  801.                   }
  802.                } while (Data->Next () == TRUE);
  803.             if (EchoLink != NULL)
  804.                delete EchoLink;
  805.             delete Data;
  806.          }
  807.          Text.Add ("");
  808.          sprintf (Temp, "%lu unlinked area(s).", Total);
  809.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  810.          MsgFooter ();
  811.  
  812.          Msg->Add (Text);
  813.       }
  814.  
  815.       if (DoHelp == TRUE) {
  816.          strcpy (Msg->Subject, "Areafix help");
  817.          Text.Clear ();
  818.          MsgHeader ();
  819.  
  820.          sprintf (Temp, "%safxhelp.txt", Cfg->SystemPath);
  821.          if ((fp = fopen (Temp, "rt")) != NULL) {
  822.             while (fgets (Temp, sizeof (Temp) - 1, fp) != NULL) {
  823.                Temp[strlen (Temp) - 1] = '\0';
  824.                Text.Add (Temp);
  825.             }
  826.             fclose (fp);
  827.          }
  828.          else {
  829.             Text.Add ("");
  830.             Text.Add ("No help file available. Contact the Sysop.");
  831.             Text.Add ("");
  832.          }
  833.  
  834.          MsgFooter ();
  835.          Msg->Add (Text);
  836.       }
  837.    }
  838.    else {
  839.       Text.Clear ();
  840.       MsgHeader ();
  841.  
  842.       if (Log != NULL)
  843.          Log->Write ("!Node %s is not authorized for echomanager", Msg->FromAddress);
  844.  
  845.       Text.Add ("");
  846.       sprintf (Temp, "Node %s isn't authorized to use areafix at %s", Msg->FromAddress, Msg->ToAddress);
  847.       Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  848.       Text.Add ("");
  849.  
  850.       strcpy (Temp, Msg->FromAddress);
  851.       strcpy (Msg->FromAddress, Msg->ToAddress);
  852.       strcpy (Msg->ToAddress, Temp);
  853.       strcpy (Msg->To, Msg->From);
  854.       strcpy (Msg->From, "Echo Manager");
  855.       strcpy (Msg->Subject, "EchoMail changes report");
  856.       Msg->Text.Clear ();
  857.       Msg->Local = TRUE;
  858.       Msg->Crash = Msg->Direct = Msg->Hold = FALSE;
  859.  
  860.       MsgFooter ();
  861.       Msg->Add (Text);
  862.  
  863.       // Invia le notifiche dei cambiamenti ai nodi indicati
  864.       if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  865.          strcpy (Temp, Msg->ToAddress);
  866.          if (Nodes->First () == TRUE)
  867.             do {
  868.                if (Nodes->NotifyAreafix == TRUE && stricmp (Temp, Nodes->Address)) {
  869.                   strcpy (Msg->To, Nodes->SysopName);
  870.                   if (Msg->To[0] == '\0')
  871.                      strcpy (Msg->To, "Sysop");
  872.                   strcpy (Msg->ToAddress, Nodes->Address);
  873.                   Msg->Add (Text);
  874.                   if (Log != NULL)
  875.                      Log->Write ("-Sent notification to %s (%s)", Msg->To, Msg->ToAddress);
  876.                }
  877.             } while (Nodes->Next () == TRUE);
  878.          delete Nodes;
  879.       }
  880.    }
  881. }
  882.  
  883. USHORT TAreaManager::FilePassive (PSZ address, USHORT flag)
  884. {
  885.    USHORT RetVal = FALSE;
  886.    CHAR Temp[96];
  887.  
  888.    if ((FileData = new TFileData (Cfg->SystemPath)) != NULL) {
  889.       if (FileData->First () == TRUE)
  890.          do {
  891.             if (FileData->EchoTag[0] != '\0') {
  892.                FileEchoLink->Load (FileData->EchoTag);
  893.                if (FileEchoLink->Check (address) == TRUE) {
  894.                   if (FileEchoLink->Passive != flag) {
  895.                      FileEchoLink->Passive = (UCHAR)flag;
  896.                      FileEchoLink->Update ();
  897.                      FileEchoLink->Save ();
  898.                      sprintf (Temp, "Area %s is now %s.", strupr (FileData->EchoTag), (flag == TRUE) ? "passive" : "active");
  899.                   }
  900.                   else
  901.                      sprintf (Temp, "Area %s already %s.", strupr (FileData->EchoTag), (flag == TRUE) ? "passive" : "active");
  902.                   Text.Add (Temp);
  903.                   RetVal = TRUE;
  904.                }
  905.             }
  906.          } while (FileData->Next () == TRUE);
  907.       delete FileData;
  908.    }
  909.  
  910.    return (RetVal);
  911. }
  912.  
  913. USHORT TAreaManager::FileRemoveAll (PSZ address)
  914. {
  915.    USHORT RetVal = FALSE;
  916.    CHAR Temp[96];
  917.  
  918.    if ((FileData = new TFileData (Cfg->SystemPath)) != NULL) {
  919.       if (FileData->First () == TRUE)
  920.          do {
  921.             if (FileData->EchoTag[0] != '\0') {
  922.                FileEchoLink->Load (FileData->EchoTag);
  923.                if (FileEchoLink->Check (address) == TRUE) {
  924.                   FileEchoLink->Delete ();
  925.                   FileEchoLink->Save ();
  926.                   sprintf (Temp, "Area %s has been removed.", strupr (FileData->EchoTag));
  927.                   Text.Add (Temp);
  928.                   RetVal = TRUE;
  929.                }
  930.             }
  931.          } while (FileData->Next () == TRUE);
  932.       delete FileData;
  933.    }
  934.  
  935.    return (RetVal);
  936. }
  937.  
  938. VOID TAreaManager::ProcessRaid (VOID)
  939. {
  940.    FILE *fp;
  941.    USHORT Ok, DoList, DoLinked, DoUnlinked, Found;
  942.    USHORT DoReport, DoHelp;
  943.    CHAR Temp[96], *Password, *p;
  944.    ULONG Total;
  945.  
  946.    if (Log != NULL)
  947.       Log->Write ("#Process Raid requests for %s", Msg->FromAddress);
  948.  
  949.    strcpy (Temp, Msg->Subject);
  950.    if ((Password = strtok (Temp, " ")) == NULL)
  951.       Password = "";
  952.  
  953.    Ok = FALSE;
  954.    if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  955.       if (Nodes->Read (Msg->FromAddress) == TRUE) {
  956.          if (!stricmp (Password, Nodes->AreaMgrPwd))
  957.             Ok = TRUE;
  958.       }
  959.       delete Nodes;
  960.    }
  961.  
  962.    if (Ok == TRUE) {
  963.       DoHelp = DoList = DoLinked = DoUnlinked = FALSE;
  964.       DoReport = FALSE;
  965.  
  966.       strcpy (Temp, Msg->Subject);
  967.       if ((p = strtok (Temp, " ")) != NULL) {
  968.          while ((p = strtok (NULL, " ")) != NULL) {
  969.             if (!stricmp (p, "-l"))
  970.                DoList = TRUE;
  971.          }
  972.       }
  973.  
  974.       Text.Clear ();
  975.       MsgHeader ();
  976.  
  977.       sprintf (Temp, "Following is a summary from %s of changes in Fileecho topology:", Msg->ToAddress);
  978.       Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  979.       Text.Add ("");
  980.  
  981.       if ((FileEchoLink = new TFilechoLink (Cfg->SystemPath)) != NULL) {
  982.          if ((p = (CHAR *)Msg->Text.First ()) != NULL)
  983.             do {
  984.                if ((p = strtok (p, " ")) != NULL) {
  985.                   if (*p == '%') {
  986.                      if (!stricmp (p, "%list"))
  987.                         DoList = TRUE;
  988.                      else if (!stricmp (p, "%unlinked"))
  989.                         DoUnlinked = TRUE;
  990.                      else if (!stricmp (p, "%linked"))
  991.                         DoLinked = TRUE;
  992.                      else if (!stricmp (p, "%help"))
  993.                         DoHelp = TRUE;
  994.                      else if (!stricmp (p, "%passive")) {
  995.                         if (FilePassive (Msg->FromAddress, TRUE) == TRUE)
  996.                            DoReport = TRUE;
  997.                      }
  998.                      else if (!stricmp (p, "%active")) {
  999.                         if (FilePassive (Msg->FromAddress, FALSE) == TRUE)
  1000.                            DoReport = TRUE;
  1001.                      }
  1002.                      else if (!stricmp (p, "%-all")) {
  1003.                         if (FileRemoveAll (Msg->FromAddress) == TRUE)
  1004.                            DoReport = TRUE;
  1005.                      }
  1006.                      else if (!stricmp (p, "%pwd")) {
  1007.                         if ((p = strtok (NULL, " ")) != NULL) {
  1008.                            if (SetPwd (Msg->FromAddress, p) == TRUE)
  1009.                               DoReport = TRUE;
  1010.                         }
  1011.                      }
  1012.                      else if (!stricmp (p, "%sessionpwd")) {
  1013.                         if ((p = strtok (NULL, " ")) != NULL) {
  1014.                            if (SetSessionPwd (Msg->FromAddress, p) == TRUE)
  1015.                               DoReport = TRUE;
  1016.                         }
  1017.                      }
  1018.                      else if (!stricmp (p, "%pktpwd")) {
  1019.                         p = strtok (NULL, " ");
  1020.                         if (SetPacketPwd (Msg->FromAddress, p) == TRUE)
  1021.                            DoReport = TRUE;
  1022.                      }
  1023.                      else if (!stricmp (p, "%inpktpwd")) {
  1024.                         p = strtok (NULL, " ");
  1025.                         if (SetInPacketPwd (Msg->FromAddress, p) == TRUE)
  1026.                            DoReport = TRUE;
  1027.                      }
  1028.                      else if (!stricmp (p, "%outpktpwd")) {
  1029.                         p = strtok (NULL, " ");
  1030.                         if (SetOutPacketPwd (Msg->FromAddress, p) == TRUE)
  1031.                            DoReport = TRUE;
  1032.                      }
  1033.                   }
  1034.                   else if (*p == '-' && strcmp (p, "---")) {
  1035.                      p++;
  1036.                      FileEchoLink->Load (p);
  1037.                      if (FileEchoLink->First () == TRUE) {
  1038.                         if (FileEchoLink->Check (Msg->FromAddress) == TRUE) {
  1039.                            FileEchoLink->Delete ();
  1040.                            FileEchoLink->Save ();
  1041.                            sprintf (Temp, "Area %s has been removed.", strupr (p));
  1042.                         }
  1043.                         else
  1044.                            sprintf (Temp, "Area %s never linked.", strupr (p));
  1045.                      }
  1046.                      else
  1047.                         sprintf (Temp, "Area %s never linked.", strupr (p));
  1048.                      Text.Add (Temp);
  1049.                      DoReport = TRUE;
  1050.                   }
  1051.                   else if (*p != '\0' && strcmp (p, "---") && *p != '\001') {
  1052.                      if (*p == '+')
  1053.                         p++;
  1054.                      FileEchoLink->Load (p);
  1055.                      if (FileEchoLink->First () == TRUE) {
  1056.                         if (FileEchoLink->Check (Msg->FromAddress) == TRUE)
  1057.                            sprintf (Temp, "Area %s already linked.\n", strupr (p));
  1058.                         else {
  1059.                            FileEchoLink->AddString (Msg->FromAddress);
  1060.                            FileEchoLink->Save ();
  1061.                            sprintf (Temp, "Area %s has been added.\n", strupr (p));
  1062.                         }
  1063.                      }
  1064.                      else {
  1065.                         Found = FALSE;
  1066.                         if ((FileData = new TFileData (Cfg->SystemPath)) != NULL) {
  1067.                            if (FileData->ReadEcho (p) == TRUE) {
  1068.                               FileEchoLink->Load (FileData->EchoTag);
  1069.                               FileEchoLink->AddString (Msg->FromAddress);
  1070.                               FileEchoLink->Save ();
  1071.                               sprintf (Temp, "Area %s has been added.\n", strupr (p));
  1072.                               Found = TRUE;
  1073.                            }
  1074.                            delete Data;
  1075.                         }
  1076.                         if (Found == FALSE)
  1077.                            sprintf (Temp, "Area %s not found.\n", strupr (p));
  1078.                      }
  1079.                      Text.Add (Temp);
  1080.                      DoReport = TRUE;
  1081.                   }
  1082.                }
  1083.             } while ((p = (CHAR *)Msg->Text.Next ()) != NULL);
  1084.          delete FileEchoLink;
  1085.       }
  1086.  
  1087.       strcpy (Temp, Msg->FromAddress);
  1088.       strcpy (Msg->FromAddress, Msg->ToAddress);
  1089.       strcpy (Msg->ToAddress, Temp);
  1090.       strcpy (Msg->To, Msg->From);
  1091.       strcpy (Msg->From, "Tic Manager");
  1092.  
  1093.       if (DoReport == TRUE) {
  1094.          MsgFooter ();
  1095.          strcpy (Msg->Subject, "Tic changes report");
  1096.          Msg->Text.Clear ();
  1097.          Msg->Local = TRUE;
  1098.          Msg->Crash = Msg->Direct = Msg->Hold = FALSE;
  1099.          Msg->Sent = FALSE;
  1100.          Msg->Add (Text);
  1101.       }
  1102.  
  1103.       if (DoList == TRUE) {
  1104.          Total = 0L;
  1105.          strcpy (Msg->Subject, "List of available Tic areas");
  1106.          Text.Clear ();
  1107.          MsgHeader ();
  1108.  
  1109.          sprintf (Temp, "Area(s) available to %s:", Msg->ToAddress);
  1110.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  1111.          Text.Add ("");
  1112.          if ((FileData = new TFileData (Cfg->SystemPath)) != NULL) {
  1113.             if (FileData->First () == TRUE)
  1114.                do {
  1115.                   if (FileData->EchoTag[0] != '\0') {
  1116.                      sprintf (Temp, "%-30.30s %.48s", FileData->EchoTag, FileData->Display);
  1117.                      Text.Add (Temp);
  1118.                      Total++;
  1119.                   }
  1120.                } while (FileData->Next () == TRUE);
  1121.             delete FileData;
  1122.          }
  1123.          Text.Add ("");
  1124.          sprintf (Temp, "%lu available area(s).", Total);
  1125.          Text.Add (Temp);
  1126.  
  1127.          MsgFooter ();
  1128.          Msg->Add (Text);
  1129.       }
  1130.  
  1131.       if (DoLinked == TRUE) {
  1132.          strcpy (Msg->Subject, "List of linked Tic areas");
  1133.          Text.Clear ();
  1134.          MsgHeader ();
  1135.  
  1136.          sprintf (Temp, "%s is now linked to the following area(s):", Msg->ToAddress);
  1137.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  1138.          Text.Add ("");
  1139.          Total = 0L;
  1140.          if ((FileData = new TFileData (Cfg->SystemPath)) != NULL) {
  1141.             FileEchoLink = new TFilechoLink (Cfg->SystemPath);
  1142.             if (FileData->First () == TRUE)
  1143.                do {
  1144.                   if (FileData->EchoTag[0] != '\0' && FileEchoLink != NULL) {
  1145.                      FileEchoLink->Load (FileData->EchoTag);
  1146.                      if (FileEchoLink->Check (Msg->ToAddress) == TRUE) {
  1147.                         sprintf (Temp, "%-30.30s %.48s", FileData->EchoTag, FileData->Display);
  1148.                         Text.Add (Temp);
  1149.                         Total++;
  1150.                      }
  1151.                   }
  1152.                } while (FileData->Next () == TRUE);
  1153.             if (FileEchoLink != NULL)
  1154.                delete FileEchoLink;
  1155.             delete FileData;
  1156.          }
  1157.          Text.Add ("");
  1158.          sprintf (Temp, "%lu linked area(s).", Total);
  1159.          Text.Add (Temp);
  1160.  
  1161.          MsgFooter ();
  1162.          Msg->Add (Text);
  1163.       }
  1164.  
  1165.       if (DoUnlinked == TRUE) {
  1166.          strcpy (Msg->Subject, "List of unlinked Tic areas");
  1167.          Text.Clear ();
  1168.          MsgHeader ();
  1169.  
  1170.          sprintf (Temp, "Area(s) not linked to %s:", Msg->ToAddress);
  1171.          Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  1172.          Text.Add ("");
  1173.          Total = 0L;
  1174.          if ((FileData = new TFileData (Cfg->SystemPath)) != NULL) {
  1175.             FileEchoLink = new TFilechoLink (Cfg->SystemPath);
  1176.             if (FileData->First () == TRUE)
  1177.                do {
  1178.                   if (FileData->EchoTag[0] != '\0' && FileEchoLink != NULL) {
  1179.                      FileEchoLink->Load (FileData->EchoTag);
  1180.                      if (FileEchoLink->Check (Msg->ToAddress) == FALSE) {
  1181.                         sprintf (Temp, "%-30.30s %.48s", FileData->EchoTag, FileData->Display);
  1182.                         Text.Add (Temp);
  1183.                         Total++;
  1184.                      }
  1185.                   }
  1186.                } while (FileData->Next () == TRUE);
  1187.             if (FileEchoLink != NULL)
  1188.                delete FileEchoLink;
  1189.             delete FileData;
  1190.          }
  1191.          Text.Add ("");
  1192.          sprintf (Temp, "%lu unlinked area(s).", Total);
  1193.          Text.Add (Temp);
  1194.          MsgFooter ();
  1195.  
  1196.          Msg->Add (Text);
  1197.       }
  1198.  
  1199.       if (DoHelp == TRUE) {
  1200.          strcpy (Msg->Subject, "Raid help");
  1201.          Text.Clear ();
  1202.          MsgHeader ();
  1203.  
  1204.          sprintf (Temp, "%sraidhelp.txt", Cfg->SystemPath);
  1205.          if ((fp = fopen (Temp, "rt")) != NULL) {
  1206.             while (fgets (Temp, sizeof (Temp) - 1, fp) != NULL) {
  1207.                Temp[strlen (Temp) - 1] = '\0';
  1208.                Text.Add (Temp);
  1209.             }
  1210.             fclose (fp);
  1211.          }
  1212.          else {
  1213.             Text.Add ("");
  1214.             Text.Add ("No help file available. Contact the Sysop.");
  1215.             Text.Add ("");
  1216.          }
  1217.  
  1218.          MsgFooter ();
  1219.          Msg->Add (Text);
  1220.       }
  1221.    }
  1222.    else {
  1223.       Text.Clear ();
  1224.       MsgHeader ();
  1225.  
  1226.       Text.Add ("");
  1227.       sprintf (Temp, "Node %s isn't authorized to use raid at %s", Msg->FromAddress, Msg->ToAddress);
  1228.       Text.Add (Temp);
  1229.       Text.Add ("");
  1230.  
  1231.       strcpy (Temp, Msg->FromAddress);
  1232.       strcpy (Msg->FromAddress, Msg->ToAddress);
  1233.       strcpy (Msg->ToAddress, Temp);
  1234.       strcpy (Msg->To, Msg->From);
  1235.       strcpy (Msg->From, "Tic Manager");
  1236.       strcpy (Msg->Subject, "Tic changes report");
  1237.       Msg->Text.Clear ();
  1238.       Msg->Local = TRUE;
  1239.       Msg->Crash = Msg->Direct = Msg->Hold = FALSE;
  1240.  
  1241.       MsgFooter ();
  1242.       Msg->Add (Text);
  1243.    }
  1244. }
  1245.  
  1246. VOID TAreaManager::Rescan (PSZ pszEchoTag, PSZ pszAddress)
  1247. {
  1248.    CHAR Temp[128], Outbound[64], *Text;
  1249.    ULONG Number;
  1250.    struct stat statbuf;
  1251.    class TMsgData *Data;
  1252.    class TMsgBase *Msg;
  1253.    class TAddress Forward;
  1254.    class PACKET *Packet;
  1255.    class TKludges *SeenBy, *Path;
  1256.  
  1257.    strcpy (Outbound, Cfg->Outbound);
  1258.    Outbound[strlen (Outbound) - 1] = '\0';
  1259.  
  1260.    Forward.Parse (pszAddress);
  1261.  
  1262.    if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  1263.       if (Data->ReadEcho (pszEchoTag) == TRUE) {
  1264.          Msg = NULL;
  1265.          if (Data->Storage == ST_JAM)
  1266.             Msg = new JAM (Data->Path);
  1267.          else if (Data->Storage == ST_SQUISH)
  1268.             Msg = new SQUISH (Data->Path);
  1269.          else if (Data->Storage == ST_FIDO)
  1270.             Msg = new FIDOSDM (Data->Path);
  1271.          else if (Data->Storage == ST_ADEPT)
  1272.             Msg = new ADEPT (Data->Path);
  1273.          else if (Data->Storage == ST_HUDSON)
  1274.             Msg = new HUDSON (Data->Path, (UCHAR)Data->Board);
  1275.  
  1276.          if (Msg != NULL) {
  1277.             if ((Packet = new PACKET) != NULL) {
  1278.                strcpy (Packet->ToAddress, Forward.String);
  1279.  
  1280.                if (Data->Address[0] != '\0')
  1281.                   strcpy (Packet->FromAddress, Data->Address);
  1282.                else {
  1283.                   if (Cfg->MailAddress.First () == TRUE) {
  1284.                      strcpy (Packet->FromAddress, Cfg->MailAddress.String);
  1285.                      do {
  1286.                         if (Cfg->MailAddress.Zone == Forward.Zone) {
  1287.                            strcpy (Packet->FromAddress, Cfg->MailAddress.String);
  1288.                            break;
  1289.                         }
  1290.                      } while (Cfg->MailAddress.Next () == TRUE);
  1291.                   }
  1292.                }
  1293.  
  1294.                Cfg->MailAddress.First ();
  1295.                if (Cfg->MailAddress.Zone == Forward.Zone) {
  1296.                   if (Forward.Point != 0) {
  1297. #if defined(__LINUX__)
  1298.                      sprintf (Temp, "%s/%04x%04x.pnt", Outbound, Forward.Net, Forward.Node);
  1299.                      mkdir (Temp, 0666);
  1300.                      sprintf (Temp, "%s/%04x%04x.pnt/%08x.xpr", Outbound, Forward.Net, Forward.Node, Forward.Point);
  1301. #else
  1302.                      sprintf (Temp, "%s\\%04x%04x.pnt", Outbound, Forward.Net, Forward.Node);
  1303.                      mkdir (Temp);
  1304.                      sprintf (Temp, "%s\\%04x%04x.pnt\\%08x.xpr", Outbound, Forward.Net, Forward.Node, Forward.Point);
  1305. #endif
  1306.                   }
  1307.                   else
  1308. #if defined(__LINUX__)
  1309.                      sprintf (Temp, "%s/%04x%04x.xpr", Outbound, Forward.Net, Forward.Node);
  1310. #else
  1311.                      sprintf (Temp, "%s\\%04x%04x.xpr", Outbound, Forward.Net, Forward.Node);
  1312. #endif
  1313.                }
  1314.                else {
  1315.                   sprintf (Temp, "%s.%03x", Outbound, Forward.Zone);
  1316. #if defined(__LINUX__)
  1317.                   mkdir (Temp, 0666);
  1318. #else
  1319.                   mkdir (Temp);
  1320. #endif
  1321.                   if (Forward.Point != 0) {
  1322. #if defined(__LINUX__)
  1323.                      sprintf (Temp, "%s.%03x/%04x%04x.pnt", Outbound, Forward.Zone, Forward.Net, Forward.Node);
  1324.                      mkdir (Temp, 0666);
  1325.                      sprintf (Temp, "%s.%03x/%04x%04x.pnt/%08x.xpr", Outbound, Forward.Zone, Forward.Net, Forward.Node, Forward.Point);
  1326. #else
  1327.                      sprintf (Temp, "%s.%03x\\%04x%04x.pnt", Outbound, Forward.Zone, Forward.Net, Forward.Node);
  1328.                      mkdir (Temp);
  1329.                      sprintf (Temp, "%s.%03x\\%04x%04x.pnt\\%08x.xpr", Outbound, Forward.Zone, Forward.Net, Forward.Node, Forward.Point);
  1330. #endif
  1331.                   }
  1332.                   else
  1333. #if defined(__LINUX__)
  1334.                      sprintf (Temp, "%s.%03x/%04x%04x.xpr", Outbound, Forward.Zone, Forward.Net, Forward.Node);
  1335. #else
  1336.                      sprintf (Temp, "%s.%03x\\%04x%04x.xpr", Outbound, Forward.Zone, Forward.Net, Forward.Node);
  1337. #endif
  1338.                }
  1339.  
  1340.                if (stat (Temp, &statbuf) != 0) {
  1341.                   if ((Nodes = new TNodes (Cfg->NodelistPath)) != NULL) {
  1342.                      if (Nodes->Read (Forward.String) == TRUE)
  1343.                         strcpy (Packet->Password, Nodes->OutPktPwd);
  1344.                      delete Nodes;
  1345.                      Nodes = NULL;
  1346.                   }
  1347.                }
  1348.  
  1349.                if (Packet->Open (Temp, FALSE) == TRUE) {
  1350.                   Number = Msg->Lowest ();
  1351.                   // Evita di esportare il messaggio #1 delle basi Fido (l'high water mark)
  1352.                   if (Number == 1L && Data->Storage == ST_FIDO) {
  1353.                      if (Msg->Next (Number) == FALSE)
  1354.                         Number = 0L;
  1355.                   }
  1356.                   do {
  1357.                      if (Msg->Read (Number) == TRUE) {
  1358.                         sprintf (Temp, "AREA:%s", Data->EchoTag);
  1359.                         if ((Text = (PSZ)Msg->Text.First ()) != NULL) {
  1360.                            Msg->Text.Insert (Temp, (USHORT)(strlen (Temp) + 1));
  1361.                            if (*Text != '\0')
  1362.                               Msg->Text.Insert (Text, (USHORT)(strlen (Text) + 1));
  1363.                            Msg->Text.First ();
  1364.                            Msg->Text.Remove ();
  1365.                         }
  1366.                         else
  1367.                            Msg->Text.Add (Temp, (USHORT)(strlen (Temp) + 1));
  1368.  
  1369.                         SeenBy = new TKludges;
  1370.                         Path = new TKludges;
  1371.  
  1372.                         if (SeenBy != NULL && Path != NULL) {
  1373.                            Path->Sort = FALSE;
  1374.                            if ((Text = (PSZ)Msg->Text.First ()) != NULL)
  1375.                               do {
  1376.                                  if (!strncmp (Text, "SEEN-BY: ", 9) && SeenBy != NULL) {
  1377.                                     SeenBy->AddString (&Text[9]);
  1378.                                     Msg->Text.Remove ();
  1379.                                     Text = (PSZ)Msg->Text.Value ();
  1380.                                  }
  1381.                                  else if (!strncmp (Text, "\001PATH: ", 7) && Path != NULL) {
  1382.                                     Path->AddString (&Text[7]);
  1383.                                     Msg->Text.Remove ();
  1384.                                     Text = (PSZ)Msg->Text.Value ();
  1385.                                  }
  1386.                                  else {
  1387.                                     if (Msg->Local == TRUE && Cfg->ReplaceTear == TRUE) {
  1388.                                        if (!strncmp (Text, "---", 3)) {
  1389.                                           sprintf (Temp, "--- %s", Cfg->TearLine);
  1390.                                           strsrep (Temp, "%1", VERSION);
  1391.                                           Msg->Text.Replace (Temp, (USHORT)(strlen (Temp) + 1));
  1392.                                        }
  1393.                                     }
  1394.                                     Text = (PSZ)Msg->Text.Next ();
  1395.                                  }
  1396.                               } while (Text != NULL);
  1397.  
  1398.                            SeenBy->AddString (Forward.String);
  1399.  
  1400.                            if (Data->Address[0] != '\0') {
  1401.                               SeenBy->AddString (Data->Address);
  1402.                               Path->AddString (Data->Address);
  1403.                            }
  1404.                            else if (Cfg->MailAddress.First () == TRUE) {
  1405.                               SeenBy->AddString (Cfg->MailAddress.String);
  1406.                               Path->AddString (Cfg->MailAddress.String);
  1407.                            }
  1408.  
  1409.                            if (SeenBy->First () == TRUE) {
  1410.                               strcpy (Temp, "SEEN-BY:");
  1411.                               do {
  1412.                                  if (strlen (Temp) + strlen (SeenBy->ShortAddress) + 1 > 70) {
  1413.                                     Msg->Text.Add (Temp);
  1414.                                     strcpy (Temp, "SEEN-BY:");
  1415.                                     strcpy (SeenBy->ShortAddress, SeenBy->Address);
  1416.                                  }
  1417.                                  if (SeenBy->Net != Cfg->FakeNet && SeenBy->Point == 0) {
  1418.                                     strcat (Temp, " ");
  1419.                                     strcat (Temp, SeenBy->ShortAddress);
  1420.                                  }
  1421.                               } while (SeenBy->Next () == TRUE);
  1422.                               if (strlen (Temp) > 8)
  1423.                                  Msg->Text.Add (Temp);
  1424.                            }
  1425.  
  1426.                            if (Path->First () == TRUE) {
  1427.                               strcpy (Temp, "\001PATH:");
  1428.                               do {
  1429.                                  if (strlen (Temp) + strlen (Path->ShortAddress) + 1 > 70) {
  1430.                                     Msg->Text.Add (Temp);
  1431.                                     strcpy (Temp, "\001PATH:");
  1432.                                     strcpy (Path->ShortAddress, SeenBy->Address);
  1433.                                  }
  1434.                                  if (Path->Point == 0) {
  1435.                                     strcat (Temp, " ");
  1436.                                     strcat (Temp, Path->ShortAddress);
  1437.                                  }
  1438.                               } while (Path->Next () == TRUE);
  1439.                               if (strlen (Temp) > 6)
  1440.                                  Msg->Text.Add (Temp);
  1441.                            }
  1442.                         }
  1443.  
  1444.                         if (Path != NULL)
  1445.                            delete Path;
  1446.                         if (SeenBy != NULL)
  1447.                            delete SeenBy;
  1448.  
  1449.                         strcpy (Msg->ToAddress, Forward.String);
  1450.                         Packet->Add (Msg);
  1451.                      }
  1452.                   } while (Msg->Next (Number) == TRUE);
  1453.                }
  1454.  
  1455.                delete Packet;
  1456.             }
  1457.  
  1458.             delete Msg;
  1459.          }
  1460.       }
  1461.  
  1462.       delete Data;
  1463.    }
  1464. }
  1465.  
  1466.  
  1467.