home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / xgopher.1.3 / sc_telnet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-11  |  2.7 KB  |  116 lines

  1. /* sc_telnet.c
  2.    gopher item subclass procedures for telnet sessions */
  3.  
  4.      /*---------------------------------------------------------------*/
  5.      /* Xgopher        version 1.3     08 April 1993                  */
  6.      /*                version 1.2     20 November 1992               */
  7.      /*                version 1.1     20 April 1992                  */
  8.      /*                version 1.0     04 March 1992                  */
  9.      /* X window system client for the University of Minnesota        */
  10.      /*                                Internet Gopher System.        */
  11.      /* Allan Tuchman, University of Illinois at Urbana-Champaign     */
  12.      /*                Computing and Communications Services Office   */
  13.      /* Copyright 1992, 1993 by                                       */
  14.      /*           the Board of Trustees of the University of Illinois */
  15.      /* Permission is granted to freely copy and redistribute this    */
  16.      /* software with the copyright notice intact.                    */
  17.      /*---------------------------------------------------------------*/
  18.  
  19. #include "conf.h"
  20. #include "globals.h"
  21. #include "gopher.h"
  22. #include "appres.h"
  23. #include "util.h"
  24. #include "status.h"
  25. #include "subst.h"
  26. #include "sc_telnet.h"
  27. #include "sc_telnetP.h"
  28.  
  29.  
  30.  
  31. /* giveTelnetSession
  32.    provide an Xterm session running a telnet command */
  33.  
  34. static BOOLEAN
  35. giveTelnetSession(gi)
  36. gopherItemP    gi;
  37. {
  38.     char    *telnetCmd;    
  39.     char    message[MESSAGE_STRING_LEN];
  40.  
  41.  
  42.     if ((int) strlen ( appResources->telnetCommand ) <= 0 ) {
  43.         showError("Cannot execute the telnet command");
  44.         return FALSE;
  45.     }
  46.  
  47.     if (gi->host == NULL || (int) strlen ( gi->host ) <= 0 ) {
  48.         showError("There is no host to telnet to.");
  49.         return FALSE;
  50.     }
  51.  
  52.     telnetCmd = editCommand(gi, appResources->telnetCommand,
  53.              (char *) NULL, (char *) NULL);
  54.     
  55.     showStatus("starting a telnet session window", STAT_TEMP_MESSAGE,
  56.             gi->host, gi->port);
  57.     system(telnetCmd);
  58.     free (telnetCmd);
  59.  
  60.     if ((int) strlen(vStringValue(&(gi->selector))) > 0) {
  61.         sprintf(message,
  62.         "If a login name is required, try:\n\'%s\'",
  63.         vStringValue(&(gi->selector)));
  64.         showInfo(message);
  65.     }
  66.  
  67.     return TRUE;
  68. }
  69.  
  70.  
  71. /* GITelnet_init
  72.    initialize telnet session class - prefix string */
  73.  
  74. void
  75. GITelnet_init()
  76. {
  77.     GU_makePrefix(prefixTelnet,  appResources->prefixTelnet);
  78.     GU_registerNewType(A_TELNET, &telnetSubclass);
  79.  
  80.     return;
  81. }
  82.  
  83.  
  84. /* GITelnet_access
  85.    check the accessability of a telnet session item */
  86.  
  87. BOOLEAN
  88. GITelnet_access(gi)
  89. gopherItemP    gi;
  90. {
  91.     BOOLEAN    result;
  92.  
  93.     if (appResources->allowTelnet) {
  94.         result = TRUE;
  95.     }else {
  96.         result = FALSE;
  97.     }
  98.  
  99.     return result;
  100. }
  101.  
  102.  
  103. /* GITelnet_process
  104.    process a telnet session selection. */
  105.  
  106. BOOLEAN
  107. GITelnet_process(gi)
  108. gopherItemP    gi;
  109. {
  110.     BOOLEAN    result;
  111.  
  112.     result = giveTelnetSession(gi);
  113.  
  114.     return result;
  115. }
  116.