| 152 | | int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec) |
| 153 | | { |
| 154 | | int len; |
| 155 | | |
| 156 | | rec->error = -1; |
| 157 | | rec->errorstr = NULL;
|
| 158 | | rec->host4 = NULL;
|
| 159 | | rec->host6 = NULL;
|
| 160 | | |
| 161 | | #ifndef WIN32 |
| 162 | | fcntl(g_io_channel_unix_get_fd(pipe), F_SETFL, O_NONBLOCK);
|
| 163 | | #endif |
| 164 | | |
| 165 | | |
| 166 | | if (g_io_channel_read_block(pipe, rec, sizeof(*rec)) == -1) { |
| 167 | | rec->errorstr = g_strdup_printf("Host name lookup: %s", |
| 168 | | g_strerror(errno)); |
| 169 | | return -1; |
| 170 | | } |
| 171 | | |
| 172 | | if (rec->error) { |
| 173 | | |
| 174 | | |
| 175 | | rec->errorstr = g_malloc0(rec->errlen+1); |
| 176 | | g_io_channel_read_block(pipe, rec->errorstr, rec->errlen); |
| 177 | | } else { |
| 178 | | if (rec->host4) { |
| 179 | | g_io_channel_read_block(pipe, &len, sizeof(int)); |
| 180 | | rec->host4 = g_malloc0(len); |
| 181 | | g_io_channel_read_block(pipe, rec->host4, len); |
| 182 | | } |
| 183 | | if (rec->host6) { |
| 184 | | g_io_channel_read_block(pipe, &len, sizeof(int)); |
| 185 | | rec->host6 = g_malloc0(len); |
| 186 | | g_io_channel_read_block(pipe, rec->host6, len); |
| 187 | | } |
| 188 | | } |
| 189 | | |
| 190 | | return 0; |
| 191 | | } |