MCPcopy Create free account
hub / github.com/RsyncProject/rsync / validate_choice_vs_env

Function validate_choice_vs_env

compat.c:426–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426void validate_choice_vs_env(int ntype, int num1, int num2)
427{
428 struct name_num_obj *nno = ntype == NSTR_COMPRESS ? &valid_compressions : &valid_checksums;
429 const char *list_str = getenv_nstr(ntype);
430 char tmpbuf[MAX_NSTR_STRLEN];
431
432 if (!list_str)
433 return;
434
435 while (isSpace(list_str)) list_str++;
436
437 if (!*list_str)
438 return;
439
440 init_nno_saw(nno, 0);
441 parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
442
443 if (ntype == NSTR_CHECKSUM) /* If "md4" is in the env list, all the old MD4 choices are OK too. */
444 nno->saw[CSUM_MD4_ARCHAIC] = nno->saw[CSUM_MD4_BUSTED] = nno->saw[CSUM_MD4_OLD] = nno->saw[CSUM_MD4];
445
446 if (!nno->saw[num1] || (num2 >= 0 && !nno->saw[num2])) {
447 rprintf(FERROR, "Your --%s-choice value (%s) was refused by the server.\n",
448 ntype == NSTR_COMPRESS ? "compress" : "checksum",
449 ntype == NSTR_COMPRESS ? compress_choice : checksum_choice);
450 exit_cleanup(RERR_UNSUPPORTED);
451 }
452
453 free(nno->saw);
454 nno->saw = NULL;
455}
456
457/* The saw buffer is initialized and used to store ordinal values from 1 to N
458 * for the order of the args in the array. If dup_markup == '\0', duplicates

Callers 2

parse_checksum_choiceFunction · 0.85
parse_compress_choiceFunction · 0.85

Calls 5

getenv_nstrFunction · 0.85
isSpaceFunction · 0.85
init_nno_sawFunction · 0.85
parse_nni_strFunction · 0.85
rprintfFunction · 0.70

Tested by

no test coverage detected