emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cvs emacs and (system-name)


From: Chong Yidong
Subject: Re: cvs emacs and (system-name)
Date: Tue, 17 Apr 2007 15:45:57 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.98 (gnu/linux)

Tom Tromey <address@hidden> writes:

>>>>>> "Andreas" == Andreas Schwab <address@hidden> writes:
>
>>> However, 'hostname' on this machine reports 'opsy'.
>
> Andreas> What does hostname -f give you?
>
> opsy. hostname -f
> opsy

Could you try to compile the following program and report its output?


#include <stdio.h>
#include <alloca.h>
#include <string.h>
#include <sys/socket.h>
#include <netdb.h>

int main ()
{
  int hostname_size = 256;
  char *hostname = (char *) alloca (hostname_size);

  while (1)
    {
      gethostname (hostname, hostname_size - 1);
      hostname[hostname_size - 1] = '\0';
      if (strlen (hostname) < hostname_size - 1)
        break;
      hostname_size <<= 1;
      hostname = (char *) alloca (hostname_size);
    }

  if (! index (hostname, '.'))
    {
      struct hostent *hp;
      hp = gethostbyname (hostname);
      if (hp)
        {
          char *fqdn = (char *) hp->h_name;
          if (!index (fqdn, '.'))
            {
              char **alias = hp->h_aliases;
              while (*alias && !index (*alias, '.'))
                alias++;
              if (*alias)
                fqdn = *alias;
            }
          hostname = fqdn;
        }
    }
  printf ("%s\n", hostname);
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]