Lines Matching +full:no +full:- +full:wp
1 /*-
2 * Copyright (c) 2003-2010 Tim Kientzle
18 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
68 static void next_field_w(const wchar_t **wp, const wchar_t **start,
70 static void append_entry_w(wchar_t **wp, const wchar_t *prefix, int type,
72 static void append_id_w(wchar_t **wp, int id);
134 while (acl->acl_head != NULL) { in archive_acl_clear()
135 ap = acl->acl_head->next; in archive_acl_clear()
136 archive_mstring_clean(&acl->acl_head->name); in archive_acl_clear()
137 free(acl->acl_head); in archive_acl_clear()
138 acl->acl_head = ap; in archive_acl_clear()
140 free(acl->acl_text_w); in archive_acl_clear()
141 acl->acl_text_w = NULL; in archive_acl_clear()
142 free(acl->acl_text); in archive_acl_clear()
143 acl->acl_text = NULL; in archive_acl_clear()
144 acl->acl_p = NULL; in archive_acl_clear()
145 acl->acl_types = 0; in archive_acl_clear()
146 acl->acl_state = 0; /* Not counting. */ in archive_acl_clear()
156 dest->mode = src->mode; in archive_acl_copy()
157 ap = src->acl_head; in archive_acl_copy()
160 ap->type, ap->permset, ap->tag, ap->id); in archive_acl_copy()
162 archive_mstring_copy(&ap2->name, &ap->name); in archive_acl_copy()
163 ap = ap->next; in archive_acl_copy()
181 archive_mstring_copy_mbs(&ap->name, name); in archive_acl_add_entry()
183 archive_mstring_clean(&ap->name); in archive_acl_add_entry()
201 archive_mstring_copy_wcs_len(&ap->name, name, len); in archive_acl_add_entry_w_len()
203 archive_mstring_clean(&ap->name); in archive_acl_add_entry_w_len()
223 r = archive_mstring_copy_mbs_len_l(&ap->name, name, len, sc); in archive_acl_add_entry_len_l()
226 archive_mstring_clean(&ap->name); in archive_acl_add_entry_len_l()
247 acl->mode &= ~0700; in acl_special()
248 acl->mode |= (permset & 7) << 6; in acl_special()
251 acl->mode &= ~0070; in acl_special()
252 acl->mode |= (permset & 7) << 3; in acl_special()
255 acl->mode &= ~0007; in acl_special()
256 acl->mode |= permset & 7; in acl_special()
277 if (acl->acl_types & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) { in acl_new_entry()
286 if (acl->acl_types & ~ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) { in acl_new_entry()
318 /* No other values are valid. */ in acl_new_entry()
322 free(acl->acl_text_w); in acl_new_entry()
323 acl->acl_text_w = NULL; in acl_new_entry()
324 free(acl->acl_text); in acl_new_entry()
325 acl->acl_text = NULL; in acl_new_entry()
331 * TODO: compare names of no id is provided (needs more rework) in acl_new_entry()
333 ap = acl->acl_head; in acl_new_entry()
337 ap->type == type && ap->tag == tag && ap->id == id) { in acl_new_entry()
338 if (id != -1 || (tag != ARCHIVE_ENTRY_ACL_USER && in acl_new_entry()
340 ap->permset = permset; in acl_new_entry()
345 ap = ap->next; in acl_new_entry()
353 acl->acl_head = ap; in acl_new_entry()
355 aq->next = ap; in acl_new_entry()
356 ap->type = type; in acl_new_entry()
357 ap->tag = tag; in acl_new_entry()
358 ap->id = id; in acl_new_entry()
359 ap->permset = permset; in acl_new_entry()
360 acl->acl_types |= type; in acl_new_entry()
374 ap = acl->acl_head; in archive_acl_count()
376 if ((ap->type & want_type) != 0) in archive_acl_count()
378 ap = ap->next; in archive_acl_count()
392 return (acl->acl_types); in archive_acl_types()
397 * of entries matching "want_type", or zero if there are no
398 * non-extended ACL entries of that type.
418 acl->acl_state = ARCHIVE_ENTRY_ACL_USER_OBJ; in archive_acl_reset()
420 acl->acl_state = 0; in archive_acl_reset()
421 acl->acl_p = acl->acl_head; in archive_acl_reset()
435 *id = -1; in archive_acl_next()
438 * The acl_state is either zero (no entries available), -1 in archive_acl_next()
442 if (acl->acl_state == 0) in archive_acl_next()
447 switch (acl->acl_state) { in archive_acl_next()
449 *permset = (acl->mode >> 6) & 7; in archive_acl_next()
452 acl->acl_state = ARCHIVE_ENTRY_ACL_GROUP_OBJ; in archive_acl_next()
455 *permset = (acl->mode >> 3) & 7; in archive_acl_next()
458 acl->acl_state = ARCHIVE_ENTRY_ACL_OTHER; in archive_acl_next()
461 *permset = acl->mode & 7; in archive_acl_next()
464 acl->acl_state = -1; in archive_acl_next()
465 acl->acl_p = acl->acl_head; in archive_acl_next()
472 while (acl->acl_p != NULL && (acl->acl_p->type & want_type) == 0) in archive_acl_next()
473 acl->acl_p = acl->acl_p->next; in archive_acl_next()
474 if (acl->acl_p == NULL) { in archive_acl_next()
475 acl->acl_state = 0; in archive_acl_next()
479 *id = -1; in archive_acl_next()
483 *type = acl->acl_p->type; in archive_acl_next()
484 *permset = acl->acl_p->permset; in archive_acl_next()
485 *tag = acl->acl_p->tag; in archive_acl_next()
486 *id = acl->acl_p->id; in archive_acl_next()
487 if (archive_mstring_get_mbs(a, &acl->acl_p->name, name) != 0) { in archive_acl_next()
492 acl->acl_p = acl->acl_p->next; in archive_acl_next()
505 if ((acl->acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { in archive_acl_text_want_type()
507 if ((acl->acl_types & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) in archive_acl_text_want_type()
543 for (ap = acl->acl_head; ap != NULL; ap = ap->next) { in archive_acl_text_len()
544 if ((ap->type & want_type) == 0) in archive_acl_text_len()
547 * Filemode-mapping ACL entries are stored exclusively in in archive_acl_text_len()
548 * ap->mode so they should not be in the list in archive_acl_text_len()
550 if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) in archive_acl_text_len()
551 && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ in archive_acl_text_len()
552 || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ in archive_acl_text_len()
553 || ap->tag == ARCHIVE_ENTRY_ACL_OTHER)) in archive_acl_text_len()
557 && (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) in archive_acl_text_len()
559 switch (ap->tag) { in archive_acl_text_len()
585 if (ap->tag == ARCHIVE_ENTRY_ACL_USER || in archive_acl_text_len()
586 ap->tag == ARCHIVE_ENTRY_ACL_GROUP) { in archive_acl_text_len()
588 r = archive_mstring_get_wcs(a, &ap->name, in archive_acl_text_len()
597 r = archive_mstring_get_mbs_l(a, &ap->name, &name, in archive_acl_text_len()
612 && (ap->tag == ARCHIVE_ENTRY_ACL_OTHER in archive_acl_text_len()
613 || ap->tag == ARCHIVE_ENTRY_ACL_MASK)) { in archive_acl_text_len()
614 /* Solaris has no colon after other: and mask: */ in archive_acl_text_len()
615 length = length - 1; in archive_acl_text_len()
621 if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DENY) == 0) in archive_acl_text_len()
626 if ((ap->tag == ARCHIVE_ENTRY_ACL_USER || in archive_acl_text_len()
627 ap->tag == ARCHIVE_ENTRY_ACL_GROUP) && in archive_acl_text_len()
632 tmp = ap->id; in archive_acl_text_len()
642 /* Add filemode-mapping access entries to the length */ in archive_acl_text_len()
674 wchar_t *wp, *ws; in archive_acl_to_text_w() local
696 wp = ws = malloc(length * sizeof(*wp)); in archive_acl_to_text_w()
697 if (wp == NULL) { in archive_acl_to_text_w()
699 __archive_errx(1, "No memory"); in archive_acl_to_text_w()
705 append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, in archive_acl_to_text_w()
707 acl->mode & 0700, -1); in archive_acl_to_text_w()
708 *wp++ = separator; in archive_acl_to_text_w()
709 append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, in archive_acl_to_text_w()
711 acl->mode & 0070, -1); in archive_acl_to_text_w()
712 *wp++ = separator; in archive_acl_to_text_w()
713 append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, in archive_acl_to_text_w()
715 acl->mode & 0007, -1); in archive_acl_to_text_w()
719 for (ap = acl->acl_head; ap != NULL; ap = ap->next) { in archive_acl_to_text_w()
720 if ((ap->type & want_type) == 0) in archive_acl_to_text_w()
723 * Filemode-mapping ACL entries are stored exclusively in in archive_acl_to_text_w()
724 * ap->mode so they should not be in the list in archive_acl_to_text_w()
726 if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) in archive_acl_to_text_w()
727 && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ in archive_acl_to_text_w()
728 || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ in archive_acl_to_text_w()
729 || ap->tag == ARCHIVE_ENTRY_ACL_OTHER)) in archive_acl_to_text_w()
731 if (ap->type == ARCHIVE_ENTRY_ACL_TYPE_DEFAULT && in archive_acl_to_text_w()
736 r = archive_mstring_get_wcs(a, &ap->name, &wname); in archive_acl_to_text_w()
739 *wp++ = separator; in archive_acl_to_text_w()
741 id = ap->id; in archive_acl_to_text_w()
743 id = -1; in archive_acl_to_text_w()
744 append_entry_w(&wp, prefix, ap->type, ap->tag, flags, in archive_acl_to_text_w()
745 wname, ap->permset, id); in archive_acl_to_text_w()
754 *wp++ = L'\0'; in archive_acl_to_text_w()
758 if (len > length - 1) in archive_acl_to_text_w()
768 append_id_w(wchar_t **wp, int id) in append_id_w() argument
773 append_id_w(wp, id / 10); in append_id_w()
774 *(*wp)++ = L"0123456789"[id % 10]; in append_id_w()
778 append_entry_w(wchar_t **wp, const wchar_t *prefix, int type, in append_entry_w() argument
784 wcscpy(*wp, prefix); in append_entry_w()
785 *wp += wcslen(*wp); in append_entry_w()
790 id = -1; in append_entry_w()
792 wcscpy(*wp, L"owner@"); in append_entry_w()
797 wcscpy(*wp, L"user"); in append_entry_w()
801 id = -1; in append_entry_w()
803 wcscpy(*wp, L"group@"); in append_entry_w()
808 wcscpy(*wp, L"group"); in append_entry_w()
811 wcscpy(*wp, L"mask"); in append_entry_w()
813 id = -1; in append_entry_w()
816 wcscpy(*wp, L"other"); in append_entry_w()
818 id = -1; in append_entry_w()
821 wcscpy(*wp, L"everyone@"); in append_entry_w()
823 id = -1; in append_entry_w()
826 *wp += wcslen(*wp); in append_entry_w()
827 *(*wp)++ = L':'; in append_entry_w()
832 wcscpy(*wp, wname); in append_entry_w()
833 *wp += wcslen(*wp); in append_entry_w()
836 append_id_w(wp, id); in append_entry_w()
838 id = -1; in append_entry_w()
840 /* Solaris style has no second colon after other and mask */ in append_entry_w()
844 *(*wp)++ = L':'; in append_entry_w()
848 *(*wp)++ = (perm & 0444) ? L'r' : L'-'; in append_entry_w()
849 *(*wp)++ = (perm & 0222) ? L'w' : L'-'; in append_entry_w()
850 *(*wp)++ = (perm & 0111) ? L'x' : L'-'; in append_entry_w()
855 *(*wp)++ = nfsv4_acl_perm_map[i].wc; in append_entry_w()
857 *(*wp)++ = L'-'; in append_entry_w()
859 *(*wp)++ = L':'; in append_entry_w()
862 *(*wp)++ = nfsv4_acl_flag_map[i].wc; in append_entry_w()
864 *(*wp)++ = L'-'; in append_entry_w()
866 *(*wp)++ = L':'; in append_entry_w()
869 wcscpy(*wp, L"allow"); in append_entry_w()
872 wcscpy(*wp, L"deny"); in append_entry_w()
875 wcscpy(*wp, L"audit"); in append_entry_w()
878 wcscpy(*wp, L"alarm"); in append_entry_w()
883 *wp += wcslen(*wp); in append_entry_w()
885 if (id != -1) { in append_entry_w()
886 *(*wp)++ = L':'; in append_entry_w()
887 append_id_w(wp, id); in append_entry_w()
932 __archive_errx(1, "No memory"); in archive_acl_to_text_l()
940 acl->mode & 0700, -1); in archive_acl_to_text_l()
944 acl->mode & 0070, -1); in archive_acl_to_text_l()
948 acl->mode & 0007, -1); in archive_acl_to_text_l()
952 for (ap = acl->acl_head; ap != NULL; ap = ap->next) { in archive_acl_to_text_l()
953 if ((ap->type & want_type) == 0) in archive_acl_to_text_l()
956 * Filemode-mapping ACL entries are stored exclusively in in archive_acl_to_text_l()
957 * ap->mode so they should not be in the list in archive_acl_to_text_l()
959 if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) in archive_acl_to_text_l()
960 && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ in archive_acl_to_text_l()
961 || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ in archive_acl_to_text_l()
962 || ap->tag == ARCHIVE_ENTRY_ACL_OTHER)) in archive_acl_to_text_l()
964 if (ap->type == ARCHIVE_ENTRY_ACL_TYPE_DEFAULT && in archive_acl_to_text_l()
970 NULL, &ap->name, &name, &len, sc); in archive_acl_to_text_l()
979 id = ap->id; in archive_acl_to_text_l()
981 id = -1; in archive_acl_to_text_l()
983 append_entry(&p, prefix, ap->type, ap->tag, flags, name, in archive_acl_to_text_l()
984 ap->permset, id); in archive_acl_to_text_l()
993 if (len > length - 1) in archive_acl_to_text_l()
1025 id = -1; in append_entry()
1036 id = -1; in append_entry()
1048 id = -1; in append_entry()
1053 id = -1; in append_entry()
1058 id = -1; in append_entry()
1073 id = -1; in append_entry()
1075 /* Solaris style has no second colon after other and mask */ in append_entry()
1083 *(*p)++ = (perm & 0444) ? 'r' : '-'; in append_entry()
1084 *(*p)++ = (perm & 0222) ? 'w' : '-'; in append_entry()
1085 *(*p)++ = (perm & 0111) ? 'x' : '-'; in append_entry()
1092 *(*p)++ = '-'; in append_entry()
1099 *(*p)++ = '-'; in append_entry()
1118 if (id != -1) { in append_entry()
1128 * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - text is a POSIX.1e ACL of type ACCESS
1129 * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - text is a POSIX.1e ACL of type DEFAULT
1130 * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - text is as a NFSv4 ACL
1196 id = -1; in archive_acl_from_text_w()
1211 len = field[0].end - field[0].start; in archive_acl_from_text_w()
1225 if (id == -1 && fields > n+3) in archive_acl_from_text_w()
1232 len = field[n].end - field[n].start; in archive_acl_from_text_w()
1266 /* This is Solaris-style "other:rwx" */ in archive_acl_from_text_w()
1277 if (id != -1 || in archive_acl_from_text_w()
1296 if (permset == 0 && !ismode_w(field[n + 2 - sol].start, in archive_acl_from_text_w()
1297 field[n + 2 - sol].end, &permset)) { in archive_acl_from_text_w()
1305 len = field[0].end - field[0].start; in archive_acl_from_text_w()
1355 len = field[3 + n].end - field[3 + n].start; in archive_acl_from_text_w()
1378 tag, id, name.start, name.end - name.start); in archive_acl_from_text_w()
1394 * the string is non-empty and consists only of decimal digits,
1407 (n == INT_MAX / 10 && (*start - L'0') > INT_MAX % 10)) { in isint_w()
1411 n += *start - L'0'; in isint_w()
1421 * the string is non-empty and consists only of mode characters,
1444 case L'-': in ismode_w()
1455 * Returns true if the string is non-empty and consists only of NFS4 ACL
1507 case L'-': in is_nfs4_perms_w()
1518 * Returns true if the string is non-empty and consists only of NFS4 ACL
1550 case L'-': in is_nfs4_flags_w()
1560 * Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]". *wp is updated
1563 * character of the matched identifier. In particular *end - *start
1568 next_field_w(const wchar_t **wp, const wchar_t **start, in next_field_w() argument
1572 while (**wp == L' ' || **wp == L'\t' || **wp == L'\n') { in next_field_w()
1573 (*wp)++; in next_field_w()
1575 *start = *wp; in next_field_w()
1578 while (**wp != L'\0' && **wp != L',' && **wp != L':' && in next_field_w()
1579 **wp != L'\n' && **wp != L'#') { in next_field_w()
1580 (*wp)++; in next_field_w()
1582 *sep = **wp; in next_field_w()
1585 if (*wp == *start) { in next_field_w()
1586 *end = *wp; in next_field_w()
1588 *end = *wp - 1; in next_field_w()
1590 (*end)--; in next_field_w()
1595 /* Handle in-field comments */ in next_field_w()
1597 while (**wp != L'\0' && **wp != L',' && **wp != L'\n') { in next_field_w()
1598 (*wp)++; in next_field_w()
1600 *sep = **wp; in next_field_w()
1604 if (**wp != L'\0') in next_field_w()
1605 (*wp)++; in next_field_w()
1612 * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - text is a POSIX.1e ACL of type ACCESS
1613 * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - text is a POSIX.1e ACL of type DEFAULT
1614 * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - text is as a NFSv4 ACL
1686 id = -1; in archive_acl_from_text_nl()
1701 len = field[0].end - field[0].start; in archive_acl_from_text_nl()
1715 if (id == -1 && fields > (n + 3)) in archive_acl_from_text_nl()
1722 len = field[n].end - field[n].start; in archive_acl_from_text_nl()
1761 /* This is Solaris-style "other:rwx" */ in archive_acl_from_text_nl()
1772 if (id != -1 || in archive_acl_from_text_nl()
1791 if (permset == 0 && !ismode(field[n + 2 - sol].start, in archive_acl_from_text_nl()
1792 field[n + 2 - sol].end, &permset)) { in archive_acl_from_text_nl()
1800 len = field[0].end - field[0].start; in archive_acl_from_text_nl()
1851 len = field[3 + n].end - field[3 + n].start; in archive_acl_from_text_nl()
1875 tag, id, name.start, name.end - name.start, sc); in archive_acl_from_text_nl()
1891 * the string is non-empty and consists only of decimal digits,
1904 (n == INT_MAX / 10 && (*start - '0') > INT_MAX % 10)) { in isint()
1908 n += *start - '0'; in isint()
1918 * the string is non-empty and consists only of mode characters,
1941 case '-': in ismode()
1952 * Returns true if the string is non-empty and consists only of NFS4 ACL
2004 case '-': in is_nfs4_perms()
2015 * Returns true if the string is non-empty and consists only of NFS4 ACL
2047 case '-': in is_nfs4_flags()
2060 * character of the matched identifier. In particular *end - *start
2071 (*l)--; in next_field()
2078 (*l)--; in next_field()
2085 (*l)--; in next_field()
2089 /* Handle in-field comments */ in next_field()
2093 (*l)--; in next_field()
2101 (*l)--; in next_field()