v12i100: xrlogin - X client for creating rlogin and telnet sessions, Patch1, Part01/01

William LeFebvre phil at eecs.nwu.edu
Sat May 11 12:19:52 AEST 1991


Submitted-by: phil at eecs.nwu.edu (William LeFebvre)
Posting-number: Volume 12, Issue 100
Archive-name: xrlogin/patch1
Patch-To: xrlogin: Volume 12, Issue 55

xrlogin - an X tool to create rlogin and telnet windows

This is patch1 for xrlogin, incorporating some fixes recommended by 
various people on the net.  This brings xrlogin from patchlevel 2 to
patchlevel 3.

Prereq: 2

diff -c 1.2/patchlevel.h ./patchlevel.h
*** 1.2/patchlevel.h	Thu Mar 21 16:34:45 1991
--- ./patchlevel.h	Wed Apr 24 17:45:08 1991
***************
*** 1 ****
! #define PATCHLEVEL 2
--- 1 ----
! #define PATCHLEVEL 3
diff -c 1.2/Changes ./Changes
*** 1.2/Changes	Fri May 10 18:53:14 1991
--- ./Changes	Fri May 10 18:56:05 1991
***************
*** 0 ****
--- 1,14 ----
+ Minor digit of version number (i.e.: the 3 in 1.3) is the patch level as
+ defined by patchlevel.h.
+ 
+ 1.3: patch1, 5/10/91:
+      fixes from the net:
+ 	byte order fix in cmd_connect (Melinda Shore of Cornell)
+ 	specify location of xrlogin in Imakefile (Mark McIntosh of UVic)
+ 	make location of xrlogin settable via resources and via the
+ 		command line (phil)
+ 	call perror from child if exec of xterm fails (phil)
+ 	explicitly specify font in .ad file
+ 	describe widgets in man page (jqj at duff.uoregon.edu)
+ 
+ 1.2: first complete release.
diff -c 1.2/Imakefile ./Imakefile
*** 1.2/Imakefile	Tue Feb  5 10:13:17 1991
--- ./Imakefile	Thu Apr 25 15:58:51 1991
***************
*** 8,13 ****
--- 8,18 ----
   */
  Ping = $(LIBDIR)/xrlogin/tryhost
  /*
+  * Set "Xterm" to wherever you installed xterm.  By default we assume
+  * it is in $(BINDIR).  This should work in all but the most unusual cases.
+  */
+ Xterm = $(BINDIR)/xterm
+ /*
   * If you do not want to use the "tryhost" program included in this
   * distribution, then comment out the next line.
   */
***************
*** 26,32 ****
  NormalProgramTarget(tryhost, tryhost.o, /**/, /**/, /**/)
  
  SpecialObjectRule(.o, .h, /**/)
! SpecialObjectRule(xrlogin.o, /**/, '-DDEFAULT_PING="$(Ping)"')
  
  DependTarget()
  
--- 31,37 ----
  NormalProgramTarget(tryhost, tryhost.o, /**/, /**/, /**/)
  
  SpecialObjectRule(.o, .h, /**/)
! SpecialObjectRule(xrlogin.o, /**/, -DXTERM=\"$(Xterm)\" -DDEFAULT_PING=\"$(Ping)\")
  
  DependTarget()
  
diff -c 1.2/README ./README
*** 1.2/README	Tue Feb  5 10:04:01 1991
--- ./README	Fri May 10 18:52:20 1991
***************
*** 22,28 ****
  I originally used "ping" to perform this function, but some (if not
  all) versions of "ping" keep trying in certain situations, such as
  "network is unreachable".  Xrlogin gives the system manager and the
! user the aility to choose the "ping" program through the option
  "-ping" and through the resource manager.  If the named program does
  not end with "/tryhost", then the arguments provided will be (in this
  order) hostname and timeout.  If it does end with "/tryhost", then the
--- 22,28 ----
  I originally used "ping" to perform this function, but some (if not
  all) versions of "ping" keep trying in certain situations, such as
  "network is unreachable".  Xrlogin gives the system manager and the
! user the ability to choose the "ping" program through the option
  "-ping" and through the resource manager.  If the named program does
  not end with "/tryhost", then the arguments provided will be (in this
  order) hostname and timeout.  If it does end with "/tryhost", then the
***************
*** 36,42 ****
  want to use "tryhost", then comment out the line "#define UseTryhost"
  and set "Ping" to point to the pinging program of your choice.
  
! After editing Imakefile, merely run "xmkmf" and "make install".
  
  I hope you like this program as much as I do.  Send comments, bugs,
  fixes, etc., to the address below.
--- 36,64 ----
  want to use "tryhost", then comment out the line "#define UseTryhost"
  and set "Ping" to point to the pinging program of your choice.
  
! After editing Imakefile, merely run "xmkmf" and "make install".  If
! "xmkmf" is not part of your X11 installation, then I can't be of much
! help to you.  You'll have to get it working by experimentation, I
! guess.  Any Makefile that I attempted to construct would almost
! certainly be wrong.
! 
! NOTE: This program depends on the application defaults file for
! certain defaults.  The file "XRlogin.ad" MUST be installed in the
! appropriate place for xrlogin to function correctly.  The "appropriate
! place" depends on your particular installation, but is typically the
! subdirectory named "app-defaults" in the "lib/X11" directory.  If your
! X11 installation was done correctly, then "xmkmf" and "make install"
! will take care of this for you.
! 
! If you are having problems with the appearance of the xrlogin window
! and you do not have permission to install "XRlogin.ad", then put a
! copy of the file in your home directory and call it "XRlogin" (c-shell
! users can type "cp XRlogin.ad ~/XRlogin").
! 
! NOTE: If xrlogin does absolutely nothing for you after you click
! "Connect", one possible cause might be that its attempt to execute
! "xterm" failed.  Version 1.3 attempts to write an error message to
! stderr in this situation (version 1.2 ignored the error).
  
  I hope you like this program as much as I do.  Send comments, bugs,
  fixes, etc., to the address below.
diff -c 1.2/XRlogin.ad ./XRlogin.ad
*** 1.2/XRlogin.ad	Thu Mar 21 17:20:19 1991
--- ./XRlogin.ad	Thu Apr 25 16:25:30 1991
***************
*** 16,21 ****
--- 16,27 ----
  !   hostview		Viewport
  !     hostlist		List
  
+ ! We set all fonts to 7x13bold.  All widget sizes in this file are based on
+ ! that font.  If you change the fonts, you may have to tweak some of the
+ ! other sizes.
+ 
+ *Font: 7x13bold
+ 
  *Label.borderWidth: 0
  *Toggle.shapeStyle: Rectangle
  
diff -c 1.2/xrlogin.c ./xrlogin.c
*** 1.2/xrlogin.c	Fri Mar 22 14:50:04 1991
--- ./xrlogin.c	Thu Apr 25 15:58:48 1991
***************
*** 89,95 ****
--- 89,98 ----
  	message_intid = NULL;
      }
  
+     /* copy the message in to place */
      strcpy(message_area, msg);
+ 
+     /* show it */
      XtSetValues(context->message, nargs, XtNumber(nargs));
  }
  
***************
*** 117,122 ****
--- 120,140 ----
  
  /* * * * * * * */
  
+ /*
+  *  basename(str) - return just the filename portion of the given path name
+  */
+ 
+ char *basename(str)
+ 
+ char *str;
+ 
+ {
+     register char *ptr;
+ 
+     ptr = rindex(str, '/');
+     return(ptr == NULL ? str : ptr+1);
+ }
+ 
  char *tryhost(name, ipaddr, timeout, ping)
  
  char *name;
***************
*** 216,222 ****
      char *reach;
      char *cmd;
      unsigned int addrparts[4];
!     unsigned int address;
      char *opt1 = NULL;         /* optional argument to xterm */
      char *opt2 = NULL;         /* optional argument to xterm */
      static String str;
--- 234,240 ----
      char *reach;
      char *cmd;
      unsigned int addrparts[4];
!     unsigned long address;
      char *opt1 = NULL;         /* optional argument to xterm */
      char *opt2 = NULL;         /* optional argument to xterm */
      static String str;
***************
*** 287,292 ****
--- 305,314 ----
  	}
  	bcopy(hent->h_addr_list[0], &address, IP_ADDR_LEN);
  
+ 	/* gethostbyname gives addresses in network byte order */
+ 	/* convert to host's order */
+ 	address = ntohl(address);
+ 
  	/* if rlogin, get and use username */
  	if (isrlogin)
  	{
***************
*** 311,323 ****
      }
      else     /* everything is okay, initiate a connection */
      {
! 	if (vfork() == 0)
  	{
  	    /* child */
! 	    execl("/usr/bin/X11/xterm", "xterm",
  		  "-T", name,
  		  "-e", cmd, name, opt1, opt2, 0);
! 	    _exit(100);
  	}
  
  	/* set the message to expire */
--- 333,347 ----
      }
      else     /* everything is okay, initiate a connection */
      {
! 	/* fork is necessary because we may have to use a stdio buffer */
! 	if (fork() == 0)
  	{
  	    /* child */
! 	    execl(app_data.emulator, basename(app_data.emulator),
  		  "-T", name,
  		  "-e", cmd, name, opt1, opt2, 0);
! 	    perror(app_data.emulator);
! 	    exit(100);
  	}
  
  	/* set the message to expire */
***************
*** 546,551 ****
--- 570,582 ----
  			      XtNumber(resources),
  			      NULL, ZERO);
  
+     /* make sure that the file named as emulator is present */
+     if (access(app_data.emulator, 1) == -1)
+     {
+ 	perror(app_data.emulator);
+ 	exit(2);
+     }
+     
      /* build the hosts list from the file in the home directory */
      hosts = build_hosts_list(app_data.hostfile);
  
***************
*** 608,617 ****
  	/* create the viewport (with scrollbar) */
  	wg_hostview = XtVaCreateManagedWidget("hostview",
  					      viewportWidgetClass, wg_form,
- #ifdef notdef
- 					      XtNfromHoriz, (XtArgVal)wg_message,
- 					      XtNfromVert, (XtArgVal)wg_host,
- #endif
  					      XtNallowVert, (XtArgVal)True,
  					      NULL);
  
--- 639,644 ----
***************
*** 667,672 ****
  xrlogin version %d.%d, Copyright (c) 1991 by William LeFebvre,\n\
  xrlogin understands all X toolkit options plus:\n\
  \t-hostfile file     file containing popular host names\n\
! \t-timeout time      time to wait for remote end to answer\n",
  	    VERSION, PATCHLEVEL);
  }
--- 694,701 ----
  xrlogin version %d.%d, Copyright (c) 1991 by William LeFebvre,\n\
  xrlogin understands all X toolkit options plus:\n\
  \t-hostfile file     file containing popular host names\n\
! \t-timeout time      time to wait for remote end to answer\n\
! \t-ping file         program to test for remote host connectivity\n\
! \t-emulator file     terminal emulator program (xterm)\n",
  	    VERSION, PATCHLEVEL);
  }
diff -c 1.2/xrlogin.h ./xrlogin.h
*** 1.2/xrlogin.h	Mon Feb  4 16:58:04 1991
--- ./xrlogin.h	Thu Apr 25 15:58:49 1991
***************
*** 1,8 ****
--- 1,16 ----
  /* xrlogin.h - include file for xrlogin */
  
+ 
+ /* if XTERM is not defined, assume it is in /usr/bin/X11/xterm */
+ /* XTERM is the default for the resource "emulator" */
+ #ifndef XTERM
+ #define XTERM "/usr/bin/X11/xterm"
+ #endif XTERM
+ 
  typedef struct {
      String hostfile;
      String ping;
+     String emulator;
      int timeout;
  } AppData, *AppDataPtr;
  
***************
*** 26,31 ****
--- 34,48 ----
  	DEFAULT_PING
      },
      {
+ 	"emulator",
+ 	"Emulator",
+ 	XtRString,
+ 	sizeof(String),
+ 	XtOffset(AppDataPtr, emulator),
+ 	XtRString,
+ 	XTERM
+     },
+     {
  	"timeout",
  	"Timeout",
  	XtRInt,
***************
*** 39,43 ****
--- 56,61 ----
  static XrmOptionDescRec options[] = {
      {"-hostfile", "*hostfile", XrmoptionSepArg, NULL},
      {"-ping", "*ping", XrmoptionSepArg, NULL},
+     {"-emulator", "*emulator", XrmoptionSepArg, NULL},
      {"-timeout", "*timeout", XrmoptionSepArg, NULL}
  };
diff -c 1.2/xrlogin.man ./xrlogin.man
*** 1.2/xrlogin.man	Mon Feb  4 17:30:44 1991
--- ./xrlogin.man	Thu Apr 25 16:12:15 1991
***************
*** 53,58 ****
--- 53,68 ----
  to attempt to reach the machine.  If no answer is received in that
  time, ping will declare the machine down.  The default is 5.
  .TP
+ .B \-emulator
+ Specifies the program to use as the terminal emulator.  The default is
+ .IR xterm ,
+ wherever it happens to be installed.  Whatever program is named here
+ must be prepared to take xterm-style arguments, specifically
+ .B -T
+ to specify a title and
+ .B -e
+ to specify a command to execute.
+ .TP
  .B \-ping
  Specifies the program to use to check for connectivity.  It usually
  defaults to something called
***************
*** 63,68 ****
--- 73,97 ----
  arguments:  a host name and an integer timeout value (in that order).
  It should exit with a non-zero status and a message on standard error
  if it detected that something was amiss.
+ .SH WIDGETS
+ The following widgets are created and used by
+ .IR xrlogin .  For further information, consult the applications default
+ file.
+ .DT
+ Name	Class
+ form	Form
+   label	Label
+   host	AsciiText
+   message	Label
+   type	Label
+   telnet	Toggle
+   rlogin	Toggle
+   username	Label
+   user	AsciiText
+   quit	Command
+   connect	Command
+   hostview	Viewport
+     hostlist	List
  .SH AUTHOR
  William LeFebvre, Northwestern University
  .SH FILES
***************
*** 75,77 ****
--- 104,119 ----
  .IR rlogin (1),
  .IR telnet (1),
  .IR ping (8).
+ .SH BUGS
+ Not really a bug, but one should be able to specify the format of
+ the emulator's command line.  This way one could substitute the 
+ emulator of choice (cmdtool or shelltool, for example).
+ 
+ The hostfile should also allow one to specify an alternate username.
+ 
+ If the emulator can't be executed for some reason, an error message is
+ written to stderr rather than nicely displayed in the xrlogin window.
+ 
+ Many people have recommended different types of information that could
+ be give in the hostfile.  I'm thinking about it.
+ 

--
Dan Heller
O'Reilly && Associates       Z-Code Software    Comp-sources-x:
Senior Writer                President          comp-sources.x at uunet.uu.net
argv at ora.com                 argv at zipcode.com



More information about the Comp.sources.x mailing list