home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / c-kermit / ckmrem.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  5KB  |  151 lines

  1. /* $Id: ckmrem.c,v 1.5 91/12/15 23:17:48 rick Exp $
  2.  * $Source: /uw/mackermit/RCS/ckmrem.c,v $
  3.  *------------------------------------------------------------------
  4.  * $Log:    ckmrem.c,v $
  5.  * Revision 1.5  91/12/15  23:17:48  rick
  6.  * ut9
  7.  * 
  8.  * Revision 1.4  91/10/13  13:44:24  rick
  9.  * UT(7)
  10.  * 
  11.  * Revision 1.3  91/10/03  12:42:59  rick
  12.  * UT(5)
  13.  * 
  14.  * Revision 1.2  91/09/25  12:17:25  rick
  15.  * Command window in TE. Multiple vt100 windows for command window.
  16.  * 
  17.  * Revision 1.3  1991/09/25  14:45:26  rick
  18.  * Multiple vt100 window support for command window.
  19.  *
  20.  * Revision 1.2  1991/09/16  17:03:14  rick
  21.  * Command window in TE
  22.  *
  23.  *------------------------------------------------------------------
  24.  * $Endlog$
  25.  */
  26.  
  27. /* Version 0.8(35) - Jim Noble at Planning Research Corporation, June 1987. */
  28. /* Ported to Megamax native Macintosh C compiler. */
  29.  
  30. /*
  31.  * file ckmrem.c
  32.  *
  33.  * Module of MacKermit containing code for remote commands and the display
  34.  * of remote commands.
  35.  *
  36.  */
  37.  
  38. /*
  39.   Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New
  40.   York.  Permission is granted to any individual or institution to use this
  41.   software as long as it is not sold for profit.  This copyright notice must be
  42.   retained.  This software may not be included in commercial products without
  43.   written permission of Columbia University.
  44. */
  45.  
  46. #include "ckcdeb.h"
  47. #include "ckcasc.h"
  48. #include "ckcker.h"
  49.  
  50. #include "ckmdef.h"        /* General Mac defs */
  51. #include "ckmres.h"        /* Resource file defs */
  52. #include "ckmwin.h"        /* common window defs */
  53. #include "ckmptp.h"            /* ckm* Prototypes */
  54.  
  55. typedef struct {
  56.     int resid;
  57.     char scode;
  58.     StringPtr name;
  59.     StringPtr hlp1;
  60.     StringPtr hlp2;
  61. }   RCMDTBL;
  62.  
  63. RCMDTBL remotecmds[] = {
  64.     {CWD_REMO, 'C', "\pCWD", "\pDirectory", "\pPassword"},
  65.     {DEL_REMO, 'E', "\pDelete", "\pFilespec", "\p"},
  66.     {DIR_REMO, 'D', "\pDirectory", "\pFilespec", "\p"},
  67.     {HELP_REMO, 'H', "\pHelp", "\pTopic", "\p"},
  68.     {HOST_REMO, ' ', "\pHost", "\pCommand", "\p"},
  69.     {SPAC_REMO, 'U', "\pSpace", "\pArea", "\p"},
  70.     {TYPE_REMO, 'T', "\pType", "\pFilespec", "\p"},
  71.     {WHO_REMO, 'W', "\pWho", "\pUser ID", "\pOptions"},
  72.     {0, 0, NULL, NULL, NULL}
  73. };
  74.  
  75.  
  76.  
  77. /****************************************************************************/
  78. /* Remote command dialog */
  79. /* remotedialog - returns FALSE if cancel hit, TRUE otherwise with */
  80. /*                    generic command setup in gstr. */
  81. /****************************************************************************/
  82. int
  83. remotedialog (rid, gstr)
  84. int rid;
  85. char *gstr;
  86. {
  87.     short itemhit;
  88.     short itemtype;
  89.     int i;
  90.     DialogPtr remoteDialog;
  91.     Handle itemhdl;
  92.     Rect itemrect;
  93.     RCMDTBL *rcmdh = (RCMDTBL *) NULL;
  94.     char arg1[256], arg2[256];
  95.  
  96.     for (i = 0; remotecmds[i].resid != 0; i++)    /* locate remote command */
  97.     if (remotecmds[i].resid == rid)    /* record for this command */
  98.         rcmdh = &remotecmds[i];    /* set our handle */
  99.  
  100.     if (rcmdh == (RCMDTBL *) NULL) {    /* find anything? */
  101.     printerr ("Can't find remote command info for ", rid);    /* ugh... */
  102.     return (FALSE);
  103.     }
  104.     remoteDialog = GetNewDialog (REMOTEBOXID, NILPTR, (WindowPtr) - 1);
  105.     circleOK(remoteDialog);
  106.     
  107.     /* setup variables */
  108.     ParamText (rcmdh->name, rcmdh->hlp1, rcmdh->hlp2, "");
  109.  
  110.     /* second argument? no, remove from screen */
  111.     if (Length (rcmdh->hlp2) == 0) {
  112.     GetDItem (remoteDialog, RRES_ARG2, &itemtype, &itemhdl, &itemrect);
  113.     if (itemtype != editText)
  114.         printerr ("RRES_ARG2 is not editText!", 0);    /* ugh now we die! */
  115.     itemtype |= itemDisable;/* disable it */
  116.     SetRect (&itemrect, 1044, 20, 1145, 116); /* off the end of our
  117.                            * world */
  118.     SetDItem (remoteDialog, RRES_ARG2, itemtype, itemhdl, &itemrect);
  119.     }
  120.     for (;;) {
  121.     ModalDialog ((ModalFilterProcPtr) NILPROC, &itemhit);
  122.     switch (itemhit) {
  123.       case OKBtn:
  124.         GetDItem (remoteDialog, RRES_ARG1, &itemtype, &itemhdl, &itemrect);
  125.         GetIText (itemhdl, arg1);
  126.         p2cstr(arg1);
  127.         GetDItem (remoteDialog, RRES_ARG2, &itemtype, &itemhdl, &itemrect);
  128.         GetIText (itemhdl, arg2);
  129.         p2cstr(arg2);
  130.         if (rid == HOST_REMO)
  131.         strcpy (gstr, arg1);
  132.         else
  133.                 /* setup the command */
  134.         ssetgen (gstr, rcmdh->scode, arg1, arg2, "");
  135.  
  136.       case QuitBtn:    /* fall through */
  137.         DisposDialog (remoteDialog);    /* all done, answer on cterm
  138.                          * screen */
  139.         if (itemhit == OKBtn) {    /* want to do the command?/ */
  140.         conoc (CR);    /* output CR to delimit */
  141.         conoll ("-----");    /* and dashes followed by CR */
  142.         rcmdwshow (rcmdw);    /* show Response window */
  143.         }
  144.         return (itemhit == OKBtn);    /* and return ok or bad... */
  145.     }
  146.     }
  147. }                /* remotedialog */
  148.  
  149.  
  150.  
  151.