cap_t cap_get_file(const char *filename) { cap_t result; /* allocate a new capability set */ result = cap_init(); if (result) { struct vfs_cap_data rawvfscap; int sizeofcaps; _cap_debug("getting filename capabilities"); /* fill the capability sets via a system call */ sizeofcaps = getxattr(filename, XATTR_NAME_CAPS, &rawvfscap, sizeof(rawvfscap)); if (sizeofcaps < ssizeof(rawvfscap.magic_etc)) { cap_free(result); result = NULL; } else { result = _fcaps_load(&rawvfscap, result, sizeofcaps); } } return result; }
static int load_arginfo(char *format,Ft_arginfo *ainfo, int maxargs) /* load array of offsets to actual formats and to stack areas containing data * returns errcode if a problem the number of arguments parsed if ok. It will * load one more offset than the number of arguments so that the size for the * last argument may be calculated using it and the offset to the last and to * the one beyond last. "cstack.h" is a compiler dependent header that * defines the size of objects on the stack. This function will only work fo * va_lists which are pointers to the stack or a duplicate thereof. No items * will have an offset of 255 */ { Formatarg fa; Ft_arginfo *ai, *lastai; char c; SHORT offset; if(!format) return(0); ai = ainfo; lastai = ai + maxargs; init_format_parse(&fa,format); offset = ai->va_oset = 0; /* first one starts at zero */ while ((c = fa_getchar(&fa)) != '\0') { switch(FT_TYPE(c)) { case FT_INT: offset += ssizeof(intptr_t); if(c == FT_STARTYPE) /* '*' star type int args */ continue; break; case FT_LONG: case FT_DLONG: offset += ssizeof(long); break; case FT_VOID_PTR: case FT_CHAR_PTR: offset += ssizeof(void *); break; case FT_SHORT_PTR: case FT_INT_PTR: if(FT_FMTCHAR(c) == 'n') return(Err_n_args_invalid); case FT_DOUBLE: offset += ssizeof(double); break; } if(SIZE(format,fa.str) >= 255) return(Err_too_many_args); ai->fmt_oset = SIZE(format,fa.str); if(++ai >= lastai) return(Err_too_many_args); ai->va_oset = offset; /* set offset to next one */ } return(ai - ainfo); /* return number of arg formats parsed */ }
void pwsc_get_qsc(mmc_raw_pwsc_t *rawPWsc, qsc_buffer_t *formattedQsc) { int i; memset(formattedQsc, 0x00, sizeof(qsc_buffer_t)); for (i = 0; i < ssizeof(rawPWsc->subcodeData); ++i) { if (QSC_MASK(rawPWsc->subcodeData[i])) { pwsc_set_bit(formattedQsc->subcodeData, i); } } }