| 1225 | } |
| 1226 | |
| 1227 | BOOL namecvt_call(const char *cmd, const char **name_p, id_t *id_p) |
| 1228 | { |
| 1229 | char buf[1024]; |
| 1230 | int got, len; |
| 1231 | |
| 1232 | if (*name_p) |
| 1233 | len = snprintf(buf, sizeof buf, "%s %s\n", cmd, *name_p); |
| 1234 | else |
| 1235 | len = snprintf(buf, sizeof buf, "%s %ld\n", cmd, (long)*id_p); |
| 1236 | if (len >= (int)sizeof buf) { |
| 1237 | rprintf(FERROR, "namecvt_call() request was too large.\n"); |
| 1238 | exit_cleanup(RERR_UNSUPPORTED); |
| 1239 | } |
| 1240 | |
| 1241 | while ((got = write(namecvt_fd_req, buf, len)) != len) { |
| 1242 | if (got < 0 && errno == EINTR) |
| 1243 | continue; |
| 1244 | rprintf(FERROR, "Connection to name-converter failed.\n"); |
| 1245 | exit_cleanup(RERR_SOCKETIO); |
| 1246 | } |
| 1247 | |
| 1248 | if (!read_line_old(namecvt_fd_ans, buf, sizeof buf, 0)) |
| 1249 | return False; |
| 1250 | |
| 1251 | if (*name_p) |
| 1252 | *id_p = (id_t)atol(buf); |
| 1253 | else |
| 1254 | *name_p = strdup(buf); |
| 1255 | |
| 1256 | return True; |
| 1257 | } |
| 1258 | |
| 1259 | /* send a list of available modules to the client. Don't list those |
| 1260 | with "list = False". */ |
no test coverage detected