MCPcopy Index your code
hub / github.com/RsyncProject/rsync / get_rule_prefix

Function get_rule_prefix

exclude.c:1525–1587  ·  view source on GitHub ↗

If the "for_xfer" flag is set, the prefix is made compatible with the * current protocol_version (if possible) or a NULL is returned (if not * possible). */

Source from the content-addressed store, hash-verified

1523 * current protocol_version (if possible) or a NULL is returned (if not
1524 * possible). */
1525char *get_rule_prefix(filter_rule *rule, const char *pat, int for_xfer,
1526 unsigned int *plen_ptr)
1527{
1528 static char buf[MAX_RULE_PREFIX+1];
1529 char *op = buf;
1530 int legal_len = for_xfer && protocol_version < 29 ? 1 : MAX_RULE_PREFIX-1;
1531
1532 if (rule->rflags & FILTRULE_PERDIR_MERGE) {
1533 if (legal_len == 1)
1534 return NULL;
1535 *op++ = ':';
1536 } else if (rule->rflags & FILTRULE_INCLUDE)
1537 *op++ = '+';
1538 else if (legal_len != 1
1539 || ((*pat == '-' || *pat == '+') && pat[1] == ' '))
1540 *op++ = '-';
1541 else
1542 legal_len = 0;
1543
1544 if (rule->rflags & FILTRULE_ABS_PATH)
1545 *op++ = '/';
1546 if (rule->rflags & FILTRULE_NEGATE)
1547 *op++ = '!';
1548 if (rule->rflags & FILTRULE_CVS_IGNORE)
1549 *op++ = 'C';
1550 else {
1551 if (rule->rflags & FILTRULE_NO_INHERIT)
1552 *op++ = 'n';
1553 if (rule->rflags & FILTRULE_WORD_SPLIT)
1554 *op++ = 'w';
1555 if (rule->rflags & FILTRULE_NO_PREFIXES) {
1556 if (rule->rflags & FILTRULE_INCLUDE)
1557 *op++ = '+';
1558 else
1559 *op++ = '-';
1560 }
1561 }
1562 if (rule->rflags & FILTRULE_EXCLUDE_SELF)
1563 *op++ = 'e';
1564 if (rule->rflags & FILTRULE_XATTR)
1565 *op++ = 'x';
1566 if (rule->rflags & FILTRULE_SENDER_SIDE
1567 && (!for_xfer || protocol_version >= 29))
1568 *op++ = 's';
1569 if (rule->rflags & FILTRULE_RECEIVER_SIDE
1570 && (!for_xfer || protocol_version >= 29
1571 || (delete_excluded && am_sender)))
1572 *op++ = 'r';
1573 if (rule->rflags & FILTRULE_PERISHABLE) {
1574 if (!for_xfer || protocol_version >= 30)
1575 *op++ = 'p';
1576 else if (am_sender)
1577 return NULL;
1578 }
1579 if (op - buf > legal_len)
1580 return NULL;
1581 if (legal_len)
1582 *op++ = ' ';

Callers 3

write_filter_rulesFunction · 0.85
add_ruleFunction · 0.85
send_rulesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected