//->$.Fax.!Arcfax.Server.CadeUp
// Copyright (c) Tim Nicholson 1994
// From an idea by David Pilling
// Upload private mail and messages to Arcade
// Version 0.5
// note, id and password are stored in the phone book as
// parameters
//
//


int main(int mode,string & Opt1,string & Opt2)
{
 int code=1;
 string uploaderr;
 if(mode==DATA)
 {
  if(getprompt("new user):",2000))
  {
   sprints(Opt1);       // login
   sputc(13);           // CR to terminate
   if(getprompt("assword",1000))
   {
    sprints(Opt2);      // Password
    sputc(13);          // Cr to terminate
    if(getprompt("key to continue",1000))
    {
     sputc(13);        // this deals with first occurrence
     sputc(13);        // this in case of another (e.g. Today in History)
     sputc(13);        // this in case of Priv mail
     if(getprompt("Main Menu",1000))
     {
      sprints("PUU");   // Public message area, and upload mail
      if(getprompt("ancel:",1000))
      {
       sputc('Z');     // Zmodem upload
       if(getprompt("load now",1000))
       {
        code=ftpsendfiles();
        if(getprompt("Processing upload",1000))
        {
         sreadtext(uploaderr,1000,100);  // rest of line
         sreadtext(uploaderr,1000,100);  // error message if exists
         if(uploaderr/"complete">=0)
         {
          logreason("Mail OK"); // No error mess found
         }
         else
         {
          logreason("Mail Error"); // log an error
          writetolog(mids(uploaderr+"\n",6,100)); // put error in log file
         }
         if(getprompt("key to continue",1000))
         {
          sputc(13);
          sprints("MG"); // Goto main then logoff menu
          sputc(13);     // In case of priv mail
          sprints("L");  // Logoff
          if(code)
          {
           logreason("Z Failed"); // the transfer failed
          }
         }
        }
       }
      }
     }
    }
   }
  }
 }
 return(code);
}

