/* $XConsortium: XDisName.c,v 11.4 88/09/06 16:06:28 jim Exp $ */

/* XDisplayName.c */

/*
 * Returns the name of the display XOpenDisplay would use.  This is better
 * than just printing the "display" variable in a program because that could
 * be NULL and/or there could be an environment variable set. This makes it
 * easier for programmers to provide meaningful error messages.
 * 
 * 
 * For example, this is used in XOpenDisplay() as strncpy( displaybuf,
 * XDisplayName( display ), sizeof(displaybuf) ); if ( *displaybuf == '\0' )
 * return( NULL ); This check is actually unnecessary because the next thing
 * is an index() call looking for a ':' which will fail and we'll
 * return(NULL).
 */
/* Written at Waterloo - JMSellens */

#include <stdio.h>

char *getenv ();


char *
XDisplayName (display)
  char *display;
{
  char *d;
  if (display != (char *) NULL && *display != '\0')
    return (display);
  if ((d = getenv ("DISPLAY")) != (char *) NULL)
    return (d);
  return ("");
}
