1GETHOSTNAME(2) 386BSD Programmer's Manual GETHOSTNAME(2) 2 3NNAAMMEE 4 ggeetthhoossttnnaammee, sseetthhoossttnnaammee - get/set name of current host 5 6SSYYNNOOPPSSIISS 7 ##iinncclluuddee <<uunniissttdd..hh>> 8 9 _i_n_t 10 ggeetthhoossttnnaammee(_c_h_a_r *_n_a_m_e, _i_n_t _n_a_m_e_l_e_n) 11 12 _i_n_t 13 sseetthhoossttnnaammee(_c_o_n_s_t _c_h_a_r *_n_a_m_e, _i_n_t _n_a_m_e_l_e_n) 14 15DDEESSCCRRIIPPTTIIOONN 16 GGeetthhoossttnnaammee() returns the standard host name for the current processor, 17 as previously set by sseetthhoossttnnaammee(). The parameter _n_a_m_e_l_e_n specifies the 18 size of the _n_a_m_e array. The returned name is null-terminated unless 19 insufficient space is provided. 20 21 SSeetthhoossttnnaammee() sets the name of the host machine to be _n_a_m_e, which has 22 length _n_a_m_e_l_e_n. This call is restricted to the super-user and is normally 23 used only when the system is bootstrapped. 24 25RREETTUURRNN VVAALLUUEESS 26 If the call succeeds a value of 0 is returned. If the call fails, a 27 value of -1 is returned and an error code is placed in the global 28 location _e_r_r_n_o. 29 30EERRRROORRSS 31 The following errors may be returned by these calls: 32 33 [EFAULT] The _n_a_m_e or _n_a_m_e_l_e_n parameter gave an invalid address. 34 35 [EPERM] The caller tried to set the hostname and was not the super- 36 user. 37 38SSEEEE AALLSSOO 39 gethostid(2) 40 41BBUUGGSS 42 Host names are limited to MAXHOSTNAMELEN (from <_s_y_s/_p_a_r_a_m._h>) characters, 43 currently 64. 44 45HHIISSTTOORRYY 46 The ggeetthhoossttnnaammee function call appeared in 4.2BSD. 47 484.2 Berkeley Distribution March 10, 1991 1 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67