home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lora299s.zip / LIBRARY.CPP < prev    next >
C/C++ Source or Header  |  1998-05-12  |  85KB  |  2,095 lines

  1.  
  2. // LoraBBS Version 2.99 Free Edition
  3. // Copyright (C) 1987-98 Marco Maccaferri
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #include "_ldefs.h"
  20. #include "lora.h"
  21.  
  22. class TFileAreaListing : public TListings
  23. {
  24. public:
  25.    TFileAreaListing (void);
  26.  
  27.    CHAR   Command[16];
  28.    class  TConfig *Cfg;
  29.    class  TFileData *Current;
  30.    class  TLanguage *Language;
  31.  
  32.    VOID   Begin (VOID);
  33.    USHORT DrawScreen (VOID);
  34.    VOID   PrintCursor (USHORT y);
  35.    VOID   PrintLine (VOID);
  36.    VOID   PrintTitles (VOID);
  37.    VOID   RemoveCursor (USHORT y);
  38.    VOID   Select (VOID);
  39.  
  40. private:
  41. };
  42.  
  43. // ----------------------------------------------------------------------
  44.  
  45. TLibrary::TLibrary (PSZ pszDataPath)
  46. {
  47.    Embedded = NULL;
  48.    Log = NULL;
  49.    User = NULL;
  50.  
  51.    strcpy (DataPath, pszDataPath);
  52.    Current = new TFileData (DataPath);
  53. }
  54.  
  55. TLibrary::~TLibrary (void)
  56. {
  57.    if (Current != NULL)
  58.       delete Current;
  59. }
  60.  
  61. VOID TLibrary::ExternalProtocols (USHORT Batch)
  62. {
  63.    class TProtocol *Protocol;
  64.  
  65.    if ((Protocol = new TProtocol (Cfg->SystemPath)) != NULL) {
  66.       if (Protocol->First () == TRUE)
  67.          do {
  68.             if (Protocol->Active == TRUE && (Batch == FALSE || Protocol->Batch == TRUE))
  69.                Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), Protocol->Key, Protocol->Description);
  70.          } while (Protocol->Next () == TRUE);
  71.       delete Protocol;
  72.    }
  73. }
  74.  
  75. VOID TLibrary::Download (class TFileTag *Files, USHORT AnyLibrary)
  76. {
  77.    CHAR Names[64], Cmd[10], *p;
  78.    USHORT KB, SelectOK, ClearAfter = FALSE, Loop = TRUE, Continue = TRUE;
  79.    ULONG DlTime;
  80.    class TFileBase *Data;
  81.    class TTransfer *Transfer;
  82.    class TLimits *Limits;
  83.    class TProtocol *Protocol;
  84.  
  85.    ///////////////////////////////////////////////////////////////////////////
  86.    // Verifica che l'utente sia collegato ad una velocita' tale da          //
  87.    // consentire il download dei files.                                     //
  88.    ///////////////////////////////////////////////////////////////////////////
  89.    if ((Limits = new TLimits (Cfg->SystemPath)) != NULL) {
  90.       if (Limits->Read (User->LimitClass) == TRUE) {
  91.          if (Limits->DownloadSpeed != 0L && CarrierSpeed < Limits->DownloadSpeed) {
  92.             Embedded->Printf ("\n\016\001\014Sorry, you can't download files at your current speed.\nBetter buy a faster modem.\n");
  93.             delete Limits;
  94.             return;
  95.          }
  96.       }
  97.       delete Limits;
  98.    }
  99.  
  100.    if (Files == NULL) {
  101.       Files = new TFileTag;
  102.       ClearAfter = TRUE;
  103.  
  104.       if (User->FileTag->TotalFiles != 0) {
  105.          Embedded->Printf (Language->Text (LNG_FILETAGGEDWARNING), User->FileTag->TotalFiles);
  106.          if (Embedded->GetAnswer (ASK_DEFYES) == ANSWER_YES) {
  107.             if (User->FileTag->First () == TRUE)
  108.                do {
  109.                   Files->New ();
  110.                   strcpy (Files->Name, User->FileTag->Name);
  111.                   strcpy (Files->Area, User->FileTag->Area);
  112.                   Files->Size = User->FileTag->Size;
  113.                   strcpy (Files->Complete, User->FileTag->Complete);
  114.                   Files->CdRom = User->FileTag->CdRom;
  115.                   Files->Add ();
  116.                } while (User->FileTag->Next () == TRUE);
  117.             User->FileTag->Clear ();
  118.          }
  119.       }
  120.  
  121.       do {
  122.          Embedded->Printf (Language->Text (LNG_FILEDOWNLOADNAME), Files->TotalFiles + 1);
  123.          Embedded->Input (Names, (USHORT)(sizeof (Names) - 1), 0);
  124.  
  125.          if ((Data = new TFileBase (Cfg->SystemPath, (AnyLibrary == TRUE) ? "" : Current->Key)) != NULL) {
  126.             if ((p = strtok (Names, " ")) != NULL)
  127.                do {
  128.                   if (Data->Read (p) == TRUE) {
  129.                      Files->New ();
  130.                      strcpy (Files->Name, Data->Name);
  131.                      strcpy (Files->Area, Data->Area);
  132.                      Files->Size = Data->Size;
  133.                      if (Data->Complete[0] == '\0')
  134.                         sprintf (Files->Complete, "%s%s", Current->Download, Files->Name);
  135.                      else
  136.                         strcpy (Files->Complete, Data->Complete);
  137.                      Files->CdRom = Data->CdRom;
  138.                      if (Files->Add () == TRUE) {
  139.                         DlTime = Data->Size / (CarrierSpeed / 10L);
  140.                         Embedded->Printf (Language->Text (LNG_DOWNLOADFILENAME), Files->Index, Data->Name, DlTime / 60L, DlTime % 60L, Data->Size);
  141.                      }
  142.                   }
  143.                   else
  144.                      Embedded->Printf (Language->Text (LNG_NOFILEHERE), p);
  145.                } while ((p = strtok (NULL, " ")) != NULL);
  146.             Data->Close ();
  147.             delete Data;
  148.          }
  149.       } while (Names[0] != '\0');
  150.    }
  151.    else
  152.       Log->Write (":Download of %d tagged files", Files->TotalFiles);
  153.  
  154.    DlTime = (Files->TotalBytes / (CarrierSpeed / 10L)) / 60L;
  155.  
  156.    if (DlTime >= Embedded->TimeRemain ()) {
  157.       Embedded->Printf (Language->Text (LNG_FILENOTIMEWARNING));
  158.       Continue = FALSE;
  159.    }
  160.    if ((Limits = new TLimits (Cfg->SystemPath)) != NULL) {
  161.       if (Limits->Read (User->LimitClass) == TRUE) {
  162.          KB = (USHORT)((Files->TotalBytes + 1023L)/ 1024L);
  163.          if (Limits->DownloadLimit != 0 && KB > (Limits->DownloadLimit - (User->BytesToday + 1023L) / 1024L)) {
  164.             Embedded->Printf (Language->Text (LNG_FILENOBYTESWARNING));
  165.             Continue = FALSE;
  166.          }
  167.          if (Continue == TRUE && CarrierSpeed <= 2400) {
  168.             if (Limits->DownloadAt2400 != 0 && KB > (Limits->DownloadAt2400 - (User->BytesToday + 1023L) / 1024L)) {
  169.                Embedded->Printf (Language->Text (LNG_FILENOBYTESWARNING));
  170.                Continue = FALSE;
  171.             }
  172.          }
  173.          if (Continue == TRUE && CarrierSpeed > 2400 && CarrierSpeed < 9600) {
  174.             if (Limits->DownloadAt9600 != 0 && KB > (Limits->DownloadAt9600 - (User->BytesToday + 1023L) / 1024L)) {
  175.                Embedded->Printf (Language->Text (LNG_FILENOBYTESWARNING));
  176.                Continue = FALSE;
  177.             }
  178.          }
  179.          if (Continue == TRUE && CarrierSpeed > 9600 && CarrierSpeed < 14400) {
  180.             if (Limits->DownloadAt14400 != 0 && KB > (Limits->DownloadAt14400 - (User->BytesToday + 1023L) / 1024L)) {
  181.                Embedded->Printf (Language->Text (LNG_FILENOBYTESWARNING));
  182.                Continue = FALSE;
  183.             }
  184.          }
  185.          if (Continue == TRUE && CarrierSpeed > 14400 && CarrierSpeed < 28800) {
  186.             if (Limits->DownloadAt28800 != 0 && KB > (Limits->DownloadAt28800 - (User->BytesToday + 1023L) / 1024L)) {
  187.                Embedded->Printf (Language->Text (LNG_FILENOBYTESWARNING));
  188.                Continue = FALSE;
  189.             }
  190.          }
  191.          if (Continue == TRUE && CarrierSpeed > 28800 && CarrierSpeed < 33600) {
  192.             if (Limits->DownloadAt33600 != 0 && KB > (Limits->DownloadAt33600 - (User->BytesToday + 1023L) / 1024L)) {
  193.                Embedded->Printf (Language->Text (LNG_FILENOBYTESWARNING));
  194.                Continue = FALSE;
  195.             }
  196.          }
  197.       }
  198.       delete Limits;
  199.    }
  200.  
  201.    if (Files != NULL && Files->TotalFiles != 0 && Continue == TRUE) {
  202.       if (DlTime < 1)
  203.          Embedded->Printf ("\n\x16\x01\012Approximate download time: < 1 minute.\n\n");
  204.       else
  205.          Embedded->Printf ("\n\x16\x01\012Approximate download time: %ld minutes.\n\n", DlTime);
  206.  
  207.       if (Files->TotalFiles == 1) {
  208.          Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "A", "ASCII (continuos dump)");
  209.          Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "M", "XMODEM (Checksum/CRC)");
  210.          Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "1", "XMODEM-1K");
  211.       }
  212.       Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "Z", "ZMODEM");
  213.       ExternalProtocols ((Files->TotalFiles == 1) ? FALSE : TRUE);
  214. //      Embedded->Printf ("  \x16\x01\013T ... \x16\x01\016FTP to Internet host\n");
  215. //      Embedded->Printf ("  \x16\x01\013F ... \x16\x01\016File Export (to any DOS path)\n");
  216.       if (ClearAfter == TRUE)
  217.          Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "T", "Tag file(s) for later download");
  218.  
  219.       SelectOK = FALSE;
  220.  
  221.       do {
  222.          Embedded->Printf ("\n\x16\x01\013Choose a download option (or RETURN to exit): ");
  223.          if (Embedded->HotKey == TRUE)
  224.             Embedded->Input (Cmd, 1, INP_HOTKEY);
  225.          else
  226.             Embedded->Input (Cmd, (USHORT)(sizeof (Cmd) - 1), 0);
  227.          Cmd[0] = (CHAR)toupper (Cmd[0]);
  228.          if ((Protocol = new TProtocol (Cfg->SystemPath)) != NULL) {
  229.             if (Protocol->Read (Cmd) == TRUE)
  230.                SelectOK = TRUE;
  231.             delete Protocol;
  232.          }
  233.          if (Files->TotalFiles == 1) {
  234.             if (Cmd[0] == 'M' || Cmd[0] == '1' || Cmd[0] == 'A')
  235.                SelectOK = TRUE;
  236.          }
  237.          if (Cmd[0] == '\0' || Cmd[0] == 'Z' || Cmd[0] == 'T' || Cmd[0] == 'F')
  238.             SelectOK = TRUE;
  239.       } while (Embedded->AbortSession () == FALSE && SelectOK == FALSE);
  240.  
  241.       if (Cmd[0] != '\0' && (Transfer = new TTransfer) != NULL) {
  242.          Transfer->Task = Task;
  243.          Transfer->Com = Embedded->Com;
  244.          Transfer->Log = Log;
  245.          Transfer->Speed = CarrierSpeed;
  246.          Transfer->Progress = Progress;
  247.          Transfer->Telnet = Cfg->ZModemTelnet;
  248.          strcpy (Transfer->Device, Cfg->Device);
  249.          while (Loop == TRUE && Files->TotalFiles > 0 && Embedded->AbortSession () == FALSE) {
  250.             if (Cmd[0] == '1') {
  251.                Files->First ();
  252.                Embedded->Printf (Language->Text (LNG_FILEBEGINDOWNLOAD), "XMODEM-1K", Files->Name);
  253.                if (Transfer->Send1kXModem (Files->Complete) == TRUE) {
  254.                   if ((Data = new TFileBase (Cfg->SystemPath, Files->Area)) != NULL) {
  255.                      if (Data->Read (Files->Name) == TRUE) {
  256.                         Data->DlTimes++;
  257.                         Data->ReplaceHeader ();
  258.                         if (User != NULL) {
  259.                            User->FilesToday++;
  260.                            User->DownloadFiles++;
  261.                            User->BytesToday += Data->Size;
  262.                            User->DownloadBytes += Data->Size;
  263.                         }
  264.                      }
  265.                      Data->Close ();
  266.                      delete Data;
  267.                   }
  268.                   Files->Remove ();
  269.                }
  270.             }
  271.             else if (Cmd[0] == 'A') {
  272.                Files->First ();
  273.                if (Transfer->SendASCIIDump (Files->Complete) == TRUE) {
  274.                   if ((Data = new TFileBase (Cfg->SystemPath, Files->Area)) != NULL) {
  275.                      if (Data->Read (Files->Name) == TRUE) {
  276.                         Data->DlTimes++;
  277.                         Data->ReplaceHeader ();
  278.                         if (User != NULL) {
  279.                            User->FilesToday++;
  280.                            User->DownloadFiles++;
  281.                            User->BytesToday += Data->Size;
  282.                            User->DownloadBytes += Data->Size;
  283.                         }
  284.                      }
  285.                      Data->Close ();
  286.                      delete Data;
  287.                   }
  288.                   Files->Remove ();
  289.                }
  290.             }
  291.             else if (Cmd[0] == 'M') {
  292.                Files->First ();
  293.                Embedded->Printf (Language->Text (LNG_FILEBEGINDOWNLOAD), "XMODEM", Files->Name);
  294.                if (Transfer->SendXModem (Files->Complete) == TRUE) {
  295.                   if ((Data = new TFileBase (Cfg->SystemPath, Files->Area)) != NULL) {
  296.                      if (Data->Read (Files->Name) == TRUE) {
  297.                         Data->DlTimes++;
  298.                         Data->ReplaceHeader ();
  299.                         if (User != NULL) {
  300.                            User->FilesToday++;
  301.                            User->DownloadFiles++;
  302.                            User->BytesToday += Data->Size;
  303.                            User->DownloadBytes += Data->Size;
  304.                         }
  305.                      }
  306.                      Data->Close ();
  307.                      delete Data;
  308.                   }
  309.                   Files->Remove ();
  310.                }
  311.             }
  312.             else if (Cmd[0] == 'Z') {
  313.                Embedded->Printf (Language->Text (LNG_FILEBEGINDOWNLOAD2), "ZMODEM");
  314.                while (Files->First () == TRUE && Embedded->AbortSession () == FALSE) {
  315.                   if (Transfer->SendZModem (Files->Complete) == FALSE)
  316.                      break;
  317.                   if ((Data = new TFileBase (Cfg->SystemPath, Files->Area)) != NULL) {
  318.                      if (Data->Read (Files->Name) == TRUE) {
  319.                         Data->DlTimes++;
  320.                         Data->ReplaceHeader ();
  321.                         if (User != NULL) {
  322.                            User->FilesToday++;
  323.                            User->DownloadFiles++;
  324.                            User->BytesToday += Data->Size;
  325.                            User->DownloadBytes += Data->Size;
  326.                         }
  327.                      }
  328.                      Data->Close ();
  329.                      delete Data;
  330.                   }
  331.                   Files->Remove ();
  332.                }
  333.                if (Embedded->AbortSession () == FALSE && Files->TotalFiles == 0L)
  334.                   Transfer->SendZModem (NULL);
  335.             }
  336.             else if (Cmd[0] == 'T') {
  337.                if (ClearAfter == TRUE) {
  338.                   Embedded->Printf (Language->Text (LNG_FILETAGGEDHEADER));
  339.  
  340.                   if (Files->First () == TRUE)
  341.                      do {
  342.                         User->FileTag->New ();
  343.                         strcpy (User->FileTag->Name, Files->Name);
  344.                         strcpy (User->FileTag->Area, Files->Area);
  345.                         strcpy (User->FileTag->Complete, Files->Complete);
  346.                         User->FileTag->Size = Files->Size;
  347.                         User->FileTag->DeleteAfter = Files->DeleteAfter;
  348.                         User->FileTag->CdRom = Files->CdRom;
  349.                         User->FileTag->Add ();
  350.  
  351.                         DlTime = User->FileTag->Size / (CarrierSpeed / 10L);
  352.                         Embedded->Printf (Language->Text (LNG_FILETAGGEDLIST), User->FileTag->Index, User->FileTag->Name, User->FileTag->Area, DlTime / 60L, DlTime % 60L, User->FileTag->Size);
  353.  
  354.                         Log->Write (":Tagged file %s, library %s", Files->Name, Files->Area);
  355.                      } while (Files->Next () == TRUE);
  356.  
  357.                   DlTime = User->FileTag->TotalBytes / (CarrierSpeed / 10L);
  358.                   Embedded->Printf (Language->Text (LNG_FILETAGGEDTOTAL), User->FileTag->TotalBytes, DlTime / 60L, DlTime % 60L);
  359.  
  360.                   Files->Clear ();
  361.                }
  362.             }
  363.             else {
  364.                if ((Protocol = new TProtocol (Cfg->SystemPath)) != NULL) {
  365.                   Transfer->TxQueue.Clear ();
  366.                   if (Files->First () == TRUE)
  367.                      do {
  368.                         Transfer->TxQueue.New ();
  369.                         strcpy (Transfer->TxQueue.Name, Files->Name);
  370.                         strcpy (Transfer->TxQueue.Complete, Files->Complete);
  371.                         Transfer->TxQueue.Size = Files->Size;
  372.                         Transfer->TxQueue.Add ();
  373.                      } while (Files->Next () == TRUE);
  374.  
  375.                   Transfer->RunExternalProtocol (TRUE, Cmd, Protocol);
  376.  
  377.                   if (Transfer->TxQueue.First () == TRUE)
  378.                      do {
  379.                         if (Transfer->TxQueue.Sent == TRUE) {
  380.                            if (Files->First () == TRUE)
  381.                               do {
  382.                                  if (!stricmp (Files->Complete, Transfer->TxQueue.Complete)) {
  383.                                     if ((Data = new TFileBase (Cfg->SystemPath, Files->Area)) != NULL) {
  384.                                        if (Data->Read (Files->Name) == TRUE) {
  385.                                           Data->DlTimes++;
  386.                                           Data->ReplaceHeader ();
  387.                                           if (User != NULL) {
  388.                                              User->FilesToday++;
  389.                                              User->DownloadFiles++;
  390.                                              User->BytesToday += Data->Size;
  391.                                              User->DownloadBytes += Data->Size;
  392.                                           }
  393.                                        }
  394.                                        Data->Close ();
  395.                                        delete Data;
  396.                                     }
  397.                                     Files->Remove ();
  398.                                     break;
  399.                                  }
  400.                               } while (Files->Next () == TRUE);
  401.                         }
  402.                      } while (Transfer->TxQueue.Next () == TRUE);
  403.  
  404.                   delete Protocol;
  405.                }
  406.             }
  407.  
  408.             if (Cmd[0] != 'T' && Embedded->AbortSession () == FALSE) {
  409.                if (Files->TotalFiles > 0) {
  410.                   Embedded->Printf (Language->Text (LNG_FILEDOWNLOADERROR));
  411. //                  Embedded->Printf ("\n\x16\x01\013Do you want to try to download the file(s) again");
  412. //                  if (Embedded->GetAnswer (ASK_DEFYES) == ANSWER_NO)
  413. //                  Files->Clear ();
  414.                   Loop = FALSE;
  415.                }
  416.                else
  417.                   Embedded->Printf (Language->Text (LNG_FILEDOWNLOADCOMPLETE));
  418.             }
  419.          }
  420.  
  421.          delete Transfer;
  422.       }
  423.    }
  424.  
  425.    if (ClearAfter == TRUE) {
  426.       Files->Clear ();
  427.       delete Files;
  428.    }
  429. }
  430.  
  431. VOID TLibrary::TypeFile (VOID)
  432. {
  433.    CHAR File[128], Names[32], *p;
  434.    class TFileBase *Data;
  435.  
  436.    Embedded->Printf (Language->Text (LNG_DISPLAYWHICHFILE));
  437.    Embedded->Input (Names, (USHORT)(sizeof (Names) - 1), 0);
  438.    Embedded->Printf ("\n");
  439.  
  440.    if ((Data = new TFileBase (Cfg->SystemPath, Current->Key)) != NULL) {
  441.       if ((p = strtok (Names, " ")) != NULL) {
  442.          if (Data->Read (p) == TRUE) {
  443.             if (Embedded->DisplayFile (Data->Complete) == FALSE) {
  444.                if (Log != NULL)
  445.                   Log->Write ("!File %s not found", Data->Complete);
  446.                sprintf (File, "%s%s", Current->Download, Data->Name);
  447.                Embedded->DisplayFile (Data->Complete);
  448.             }
  449.          }
  450.          else
  451.             Embedded->Printf (Language->Text (LNG_NOFILEHERE), Names);
  452.       }
  453.       delete Data;
  454.    }
  455. }
  456.  
  457. USHORT TLibrary::DownloadFile (PSZ pszFile, PSZ pszName, ULONG ulSize)
  458. {
  459.    USHORT RetVal = FALSE, SelectOK, Loop;
  460.    CHAR Cmd[10];
  461.    ULONG DlTime;
  462.    class TTransfer *Transfer;
  463.    class TProtocol *Protocol;
  464.  
  465.    DlTime = (ulSize / (CarrierSpeed / 10L) + 30L) / 60L;
  466.    if (ulSize != 0L) {
  467.       if (DlTime < 1)
  468.          Embedded->Printf ("\n\x16\x01\012Approximate download time: < 1 minute.\n\n");
  469.       else
  470.          Embedded->Printf ("\n\x16\x01\012Approximate download time: %ld minutes.\n\n", DlTime);
  471.    }
  472.    else
  473.       Embedded->Printf ("\n");
  474.  
  475.    Embedded->Printf ("  \x16\x01\013A ... \x16\x01\016ASCII (continuos dump)\n");
  476.    if (DlTime < Embedded->TimeRemain ()) {
  477.       Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "M", "XMODEM (Checksum/CRC)");
  478.       Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "1", "XMODEM-1K");
  479.       Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "Z", "ZMODEM");
  480.       ExternalProtocols (FALSE);
  481.    }
  482.    Embedded->Printf (Language->Text (LNG_FILEPROTOCOLLIST), "T", "Tag file(s) for later download");
  483.  
  484.    SelectOK = FALSE;
  485.  
  486.    do {
  487.       Embedded->Printf ("\n\x16\x01\013Choose a download option (or RETURN to exit): ");
  488.       if (Embedded->HotKey == TRUE)
  489.          Embedded->Input (Cmd, 1, INP_HOTKEY);
  490.       else
  491.          Embedded->Input (Cmd, (USHORT)(sizeof (Cmd) - 1), 0);
  492.       Cmd[0] = (CHAR)toupper (Cmd[0]);
  493.       if (Cmd[0] == 'M' || Cmd[0] == '1' || Cmd[0] == 'A')
  494.          SelectOK = TRUE;
  495.       else if (Cmd[0] == '\0' || Cmd[0] == 'Z' || Cmd[0] == 'T' || Cmd[0] == 'F')
  496.          SelectOK = TRUE;
  497.    } while (Embedded->AbortSession () == FALSE && SelectOK == FALSE);
  498.  
  499.    if (Cmd[0] != '\0' && (Transfer = new TTransfer) != NULL) {
  500.       Transfer->Com = Embedded->Com;
  501.       Transfer->Log = Log;
  502.       Transfer->Speed = CarrierSpeed;
  503.       Transfer->Progress = Progress;
  504.       Transfer->Telnet = Cfg->ZModemTelnet;
  505.       Loop = TRUE;
  506.  
  507.       while (Loop == TRUE && RetVal == FALSE && Embedded->AbortSession () == FALSE) {
  508.          if (DlTime < Embedded->TimeRemain ()) {
  509.             if (Cmd[0] == 'A') {
  510.                RetVal = Transfer->SendASCIIDump (pszFile);
  511.                if (User != NULL) {
  512.                   User->FilesToday++;
  513.                   User->DownloadFiles++;
  514.                   User->BytesToday += ulSize;
  515.                   User->DownloadBytes += ulSize;
  516.                }
  517.             }
  518.             else if (Cmd[0] == '1') {
  519.                Embedded->Printf (Language->Text (LNG_FILEBEGINDOWNLOAD), "XMODEM-1K", pszName);
  520.                if ((RetVal = Transfer->Send1kXModem (pszFile)) == TRUE) {
  521.                   if (User != NULL) {
  522.                      User->FilesToday++;
  523.                      User->DownloadFiles++;
  524.                      User->BytesToday += ulSize;
  525.                      User->DownloadBytes += ulSize;
  526.                   }
  527.                }
  528.             }
  529.             else if (Cmd[0] == 'M') {
  530.                Embedded->Printf (Language->Text (LNG_FILEBEGINDOWNLOAD), "XMODEM", pszName);
  531.                if ((RetVal = Transfer->SendXModem (pszFile)) == TRUE) {
  532.                   if (User != NULL) {
  533.                      User->FilesToday++;
  534.                      User->DownloadFiles++;
  535.                      User->BytesToday += ulSize;
  536.                      User->DownloadBytes += ulSize;
  537.                   }
  538.                }
  539.             }
  540.             else if (Cmd[0] == 'Z') {
  541.                Embedded->Printf (Language->Text (LNG_FILEBEGINDOWNLOAD), "ZMODEM", pszName);
  542.                if ((RetVal = Transfer->SendZModem (pszFile)) == TRUE) {
  543.                   if (User != NULL) {
  544.                      User->FilesToday++;
  545.                      User->DownloadFiles++;
  546.                      User->BytesToday += ulSize;
  547.                      User->DownloadBytes += ulSize;
  548.                   }
  549.                   Transfer->SendZModem (NULL);
  550.                }
  551.             }
  552.             else {
  553.                if ((Protocol = new TProtocol (Cfg->SystemPath)) != NULL) {
  554.                   Transfer->TxQueue.Clear ();
  555.                   Transfer->TxQueue.New ();
  556.                   strcpy (Transfer->TxQueue.Name, pszName);
  557.                   strcpy (Transfer->TxQueue.Complete, pszFile);
  558.                   Transfer->TxQueue.Size = ulSize;
  559.                   Transfer->TxQueue.Add ();
  560.  
  561.                   Transfer->RunExternalProtocol (TRUE, Cmd, Protocol);
  562.  
  563.                   if (Transfer->TxQueue.First () == TRUE) {
  564.                      if (Transfer->TxQueue.Sent == TRUE) {
  565.                         if (User != NULL) {
  566.                            User->FilesToday++;
  567.                            User->DownloadFiles++;
  568.                            User->BytesToday += ulSize;
  569.                            User->DownloadBytes += ulSize;
  570.                         }
  571.                      }
  572.                   }
  573.  
  574.                   delete Protocol;
  575.                }
  576.             }
  577.          }
  578.  
  579.          if (Cmd[0] == 'T') {
  580.             Embedded->Printf ("\n\x16\x01\012You have just tagged:\n\n");
  581.             User->FileTag->New ();
  582.             strcpy (User->FileTag->Name, pszName);
  583.             strcpy (User->FileTag->Complete, pszFile);
  584.             User->FileTag->Size = ulSize;
  585.             User->FileTag->Add ();
  586.             Embedded->Printf ("\x16\x01\x0A%5d. The file %s\n", User->FileTag->Index, pszName);
  587.             RetVal = Loop = FALSE;
  588.          }
  589.  
  590.          if (Cmd[0] != 'T') {
  591.             if (RetVal == FALSE) {
  592.                Embedded->Printf (Language->Text (LNG_FILEDOWNLOADERROR));
  593. //               Embedded->Printf ("\n\x16\x01\013Do you want to try to download the file again");
  594. //               if (Embedded->GetAnswer (ASK_DEFYES) == ANSWER_NO)
  595.                Loop = FALSE;
  596.             }
  597.             else
  598.                Embedded->Printf (Language->Text (LNG_FILEDOWNLOADCOMPLETE));
  599.          }
  600.       }
  601.  
  602.       delete Transfer;
  603.    }
  604.  
  605.    return (RetVal);
  606. }
  607.  
  608. VOID TLibrary::DownloadList (VOID)
  609. {
  610.    FILE *fp;
  611.    UCHAR CanDownload = FALSE;
  612.    CHAR Work[64], Cmd[16], Temp[128], *p;
  613.    struct stat statbuf;
  614.    class TFileData *File;
  615.    class TFileBase *Data;
  616.    class TPacker *Packer;
  617.  
  618.    sprintf (Work, "%s%s\\", Cfg->UsersHomePath, User->MailBox);
  619.    BuildPath (Work);
  620.    strcat (Work, "bbslist.txt");
  621.  
  622.    if (Log != NULL)
  623.       Log->Write ("+Building list of files");
  624.  
  625.    if ((fp = _fsopen (Work, "wt", SH_DENYNO)) != NULL) {
  626.       if ((File = new TFileData (DataPath)) != NULL) {
  627.          if (File->First () == TRUE) {
  628.             Embedded->Printf (Language->Text (LNG_FILEBUILDLIST));
  629.             do {
  630.                if (User->Level >= File->Level) {
  631.                   if ((File->AccessFlags & User->AccessFlags) == File->AccessFlags) {
  632.                      if ((Data = new TFileBase (Cfg->SystemPath, File->Key)) != NULL) {
  633.                         Data->SortByName ();
  634.                         if (Data->First () == TRUE) {
  635.                            fprintf (fp, "\nLibrary: %s\n", File->Key);
  636.                            fprintf (fp, "Description: %s\n", File->Display);
  637.                            fprintf (fp, "There are %lu files available for download\n\n", File->ActiveFiles);
  638.  
  639.                            fprintf (fp, "File Name    Size  Date  Description\n============ ===== ===== =====================================================\n");
  640.                            do {
  641.                               if ((p = (PSZ)Data->Description->First ()) == NULL)
  642.                                  p = "";
  643.                               fprintf (fp, "%-12.12s %4ldK %02d/%02d %.53s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  644.                               while ((p = (PSZ)Data->Description->Next ()) != NULL)
  645.                                  fprintf (fp, "                         %.53s\n", p);
  646.                            } while (Data->Next () == TRUE);
  647.  
  648.                            fprintf (fp, "\n");
  649.                            CanDownload = TRUE;
  650.                         }
  651.                         Data->Close ();
  652.                         delete Data;
  653.                      }
  654.                   }
  655.                }
  656.             } while (File->Next () == TRUE);
  657.             Embedded->Printf ("\n\n");
  658.          }
  659.          delete File;
  660.       }
  661.       fclose (fp);
  662.    }
  663.  
  664.    if (CanDownload == TRUE) {
  665.       Embedded->Printf ("\n\n");
  666.  
  667.       if ((Packer = new TPacker (Cfg->SystemPath)) != NULL) {
  668.          if (Packer->First () == TRUE)
  669.             do {
  670.                Embedded->Printf ("  \x16\x01\013%s ... \x16\x01\016%s\n", Packer->Key, Packer->Display);
  671.             } while (Packer->Next () == TRUE);
  672.  
  673.          do {
  674.             Embedded->Printf ("\n\x16\x01\013Choose a compression option (or RETURN to exit): ");
  675.             Embedded->Input (Cmd, (USHORT)(sizeof (Cmd) - 1), 0);
  676.          } while (Cmd[0] != '\0' && Embedded->AbortSession () == FALSE && Packer->Read (Cmd) == FALSE);
  677.  
  678.          if (Cmd[0] != '\0' && Packer->Read (Cmd) == TRUE) {
  679.             Embedded->Printf ("\n\x16\x01\016Please wait while compressing your mail packet.\n");
  680.             sprintf (Temp, "%s%s\\", Cfg->UsersHomePath, User->MailBox);
  681.             strcat (Temp, "filelist.bbs");
  682.             if (Packer->DoPack (Temp, Work) == TRUE) {
  683.                stat (Temp, &statbuf);
  684.                if (DownloadFile (Temp, "filelist.bbs", statbuf.st_size) == TRUE) {
  685.                   unlink (Temp);
  686.                   sprintf (Work, "%s%s", Cfg->UsersHomePath, User->MailBox);
  687.                   rmdir (Work);
  688.                }
  689.                else if (User->FileTag->Check ("filelist.bbs") == TRUE) {
  690.                   User->FileTag->DeleteAfter = TRUE;
  691.                   User->FileTag->Update ();
  692.                }
  693.                else {
  694.                   unlink (Temp);
  695.                   sprintf (Work, "%s%s", Cfg->UsersHomePath, User->MailBox);
  696.                   rmdir (Work);
  697.                }
  698.             }
  699.          }
  700.          else {
  701.             unlink (Work);
  702.             sprintf (Work, "%s%s", Cfg->UsersHomePath, User->MailBox);
  703.             rmdir (Work);
  704.          }
  705.  
  706.          delete Packer;
  707.       }
  708.    }
  709. }
  710.  
  711. VOID TLibrary::FileDetails (class TFileBase *File)
  712. {
  713.    USHORT Line;
  714.    CHAR Temp[128];
  715.    PSZ Text;
  716.    ULONG DlTime;
  717.  
  718.    Embedded->Printf ("\x0C\x16\x01\x0A   File Name: \x16\x01\x0E%-32.32s  \x16\x01\x0A       Date: \x16\x01\x0E%02d/%02d/%02d\n", File->Name, File->Date.Day, File->Date.Month, File->Date.Year % 100);
  719.    Embedded->Printf ("\x16\x01\x0A     Library: \x16\x01\x0E%-32.32s  \x16\x01\x0A       Time: \x16\x01\x0E%02d:%02d\n", File->Area, File->Date.Hour, File->Date.Minute);
  720.    Embedded->Printf ("\x16\x01\x0ASize (bytes): \x16\x01\x0E%lu\n", File->Size);
  721.    if (File->Uploader == NULL)
  722.       File->Uploader = "";
  723.    Embedded->Printf ("\x16\x01\x0A Uploaded by: \x16\x01\x0E%-32.32s  \x16\x01\x0A Downloaded: \x16\x01\x0E%lu \x16\x01\x0Atimes\n", File->Uploader, File->DlTimes);
  724.    Embedded->Printf ("\x16\x01\x0A              %32.32s        Added: \x16\x01\x0E%02d/%02d/%02d %02d:%02d\n", "", File->UplDate.Day, File->UplDate.Month, File->UplDate.Year % 100, File->UplDate.Hour, File->UplDate.Minute);
  725.  
  726.    DlTime = (File->Size / (CarrierSpeed / 10L) + 30L) / 60L;
  727.    if (DlTime < 1)
  728.       Embedded->Printf ("\n\x16\x01\012Approximate download time: \x16\x01\x0E< 1 \x16\x01\x0Aminute.\n\n");
  729.    else
  730.       Embedded->Printf ("\n\x16\x01\012Approximate download time: \x16\x01\x0E%ld \x16\x01\x0Aminutes.\n\n", DlTime);
  731.  
  732.    if ((Text = (PSZ)File->Description->First ()) != NULL) {
  733.       Embedded->Printf ("\x16\x01\012Description:\n\x16\x01\x0E");
  734.       Line = 10;
  735.       do {
  736.          Embedded->Printf ("%s\n", Text);
  737.          Line = Embedded->MoreQuestion (Line);
  738.       } while (Line != 0 && Embedded->AbortSession () == FALSE && (Text = (PSZ)File->Description->Next ()) != NULL);
  739.    }
  740.  
  741.    Temp[0] = '\0';
  742.    while (toupper (Temp[0]) != 'X' && Embedded->AbortSession () == FALSE) {
  743.       Embedded->Printf ("\n\x16\x01\013(D)ownload now, (T)ag for download later, or e(X)it? ");
  744.       Embedded->Input (Temp, 1, (Embedded->HotKey == TRUE) ? INP_HOTKEY : 0);
  745.  
  746.       switch (toupper (Temp[0])) {
  747.          case '\0':
  748.             Temp[0] = 'X';
  749.             break;
  750.  
  751.          case 'D': {
  752.             class TFileData *fd;
  753.  
  754.             if ((fd = new TFileData (DataPath)) != NULL) {
  755.                if (fd->Read (File->Area) == TRUE) {
  756.                   sprintf (Temp, "%s%s", fd->Download, File->Name);
  757.                   if (DownloadFile (Temp, File->Name, 0L) == TRUE) {
  758.                      File->DlTimes++;
  759.                      File->ReplaceHeader ();
  760.                   }
  761.                   Temp[0] = 'X';
  762.                }
  763.                delete fd;
  764.             }
  765.             break;
  766.          }
  767.  
  768.          case 'T': {
  769.             class TFileData *fd;
  770.             class TFileTag *Tag = User->FileTag;
  771.  
  772.             if ((fd = new TFileData (DataPath)) != NULL) {
  773.                if (fd->Read (File->Area) == TRUE) {
  774.                   Tag->New ();
  775.                   strcpy (Tag->Name, File->Name);
  776.                   strcpy (Tag->Area, File->Area);
  777.                   Tag->Size = File->Size;
  778.                   sprintf (Tag->Complete, "%s%s", fd->Download, File->Name);
  779.                   Tag->CdRom = fd->CdRom;
  780.                   Tag->Add ();
  781.                   Temp[0] = 'X';
  782.                }
  783.                delete fd;
  784.             }
  785.             break;
  786.          }
  787.       }
  788.    }
  789. }
  790.  
  791. VOID TLibrary::ListDownloadedFiles (VOID)
  792. {
  793.    CHAR Range;
  794.    class TFileBase *Data;
  795.  
  796.    if ((Range = (CHAR)SearchRange ()) != 'X') {
  797.       if ((Data = new TFileBase (Cfg->SystemPath, (Range == 'A') ? "" : Current->Key)) != NULL) {
  798.          Data->SortByDownload ();
  799.          ListFiles (Data);
  800.          Data->Close ();
  801.          delete Data;
  802.       }
  803.    }
  804. }
  805.  
  806. VOID TLibrary::TagListed (VOID)
  807. {
  808.    USHORT First = TRUE;
  809.    CHAR Names[64], *p;
  810.    ULONG DlTime;
  811.    class TFileBase *Data;
  812.    class TFileTag *Files = User->FileTag;
  813.  
  814.    Embedded->Printf (Language->Text (LNG_FILETAGLISTED), Files->TotalFiles + 1);
  815.    Embedded->Input (Names, (USHORT)(sizeof (Names) - 1), INP_NOCRLF);
  816.  
  817.    if ((Data = new TFileBase (Cfg->SystemPath, "")) != NULL) {
  818.       if ((p = strtok (Names, " ")) != NULL)
  819.          do {
  820.             if (First == FALSE)
  821.                Pause (100L);
  822.  
  823.             First = FALSE;
  824.             if (Data->Read (p) == TRUE) {
  825.                Files->New ();
  826.                strcpy (Files->Name, Data->Name);
  827.                strcpy (Files->Area, Data->Area);
  828.                Files->Size = Data->Size;
  829.                if (Data->Complete[0] == '\0')
  830.                   sprintf (Files->Complete, "%s%s", Current->Download, Files->Name);
  831.                else
  832.                   strcpy (Files->Complete, Data->Complete);
  833.                Files->CdRom = Data->CdRom;
  834.                if (Files->Add () == TRUE) {
  835.                   DlTime = Data->Size / (CarrierSpeed / 10L);
  836.                   Embedded->Printf (Language->Text (LNG_FILELISTTAGCONFIRM), Files->Index, Data->Name, DlTime / 60L, DlTime % 60L, Data->Size);
  837.                }
  838.             }
  839.             else
  840.                Embedded->Printf (Language->Text (LNG_FILELISTNOTFOUND), p);
  841.          } while ((p = strtok (NULL, " ")) != NULL);
  842.       Data->Close ();
  843.       delete Data;
  844.    }
  845. }
  846.  
  847. SHORT TLibrary::MoreQuestion (SHORT nLine)
  848. {
  849.    CHAR Temp[2];
  850.  
  851.    if (nLine == -1 || nLine == 0 || Embedded->More == FALSE)
  852.       return (nLine);
  853.  
  854.    if (++nLine >= (SHORT)(Embedded->ScreenHeight - 1)) {
  855.       while (Embedded->AbortSession () == FALSE) {
  856.          Embedded->Printf (Language->Text (LNG_FILELISTMOREQUESTION));
  857.          Embedded->GetString (Temp, 1, INP_NOCRLF|INP_NOCOLOR|INP_HOTKEY);
  858.          if (toupper (Temp[0]) == Language->Text(LNG_QUIT)[0]) {
  859.             Embedded->Printf (Language->Text(LNG_FILELISTDELETEMOREQUESTION));
  860.             return (0);
  861.          }
  862.          else if (toupper (Temp[0]) == Language->Text(LNG_NONSTOP)[0]) {
  863.             Embedded->Printf (Language->Text(LNG_FILELISTDELETEMOREQUESTION));
  864.             return (-1);
  865.          }
  866.          else if (toupper (Temp[0]) == Language->Text(LNG_CONTINUE)[0] || Temp[0] == '\0') {
  867.             Embedded->Printf (Language->Text(LNG_FILELISTDELETEMOREQUESTION));
  868.             return (1);
  869.          }
  870.          else if (toupper (Temp[0]) == Language->Text(LNG_FILELISTTAGKEY)[0])
  871.             TagListed ();
  872.       }
  873.    }
  874.  
  875.    return (nLine);
  876. }
  877.  
  878. VOID TLibrary::ListFiles (class TFileBase *Data)
  879. {
  880.    USHORT i, y, t, End, DoDelete = FALSE;
  881.    SHORT Line, TopLine = 3;
  882.    CHAR FileName[128], Redraw, Titles, *p;
  883.    class TCollection List;
  884.    class TFileTag *Tag = User->FileTag;
  885.  
  886.    if (Data == NULL) {
  887.       if ((Data = new TFileBase (Cfg->SystemPath, Current->Key)) != NULL)
  888.          Data->SortByName ();
  889.       DoDelete = TRUE;
  890.    }
  891.  
  892.    if (Data != NULL) {
  893.       if (User->FullScreen == TRUE && (Embedded->Ansi == TRUE || Embedded->Avatar == TRUE)) {
  894.          List.Clear ();
  895.          i = 0;
  896.          if (Data->First () == TRUE) {
  897.             do {
  898.                List.Add (Data->Name);
  899.                i++;
  900.             } while (Data->Next () == TRUE && i < (User->ScreenHeight - TopLine - 2));
  901.  
  902.             y = TopLine;
  903.             List.First ();
  904.             Data->First ();
  905.             End = FALSE;
  906.             Titles = Redraw = TRUE;
  907.  
  908.             while (End == FALSE && Embedded->AbortSession () == FALSE) {
  909.                if (Redraw == TRUE) {
  910.                   while (List.Previous () != NULL)
  911.                      Data->Previous ();
  912.  
  913.                   if (Titles == TRUE) {
  914.                      Embedded->Printf ("\x0C");
  915.                      Embedded->Printf (Language->Text (LNG_FILELISTHEADER));
  916.  
  917.                      Embedded->PrintfAt ((USHORT)(User->ScreenHeight - 2), 1, Language->Text (LNG_FILELISTSEPARATOR));
  918.                      Embedded->Printf (Language->Text (LNG_FILELISTDESCRIPTION1));
  919.                      Embedded->Printf (Language->Text (LNG_FILELISTDESCRIPTION2));
  920.  
  921.                      Embedded->PrintfAt (TopLine, 1, "");
  922.                   }
  923.  
  924.                   i = 0;
  925.                   do {
  926.                      if ((p = (PSZ)Data->Description->First ()) == NULL)
  927.                         p = "";
  928.                      if (Tag->Check (Data->Name) == TRUE)
  929.                         Embedded->Printf (Language->Text (LNG_FILELISTTAGGED), Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  930.                      else
  931.                         Embedded->Printf (Language->Text (LNG_FILELISTNORMAL), Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  932.                      i++;
  933.                   } while (Data->Next () == TRUE && i < (User->ScreenHeight - TopLine - 2));
  934.  
  935.                   List.Last ();
  936.                   for (t = (USHORT)(i + TopLine - 1); t > y; t--) {
  937.                      List.Previous ();
  938.                      Data->Previous ();
  939.                   }
  940.  
  941.                   if (i < (User->ScreenHeight - 2 - TopLine)) {
  942.                      do {
  943.                         Embedded->Printf ("\n");
  944.                         i++;
  945.                      } while (i < (User->ScreenHeight - 2 - TopLine));
  946.                   }
  947.                   else
  948.                      Data->Previous ();
  949.  
  950.                   Embedded->PrintfAt (y, 2, "\026\001\x70%-12.12s", (PSZ)List.Value ());
  951.                   Redraw = Titles = FALSE;
  952.                }
  953.  
  954.                if (Embedded->KBHit () == TRUE) {
  955.                   if ((i = Embedded->Getch ()) == 0)
  956.                      i = (USHORT)(Embedded->Getch () << 8);
  957.                   else
  958.                      i = (USHORT)toupper (i);
  959.  
  960.                   if (i == ESC) {
  961.                      if ((i = Embedded->Getch ()) == '[') {
  962.                         while ((i = Embedded->Getch ()) == ';' || isdigit (i))
  963.                            ;
  964.                         if (i == 'A')
  965.                            i = CTRLE;
  966.                         else if (i == 'B')
  967.                            i = CTRLX;
  968.                      }
  969.                   }
  970.  
  971.                   switch (i) {
  972.                      case CTRLD:
  973.                         Embedded->Printf ("\x0C\n");
  974.                         if ((p = (PSZ)Data->Description->First ()) == NULL)
  975.                            p = "";
  976.                         Embedded->Printf ("\026\001\016 %-12.12s \026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  977.  
  978.                         sprintf (FileName, "%s%s", Current->Download, Data->Name);
  979.                         if (DownloadFile (FileName, Data->Name, Data->Size) == TRUE) {
  980.                            Data->DlTimes++;
  981.                            Data->ReplaceHeader ();
  982.                         }
  983.  
  984.                         Titles = Redraw = TRUE;
  985.                         break;
  986.  
  987.                      case CTRLT:
  988.                         if (Tag->TotalFiles > 0) {
  989.                            Embedded->Printf ("\x0C\n");
  990.                            Download (Tag);
  991.                            Titles = Redraw = TRUE;
  992.                         }
  993.                         break;
  994.  
  995.                      case ' ':
  996.                         if (Tag->Check (Data->Name) == FALSE) {
  997.                            Tag->New ();
  998.                            strcpy (Tag->Name, Data->Name);
  999.                            strcpy (Tag->Area, Data->Area);
  1000.                            if (Data->Complete[0] == '\0')
  1001.                               sprintf (Tag->Complete, "%s%s", Current->Download, Tag->Name);
  1002.                            else
  1003.                               strcpy (Tag->Complete, Data->Complete);
  1004.                            Tag->Size = Data->Size;
  1005.                            Tag->Add ();
  1006.                         }
  1007.                         else
  1008.                            Tag->Remove (Data->Name);
  1009.                         Embedded->PrintfAt (1, 29, " \x16\x01\013CTRL-T \x16\x01\016downloads tagged files (%d tagged).", Tag->TotalFiles);
  1010.                         if (Tag->TotalFiles == 0)
  1011.                            Embedded->PrintfAt (1, 29, "\x1B[K");
  1012.                         if (Tag->Check (Data->Name) == TRUE)
  1013.                            Embedded->PrintfAt (y, 1, "\026\001\016*%-12.12s*", Data->Name);
  1014.                         else
  1015.                            Embedded->PrintfAt (y, 1, "\026\001\016 %-12.12s ", Data->Name);
  1016.                         Embedded->PrintfAt (y, 2, "\x16\x01\x70%-12.12s\x16\x01\x0E", (PSZ)List.Value ());
  1017.                         break;
  1018.  
  1019.                      case CTRLY:
  1020.                         Embedded->PrintfAt (y, 2, "\x16\x01\x0E%-12.12s\x16\x01\x0E", (PSZ)List.Value ());
  1021.                         while (List.Previous () != NULL) {
  1022.                            Data->Previous ();
  1023.                            y--;
  1024.                         }
  1025.                         if (Data->Previous () == TRUE) {
  1026.                            Embedded->PrintfAt (TopLine, 1, "");
  1027.                            for (i = 0; i < (User->ScreenHeight - TopLine - 2); i++)
  1028.                               Embedded->Printf ("\x1B[K\n");
  1029.                            for (i = 0; i < (User->ScreenHeight - TopLine - 2 - 1); i++)
  1030.                               Data->Previous ();
  1031.                            List.Clear ();
  1032.                            Embedded->PrintfAt (TopLine, 1, "");
  1033.                            i = 0;
  1034.                            do {
  1035.                               if ((p = (PSZ)Data->Description->First ()) == NULL)
  1036.                                  p = "";
  1037.                               if (Tag->Check (Data->Name) == TRUE)
  1038.                                  Embedded->Printf ("\026\001\016*%-12.12s*\026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1039.                               else
  1040.                                  Embedded->Printf ("\026\001\016 %-12.12s \026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1041.                               List.Add (Data->Name, (USHORT)(strlen (Data->Name) + 1));
  1042.                               i++;
  1043.                            } while (Data->Next () == TRUE && i < (User->ScreenHeight - TopLine - 2));
  1044.                            Data->Previous ();
  1045.                            y = (USHORT)(TopLine + User->ScreenHeight - TopLine - 2 - 1);
  1046.                            List.Last ();
  1047.                            Embedded->PrintfAt (y, 2, "\x16\x01\x70%-12.12s\x16\x01\x0E", (PSZ)List.Value ());
  1048.                         }
  1049.                         break;
  1050.  
  1051.                      case CTRLE:
  1052.                      case 0x4800:
  1053.                         if (List.Previous () != NULL) {
  1054.                            Embedded->PrintfAt (y, 2, "\x16\x01\x0E%-12.12s\x16\x01\x0E", (PSZ)List.Next ());
  1055.                            Embedded->PrintfAt (--y, 2, "\x16\x01\x70%-12.12s\x16\x01\x0E", (PSZ)List.Previous ());
  1056.                            Data->Previous ();
  1057.                         }
  1058.                         else if (Data->Previous () == TRUE) {
  1059.                            Embedded->PrintfAt (TopLine, 1, "");
  1060.                            for (i = 0; i < (User->ScreenHeight - TopLine - 2); i++)
  1061.                               Embedded->Printf ("\x1B[K\n");
  1062.                            for (i = 0; i < (User->ScreenHeight - TopLine - 2 - 1); i++)
  1063.                               Data->Previous ();
  1064.                            List.Clear ();
  1065.                            Embedded->PrintfAt (TopLine, 1, "");
  1066.                            i = 0;
  1067.                            do {
  1068.                               if ((p = (PSZ)Data->Description->First ()) == NULL)
  1069.                                  p = "";
  1070.                               if (Tag->Check (Data->Name) == TRUE)
  1071.                                  Embedded->Printf ("\026\001\016*%-12.12s*\026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1072.                               else
  1073.                                  Embedded->Printf ("\026\001\016 %-12.12s \026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1074.                               List.Add (Data->Name, (USHORT)(strlen (Data->Name) + 1));
  1075.                               i++;
  1076.                            } while (Data->Next () == TRUE && i < (User->ScreenHeight - TopLine - 2));
  1077.                            Data->Previous ();
  1078.                            y = (USHORT)(TopLine + User->ScreenHeight - TopLine - 2 - 1);
  1079.                            List.Last ();
  1080.                            Embedded->PrintfAt (y, 2, "\x16\x01\x70%-12.12s\x16\x01\x0E", (PSZ)List.Value ());
  1081.                         }
  1082.                         break;
  1083.  
  1084.                      case '\r':
  1085.                         FileDetails (Data);
  1086.                         Titles = Redraw = TRUE;
  1087.                         break;
  1088.  
  1089.                      case CTRLV:
  1090.                         Embedded->PrintfAt (y, 2, "\x16\x01\x0E%-12.12s\x16\x01\x0E", (PSZ)List.Value ());
  1091.                         while (List.Next () != NULL) {
  1092.                            Data->Next ();
  1093.                            y++;
  1094.                         }
  1095.                         if (Data->Next () == TRUE) {
  1096.                            Embedded->PrintfAt (TopLine, 1, "");
  1097.                            for (i = 0; i < (User->ScreenHeight - TopLine - 2); i++)
  1098.                               Embedded->Printf ("\x1B[K\n");
  1099.                            List.Clear ();
  1100.                            Embedded->PrintfAt (TopLine, 1, "");
  1101.                            i = 0;
  1102.                            do {
  1103.                               if ((p = (PSZ)Data->Description->First ()) == NULL)
  1104.                                  p = "";
  1105.                               if (Tag->Check (Data->Name) == TRUE)
  1106.                                  Embedded->Printf ("\026\001\016*%-12.12s*\026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1107.                               else
  1108.                                  Embedded->Printf ("\026\001\016 %-12.12s \026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1109.                               List.Add (Data->Name, (USHORT)(strlen (Data->Name) + 1));
  1110.                            } while (Data->Next () == TRUE && ++i < (User->ScreenHeight - TopLine - 2));
  1111.                            for (y = 0; y < i; y++)
  1112.                               Data->Previous ();
  1113.                            y = TopLine;
  1114.                            List.First ();
  1115.                            Embedded->PrintfAt (y, 2, "\x16\x01\x70%-12.12s\x16\x01\x0E", (PSZ)List.Value ());
  1116.                         }
  1117.                         break;
  1118.  
  1119.                      case CTRLX:
  1120.                      case 0x5000:
  1121.                         if (List.Next () != NULL) {
  1122.                            Embedded->PrintfAt (y, 2, "\x16\x01\x0E%-12.12s\x16\x01\x0E", (PSZ)List.Previous ());
  1123.                            Embedded->PrintfAt (++y, 2, "\x16\x01\x70%-12.12s\x16\x01\x0E", (PSZ)List.Next ());
  1124.                            Data->Next ();
  1125.                         }
  1126.                         else if (Data->Next () == TRUE) {
  1127.                            Embedded->PrintfAt (TopLine, 1, "");
  1128.                            for (i = 0; i < (User->ScreenHeight - TopLine - 2); i++)
  1129.                               Embedded->Printf ("\x1B[K\n");
  1130.                            List.Clear ();
  1131.                            Embedded->PrintfAt (TopLine, 1, "");
  1132.                            i = 0;
  1133.                            do {
  1134.                               if ((p = (PSZ)Data->Description->First ()) == NULL)
  1135.                                  p = "";
  1136.                               if (Tag->Check (Data->Name) == TRUE)
  1137.                                  Embedded->Printf ("\026\001\016*%-12.12s*\026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1138.                               else
  1139.                                  Embedded->Printf ("\026\001\016 %-12.12s \026\001\015%4ldK \026\001\002%2d/%02d/%02d \026\001\003%.50s\n", Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1140.                               List.Add (Data->Name, (USHORT)(strlen (Data->Name) + 1));
  1141.                            } while (Data->Next () == TRUE && ++i < (User->ScreenHeight - TopLine - 2));
  1142.                            for (y = 0; y < i; y++)
  1143.                               Data->Previous ();
  1144.                            y = TopLine;
  1145.                            List.First ();
  1146.                            Embedded->PrintfAt (y, 2, "\x16\x01\x70%-12.12s\x16\x01\x0E", (PSZ)List.Value ());
  1147.                         }
  1148.                         break;
  1149.  
  1150.                      case 'X':
  1151.                         End = TRUE;
  1152.                         break;
  1153.                   }
  1154.                }
  1155.  
  1156. #if defined(__OS2__)
  1157.                DosSleep (1L);
  1158. #elif defined(__NT__)
  1159.                Sleep (1L);
  1160. #endif
  1161.             }
  1162.  
  1163.             Embedded->Printf ("\x0C");
  1164.          }
  1165.          else
  1166.             Embedded->Printf (Language->Text (LNG_FILELISTNOFILESFOUND));
  1167.       }
  1168.       else {
  1169.          if (Data->First () == TRUE) {
  1170.             Embedded->BufferedPrintf ("\x0C");
  1171.             Embedded->BufferedPrintf (Language->Text (LNG_FILELISTHEADER));
  1172.             Line = 2;
  1173.             do {
  1174.                if ((p = (PSZ)Data->Description->First ()) == NULL)
  1175.                   p = "";
  1176.                if (Tag->Check (Data->Name) == TRUE)
  1177.                   Embedded->BufferedPrintf (Language->Text (LNG_FILELISTTAGGED), Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1178.                else
  1179.                   Embedded->BufferedPrintf (Language->Text (LNG_FILELISTNORMAL), Data->Name, (Data->Size + 1023) / 1024, Data->UplDate.Day, Data->UplDate.Month, Data->UplDate.Year % 100, p);
  1180.                if ((Line = MoreQuestion (Line)) == 1) {
  1181.                   Embedded->BufferedPrintf ("\x0C");
  1182.                   Embedded->BufferedPrintf (Language->Text (LNG_FILELISTHEADER));
  1183.                   Line = 2;
  1184.                }
  1185.                while ((p = (PSZ)Data->Description->Next ()) != NULL && Embedded->AbortSession () == FALSE && Line != 0) {
  1186.                   Embedded->BufferedPrintf (Language->Text (LNG_FILELISTCOMMENT), p);
  1187.                   if ((Line = MoreQuestion (Line)) == 1) {
  1188.                      Embedded->BufferedPrintf ("\x0C");
  1189.                      Embedded->BufferedPrintf (Language->Text (LNG_FILELISTHEADER));
  1190.                      Line = 2;
  1191.                   }
  1192.                }
  1193.             } while (Data->Next () == TRUE && Embedded->AbortSession () == FALSE && Line != 0);
  1194.  
  1195.             if (Line > 3)
  1196.                MoreQuestion (99);
  1197.          }
  1198.          else
  1199.             Embedded->Printf (Language->Text (LNG_FILELISTNOFILESFOUND));
  1200.       }
  1201.  
  1202.       if (DoDelete == TRUE) {
  1203.          Data->Close ();
  1204.          delete Data;
  1205.       }
  1206.    }
  1207. }
  1208.  
  1209. VOID TLibrary::ListRecentFiles (VOID)
  1210. {
  1211.    CHAR Range;
  1212.    class TFileBase *Data;
  1213.  
  1214.    if ((Range = (CHAR)SearchRange ()) != 'X') {
  1215.       if ((Data = new TFileBase (Cfg->SystemPath, (Range == 'A') ? "" : Current->Key)) != NULL) {
  1216.          Data->SortByDate ();
  1217.          ListFiles (Data);
  1218.          Data->Close ();
  1219.          delete Data;
  1220.       }
  1221.    }
  1222. }
  1223.  
  1224. VOID TLibrary::AddTagged (VOID)
  1225. {
  1226.    CHAR Names[64], *p;
  1227.    ULONG DlTime;
  1228.    class TFileBase *Data;
  1229.    class TFileTag *Files = User->FileTag;
  1230.  
  1231.    do {
  1232.       Embedded->Printf (Language->Text (LNG_FILETOTAG), Files->TotalFiles + 1);
  1233.       Embedded->Input (Names, (USHORT)(sizeof (Names) - 1), 0);
  1234.  
  1235.       if ((Data = new TFileBase (Cfg->SystemPath, "")) != NULL) {
  1236.          if ((p = strtok (Names, " ")) != NULL)
  1237.             do {
  1238.                if (Data->Read (p) == TRUE) {
  1239.                   Files->New ();
  1240.                   strcpy (Files->Name, Data->Name);
  1241.                   strcpy (Files->Area, Data->Area);
  1242.                   Files->Size = Data->Size;
  1243.                   if (Data->Complete[0] == '\0')
  1244.                      sprintf (Files->Complete, "%s%s", Current->Download, Files->Name);
  1245.                   else
  1246.                      strcpy (Files->Complete, Data->Complete);
  1247.                   Files->CdRom = Data->CdRom;
  1248.                   if (Files->Add () == TRUE) {
  1249.                      DlTime = Data->Size / (CarrierSpeed / 10L);
  1250.                      Embedded->Printf (Language->Text (LNG_FILETAGCONFIRM), Files->Index, Data->Name, DlTime / 60L, DlTime % 60L, Data->Size);
  1251.                   }
  1252.                }
  1253.                else
  1254.                   Embedded->Printf (Language->Text (LNG_FILENOTFOUND), p);
  1255.             } while ((p = strtok (NULL, " ")) != NULL);
  1256.          Data->Close ();
  1257.          delete Data;
  1258.       }
  1259.    } while (Names[0] != '\0');
  1260. }
  1261.  
  1262. VOID TLibrary::ListTagged (VOID)
  1263. {
  1264.    ULONG DlTime;
  1265.    class TFileTag *Tag = User->FileTag;
  1266.  
  1267.    Tag->Reindex ();
  1268.  
  1269.    if (Tag->First () == TRUE) {
  1270.       Embedded->Printf (Language->Text (LNG_FILETAGGEDHEADER));
  1271.  
  1272.       do {
  1273.          DlTime = Tag->Size / (CarrierSpeed / 10L);
  1274.          Embedded->Printf (Language->Text (LNG_FILETAGGEDLIST), Tag->Index, Tag->Name, Tag->Area, DlTime / 60L, DlTime % 60L, Tag->Size);
  1275.       } while (Tag->Next () == TRUE);
  1276.  
  1277.       DlTime = Tag->TotalBytes / (CarrierSpeed / 10L);
  1278.       Embedded->Printf (Language->Text (LNG_FILETAGGEDTOTAL), Tag->TotalBytes, DlTime / 60L, DlTime % 60L);
  1279.    }
  1280.    else
  1281.       Embedded->Printf (Language->Text (LNG_FILENOTAGGED));
  1282. }
  1283.  
  1284. VOID TLibrary::DeleteTagged (VOID)
  1285. {
  1286.    SHORT Index;
  1287.    CHAR Temp[32];
  1288.    class TFileTag *Tag = User->FileTag;
  1289.  
  1290.    Tag->Reindex ();
  1291.  
  1292.    if (Tag->First () == TRUE) {
  1293.       Embedded->Printf (Language->Text (LNG_FILETODETAG), Tag->TotalFiles);
  1294.       Embedded->Input (Temp, (USHORT)(sizeof (Temp) - 1), 0);
  1295.  
  1296.       if (Embedded->AbortSession () == FALSE) {
  1297.          if (toupper (Temp[0] == 'A')) {
  1298.             while (Tag->First () == TRUE) {
  1299.                Embedded->Printf (Language->Text (LNG_FILEDETAGGED), Tag->Name);
  1300.                Tag->Remove ();
  1301.             }
  1302.             Embedded->Printf (Language->Text (LNG_FILETAGEMPTY));
  1303.          }
  1304.          else {
  1305.             Index = (SHORT)atoi (Temp);
  1306.             if (Index > 0) {
  1307.                if (Tag->Select ((USHORT)abs (Index)) == TRUE)
  1308.                   Tag->Remove ();
  1309.             }
  1310.          }
  1311.       }
  1312.    }
  1313. }
  1314.  
  1315. VOID TLibrary::DeleteAllTagged (VOID)
  1316. {
  1317.    class TFileTag *Tag = User->FileTag;
  1318.  
  1319.    Tag->Reindex ();
  1320.  
  1321.    if (Tag->First () == TRUE) {
  1322.       while (Tag->First () == TRUE)
  1323.          Tag->Remove ();
  1324.       Embedded->Printf (Language->Text (LNG_FILETAGEMPTY));
  1325.    }
  1326. }
  1327.  
  1328. VOID TLibrary::RemoveFiles (VOID)
  1329. {
  1330.    CHAR FileName[32];
  1331.    class TFileBase *Data;
  1332.  
  1333.    Embedded->Printf (Language->Text (LNG_FILENAMETODELETE));
  1334.    Embedded->Input (FileName, sizeof (FileName) - 1, 0);
  1335.  
  1336.    if (FileName[0] != '\0') {
  1337.       if ((Data = new TFileBase (Cfg->SystemPath, Current->Key)) != NULL) {
  1338.          if (Data->Read (FileName) == TRUE) {
  1339.             Data->Delete ();
  1340.             Embedded->Printf (Language->Text (LNG_FILEDELETED), strupr (FileName));
  1341.  
  1342.             Current->ActiveFiles--;
  1343.             Current->Update ();
  1344.             if (Log != NULL)
  1345.                Log->Write ("+Deleted file %s from library %s", FileName, Current->Key);
  1346.          }
  1347.          else
  1348.             Embedded->Printf (Language->Text (LNG_FILENOTFOUND), FileName);
  1349.  
  1350.          Data->Close ();
  1351.          delete Data;
  1352.       }
  1353.    }
  1354. }
  1355.  
  1356. VOID TLibrary::SearchFileName (VOID)
  1357. {
  1358.    CHAR Keyword[32], Range;
  1359.    class TFileBase *Data;
  1360.  
  1361.    Embedded->Printf ("\n\026\001\012Enter the file name to find, below.\n\nYou may specify \"wildcards\" such as *.ANS or LA*.ZIP for more exact searches.\n\n\026\001\013Search file name: ");
  1362.    Embedded->Input (Keyword, (USHORT)(sizeof (Keyword) - 1), 0);
  1363.  
  1364.    if (Keyword[0] != '\0' && Embedded->AbortSession () == FALSE) {
  1365.       if ((Range = (CHAR)SearchRange ()) != 'X') {
  1366.          if ((Data = new TFileBase (Cfg->SystemPath, (Range == 'A') ? "" : Current->Key)) != NULL) {
  1367.             Data->SearchFile (Keyword);
  1368.             ListFiles (Data);
  1369.             Data->Close ();
  1370.             delete Data;
  1371.          }
  1372.       }
  1373.    }
  1374. }
  1375.  
  1376. VOID TLibrary::SearchKeyword (VOID)
  1377. {
  1378.    CHAR Keyword[32], Range;
  1379.    class TFileBase *Data;
  1380.  
  1381.    Embedded->Printf ("\n\x16\x01\x0BOn the line below, enter your keyword list, ? for help, or RETURN to exit.\n: ");
  1382.    Embedded->Input (Keyword, (USHORT)(sizeof (Keyword) - 1), 0);
  1383.  
  1384.    if (Keyword[0] != '\0' && Embedded->AbortSession () == FALSE) {
  1385.       if ((Range = (CHAR)SearchRange ()) != 'X') {
  1386.          if ((Data = new TFileBase (Cfg->SystemPath, (Range == 'A') ? "" : Current->Key)) != NULL) {
  1387.             Data->SearchKeyword (Keyword);
  1388.             ListFiles (Data);
  1389.             Data->Close ();
  1390.             delete Data;
  1391.          }
  1392.       }
  1393.    }
  1394. }
  1395.  
  1396. VOID TLibrary::SearchNewFiles (VOID)
  1397. {
  1398.    CHAR Range;
  1399.    class TFileBase *Data;
  1400.  
  1401.    if ((Range = (CHAR)SearchRange ()) != 'X') {
  1402.       if ((Data = new TFileBase (Cfg->SystemPath, (Range == 'A') ? "" : Current->Key)) != NULL) {
  1403.          Data->SortByDate (User->LastCall);
  1404.          ListFiles (Data);
  1405.          Data->Close ();
  1406.          delete Data;
  1407.       }
  1408.    }
  1409. }
  1410.  
  1411. USHORT TLibrary::SearchRange (VOID)
  1412. {
  1413.    CHAR Range[4];
  1414.  
  1415.    while (Embedded->AbortSession () == FALSE) {
  1416.       Embedded->Printf ("\n\x16\x01\012Which Libraries would you like included in the list of search?\n\n");
  1417.       Embedded->Printf ("  \x16\x01\013C \x16\x01\016... Current Library (%s)\n", Current->Key);
  1418.       Embedded->Printf ("  \x16\x01\013A \x16\x01\016... All Libraries\n\n");
  1419.       Embedded->Printf ("\x16\x01\013Select an option, X to exit, or RETURN for the current Library: ");
  1420.       Embedded->Input (Range, 1, INP_HOTKEY);
  1421.       Range[0] = (CHAR)toupper (Range[0]);
  1422.       if (Range[0] == 'A' || Range[0] == 'C' || Range[0] == 'X' || Range[0] == '\0')
  1423.          break;
  1424.    }
  1425.  
  1426.    return ((USHORT)toupper (Range[0]));
  1427. }
  1428.  
  1429. VOID TLibrary::SearchText (VOID)
  1430. {
  1431.    CHAR Keyword[32], Range;
  1432.    class TFileBase *Data;
  1433.  
  1434.    Embedded->Printf ("\n\x16\x01\013Enter the text to search, ? for help, or RETURN to exit.\n: ");
  1435.    Embedded->Input (Keyword, (USHORT)(sizeof (Keyword) - 1), 0);
  1436.  
  1437.    if (Keyword[0] != '\0' && Embedded->AbortSession () == FALSE) {
  1438.       if ((Range = (CHAR)SearchRange ()) != 'X') {
  1439.          if ((Data = new TFileBase (Cfg->SystemPath, (Range == 'A') ? "" : Current->Key)) != NULL) {
  1440.             Data->SearchText (Keyword);
  1441.             ListFiles (Data);
  1442.             Data->Close ();
  1443.             delete Data;
  1444.          }
  1445.       }
  1446.    }
  1447. }
  1448.  
  1449. USHORT TLibrary::SelectArea (PSZ pszArea)
  1450. {
  1451.    USHORT RetVal = FALSE, FirstHit, DoList;
  1452.    SHORT Line;
  1453.    CHAR Command[16], Temp[128];
  1454.    class TFileData *File;
  1455.    class TFileAreaListing *List;
  1456.  
  1457.    DoList = FALSE;
  1458.    if (pszArea != NULL && *pszArea != '\0') {
  1459.       strcpy (Command, pszArea);
  1460.       DoList = TRUE;
  1461.    }
  1462.  
  1463.    if ((File = new TFileData (DataPath)) != NULL) {
  1464.       do {
  1465.          if (DoList == FALSE) {
  1466.             Embedded->Printf (Language->Text (LNG_FILEAREAREQUEST));
  1467.             Embedded->Input (Command, (USHORT)(sizeof (Command) - 1), INP_FIELD);
  1468.          }
  1469.          else
  1470.             DoList = FALSE;
  1471.  
  1472.          if (!stricmp (Command, "?")) {
  1473.             if (User->FullScreen == TRUE && (Embedded->Ansi == TRUE || Embedded->Avatar == TRUE)) {
  1474.                if ((List = new TFileAreaListing) != NULL) {
  1475.                   List->Cfg = Cfg;
  1476.                   List->Embedded = Embedded;
  1477.                   List->Log = Log;
  1478.                   List->Current = Current;
  1479.                   List->User = User;
  1480.                   List->Language = Language;
  1481.                   RetVal = List->Run ();
  1482.                   delete List;
  1483.                }
  1484.             }
  1485.             else {
  1486.                if (File->First () == TRUE) {
  1487.                   Embedded->Printf ("\x0C");
  1488.                   Embedded->Printf (Language->Text (LNG_FILEAREAHEADER));
  1489.                   Line = 3;
  1490.                   do {
  1491.                      if (User->Level >= File->Level) {
  1492.                         if ((File->AccessFlags & User->AccessFlags) == File->AccessFlags) {
  1493.                            Embedded->Printf (Language->Text (LNG_FILEAREALIST), File->Key, File->ActiveFiles, File->Display);
  1494.                            if ((Line = Embedded->MoreQuestion (Line)) == 1) {
  1495.                               Embedded->Printf ("\x0C");
  1496.                               Embedded->Printf (Language->Text (LNG_FILEAREAHEADER));
  1497.                               Line = 3;
  1498.                            }
  1499.                         }
  1500.                      }
  1501.                   } while (Line != 0 && Embedded->AbortSession () == FALSE && File->Next () == TRUE);
  1502.                }
  1503.             }
  1504.          }
  1505.          else if (!stricmp (Command, "[")) {
  1506.             File->Read (Current->Key, FALSE);
  1507.             if (File->Previous () == TRUE)
  1508.                do {
  1509.                   if (User->Level >= File->Level) {
  1510.                      if ((File->AccessFlags & User->AccessFlags) == File->AccessFlags) {
  1511.                         Current->Read (File->Key);
  1512.                         if (User != NULL) {
  1513.                            strcpy (User->LastFileArea, Current->Key);
  1514.                            User->Update ();
  1515.                         }
  1516.                         if (Current->Download[strlen (Current->Download) - 1] != '\\')
  1517.                            strcat (Current->Download, "\\");
  1518.                         if (Current->Upload[strlen (Current->Upload) - 1] != '\\')
  1519.                            strcat (Current->Upload, "\\");
  1520.                         Log->Write (":File Area: %s - %s", File->Key, File->Display);
  1521.                         RetVal = TRUE;
  1522.                         break;
  1523.                      }
  1524.                   }
  1525.                } while (File->Previous () == TRUE);
  1526.          }
  1527.          else if (!stricmp (Command, "]")) {
  1528.             File->Read (Current->Key, FALSE);
  1529.             if (File->Next () == TRUE)
  1530.                do {
  1531.                   if (User->Level >= File->Level) {
  1532.                      if ((File->AccessFlags & User->AccessFlags) == File->AccessFlags) {
  1533.                         Current->Read (File->Key);
  1534.                         if (User != NULL) {
  1535.                            strcpy (User->LastFileArea, Current->Key);
  1536.                            User->Update ();
  1537.                         }
  1538.                         if (Current->Download[strlen (Current->Download) - 1] != '\\')
  1539.                            strcat (Current->Download, "\\");
  1540.                         if (Current->Upload[strlen (Current->Upload) - 1] != '\\')
  1541.                            strcat (Current->Upload, "\\");
  1542.                         Log->Write (":File Area: %s - %s", File->Key, File->Display);
  1543.                         RetVal = TRUE;
  1544.                         break;
  1545.                      }
  1546.                   }
  1547.                } while (File->Next () == TRUE);
  1548.          }
  1549.          else if (Command[0] != '\0') {
  1550.             if (File->Read (Command) == TRUE) {
  1551.                if (User->Level >= File->Level) {
  1552.                   if ((File->AccessFlags & User->AccessFlags) == File->AccessFlags) {
  1553.                      Current->Read (Command);
  1554.  
  1555.                      if (User != NULL) {
  1556.                         strcpy (User->LastFileArea, Current->Key);
  1557.                         User->Update ();
  1558.                      }
  1559.  
  1560.                      if (Current->Download[strlen (Current->Download) - 1] != '\\')
  1561.                         strcat (Current->Download, "\\");
  1562.                      if (Current->Upload[strlen (Current->Upload) - 1] != '\\')
  1563.                         strcat (Current->Upload, "\\");
  1564.                      Log->Write (":File Area: %s - %s", File->Key, File->Display);
  1565.                      RetVal = TRUE;
  1566.                   }
  1567.                }
  1568.             }
  1569.  
  1570.             if (RetVal == FALSE) {
  1571.                if (User->FullScreen == TRUE && (Embedded->Ansi == TRUE || Embedded->Avatar == TRUE)) {
  1572.                   if ((List = new TFileAreaListing) != NULL) {
  1573.                      List->Cfg = Cfg;
  1574.                      List->Embedded = Embedded;
  1575.                      List->Log = Log;
  1576.                      List->Current = Current;
  1577.                      List->User = User;
  1578.                      strcpy (List->Command, Command);
  1579.                      List->Language = Language;
  1580.                      RetVal = List->Run ();
  1581.                      delete List;
  1582.                   }
  1583.                }
  1584.                else {
  1585.                   FirstHit = TRUE;
  1586.                   strupr (Command);
  1587.                   Line = 3;
  1588.  
  1589.                   if (File->First () == TRUE) {
  1590.                      do {
  1591.                         if (User->Level >= File->Level) {
  1592.                            if ((File->AccessFlags & User->AccessFlags) == File->AccessFlags) {
  1593.                               strcpy (Temp, File->Key);
  1594.                               if (strstr (strupr (Temp), Command) != NULL) {
  1595.                                  if (FirstHit == TRUE)
  1596.                                     Embedded->Printf (Language->Text (LNG_FILEAREAHEADER));
  1597.                                  Embedded->Printf (Language->Text (LNG_FILEAREALIST), File->Key, File->ActiveFiles, File->Display);
  1598.                                  Line = Embedded->MoreQuestion (Line);
  1599.                                  FirstHit = FALSE;
  1600.                               }
  1601.                               else {
  1602.                                  strcpy (Temp, File->Display);
  1603.                                  if (strstr (strupr (Temp), Command) != NULL) {
  1604.                                     if (FirstHit == TRUE)
  1605.                                        Embedded->Printf (Language->Text (LNG_FILEAREAHEADER));
  1606.                                     Embedded->Printf (Language->Text (LNG_FILEAREALIST), File->Key, File->ActiveFiles, File->Display);
  1607.                                     Line = Embedded->MoreQuestion (Line);
  1608.                                     FirstHit = FALSE;
  1609.                                  }
  1610.                               }
  1611.                            }
  1612.                         }
  1613.                      } while (Line != 0 && Embedded->AbortSession () == FALSE && File->Next () == TRUE);
  1614.                   }
  1615.  
  1616.                   if (FirstHit == TRUE)
  1617.                      Embedded->Printf (Language->Text (LNG_FILEAREANOTAVAILABLE));
  1618.                }
  1619.                if (pszArea != NULL && *pszArea != '\0')
  1620.                   Command[0] = '\0';
  1621.             }
  1622.          }
  1623.       } while (Command[0] != '\0' && RetVal == FALSE && Embedded->AbortSession () == FALSE);
  1624.  
  1625.       delete File;
  1626.    }
  1627.  
  1628.    return (RetVal);
  1629. }
  1630.  
  1631. VOID TLibrary::Upload (VOID)
  1632. {
  1633.    SHORT fRet, BatchTransfer, DoTransfer;
  1634.    CHAR szAnswer[32], szProtocol[10], szFile[128], *p, *q, *RxFile;
  1635.    struct stat statbuf;
  1636.    struct dosdate_t date;
  1637.    struct dostime_t time;
  1638.    struct tm *timep;
  1639.    class TFileBase *Data;
  1640.    class TTransfer *Transfer;
  1641.    class TCollection Received;
  1642.    class TCommentEditor *Editor;
  1643.  
  1644.    if (User->Level >= Current->UploadLevel) {
  1645.       if ((User->AccessFlags & Current->UploadFlags) == Current->UploadFlags) {
  1646.          BatchTransfer = FALSE;
  1647.  
  1648.          while (Embedded->AbortSession () == FALSE) {
  1649.             DoTransfer = FALSE;
  1650.  
  1651.             Embedded->Printf ("\n\x16\x01\012Upload to the %s library\n\n", Current->Key);
  1652.  
  1653.             Embedded->Printf ("\x16\x01\013<file name> \x16\x01\016... Upload a file to this library\n");
  1654.             Embedded->Printf ("\x16\x01\013          * \x16\x01\016... Upload multiple files at once\n");
  1655. //            Embedded->Printf ("\x16\x01\013          M \x16\x01\016... Modify or add descriptions to files you have uploaded\n");
  1656.  
  1657.             Embedded->Printf ("\n\x16\x01\013Enter your selection, ? for more help, or RETURN to exit: ");
  1658.             Embedded->Input (szAnswer, (USHORT)(sizeof (szAnswer) - 1), 0);
  1659.             if (szAnswer[0] == '\0')
  1660.                break;
  1661.  
  1662.             if (!stricmp (szAnswer, "?")) {
  1663.                Embedded->DisplayFile ("UPLOAD");
  1664.                DoTransfer = FALSE;
  1665.             }
  1666.             else if (!stricmp (szAnswer, "*")) {
  1667.                BatchTransfer = TRUE;
  1668.                DoTransfer = TRUE;
  1669.             }
  1670.             else if (!stricmp (szAnswer, "M"))
  1671.                DoTransfer = FALSE;
  1672.             else {
  1673.                BatchTransfer = FALSE;
  1674.                DoTransfer = TRUE;
  1675.             }
  1676.  
  1677.             if (DoTransfer == TRUE) {
  1678.                if (BatchTransfer == FALSE) {
  1679.                   if ((Data = new TFileBase (Cfg->SystemPath, Current->Key)) != NULL) {
  1680.                      if (Data->Read (szAnswer) == TRUE) {
  1681.                         Embedded->Printf ("\n\x16\x01\013*** File exists!\n");
  1682.                         DoTransfer = FALSE;
  1683.                      }
  1684.                      Data->Close ();
  1685.                      delete Data;
  1686.                   }
  1687.                }
  1688.  
  1689.                if (DoTransfer == TRUE) {
  1690.                   Embedded->Printf ("\n\x16\x01\012To start uploading %s, type:\n\n", strupr (szAnswer));
  1691.  
  1692.                   if (BatchTransfer == FALSE) {
  1693.                      Embedded->Printf ("  \x16\x01\013A ... \x16\x01\016ASCII\n");
  1694.                      Embedded->Printf ("  \x16\x01\013M ... \x16\x01\016XMODEM (Checksum/CRC)\n");
  1695.                      Embedded->Printf ("  \x16\x01\0131 ... \x16\x01\016XMODEM-1K\n");
  1696.                   }
  1697.                   Embedded->Printf ("  \x16\x01\013Z ... \x16\x01\016ZMODEM\n");
  1698. //                  Embedded->Printf ("  \x16\x01\013F ... \x16\x01\016File Import (existing file)\n");
  1699.  
  1700.                   Embedded->Printf ("\n\x16\x01\013Choose an upload option, or RETURN to exit: ");
  1701.                   if (Embedded->HotKey == TRUE)
  1702.                      Embedded->Input (szProtocol, 1, INP_HOTKEY);
  1703.                   else
  1704.                      Embedded->Input (szProtocol, (USHORT)(sizeof (szProtocol) - 1), 0);
  1705.  
  1706.                   fRet = FALSE;
  1707.  
  1708.                   if ((Transfer = new TTransfer) != NULL) {
  1709.                      Transfer->Com = Embedded->Com;
  1710.                      Transfer->Log = Log;
  1711.                      Transfer->Speed = CarrierSpeed;
  1712.                      Transfer->Progress = Progress;
  1713.                      Transfer->Telnet = Cfg->ZModemTelnet;
  1714.  
  1715.                      sprintf (szFile, "%s%s", szAnswer, Current->Upload);
  1716.                      Received.Clear ();
  1717.  
  1718.                      switch (toupper (szProtocol[0])) {
  1719.                         case '1':
  1720.                            if (Transfer->Receive1kXModem (szFile) != NULL) {
  1721.                               fRet = TRUE;
  1722.                               Received.Add (szFile, (USHORT)(strlen (szFile) + 1));
  1723.                            }
  1724.                            break;
  1725.  
  1726.                         case 'M':
  1727.                            if (Transfer->ReceiveXModem (szFile) != NULL) {
  1728.                               fRet = TRUE;
  1729.                               Received.Add (szFile, (USHORT)(strlen (szFile) + 1));
  1730.                            }
  1731.                            break;
  1732.  
  1733.                         case 'Z':
  1734.                            if ((p = Transfer->ReceiveZModem (Current->Upload)) != NULL) {
  1735.                               fRet = TRUE;
  1736.                               Received.Add (p, (USHORT)(strlen (p) + 1));
  1737.                               while ((p = Transfer->ReceiveZModem (Current->Upload)) != NULL)
  1738.                                  Received.Add (p, (USHORT)(strlen (p) + 1));
  1739.                            }
  1740.                            break;
  1741.                      }
  1742.  
  1743.                      delete Transfer;
  1744.                   }
  1745.  
  1746.                   Embedded->Printf ("\n");
  1747.  
  1748.                   if (fRet == TRUE) {
  1749.                      if ((Data = new TFileBase (Cfg->SystemPath, Current->Key)) == NULL)
  1750.                         return;
  1751.  
  1752.                      if ((RxFile = (CHAR *)Received.First ()) != NULL)
  1753.                         do {
  1754.                            for (p = RxFile, q = RxFile; *p; p++) {
  1755.                               if (*p == '/' || *p == '\\' || *p == ':')
  1756.                                  q = p + 1;
  1757.                            }
  1758.  
  1759.                            Embedded->Printf ("\n\x16\x01\016Now adding %s to the %s library.\n", q, Current->Key);
  1760.  
  1761.                            stat (RxFile, &statbuf);
  1762.                            if (User != NULL) {
  1763.                               User->UploadFiles++;
  1764.                               User->UploadBytes += statbuf.st_size;
  1765.                            }
  1766.  
  1767.                            Data->Clear ();
  1768.                            strcpy (Data->Area, Current->Key);
  1769.                            strcpy (Data->Name, strupr (q));
  1770.                            Data->Size = statbuf.st_size;
  1771.                            _dos_getdate (&date);
  1772.                            _dos_gettime (&time);
  1773.                            Data->UplDate.Day = date.day;
  1774.                            Data->UplDate.Month = date.month;
  1775.                            Data->UplDate.Year = date.year;
  1776.                            Data->UplDate.Hour = time.hour;
  1777.                            Data->UplDate.Minute = time.minute;
  1778.                            timep = localtime (&statbuf.st_mtime);
  1779.  
  1780.                            Data->Date.Day = (UCHAR)timep->tm_mday;
  1781.                            Data->Date.Month = (UCHAR)(timep->tm_mon + 1);
  1782.                            Data->Date.Year = (USHORT)(timep->tm_year + 1900);
  1783.                            Data->Date.Hour = (UCHAR)timep->tm_hour;
  1784.                            Data->Date.Minute = (UCHAR)timep->tm_min;
  1785.  
  1786.                            Data->Uploader = User->Name;
  1787.  
  1788.                            if ((Editor = new TCommentEditor) != NULL) {
  1789.                               Editor->Embedded = Embedded;
  1790.                               Editor->File = Data;
  1791.                               Editor->Width = 60;
  1792.                               if (Editor->Write () == TRUE)
  1793.                                  Editor->Menu ();
  1794.                            }
  1795.  
  1796.                            Data->Add ();
  1797.                            Current->ActiveFiles++;
  1798.                         } while ((RxFile = (CHAR *)Received.Next ()) != NULL);
  1799.  
  1800.                      Data->Close ();
  1801.                      delete Data;
  1802.  
  1803.                      Current->Update ();
  1804.                   }
  1805.                }
  1806.             }
  1807.          }
  1808.       }
  1809.       else
  1810.          Embedded->Printf ("\n\x16\x01\016   *** Sorry, you can't upload files to this Library! ***\n\006\007\006\007");
  1811.    }
  1812.    else
  1813.       Embedded->Printf ("\n\x16\x01\016   *** Sorry, you can't upload files to this Library! ***\n\006\007\006\007");
  1814. }
  1815.  
  1816. VOID TLibrary::UploadUser (PSZ user)
  1817. {
  1818.    SHORT fRet, BatchTransfer, DoTransfer;
  1819.    CHAR Name[48], szAnswer[32], szProtocol[10], szFile[128], *p, *q, *RxFile;
  1820.    struct stat statbuf;
  1821.    class TTransfer *Transfer;
  1822.    class TCollection Received;
  1823.    class TUser *DestUser;
  1824.  
  1825.    if ((DestUser = new TUser (Cfg->UserFile)) != NULL) {
  1826.       if (user == NULL || *user == '\0') {
  1827.          Embedded->Printf ("\n\026\001\013Write the user's name or Enter to exit)\n: \026\001\x1E");
  1828.          Embedded->Input (Name, (USHORT)(sizeof (Name) - 1), INP_FIELD|INP_FANCY);
  1829.       }
  1830.       else
  1831.          strcpy (Name, user);
  1832.  
  1833.       if (Name[0] != '\0' && DestUser->GetData (Name) == TRUE) {
  1834.          BatchTransfer = FALSE;
  1835.          while (Embedded->AbortSession () == FALSE) {
  1836.             DoTransfer = FALSE;
  1837.  
  1838.             Embedded->Printf ("\n\x16\x01\012Upload for %s\n\n", Name);
  1839.  
  1840.             Embedded->Printf ("\x16\x01\013<file name> \x16\x01\016... Upload a file\n");
  1841.             Embedded->Printf ("\x16\x01\013          * \x16\x01\016... Upload multiple files at once\n");
  1842.  
  1843.             Embedded->Printf ("\n\x16\x01\013Enter your selection, ? for more help, or RETURN to exit: ");
  1844.             Embedded->Input (szAnswer, (USHORT)(sizeof (szAnswer) - 1), 0);
  1845.             if (szAnswer[0] == '\0')
  1846.                break;
  1847.  
  1848.             if (!stricmp (szAnswer, "?")) {
  1849.                Embedded->DisplayFile ("USRUPLD");
  1850.                DoTransfer = FALSE;
  1851.             }
  1852.             else if (!stricmp (szAnswer, "*")) {
  1853.                BatchTransfer = TRUE;
  1854.                DoTransfer = TRUE;
  1855.             }
  1856.             else {
  1857.                BatchTransfer = FALSE;
  1858.                DoTransfer = TRUE;
  1859.             }
  1860.  
  1861.             if (DoTransfer == TRUE) {
  1862.                Embedded->Printf ("\n\x16\x01\012To start uploading %s, type:\n\n", strupr (szAnswer));
  1863.  
  1864.                if (BatchTransfer == FALSE) {
  1865.                   Embedded->Printf ("  \x16\x01\013A ... \x16\x01\016ASCII\n");
  1866.                   Embedded->Printf ("  \x16\x01\013M ... \x16\x01\016XMODEM (Checksum/CRC)\n");
  1867.                   Embedded->Printf ("  \x16\x01\0131 ... \x16\x01\016XMODEM-1K\n");
  1868.                }
  1869.                Embedded->Printf ("  \x16\x01\013Z ... \x16\x01\016ZMODEM\n");
  1870.  
  1871.                Embedded->Printf ("\n\x16\x01\013Choose an upload option, or RETURN to exit: ");
  1872.                if (Embedded->HotKey == TRUE)
  1873.                   Embedded->Input (szProtocol, 1, INP_HOTKEY);
  1874.                else
  1875.                   Embedded->Input (szProtocol, (USHORT)(sizeof (szProtocol) - 1), 0);
  1876.  
  1877.                fRet = FALSE;
  1878.  
  1879.                if ((Transfer = new TTransfer) != NULL) {
  1880.                   Transfer->Com = Embedded->Com;
  1881.                   Transfer->Log = Log;
  1882.                   Transfer->Speed = CarrierSpeed;
  1883.                   Transfer->Progress = Progress;
  1884.                   Transfer->Telnet = Cfg->ZModemTelnet;
  1885.  
  1886.                   sprintf (szFile, "%s%s\\", Cfg->UsersHomePath, DestUser->MailBox);
  1887.                   BuildPath (AdjustPath (szFile));
  1888.                   strcat (szFile, szAnswer);
  1889.                   Received.Clear ();
  1890.  
  1891.                   switch (toupper (szProtocol[0])) {
  1892.                      case '1':
  1893.                         if (Transfer->Receive1kXModem (szFile) != NULL) {
  1894.                            fRet = TRUE;
  1895.                            Received.Add (szFile, (USHORT)(strlen (szFile) + 1));
  1896.                         }
  1897.                         break;
  1898.  
  1899.                      case 'M':
  1900.                         if (Transfer->ReceiveXModem (szFile) != NULL) {
  1901.                            fRet = TRUE;
  1902.                            Received.Add (szFile, (USHORT)(strlen (szFile) + 1));
  1903.                         }
  1904.                         break;
  1905.  
  1906.                      case 'Z':
  1907.                         sprintf (szFile, "%s%s\\", Cfg->UsersHomePath, DestUser->MailBox);
  1908.                         AdjustPath (szFile);
  1909.                         if ((p = Transfer->ReceiveZModem (szFile)) != NULL) {
  1910.                            fRet = TRUE;
  1911.                            Received.Add (p, (USHORT)(strlen (p) + 1));
  1912.                            while ((p = Transfer->ReceiveZModem (szFile)) != NULL)
  1913.                               Received.Add (p, (USHORT)(strlen (p) + 1));
  1914.                         }
  1915.                         break;
  1916.                   }
  1917.  
  1918.                   delete Transfer;
  1919.                }
  1920.  
  1921.                Embedded->Printf ("\n");
  1922.  
  1923.                if (fRet == TRUE) {
  1924.                   if ((RxFile = (CHAR *)Received.First ()) != NULL) {
  1925.                      do {
  1926.                         for (p = RxFile, q = RxFile; *p; p++) {
  1927.                            if (*p == '/' || *p == '\\' || *p == ':')
  1928.                               q = p + 1;
  1929.                         }
  1930.  
  1931.                         Embedded->Printf ("\n\x16\x01\016Now adding %s to %s.\n", q, Name);
  1932.  
  1933.                         sprintf (szFile, "%s%s\\%s", Cfg->UsersHomePath, DestUser->MailBox, q);
  1934.                         AdjustPath (szFile);
  1935.                         stat (szFile, &statbuf);
  1936.  
  1937.                         DestUser->FileTag->New ();
  1938.                         strcpy (DestUser->FileTag->Name, q);
  1939.                         strcpy (DestUser->FileTag->Area, "PERSONAL");
  1940.                         strcpy (DestUser->FileTag->Complete, szFile);
  1941.                         DestUser->FileTag->Size = statbuf.st_size;
  1942.                         DestUser->FileTag->DeleteAfter = TRUE;
  1943.                         DestUser->FileTag->Add ();
  1944.                      } while ((RxFile = (CHAR *)Received.Next ()) != NULL);
  1945.  
  1946.                      DestUser->Update ();
  1947.                   }
  1948.                }
  1949.             }
  1950.          }
  1951.  
  1952.          sprintf (szFile, "%s%s", Cfg->UsersHomePath, DestUser->MailBox);
  1953.          rmdir (AdjustPath (szFile));
  1954.       }
  1955.       else if (Name[0] != '\0')
  1956.          Embedded->Printf ("\n\x16\x01\016   *** Sorry, you can't upload files to this User! ***\n\006\007\006\007");
  1957.  
  1958.       delete DestUser;
  1959.    }
  1960. }
  1961.  
  1962. // ----------------------------------------------------------------------
  1963.  
  1964. TFileAreaListing::TFileAreaListing (void)
  1965. {
  1966.    Command[0] = '\0';
  1967.    Language = NULL;
  1968. }
  1969.  
  1970. VOID TFileAreaListing::Begin (VOID)
  1971. {
  1972.    USHORT i, Add;
  1973.    CHAR Temp[128];
  1974.    LISTDATA ld;
  1975.    class TFileData *FileData;
  1976.  
  1977.    i = 0;
  1978.    y = 4;
  1979.    Found = FALSE;
  1980.    List.Clear ();
  1981.    Data.Clear ();
  1982.    strupr (Command);
  1983.  
  1984.    if ((FileData = new TFileData (Cfg->SystemPath)) != NULL) {
  1985.       if (FileData->First () == TRUE)
  1986.          do {
  1987.             if (User->Level >= FileData->Level) {
  1988.                if ((FileData->AccessFlags & User->AccessFlags) == FileData->AccessFlags) {
  1989.                   if (Command[0] != '\0') {
  1990.                      Add = FALSE;
  1991.                      strcpy (Temp, FileData->Key);
  1992.                      if (strstr (strupr (Temp), Command) != NULL)
  1993.                         Add = TRUE;
  1994.                      else {
  1995.                         strcpy (Temp, FileData->Display);
  1996.                         if (strstr (strupr (Temp), Command) != NULL)
  1997.                            Add = TRUE;
  1998.                      }
  1999.                   }
  2000.  
  2001.                   if (Command[0] == '\0' || Add == TRUE) {
  2002.                      strcpy (ld.Key, FileData->Key);
  2003.                      ld.ActiveFiles = FileData->ActiveFiles;
  2004.                      strcpy (ld.Display, FileData->Display);
  2005.                      Data.Add (&ld, sizeof (LISTDATA));
  2006.                   }
  2007.                }
  2008.             }
  2009.          } while (FileData->Next () == TRUE);
  2010.  
  2011.       delete FileData;
  2012.    }
  2013.  
  2014.    if ((pld = (LISTDATA *)Data.First ()) != NULL) {
  2015.       do {
  2016.          if (!strcmp (pld->Key, Current->Key))
  2017.             Found = TRUE;
  2018.          List.Add (pld->Key, (USHORT)(strlen (pld->Key) + 1));
  2019.          i++;
  2020.          if (i >= (User->ScreenHeight - 6)) {
  2021.             if (Found == TRUE)
  2022.                break;
  2023.             List.Clear ();
  2024.             i = 0;
  2025.          }
  2026.       } while ((pld = (LISTDATA *)Data.Next ()) != NULL);
  2027.    }
  2028. }
  2029.  
  2030. USHORT TFileAreaListing::DrawScreen (VOID)
  2031. {
  2032.    USHORT i;
  2033.  
  2034.    i = 0;
  2035.    do {
  2036.       List.Next ();
  2037.       pld = (LISTDATA *)Data.Value ();
  2038.       if (Found == TRUE && !strcmp (pld->Key, Current->Key)) {
  2039.          y = (USHORT)(i + 4);
  2040.          Found = FALSE;
  2041.       }
  2042.       PrintLine ();
  2043.       i++;
  2044.    } while (Data.Next () != NULL && i < (User->ScreenHeight - 6));
  2045.  
  2046.    return (i);
  2047. }
  2048.  
  2049. VOID TFileAreaListing::PrintTitles (VOID)
  2050. {
  2051.    Embedded->Printf ("\x0C");
  2052.    Embedded->Printf (Language->Text (LNG_FILEAREAHEADER));
  2053.  
  2054.    Embedded->PrintfAt ((USHORT)(User->ScreenHeight - 2), 1, Language->Text (LNG_FILEAREASEPARATOR));
  2055.  
  2056.    Embedded->Printf (Language->Text (LNG_FILEAREADESCRIPTION1));
  2057.    Embedded->Printf (Language->Text (LNG_FILEAREADESCRIPTION2));
  2058.  
  2059.    Embedded->PrintfAt (4, 1, "");
  2060. }
  2061.  
  2062. VOID TFileAreaListing::PrintLine (VOID)
  2063. {
  2064.    Embedded->Printf (Language->Text (LNG_FILEAREALIST), pld->Key, pld->ActiveFiles, pld->Display);
  2065. }
  2066.  
  2067. VOID TFileAreaListing::PrintCursor (USHORT y)
  2068. {
  2069.    Embedded->PrintfAt (y, 1, Language->Text (LNG_FILEAREACURSOR), (PSZ)List.Value ());
  2070. }
  2071.  
  2072. VOID TFileAreaListing::RemoveCursor (USHORT y)
  2073. {
  2074.    Embedded->PrintfAt (y, 1, Language->Text (LNG_FILEAREAKEY), (PSZ)List.Value ());
  2075. }
  2076.  
  2077. VOID TFileAreaListing::Select (VOID)
  2078. {
  2079.    Current->Read ((PSZ)List.Value ());
  2080.    if (User != NULL) {
  2081.       strcpy (User->LastFileArea, Current->Key);
  2082.       User->Update ();
  2083.    }
  2084.  
  2085.    if (Current->Download[strlen (Current->Download) - 1] != '\\')
  2086.       strcat (Current->Download, "\\");
  2087.    if (Current->Upload[strlen (Current->Upload) - 1] != '\\')
  2088.       strcat (Current->Upload, "\\");
  2089.    Log->Write (":File Area: %s - %s", Current->Key, Current->Display);
  2090.  
  2091.    RetVal = End = TRUE;
  2092. }
  2093.  
  2094.  
  2095.