home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / ftp.vapor.com / microdot-1 / md1_src_02.lzx / netcall.c < prev    next >
C/C++ Source or Header  |  2015-03-19  |  66KB  |  3,232 lines

  1. #include "microdot.h"
  2. #include "ogre.h"
  3. #include "ogre_protos.h"
  4. #include "asyncio.h"
  5.  
  6. #include <devices/serial.h>
  7. #include <dos/dostags.h>
  8. #include <libraries/owndevunit.h>
  9. #include <dos.h>
  10.  
  11. #include <constructor.h>
  12.  
  13. struct Library *OwnDevUnitBase;
  14.  
  15. CONSTRUCTOR_P(openodu,25000)
  16. {
  17.     OwnDevUnitBase = OldOpenLibrary( ODU_NAME );
  18.     return( 0 );
  19. }
  20.  
  21. DESTRUCTOR_P(closeodu,25000)
  22. {
  23.     if( OwnDevUnitBase )
  24.         CloseLibrary( OwnDevUnitBase );
  25. }
  26.  
  27. #define BeginIO SendIO
  28.  
  29. static __aligned struct MsgPort *iorp,*iowp;
  30. static struct MsgPort *tport;
  31. __aligned struct IOExtSer ior;
  32. __aligned struct IOExtSer iow;
  33. static __aligned USHORT seropen,timeropen;
  34.  
  35. static struct timerequest tr;
  36.  
  37. static struct MsgPort *apport;
  38. static struct AppIcon *appicon;
  39. static struct DiskObject *appicondobj;
  40. static ULONG apsig;
  41.  
  42. int linespeed;
  43.  
  44. static BPTR pdir;
  45.  
  46. static struct TextAttr gadta;
  47. static char binfotxt1[ 256 ], binfotxt2[ 256 ];
  48. static struct IntuiText binfoitext2 = { 0, 0, JAM2, 4,0, &gadta, binfotxt2, NULL };
  49. static struct IntuiText binfoitext1 = { 0, 0, JAM2, 4,2, &gadta, binfotxt1, &binfoitext2 };
  50. static struct Gadget bottombordgad;
  51. static struct Image bottomclearimage = { 2,1, 0,0, 0, NULL, 0, 0, NULL };
  52. static struct Gadget bottominfogadget = { &bottombordgad, 0, 0, 0, 0,
  53.  GFLG_GADGHNONE | GFLG_RELBOTTOM | GFLG_RELWIDTH | GFLG_GADGIMAGE,
  54.  GACT_BOTTOMBORDER,
  55.  GTYP_BOOLGADGET | GTYP_GZZGADGET,
  56.  &bottomclearimage, NULL, &binfoitext1, 0, NULL, 760
  57. };
  58.  
  59. static long oldprio;
  60.  
  61. int nowdoicons;
  62.  
  63. extern ULONG tvsig;
  64.  
  65. extern int netcall_resume;
  66.  
  67. static void conprintf(char *s,...);
  68.  
  69. static void setpri(int p)
  70. {
  71.     oldprio = SetTaskPri( FindTask(NULL), p );
  72. }
  73.  
  74. static void resetpri(void)
  75. {
  76.     SetTaskPri( FindTask(NULL), oldprio );
  77. }
  78.  
  79. static void __stdargs treport( int l, char c, char *txt, ... )
  80. {
  81.     char *p = ( l ) ? binfotxt2 : binfotxt1;
  82.     struct IntuiText *it = ( l ) ? &binfoitext2 : &binfoitext1;
  83.     struct TextFont *tf;
  84.     int maxch;
  85.     int oldlen;
  86.  
  87.     if( !wbwindow )
  88.     {
  89.         ULONG *p = ( ULONG * ) ( ( ( ULONG ) ( &txt ) ) + 4 );
  90.         preport( l, c, txt, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7] );
  91.         return;
  92.     }
  93.  
  94.     //oldlen = IntuiTextLength( it );
  95.     tf = OpenFont( &gadta );
  96.     dofmt(p,txt,(void*)(((long)&txt)+4));
  97.     maxch = ogreTextFit( tf, p, bottomclearimage.Width - 4 );
  98.     p[ maxch ]á= 0;
  99.     CloseFont( tf );
  100.     it->FrontPen = c;
  101.  
  102.     /*if( IntuiTextLength( it ) < oldlen )
  103.     {*/
  104.         RefreshGList( &bottominfogadget, w, NULL, 1 );
  105. /*    }
  106.     else
  107.     {
  108.         PrintIText( w->BorderRPort, it, bottominfogadget.LeftEdge, bottominfogadget.TopEdge );
  109.     }*/
  110. }
  111.  
  112. void delpathcontents(char *path,char *ignore1,char *ignore2)
  113. {
  114.     char *buffer,*p;
  115.     int size;
  116.     long i;
  117.  
  118.     if( pushdir( path ) )
  119.         return;
  120.  
  121.     buffer=AllocMem(16384,MEMF_CLEAR);
  122.     if( !buffer )
  123.     {
  124.         outofmem();
  125.         exit( 0 );
  126.     }
  127.  
  128.     size = makefilelist( "", "#?", buffer, 16384 );
  129.     p=buffer;
  130.  
  131.     while( size-- )
  132.     {
  133.         i=0;
  134.         if(ignore1 && !stricmp(ignore1,p)) i=1;
  135.         if(ignore2 && !stricmp(ignore2,p)) i=1;
  136.         if(!i)
  137.             DeleteFile(p);
  138.         p=&p[strlen(p)+1];
  139.  
  140.     }
  141.     FreeMem(buffer,16384);
  142.  
  143.     popdir();
  144. }
  145.  
  146. struct mdtprefs mdtprefs;
  147. void selectmdtprefs( char *name )
  148. {
  149.     memset( &mdtprefs, 0, sizeof( mdtprefs ) );
  150.     if( !name || !name[á0 ] )
  151.     {
  152.         strcpy( mdtprefs.name, "½Pointserver╗" );
  153.         strcpy( mdtprefs.device, prefs.modemdevice );
  154.         strcpy( mdtprefs.modemdial, prefs.modemdial );
  155.         strcpy( mdtprefs.modeminit, prefs.modeminit );
  156.         strcpy( mdtprefs.modemhangup, prefs.modemhangup );
  157.         mdtprefs.unit = prefs.modemunit;
  158.         mdtprefs.baud = prefs.modembaud;
  159.         mdtprefs.flags = prefs.modemflags;
  160.         if( prefs.flags & MDF_TERM_IBM )
  161.             mdtprefs.flags |= MDTF_IBM;
  162.         if( prefs.modem_dropdtr )
  163.             mdtprefs.flags |= MDTF_DROPDTR;
  164.         mdtprefs.whichcolors = prefs.term_whichcolors;
  165.     }
  166.     else
  167.     {
  168.         struct AsyncFile *f;
  169.  
  170.         pushhomedir();
  171.         f = OpenAsync( "microdot.mdtprefs", MODE_READ, sizeof( struct mdtprefs ) * 16 );
  172.         popdir();
  173.  
  174.         if( f )
  175.         {
  176.             for(;;)
  177.             {
  178.                 if( ReadAsync( f, &mdtprefs, sizeof( mdtprefs ) ) != sizeof( mdtprefs ) )
  179.                 {
  180.                     memset( &mdtprefs, 0, sizeof( mdtprefs ) );
  181.                     break;
  182.                 }
  183.                 if( !stricmp( mdtprefs.name, name ) )
  184.                     break;
  185.             }
  186.             CloseAsync( f );
  187.         }
  188.     }
  189. }
  190.  
  191. void savemdtprefs( void )
  192. {
  193.     struct mdtprefs n;
  194.  
  195.     if( strcmp( mdtprefs.name, "½Pointserver╗" ) )
  196.     {
  197.         BPTR f;
  198.  
  199.         pushhomedir();
  200.         f = Open( "microdot.mdtprefs", MODE_OLDFILE );
  201.         popdir();
  202.  
  203.         if( f )
  204.         {
  205.             for(;;)
  206.             {
  207.                 if( Read( f, &n, sizeof( mdtprefs ) ) != sizeof( mdtprefs ) )
  208.                 {
  209.                     break;
  210.                 }
  211.                 if( !stricmp( n.name, mdtprefs.name ) )
  212.                 {
  213.                     Seek( f, -sizeof( mdtprefs ), OFFSET_CURRENT );
  214.                     Write( f, &mdtprefs, sizeof( mdtprefs ) );
  215.                     break;
  216.                 }
  217.             }
  218.             Close( f );
  219.         }
  220.     }
  221.     else
  222.     {
  223.         if( mdtprefs.flags & MDTF_IBM )
  224.             prefs.flags |= MDF_TERM_IBM;
  225.         else
  226.             prefs.flags &= ~MDF_TERM_IBM;
  227.         prefs.term_whichcolors = mdtprefs.whichcolors;
  228.     }
  229. }
  230.  
  231. static int oduflag = 0;
  232.  
  233. static int initser( int termmode )
  234. {
  235.     long serflags = SERF_XDISABLED;
  236.     int rc;
  237.  
  238.     oduflag = 0;
  239.  
  240.     if( OwnDevUnitBase )
  241.     {
  242.         char *oduerr;
  243.  
  244.         for(;;)
  245.         {
  246.             int rc;
  247.             oduerr = AttemptDevUnit( mdtprefs.device, mdtprefs.unit, "MicroDot", SIGBREAKB_CTRL_E );
  248.  
  249.             if( !oduerr )
  250.             {
  251.                 oduflag = TRUE;
  252.                 break;
  253.             }
  254.  
  255.             rc = askreq( "OwnDevUnit-Meldung:\nDevice %s, Unit %ld\nkann nicht belegt werden.\n%s: %s", 
  256.                 "Wiederholen|Ignorieren|Abbruch",
  257.                 mdtprefs.device, mdtprefs.unit,
  258.                 *oduerr == 7 ? "Fehler" : "Aktueller Besitzer",
  259.                 *oduerr == 7 ? oduerr + 1 : oduerr
  260.             );
  261.     
  262.             if( !rc )
  263.             {
  264.                 return( -1 );
  265.             }
  266.             else if( rc == 2 )
  267.                 break;
  268.         }
  269.     }
  270.  
  271.     seropen=0;
  272.     timeropen=0;
  273.  
  274.     tr.tr_node.io_Message.mn_ReplyPort=tport=CreatePort(0,0);
  275.     OpenDevice("timer.device",UNIT_VBLANK,&tr,0);
  276.     timeropen=1;
  277.  
  278.     if( mdtprefs.flags & 1 )
  279.         serflags |= SERF_7WIRE;
  280.     if( ( mdtprefs.flags & 2 ) && ( ! ( mdtprefs.flags & MDTF_7E1 ) ) )
  281.         serflags |= SERF_RAD_BOOGIE;
  282.     if( mdtprefs.flags & 4 )
  283.         serflags |= SERF_SHARED;
  284.  
  285.     ior.IOSer.io_Message.mn_ReplyPort=iorp=CreatePort(0,0);
  286.     ior.io_SerFlags=serflags;
  287.  
  288. reopen:
  289.     if((rc=OpenDevice(mdtprefs.device,mdtprefs.unit,&ior,0)))
  290.     {
  291.         if( termmode && prefs.term_currentmdt[á0 ]á)
  292.             rc = askreq("Fehler Nr. %ld beim ╓ffnen von\n%s, Unit %ld","Wiederholen|Mit Point-Konfiguration|Abbruch",rc,mdtprefs.device,mdtprefs.unit);
  293.         else
  294.             rc = askreq("Fehler Nr. %ld beim ╓ffnen von\n%s, Unit %ld","Wiederholen|Abbruch",rc,mdtprefs.device,mdtprefs.unit);
  295.         if( rc == 1 )
  296.             goto reopen;
  297.  
  298.         CloseDevice( &tr );
  299.         timeropen = FALSE;
  300.         DeletePort( tport );
  301.         DeletePort(iorp);
  302.  
  303.         if( oduflag )
  304.         {
  305.             FreeDevUnit( mdtprefs.device, mdtprefs.unit );
  306.             oduflag = FALSE;
  307.         }
  308.  
  309.         return( ( rc == 2 ) ? -2 : -1 );
  310.     }
  311.     seropen=1;
  312.     ior.IOSer.io_Command=SDCMD_SETPARAMS;
  313.     ior.io_Baud=mdtprefs.baud;
  314.     ior.io_StopBits=1;
  315.     ior.io_RBufLen=8192;
  316.  
  317.     if( mdtprefs.flags & MDTF_7E1 )
  318.     {
  319.         ior.io_ReadLen = ior.io_WriteLen = 7;
  320.         serflags |= SERF_PARTY_ON;
  321.     }
  322.     else
  323.     {
  324.         ior.io_ReadLen=ior.io_WriteLen=8;
  325.     }
  326.  
  327.     ior.io_SerFlags=serflags;
  328.  
  329.     DoIO(&ior);
  330.     iow=ior;
  331.     iow.IOSer.io_Message.mn_ReplyPort=iowp=CreatePort(0,0);
  332.  
  333.     return(0);
  334. }
  335.  
  336. static void exitser(void)
  337. {
  338.     if( oduflag )
  339.     {
  340.         FreeDevUnit( mdtprefs.device, mdtprefs.unit );
  341.         oduflag = FALSE;
  342.     }
  343.  
  344.     if(seropen) CloseDevice(&ior);
  345.     if(timeropen) CloseDevice(&tr);
  346.     if(tport) DeletePort(tport);
  347.     if(iorp) DeletePort(iorp);
  348.     if(iowp) DeletePort(iowp);
  349.     seropen=0; timeropen=0;
  350.     iorp=0;
  351.     iowp=0;
  352. }
  353.  
  354. static void sendat( char *cmd )
  355. {
  356.     char ch;
  357.  
  358.     while( *cmd )
  359.     {
  360.         ch = *cmd;
  361.         if( ( *cmd == '^' ) || ( *cmd == '~' ) )
  362.         {
  363.             cmd++;
  364.             Delay(25);
  365.             continue;
  366.         }
  367.         if( *cmd == '|' )
  368.             ch=13;
  369.         cmd++;
  370.         iow.IOSer.io_Length  = 1;
  371.         iow.IOSer.io_Command = CMD_WRITE;
  372.         iow.IOSer.io_Data    = &ch;
  373.         DoIO(&iow);
  374.     }
  375. }
  376.  
  377. static void serputs( char *string )
  378. {
  379.     iow.IOSer.io_Length = strlen( string );
  380.     iow.IOSer.io_Command = CMD_WRITE;
  381.     iow.IOSer.io_Data = string;
  382.     DoIO( &iow );
  383.  
  384.     iow.IOSer.io_Command = CMD_WRITE;
  385.     if( prefs.flags2 & MDF2_NETCALLCRLF )
  386.     {
  387.         iow.IOSer.io_Length = 2;
  388.         iow.IOSer.io_Data = "\r\n";
  389.     }
  390.     else
  391.     {
  392.         iow.IOSer.io_Length = 1;
  393.         iow.IOSer.io_Data = "\r";
  394.     }
  395.     DoIO( &iow );
  396.  
  397. }
  398.  
  399. static void serialclear( void )
  400. {
  401.     iow.IOSer.io_Command = CMD_CLEAR;
  402.     DoIO( &iow );
  403. }
  404.  
  405. struct IOStdReq cr,cw;
  406. static struct MsgPort *crp,*cwp;
  407. static long conopen;
  408.  
  409. static struct ExtNewWindow tnw={0,0,0,0, (UBYTE)-1,(UBYTE)-1, MENUPICK|IDCMP_MENUHELP|IDCMP_REFRESHWINDOW|IDCMP_NEWSIZE|IDCMP_CLOSEWINDOW, ACTIVATE|BORDERLESS|WFLG_NW_EXTENDED|WFLG_BACKDROP, 0,0,0,0,0, 0,0,0,0, CUSTOMSCREEN,menuhelpti};
  410. struct Window *twindow;
  411. extern struct Menu *termmenustrip,*netcallmenustrip,*answermenustrip;
  412. extern struct Gadget scrollgad;
  413. extern struct TextFont *listfont;
  414. static ULONG oldidcmpflags;
  415.  
  416. static void conresize( void )
  417. {
  418.     int d = ( w->BorderLeft + w->BorderRight );
  419.  
  420.     bottombordgad.GadgetRender = makebevelborder( w->Width - d - 6, bottominfogadget.Height, TRUE );
  421.     bottomclearimage.Width     = w->Width - d - 10;
  422.  
  423.     treport( 0, binfoitext1.FrontPen, binfotxt1 );
  424.     treport( 1, binfoitext2.FrontPen, binfotxt2 );
  425.  
  426.     RefreshWindowFrame( w );
  427. }
  428.  
  429. extern int gadgetlistcount;
  430.  
  431. int initconsole( void )
  432. {
  433.     conopen        = 0;
  434.  
  435.     if( wbwindow )
  436.     {
  437.         int d = ( w->BorderLeft + w->BorderRight );
  438.  
  439.         removescrollgads();
  440.         RemoveGList( w, &scrollgad, gadgetlistcount );
  441.  
  442.         gadta.ta_Name = prefs.gadfontname;
  443.         gadta.ta_YSize = prefs.gadfontheight;
  444.  
  445.         twindow = w;
  446.  
  447.         oldidcmpflags = w->IDCMPFlags;
  448.         ModifyIDCMP( w, tnw.IDCMPFlags );
  449.  
  450.         bottominfogadget.Width = - ( d + 6 );
  451.         bottominfogadget.Height = ( prefs.gadfontheight + 2 ) * 2;
  452.         bottominfogadget.TopEdge = -bottominfogadget.Height - 2;
  453.         bottominfogadget.LeftEdge = w->BorderLeft + 2;
  454.  
  455.         bottombordgad = bottominfogadget;
  456.         bottombordgad.Flags &= ~ GFLG_GADGIMAGE;
  457.         bottombordgad.GadgetRender = makebevelborder( w->Width - d - 6, bottominfogadget.Height, TRUE );
  458.         bottombordgad.GadgetText = NULL;
  459.         bottombordgad.NextGadget = NULL;
  460.  
  461.         bottomclearimage.Width  = w->Width - d - 10;
  462.         bottomclearimage.Height = bottominfogadget.Height - 2;
  463.         bottomclearimage.Depth  = scr->RastPort.BitMap->Depth;
  464.         binfoitext2.TopEdge     = 3 + prefs.gadfontheight;
  465.  
  466.         AddGList( w, &bottominfogadget, 0, 2, NULL );
  467.         RefreshWindowFrame( w );
  468.     }
  469.     else
  470.     {
  471.         tnw.Screen    = scr;
  472.         tnw.Height    = scr->Height-topoffs;
  473.         tnw.TopEdge = topoffs;
  474.         tnw.Width    = scr->Width;
  475.         if( isv37 )
  476.             tnw.Flags |= SIMPLE_REFRESH;
  477.         twindow = OpenWindow( &tnw );
  478.         if( !twindow )
  479.         {
  480.             displaybeep();
  481.             return(-1);
  482.         }
  483.         SetFont( twindow->RPort, listfont );
  484.     }
  485.  
  486.     cr.io_Message.mn_ReplyPort = crp = CreatePort( 0, 0 );
  487.     cr.io_Data     = twindow;
  488.     cr.io_Length = sizeof(struct Window);
  489.  
  490.     if( isv39 )
  491.         SetMaxPen( twindow->RPort, 255 );
  492.     
  493.     if( OpenDevice( "console.device", ( isv37 ) ? 3 : 0, &cr, 0 ) )
  494.     {
  495.         displaybeep();
  496.         if( !wbwindow )
  497.         {
  498.             DeletePort( crp );
  499.             CloseWindow( twindow );
  500.         }
  501.         return(-1);
  502.     }
  503.     conopen = 1;
  504.  
  505.     cw = cr;
  506.     cw.io_Message.mn_ReplyPort = cwp = CreatePort( 0, 0 );    
  507.  
  508.     return(0);
  509. }
  510.  
  511. static void exitconsole(void)
  512. {
  513.     if( conopen )
  514.         CloseDevice( &cr );
  515.     if( crp )
  516.         DeletePort( crp );
  517.     if( cwp )
  518.         DeletePort( cwp );
  519.  
  520.     conopen = 0;
  521.     crp = 0;
  522.     cwp = 0;
  523.  
  524.     if( twindow )
  525.     {
  526.         if( wbwindow )
  527.         {
  528.             RemoveGList( w, &bottominfogadget, 2 );
  529.             ClearMenuStrip( twindow );
  530.             setmenuescflag();
  531.             ModifyIDCMP( w, oldidcmpflags );
  532.             SetRast( w->RPort, 0 );
  533.             AddGList( w, &scrollgad, -1, gadgetlistcount, NULL );
  534.             RefreshGList( &scrollgad, w, NULL, 4 );
  535.             //makescrollergads();
  536.         }
  537.         else
  538.         {
  539.             ClearMenuStrip( twindow );
  540.             CloseWindow( twindow );
  541.         }
  542.         twindow=0;
  543.     }
  544.     calcmaxpen();
  545. }
  546.  
  547. int testcarrier(void)
  548. {
  549.     if( mdtprefs.flags & 8 )
  550.         return( 1 );
  551.  
  552.     iow.IOSer.io_Command=SDCMD_QUERY;
  553.     DoIO(&iow);
  554.     return(!(iow.io_Status&(1<<5)));
  555. }
  556.  
  557. struct uploadnode {
  558.     struct MinNode n;
  559.     char name[ 256 ];
  560. };
  561.  
  562. static struct MinList uploadlist;
  563. static APTR uploadlistpool;
  564.  
  565. static void inituploadlist( void )
  566. {
  567.     uploadlistpool = LibCreatePool(    MEMF_CLEAR, 4096, 2048 );
  568.     NewList( ( struct List * ) &uploadlist );
  569. }
  570.  
  571. static void exituploadlist( void )
  572. {
  573.     if( uploadlistpool )
  574.         LibDeletePool( uploadlistpool );
  575. }
  576.  
  577. #define ULID_LV 1
  578. #define ULID_ADD 2
  579. #define ULID_DEL 3
  580. #define ULID_CLR 4
  581. #define ULID_OK 5
  582.  
  583. static void doaddfiles( struct ogwin *ogw )
  584. {
  585.     struct rtFileList *fl,*fp;
  586.     char name[256];
  587.  
  588.     name[ 0 ] = 0;
  589.     fl=rtFileRequest(fr[FR_TERMUPLOAD],name,"Upload-Liste: Bitte Dateien wΣhlen",
  590.         RT_Window,twindow,RT_ReqPos,REQPOS_CENTERWIN,RT_LockWindow,TRUE,
  591.         RTFI_Flags,FREQF_MULTISELECT,
  592.         TAG_DONE
  593.     );
  594.  
  595.     if(fl)
  596.     {
  597.         fp=fl;
  598.         while( fp )
  599.         {
  600.             strcpy( name, fr[áFR_TERMUPLOAD ]->Dir );
  601.             addpart( name, fp->Name );
  602.             ogreLVAddEntry( ogw, ULID_LV, name, 2, 0 );
  603.             fp=fp->Next;
  604.         }
  605.         rtFreeFileList( fl );
  606.     }
  607.  
  608. }
  609.  
  610.  
  611. static void makeuploadlist( void )
  612. {
  613.     struct ogwin *ogw;
  614.     struct Window *iw;
  615.     struct IntuiMessage *im;
  616.     int    Done = FALSE;
  617.     struct uploadnode *uln;
  618.     int c;
  619.     struct ogrevn *vn;
  620.     int active = -1;
  621.     struct AppWindow *aw = NULL;
  622.     ULONG sig, sigw;
  623.  
  624.     ogw = ogreInitWindow( scr, 0, 0, "Upload-Liste" );
  625.  
  626.     ogreAddGroup( ogw, 0, OGFRAME_NONE, NULL );
  627.     ogreAddList( ogw, 0, 0xff, NULL, ULID_LV, 60, 14, 0, NULL );
  628.     ogreLVInit( ogw, ULID_LV );
  629.  
  630.     uln = ( struct uploadnode * ) uploadlist.mlh_Head;
  631.     while( uln->n.mln_Succ )
  632.     {
  633.         ogreLVAddEntry( ogw, ULID_LV, uln->name, 2, NULL );
  634.         uln = ( struct uploadnode * ) uln->n.mln_Succ;
  635.     }
  636.  
  637.     ogreAddButton( ogw, 1 | OGB_ONENTER, 'o', "_Ok", ULID_OK );
  638.     ogreAddHelp( ogw, 1 );
  639.     ogreAddButton( ogw, 1, 'h', "_Hinzufⁿgen", ULID_ADD );
  640.     ogreAddButton( ogw, 1, 'l', "_L÷schen", ULID_DEL );
  641.     ogreAddButton( ogw, 1, 'a', "_Alle l÷schen", ULID_CLR );
  642.  
  643.     iw = ogreOpenWindow( ogw );
  644.     if( !iw )
  645.         return;
  646.  
  647.     sigw = 1L << iw->UserPort->mp_SigBit;
  648.  
  649.     if( appicon )
  650.         aw = AddAppWindow( 42, NULL, iw, apport, TAG_DONE );
  651.  
  652.     while( !Done )
  653.     {
  654.         ogreEnable( ogw, active != -1, ULID_DEL, 0 );
  655.  
  656.         sig = Wait( sigw | apsig );
  657.  
  658.         if( sig & apsig )
  659.         {
  660.             struct AppMessage *am;
  661.             struct uploadnode *uln;
  662.             struct WBArg *wba;
  663.  
  664.             while( ( am = ( struct AppMessage * ) GetMsg( apport ) ) )
  665.             {
  666.                 if( !am->am_NumArgs )
  667.                 {
  668.                     ScreenToFront( scr );
  669.                 }
  670.                 else
  671.                 {
  672.                     wba = am->am_ArgList;
  673.                     while( am->am_NumArgs-- )
  674.                     {
  675.                         if( wba->wa_Name[á0 ]á)
  676.                         {
  677.                             char dirname[á256 ];
  678.  
  679.                             NameFromLock( wba->wa_Lock, dirname, 256 );
  680.                             AddPart( dirname, wba->wa_Name, 256 );
  681.                             ogreLVAddEntry( ogw, ULID_LV, dirname, 2, NULL );
  682.                         }
  683.                         wba++;
  684.                     }
  685.                 }
  686.                 ReplyMsg( am );
  687.             }
  688.             ogreLVRefresh( ogw, ULID_LV );
  689.         }
  690.  
  691.         while( im = ogreIM( ogw ) )
  692.         {
  693.             if( im->Class == IDCMP_GADGETHELP)
  694.                 showguidenum( "term_uploadlist_gads", im->Code );
  695.             else if( im->Class == IDCMP_GADGETUP )
  696.             {
  697.                 switch( im->Code )
  698.                 {
  699.                     case ULID_OK:
  700.                         Done = 1;
  701.                         break;
  702.  
  703.                     case ULID_LV:
  704.                         active = ogreValue( ogw, ULID_LV );
  705.                         break;
  706.  
  707.                     case ULID_ADD:
  708.                         doaddfiles( ogw );
  709.                         ogreLVRefresh( ogw, ULID_LV );
  710.                         break;
  711.  
  712.                     case ULID_DEL:
  713.                         if( active >= 0 )
  714.                         {
  715.                             ogreLVRemEntry( ogw, ULID_LV, active );
  716.                             ogreLVRefresh( ogw, ULID_LV );
  717.                         }
  718.                         active = -1;
  719.                         break;
  720.  
  721.                     case ULID_CLR:
  722.                         ogreLVInit( ogw, ULID_LV );
  723.                         ogreLVRefresh( ogw, ULID_LV );
  724.                         break;
  725.                 }
  726.             }
  727.             ogreIMReply( ogw, im );
  728.         }
  729.     }
  730.  
  731.     exituploadlist();
  732.     inituploadlist();
  733.  
  734.     for( c = 0; ; c++ )
  735.     {
  736.         vn = ogreLVGetEntry( ogw, ULID_LV, c );
  737.         if( !vn )
  738.             break;
  739.         uln = LibAllocPooled( uploadlistpool, sizeof( *uln ) );
  740.         strcpy( uln->name, vn->txt );
  741.         AddTail( ( struct List * ) &uploadlist, ( struct uploadnode * ) uln );
  742.     }
  743.  
  744.     if( aw )
  745.         RemoveAppWindow( aw );
  746.  
  747.     ogreExitWindow( ogw );
  748. }
  749.  
  750.  
  751. static void douploadlist(void)
  752. {
  753.     char **filelist;
  754.     long count;
  755.     int c;
  756.     void *winlock;
  757.     struct uploadnode *uln;
  758.  
  759.     if( GetNumEntries( &uploadlist ) )
  760.     {
  761.         winlock=rtLockWindow(twindow);
  762.  
  763.         count = GetNumEntries( &uploadlist );
  764.  
  765.         filelist=myAllocVec((count+1)*4,MEMF_CLEAR);
  766.  
  767.         for(c=0; c<count; c++)
  768.         {
  769.             uln = ( struct uploadnode * ) RemHead( &uploadlist );
  770.             filelist[ c ] = uln->name;
  771.             AddTail( &uploadlist, ( struct Node * ) uln );
  772.         }
  773.  
  774.         ior.IOSer.io_Command=CMD_CLEAR;
  775.         DoIO(&ior);        
  776.  
  777.         setpri(5);
  778.         setzmodemmode( prefs.flags2 & MDF2_TERM_ZM8K );
  779.         c = xpr_send(&ior,&iow,-1,filelist);
  780.         resetpri();
  781.  
  782.         myFreeVec(filelist);
  783.  
  784.         /*ior.IOSer.io_Command=CMD_CLEAR;
  785.         DoIO(&ior);*/
  786.  
  787.         rtUnlockWindow(twindow,winlock);
  788.  
  789.         conprintf( "\rDateiⁿbertragung/Senden %s.\n", c ? "erfolgreich" : "abgebrochen" );
  790.  
  791.         if( c )
  792.         {
  793.             exituploadlist();
  794.             inituploadlist();
  795.         }
  796.  
  797.     }
  798.     else
  799.         displaybeep();
  800. }
  801.  
  802.  
  803. static void doupload(void)
  804. {
  805.     struct rtFileList *fl,*fp;
  806.     char **filelist;
  807.     char name[108];
  808.     long count;
  809.     int c;
  810.     void *winlock;
  811.  
  812.     name[0]=0;
  813.     fl=rtFileRequest(fr[FR_TERMUPLOAD],name,"Z-Modem-Upload: Bitte Dateien wΣhlen",
  814.         RT_Window,twindow,RT_ReqPos,REQPOS_CENTERWIN,RT_LockWindow,TRUE,
  815.         RTFI_Flags,FREQF_MULTISELECT,
  816.         TAG_DONE
  817.     );
  818.  
  819.     if(fl)
  820.     {
  821.         winlock=rtLockWindow(twindow);
  822.         pushdir(fr[FR_TERMUPLOAD]->Dir);
  823.         fp=fl;
  824.         for(count=0; fp; count++, fp=fp->Next);
  825.  
  826.         filelist=myAllocVec((count+1)*4,MEMF_CLEAR);
  827.         fp=fl;
  828.         for(c=0; c<count; c++)
  829.         {
  830.             filelist[c]=fp->Name;
  831.             fp=fp->Next;
  832.         }
  833.  
  834.         ior.IOSer.io_Command=CMD_CLEAR;
  835.         DoIO(&ior);        
  836.  
  837.         setpri(5);
  838.         setzmodemmode( prefs.flags2 & MDF2_TERM_ZM8K );
  839.         c = xpr_send(&ior,&iow,-1,filelist);
  840.         resetpri();
  841.  
  842.         myFreeVec(filelist);
  843.  
  844.         rtFreeFileList(fl);
  845.  
  846.         /*ior.IOSer.io_Command=CMD_CLEAR;
  847.         DoIO(&ior);*/
  848.  
  849.         popdir();
  850.  
  851.         rtUnlockWindow(twindow,winlock);
  852.  
  853.         conprintf( "\rDateiⁿbertragung/Senden %s.\n", c ? "erfolgreich" : "abgebrochen" );
  854.  
  855.     }
  856. }
  857.  
  858.  
  859. static void dodownload(void)
  860. {
  861.     void *winlock;
  862.     char fileb[256];
  863.     int c;
  864.  
  865.     pushdir( prefs.term_downloadpath );
  866.  
  867.     nowdoicons = TRUE;
  868.     winlock=rtLockWindow(twindow);
  869.     /*ior.IOSer.io_Command = CMD_CLEAR;
  870.     DoIO(&ior);*/
  871.     fileb[0]=0;
  872.     setpri(5);
  873.     c = xpr_receive(&ior,&iow,-1);
  874.     resetpri();
  875.     rtUnlockWindow(twindow,winlock);
  876.     /*ior.IOSer.io_Command=CMD_CLEAR;
  877.     DoIO(&ior);*/
  878.     nowdoicons = FALSE;
  879.  
  880.     popdir();
  881.  
  882.     conprintf( "\rDateiⁿbertragung/Empfang %s.\n", c ? "erfolgreich" : "abgebrochen" );
  883. }
  884.  
  885. static void qtimer(void)
  886. {
  887.     tr.tr_time.tv_micro=0;
  888.     tr.tr_time.tv_secs=1;
  889.     tr.tr_node.io_Command=TR_ADDREQUEST;
  890.     SendIO(&tr);
  891. }
  892.  
  893. static void conprint(char *s)
  894. {
  895.     cw.io_Data=s;
  896.     cw.io_Length=-1;
  897.     cw.io_Command=CMD_WRITE;
  898.     DoIO(&cw);
  899. }
  900.  
  901. static void conprintf(char *s,...)
  902. {
  903.     char dat[128];
  904.  
  905.     dofmt(dat,s,(void*)(((long)&s)+4));
  906.     conprint("\x1b[3;32m");
  907.     conprint(dat);
  908.     conprint("\x1b[0m");
  909.  
  910. }
  911.  
  912. static    APTR oldrdata;
  913. static    LONG oldrlen;
  914. static void serclose_temp( void )
  915. {
  916.     oldrdata = ior.IOSer.io_Data;
  917.     oldrlen = ior.IOSer.io_Length;
  918.  
  919.     /* DTR aus; dazu Device kurz schlie▀en */
  920.     AbortIO( &ior );
  921.     WaitIO( &ior );
  922.  
  923.     CloseDevice( &ior );
  924. }
  925.  
  926. static void seropen_temp( int queue )
  927. {
  928.     if( OpenDevice( mdtprefs.device, mdtprefs.unit, &ior, 0 ) )
  929.     {
  930.         displaybeep();
  931.         return;
  932.     }
  933.     iow.IOSer.io_Device = ior.IOSer.io_Device;
  934.     iow.IOSer.io_Unit = ior.IOSer.io_Unit;
  935.  
  936.     ior = iow;
  937.     ior.IOSer.io_Message.mn_ReplyPort = iorp;    
  938.     ior.IOSer.io_Command = SDCMD_SETPARAMS;
  939.     DoIO( &ior );
  940.     ior.IOSer.io_Data = oldrdata;
  941.     ior.IOSer.io_Length = oldrlen;
  942.     ior.IOSer.io_Command = CMD_READ;
  943.     if( queue )
  944.         BeginIO( &ior );
  945. }
  946.  
  947. static void hangup( void )
  948. {
  949.     if( mdtprefs.flags & MDTF_DROPDTR )
  950.     {
  951.         serclose_temp();
  952.         Delay( 42 );
  953.         seropen_temp( TRUE );
  954.         Delay( 10 );
  955.     }
  956.     else
  957.         Delay( 30 );
  958.     sendat( mdtprefs.modemhangup );
  959. }
  960.  
  961. static void cursoron( void )
  962. {
  963.     conprintf( "\x1b[ p" );
  964. }
  965. static void cursoroff( void )
  966. {
  967.     conprintf( "\x1b[0 p" );
  968. }
  969.  
  970.  
  971. static char *getphonefrom( char *phone, int n )
  972. {
  973.     int pc=0;
  974.     char *p = phone;
  975.     static char temp[80];
  976.     int offs[ 32 ];
  977.  
  978.     do
  979.     {
  980.         p = stpblk( p );
  981.         if( !*p )
  982.             break;
  983.         offs[ápc++ ]á= p - phone;
  984.     }áwhile( ( p = strchr( p, ' ' ) ) );
  985.  
  986.     if( !pc )
  987.         return( "" );
  988.  
  989.     n = n % pc;
  990.     strcpy( temp, &phone[áoffs[án ]á] );
  991.     p = strchr( temp, ' ' );
  992.     if( p )
  993.         *p=0;
  994.     return( temp );
  995. }
  996.  
  997. static char *getphone( int n )
  998. {
  999.     return( getphonefrom( prefs.phone, n ) );
  1000. }
  1001.  
  1002.  
  1003. #define RBSIZE 16
  1004. static char roundbuffer[RBSIZE];
  1005.  
  1006. static void putrb(UBYTE ch)
  1007. {
  1008.     memcpy(&roundbuffer[0],&roundbuffer[1],RBSIZE-1);
  1009.     roundbuffer[RBSIZE-1]=ch;
  1010. }
  1011.  
  1012. static void putrb7(UBYTE ch)
  1013. {
  1014.     /* TAB, SPACE, BELL */
  1015.     if( ( ch == 9 ) || ( ch == 32 ) || ( ch == 7 ) || ( ch == 10 ) ||( ch == 13 ) )
  1016.         return;
  1017.  
  1018.     memcpy(&roundbuffer[0],&roundbuffer[1],RBSIZE-1);
  1019.     roundbuffer[RBSIZE-1]=ch;
  1020. }
  1021.  
  1022. static int testrb(char *s)
  1023. {
  1024.     long sl=strlen(s);
  1025.     long x=RBSIZE-sl;
  1026.  
  1027.     return(!strnicmp(s,&roundbuffer[x],sl));
  1028. }
  1029.  
  1030. static int testrbzdl(void)
  1031. {
  1032.     return(!strncmp(ZMODEMAUTODOWNLOAD,&roundbuffer[RBSIZE-strlen(ZMODEMAUTODOWNLOAD)],strlen(ZMODEMAUTODOWNLOAD)));
  1033. }
  1034. static int testrbzul(void)
  1035. {
  1036.     return(!strncmp(ZMODEMAUTOUPLOAD,&roundbuffer[RBSIZE-strlen(ZMODEMAUTOUPLOAD)],strlen(ZMODEMAUTOUPLOAD)));
  1037. }
  1038.  
  1039. int checkmenustate(struct Menu *strip,USHORT menunum)
  1040. {
  1041.     struct MenuItem *mit=ItemAddress(strip,menunum);
  1042.     return(mit && mit->Flags&CHECKED);
  1043. }
  1044.  
  1045. static FILE *openlog(char *name)
  1046. {
  1047.     FILE *f=fopen(name,"a");
  1048.  
  1049.     if(!f) f=fopen(name,"w");
  1050.  
  1051.     if(!f) {
  1052.         askreq("Kann Logfile\n%s\nnicht ÷ffnen (%ld)\n%s","Abbruch",name,_OSERR, errorstring( _OSERR ) );
  1053.     }
  1054.     return(f);
  1055. }
  1056.  
  1057. static int callbymodem( char *name, char *number, char *username, char *password, char *dialprefix, int doautologin )
  1058. {
  1059.     int tries = prefs.dialretries;
  1060.     char *phone;
  1061.     long timeout;
  1062.     void *iop1, *iop2;
  1063.     long sigs, tsig, ssig, csig;
  1064.     int connect = 0;
  1065.     char conr, serr;
  1066.     ULONG phonetrycount = 0;
  1067.     int cq = FALSE, tq, sq;
  1068.     int loginmode = 0;
  1069.     int notfirst = FALSE;
  1070.  
  1071.     tsig = 1<<tr.tr_node.io_Message.mn_ReplyPort->mp_SigBit;
  1072.     ssig = 1<<ior.IOSer.io_Message.mn_ReplyPort->mp_SigBit;
  1073.     csig = 1<<cr.io_Message.mn_ReplyPort->mp_SigBit;
  1074.  
  1075.     iop1 = cr.io_Data;
  1076.     AbortIO( &cr );
  1077.     WaitIO( &cr );
  1078.  
  1079.     iop2 = ior.IOSer.io_Data;
  1080.     AbortIO( &ior );
  1081.     WaitIO( &ior );
  1082.  
  1083.     AbortIO( &tr );
  1084.     WaitIO( &tr );
  1085.  
  1086.     twindow->Flags |= RMBTRAP;
  1087.  
  1088.     cursoroff();
  1089.  
  1090.     while( tries-- && ( connect != -2 ) )
  1091.     {
  1092.         if( notfirst )
  1093.         {
  1094.             int timeout = prefs.retrydelay;
  1095.  
  1096.             if( cq )
  1097.             {
  1098.                 AbortIO( &cr );
  1099.                 WaitIO( &cr );
  1100.             }
  1101.             cr.io_Command = CMD_CLEAR;
  1102.             DoIO( &cr );
  1103.  
  1104.             cr.io_Command = CMD_READ;
  1105.             cr.io_Length     = 1;
  1106.             cr.io_Data     = &conr;
  1107.             BeginIO( &cr );
  1108.             cq = TRUE;
  1109.  
  1110.             while( timeout > 0 )
  1111.             {        
  1112.                 conprintf( "\rAnwahlpause; noch %ld Sekunden...  ", timeout-- );
  1113.                 Delay( 50 );
  1114.                 if( CheckIO( &cr ) )
  1115.                     break;
  1116.             }
  1117.         }
  1118.         notfirst = TRUE;
  1119.  
  1120.         if( !number )
  1121.             phone = getphone( phonetrycount++ );
  1122.         else
  1123.             phone = getphonefrom( number, phonetrycount++ );
  1124.  
  1125.         loginmode = 0;
  1126.  
  1127.         conprintf( "\r%s unter %s anrufen (noch %lD Versuche)...", name, phone, tries );
  1128.         sendat( dialprefix );
  1129.         sendat( phone );
  1130.         sendat( "|" );
  1131.  
  1132.         timeout = prefs.dialtimeout;
  1133.         connect = 0;
  1134.  
  1135.         cq = FALSE;
  1136.         tq = FALSE;
  1137.         sq = FALSE;
  1138.  
  1139.         SetSignal( 0, tsig | ssig | csig );
  1140.  
  1141.         while( timeout && ( !connect || connect == 1 ) )
  1142.         {
  1143.             if( !tq )
  1144.             {
  1145.                 if( connect != 1 )
  1146.                     conprintf( "%02ld:%02ld\b\b\b\b\b",
  1147.                         timeout / 60,
  1148.                         timeout % 60 );
  1149.                 qtimer();
  1150.                 tq = TRUE;
  1151.             }
  1152.  
  1153.             if( !cq )
  1154.             {
  1155.                 cr.io_Command = CMD_READ;
  1156.                 cr.io_Length     = 1;
  1157.                 cr.io_Data     = &conr;
  1158.                 BeginIO( &cr );
  1159.                 cq = TRUE;
  1160.             }
  1161.  
  1162.             if( !sq )
  1163.             {
  1164.                 ior.IOSer.io_Command     = CMD_READ;
  1165.                 ior.IOSer.io_Data    = &serr;
  1166.                 ior.IOSer.io_Length    = 1;
  1167.                 BeginIO( &ior );
  1168.                 sq = TRUE;
  1169.             }
  1170.  
  1171.             sigs = mWait( tsig | ssig | csig );
  1172.  
  1173.             if( sigs & tsig )
  1174.             {
  1175.                 WaitIO( &tr );
  1176.                 tq = FALSE;
  1177.                 timeout--;
  1178.             }
  1179.  
  1180.             if( sigs & csig )
  1181.             {
  1182.                 WaitIO( &cr );
  1183.                 cq = FALSE;
  1184.  
  1185.                 if( conr == 0x1b )
  1186.                     connect = -2;
  1187.                 else
  1188.                     connect = -1;
  1189.                 break;
  1190.             }
  1191.  
  1192.             if( sigs & ssig )
  1193.             {
  1194.                 WaitIO( &ior );
  1195.                 sq = FALSE;
  1196.  
  1197.                 putrb7( serr );
  1198.  
  1199.                 if( !connect && testrb( "CONNECT" ) )
  1200.                 {
  1201.                     conprintf( "\nVerbindung hergestellt!\n\n\x1b[0mCONNECT " );
  1202.                     connect = ( doautologin ) ? 1 : 4;
  1203.                     continue;
  1204.                 }
  1205.                 else if( testrb( "BUSY" ) && !connect )
  1206.                     connect = 2;
  1207.                 else if( testrb( "NO CARRIER" ) || testrb( "NO DIALTONE" ) || testrb( "DIAL LOCKED" ) )
  1208.                     connect = 3;
  1209.  
  1210.                 if( connect == 1 && doautologin )
  1211.                 {
  1212.                     if( !loginmode )
  1213.                     {
  1214.                         serr = ibm2iso( serr );
  1215.                         cw.io_Data    = &serr;
  1216.                         cw.io_Length  = 1;
  1217.                         cw.io_Command = CMD_WRITE;
  1218.                         DoIO( &cw );
  1219.                     }
  1220.  
  1221.                     if( testrb( "username:" ) || testrb( "login:" ) )
  1222.                     {
  1223.                         loginmode = TRUE;
  1224.                         conprintf( "\rUsername...\n" );
  1225.                         serialclear();
  1226.                         serputs( username );
  1227.  
  1228.                         if( !password[á0 ]á)
  1229.                             connect = 4;
  1230.                     }
  1231.                     else if( testrb( "pressESCtwice" ) )
  1232.                     {
  1233.                         serputs( "\033\033" );
  1234.                     }
  1235.                     else if( loginmode && ( testrb( "password:" ) || testrb( "passwort:" ) ) )
  1236.                     {
  1237.                         conprintf( "Passwort...\n" );
  1238.                         serialclear();
  1239.                         serputs( password );
  1240.                         connect = 4;
  1241.                     }
  1242.                 }
  1243.             }
  1244.         }
  1245.  
  1246.         if( tq )
  1247.         {
  1248.             AbortIO( &tr );
  1249.             WaitIO( &tr );
  1250.         }
  1251.         if( sq )
  1252.         {
  1253.             AbortIO( &ior );
  1254.             WaitIO( &ior );
  1255.         }
  1256.         if( cq )
  1257.         {
  1258.             AbortIO( &cr );
  1259.             WaitIO( &cr );
  1260.         }
  1261.  
  1262.         if( connect == 1 || connect == 4 )
  1263.         {
  1264.             break;
  1265.         }
  1266.         else if( connect == 2 )
  1267.         {
  1268.             conprintf( "Box ist besetzt.\n" );
  1269.         }
  1270.         else if( connect == 3 )
  1271.         {
  1272.             conprintf( "Keine Verbindung.\n" );
  1273.         }
  1274.         else if( connect == 0 )
  1275.         {
  1276.             conprintf( "Timeout.\n" );
  1277.         }
  1278.         else if( connect < 0 )
  1279.         {
  1280.             conprintf( "Abgebrochen!\n" );
  1281.             sendat( "|^" );
  1282.             if( connect == -2 )
  1283.             {
  1284.                 conprintf( "\n" );
  1285.                 iow.IOSer.io_Command = CMD_CLEAR;
  1286.                 DoIO( &iow );
  1287.                 break;
  1288.             }
  1289.         }
  1290.  
  1291.         Delay( 60 );
  1292.  
  1293.         iow.IOSer.io_Command = CMD_CLEAR;
  1294.         DoIO( &iow );
  1295.     }
  1296.  
  1297.     cursoron();
  1298.  
  1299.     cr.io_Data = iop1;
  1300.     cr.io_Length = 1;
  1301.     cr.io_Command = CMD_READ;
  1302.     BeginIO( &cr );
  1303.  
  1304.     ior.IOSer.io_Data = iop2;
  1305.     ior.IOSer.io_Length = 1;
  1306.     ior.IOSer.io_Command = CMD_READ;
  1307.     BeginIO( &ior );
  1308.  
  1309.     qtimer();
  1310.  
  1311.     twindow->Flags &= ~RMBTRAP;
  1312.  
  1313.     return( ( connect == 1 || connect == 4 ) );
  1314. }
  1315.  
  1316.  
  1317. static void calluser(void)
  1318. {
  1319.     struct user u;
  1320.  
  1321.     if(douserrequser(&u))
  1322.     {
  1323.         if(!u.telefon[0]) conprintf("Fⁿr User %s ist keine Telefonnummern eingetragen.\n",UNAME(u));
  1324.         else
  1325.         {
  1326.             callbymodem( UNAME( u ), u.telefon, 0, 0, mdtprefs.modemdial, FALSE );
  1327.         }
  1328.     }
  1329. }
  1330.  
  1331. static struct mdphone *dialasap;
  1332. char lastboxdialed[ 40 ] = {á"KEIN TELEFONBUCHEINTRAG" };
  1333. static int callphone( void )
  1334. {
  1335.     struct mdphone *m;
  1336.  
  1337.     if( dialasap )
  1338.     {
  1339.         m = dialasap;
  1340.         dialasap = NULL;
  1341.     }
  1342.     else
  1343.     {
  1344.         m = dotermphonesel();
  1345.     }
  1346.     if( m )
  1347.     {
  1348.         strcpy( lastboxdialed, m->name );
  1349.         if( stricmp( prefs.term_currentmdt, m->prefs ) )
  1350.         {
  1351.             strcpy( prefs.term_currentmdt, m->prefs );
  1352.             dialasap = m;
  1353.             return( TRUE );
  1354.         }
  1355.         callbymodem( m->name, m->phone, m->username, m->password, mdtprefs.modemdial, m->autologin );
  1356.     }
  1357.     return( 0 );
  1358. }
  1359.  
  1360.  
  1361. static void dotermhelp(void)
  1362. {
  1363.     showguide("menu_brett_0_3");
  1364. }
  1365.  
  1366. static void callnumber( void )
  1367. {
  1368.     int rc;
  1369.     static char buffer[ 128 ];
  1370.  
  1371.     rc = rtGetString( buffer, 128,
  1372.         NULL,
  1373.         rinfo,
  1374.         RTGS_TextFmt, "Beliebige Telefonnummer anrufen:",
  1375.         TAG_DONE );
  1376.  
  1377.     if( rc )
  1378.         callbymodem( buffer, buffer, 0, 0, mdtprefs.modemdial, FALSE );
  1379.         
  1380. }
  1381.  
  1382.  
  1383. static void insertfkey(struct IOExtSer *iow,long fkey)
  1384. {
  1385.     static char key[128];
  1386.     UBYTE *p,*p2;
  1387.  
  1388.     if(fkey<0) {ádotermhelp(); return; }
  1389.     if(fkey>19) return;
  1390.     p=prefs.fkeys[fkey];
  1391.     p2=key;
  1392.     while(*p) {
  1393.         if(*p=='|') { *p2++=13; p++; }
  1394.         else *p2++=*p++;
  1395.     }
  1396.     *p2=0;
  1397.     iow->IOSer.io_Data=key;
  1398.     iow->IOSer.io_Length=strlen(key);
  1399. }
  1400.  
  1401. extern char *download;
  1402.  
  1403. static int doterminal2( void )
  1404. {
  1405.     UBYTE crch,srch; /* console & serial read chars */
  1406.     ULONG ssig, csig, wsig, sigs, tsig;
  1407.     time_t t,t2,t3;
  1408.     USHORT carrier,check;
  1409.     struct IntuiMessage *im;
  1410.     ULONG itemnum,menunum;
  1411.     long doexit=0;
  1412.     char serbuf[256],*p,csibuf[4];
  1413.     int c,d;
  1414.     int dolog = ( prefs.flags & MDF_TERM_LOG );
  1415.     int hexmode = FALSE;
  1416.  
  1417.     if( isv37 )
  1418.     {
  1419.         if( GetVar( "MD_TERM_HEX", serbuf, 256, 0 ) >= 0 )
  1420.             hexmode = TRUE;
  1421.     }
  1422.  
  1423. retrycfg:
  1424.     selectmdtprefs( prefs.term_currentmdt );
  1425.     linespeed = prefs.modembaud;
  1426.     if( !mdtprefs.name[á0 ]á)
  1427.     {
  1428.         if( askreq( "Terminal-Konfiguration\n%s\nnicht gefunden.", "Weiter mit Point-Konfiguration|Abbruch", prefs.term_currentmdt ) )
  1429.         {
  1430.             prefs.term_currentmdt[á0 ] = 0;
  1431.             goto retrycfg;
  1432.         }
  1433.         else
  1434.             return( 0 );
  1435.     }
  1436.  
  1437.     c = initser( TRUE );
  1438.     if( c )
  1439.     {
  1440.         if( c == -2 )
  1441.         {
  1442.             prefs.term_currentmdt[á0 ]á= 0;
  1443.             goto retrycfg;
  1444.         }
  1445.         return( 0 );
  1446.     }
  1447.     if(initconsole())
  1448.     {
  1449.         exitser();
  1450.         return( 0 );
  1451.     }
  1452.  
  1453.     if( isv37 && WorkbenchBase )
  1454.     {
  1455.         apport = CreateMsgPort();
  1456.         pushhomedir();
  1457.         appicondobj = GetDiskObject( "DefIcons/UploadList" );
  1458.         if( !appicondobj )
  1459.             appicondobj = GetDefDiskObject( WBPROJECT );
  1460.         popdir();
  1461.         appicon = AddAppIcon( 42, NULL, "MicroDot-Upload-Liste", apport, NULL, appicondobj, TAG_DONE );
  1462.         if( appicon )
  1463.             apsig = 1L << apport->mp_SigBit;
  1464.     }
  1465.  
  1466.     treport( 0, 2, "Terminal-Modus %s (%s, Unit %ld, %lD bps%s%s%s)",mdtprefs.name, mdtprefs.device,mdtprefs.unit,mdtprefs.baud,
  1467.         (mdtprefs.flags&1)?", RTS/CTS":"",
  1468.         (mdtprefs.flags&2)?", HISPEED":"",
  1469.         (mdtprefs.flags&4)?", SHARED":"");
  1470.     treport( 1, 2, "Online: 00:00:00" );
  1471.  
  1472.     tv_init();
  1473.  
  1474.     ClearMenuStrip( twindow );
  1475.     SetMenuStrip( twindow, termmenustrip );
  1476.  
  1477.     if( prefs.term_currentmdt[á0 ]á)
  1478.         OnMenu( twindow, FULLMENUNUM( 3, 1, 0 ) );
  1479.     else
  1480.         OffMenu( twindow, FULLMENUNUM( 3, 1, 0 ) );
  1481.  
  1482.     ssig = 1L<<iorp->mp_SigBit;
  1483.     wsig = 1L<<twindow->UserPort->mp_SigBit;
  1484.     csig = 1L<<crp->mp_SigBit;
  1485.     tsig = 1L<<tport->mp_SigBit;
  1486.  
  1487.     cr.io_Data=&crch;
  1488.     cr.io_Length=1;
  1489.     cr.io_Command=CMD_READ;
  1490.     BeginIO(&cr);
  1491.  
  1492.     ior.IOSer.io_Data=&srch;
  1493.     ior.IOSer.io_Length=1;
  1494.     ior.IOSer.io_Command=CMD_READ;
  1495.     BeginIO(&ior);
  1496.  
  1497.     t=0;
  1498.     carrier=testcarrier();
  1499.  
  1500.     if( carrier )
  1501.         time( &t2 );
  1502.  
  1503.     qtimer();
  1504.  
  1505. #define    isibm ( mdtprefs.flags & MDTF_IBM )
  1506. #define    autodl ( prefs.flags & MDF_TERM_AUTODL )
  1507. #define    autoul ( prefs.flags & MDF_TERM_AUTOUL )
  1508.  
  1509.     ClearPointer( twindow );
  1510.  
  1511.     if( !wbwindow && mdtprefs.whichcolors )
  1512.         term_setcolors();
  1513.  
  1514.     inituploadlist();
  1515.  
  1516.     while( !doexit )
  1517.     {
  1518.         if( dialasap )
  1519.             callphone();
  1520.  
  1521.         sigs = mWait( ssig | csig | wsig | tsig | tvsig | apsig );
  1522.  
  1523.         if( sigs & apsig )
  1524.         {
  1525.             struct AppMessage *am;
  1526.             struct uploadnode *uln;
  1527.             struct WBArg *wba;
  1528.  
  1529.             while( ( am = ( struct AppMessage * ) GetMsg( apport ) ) )
  1530.             {
  1531.                 if( !am->am_NumArgs )
  1532.                 {
  1533.                     ScreenToFront( scr );
  1534.                 }
  1535.                 else
  1536.                 {
  1537.                     wba = am->am_ArgList;
  1538.                     while( am->am_NumArgs-- )
  1539.                     {
  1540.                         if( wba->wa_Name[á0 ]á)
  1541.                         {
  1542.                             uln = LibAllocPooled( uploadlistpool, sizeof( *uln ) );
  1543.                             if( uln )
  1544.                             {
  1545.                                 NameFromLock( wba->wa_Lock, uln->name, 256 );
  1546.                                 AddPart( uln->name, wba->wa_Name, 256 );
  1547.                                 AddTail( ( struct List * ) &uploadlist, ( struct Node * ) uln );
  1548.                             }
  1549.                         }
  1550.                         wba++;
  1551.                     }
  1552.                 }
  1553.                 ReplyMsg( am );
  1554.             }
  1555.         }
  1556.  
  1557.         if( sigs & wsig )
  1558.         {
  1559.             while( ( im = ( struct IntuiMessage * )    GetMsg( twindow->UserPort)))
  1560.             {
  1561.                 if(im->Class==IDCMP_MENUHELP)
  1562.                 {
  1563.                     domenuhelp( "term", im );
  1564.                     ReplyMsg( im );
  1565.                 }
  1566.                 else if( im->Class == IDCMP_CLOSEWINDOW )
  1567.                 {
  1568.                     ReplyMsg( im );
  1569.                     doexit = 1;
  1570.                 }
  1571.                 else if( im->Class == IDCMP_NEWSIZE )
  1572.                 {
  1573.                     ReplyMsg( im );
  1574.                     conresize();
  1575.                 }
  1576.                 else if( im->Class == IDCMP_REFRESHWINDOW )
  1577.                 {
  1578.                     ReplyMsg( im );
  1579.                     BeginRefresh( w );
  1580.                     EndRefresh( w, TRUE );
  1581.                 }
  1582.                 else if( im->Class == IDCMP_MENUPICK )
  1583.                 {
  1584.                     itemnum = ITEMNUM( im->Code );
  1585.                     menunum = MENUNUM( im->Code );
  1586.                     ReplyMsg( im );
  1587.  
  1588.                     if(!menunum) switch(itemnum)
  1589.                     {
  1590.                         case 0: conprintf("\x1b\x63\f"); break;
  1591.                         case 2: 
  1592.                             callbymodem( prefs.boxname, prefs.phone, prefs.username, prefs.userpassword, prefs.modemdial, TRUE /*prefs.flags2 & MDF2_TERM_AUTOLOGIN*/ );
  1593.                             break;
  1594.                         case 3: if( callphone() )
  1595.                                     doexit = 2;
  1596.                                 break;
  1597.                         case 4: calluser(); break;
  1598.                         case 5: callnumber(); break;
  1599.                         case 7: conprintf("Auflegen...\n"); hangup(); break;
  1600.                         case 9: dotermhelp(); break;
  1601.                         case 11: doexit=1; break;
  1602.                     }
  1603.                     else if(menunum==1) switch(itemnum)
  1604.                     {
  1605.                         case 0: AbortIO(&ior); WaitIO(&ior);
  1606.                             doupload();
  1607.                             ior.IOSer.io_Data=&srch;
  1608.                             ior.IOSer.io_Length=1;
  1609.                             ior.IOSer.io_Command=CMD_READ;
  1610.                             BeginIO(&ior);
  1611.                             break;
  1612.                         case 1: AbortIO(&ior); WaitIO(&ior);
  1613.                             dodownload();
  1614.                             ior.IOSer.io_Data=&srch;
  1615.                             ior.IOSer.io_Length=1;
  1616.                             ior.IOSer.io_Command=CMD_READ;
  1617.                             BeginIO(&ior);
  1618.                             break;
  1619.  
  1620.                         case 3:
  1621.                             if( checkmenustate( termmenustrip, FULLMENUNUM( 1,3, NOSUB ) ) )
  1622.                                 prefs.flags2 |= MDF2_TERM_ZM8K;
  1623.                             else
  1624.                                 prefs.flags2 &= ~MDF2_TERM_ZM8K;
  1625.                             break;
  1626.  
  1627.                         case 5:
  1628.                             makeuploadlist();
  1629.                             break;
  1630.  
  1631.                         case 6:
  1632.                             AbortIO(&ior); WaitIO(&ior);
  1633.                             douploadlist();
  1634.                             ior.IOSer.io_Data=&srch;
  1635.                             ior.IOSer.io_Length=1;
  1636.                             ior.IOSer.io_Command=CMD_READ;
  1637.                             BeginIO(&ior);
  1638.                             break;
  1639.  
  1640.                         case 8:
  1641.                             AbortIO(&ior);
  1642.                             WaitIO(&ior);
  1643.                             AbortIO(&cr);
  1644.                             WaitIO(&cr);
  1645.                             download = prefs.term_downloadpath;
  1646.                             hydra_xfer( &uploadlist );
  1647.                             ior.IOSer.io_Data=&srch;
  1648.                             ior.IOSer.io_Length=1;
  1649.                             ior.IOSer.io_Command=CMD_READ;
  1650.                             BeginIO( &ior );
  1651.                             cr.io_Data=&crch;
  1652.                             cr.io_Length=1;
  1653.                             cr.io_Command=CMD_READ;
  1654.                             BeginIO( &cr );
  1655.                             break;
  1656.  
  1657.                     }
  1658.                     else if(menunum==2) switch(itemnum)
  1659.                     {
  1660.                         case 0: dolog = checkmenustate( termmenustrip, FULLMENUNUM( 2,0, NOSUB ) ); break;
  1661.                         case 2: tvsig = tv_open( twindow ); break;
  1662.                         case 4: tv_clear(); break;
  1663.                         case 5: tv_save(); break;
  1664.                         case 6: tv_save_proto(); break;
  1665.                     }
  1666.                     else if(menunum==3) switch(itemnum)
  1667.                     {
  1668.                         case 0: if( dotermsel() )
  1669.                                     doexit = 2;
  1670.                                 break;
  1671.                         case 1: if( dotermserial() )
  1672.                                     doexit = 2;
  1673.                                 break;
  1674.                         case 2: dotermterm(); break;
  1675.                         case 4: dotermfkey(); break;
  1676.                         case 5: dotermtransfer(); break;
  1677.                         case 7: dotermphone(); break;
  1678.                     }
  1679.                 }
  1680.                 else ReplyMsg( im );
  1681.             }
  1682.         }
  1683.  
  1684.  
  1685.         if( ( sigs & csig ) && CheckIO( &cr ) )
  1686.         {
  1687.             WaitIO( &cr );
  1688.  
  1689.             if(crch == 0x9b)
  1690.             {
  1691.                 memset( csibuf, 0, 4 );
  1692.                 iow.IOSer.io_Data = NULL;
  1693.  
  1694.                 /* CSI received */
  1695.                 cr.io_Command     = CMD_READ;
  1696.                 cr.io_Length      = 1;
  1697.                 cr.io_Data        = &csibuf[0];
  1698.                 DoIO( &cr );
  1699.                 if( isdigit( csibuf[0] ) || csibuf[0] == '?' )
  1700.                 {
  1701.                     cr.io_Data = &csibuf[1];
  1702.                     DoIO( &cr );
  1703.                     if( csibuf[0]=='?' && csibuf[1]=='~')
  1704.                     {
  1705.                         insertfkey( &iow, -1 );
  1706.                         goto contcsi;
  1707.                     }
  1708.  
  1709.                     if( isdigit(csibuf[1]) )
  1710.                     {
  1711.                         cr.io_Data = &csibuf[2];
  1712.                         DoIO( &cr );
  1713.                         if( csibuf[2]=='~' )
  1714.                         {
  1715.                             insertfkey( &iow, atoi( csibuf ) );
  1716.                             goto contcsi;
  1717.                         }
  1718.                     }
  1719.                     else if( csibuf[1]=='~' )
  1720.                     {
  1721.                         insertfkey( &iow, atoi(csibuf) );
  1722.                         goto contcsi;
  1723.                     }
  1724.                 }
  1725. writecsi:
  1726.                 iow.IOSer.io_Command=CMD_WRITE;
  1727.                 iow.IOSer.io_Data="\x1b[";
  1728.                 iow.IOSer.io_Length=2;
  1729.                 DoIO( &iow );
  1730.                 c = strlen( csibuf );
  1731.                 if( c )
  1732.                 {
  1733.                     iow.IOSer.io_Data    =    csibuf;
  1734.                     iow.IOSer.io_Length    =    c;
  1735.                 }
  1736. contcsi:
  1737.                 cr.io_Data=&crch;
  1738.             }
  1739.             else
  1740.             {
  1741.                 if(isibm) crch=iso2ibm(crch);
  1742.                 iow.IOSer.io_Data=&crch;
  1743.                 iow.IOSer.io_Length=1;
  1744.             }
  1745.             if( iow.IOSer.io_Data )
  1746.             {
  1747.                 iow.IOSer.io_Command=CMD_WRITE;
  1748.                 DoIO(&iow);
  1749.             }
  1750.             cr.io_Length = 1;
  1751.             cr.io_Command = CMD_READ;
  1752.             BeginIO(&cr);
  1753.         }
  1754.         if( ( sigs & ssig ) && CheckIO(&ior))
  1755.         {
  1756.             if( hexmode )
  1757.             {
  1758.                 conprintf( "<%02lx:%lc>", srch, isprint( srch ) ? srch : '.' );
  1759.                 if( srch == 10 || srch == 13 )
  1760.                     conprintf( "\n" );
  1761.                 goto contser;
  1762.             }
  1763.  
  1764.             WaitIO(&ior);
  1765.             if(isibm)
  1766.                 srch=ibm2iso(srch);
  1767.             cw.io_Command=CMD_WRITE;
  1768.             cw.io_Data=&srch;
  1769.             cw.io_Length=1;
  1770.             if( dolog )
  1771.             {
  1772.                 SendIO(&cw);
  1773.                 tv_add( &srch, 1 ); 
  1774.                 WaitIO(&cw);
  1775.             } else DoIO(&cw);
  1776.  
  1777.             /* Auto-Download? */
  1778.             if(autodl || autoul ) {
  1779.                 putrb(srch);
  1780.                 if(autodl && testrbzdl()) dodownload();
  1781.                 if(autoul && testrbzul()) doupload();
  1782.             }
  1783.  
  1784.             /* Weitere Zeichen? */
  1785. retest:
  1786.             ior.IOSer.io_Command=SDCMD_QUERY;
  1787.             DoIO(&ior);
  1788.             if(ior.IOSer.io_Actual)
  1789.             {
  1790.                 ior.IOSer.io_Length=min(ior.IOSer.io_Actual,256);
  1791.                 ior.IOSer.io_Command=CMD_READ;
  1792.                 ior.IOSer.io_Data=serbuf;
  1793.                 DoIO(&ior);
  1794.                 c=ior.IOSer.io_Actual;
  1795.                 if(isibm) bibm2iso(serbuf,c);
  1796.                 cw.io_Command=CMD_WRITE;
  1797.                 cw.io_Data=serbuf;
  1798.                 cw.io_Length=c;
  1799.                 if( dolog ) {
  1800.                     SendIO(&cw);
  1801.                     tv_add( serbuf, c );
  1802.                     WaitIO(&cw);
  1803.                 } else DoIO(&cw);
  1804.  
  1805.                 /* Auto-Download? */
  1806.                 if( autodl || autoul ) {
  1807.                     p=serbuf;
  1808.                     while(c--) {
  1809.                         putrb(*p++);
  1810.                         if(autodl && testrbzdl()) { dodownload(); break; }
  1811.                         if(autoul && testrbzul()) { doupload(); break; }
  1812.                     }
  1813.                 }
  1814.  
  1815.                 goto retest;
  1816.             }
  1817.  
  1818.             tv_update();
  1819.             
  1820. contser:
  1821.             ior.IOSer.io_Data=&srch;
  1822.             ior.IOSer.io_Length=1;
  1823.             ior.IOSer.io_Command=CMD_READ;
  1824.             BeginIO(&ior);
  1825.         }
  1826.  
  1827.         if( sigs & tvsig )
  1828.             tv_proc();
  1829.  
  1830.         if( sigs & tsig )
  1831.         {
  1832.             /*AbortIO(&tr);*/
  1833.             WaitIO(&tr);
  1834.             check=testcarrier();
  1835.             treport(1,2,"Online: %02ld:%02ld:%02ld %s %s",
  1836.                 (t/3600)%60,(t/60)%60,t%60,
  1837.                 (check)?((mdtprefs.flags&8)?"(Carrier ignorieren)":"(Verbindung besteht)"):"",
  1838.                 (dolog)?"(Mitschnitt aktiv)":"");
  1839.     
  1840.             if(carrier && !check) {
  1841.                 carrier=0;
  1842.             }    
  1843.             if(!carrier & check) {
  1844.                 carrier=1;
  1845.                 time(&t2);
  1846.             }
  1847.  
  1848.             if(check) {
  1849.                 time(&t3);
  1850.                 if(t2!=t3) {
  1851.                     t+=t3-t2;
  1852.                 }
  1853.                 t2=t3;
  1854.             }
  1855.  
  1856.             qtimer();
  1857.         }
  1858.             
  1859.         if( doexit == 1 )
  1860.         {
  1861.             c = testcarrier() && !( mdtprefs.flags & 8 );
  1862.             d = tv_changed();
  1863.  
  1864.             if( c || d )
  1865.             {
  1866.                 doexit = askreq( "Wollen Sie das Terminal wirklich beenden?\n%s%s",
  1867.                     "Beenden|Weitermachen",
  1868.                     ( c ) ? "\n╖ Es ist noch eine Verbindung vorhanden!" : "",
  1869.                     ( d ) ? "\n╖ Der Mitschnitt-Puffer wurde nicht gespeichert!" : "" );
  1870.             }
  1871.         }
  1872.     }            
  1873.  
  1874.     AbortIO(&cr); WaitIO(&cr);
  1875.     AbortIO(&ior); WaitIO(&ior);
  1876.     AbortIO(&tr); WaitIO(&tr);
  1877.  
  1878.     tv_exit();
  1879.  
  1880.     if( appicon )
  1881.         RemoveAppIcon( appicon );
  1882.     if( appicondobj )
  1883.         FreeDiskObject( appicondobj );
  1884.     if( apport )
  1885.         DeleteMsgPort( apport );
  1886.  
  1887.     exituploadlist();
  1888.  
  1889.     if( dolog )
  1890.         prefs.flags |= MDF_TERM_LOG;
  1891.     else
  1892.         prefs.flags &=~ MDF_TERM_LOG;
  1893.  
  1894.     ClearMenuStrip( twindow );
  1895.  
  1896.     exitser();
  1897.     exitconsole();
  1898.  
  1899.     treport(0,0,"");
  1900.     treport(1,0,"");
  1901.  
  1902.     if( !wbwindow )
  1903.     {
  1904.         if( prefs.usecustomcolors )
  1905.             setcolors( scr );
  1906.         else
  1907.             setwbcolors( scr );
  1908.     }
  1909.  
  1910.     return( doexit == 2 );
  1911. }
  1912.  
  1913. void doterminal( void )
  1914. {
  1915.     while( doterminal2() );
  1916. }
  1917.  
  1918. static void writecs(char*s)
  1919. {
  1920.     iow.IOSer.io_Command=cw.io_Command=CMD_WRITE;
  1921.     iow.IOSer.io_Length=cw.io_Length=strlen(s);
  1922.     iow.IOSer.io_Data=cw.io_Data=s;
  1923.     SendIO(&iow); DoIO(&cw); WaitIO(&iow);
  1924. }
  1925.  
  1926. static void sendzeros(void)
  1927. {
  1928.     ULONG zero[2]={0,0};
  1929.  
  1930.     iow.IOSer.io_Data=zero;
  1931.     iow.IOSer.io_Length=5;
  1932.     iow.IOSer.io_Command=CMD_WRITE;
  1933.  
  1934.     DoIO(&iow);
  1935.  
  1936. }
  1937.  
  1938. static void sendx(void)
  1939. {
  1940.     UBYTE ctrlx[]={24,3,24,3};
  1941.  
  1942.     iow.IOSer.io_Data=ctrlx;
  1943.     iow.IOSer.io_Length=4;
  1944.     iow.IOSer.io_Command=CMD_WRITE;
  1945.  
  1946.     DoIO(&iow);
  1947.  
  1948. }
  1949.  
  1950. static char *gotfilename, sendfilename[ 256 ];
  1951.  
  1952. ALLOCSTATIC( gotfilename, 4096, MEMF_CLEAR )
  1953.  
  1954. static ULONG getprotection( char *name )
  1955. {
  1956.     BPTR lock;
  1957.     struct FileInfoBlock *fib;
  1958.     ULONG rc = -1;
  1959.  
  1960.     lock = Lock( name, SHARED_LOCK );
  1961.     if( !lock )
  1962.         return( rc );
  1963.  
  1964.     fib = allocfib();
  1965.     if( fib )
  1966.     {
  1967.         Examine( lock, fib );
  1968.         rc = fib->fib_Protection;
  1969.         freefib( fib );
  1970.     }
  1971.  
  1972.     UnLock( lock );
  1973.     return( rc );
  1974. }
  1975.  
  1976. static int dopackdata(void)
  1977. {
  1978.     BPTR f,outwin;
  1979.     char temp[1024], *p;
  1980.     int rc;
  1981.  
  1982.     if(!(f=Lock("PUFFER",SHARED_LOCK)))
  1983.     {
  1984.         strcpy(sendfilename,"CALLER.LHA");
  1985.         f=Open(sendfilename,MODE_NEWFILE);
  1986.         Write(f,"\r\n",2);
  1987.         Close(f);
  1988.         return( 0 );
  1989.     } else UnLock(f);
  1990.  
  1991. /*    sprintf( temp, "CON:40/40/%ld/%ld/Packe Daten.../INACTIVE/AUTO",
  1992.         scr->Width - 80,
  1993.         scr->Height - 80 ) ;
  1994.  
  1995.     if( !isv37 )
  1996.         outwin=Open( "CON:40/40/560/110/MicroDot: Packe Daten...", MODE_NEWFILE );
  1997.     else
  1998.         outwin = OpenCon( temp );*/
  1999.  
  2000.     outwin = openconsole( "Packe Daten..." );
  2001.  
  2002.     temp[0]=0;
  2003.     if(!isv37)
  2004.     {
  2005.         WBenchToFront();
  2006.         sprintf( temp, "cd \"%s\"\n", prefs.transferdir );    
  2007.     }
  2008.  
  2009.     asprintf(temp,prefs.packer,"caller.lha","PUFFER",0,0,0,0,0,0,0,0,0);
  2010.  
  2011.     if( isv37 )
  2012.     {
  2013.         rc = SystemTags( temp,
  2014.             SYS_Input, NULL,
  2015.             SYS_Output, outwin,
  2016.             NP_StackSize, 16384,
  2017.             NP_Cli, TRUE,
  2018.             TAG_DONE );
  2019.     }
  2020.     else
  2021.     {
  2022.         rc = !Execute(temp,0,outwin);
  2023.     }
  2024.  
  2025.  
  2026.     DeleteFile( "PUFFER" );
  2027.     makefilelist( "", "#?.#?", temp, 1024 );
  2028.  
  2029.     p = temp;
  2030.     while( *p )
  2031.     {
  2032.         strcpy( sendfilename, p );
  2033.         while( *p++ );
  2034.  
  2035.         if( !strnicmp( sendfilename, "BAD-XFER", 8 ) )
  2036.             continue;
  2037.  
  2038.         if( !( getprotection( sendfilename ) & FIBF_DELETE ) )
  2039.             break;
  2040.     }
  2041.  
  2042.     Close(outwin);
  2043.  
  2044.     if(!isv37)
  2045.         ScreenToFront(scr);
  2046.  
  2047.     return( rc );
  2048.  
  2049.  
  2050. }
  2051.  
  2052. void setgotfilename( char *txt )
  2053. {
  2054.     memset( gotfilename, 0, 2048 );
  2055.     strcpy( gotfilename, txt );
  2056. }
  2057.  
  2058. int backdisable;
  2059.  
  2060. int unpackdata(void)
  2061. {
  2062.     BPTR outwin,dirlock;
  2063.     struct FileInfoBlock *fib;
  2064.     char exec[256];
  2065.     ULONG t;
  2066.     char x[6];
  2067.     char *p = gotfilename;
  2068.     int totalarcsize = 0, totalarcs = 0;
  2069.     static int destcnt = 0;
  2070.     char destdate[á6 ];
  2071.  
  2072.     utunpk( time( 0 ), destdate );
  2073.  
  2074. /*    sprintf( exec, "CON:40/40/%ld/%ld/Entpacke Daten.../INACTIVE/AUTO",
  2075.         scr->Width - 80 ,
  2076.         scr->Height - 80 );
  2077.  
  2078.     if( !isv37 )
  2079.         outwin=Open( "CON:40/40/560/110/Entpacke Daten...", MODE_NEWFILE );
  2080.     else
  2081.         outwin = OpenCon( exec );*/
  2082.  
  2083.     outwin = openconsole( "Entpacke Daten..." );
  2084.     pushdir( prefs.transferdir );
  2085.  
  2086.     while( *p )
  2087.     {
  2088.         int arclen = getfilelen( p );
  2089.  
  2090.         totalarcs++;
  2091.         totalarcsize += arclen;
  2092.  
  2093.         if( arclen < 10 )
  2094.         {
  2095.             printlog( "Empfangene Archivdatei....: %s (%ld Bytes, deshalb IGNORIERT)\n", p, arclen );
  2096.             DeleteFile( p );
  2097.             p = strchr( p, 0 ) + 1;
  2098.             continue;
  2099.         }
  2100.  
  2101.         printlog( "Empfangene Archivdatei....: %s (%lD Bytes)\n", p, arclen );
  2102.  
  2103.         exec[0]á= 0;
  2104.         if(!isv37)
  2105.         {
  2106.             WBenchToFront();
  2107.             sprintf( exec, "cd \"%s\"\n", prefs.transferdir );
  2108.             asprintf(exec,prefs.unpacker,p,"#?",0,0,0,0,0,0,0,0,0,0);
  2109.             Execute(exec,0,outwin);
  2110.         }
  2111.         else
  2112.         {
  2113.             int rc;
  2114.  
  2115.             sprintf( exec, prefs.unpacker, p, "#?", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
  2116.  
  2117.             rc = SystemTags( exec,
  2118.                 SYS_Input, NULL,
  2119.                 SYS_Output, outwin,
  2120.                 NP_StackSize, 16384,
  2121.                 NP_Cli, TRUE,
  2122.                 TAG_DONE 
  2123.             );
  2124.  
  2125.             if( rc )
  2126.             {
  2127.                 printlog( "Fehler #%ld beim Entpacken (%s)!\n", rc, exec );
  2128.  
  2129.                 if( !( prefs.flags2 & MDF2_JANUS2 ) )
  2130.                 {
  2131.                     Close( outwin );
  2132.                     popdir();
  2133.                     return( -1 );
  2134.                 }
  2135.             }
  2136.         }
  2137.  
  2138.         if( prefs.netcall_save && !backdisable )
  2139.         {
  2140.             BPTR xdirlock = CreateDir( "BACKUP" );
  2141.             UnLock( xdirlock );
  2142.  
  2143.             if( prefs.flags2 & MDF2_JANUS2 )
  2144.                 sprintf( exec, "BACKUP/%s.%ld.%02ld-%02ld-%02ld_%02ld-%02ld-%02ld", prefs.boxname, destcnt++, destdate[ 2 ], destdate[á1 ], ( destdate[á0 ]á+ 70 ) % 100, destdate[á3 ], destdate[á4 ], destdate[á5 ] );
  2145.             else
  2146.                 sprintf( exec, "BACKUP/%s.%02ld-%02ld-%02ld_%02ld-%02ld-%02ld", prefs.boxname, destdate[ 2 ], destdate[á1 ], ( destdate[á0 ]á+ 70 ) % 100, destdate[á3 ], destdate[á4 ], destdate[á5 ] );
  2147.  
  2148.             Rename( p, exec );
  2149.         }
  2150.         else
  2151.             DeleteFile( p );
  2152.  
  2153.         backdisable = FALSE;
  2154.  
  2155.         p = strchr( p, 0 ) + 1;
  2156.     }
  2157.  
  2158.     printlog( "Insgesamt %lD Archiv-Datei(en), %lD Bytes\n\n", totalarcs, totalarcsize );
  2159.  
  2160.     printlog("\nEnthaltene Dateien      Datum/Zeit            LΣnge in Bytes\n");
  2161.     dirlock=Lock("",SHARED_LOCK);
  2162.     fib = allocfib();
  2163.     Examine( dirlock, fib );
  2164.     while( ExNext( dirlock, fib ) )
  2165.     {
  2166.         if( fib->fib_DirEntryType > 0 )
  2167.             continue;
  2168.         t=__datecvt(&fib->fib_Date);
  2169.         utunpk(t,x);
  2170.         printlog( "%-23s %02ld.%02ld.%04ld %02ld:%02ld:%02ld   %lD\n",
  2171.             fib->fib_FileName,
  2172.             x[2],x[1],x[0]+1970,x[3],x[4],x[5],
  2173.             fib->fib_Size);
  2174.     }
  2175.     freefib( fib );
  2176.     UnLock( dirlock );
  2177.  
  2178.     popdir();
  2179.  
  2180.     Close( outwin );
  2181.  
  2182.     if( !isv37 )
  2183.         ScreenToFront( scr );
  2184.  
  2185.     return( 0 );
  2186. }
  2187.  
  2188. static int donetcall1( int netcallmode )
  2189. {
  2190.     int dialnum=prefs.dialretries;
  2191.     int c,timeout,doabort=0,connect,isarcing,d,e;
  2192.     long ssig,csig,wsig,sigs,tsig;
  2193.     char crch,srch,*p; /* console & serial read chars */
  2194.     struct IntuiMessage *im;
  2195.     int itemnum,showdata;
  2196.     long tconnect=0,thangup;
  2197.     long sendtime,rectime;
  2198.     long sendbytes,recbytes;
  2199.     long t;
  2200.     int quietsecs;
  2201.     char tmp[32];
  2202.     char *filearray[2];
  2203.     char connectstring[ 32 ];
  2204.     int connectlen;
  2205.     int allowpw = FALSE;
  2206.     char *loginstring = "JANUS";
  2207.  
  2208.     if( prefs.flags2 & MDF2_JANUS2 )
  2209.     {
  2210.         switch( netcallmode )
  2211.         {
  2212.             case 0:
  2213.                 loginstring = "JANUS2";
  2214.                 break;
  2215.             case 1:
  2216.                 loginstring = "JANUS2P";
  2217.                 break;
  2218.             case 2:
  2219.                 loginstring = "JANUS2N";
  2220.                 break;
  2221.             case 3:
  2222.                 loginstring = "JANUS2H";
  2223.                 break;
  2224.         }
  2225.     }
  2226.  
  2227.     /* Pointcfg laden */
  2228.     selectmdtprefs( NULL );
  2229.  
  2230.     linespeed = prefs.modembaud;
  2231.  
  2232.     if(initser( FALSE )) return(-1);
  2233.     if(initconsole())
  2234.     {
  2235.         exitser();
  2236.         return(-1);
  2237.     }
  2238.  
  2239.     SetMenuStrip(twindow,netcallmenustrip);
  2240.  
  2241.     sprintf(tmp,"Netcall %s",dat2str(time(0)));
  2242.     openlogmsg(tmp);
  2243.  
  2244.     printlog("Netcall bei der '%s' am %s\n\n",prefs.boxname,dat2str(time(0)));
  2245.  
  2246.     addlogfile( "NETCALL bei %s", prefs.boxname );
  2247.  
  2248.     treport(0,1,"Netcall...");
  2249.     treport(1,0,"");
  2250.  
  2251.     ssig=1<<iorp->mp_SigBit;
  2252.     wsig=1<<twindow->UserPort->mp_SigBit;
  2253.     csig=1<<crp->mp_SigBit;
  2254.     tsig=1<<tport->mp_SigBit;
  2255.  
  2256.     cr.io_Data=&crch;
  2257.     cr.io_Length=1;
  2258.     cr.io_Command=CMD_READ;
  2259.     BeginIO( &cr );
  2260.  
  2261.     ior.IOSer.io_Data=&srch;
  2262.     ior.IOSer.io_Length=1;
  2263.     ior.IOSer.io_Command=CMD_READ;
  2264.     BeginIO(&ior);
  2265.  
  2266.     conprintf("\x1b[0 p\nModem-Initialisierung...\n");
  2267.     sendat(prefs.modeminit);
  2268.     Delay(24);
  2269.  
  2270.     pushdir(prefs.transferdir);
  2271.     c=getfilelen("PUFFER"); if(c<2) c=2;
  2272.     conprintf("Packe Daten: %lD Bytes",c);
  2273.     printlog("Ausgehende Daten ungepackt: %lD Bytes\n",c);
  2274.  
  2275.     if( dopackdata() )
  2276.     {
  2277.         printlog( "Fehler beim Packeraufruf!\n" );
  2278.         doabort = 1;
  2279.         goto bye;
  2280.     }
  2281.  
  2282.     sendbytes=d=getfilelen(sendfilename); if(d<1) d=1;
  2283.     e = 100-((d*100)/c);
  2284.     if( e<0 || e>100) e = 0;
  2285.     conprintf(" -> %lD Bytes (%ld%%)\n", d, e);
  2286.     printlog("Ausgehende Daten gepackt..: %lD Bytes (%ld%%)\n",d,e);
  2287.  
  2288.     ClearPointer( twindow );
  2289.  
  2290.     for(c=0; c<dialnum && doabort<2; c++)
  2291.     {
  2292.         allowpw = FALSE;
  2293.         if( c )
  2294.         {
  2295.             int sq = FALSE;
  2296.             int tq = FALSE;
  2297.  
  2298.             putrb( 'X' );
  2299.  
  2300.             iow.IOSer.io_Command = CMD_CLEAR;
  2301.             DoIO( &iow );
  2302.  
  2303.             AbortIO( &ior );
  2304.             WaitIO( &ior );
  2305.  
  2306.             for( d = prefs.retrydelay; d > 0; )
  2307.             {
  2308.                 conprintf("Warte %ld Sekunden... \r",d);
  2309.  
  2310.                 if( !tq )
  2311.                 {
  2312.                     qtimer();
  2313.                     tq = TRUE;
  2314.                 }
  2315.  
  2316.                 if( !sq )
  2317.                 {
  2318.                     ior.IOSer.io_Data = &srch;
  2319.                     ior.IOSer.io_Length = 1;
  2320.                     ior.IOSer.io_Command = CMD_READ;
  2321.                     SendIO( &ior );
  2322.                     sq = TRUE;
  2323.                 }
  2324.  
  2325.                 sigs = mWait( csig | wsig | tsig | ssig | SIGBREAKF_CTRL_E );
  2326.                 if( sigs & wsig )
  2327.                 {
  2328.                     im = (struct IntuiMessage *)GetMsg( twindow->UserPort );
  2329.                     if( im )
  2330.                         ReplyMsg( im );
  2331.                     break;
  2332.                 }
  2333.  
  2334.                 if( sigs & SIGBREAKF_CTRL_E )
  2335.                     break;
  2336.  
  2337.                 if( sigs & csig )
  2338.                 {
  2339.                     WaitIO( &cr );
  2340.                     cr.io_Data=&crch;
  2341.                     cr.io_Length=1;
  2342.                     cr.io_Command=CMD_READ;
  2343.                     SendIO( &cr );
  2344.                     break;
  2345.                 }
  2346.  
  2347.                 if( sigs & tsig )
  2348.                 {
  2349.                     WaitIO( &tr );
  2350.                     tq = FALSE;
  2351.                     d--;
  2352.                 }
  2353.  
  2354.                 if( CheckIO( &ior ) )
  2355.                 {
  2356.                     sq = FALSE;
  2357.                     WaitIO( &ior );
  2358.                     putrb( srch );
  2359.                     if( testrb( "RING" ) )
  2360.                     {
  2361.                         conprintf( "\n[Eingehender Anruf!]\n" );
  2362.                         doabort = 2;
  2363.                         putrb( 'X' );
  2364.                         break;
  2365.                     }
  2366.                 }
  2367.  
  2368.                 if( !sq )
  2369.                 {
  2370.                     ior.IOSer.io_Data = &srch;
  2371.                     ior.IOSer.io_Length = 1;
  2372.                     ior.IOSer.io_Command = CMD_READ;
  2373.                     SendIO( &ior );
  2374.                     sq = TRUE;
  2375.                 }
  2376.             }
  2377.  
  2378.             if( !sq )
  2379.             {
  2380.                 ior.IOSer.io_Data = &srch;
  2381.                 ior.IOSer.io_Length = 1;
  2382.                 ior.IOSer.io_Command = CMD_READ;
  2383.                 SendIO( &ior );
  2384.                 sq = TRUE;
  2385.             }
  2386.  
  2387.             if( tq )
  2388.             {
  2389.                 AbortIO( &tr);
  2390.                 WaitIO( &tr );
  2391.                 tq = FALSE;
  2392.             }
  2393.         }
  2394.  
  2395.         if( doabort == 2 )
  2396.             break;
  2397.  
  2398.         connectlen = 0;
  2399.         p=getphone(c);
  2400.         conprintf("\rAnwahlversuch %ld bei %s; noch %ld Versuche...",c+1,p,dialnum-c-1);
  2401.         addlogfile( "NETCALL WΣhle %s", p );
  2402.         Delay(25);
  2403.         iow.IOSer.io_Command = CMD_CLEAR;
  2404.         DoIO(&iow);
  2405.         sendat( prefs.modemdial );
  2406.         sendat( p );
  2407.         sendat( "|" );
  2408.         timeout=prefs.dialtimeout; connect=0; isarcing=0; doabort=0; showdata=0;
  2409.         qtimer();
  2410.  
  2411.         quietsecs = 0;
  2412.  
  2413.         while( timeout && isarcing != 2 )
  2414.         {
  2415.             sigs = mWait( ssig | csig | wsig | tsig | SIGBREAKF_CTRL_E );
  2416.             if(sigs&wsig) while((im=(struct IntuiMessage*)GetMsg(twindow->UserPort)))
  2417.             {
  2418.                 if(im->Class==IDCMP_MENUHELP) { domenuhelp("netcall",im); ReplyMsg(im); }
  2419.                 else if( im->Class == IDCMP_CLOSEWINDOW )
  2420.                 {
  2421.                     ReplyMsg( im );
  2422.                     timeout = 0;
  2423.                     doabort = 2;
  2424.                 }
  2425.                 else if( im->Class == IDCMP_NEWSIZE )
  2426.                 {
  2427.                     ReplyMsg( im );
  2428.                     conresize();
  2429.                 }
  2430.                 else if( im->Class == IDCMP_REFRESHWINDOW )
  2431.                 {
  2432.                     ReplyMsg( im );
  2433.                     BeginRefresh( w );
  2434.                     EndRefresh( w, TRUE );
  2435.                 }
  2436.                 else if( im->Class == IDCMP_MENUPICK )
  2437.                 {
  2438.                     if( !MENUNUM( im->Code ) )
  2439.                     {
  2440.                         itemnum=ITEMNUM(im->Code);
  2441.                         ReplyMsg(im);
  2442.                         switch(itemnum)
  2443.                         {
  2444.                             case 0: timeout=0;
  2445.                                 doabort=1;
  2446.                                 break;
  2447.                             case 2: timeout=0; doabort=2;
  2448.                                 break;
  2449.                         }
  2450.                     }
  2451.                 }
  2452.                 else ReplyMsg( im );
  2453.             }
  2454.             if( CheckIO( &cr ) )
  2455.             {
  2456.                 WaitIO(&cr);
  2457.                 if(crch==' ') { timeout=0; doabort=1; }
  2458.                 else if(crch==27) { timeout=0; doabort=2; }
  2459.                 SendIO(&cr);
  2460.             }
  2461.             if( sigs & SIGBREAKF_CTRL_E )
  2462.             {
  2463.                 if( !connect )
  2464.                 {
  2465.                     timeout = 0;
  2466.                     doabort = 2;
  2467.                 }
  2468.             }
  2469.             if( CheckIO( &ior ) )
  2470.             {
  2471.                 WaitIO( &ior );
  2472.                 if(showdata==1)
  2473.                 {
  2474.                     srch=ibm2iso(srch);
  2475.                     cw.io_Command=CMD_WRITE;
  2476.                     cw.io_Data=&srch;
  2477.                     cw.io_Length=1;
  2478.                     DoIO(&cw);
  2479.                 }
  2480.                 if( connect == 2 )
  2481.                 {
  2482.                     connectstring[áconnectlen++ ]á= srch;
  2483.                     connectstring[áconnectlen ]á= 0;
  2484.                     if( connectlen > 30 || srch == '\n'á|| srch == '\r'á)
  2485.                     {
  2486.                         connect = 1;
  2487.                         linespeed = atoi( connectstring );
  2488.                     }
  2489.                 }
  2490.  
  2491.                 putrb7(srch);
  2492.                 ior.IOSer.io_Data=&srch;
  2493.                 ior.IOSer.io_Length=1;
  2494.                 ior.IOSer.io_Command=CMD_READ;
  2495.                 BeginIO(&ior);
  2496.                 quietsecs = 0;
  2497.             }
  2498.  
  2499.             if( CheckIO( &tr ) )
  2500.             {
  2501.                 /*AbortIO(&tr);*/
  2502.                 WaitIO(&tr);
  2503.                 qtimer();
  2504.                 quietsecs++;
  2505.                 if( timeout )
  2506.                     timeout--;
  2507.                 if(!showdata) conprintf("%02ld:%02ld\x1b[5\x44",TM(timeout),TS(timeout));
  2508.             }
  2509.             if( connect == 1 )
  2510.             {
  2511.                 if(testrb("nocarrier")) { time(&thangup); connect=0; doabort=2; break; }
  2512.                 else if( ( quietsecs > 1 ) && ( testrb("username:") || testrb("login:") ) ) { putrb( 0 ); serialclear(); serputs( ISN38 ? "ZERBERUS" : loginstring); showdata=2; conprintf("\rUsername...\n"); }
  2513.                 else if( ( testrb("systemname:"))) { putrb( 0 ); serputs(prefs.pointname); conprintf("Systemname...\n"); allowpw = TRUE; }
  2514.                 else if( ( testrb("pressESCtwice"))) { putrb( 0 ); serputs( "\033\033" ); conprintf("Fido-Mailer-Kennung [2xESC] geschickt.\n"); }
  2515.                 else if( allowpw && ( testrb("passwort:") || testrb("password:"))) { putrb( 0 ); serputs(prefs.password); conprintf("Passwort...\n"); }
  2516.                 else if(!isarcing && testrb("runningarc")) {
  2517.                     conprintf("Box packt Daten: ");
  2518.                     isarcing=1;
  2519.                     showdata=0;
  2520.                     timeout=prefs.packtimeout;
  2521.                 }
  2522.                 else if(testrb("\x15")) {
  2523.                     sendzeros();
  2524.                 }
  2525.                 else if(testrb("\x6")) {
  2526.                     long t=prefs.packtimeout-timeout;
  2527.                     printlog("Packzeit..................: %02ld:%02ld:%02ld\n",
  2528.                         TH(t),TM(t),TS(t));
  2529.                     isarcing=2;
  2530.                 }
  2531.                 else if( !isarcing && quietsecs > 10 )
  2532.                 {
  2533.                     serputs( "" );
  2534.                 }
  2535.             }
  2536.             else
  2537.             {
  2538.                 if(testrb("nocarrier") || testrb("nodial") || testrb("diallocked"))
  2539.                 {
  2540.                     conprintf("Anwahlversuch gescheitert!\n");
  2541.                     timeout=0;
  2542.                     doabort=4;
  2543.                 }
  2544.                 else if(testrb("busy"))
  2545.                 {
  2546.                     conprintf("Box ist besetzt!\n");
  2547.                     timeout=0;
  2548.                     doabort=4;
  2549.                 }
  2550.                 else if( testrb( "CONNECT" ) && !connect )
  2551.                 {
  2552.                     timeout=prefs.dialtimeout;
  2553.                     connect=2;
  2554.                     time(&tconnect);
  2555.                     printlog( "Ben÷tigte Anwahlversuche..: %ld\n", c + 1 );
  2556.                     printlog( "Verbindung hergestellt....: %s\n", dat2str( time( 0 ) ) );
  2557.                     conprintf("Verbindung hergestellt\nLogin...\n");
  2558.                     conprint("\nCONNECT");
  2559.                     addlogfile( "NETCALL Verbindung hergestellt" );
  2560.                     showdata=1;
  2561.  
  2562.                     if( prefs.flags2 & MDF2_BREAKLOGIN )
  2563.                     {
  2564.                         sendx();
  2565.                         serputs( "" );
  2566.                     }
  2567.                 }
  2568.             }
  2569.         }
  2570.  
  2571.         AbortIO(&tr);
  2572.         WaitIO(&tr);
  2573.  
  2574.         /* Transfer ok? */
  2575.         if( isarcing == 2 )
  2576.         {
  2577.             /* Hydra? */
  2578.             if( prefs.pointxfer == 2 )
  2579.             {
  2580.                 int rc;
  2581.                 struct List hxsl;
  2582.                 struct tempsendnode {
  2583.                     struct MinNode n;
  2584.                     char file[á128 ];
  2585.                 } dummy;
  2586.  
  2587.                 strcpy( dummy.file, sendfilename );
  2588.                 NewList( &hxsl );
  2589.                 AddTail( &hxsl, &dummy );
  2590.  
  2591.                 time( &t );
  2592.                 AbortIO(&ior);
  2593.                 WaitIO(&ior);
  2594.                 AbortIO(&cr);
  2595.                 WaitIO(&cr);
  2596.                 download = "";
  2597.                 rc = hydra_xfer( &hxsl );
  2598.                 ior.IOSer.io_Data=&srch;
  2599.                 ior.IOSer.io_Length=1;
  2600.                 ior.IOSer.io_Command=CMD_READ;
  2601.                 BeginIO( &ior );
  2602.                 cr.io_Data=&crch;
  2603.                 cr.io_Length=1;
  2604.                 cr.io_Command=CMD_READ;
  2605.                 BeginIO( &cr );
  2606.  
  2607.                 sendtime = time( 0 ) - t;
  2608.                 if( sendtime < 1 )
  2609.                     sendtime = 1;
  2610.                 DeleteFile( sendfilename );
  2611.  
  2612.                 if( rc < 1 )
  2613.                 {
  2614.                     conprintf("Transfer fehlgeschlagen!\n\x07");
  2615.                     printlog("Transfer fehlgeschlagen!\n");
  2616.                     doabort=2;
  2617.                 }
  2618.                 else
  2619.                 {
  2620.                     char *p = gotfilename;
  2621.  
  2622.                     addlogfile( "NETCALL %ld Bytes gesendet (%lds)", sendbytes, sendtime );
  2623.                     conprintf("ok; %02ld:%02ld:%02ld, %lD cps\n",TH(sendtime),TM(sendtime),TS(sendtime),sendbytes/sendtime);
  2624.                     makefilelist( "", "#?", gotfilename, 4096 );
  2625.                     while( *p )
  2626.                     {
  2627.                         recbytes = getfilelen( p );
  2628.                         conprintf("Empfangen: %s, %lD Bytes, %lD cps\n", p, recbytes, recbytes / sendtime );
  2629.                         addlogfile( "NETCALL %ld Bytes empfangen [%s] (0s)", recbytes, p );
  2630.                         p = strchr( p, 0 ) + 1;
  2631.                     }
  2632.                     doabort=3;
  2633.                 }
  2634.             }
  2635.             else
  2636.             {
  2637.                 AbortIO(&ior);
  2638.                 WaitIO(&ior);
  2639.                 iow.IOSer.io_Command=CMD_CLEAR;
  2640.                 DoIO(&iow);
  2641.                 conprintf("\nSende Daten (%lD Bytes)...",sendbytes);
  2642.                 time(&t);
  2643.                 filearray[0]=sendfilename; filearray[1]=NULL;
  2644.                 setzmodemmode( prefs.pointxfer );
  2645.                 d=xpr_send(&ior,&iow,-1,filearray);
  2646.                 sendtime=time(0)-t;
  2647.                 if(sendtime<1) sendtime=1;
  2648.                 DeleteFile(sendfilename);
  2649.                 if(!d)
  2650.                 {
  2651.                     conprintf("Senden fehlgeschlagen!\n\x07");
  2652.                     printlog("Senden fehlgeschlagen!\n");
  2653.                     doabort=2;
  2654.                 }
  2655.                 else
  2656.                 {
  2657.                     conprintf("ok; %02ld:%02ld:%02ld, %lD cps\nEmpfange Daten...",TH(sendtime),TM(sendtime),TS(sendtime),sendbytes/sendtime);
  2658.                     printlog("Sende Daten...............: %lD Byte, %02ld:%02ld:%02ld, %lD cps\n",sendbytes,TH(sendtime),TM(sendtime),TS(sendtime),sendbytes/sendtime);
  2659.                     addlogfile( "NETCALL %ld Bytes gesendet (%lds)", sendbytes, sendtime );
  2660.                     strcpy(gotfilename,prefs.transferdir);
  2661.                     addpart(gotfilename,"called.lzh");
  2662.                     time(&t);
  2663.  
  2664.                     d = xpr_receive( &ior, &iow, -1 );
  2665.                     makefilelist( "", "#?", gotfilename, 4096 );
  2666.                     rectime = time( 0 ) - t; 
  2667.                     if( rectime < 1 )
  2668.                         rectime=1;
  2669.                     if( !d && !( prefs.flags2 & MDF2_JANUS2 ) )
  2670.                     {
  2671.                         if( netcall_resume )
  2672.                             SetProtection( gotfilename, FIBF_DELETE );
  2673.  
  2674.                         conprintf("Empfang fehlgeschlagen!\n\x07");
  2675.                         printlog("Empfang fehlgeschlagen!\n");
  2676.                         doabort=2;
  2677.                     }
  2678.                     else
  2679.                     {
  2680.                         char *p = gotfilename;
  2681.  
  2682.                         doabort = 2;
  2683.                         while( *p )
  2684.                         {
  2685.                             SetProtection( p, 0 );
  2686.                             recbytes=getfilelen( p );
  2687.                             conprintf("%s, %lD Bytes, %02ld:%02ld:%02ld, %lD cps\n",
  2688.                                 p, recbytes,TH(rectime),TM(rectime),TS(rectime),recbytes/rectime);
  2689.                             addlogfile( "NETCALL %ld Bytes empfangen [%s] (%lds)", recbytes, p, rectime );
  2690.                             printlog("Empfange Daten............: %s, %lD Bytes, %02ld:%02ld:%02ld, %lD cps\n",
  2691.                                 p, recbytes,TH(rectime),TM(rectime),TS(rectime),recbytes/rectime);
  2692.                             doabort=3;
  2693.                             p = strchr( p, 0 ) + 1;
  2694.                         }
  2695.                     }
  2696.                 }
  2697.             }
  2698.             ior.IOSer.io_Command=CMD_CLEAR;
  2699.             BeginIO(&ior);
  2700.         }
  2701. aborting:
  2702.         if(doabort && doabort<3)
  2703.         {
  2704.             if(doabort==2) printlog("Netcall abgebrochen!\n");
  2705.             conprintf("abgebrochen!\n");
  2706.         }
  2707.         if(doabort==4) doabort=1;
  2708.         if(!timeout && !doabort) {
  2709.             printlog("Timeout!\n");
  2710.             conprintf("Timeout!\n");
  2711.         }
  2712.         
  2713.         if(connect)
  2714.         {
  2715.             conprintf("Auflegen...\n");
  2716.             hangup();
  2717.             time(&thangup);
  2718.         }
  2719.         else
  2720.             sendat("\r");
  2721.     }
  2722.  
  2723.     if(tconnect)
  2724.     {
  2725.         tconnect=thangup-tconnect;
  2726.         conprintf("Verbindungsdauer %02ld:%02ld:%02ld\n",TH(tconnect),TM(tconnect),TS(tconnect));
  2727.         printlog("Gesamtverbindungsdauer....: %02ld:%02ld:%02ld\n",TH(tconnect),TM(tconnect),TS(tconnect));
  2728.  
  2729.         addlogfile( "NETCALL %s (%lds gesamte Verbindungsdauer)",
  2730.                 ( doabort == 3 ) ? "erfolgreich" : "fehlgeschlagen",
  2731.                 tconnect
  2732.         );
  2733.  
  2734.     }
  2735.     if(doabort==3)
  2736.     {
  2737.         conprintf("\n\nNetcall erfolgreich beendet.\n");
  2738.         printlog("\nNetcall erfolgreich beendet.\n\n");
  2739.     }
  2740.  
  2741. bye:
  2742.  
  2743.     AbortIO(&cr);
  2744.     WaitIO(&cr);
  2745.  
  2746.     AbortIO(&ior);
  2747.     WaitIO(&ior);
  2748.  
  2749.     popdir();
  2750.  
  2751.     if(doabort==3)
  2752.     {
  2753.         conprintf("Entpacke Daten...\n");
  2754.         if( unpackdata() )
  2755.             doabort = 1;
  2756.     }
  2757.     closelogmsg();
  2758.  
  2759.     ClearMenuStrip(twindow);
  2760.  
  2761.     exitser();
  2762.     exitconsole();
  2763.  
  2764.     treport(0,0,""); treport(1,0,"");
  2765.  
  2766.     return((doabort==3)?0:-1);
  2767. }
  2768.  
  2769. static int syscopyfile(char *from,char *to,struct ogwin *ogw, ULONG id)
  2770. {
  2771.     long len=getfilelen(from);
  2772.     BPTR f1,f2;
  2773.     void *buffer;
  2774.     long blen;
  2775.     int rc;
  2776.     int fulllen = len;
  2777.     int maxbufsize = max( prefs.sm_copybuf * 1024, 1024 );
  2778.  
  2779.     if(len<0) return(IoErr());
  2780.     f1 = Open( from, MODE_OLDFILE );
  2781.     if(!f1) return(IoErr());
  2782.     f2 = Open( to, MODE_NEWFILE );
  2783.     if(!f2)
  2784.     {
  2785.         rc=IoErr();
  2786.         Close(f1);
  2787.         return(rc);
  2788.     }
  2789.  
  2790.     ogreSetMaxVal( ogw, id, len );
  2791.     ogreSetValue( ogw, id, 0 );
  2792.  
  2793.     blen = min( len, AvailMem( MEMF_LARGEST ) / 2 );
  2794.     blen = min( blen, maxbufsize );
  2795.     for( ;; )
  2796.     {
  2797.         buffer = AllocMem( blen, 0 );
  2798.         if( buffer )
  2799.             break;
  2800.         blen /= 2;
  2801.     }
  2802.  
  2803.     while( len > 0 )
  2804.     {
  2805.         rc = Read( f1, buffer, blen );
  2806.         if( rc < 1 )
  2807.             break;
  2808.         Write( f2, buffer, rc );
  2809.         len -= rc;
  2810.         ogreSetValue( ogw, id, fulllen - len );
  2811.     }
  2812.  
  2813.     FreeMem( buffer, blen );
  2814.     Close( f1 );
  2815.     Close( f2 );
  2816.  
  2817.     return( 0 );
  2818. }
  2819.  
  2820. static int sysmovefile( char *from, char *to, struct ogwin *ogw, ULONG id )
  2821. {
  2822.     int rc;
  2823.  
  2824.     DeleteFile( to );
  2825.     if( Rename( from, to ) )
  2826.     {
  2827.         ogreSetValue( ogw, id, 1 );
  2828.         return( 0 );
  2829.     }
  2830.     rc = IoErr();
  2831.     if( rc != ERROR_RENAME_ACROSS_DEVICES )
  2832.         return( rc );
  2833.     rc = syscopyfile( from, to, ogw, id );
  2834.     if( rc )
  2835.         return( rc );
  2836.     while( !DeleteFile( from ) )
  2837.     {
  2838.         rc = IoErr();
  2839.  
  2840.         if( rc == ERROR_OBJECT_NOT_FOUND )
  2841.             break;
  2842.         if( !askreq( "Fehler beim Sysop-Mode-Import: Importdatei\n%s\nkonnte nicht gel÷scht werden (%ld)", "Wiederholen|Abbruch", from, rc ) )
  2843.             return( ERROR_BREAK );
  2844.     }
  2845.     return( 0 );
  2846. }
  2847.  
  2848. static void addtolog( char *file )
  2849. {
  2850.     char buffer[á256 ];
  2851.     struct AsyncFile *f = OpenAsync( file, MODE_READ, 2048 );
  2852.  
  2853.     if( !f )
  2854.     {
  2855.         printlog( "Datei %s existiert nicht.\n", file );
  2856.         return;
  2857.     }
  2858.  
  2859.     while( FGetsAsync( f, buffer, 256 ) )
  2860.     {
  2861.         printlog( "%s", buffer );
  2862.     }
  2863.     CloseAsync( f );
  2864.     DeleteFile( file );
  2865. }
  2866.  
  2867. #ifndef NO_RFC
  2868. static int donetcall_rfc( void )
  2869. {
  2870.     BPTR f = OpenCon( prefs.rfc_cicocon );
  2871.     char exec[á256 ];
  2872.     struct DosList *old_uuspool, *old_uulib, *dl;
  2873.     BPTR lock;
  2874.     int rc;
  2875.     char cicofullpath[ 256 ], *p;
  2876.  
  2877.     if( !checkprograminpathfull( "UUCICO", cicofullpath ) )
  2878.     {
  2879.             askreq( "\"UUCICO\" nicht gefunden!\nDas Program \"UUCICO\" mu▀ im Pfad liegen und\naufrufbar sein!", "Abbruch" );
  2880.             return( 1 );
  2881.     }
  2882.  
  2883.     sprintf(exec,"Netcall %s",dat2str(time(0)));
  2884.     openlogmsg(exec);
  2885.     printlog("Netcall bei der '%s' am %s\n\n",prefs.boxname,dat2str(time(0)));
  2886.  
  2887.     dl =  LockDosList( LDF_ASSIGNS | LDF_WRITE );
  2888.     old_uuspool = FindDosEntry( dl, "UUSPOOL", LDF_ASSIGNS );
  2889.     if( old_uuspool )
  2890.         RemDosEntry( old_uuspool );
  2891.     old_uulib = FindDosEntry( dl, "UULIB", LDF_ASSIGNS );
  2892.     if( old_uulib )
  2893.         RemDosEntry( old_uulib );
  2894.     UnLockDosList( LDF_ASSIGNS | LDF_WRITE );
  2895.  
  2896.     UnLock( CreateDir( "T:mduutmp" ) );
  2897.     lock = Lock( "T:mduutmp", SHARED_LOCK );
  2898.     AssignLock( "UULIB", lock );
  2899.     lock = Lock( prefs.transferdir, SHARED_LOCK );
  2900.     AssignLock( "UUSPOOL", lock );
  2901.  
  2902.     /* T-Files generieren */
  2903.     lock = Open( "UULIB:config", MODE_NEWFILE );
  2904.     FPrintf( lock, "NodeName\t%s\nUsername\t%s\nRealname\t%s\nDebug\t5\n",
  2905.         prefs.pointname,
  2906.         prefs.username,
  2907.         prefs.userrealname
  2908.     );
  2909.     Close( lock );
  2910.     lock = Open( "UULIB:L.sys", MODE_NEWFILE );
  2911.  
  2912.     // generieren...
  2913.     stccpy( exec, prefs.phone, sizeof( exec ) );
  2914.  
  2915.     for( p = strtok( exec, "  \t" ); p; p = strtok( NULL, "  \t" ) )
  2916.     {
  2917.         FPrintf( lock, "%s Any Ser: %ld %s%s %s\n",
  2918.             prefs.boxname,
  2919.             prefs.modembaud,
  2920.             prefs.modemdial,
  2921.             p,
  2922.             prefs.rfc_login
  2923.         );
  2924.     }
  2925.     Close( lock );
  2926.  
  2927.     /* Nun CICO aufrufen */
  2928.     sprintf( exec, "%s -D %s -U %ld %s%s%s%s -q -s%s",
  2929.         cicofullpath,
  2930.         prefs.modemdevice,
  2931.         prefs.modemunit,
  2932.         prefs.modemflags & 8 ? "-h0 " : "",
  2933.         prefs.modemflags & 1 ? "-7 " : "",
  2934.         prefs.modem_dropdtr ? "" : "-d0 ",
  2935.         prefs.rfc_cicoopts,
  2936.         prefs.boxname
  2937.     );
  2938.     FPrintf( f, "Fⁿhre aus: \x1b[1m%s\n\x1b[0m", exec );
  2939.     Flush( f );
  2940.  
  2941.     rc = SystemTags( exec,
  2942.         SYS_Output, f,
  2943.         //SYS_Output, NULL,
  2944.         NP_StackSize, 32768,
  2945.         NP_Priority, 0,
  2946.         TAG_DONE
  2947.     );
  2948.     printlog( "UUCICO-Aufruf: \"%s\", rc = %ld\n", exec, rc );
  2949.     printlog( "\nUUCICO-Logfile:\n" );
  2950.     addtolog( "UUSPOOL:Logfile" );
  2951.     if( exists( "UUSPOOL:Xferlog" ) )
  2952.     {
  2953.         printlog( "\nUUCICO-Xferlog:\n" );
  2954.         addtolog( "UUSPOOL:XferLog" );
  2955.     }
  2956.  
  2957.     // TemporΣre Assigns wieder entfernen
  2958.  
  2959.     AssignLock( "UULIB", NULL );
  2960.     AssignLock( "UUSPOOL", NULL );
  2961.  
  2962.     dl = LockDosList( LDF_ASSIGNS | LDF_WRITE );
  2963.     if( old_uuspool )
  2964.         AddDosEntry( old_uuspool );
  2965.     if( old_uulib )
  2966.         AddDosEntry( old_uulib );
  2967.     UnLockDosList( LDF_ASSIGNS | LDF_WRITE );
  2968.  
  2969.     SystemTags( "DELETE >NIL: T:mduutmp ALL QUIET", TAG_DONE );
  2970.  
  2971.     Close( f );
  2972.     closelogmsg();
  2973.  
  2974.     return( 0 );
  2975. }
  2976.  
  2977. #endif
  2978.  
  2979. #define IID_STATUS 1
  2980. #define IID_ACT 2
  2981. #define IID_FUEL 3
  2982.  
  2983. #if 0
  2984. #define AMITCP_NEW_NAMES
  2985. #define openlog foobaryx
  2986. #include <netinclude:sys/types.h>
  2987. #include <netinclude:sys/socket.h>
  2988. #include <netinclude:bsdsocket.h>
  2989. #include <netinclude:netinet/in.h>
  2990. #include <netinclude:netdb.h>
  2991. #include <constructor.h>
  2992. struct Library *SocketBase;
  2993.  
  2994. CONSTRUCTOR_P(opensock,15000)
  2995. {
  2996.     SocketBase = OldOpenLibrary( "bsdsocket.library" );
  2997.     return( 0 );
  2998. }
  2999. DESTRUCTOR_P(closesock,15000)
  3000. {
  3001.     if( SocketBase )
  3002.         CloseLibrary( SocketBase );
  3003. }
  3004.  
  3005. static int clipsaug( void )
  3006. {
  3007.     BPTR fh = Open( "CON:50/20/400/180/CLIPSAUG-Transfer/AUTO/WAIT/CLOSE/SCREEN*", MODE_NEWFILE );
  3008.     int sock;
  3009.     struct hostent *host;
  3010.     static struct sockaddr_in sockadr;
  3011.     struct loginpkt {
  3012.         char pointname[á32 ];
  3013.         char password[á28 ];
  3014.         ULONG bytes;
  3015.     } loginpkt;
  3016.     struct AsyncFile *f;
  3017.     char buffer[á2048 ];
  3018.     int len, rlen;
  3019.  
  3020.     FPrintf( fh, "CLIPSaug bei %s...\n", prefs.phone );
  3021.  
  3022.     strcpy( loginpkt.pointname, prefs.pointname );
  3023.     strcpy( loginpkt.password, prefs.password );
  3024.  
  3025.     host = GetHostByName( prefs.phone );
  3026.     if( !host )
  3027.     {
  3028.         FPrintf( fh, "Server-Adresse nicht auffindbar\n" );
  3029.         Close( fh );
  3030.         return( -1 );
  3031.     }
  3032.  
  3033.     sock = Socket( AF_INET, SOCK_STREAM, 0 );
  3034.     if( sock < 0 )
  3035.     {
  3036.         FPrintf( fh, "Socket konnte nicht erzeugt werden (%ld)!\n", Errno() );
  3037.         Close( fh );
  3038.         return( -1 );
  3039.     }
  3040.  
  3041.     sockadr.sin_len = sizeof( sockadr );
  3042.     memcpy( &sockadr.sin_addr, *host->h_addr_list, 4 );
  3043.     sockadr.sin_family = AF_INET;
  3044.     sockadr.sin_port = 5557;
  3045.  
  3046.     if( Connect( sock, &sockadr, sizeof( sockadr ) ) )
  3047.     {
  3048.         FPrintf( fh, "Connection failed! (%ld)\n", Errno() );
  3049.         CloseSocket( sock );
  3050.         Close( fh );
  3051.         return( -1 );
  3052.     }
  3053.  
  3054.     // Verbindung besteht, nun loginpkt schicken
  3055.     pushdir( prefs.transferdir );
  3056.     loginpkt.bytes = getfilelen( "PUFFER" );
  3057.     if( loginpkt.bytes < 0 )
  3058.         loginpkt.bytes = 0;
  3059.     FPrintf( fh, "Sende LoginPKT...\n" );
  3060.     Send( sock, &loginpkt, sizeof( loginpkt ), 0 );
  3061.  
  3062.     if( len = loginpkt.bytes )
  3063.     {
  3064.         f = OpenAsync( "PUFFER", MODE_READ, 16384 );
  3065.         while( loginpkt.bytes )
  3066.         {
  3067.             int rc = ReadAsync( f, buffer, 2048 );
  3068.             int rc2 = Send( sock, buffer, rc, 0 );
  3069.             if( rc != rc2 )
  3070.             {
  3071.                 FPrintf( fh, "Fehler beim Senden!\n" );
  3072.                 CloseAsync( f );
  3073.                 CloseSocket( sock );
  3074.                 Close( fh );
  3075.                 popdir();
  3076.                 return( -1 );    
  3077.             }
  3078.             loginpkt.bytes -= rc;
  3079.             FPrintf( fh, "Sende: %ld/%ld Bytes\r", len - loginpkt.bytes, len );
  3080.         }
  3081.         CloseAsync( f );
  3082.         DeleteFile( "PUFFER" );
  3083.         FPrintf( fh, "\nSenden erfolgreich abgeschlossen.\n" );
  3084.     }
  3085.  
  3086.     FPrintf( fh, "Warte auf Empfang...\n" );
  3087.     if( Recv( sock, &len, 4, 0 ) != 4 )
  3088.     {
  3089.         FPrintf( fh, "Fehler beim Handshake!\n" );
  3090.         CloseSocket( sock );
  3091.         Close( fh );
  3092.         popdir();
  3093.         return( -1 );    
  3094.  
  3095.     }
  3096.     FPrintf( fh, "Empfange %ld Bytes\n", len );
  3097.  
  3098.     if( len )
  3099.     {
  3100.         f = OpenAsync( "CALLED.LZH", MODE_WRITE, 16384 );
  3101.         rlen = len;
  3102.         while( len )
  3103.         {
  3104.             int rc = Recv( sock, buffer, 2048, 0 );
  3105.             if( rc <= 0 )
  3106.             {
  3107.                 FPrintf( fh, "Fehler beim Empfangen!\n" );
  3108.                 CloseAsync( f );
  3109.                 CloseSocket( sock );
  3110.                 Close( fh );
  3111.                 popdir();
  3112.                 return( -1 );    
  3113.             }
  3114.             WriteAsync( f, buffer, rc );
  3115.             len -= rc;
  3116.             FPrintf( fh, "Empfange: %ld/%ld Bytes\r", rlen - len, rlen );
  3117.         }
  3118.         CloseAsync( f );
  3119.     }
  3120.     FPrintf( fh, "\nCLIPSaug erfolgreich beendet.\n" );
  3121.     CloseSocket( sock );
  3122.     popdir();
  3123.     unpackdata();
  3124.     Close( fh );
  3125.     return( 0 );
  3126. }
  3127. #endif
  3128.  
  3129. int donetcall( int mode )
  3130. {
  3131.     int rc;
  3132.     char path[256];
  3133.     struct ogwin *ogw;
  3134.     struct Window *iw;
  3135.  
  3136. #if 0
  3137.     if( prefs.flags2 & MDF2_CLIPSAUG )
  3138.     {
  3139.         return( clipsaug() );
  3140.     }
  3141. #endif
  3142.  
  3143.     if(!(prefs.flags&MDF_SYSOPMODE))
  3144.     {
  3145. #ifndef NO_RFC
  3146.         if( prefs.mode == MDM_RFC )
  3147.         {
  3148.             return( donetcall_rfc() );
  3149.         }
  3150.         else
  3151.         {
  3152. #endif
  3153.             return( donetcall1( mode ) );
  3154. #ifndef NO_RFC
  3155.         }
  3156. #endif
  3157.     }
  3158.  
  3159.     addlogfile( "SYSOPMODENETCALL fⁿr %s", prefs.boxname );
  3160.  
  3161.     ogw = ogreInitWindow( scr, WFLG_RMBTRAP, 0, "Sysop-Modus Datenaustausch" );
  3162.     ogreAddGroup( ogw, 0, OGFRAME_NONE, NULL );
  3163.     ogreAddText( ogw, 0, "Status:", IID_STATUS, "", 40, 1 );
  3164.     ogreAddText( ogw, 1, "Aktion:", IID_ACT, "", 40, 1 );
  3165.     ogreAddFuelGauge( ogw, 2, IID_FUEL, 1 );
  3166.     iw = ogreOpenWindow( ogw );
  3167.     if( !iw )
  3168.         return( 0 );
  3169.  
  3170.     ogreSetStringValue( ogw, IID_ACT, "Fⁿhre Init-Befehle aus" );
  3171.     system( prefs.sm_init );
  3172.  
  3173.     pushdir( prefs.transferdir );
  3174.     if( ( rc = getfilelen("PUFFER") ) > 2 )
  3175.     {
  3176.         sprintf( path, "Exportiere Daten... (%lD Bytes)", rc );
  3177.         addlogfile( "SYSOPMODENETCALL %ld Bytes exportiert", rc );
  3178.         ogreSetStringValue( ogw, IID_STATUS, path );
  3179.         sprintf( path, prefs.sm_exportfile, prefs.counter++, 0, 0, 0, 0, 0, 0, 0 );
  3180.         if( prefs.sm_exportbefore[0] )
  3181.         {
  3182.             ogreSetStringValue( ogw, IID_ACT, "Fⁿhre Preexport-Befehle aus" );
  3183.             system( prefs.sm_exportbefore );
  3184.         }
  3185.         ogreSetStringValue( ogw, IID_ACT, "Kopiere Daten..." );
  3186.         rc = sysmovefile( "PUFFER", path, ogw, IID_FUEL );
  3187.         if( rc )
  3188.         {
  3189.             askreq( "Export fehlgeschlagen!\nFehler Nr. %ld (%s)",
  3190.                 "Abbruch",
  3191.                 rc,
  3192.                 errorstring( rc )
  3193.             );
  3194.             popdir();
  3195.             ogreExitWindow( ogw );
  3196.             return( -1 );
  3197.         }
  3198.  
  3199.         if( prefs.sm_exportafter[0] )
  3200.         {
  3201.             ogreSetStringValue( ogw, IID_ACT, "Fⁿhre Postexport-Befehle aus" );
  3202.             system( prefs.sm_exportafter );
  3203.         }
  3204.     }
  3205.     DeleteFile("PUFFER");
  3206.     if(prefs.sm_importbefore[0])
  3207.     {
  3208.         ogreSetStringValue( ogw, IID_ACT, "Fⁿhre Preimport-Befehle aus" );
  3209.         system(prefs.sm_importbefore);
  3210.     }
  3211.     rc=getfilelen(prefs.sm_importfile);
  3212.     if(rc>2) {
  3213.         sprintf( path, "Importiere Daten (%lD Bytes)", rc );
  3214.         addlogfile( "SYSOPMODENETCALL %ld Bytes importiert", rc );
  3215.         ogreSetStringValue( ogw, IID_STATUS, path );
  3216.         ogreSetStringValue( ogw, IID_ACT, "Kopiere Daten..." );
  3217.         sysmovefile(prefs.sm_importfile,"sysop_modus.import",ogw, IID_FUEL);
  3218.     }
  3219.  
  3220.     if(prefs.sm_importafter[0])
  3221.     {
  3222.         ogreSetStringValue( ogw, IID_ACT, "Fⁿhre Postimport-Befehle aus" );
  3223.         system(prefs.sm_importafter);
  3224.     }
  3225.  
  3226.     popdir();
  3227.  
  3228.     ogreExitWindow( ogw );
  3229.  
  3230.     return(0);
  3231. }
  3232.