Example #1
0
char *mylocalhost ()
{
  int status;
  char tmp[MAILTMPLEN];
  if (!myLocalHost) {		/* have local host yet? */
				/* receives local host name */
    struct dsc$descriptor LocalhostDesc = {0,DSC$K_DTYPE_T,DSC$K_CLASS_D,NULL};
    if (!((status = net_get_hostname (&LocalhostDesc)) & 0x1)) {
      sprintf (tmp,"Can't get local hostname, status=%d",status);
      mm_log (tmp,ERROR);
      return "UNKNOWN";
    }
    strncpy (tmp,LocalhostDesc.dsc$a_pointer,LocalhostDesc.dsc$w_length);
    tmp[LocalhostDesc.dsc$w_length] = '\0';
    str$free1_dx (&LocalhostDesc);
    myLocalHost = cpystr (tmp);
  }
  return myLocalHost;
}
Example #2
0
static void daemon_banner()
{
	gchar *hostname = net_get_hostname();
	time_t t;
	time(&t);
	snprintf( daemonStamp, sizeof (daemonStamp), "<%d.%d.%lu@%s>",
		stardictdMain._dict_forks,
		(int) getpid(),
		(long unsigned)t,
		hostname );

	static std::string public_key;
	if (public_key.empty()) {
		rsa_get_public_key_str(public_key);
	}
	daemon_printf( "%d %s %s <auth> %s <rsa_public_key> <%s>\n",
			CODE_HELLO,
			hostname,
			"stardictd-0.5",
			daemonStamp, public_key.c_str());
	g_free(hostname);
}