| 331 | } |
| 332 | |
| 333 | static int parse_negotiate_str(struct name_num_obj *nno, char *tmpbuf) |
| 334 | { |
| 335 | struct name_num_item *nni, *ret = NULL; |
| 336 | int best = nno->saw_len; /* We want best == 1 from the client list, so start with a big number. */ |
| 337 | char *space, *tok = tmpbuf; |
| 338 | while (tok) { |
| 339 | while (*tok == ' ') tok++; /* Should be unneeded... */ |
| 340 | if (!*tok) |
| 341 | break; |
| 342 | if ((space = strchr(tok, ' ')) != NULL) |
| 343 | *space = '\0'; |
| 344 | nni = get_nni_by_name(nno, tok, -1); |
| 345 | if (space) { |
| 346 | *space = ' '; |
| 347 | tok = space + 1; |
| 348 | } else |
| 349 | tok = NULL; |
| 350 | if (!nni || !nno->saw[nni->num] || best <= nno->saw[nni->num]) |
| 351 | continue; |
| 352 | ret = nni; |
| 353 | best = nno->saw[nni->num]; |
| 354 | if (best == 1 || am_server) /* The server side stops at the first acceptable client choice */ |
| 355 | break; |
| 356 | } |
| 357 | if (ret) { |
| 358 | free(nno->saw); |
| 359 | nno->saw = NULL; |
| 360 | nno->negotiated_nni = ret->main_nni ? ret->main_nni : ret; |
| 361 | return 1; |
| 362 | } |
| 363 | return 0; |
| 364 | } |
| 365 | |
| 366 | /* This routine is always called with a tmpbuf of MAX_NSTR_STRLEN length, but the |
| 367 | * buffer may be pre-populated with a "len" length string to use OR a len of -1 |
no test coverage detected