bool key(int code, bool isdown) { if(vmenu<=0) return false; int menusel = menus[vmenu].menusel; if(isdown) { if(code==SDLK_ESCAPE) { set(-1); if(!menustack.empty()) set(menustack.pop()); return true; } else if(code==SDLK_UP || code==-4) menusel--; else if(code==SDLK_DOWN || code==-5) menusel++; int n = menus[vmenu].items.length(); if(menusel<0) menusel = n-1; else if(menusel>=n) menusel = 0; menus[vmenu].menusel = menusel; } else { if(code==SDLK_RETURN || code==-2) { char *action = menus[vmenu].items[menusel].action; if(vmenu==1) connects(getservername(menusel)); menustack.add(vmenu); set(-1); execute(action, true); } } return true; }
char* GetFullyQualifiedDomainName() { /* POSIX?! we don't need no stinkin' POSIX! */ #ifdef _SOLARIS INT32 lHostNameLen = 0; INT32 lDomainNameLen = 0; char pNodeName[257]; /* max IPv4 nodename len, plus null */ char pDomainName[2048]; lHostNameLen = sysinfo(SI_HOSTNAME, pNodeName, 257); lDomainNameLen = sysinfo(SI_SRPC_DOMAIN, pDomainName, 2048); if ( (lHostNameLen > 0) && (lDomainNameLen > 0) ) { UINT16 len = lHostNameLen + lDomainNameLen + 1; // add one for the "." char* pFullyQualifiedDomainName = new char [len + 1]; // plus the null sprintf(pFullyQualifiedDomainName, "%s.%s", pNodeName, pDomainName); pFullyQualifiedDomainName[len] = '\0'; return pFullyQualifiedDomainName; } else { return 0; } #elif defined _LINUX char pHostName[2048]; char pDomainName[2048]; if ((0 == ::gethostname(pHostName, 2048))) { if (strchr(pHostName, '.')) { return new_string(pHostName); } else if (0 == ::getdomainname(pDomainName, 2048)) { UINT16 len = strlen(pDomainName) + strlen(pHostName) + 1; char* pFullyQualifiedDomainName = new char [len+1]; sprintf(pFullyQualifiedDomainName, "%s.%s", pHostName, pDomainName); pFullyQualifiedDomainName[len] = '\0'; return pFullyQualifiedDomainName; } else { return 0; } } else { return 0; } #else return getservername(); #endif }