| 79 | // lookup functions |
| 80 | |
| 81 | int |
| 82 | get_local_hostname ( |
| 83 | std::string& hostname |
| 84 | ) |
| 85 | { |
| 86 | try |
| 87 | { |
| 88 | char temp[MAXHOSTNAMELEN]; |
| 89 | |
| 90 | if (gethostname(temp,MAXHOSTNAMELEN) == -1) |
| 91 | { |
| 92 | return OTHER_ERROR; |
| 93 | } |
| 94 | // ensure that NUL is at the end of the string |
| 95 | temp[MAXHOSTNAMELEN-1] = '\0'; |
| 96 | |
| 97 | hostname = temp; |
| 98 | } |
| 99 | catch (...) |
| 100 | { |
| 101 | return OTHER_ERROR; |
| 102 | } |
| 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | // ----------------- |
| 108 |