|
|
1.1 root 1: /* $Header: XDisplayName.c,v 10.1 86/11/19 18:17:19 jg Rel $ */
2:
3: /* XDisplayName.c */
4: /*
5: * Returns the name of the display XOpenDisplay would use. This is better
6: * than just printing the "display" variable in a program because that
7: * could be NULL and/or there could be an environment variable set.
8: * This makes it easier for programmers to provide meaningful error
9: * messages.
10: *
11: *
12: * For example, this is used in XOpenDisplay() as
13: * strncpy( displaybuf, XDisplayName( display ), sizeof(displaybuf) );
14: * if ( *displaybuf == '\0' ) return( NULL );
15: * This check is actually unnecessary because the next thing is an index()
16: * call looking for a ':' which will fail and we'll return(NULL).
17: */
18: /* Written at Waterloo - JMSellens */
19:
20: #include <stdio.h>
21:
22: char *getenv();
23:
24:
25: char *
26: XDisplayName( display )
27: char *display;
28: {
29: char *d;
30: if ( display != (char *)NULL && *display != '\0' )
31: return( display );
32: if ( (d = getenv( "DISPLAY" )) != (char *)NULL )
33: return( d );
34: return( "" );
35: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.