| 55 | // lookup functions |
| 56 | |
| 57 | int |
| 58 | get_local_hostname ( |
| 59 | std::string& hostname |
| 60 | ) |
| 61 | { |
| 62 | try |
| 63 | { |
| 64 | char temp[MAXHOSTNAMELEN]; |
| 65 | |
| 66 | if (gethostname(temp,MAXHOSTNAMELEN) == -1) |
| 67 | { |
| 68 | return OTHER_ERROR; |
| 69 | } |
| 70 | // ensure that NUL is at the end of the string |
| 71 | temp[MAXHOSTNAMELEN-1] = '\0'; |
| 72 | |
| 73 | hostname = temp; |
| 74 | } |
| 75 | catch (...) |
| 76 | { |
| 77 | return OTHER_ERROR; |
| 78 | } |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | // ----------------- |
| 84 |