comparison src/xterm.c @ 5737:eb722251d156

(x_term_init): Use get_system_name instead of gethostname.
author Karl Heuer <kwzh@gnu.org>
date Wed, 02 Feb 1994 06:32:28 +0000
parents d3074ff90741
children 48da4ed089e9
comparison
equal deleted inserted replaced
5736:6f199038b06d 5737:eb722251d156
5192 Check the DISPLAY environment variable or use \"-d\"\n", 5192 Check the DISPLAY environment variable or use \"-d\"\n",
5193 display_name); 5193 display_name);
5194 5194
5195 #ifdef HAVE_X11 5195 #ifdef HAVE_X11
5196 { 5196 {
5197 int hostname_size = 256;
5198
5199 hostname = (char *) xmalloc (hostname_size);
5200
5201 #if 0 5197 #if 0
5202 XSetAfterFunction (x_current_display, x_trace_wire); 5198 XSetAfterFunction (x_current_display, x_trace_wire);
5203 #endif /* ! 0 */ 5199 #endif /* ! 0 */
5204 5200 hostname = get_system_name ();
5205 /* Try to get the host name; if the buffer is too short, try
5206 again. Apparently, the only indication gethostname gives of
5207 whether the buffer was large enough is the presence or absence
5208 of a '\0' in the string. Eech. */
5209 for (;;)
5210 {
5211 gethostname (hostname, hostname_size - 1);
5212 hostname[hostname_size - 1] = '\0';
5213
5214 /* Was the buffer large enough for gethostname to store the '\0'? */
5215 if (strlen (hostname) < hostname_size - 1)
5216 break;
5217
5218 hostname_size <<= 1;
5219 hostname = (char *) xrealloc (hostname, hostname_size);
5220 }
5221 x_id_name = (char *) xmalloc (XSTRING (Vinvocation_name)->size 5201 x_id_name = (char *) xmalloc (XSTRING (Vinvocation_name)->size
5222 + strlen (hostname) 5202 + strlen (hostname)
5223 + 2); 5203 + 2);
5224 sprintf (x_id_name, "%s@%s", XSTRING (Vinvocation_name)->data, hostname); 5204 sprintf (x_id_name, "%s@%s", XSTRING (Vinvocation_name)->data, hostname);
5225 } 5205 }