idx
int64 | func
string | target
int64 |
|---|---|---|
513,104
|
uint decimal_scale() const
{
return type_handler()->Item_decimal_scale(this);
}
| 0
|
432,307
|
static inline void flatview_ref(FlatView *view)
{
view->ref++;
}
| 0
|
301,433
|
static SMB_ACL_T vfswrap_sys_acl_get_file(vfs_handle_struct *handle,
const char *path_p,
SMB_ACL_TYPE_T type,
TALLOC_CTX *mem_ctx)
{
return sys_acl_get_file(handle, path_p, type, mem_ctx);
}
| 0
|
254,719
|
njs_typed_array_compare_i8(const void *a, const void *b, void *c)
{
return *((const int8_t *) a) - *((const int8_t *) b);
}
| 0
|
275,474
|
njs_vm_memory_error(njs_vm_t *vm)
{
njs_memory_error_set(vm, &vm->retval);
}
| 0
|
279,933
|
ex_write(exarg_T *eap)
{
if (eap->cmdidx == CMD_saveas)
{
// :saveas does not take a range, uses all lines.
eap->line1 = 1;
eap->line2 = curbuf->b_ml.ml_line_count;
}
if (eap->usefilter) // input lines to shell command
do_bang(1, eap, FALSE, TRUE, FALSE);
else
(void)do_write(eap);
}
| 0
|
393,522
|
static SQInteger base_print(HSQUIRRELVM v)
{
const SQChar *str;
if(SQ_SUCCEEDED(sq_tostring(v,2)))
{
if(SQ_SUCCEEDED(sq_getstring(v,-1,&str))) {
if(_ss(v)->_printfunc) _ss(v)->_printfunc(v,_SC("%s"),str);
return 0;
}
}
return SQ_ERROR;
}
| 0
|
242,608
|
Status Peek(std::size_t index, Tuple* tuple) {
std::unique_lock<std::mutex> lock(mu_);
// Wait if the requested index is not available
non_empty_cond_var_.wait(
lock, [index, this]() { return index < this->buf_.size(); });
// Place tensors in the output tuple
for (const auto& tensor : buf_[index]) {
tuple->push_back(tensor);
}
return Status::OK();
}
| 0
|
233,820
|
static int decode_atari_image_paletted(deark *c, struct atari_img_decode_data *adata)
{
i64 i, j;
i64 plane;
i64 rowspan;
u8 b;
u32 v;
i64 planespan;
i64 ncolors;
planespan = 2*((adata->w+15)/16);
rowspan = planespan*adata->bpp;
if(adata->ncolors>0)
ncolors = adata->ncolors;
else
ncolors = ((i64)1)<<adata->bpp;
for(j=0; j<adata->h; j++) {
for(i=0; i<adata->w; i++) {
v = 0;
for(plane=0; plane<adata->bpp; plane++) {
if(adata->was_compressed==0) {
// TODO: Simplify this.
if(adata->bpp==1) {
b = de_get_bits_symbol(adata->unc_pixels, 1, j*rowspan, i);
}
else if(adata->bpp==2) {
b = de_get_bits_symbol(adata->unc_pixels, 1,
j*rowspan + 2*plane + (i/16)*2, i);
}
else if(adata->bpp==4) {
b = de_get_bits_symbol(adata->unc_pixels, 1,
j*rowspan + 2*plane + (i/2-(i/2)%16)+8*((i%32)/16), i%16);
}
else if(adata->bpp==8) {
b = de_get_bits_symbol(adata->unc_pixels, 1,
j*rowspan + 2*plane + (i-i%16), i%16);
}
else {
b = 0;
}
}
else {
b = de_get_bits_symbol(adata->unc_pixels, 1, j*rowspan + plane*planespan, i);
}
if(b) v |= 1<<plane;
}
if(adata->is_spectrum512) {
v = spectrum512_FindIndex(i, v);
if(j>0) {
v += (unsigned int)(48*(j));
}
}
if(v>=(unsigned int)ncolors) v=(unsigned int)(ncolors-1);
de_bitmap_setpixel_rgb(adata->img, i, j, adata->pal[v]);
}
}
return 1;
}
| 0
|
462,432
|
static rsRetVal startupUXSrv(ptcpsrv_t *pSrv) {
DEFiRet;
int sock;
int sockflags;
struct sockaddr_un local;
uchar *path = pSrv->path == NULL ? UCHAR_CONSTANT("") : pSrv->path;
DBGPRINTF("imptcp: creating listen unix socket at %s\n", path);
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if(sock < 0) {
errmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, "imptcp: error creating unix socket");
ABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);
}
local.sun_family = AF_UNIX;
strncpy(local.sun_path, (char*) path, sizeof(local.sun_path));
if (pSrv->bUnlink) {
unlink(local.sun_path);
}
/* We use non-blocking IO! */
if ((sockflags = fcntl(sock, F_GETFL)) != -1) {
sockflags |= O_NONBLOCK;
/* SETFL could fail too, so get it caught by the subsequent error check. */
sockflags = fcntl(sock, F_SETFL, sockflags);
}
if (sockflags == -1) {
errmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, "imptcp: error setting fcntl(O_NONBLOCK) on unix socket");
ABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);
}
if (bind(sock, (struct sockaddr *)&local, SUN_LEN(&local)) < 0) {
errmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, "imptcp: error while binding unix socket");
ABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);
}
if (listen(sock, 5) < 0) {
errmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, "imptcp: unix socket listen error");
ABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);
}
if(chown(local.sun_path, pSrv->fileUID, pSrv->fileGID) != 0) {
if(pSrv->bFailOnPerms) {
errmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, "imptcp: unix socket chown error");
ABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);
}
}
if(chmod(local.sun_path, pSrv->fCreateMode) != 0) {
if(pSrv->bFailOnPerms) {
errmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, "imptcp: unix socket chmod error");
ABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);
}
}
CHKiRet(addLstn(pSrv, sock, 0));
finalize_it:
if (iRet != RS_RET_OK) {
if (sock != -1) {
close(sock);
}
}
RETiRet;
}
| 0
|
196,993
|
Status DecodeImageAPNG(Span<const uint8_t> bytes, ThreadPool* pool,
CodecInOut* io) {
Reader r;
unsigned int id, i, j, w, h, w0, h0, x0, y0;
unsigned int delay_num, delay_den, dop, bop, rowbytes, imagesize;
unsigned char sig[8];
png_structp png_ptr;
png_infop info_ptr;
CHUNK chunk;
CHUNK chunkIHDR;
std::vector<CHUNK> chunksInfo;
bool isAnimated = false;
bool skipFirst = false;
bool hasInfo = false;
bool all_dispose_bg = true;
APNGFrame frameRaw = {};
r = {bytes.data(), bytes.data() + bytes.size()};
// Not an aPNG => not an error
unsigned char png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
if (r.Read(sig, 8) || memcmp(sig, png_signature, 8) != 0) {
return false;
}
id = read_chunk(&r, &chunkIHDR);
io->frames.clear();
io->dec_pixels = 0;
io->metadata.m.SetUintSamples(8);
io->metadata.m.SetAlphaBits(8);
io->metadata.m.color_encoding =
ColorEncoding::SRGB(); // todo: get data from png metadata
(void)io->dec_hints.Foreach(
[](const std::string& key, const std::string& /*value*/) {
JXL_WARNING("APNG decoder ignoring %s hint", key.c_str());
return true;
});
bool errorstate = true;
if (id == kId_IHDR && chunkIHDR.size == 25) {
w0 = w = png_get_uint_32(chunkIHDR.p + 8);
h0 = h = png_get_uint_32(chunkIHDR.p + 12);
if (w > cMaxPNGSize || h > cMaxPNGSize) {
return false;
}
x0 = 0;
y0 = 0;
delay_num = 1;
delay_den = 10;
dop = 0;
bop = 0;
rowbytes = w * 4;
imagesize = h * rowbytes;
frameRaw.p = new unsigned char[imagesize];
frameRaw.rows = new png_bytep[h * sizeof(png_bytep)];
for (j = 0; j < h; j++) frameRaw.rows[j] = frameRaw.p + j * rowbytes;
if (!processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo,
chunkIHDR, chunksInfo)) {
bool last_base_was_none = true;
while (!r.Eof()) {
id = read_chunk(&r, &chunk);
if (!id) break;
JXL_ASSERT(chunk.p != nullptr);
if (id == kId_acTL && !hasInfo && !isAnimated) {
isAnimated = true;
skipFirst = true;
io->metadata.m.have_animation = true;
io->metadata.m.animation.tps_numerator = 1000;
} else if (id == kId_IEND ||
(id == kId_fcTL && (!hasInfo || isAnimated))) {
if (hasInfo) {
if (!processing_finish(png_ptr, info_ptr)) {
ImageBundle bundle(&io->metadata.m);
bundle.duration = delay_num * 1000 / delay_den;
bundle.origin.x0 = x0;
bundle.origin.y0 = y0;
// TODO(veluca): this could in principle be implemented.
if (last_base_was_none && !all_dispose_bg &&
(x0 != 0 || y0 != 0 || w0 != w || h0 != h || bop != 0)) {
return JXL_FAILURE(
"APNG with dispose-to-0 is not supported for non-full or "
"blended frames");
}
switch (dop) {
case 0:
bundle.use_for_next_frame = true;
last_base_was_none = false;
all_dispose_bg = false;
break;
case 2:
bundle.use_for_next_frame = false;
all_dispose_bg = false;
break;
default:
bundle.use_for_next_frame = false;
last_base_was_none = true;
}
bundle.blend = bop != 0;
io->dec_pixels += w0 * h0;
Image3F sub_frame(w0, h0);
ImageF sub_frame_alpha(w0, h0);
for (size_t y = 0; y < h0; ++y) {
float* const JXL_RESTRICT row_r = sub_frame.PlaneRow(0, y);
float* const JXL_RESTRICT row_g = sub_frame.PlaneRow(1, y);
float* const JXL_RESTRICT row_b = sub_frame.PlaneRow(2, y);
float* const JXL_RESTRICT row_alpha = sub_frame_alpha.Row(y);
uint8_t* const f = frameRaw.rows[y];
for (size_t x = 0; x < w0; ++x) {
if (f[4 * x + 3] == 0) {
row_alpha[x] = 0;
row_r[x] = 0;
row_g[x] = 0;
row_b[x] = 0;
continue;
}
row_r[x] = f[4 * x + 0] * (1.f / 255);
row_g[x] = f[4 * x + 1] * (1.f / 255);
row_b[x] = f[4 * x + 2] * (1.f / 255);
row_alpha[x] = f[4 * x + 3] * (1.f / 255);
}
}
bundle.SetFromImage(std::move(sub_frame), ColorEncoding::SRGB());
bundle.SetAlpha(std::move(sub_frame_alpha),
/*alpha_is_premultiplied=*/false);
io->frames.push_back(std::move(bundle));
} else {
delete[] chunk.p;
break;
}
}
if (id == kId_IEND) {
errorstate = false;
break;
}
// At this point the old frame is done. Let's start a new one.
w0 = png_get_uint_32(chunk.p + 12);
h0 = png_get_uint_32(chunk.p + 16);
x0 = png_get_uint_32(chunk.p + 20);
y0 = png_get_uint_32(chunk.p + 24);
delay_num = png_get_uint_16(chunk.p + 28);
delay_den = png_get_uint_16(chunk.p + 30);
dop = chunk.p[32];
bop = chunk.p[33];
if (w0 > cMaxPNGSize || h0 > cMaxPNGSize || x0 > cMaxPNGSize ||
y0 > cMaxPNGSize || x0 + w0 > w || y0 + h0 > h || dop > 2 ||
bop > 1) {
delete[] chunk.p;
break;
}
if (hasInfo) {
memcpy(chunkIHDR.p + 8, chunk.p + 12, 8);
if (processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo,
chunkIHDR, chunksInfo)) {
delete[] chunk.p;
break;
}
} else
skipFirst = false;
if (io->frames.size() == (skipFirst ? 1 : 0)) {
bop = 0;
if (dop == 2) dop = 1;
}
} else if (id == kId_IDAT) {
hasInfo = true;
if (processing_data(png_ptr, info_ptr, chunk.p, chunk.size)) {
delete[] chunk.p;
break;
}
} else if (id == kId_fdAT && isAnimated) {
png_save_uint_32(chunk.p + 4, chunk.size - 16);
memcpy(chunk.p + 8, "IDAT", 4);
if (processing_data(png_ptr, info_ptr, chunk.p + 4, chunk.size - 4)) {
delete[] chunk.p;
break;
}
} else if (!isAbc(chunk.p[4]) || !isAbc(chunk.p[5]) ||
!isAbc(chunk.p[6]) || !isAbc(chunk.p[7])) {
delete[] chunk.p;
break;
} else if (!hasInfo) {
if (processing_data(png_ptr, info_ptr, chunk.p, chunk.size)) {
delete[] chunk.p;
break;
}
chunksInfo.push_back(chunk);
continue;
}
delete[] chunk.p;
}
}
delete[] frameRaw.rows;
delete[] frameRaw.p;
}
for (i = 0; i < chunksInfo.size(); i++) delete[] chunksInfo[i].p;
chunksInfo.clear();
delete[] chunkIHDR.p;
if (errorstate) return false;
SetIntensityTarget(io);
return true;
}
| 1
|
198,282
|
void ReshapeSparseTensor(OpKernelContext *context,
const Tensor &input_indices_in,
const Tensor &input_shape_in,
const Tensor &target_shape_in, int output_indices_idx,
int output_shape_idx) {
OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices_in.shape()),
errors::InvalidArgument(
"Input indices should be a matrix but received shape ",
input_indices_in.shape().DebugString()));
OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape_in.shape()),
errors::InvalidArgument(
"Input shape should be a vector but received shape ",
input_shape_in.shape().DebugString()));
OP_REQUIRES(context, TensorShapeUtils::IsVector(target_shape_in.shape()),
errors::InvalidArgument(
"Target shape should be a vector but received shape ",
target_shape_in.shape().DebugString()));
const int64_t output_rank = target_shape_in.NumElements();
const TensorShape input_shape(input_shape_in.vec<int64>());
const int64_t dense_size = input_shape.num_elements();
const int64_t nnz = input_indices_in.shape().dim_size(0);
// Compute the output shape. Determine product of specified dimensions, and
// find the index of the unspecified one.
TensorShape output_shape;
int64_t product = 1;
int unknown_index = -1;
auto target_shape = target_shape_in.vec<int64>();
for (int d = 0; d < output_rank; ++d) {
const int64_t size = target_shape(d);
if (size == -1) {
OP_REQUIRES(
context, unknown_index == -1,
errors::InvalidArgument("only one output dimension may be -1, "
"not both ",
unknown_index, " and ", d));
unknown_index = d;
output_shape.AddDim(1);
} else {
OP_REQUIRES(context, size >= 0,
errors::InvalidArgument("size ", d,
" must be non-negative, not ", size));
product *= size;
output_shape.AddDim(size);
}
}
if (unknown_index != -1) {
OP_REQUIRES(
context, product > 0,
errors::InvalidArgument("reshape cannot infer the missing "
"input size for an empty tensor unless all "
"specified input sizes are non-zero"));
const int64_t missing = dense_size / product;
OP_REQUIRES(
context, product * missing == dense_size,
errors::InvalidArgument(
"Input to reshape is a SparseTensor with ", dense_size,
" dense values, but the requested shape requires a multiple of ",
product, ". input_shape=", input_shape.DebugString(),
" output_shape=", output_shape.DebugString()));
output_shape.set_dim(unknown_index, missing);
}
OP_REQUIRES(
context, output_shape.num_elements() == dense_size,
errors::InvalidArgument("Input to reshape is a tensor with ", dense_size,
" dense values, but the requested shape has ",
output_shape.num_elements(),
". input_shape=", input_shape.DebugString(),
" output_shape=", output_shape.DebugString()));
// Optimize for reshaping to the same shape.
if (input_shape == output_shape) {
context->set_output(output_indices_idx, input_indices_in);
context->set_output(output_shape_idx, input_shape_in);
return;
}
Tensor *result_shape = nullptr;
OP_REQUIRES_OK(context, context->allocate_output(output_shape_idx,
TensorShape({output_rank}),
&result_shape));
auto output_shape_vec = result_shape->vec<int64>();
for (int j = 0; j < output_shape.dims(); ++j) {
output_shape_vec(j) = output_shape.dim_size(j);
}
Tensor *result_indices = nullptr;
OP_REQUIRES_OK(context,
context->allocate_output(output_indices_idx,
TensorShape({nnz, output_rank}),
&result_indices));
if (nnz > 0) {
OP_REQUIRES_OK(context, functor::ReshapeSparseTensorFunctor<Device>()(
context, input_shape, output_shape,
input_indices_in.matrix<int64>(),
result_indices->matrix<int64>()));
}
}
| 1
|
343,243
|
void dostru(const char *arg)
{
if (arg == NULL || !*arg) {
addreply_noformat(501, MSG_MISSING_ARG);
} else if (strcasecmp(arg, "F")) {
addreply_noformat(504, MSG_STRU_FAILURE);
} else {
addreply_noformat(200, "F OK");
}
}
| 0
|
221,407
|
static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
{
/*
* This function merges the msr permission bitmaps of kvm and the
* nested vmcb. It is optimized in that it only merges the parts where
* the kvm msr permission bitmap may contain zero bits
*/
int i;
if (!(vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT)))
return true;
for (i = 0; i < MSRPM_OFFSETS; i++) {
u32 value, p;
u64 offset;
if (msrpm_offsets[i] == 0xffffffff)
break;
p = msrpm_offsets[i];
offset = svm->nested.ctl.msrpm_base_pa + (p * 4);
if (kvm_vcpu_read_guest(&svm->vcpu, offset, &value, 4))
return false;
svm->nested.msrpm[p] = svm->msrpm[p] | value;
}
svm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm));
return true;
}
| 0
|
509,477
|
static enum data_file_type maria_row_type(HA_CREATE_INFO *info)
{
if (info->transactional == HA_CHOICE_YES)
return BLOCK_RECORD;
switch (info->row_type) {
case ROW_TYPE_FIXED: return STATIC_RECORD;
case ROW_TYPE_DYNAMIC: return DYNAMIC_RECORD;
default: return BLOCK_RECORD;
}
}
| 0
|
252,317
|
static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr,
size_t tmpBufSize, size_t inLen, int num_channels,
const EXRChannelInfo *channels, int data_width,
int num_lines) {
if (inLen == tmpBufSize) {
// Data is not compressed(Issue 40).
memcpy(outPtr, inPtr, inLen);
return true;
}
std::vector<unsigned char> bitmap(BITMAP_SIZE);
unsigned short minNonZero;
unsigned short maxNonZero;
#if !MINIZ_LITTLE_ENDIAN
// @todo { PIZ compression on BigEndian architecture. }
assert(0);
return false;
#endif
memset(bitmap.data(), 0, BITMAP_SIZE);
const unsigned char *ptr = inPtr;
// minNonZero = *(reinterpret_cast<const unsigned short *>(ptr));
tinyexr::cpy2(&minNonZero, reinterpret_cast<const unsigned short *>(ptr));
// maxNonZero = *(reinterpret_cast<const unsigned short *>(ptr + 2));
tinyexr::cpy2(&maxNonZero, reinterpret_cast<const unsigned short *>(ptr + 2));
ptr += 4;
if (maxNonZero >= BITMAP_SIZE) {
return false;
}
if (minNonZero <= maxNonZero) {
memcpy(reinterpret_cast<char *>(&bitmap[0] + minNonZero), ptr,
maxNonZero - minNonZero + 1);
ptr += maxNonZero - minNonZero + 1;
}
std::vector<unsigned short> lut(USHORT_RANGE);
memset(lut.data(), 0, sizeof(unsigned short) * USHORT_RANGE);
unsigned short maxValue = reverseLutFromBitmap(bitmap.data(), lut.data());
//
// Huffman decoding
//
int length;
// length = *(reinterpret_cast<const int *>(ptr));
tinyexr::cpy4(&length, reinterpret_cast<const int *>(ptr));
ptr += sizeof(int);
if (size_t((ptr - inPtr) + length) > inLen) {
return false;
}
std::vector<unsigned short> tmpBuffer(tmpBufSize);
hufUncompress(reinterpret_cast<const char *>(ptr), length, &tmpBuffer);
//
// Wavelet decoding
//
std::vector<PIZChannelData> channelData(static_cast<size_t>(num_channels));
unsigned short *tmpBufferEnd = &tmpBuffer.at(0);
for (size_t i = 0; i < static_cast<size_t>(num_channels); ++i) {
const EXRChannelInfo &chan = channels[i];
size_t pixelSize = sizeof(int); // UINT and FLOAT
if (chan.pixel_type == TINYEXR_PIXELTYPE_HALF) {
pixelSize = sizeof(short);
}
channelData[i].start = tmpBufferEnd;
channelData[i].end = channelData[i].start;
channelData[i].nx = data_width;
channelData[i].ny = num_lines;
// channelData[i].ys = 1;
channelData[i].size = static_cast<int>(pixelSize / sizeof(short));
tmpBufferEnd += channelData[i].nx * channelData[i].ny * channelData[i].size;
}
for (size_t i = 0; i < channelData.size(); ++i) {
PIZChannelData &cd = channelData[i];
for (int j = 0; j < cd.size; ++j) {
wav2Decode(cd.start + j, cd.nx, cd.size, cd.ny, cd.nx * cd.size,
maxValue);
}
}
//
// Expand the pixel data to their original range
//
applyLut(lut.data(), &tmpBuffer.at(0), static_cast<int>(tmpBufSize));
for (int y = 0; y < num_lines; y++) {
for (size_t i = 0; i < channelData.size(); ++i) {
PIZChannelData &cd = channelData[i];
// if (modp (y, cd.ys) != 0)
// continue;
size_t n = static_cast<size_t>(cd.nx * cd.size);
memcpy(outPtr, cd.end, static_cast<size_t>(n * sizeof(unsigned short)));
outPtr += n * sizeof(unsigned short);
cd.end += n;
}
}
return true;
}
| 0
|
224,236
|
static int _find_sm_by_from_vaddr_cb(void *incoming, void *in, void *user) {
RIOSubMap *bd = (RIOSubMap *)incoming, *sm = (RIOSubMap *)in;
if (r_io_submap_from (bd) < r_io_submap_from (sm)) {
return -1;
}
if (r_io_submap_from (bd) > r_io_submap_from (sm)) {
return 1;
}
return 0;
}
| 0
|
231,795
|
Buf recvEncryptedStream(
StreamId streamId,
folly::IOBuf& data,
uint64_t offset = 0,
bool eof = false) {
PacketNum packetNum = clientNextAppDataPacketNum++;
auto packetData = packetToBuf(createStreamPacket(
clientConnectionId.value_or(getTestConnectionId()),
*server->getConn().serverConnectionId,
packetNum,
streamId,
data,
0 /* cipherOverhead */,
0 /* largestAcked */,
folly::none /* longHeaderOverride */,
eof,
folly::none,
offset));
deliverData(packetData->clone());
return packetData;
}
| 0
|
446,427
|
static cache_accel_t *read_cache_accel(RzBuffer *cache_buf, cache_hdr_t *hdr, cache_map_t *maps) {
if (!cache_buf || !hdr || !hdr->accelerateInfoSize || !hdr->accelerateInfoAddr) {
return NULL;
}
ut64 offset = va2pa(hdr->accelerateInfoAddr, hdr->mappingCount, maps, cache_buf, 0, NULL, NULL);
if (!offset) {
return NULL;
}
ut64 size = sizeof(cache_accel_t);
cache_accel_t *accel = RZ_NEW0(cache_accel_t);
if (!accel) {
return NULL;
}
if (rz_buf_fread_at(cache_buf, offset, (ut8 *)accel, "16il", 1) != size) {
RZ_FREE(accel);
return NULL;
}
accel->imagesExtrasOffset += offset;
accel->bottomUpListOffset += offset;
accel->dylibTrieOffset += offset;
accel->initializersOffset += offset;
accel->dofSectionsOffset += offset;
accel->reExportListOffset += offset;
accel->depListOffset += offset;
accel->rangeTableOffset += offset;
return accel;
}
| 0
|
344,245
|
lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {
if (l_unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */
if (n == 0)
luaG_runerror(L, "attempt to perform 'n%%0'");
return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */
}
else {
lua_Integer r = m % n;
if (r != 0 && (r ^ n) < 0) /* 'm/n' would be non-integer negative? */
r += n; /* correct result for different rounding */
return r;
}
}
| 0
|
229,172
|
static void virtio_serial_post_load_timer_cb(void *opaque)
{
uint32_t i;
VirtIOSerial *s = VIRTIO_SERIAL(opaque);
VirtIOSerialPort *port;
uint8_t host_connected;
VirtIOSerialPortClass *vsc;
if (!s->post_load) {
return;
}
for (i = 0 ; i < s->post_load->nr_active_ports; ++i) {
port = s->post_load->connected[i].port;
host_connected = s->post_load->connected[i].host_connected;
if (host_connected != port->host_connected) {
/*
* We have to let the guest know of the host connection
* status change
*/
send_control_event(s, port->id, VIRTIO_CONSOLE_PORT_OPEN,
port->host_connected);
}
vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
if (vsc->set_guest_connected) {
vsc->set_guest_connected(port, port->guest_connected);
}
}
g_free(s->post_load->connected);
timer_free(s->post_load->timer);
g_free(s->post_load);
s->post_load = NULL;
}
| 0
|
402,591
|
generate_name(cms_context *cms, SECItem *der, CERTName *certname)
{
void *marka = PORT_ArenaMark(cms->arena);
CERTRDN **rdns = certname->rdns;
CERTRDN *rdn;
int num_items = 0;
int rc = 0;
while (rdns && (rdn = *rdns++) != NULL) {
CERTAVA **avas = rdn->avas;
CERTAVA *ava;
while (avas && (ava = *avas++) != NULL)
num_items++;
}
if (num_items == 0) {
PORT_ArenaRelease(cms->arena, marka);
cmsreterr(-1, cms, "No name items to encode");
}
SECItem items[num_items];
int i = 0;
rdns = certname->rdns;
while (rdns && (rdn = *rdns++) != NULL) {
CERTAVA **avas = rdn->avas;
CERTAVA *ava;
while (avas && (ava = *avas++) != NULL) {
SECItem avader;
rc = generate_ava(cms, &avader, ava);
if (rc < 0) {
PORT_ArenaRelease(cms->arena, marka);
return -1;
}
SECItem *list[2] = {
&avader,
NULL,
};
rc = wrap_in_set(cms, &items[i], list);
if (rc < 0) {
PORT_ArenaRelease(cms->arena, marka);
return -1;
}
i++;
}
}
wrap_in_seq(cms, der, &items[0], num_items);
PORT_ArenaUnmark(cms->arena, marka);
return 0;
}
| 0
|
459,154
|
tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain)
{
struct tcf_chain *chain_next = __tcf_get_next_chain(block, chain);
if (chain)
tcf_chain_put(chain);
return chain_next;
}
| 0
|
484,782
|
static int setup_netfront(struct xenbus_device *dev,
struct netfront_queue *queue, unsigned int feature_split_evtchn)
{
struct xen_netif_tx_sring *txs;
struct xen_netif_rx_sring *rxs;
int err;
queue->tx_ring_ref = INVALID_GRANT_REF;
queue->rx_ring_ref = INVALID_GRANT_REF;
queue->rx.sring = NULL;
queue->tx.sring = NULL;
err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&txs,
1, &queue->tx_ring_ref);
if (err)
goto fail;
XEN_FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE);
err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&rxs,
1, &queue->rx_ring_ref);
if (err)
goto fail;
XEN_FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE);
if (feature_split_evtchn)
err = setup_netfront_split(queue);
/* setup single event channel if
* a) feature-split-event-channels == 0
* b) feature-split-event-channels == 1 but failed to setup
*/
if (!feature_split_evtchn || err)
err = setup_netfront_single(queue);
if (err)
goto fail;
return 0;
fail:
xenbus_teardown_ring((void **)&queue->rx.sring, 1, &queue->rx_ring_ref);
xenbus_teardown_ring((void **)&queue->tx.sring, 1, &queue->tx_ring_ref);
return err;
}
| 0
|
231,789
|
TEST_F(QuicServerTransportTest, RecvStopSendingFrameAfterReset) {
server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 3;
std::array<std::string, 4> words = {
"Hey Bob, this is Alice, for real.",
"What message did I send you last time?",
"You don't sound like Alice",
"You are a liar!",
};
StreamId streamId1 = 0x00;
StreamId streamId2 = 0x04;
auto stream1 = server->getNonConstConn().streamManager->getStream(streamId1);
stream1->readBuffer.emplace_back(IOBuf::copyBuffer(words.at(0)), 0, false);
stream1->readBuffer.emplace_back(
IOBuf::copyBuffer(words.at(1)), words.at(0).length(), false);
stream1->retransmissionBuffer.emplace(
std::piecewise_construct,
std::forward_as_tuple(0),
std::forward_as_tuple(std::make_unique<StreamBuffer>(
IOBuf::copyBuffer(words.at(2)), 0, false)));
stream1->writeBuffer.append(IOBuf::copyBuffer(words.at(3)));
stream1->currentWriteOffset = words.at(2).length() + words.at(3).length();
stream1->currentReadOffset = words.at(0).length() + words.at(1).length();
auto stream2 = server->getNonConstConn().streamManager->getStream(streamId2);
stream2->readBuffer.emplace_back(IOBuf::copyBuffer(words.at(0)), 0, false);
stream2->readBuffer.emplace_back(
IOBuf::copyBuffer(words.at(1)), words.at(0).length(), false);
stream2->retransmissionBuffer.emplace(
std::piecewise_construct,
std::forward_as_tuple(0),
std::forward_as_tuple(std::make_unique<StreamBuffer>(
IOBuf::copyBuffer(words.at(2)), 0, false)));
stream2->writeBuffer.append(IOBuf::copyBuffer(words.at(3)));
stream2->currentWriteOffset = words.at(2).length() + words.at(3).length();
stream2->currentReadOffset = words.at(0).length() + words.at(1).length();
server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 5;
ShortHeader header(
ProtectionType::KeyPhaseZero,
*server->getConn().serverConnectionId,
clientNextAppDataPacketNum++);
RegularQuicPacketBuilder builder(
server->getConn().udpSendPacketLen,
std::move(header),
0 /* largestAcked */);
builder.encodePacketHeader();
StopSendingFrame stopSendingFrame1(
streamId1, GenericApplicationErrorCode::UNKNOWN);
StopSendingFrame stopSendingFrame2(
streamId2, GenericApplicationErrorCode::UNKNOWN);
ASSERT_TRUE(builder.canBuildPacket());
writeFrame(QuicSimpleFrame(stopSendingFrame1), builder);
writeFrame(QuicSimpleFrame(stopSendingFrame2), builder);
auto packet = std::move(builder).buildPacket();
EXPECT_CALL(
connCallback, onStopSending(_, GenericApplicationErrorCode::UNKNOWN))
.WillOnce(Invoke([&](StreamId /*sid*/, ApplicationErrorCode /*e*/) {
server->close(folly::none);
}));
EXPECT_THROW(deliverData(packetToBuf(packet)), std::runtime_error);
}
| 0
|
486,830
|
static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)
{
CadenceGEMState *s;
uint32_t retval;
s = (CadenceGEMState *)opaque;
offset >>= 2;
retval = s->regs[offset];
DB_PRINT("offset: 0x%04x read: 0x%08x\n", (unsigned)offset*4, retval);
switch (offset) {
case GEM_ISR:
DB_PRINT("lowering irqs on ISR read\n");
/* The interrupts get updated at the end of the function. */
break;
case GEM_PHYMNTNC:
if (retval & GEM_PHYMNTNC_OP_R) {
uint32_t phy_addr, reg_num;
phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
if (phy_addr == s->phy_addr) {
reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
retval &= 0xFFFF0000;
retval |= gem_phy_read(s, reg_num);
} else {
retval |= 0xFFFF; /* No device at this address */
}
}
break;
}
/* Squash read to clear bits */
s->regs[offset] &= ~(s->regs_rtc[offset]);
/* Do not provide write only bits */
retval &= ~(s->regs_wo[offset]);
DB_PRINT("0x%08x\n", retval);
gem_update_int_status(s);
return retval;
}
| 0
|
301,018
|
pcxcmyk_print_page(gx_device_printer * pdev, gp_file * file)
{
pcx_header header;
header = pcx_header_prototype;
header.version = 2;
header.bpp = 4;
header.nplanes = 1;
/* Fill the palette appropriately. */
memcpy((byte *) header.palette, pcx_cmyk_palette,
sizeof(pcx_cmyk_palette));
return pcx_write_page(pdev, file, &header, false);
}
| 0
|
247,122
|
void gf_fs_del(GF_FilterSession *fsess)
{
assert(fsess);
gf_fs_stop(fsess);
GF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, ("Session destroy begin\n"));
if (fsess->parsed_args) {
while (gf_list_count(fsess->parsed_args)) {
GF_FSArgItem *ai = gf_list_pop_back(fsess->parsed_args);
gf_free(ai->argname);
gf_free(ai);
}
gf_list_del(fsess->parsed_args);
}
//temporary until we don't introduce fsess_stop
assert(fsess->run_status != GF_OK);
if (fsess->filters) {
u32 i, count=gf_list_count(fsess->filters);
//first pass: disconnect all filters, since some may have references to property maps or packets
for (i=0; i<count; i++) {
u32 j;
GF_Filter *filter = gf_list_get(fsess->filters, i);
filter->process_th_id = 0;
filter->scheduled_for_next_task = GF_TRUE;
if (filter->detached_pid_inst) {
while (gf_list_count(filter->detached_pid_inst)) {
GF_FilterPidInst *pidi = gf_list_pop_front(filter->detached_pid_inst);
gf_filter_pid_inst_del(pidi);
}
gf_list_del(filter->detached_pid_inst);
filter->detached_pid_inst = NULL;
}
if (filter->postponed_packets) {
while (gf_list_count(filter->postponed_packets)) {
GF_FilterPacket *pck = gf_list_pop_front(filter->postponed_packets);
gf_filter_packet_destroy(pck);
}
gf_list_del(filter->postponed_packets);
filter->postponed_packets = NULL;
}
gf_mx_p(filter->tasks_mx);
for (j=0; j<filter->num_input_pids; j++) {
GF_FilterPidInst *pidi = gf_list_get(filter->input_pids, j);
gf_filter_pid_inst_reset(pidi);
}
gf_mx_v(filter->tasks_mx);
filter->scheduled_for_next_task = GF_FALSE;
}
//second pass, finalize all
for (i=0; i<count; i++) {
GF_Filter *filter = gf_list_get(fsess->filters, i);
if (filter->freg->finalize && !filter->finalized) {
filter->finalized = GF_TRUE;
FSESS_CHECK_THREAD(filter)
filter->freg->finalize(filter);
}
}
while (gf_list_count(fsess->filters)) {
GF_Filter *filter = gf_list_pop_back(fsess->filters);
gf_filter_del(filter);
}
gf_list_del(fsess->filters);
fsess->filters = NULL;
}
gf_fs_unload_script(fsess, NULL);
if (fsess->download_manager) gf_dm_del(fsess->download_manager);
#ifndef GPAC_DISABLE_PLAYER
if (fsess->font_manager) gf_font_manager_del(fsess->font_manager);
#endif
if (fsess->registry) {
while (gf_list_count(fsess->registry)) {
GF_FilterRegister *freg = gf_list_pop_back(fsess->registry);
if (freg->register_free) freg->register_free(fsess, freg);
}
gf_list_del(fsess->registry);
}
if (fsess->tasks)
gf_fq_del(fsess->tasks, gf_void_del);
if (fsess->tasks_reservoir)
gf_fq_del(fsess->tasks_reservoir, gf_void_del);
if (fsess->threads) {
if (fsess->main_thread_tasks)
gf_fq_del(fsess->main_thread_tasks, gf_void_del);
while (gf_list_count(fsess->threads)) {
GF_SessionThread *sess_th = gf_list_pop_back(fsess->threads);
gf_th_del(sess_th->th);
gf_free(sess_th);
}
gf_list_del(fsess->threads);
}
if (fsess->prop_maps_reservoir)
gf_fq_del(fsess->prop_maps_reservoir, gf_propmap_del);
#if GF_PROPS_HASHTABLE_SIZE
if (fsess->prop_maps_list_reservoir)
gf_fq_del(fsess->prop_maps_list_reservoir, (gf_destruct_fun) gf_list_del);
#endif
if (fsess->prop_maps_entry_reservoir)
gf_fq_del(fsess->prop_maps_entry_reservoir, gf_void_del);
if (fsess->prop_maps_entry_data_alloc_reservoir)
gf_fq_del(fsess->prop_maps_entry_data_alloc_reservoir, gf_propalloc_del);
if (fsess->pcks_refprops_reservoir)
gf_fq_del(fsess->pcks_refprops_reservoir, gf_void_del);
if (fsess->props_mx)
gf_mx_del(fsess->props_mx);
if (fsess->info_mx)
gf_mx_del(fsess->info_mx);
if (fsess->ui_mx)
gf_mx_del(fsess->ui_mx);
if (fsess->semaphore_other && (fsess->semaphore_other != fsess->semaphore_main) )
gf_sema_del(fsess->semaphore_other);
if (fsess->semaphore_main)
gf_sema_del(fsess->semaphore_main);
if (fsess->tasks_mx)
gf_mx_del(fsess->tasks_mx);
if (fsess->filters_mx)
gf_mx_del(fsess->filters_mx);
if (fsess->evt_mx) gf_mx_del(fsess->evt_mx);
if (fsess->event_listeners) gf_list_del(fsess->event_listeners);
if (fsess->links) {
gf_filter_sess_reset_graph(fsess, NULL);
gf_list_del(fsess->links);
}
if (fsess->links_mx) gf_mx_del(fsess->links_mx);
#ifndef GPAC_DISABLE_3D
gf_list_del(fsess->gl_providers);
if (fsess->gl_driver) {
fsess->gl_driver->Shutdown(fsess->gl_driver);
gf_modules_close_interface((GF_BaseInterface *)fsess->gl_driver);
}
#endif
if (fsess->auto_inc_nums) {
while(gf_list_count(fsess->auto_inc_nums)) {
GF_FSAutoIncNum *aint = gf_list_pop_back(fsess->auto_inc_nums);
gf_free(aint);
}
gf_list_del(fsess->auto_inc_nums);
}
#ifdef GF_FS_ENABLE_LOCALES
if (fsess->uri_relocators) gf_list_del(fsess->uri_relocators);
if (fsess->locales.szAbsRelocatedPath) gf_free(fsess->locales.szAbsRelocatedPath);
#endif
gf_free(fsess);
GF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, ("Session destroyed\n"));
}
| 0
|
411,918
|
tor_version_parse(const char *s, tor_version_t *out)
{
char *eos=NULL;
const char *cp=NULL;
/* Format is:
* "Tor " ? NUM dot NUM dot NUM [ ( pre | rc | dot ) NUM [ - tag ] ]
*/
tor_assert(s);
tor_assert(out);
memset(out, 0, sizeof(tor_version_t));
if (!strcasecmpstart(s, "Tor "))
s += 4;
/* Get major. */
out->major = (int)strtol(s,&eos,10);
if (!eos || eos==s || *eos != '.') return -1;
cp = eos+1;
/* Get minor */
out->minor = (int) strtol(cp,&eos,10);
if (!eos || eos==cp || *eos != '.') return -1;
cp = eos+1;
/* Get micro */
out->micro = (int) strtol(cp,&eos,10);
if (!eos || eos==cp) return -1;
if (!*eos) {
out->status = VER_RELEASE;
out->patchlevel = 0;
return 0;
}
cp = eos;
/* Get status */
if (*cp == '.') {
out->status = VER_RELEASE;
++cp;
} else if (0==strncmp(cp, "pre", 3)) {
out->status = VER_PRE;
cp += 3;
} else if (0==strncmp(cp, "rc", 2)) {
out->status = VER_RC;
cp += 2;
} else {
return -1;
}
/* Get patchlevel */
out->patchlevel = (int) strtol(cp,&eos,10);
if (!eos || eos==cp) return -1;
cp = eos;
/* Get status tag. */
if (*cp == '-' || *cp == '.')
++cp;
eos = (char*) find_whitespace(cp);
if (eos-cp >= (int)sizeof(out->status_tag))
strlcpy(out->status_tag, cp, sizeof(out->status_tag));
else {
memcpy(out->status_tag, cp, eos-cp);
out->status_tag[eos-cp] = 0;
}
cp = eat_whitespace(eos);
if (!strcmpstart(cp, "(r")) {
cp += 2;
out->svn_revision = (int) strtol(cp,&eos,10);
} else if (!strcmpstart(cp, "(git-")) {
char *close_paren = strchr(cp, ')');
int hexlen;
char digest[DIGEST_LEN];
if (! close_paren)
return -1;
cp += 5;
if (close_paren-cp > HEX_DIGEST_LEN)
return -1;
hexlen = (int)(close_paren-cp);
memset(digest, 0, sizeof(digest));
if ( hexlen == 0 || (hexlen % 2) == 1)
return -1;
if (base16_decode(digest, hexlen/2, cp, hexlen))
return -1;
memcpy(out->git_tag, digest, hexlen/2);
out->git_tag_len = hexlen/2;
}
return 0;
}
| 0
|
484,065
|
START_TEST(SecureChannel_sendSymmetricMessage_modeNone) {
// initialize dummy message
UA_ReadRequest dummyMessage;
UA_ReadRequest_init(&dummyMessage);
UA_DataType dummyType = UA_TYPES[UA_TYPES_READREQUEST];
testChannel.securityMode = UA_MESSAGESECURITYMODE_NONE;
UA_StatusCode retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42, UA_MESSAGETYPE_MSG,
&dummyMessage, &dummyType);
ck_assert_msg(retval == UA_STATUSCODE_GOOD, "Expected success");
ck_assert_msg(!fCalled.sym_sign, "Expected message to not have been signed");
ck_assert_msg(!fCalled.sym_enc, "Expected message to not have been encrypted");
} END_TEST
| 0
|
366,186
|
static inline struct hlist_head *mp_hash(struct dentry *dentry)
{
unsigned long tmp = ((unsigned long)dentry / L1_CACHE_BYTES);
tmp = tmp + (tmp >> mp_hash_shift);
return &mountpoint_hashtable[tmp & mp_hash_mask];
}
| 0
|
389,551
|
xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose, void *ioctx,
const char *URL,
const char *encoding, int options)
{
xmlParserInputBufferPtr input;
xmlParserInputPtr stream;
if (ioread == NULL)
return (NULL);
if (ctxt == NULL)
return (NULL);
xmlCtxtReset(ctxt);
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
XML_CHAR_ENCODING_NONE);
if (input == NULL)
return (NULL);
stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
if (stream == NULL) {
xmlFreeParserInputBuffer(input);
return (NULL);
}
inputPush(ctxt, stream);
return (xmlDoRead(ctxt, URL, encoding, options, 1));
}
| 0
|
436,109
|
__must_hold(&req->ctx->completion_lock)
{
bool posted = false;
if (likely(req->flags & REQ_F_LINK_TIMEOUT))
posted = io_kill_linked_timeout(req);
if (unlikely((req->flags & REQ_F_FAIL) &&
!(req->flags & REQ_F_HARDLINK))) {
posted |= (req->link != NULL);
io_fail_links(req);
}
return posted;
}
| 0
|
432,221
|
static void flatview_simplify(FlatView *view)
{
unsigned i, j;
i = 0;
while (i < view->nr) {
j = i + 1;
while (j < view->nr
&& can_merge(&view->ranges[j-1], &view->ranges[j])) {
int128_addto(&view->ranges[i].addr.size, view->ranges[j].addr.size);
++j;
}
++i;
memmove(&view->ranges[i], &view->ranges[j],
(view->nr - j) * sizeof(view->ranges[j]));
view->nr -= j - i;
}
}
| 0
|
301,427
|
static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void *data,
size_t n, off_t offset)
{
ssize_t result;
#if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
START_PROFILE_BYTES(syscall_pread, n);
result = sys_pread(fsp->fh->fd, data, n, offset);
END_PROFILE(syscall_pread);
if (result == -1 && errno == ESPIPE) {
/* Maintain the fiction that pipes can be seeked (sought?) on. */
result = SMB_VFS_READ(fsp, data, n);
fsp->fh->pos = 0;
}
#else /* HAVE_PREAD */
off_t curr;
int lerrno;
curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
if (curr == -1 && errno == ESPIPE) {
/* Maintain the fiction that pipes can be seeked (sought?) on. */
result = SMB_VFS_READ(fsp, data, n);
fsp->fh->pos = 0;
return result;
}
if (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) {
return -1;
}
errno = 0;
result = SMB_VFS_READ(fsp, data, n);
lerrno = errno;
SMB_VFS_LSEEK(fsp, curr, SEEK_SET);
errno = lerrno;
#endif /* HAVE_PREAD */
return result;
}
| 0
|
326,087
|
regatom(int *flagp)
{
char_u *ret;
int flags;
int c;
char_u *p;
int extra = 0;
int save_prev_at_start = prev_at_start;
*flagp = WORST; // Tentatively.
c = getchr();
switch (c)
{
case Magic('^'):
ret = regnode(BOL);
break;
case Magic('$'):
ret = regnode(EOL);
#if defined(FEAT_SYN_HL) || defined(PROTO)
had_eol = TRUE;
#endif
break;
case Magic('<'):
ret = regnode(BOW);
break;
case Magic('>'):
ret = regnode(EOW);
break;
case Magic('_'):
c = no_Magic(getchr());
if (c == '^') // "\_^" is start-of-line
{
ret = regnode(BOL);
break;
}
if (c == '$') // "\_$" is end-of-line
{
ret = regnode(EOL);
#if defined(FEAT_SYN_HL) || defined(PROTO)
had_eol = TRUE;
#endif
break;
}
extra = ADD_NL;
*flagp |= HASNL;
// "\_[" is character range plus newline
if (c == '[')
goto collection;
// "\_x" is character class plus newline
// FALLTHROUGH
// Character classes.
case Magic('.'):
case Magic('i'):
case Magic('I'):
case Magic('k'):
case Magic('K'):
case Magic('f'):
case Magic('F'):
case Magic('p'):
case Magic('P'):
case Magic('s'):
case Magic('S'):
case Magic('d'):
case Magic('D'):
case Magic('x'):
case Magic('X'):
case Magic('o'):
case Magic('O'):
case Magic('w'):
case Magic('W'):
case Magic('h'):
case Magic('H'):
case Magic('a'):
case Magic('A'):
case Magic('l'):
case Magic('L'):
case Magic('u'):
case Magic('U'):
p = vim_strchr(classchars, no_Magic(c));
if (p == NULL)
EMSG_RET_NULL(_(e_invalid_use_of_underscore));
// When '.' is followed by a composing char ignore the dot, so that
// the composing char is matched here.
if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr()))
{
c = getchr();
goto do_multibyte;
}
ret = regnode(classcodes[p - classchars] + extra);
*flagp |= HASWIDTH | SIMPLE;
break;
case Magic('n'):
if (reg_string)
{
// In a string "\n" matches a newline character.
ret = regnode(EXACTLY);
regc(NL);
regc(NUL);
*flagp |= HASWIDTH | SIMPLE;
}
else
{
// In buffer text "\n" matches the end of a line.
ret = regnode(NEWL);
*flagp |= HASWIDTH | HASNL;
}
break;
case Magic('('):
if (one_exactly)
EMSG_ONE_RET_NULL;
ret = reg(REG_PAREN, &flags);
if (ret == NULL)
return NULL;
*flagp |= flags & (HASWIDTH | SPSTART | HASNL | HASLOOKBH);
break;
case NUL:
case Magic('|'):
case Magic('&'):
case Magic(')'):
if (one_exactly)
EMSG_ONE_RET_NULL;
// Supposed to be caught earlier.
IEMSG_RET_NULL(_(e_internal_error_in_regexp));
// NOTREACHED
case Magic('='):
case Magic('?'):
case Magic('+'):
case Magic('@'):
case Magic('{'):
case Magic('*'):
c = no_Magic(c);
EMSG3_RET_NULL(_(e_str_chr_follows_nothing),
(c == '*' ? reg_magic >= MAGIC_ON : reg_magic == MAGIC_ALL), c);
// NOTREACHED
case Magic('~'): // previous substitute pattern
if (reg_prev_sub != NULL)
{
char_u *lp;
ret = regnode(EXACTLY);
lp = reg_prev_sub;
while (*lp != NUL)
regc(*lp++);
regc(NUL);
if (*reg_prev_sub != NUL)
{
*flagp |= HASWIDTH;
if ((lp - reg_prev_sub) == 1)
*flagp |= SIMPLE;
}
}
else
EMSG_RET_NULL(_(e_no_previous_substitute_regular_expression));
break;
case Magic('1'):
case Magic('2'):
case Magic('3'):
case Magic('4'):
case Magic('5'):
case Magic('6'):
case Magic('7'):
case Magic('8'):
case Magic('9'):
{
int refnum;
refnum = c - Magic('0');
if (!seen_endbrace(refnum))
return NULL;
ret = regnode(BACKREF + refnum);
}
break;
case Magic('z'):
{
c = no_Magic(getchr());
switch (c)
{
#ifdef FEAT_SYN_HL
case '(': if ((reg_do_extmatch & REX_SET) == 0)
EMSG_RET_NULL(_(e_z_not_allowed_here));
if (one_exactly)
EMSG_ONE_RET_NULL;
ret = reg(REG_ZPAREN, &flags);
if (ret == NULL)
return NULL;
*flagp |= flags & (HASWIDTH|SPSTART|HASNL|HASLOOKBH);
re_has_z = REX_SET;
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': if ((reg_do_extmatch & REX_USE) == 0)
EMSG_RET_NULL(_(e_z1_z9_not_allowed_here));
ret = regnode(ZREF + c - '0');
re_has_z = REX_USE;
break;
#endif
case 's': ret = regnode(MOPEN + 0);
if (re_mult_next("\\zs") == FAIL)
return NULL;
break;
case 'e': ret = regnode(MCLOSE + 0);
if (re_mult_next("\\ze") == FAIL)
return NULL;
break;
default: EMSG_RET_NULL(_(e_invalid_character_after_bsl_z));
}
}
break;
case Magic('%'):
{
c = no_Magic(getchr());
switch (c)
{
// () without a back reference
case '(':
if (one_exactly)
EMSG_ONE_RET_NULL;
ret = reg(REG_NPAREN, &flags);
if (ret == NULL)
return NULL;
*flagp |= flags & (HASWIDTH | SPSTART | HASNL | HASLOOKBH);
break;
// Catch \%^ and \%$ regardless of where they appear in the
// pattern -- regardless of whether or not it makes sense.
case '^':
ret = regnode(RE_BOF);
break;
case '$':
ret = regnode(RE_EOF);
break;
case '#':
ret = regnode(CURSOR);
break;
case 'V':
ret = regnode(RE_VISUAL);
break;
case 'C':
ret = regnode(RE_COMPOSING);
break;
// \%[abc]: Emit as a list of branches, all ending at the last
// branch which matches nothing.
case '[':
if (one_exactly) // doesn't nest
EMSG_ONE_RET_NULL;
{
char_u *lastbranch;
char_u *lastnode = NULL;
char_u *br;
ret = NULL;
while ((c = getchr()) != ']')
{
if (c == NUL)
EMSG2_RET_NULL(_(e_missing_sb_after_str),
reg_magic == MAGIC_ALL);
br = regnode(BRANCH);
if (ret == NULL)
ret = br;
else
{
regtail(lastnode, br);
if (reg_toolong)
return NULL;
}
ungetchr();
one_exactly = TRUE;
lastnode = regatom(flagp);
one_exactly = FALSE;
if (lastnode == NULL)
return NULL;
}
if (ret == NULL)
EMSG2_RET_NULL(_(e_empty_str_brackets),
reg_magic == MAGIC_ALL);
lastbranch = regnode(BRANCH);
br = regnode(NOTHING);
if (ret != JUST_CALC_SIZE)
{
regtail(lastnode, br);
regtail(lastbranch, br);
// connect all branches to the NOTHING
// branch at the end
for (br = ret; br != lastnode; )
{
if (OP(br) == BRANCH)
{
regtail(br, lastbranch);
if (reg_toolong)
return NULL;
br = OPERAND(br);
}
else
br = regnext(br);
}
}
*flagp &= ~(HASWIDTH | SIMPLE);
break;
}
case 'd': // %d123 decimal
case 'o': // %o123 octal
case 'x': // %xab hex 2
case 'u': // %uabcd hex 4
case 'U': // %U1234abcd hex 8
{
long i;
switch (c)
{
case 'd': i = getdecchrs(); break;
case 'o': i = getoctchrs(); break;
case 'x': i = gethexchrs(2); break;
case 'u': i = gethexchrs(4); break;
case 'U': i = gethexchrs(8); break;
default: i = -1; break;
}
if (i < 0 || i > INT_MAX)
EMSG2_RET_NULL(
_(e_invalid_character_after_str_2),
reg_magic == MAGIC_ALL);
if (use_multibytecode(i))
ret = regnode(MULTIBYTECODE);
else
ret = regnode(EXACTLY);
if (i == 0)
regc(0x0a);
else
regmbc(i);
regc(NUL);
*flagp |= HASWIDTH;
break;
}
default:
if (VIM_ISDIGIT(c) || c == '<' || c == '>'
|| c == '\'' || c == '.')
{
long_u n = 0;
int cmp;
int cur = FALSE;
cmp = c;
if (cmp == '<' || cmp == '>')
c = getchr();
if (no_Magic(c) == '.')
{
cur = TRUE;
c = getchr();
}
while (VIM_ISDIGIT(c))
{
n = n * 10 + (c - '0');
c = getchr();
}
if (c == '\'' && n == 0)
{
// "\%'m", "\%<'m" and "\%>'m": Mark
c = getchr();
ret = regnode(RE_MARK);
if (ret == JUST_CALC_SIZE)
regsize += 2;
else
{
*regcode++ = c;
*regcode++ = cmp;
}
break;
}
else if (c == 'l' || c == 'c' || c == 'v')
{
if (cur && n)
{
semsg(_(e_regexp_number_after_dot_pos_search), no_Magic(c));
rc_did_emsg = TRUE;
return NULL;
}
if (c == 'l')
{
if (cur)
n = curwin->w_cursor.lnum;
ret = regnode(RE_LNUM);
if (save_prev_at_start)
at_start = TRUE;
}
else if (c == 'c')
{
if (cur)
{
n = curwin->w_cursor.col;
n++;
}
ret = regnode(RE_COL);
}
else
{
if (cur)
{
colnr_T vcol = 0;
getvvcol(curwin, &curwin->w_cursor,
NULL, NULL, &vcol);
++vcol;
n = vcol;
}
ret = regnode(RE_VCOL);
}
if (ret == JUST_CALC_SIZE)
regsize += 5;
else
{
// put the number and the optional
// comparator after the opcode
regcode = re_put_long(regcode, n);
*regcode++ = cmp;
}
break;
}
}
EMSG2_RET_NULL(_(e_invalid_character_after_str),
reg_magic == MAGIC_ALL);
}
}
break;
case Magic('['):
collection:
{
char_u *lp;
// If there is no matching ']', we assume the '[' is a normal
// character. This makes 'incsearch' and ":help [" work.
lp = skip_anyof(regparse);
if (*lp == ']') // there is a matching ']'
{
int startc = -1; // > 0 when next '-' is a range
int endc;
// In a character class, different parsing rules apply.
// Not even \ is special anymore, nothing is.
if (*regparse == '^') // Complement of range.
{
ret = regnode(ANYBUT + extra);
regparse++;
}
else
ret = regnode(ANYOF + extra);
// At the start ']' and '-' mean the literal character.
if (*regparse == ']' || *regparse == '-')
{
startc = *regparse;
regc(*regparse++);
}
while (*regparse != NUL && *regparse != ']')
{
if (*regparse == '-')
{
++regparse;
// The '-' is not used for a range at the end and
// after or before a '\n'.
if (*regparse == ']' || *regparse == NUL
|| startc == -1
|| (regparse[0] == '\\' && regparse[1] == 'n'))
{
regc('-');
startc = '-'; // [--x] is a range
}
else
{
// Also accept "a-[.z.]"
endc = 0;
if (*regparse == '[')
endc = get_coll_element(®parse);
if (endc == 0)
{
if (has_mbyte)
endc = mb_ptr2char_adv(®parse);
else
endc = *regparse++;
}
// Handle \o40, \x20 and \u20AC style sequences
if (endc == '\\' && !reg_cpo_lit && !reg_cpo_bsl)
endc = coll_get_char();
if (startc > endc)
EMSG_RET_NULL(_(e_reverse_range_in_character_class));
if (has_mbyte && ((*mb_char2len)(startc) > 1
|| (*mb_char2len)(endc) > 1))
{
// Limit to a range of 256 chars.
if (endc > startc + 256)
EMSG_RET_NULL(_(e_range_too_large_in_character_class));
while (++startc <= endc)
regmbc(startc);
}
else
{
while (++startc <= endc)
regc(startc);
}
startc = -1;
}
}
// Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
// accepts "\t", "\e", etc., but only when the 'l' flag in
// 'cpoptions' is not included.
// Posix doesn't recognize backslash at all.
else if (*regparse == '\\'
&& !reg_cpo_bsl
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
|| (!reg_cpo_lit
&& vim_strchr(REGEXP_ABBR,
regparse[1]) != NULL)))
{
regparse++;
if (*regparse == 'n')
{
// '\n' in range: also match NL
if (ret != JUST_CALC_SIZE)
{
// Using \n inside [^] does not change what
// matches. "[^\n]" is the same as ".".
if (*ret == ANYOF)
{
*ret = ANYOF + ADD_NL;
*flagp |= HASNL;
}
// else: must have had a \n already
}
regparse++;
startc = -1;
}
else if (*regparse == 'd'
|| *regparse == 'o'
|| *regparse == 'x'
|| *regparse == 'u'
|| *regparse == 'U')
{
startc = coll_get_char();
if (startc == 0)
regc(0x0a);
else
regmbc(startc);
}
else
{
startc = backslash_trans(*regparse++);
regc(startc);
}
}
else if (*regparse == '[')
{
int c_class;
int cu;
c_class = get_char_class(®parse);
startc = -1;
// Characters assumed to be 8 bits!
switch (c_class)
{
case CLASS_NONE:
c_class = get_equi_class(®parse);
if (c_class != 0)
{
// produce equivalence class
reg_equi_class(c_class);
}
else if ((c_class =
get_coll_element(®parse)) != 0)
{
// produce a collating element
regmbc(c_class);
}
else
{
// literal '[', allow [[-x] as a range
startc = *regparse++;
regc(startc);
}
break;
case CLASS_ALNUM:
for (cu = 1; cu < 128; cu++)
if (isalnum(cu))
regmbc(cu);
break;
case CLASS_ALPHA:
for (cu = 1; cu < 128; cu++)
if (isalpha(cu))
regmbc(cu);
break;
case CLASS_BLANK:
regc(' ');
regc('\t');
break;
case CLASS_CNTRL:
for (cu = 1; cu <= 127; cu++)
if (iscntrl(cu))
regmbc(cu);
break;
case CLASS_DIGIT:
for (cu = 1; cu <= 127; cu++)
if (VIM_ISDIGIT(cu))
regmbc(cu);
break;
case CLASS_GRAPH:
for (cu = 1; cu <= 127; cu++)
if (isgraph(cu))
regmbc(cu);
break;
case CLASS_LOWER:
for (cu = 1; cu <= 255; cu++)
if (MB_ISLOWER(cu) && cu != 170
&& cu != 186)
regmbc(cu);
break;
case CLASS_PRINT:
for (cu = 1; cu <= 255; cu++)
if (vim_isprintc(cu))
regmbc(cu);
break;
case CLASS_PUNCT:
for (cu = 1; cu < 128; cu++)
if (ispunct(cu))
regmbc(cu);
break;
case CLASS_SPACE:
for (cu = 9; cu <= 13; cu++)
regc(cu);
regc(' ');
break;
case CLASS_UPPER:
for (cu = 1; cu <= 255; cu++)
if (MB_ISUPPER(cu))
regmbc(cu);
break;
case CLASS_XDIGIT:
for (cu = 1; cu <= 255; cu++)
if (vim_isxdigit(cu))
regmbc(cu);
break;
case CLASS_TAB:
regc('\t');
break;
case CLASS_RETURN:
regc('\r');
break;
case CLASS_BACKSPACE:
regc('\b');
break;
case CLASS_ESCAPE:
regc('\033');
break;
case CLASS_IDENT:
for (cu = 1; cu <= 255; cu++)
if (vim_isIDc(cu))
regmbc(cu);
break;
case CLASS_KEYWORD:
for (cu = 1; cu <= 255; cu++)
if (reg_iswordc(cu))
regmbc(cu);
break;
case CLASS_FNAME:
for (cu = 1; cu <= 255; cu++)
if (vim_isfilec(cu))
regmbc(cu);
break;
}
}
else
{
if (has_mbyte)
{
int len;
// produce a multibyte character, including any
// following composing characters
startc = mb_ptr2char(regparse);
len = (*mb_ptr2len)(regparse);
if (enc_utf8 && utf_char2len(startc) != len)
startc = -1; // composing chars
while (--len >= 0)
regc(*regparse++);
}
else
{
startc = *regparse++;
regc(startc);
}
}
}
regc(NUL);
prevchr_len = 1; // last char was the ']'
if (*regparse != ']')
EMSG_RET_NULL(_(e_too_many_brackets)); // Cannot happen?
skipchr(); // let's be friends with the lexer again
*flagp |= HASWIDTH | SIMPLE;
break;
}
else if (reg_strict)
EMSG2_RET_NULL(_(e_missing_rsb_after_str_lsb),
reg_magic > MAGIC_OFF);
}
// FALLTHROUGH
default:
{
int len;
// A multi-byte character is handled as a separate atom if it's
// before a multi and when it's a composing char.
if (use_multibytecode(c))
{
do_multibyte:
ret = regnode(MULTIBYTECODE);
regmbc(c);
*flagp |= HASWIDTH | SIMPLE;
break;
}
ret = regnode(EXACTLY);
// Append characters as long as:
// - there is no following multi, we then need the character in
// front of it as a single character operand
// - not running into a Magic character
// - "one_exactly" is not set
// But always emit at least one character. Might be a Multi,
// e.g., a "[" without matching "]".
for (len = 0; c != NUL && (len == 0
|| (re_multi_type(peekchr()) == NOT_MULTI
&& !one_exactly
&& !is_Magic(c))); ++len)
{
c = no_Magic(c);
if (has_mbyte)
{
regmbc(c);
if (enc_utf8)
{
int l;
// Need to get composing character too.
for (;;)
{
l = utf_ptr2len(regparse);
if (!UTF_COMPOSINGLIKE(regparse, regparse + l))
break;
regmbc(utf_ptr2char(regparse));
skipchr();
}
}
}
else
regc(c);
c = getchr();
}
ungetchr();
regc(NUL);
*flagp |= HASWIDTH;
if (len == 1)
*flagp |= SIMPLE;
}
break;
}
return ret;
}
| 0
|
301,409
|
static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
{
return false;
}
| 0
|
424,927
|
static ssize_t iwl_dbgfs_monitor_data_read(struct file *file,
char __user *user_buf,
size_t count, loff_t *ppos)
{
struct iwl_trans *trans = file->private_data;
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
void *cpu_addr = (void *)trans->dbg.fw_mon[0].block, *curr_buf;
struct cont_rec *data = &trans_pcie->fw_mon_data;
u32 write_ptr_addr, wrap_cnt_addr, write_ptr, wrap_cnt;
ssize_t size, bytes_copied = 0;
bool b_full;
if (trans->dbg.dest_tlv) {
write_ptr_addr =
le32_to_cpu(trans->dbg.dest_tlv->write_ptr_reg);
wrap_cnt_addr = le32_to_cpu(trans->dbg.dest_tlv->wrap_count);
} else {
write_ptr_addr = MON_BUFF_WRPTR;
wrap_cnt_addr = MON_BUFF_CYCLE_CNT;
}
if (unlikely(!trans->dbg.rec_on))
return 0;
mutex_lock(&data->mutex);
if (data->state ==
IWL_FW_MON_DBGFS_STATE_DISABLED) {
mutex_unlock(&data->mutex);
return 0;
}
/* write_ptr position in bytes rather then DW */
write_ptr = iwl_read_prph(trans, write_ptr_addr) * sizeof(u32);
wrap_cnt = iwl_read_prph(trans, wrap_cnt_addr);
if (data->prev_wrap_cnt == wrap_cnt) {
size = write_ptr - data->prev_wr_ptr;
curr_buf = cpu_addr + data->prev_wr_ptr;
b_full = iwl_write_to_user_buf(user_buf, count,
curr_buf, &size,
&bytes_copied);
data->prev_wr_ptr += size;
} else if (data->prev_wrap_cnt == wrap_cnt - 1 &&
write_ptr < data->prev_wr_ptr) {
size = trans->dbg.fw_mon[0].size - data->prev_wr_ptr;
curr_buf = cpu_addr + data->prev_wr_ptr;
b_full = iwl_write_to_user_buf(user_buf, count,
curr_buf, &size,
&bytes_copied);
data->prev_wr_ptr += size;
if (!b_full) {
size = write_ptr;
b_full = iwl_write_to_user_buf(user_buf, count,
cpu_addr, &size,
&bytes_copied);
data->prev_wr_ptr = size;
data->prev_wrap_cnt++;
}
} else {
if (data->prev_wrap_cnt == wrap_cnt - 1 &&
write_ptr > data->prev_wr_ptr)
IWL_WARN(trans,
"write pointer passed previous write pointer, start copying from the beginning\n");
else if (!unlikely(data->prev_wrap_cnt == 0 &&
data->prev_wr_ptr == 0))
IWL_WARN(trans,
"monitor data is out of sync, start copying from the beginning\n");
size = write_ptr;
b_full = iwl_write_to_user_buf(user_buf, count,
cpu_addr, &size,
&bytes_copied);
data->prev_wr_ptr = size;
data->prev_wrap_cnt = wrap_cnt;
}
mutex_unlock(&data->mutex);
return bytes_copied;
}
| 0
|
246,742
|
static u64 do_size_top_boxes(char *inName, char *compress_top_boxes, u32 mode)
{
FILE *in;
u64 top_size = 0;
Bool do_all = GF_FALSE;
GF_BitStream *bs_in;
if (!compress_top_boxes) return GF_BAD_PARAM;
if (!strcmp(compress_top_boxes, "all") || !strcmp(compress_top_boxes, "*") || !strcmp(compress_top_boxes, "@"))
do_all = GF_TRUE;
in = gf_fopen(inName, "rb");
if (!in) return GF_URL_ERROR;
bs_in = gf_bs_from_file(in, GF_BITSTREAM_READ);
while (gf_bs_available(bs_in)) {
const char *stype;
u32 hdr_size = 8;
u64 lsize = gf_bs_read_u32(bs_in);
u32 type = gf_bs_read_u32(bs_in);
if (lsize==1) {
lsize = gf_bs_read_u64(bs_in);
hdr_size = 16;
} else if (lsize==0) {
lsize = gf_bs_available(bs_in) + 8;
}
stype = gf_4cc_to_str(type);
if (do_all || strstr(compress_top_boxes, stype)) {
//only count boxes
if (mode==2) {
top_size += 1;
} else {
top_size += lsize;
}
}
gf_bs_skip_bytes(bs_in, lsize - hdr_size);
}
gf_bs_del(bs_in);
gf_fclose(in);
return top_size;
}
| 0
|
513,328
|
uint check_join_cache_usage(JOIN_TAB *tab,
ulonglong options,
uint no_jbuf_after,
uint table_index,
JOIN_TAB *prev_tab)
{
Cost_estimate cost;
uint flags= 0;
ha_rows rows= 0;
uint bufsz= 4096;
JOIN_CACHE *prev_cache=0;
JOIN *join= tab->join;
MEM_ROOT *root= join->thd->mem_root;
uint cache_level= tab->used_join_cache_level;
bool force_unlinked_cache=
!(join->allowed_join_cache_types & JOIN_CACHE_INCREMENTAL_BIT);
bool no_hashed_cache=
!(join->allowed_join_cache_types & JOIN_CACHE_HASHED_BIT);
bool no_bka_cache=
!(join->allowed_join_cache_types & JOIN_CACHE_BKA_BIT);
join->return_tab= 0;
/*
Don't use join cache if @@join_cache_level==0 or this table is the first
one join suborder (either at top level or inside a bush)
*/
if (cache_level == 0 || !prev_tab)
return 0;
if (force_unlinked_cache && (cache_level%2 == 0))
cache_level--;
if (options & SELECT_NO_JOIN_CACHE)
goto no_join_cache;
if (tab->use_quick == 2)
goto no_join_cache;
if (tab->table->map & join->complex_firstmatch_tables)
goto no_join_cache;
/*
Don't use join cache if we're inside a join tab range covered by LooseScan
strategy (TODO: LooseScan is very similar to FirstMatch so theoretically it
should be possible to use join buffering in the same way we're using it for
multi-table firstmatch ranges).
*/
if (tab->inside_loosescan_range)
goto no_join_cache;
if (tab->is_inner_table_of_semijoin() &&
!join->allowed_semijoin_with_cache)
goto no_join_cache;
if (tab->is_inner_table_of_outer_join() &&
!join->allowed_outer_join_with_cache)
goto no_join_cache;
/*
Non-linked join buffers can't guarantee one match
*/
if (tab->is_nested_inner())
{
if (force_unlinked_cache || cache_level == 1)
goto no_join_cache;
if (cache_level & 1)
cache_level--;
}
/*
Don't use BKA for materialized tables. We could actually have a
meaningful use of BKA when linked join buffers are used.
The problem is, the temp.table is not filled (actually not even opened
properly) yet, and this doesn't let us call
handler->multi_range_read_info(). It is possible to come up with
estimates, etc. without acessing the table, but it seems not to worth the
effort now.
*/
if (tab->table->pos_in_table_list->is_materialized_derived())
{
no_bka_cache= true;
/*
Don't use hash join algorithm if the temporary table for the rows
of the derived table will be created with an equi-join key.
*/
if (tab->table->s->keys)
no_hashed_cache= true;
}
/*
Don't use join buffering if we're dictated not to by no_jbuf_after
(This is not meaningfully used currently)
*/
if (table_index > no_jbuf_after)
goto no_join_cache;
/*
TODO: BNL join buffer should be perfectly ok with tab->bush_children.
*/
if (tab->loosescan_match_tab || tab->bush_children)
goto no_join_cache;
for (JOIN_TAB *first_inner= tab->first_inner; first_inner;
first_inner= first_inner->first_upper)
{
if (first_inner != tab &&
(!first_inner->use_join_cache || !(tab-1)->use_join_cache))
goto no_join_cache;
}
if (tab->first_sj_inner_tab && tab->first_sj_inner_tab != tab &&
(!tab->first_sj_inner_tab->use_join_cache || !(tab-1)->use_join_cache))
goto no_join_cache;
if (!prev_tab->use_join_cache)
{
/*
Check whether table tab and the previous one belong to the same nest of
inner tables and if so do not use join buffer when joining table tab.
*/
if (tab->first_inner && tab != tab->first_inner)
{
for (JOIN_TAB *first_inner= tab[-1].first_inner;
first_inner;
first_inner= first_inner->first_upper)
{
if (first_inner == tab->first_inner)
goto no_join_cache;
}
}
else if (tab->first_sj_inner_tab && tab != tab->first_sj_inner_tab &&
tab->first_sj_inner_tab == tab[-1].first_sj_inner_tab)
goto no_join_cache;
}
prev_cache= prev_tab->cache;
switch (tab->type) {
case JT_ALL:
if (cache_level == 1)
prev_cache= 0;
if ((tab->cache= new (root) JOIN_CACHE_BNL(join, tab, prev_cache)))
{
tab->icp_other_tables_ok= FALSE;
return (2 - MY_TEST(!prev_cache));
}
goto no_join_cache;
case JT_SYSTEM:
case JT_CONST:
case JT_REF:
case JT_EQ_REF:
if (cache_level <=2 || (no_hashed_cache && no_bka_cache))
goto no_join_cache;
if (tab->ref.is_access_triggered())
goto no_join_cache;
if (!tab->is_ref_for_hash_join() && !no_bka_cache)
{
flags= HA_MRR_NO_NULL_ENDPOINTS | HA_MRR_SINGLE_POINT;
if (tab->table->covering_keys.is_set(tab->ref.key))
flags|= HA_MRR_INDEX_ONLY;
rows= tab->table->file->multi_range_read_info(tab->ref.key, 10, 20,
tab->ref.key_parts,
&bufsz, &flags, &cost);
}
if ((cache_level <=4 && !no_hashed_cache) || no_bka_cache ||
tab->is_ref_for_hash_join() ||
((flags & HA_MRR_NO_ASSOCIATION) && cache_level <=6))
{
if (!tab->hash_join_is_possible() ||
tab->make_scan_filter())
goto no_join_cache;
if (cache_level == 3)
prev_cache= 0;
if ((tab->cache= new (root) JOIN_CACHE_BNLH(join, tab, prev_cache)))
{
tab->icp_other_tables_ok= FALSE;
return (4 - MY_TEST(!prev_cache));
}
goto no_join_cache;
}
if (cache_level > 4 && no_bka_cache)
goto no_join_cache;
if ((flags & HA_MRR_NO_ASSOCIATION) &&
(cache_level <= 6 || no_hashed_cache))
goto no_join_cache;
if ((rows != HA_POS_ERROR) && !(flags & HA_MRR_USE_DEFAULT_IMPL))
{
if (cache_level <= 6 || no_hashed_cache)
{
if (cache_level == 5)
prev_cache= 0;
if ((tab->cache= new (root) JOIN_CACHE_BKA(join, tab, flags, prev_cache)))
return (6 - MY_TEST(!prev_cache));
goto no_join_cache;
}
else
{
if (cache_level == 7)
prev_cache= 0;
if ((tab->cache= new (root) JOIN_CACHE_BKAH(join, tab, flags, prev_cache)))
{
tab->idx_cond_fact_out= FALSE;
return (8 - MY_TEST(!prev_cache));
}
goto no_join_cache;
}
}
goto no_join_cache;
default : ;
}
no_join_cache:
if (tab->type != JT_ALL && tab->is_ref_for_hash_join())
{
tab->type= JT_ALL;
tab->ref.key_parts= 0;
}
revise_cache_usage(tab);
return 0;
}
| 0
|
437,405
|
vhost_user_set_vring_num(struct virtio_net **pdev,
struct VhostUserMsg *msg,
int main_fd __rte_unused)
{
struct virtio_net *dev = *pdev;
struct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index];
vq->size = msg->payload.state.num;
/* VIRTIO 1.0, 2.4 Virtqueues says:
*
* Queue Size value is always a power of 2. The maximum Queue Size
* value is 32768.
*/
if ((vq->size & (vq->size - 1)) || vq->size > 32768) {
RTE_LOG(ERR, VHOST_CONFIG,
"invalid virtqueue size %u\n", vq->size);
return RTE_VHOST_MSG_RESULT_ERR;
}
if (dev->dequeue_zero_copy) {
vq->nr_zmbuf = 0;
vq->last_zmbuf_idx = 0;
vq->zmbuf_size = vq->size;
vq->zmbufs = rte_zmalloc(NULL, vq->zmbuf_size *
sizeof(struct zcopy_mbuf), 0);
if (vq->zmbufs == NULL) {
RTE_LOG(WARNING, VHOST_CONFIG,
"failed to allocate mem for zero copy; "
"zero copy is force disabled\n");
dev->dequeue_zero_copy = 0;
}
TAILQ_INIT(&vq->zmbuf_list);
}
if (vq_is_packed(dev)) {
vq->shadow_used_packed = rte_malloc(NULL,
vq->size *
sizeof(struct vring_used_elem_packed),
RTE_CACHE_LINE_SIZE);
if (!vq->shadow_used_packed) {
RTE_LOG(ERR, VHOST_CONFIG,
"failed to allocate memory for shadow used ring.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
} else {
vq->shadow_used_split = rte_malloc(NULL,
vq->size * sizeof(struct vring_used_elem),
RTE_CACHE_LINE_SIZE);
if (!vq->shadow_used_split) {
RTE_LOG(ERR, VHOST_CONFIG,
"failed to allocate memory for shadow used ring.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
}
vq->batch_copy_elems = rte_malloc(NULL,
vq->size * sizeof(struct batch_copy_elem),
RTE_CACHE_LINE_SIZE);
if (!vq->batch_copy_elems) {
RTE_LOG(ERR, VHOST_CONFIG,
"failed to allocate memory for batching copy.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
return RTE_VHOST_MSG_RESULT_OK;
}
| 0
|
500,647
|
unsigned long sftp_tell(sftp_file file) {
return (unsigned long)file->offset;
}
| 0
|
278,280
|
preprocs_left(void)
{
return
(curbuf->b_p_si && !curbuf->b_p_cin) ||
(curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE)
&& curbuf->b_ind_hash_comment == 0)
;
}
| 0
|
455,398
|
xfs_icache_inode_is_allocated(
struct xfs_mount *mp,
struct xfs_trans *tp,
xfs_ino_t ino,
bool *inuse)
{
struct xfs_inode *ip;
int error;
error = xfs_iget(mp, tp, ino, XFS_IGET_INCORE, 0, &ip);
if (error)
return error;
*inuse = !!(VFS_I(ip)->i_mode);
IRELE(ip);
return 0;
}
| 0
|
225,097
|
void RemoveDescriptionsFromOpDef(OpDef* op_def) {
RemoveNonDeprecationDescriptionsFromOpDef(op_def);
if (op_def->has_deprecation()) {
op_def->mutable_deprecation()->clear_explanation();
}
}
| 0
|
252,351
|
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) {
if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) ||
(pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))
return MZ_FALSE;
if (pZip->m_file_offset_alignment) {
// Ensure user specified file offset alignment is a power of 2.
if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1))
return MZ_FALSE;
}
if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func;
if (!pZip->m_pFree) pZip->m_pFree = def_free_func;
if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func;
pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;
pZip->m_archive_size = existing_size;
pZip->m_central_directory_file_ofs = 0;
pZip->m_total_files = 0;
if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(
pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))
return MZ_FALSE;
memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir,
sizeof(mz_uint8));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets,
sizeof(mz_uint32));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets,
sizeof(mz_uint32));
return MZ_TRUE;
}
| 0
|
223,439
|
static PCRE2_SPTR SLJIT_FUNC do_script_run_utf(PCRE2_SPTR ptr, PCRE2_SPTR endptr)
{
if (PRIV(script_run)(ptr, endptr, TRUE))
return endptr;
return NULL;
}
| 0
|
359,446
|
zlog_rotate (struct zlog *zl)
{
int level;
if (zl == NULL)
zl = zlog_default;
if (zl->fp)
fclose (zl->fp);
zl->fp = NULL;
logfile_fd = -1;
level = zl->maxlvl[ZLOG_DEST_FILE];
zl->maxlvl[ZLOG_DEST_FILE] = ZLOG_DISABLED;
if (zl->filename)
{
mode_t oldumask;
int save_errno;
oldumask = umask (0777 & ~LOGFILE_MASK);
zl->fp = fopen (zl->filename, "a");
save_errno = errno;
umask(oldumask);
if (zl->fp == NULL)
{
zlog_err("Log rotate failed: cannot open file %s for append: %s",
zl->filename, safe_strerror(save_errno));
return -1;
}
logfile_fd = fileno(zl->fp);
zl->maxlvl[ZLOG_DEST_FILE] = level;
}
return 1;
}
| 0
|
380,958
|
ins_pagedown(void)
{
pos_T tpos;
undisplay_dollar();
if (mod_mask & MOD_MASK_CTRL)
{
// <C-PageDown>: tab page forward
if (first_tabpage->tp_next != NULL)
{
start_arrow(&curwin->w_cursor);
goto_tabpage(0);
}
return;
}
tpos = curwin->w_cursor;
if (onepage(FORWARD, 1L) == OK)
{
start_arrow(&tpos);
can_cindent = TRUE;
}
else
vim_beep(BO_CRSR);
}
| 0
|
238,638
|
static int check_ptr_to_btf_access(struct bpf_verifier_env *env,
struct bpf_reg_state *regs,
int regno, int off, int size,
enum bpf_access_type atype,
int value_regno)
{
struct bpf_reg_state *reg = regs + regno;
const struct btf_type *t = btf_type_by_id(reg->btf, reg->btf_id);
const char *tname = btf_name_by_offset(reg->btf, t->name_off);
u32 btf_id;
int ret;
if (off < 0) {
verbose(env,
"R%d is ptr_%s invalid negative access: off=%d\n",
regno, tname, off);
return -EACCES;
}
if (!tnum_is_const(reg->var_off) || reg->var_off.value) {
char tn_buf[48];
tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);
verbose(env,
"R%d is ptr_%s invalid variable offset: off=%d, var_off=%s\n",
regno, tname, off, tn_buf);
return -EACCES;
}
if (env->ops->btf_struct_access) {
ret = env->ops->btf_struct_access(&env->log, reg->btf, t,
off, size, atype, &btf_id);
} else {
if (atype != BPF_READ) {
verbose(env, "only read is supported\n");
return -EACCES;
}
ret = btf_struct_access(&env->log, reg->btf, t, off, size,
atype, &btf_id);
}
if (ret < 0)
return ret;
if (atype == BPF_READ && value_regno >= 0)
mark_btf_ld_reg(env, regs, value_regno, ret, reg->btf, btf_id);
return 0;
}
| 0
|
230,143
|
json_t * user_auth_scheme_module_trigger(struct config_module * config, const struct _u_request * http_request, const char * username, json_t * j_scheme_trigger, void * cls) {
UNUSED(j_scheme_trigger);
json_t * j_return = NULL, * j_session = config->glewlwyd_module_callback_check_user_session(config, http_request, username), * j_credential, * j_assertion, * j_user_id, * j_credential_fake;
unsigned char user_id_fake[64];
if (check_result_value(j_session, G_OK) || json_object_get((json_t *)cls, "session-mandatory") == json_false()) {
j_credential_fake = generate_credential_fake_list((json_t *)cls, username);
if (check_result_value(j_credential_fake, G_OK)) {
j_user_id = get_user_id_from_username(config, (json_t *)cls, username, 0);
if (check_result_value(j_user_id, G_OK)) {
j_credential = get_credential_list(config, (json_t *)cls, username, 1);
if (check_result_value(j_credential, G_OK)) {
j_assertion = generate_new_assertion(config, (json_t *)cls, username, 0);
if (check_result_value(j_assertion, G_OK)) {
j_return = json_pack("{sis{sOsOsOs{sOss}sOsssi}}",
"result", G_OK,
"response",
"allowCredentials", json_object_get(j_credential, "credential"),
"session", json_object_get(json_object_get(j_assertion, "assertion"), "session"),
"challenge", json_object_get(json_object_get(j_assertion, "assertion"), "challenge"),
"user",
"id", json_object_get(j_user_id, "user_id"),
"name", username,
"rpId", json_object_get((json_t *)cls, "rp-origin"),
"attestation-required", json_object_get((json_t *)cls, "force-fmt-none")==json_true()?"none":"direct",
"timeout", 60000
);
if (json_object_get((json_t *)cls, "session-mandatory") == json_false()) {
json_array_extend(json_object_get(json_object_get(j_return, "response"), "allowCredentials"), json_object_get(j_credential_fake, "credential"));
}
} else if (check_result_value(j_assertion, G_ERROR_UNAUTHORIZED)) {
j_return = json_pack("{si}", "result", G_ERROR_UNAUTHORIZED);
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_trigger webauthn - Error register_new_assertion");
j_return = json_pack("{si}", "result", G_ERROR);
}
json_decref(j_assertion);
} else if (check_result_value(j_credential, G_ERROR_NOT_FOUND)) {
if (json_object_get((json_t *)cls, "session-mandatory") == json_false()) {
j_assertion = generate_new_assertion(config, (json_t *)cls, username, 2);
if (check_result_value(j_assertion, G_OK)) {
j_return = json_pack("{sis{sOsOsOs{sOss}sO}}",
"result", G_OK,
"response",
"allowCredentials", json_object_get(j_credential_fake, "credential"),
"session", json_object_get(json_object_get(j_assertion, "assertion"), "session"),
"challenge", json_object_get(json_object_get(j_assertion, "assertion"), "challenge"),
"user",
"id", json_object_get(j_user_id, "user_id"),
"name", username,
"rpId", json_object_get((json_t *)cls, "rp-origin")
);
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_trigger webauthn - Error register_new_assertion");
j_return = json_pack("{si}", "result", G_ERROR);
}
json_decref(j_assertion);
} else {
j_return = json_pack("{si}", "result", G_ERROR_UNAUTHORIZED);
}
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_trigger webauthn - Error get_credential_list");
j_return = json_pack("{si}", "result", G_ERROR);
}
json_decref(j_credential);
} else if (check_result_value(j_user_id, G_ERROR_NOT_FOUND)) {
if (json_object_get((json_t *)cls, "session-mandatory") == json_false()) {
if (generate_fake_user_id((json_t *)cls, username, user_id_fake) == G_OK) {
j_assertion = generate_new_assertion(config, (json_t *)cls, username, 2);
if (check_result_value(j_assertion, G_OK)) {
j_return = json_pack("{sis{sOsOsOs{ssss}sO}}",
"result", G_OK,
"response",
"allowCredentials", json_object_get(j_credential_fake, "credential"),
"session", json_object_get(json_object_get(j_assertion, "assertion"), "session"),
"challenge", json_object_get(json_object_get(j_assertion, "assertion"), "challenge"),
"user",
"id", user_id_fake,
"name", username,
"rpId", json_object_get((json_t *)cls, "rp-origin")
);
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_trigger webauthn - Error register_new_assertion");
j_return = json_pack("{si}", "result", G_ERROR);
}
json_decref(j_assertion);
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_register webauthn - Error generate_fake_user_id");
j_return = json_pack("{si}", "result", G_ERROR);
}
} else {
j_return = json_pack("{si}", "result", G_ERROR_UNAUTHORIZED);
}
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_register webauthn - Error get_user_id_from_username");
j_return = json_pack("{si}", "result", G_ERROR);
}
json_decref(j_user_id);
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_trigger webauthn - Error generate_credential_fake");
j_return = json_pack("{si}", "result", G_ERROR);
}
json_decref(j_credential_fake);
} else if (check_result_value(j_session, G_ERROR_UNAUTHORIZED)) {
j_return = json_pack("{si}", "result", G_ERROR_UNAUTHORIZED);
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_trigger webauthn - Error glewlwyd_module_callback_check_user_session");
j_return = json_pack("{si}", "result", G_ERROR);
}
json_decref(j_session);
return j_return;
}
| 0
|
314,533
|
PJ_DEF(pj_status_t) pjmedia_sdp_parse( pj_pool_t *pool,
char *buf, pj_size_t len,
pjmedia_sdp_session **p_sdp)
{
pj_scanner scanner;
pjmedia_sdp_session *session;
pjmedia_sdp_media *media = NULL;
pjmedia_sdp_attr *attr;
pjmedia_sdp_conn *conn;
pjmedia_sdp_bandw *bandw;
pj_str_t dummy;
int cur_name = 254;
volatile parse_context ctx;
PJ_USE_EXCEPTION;
ctx.last_error = PJ_SUCCESS;
init_sdp_parser();
pj_scan_init(&scanner, buf, len, 0, &on_scanner_error);
session = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session);
PJ_ASSERT_RETURN(session != NULL, PJ_ENOMEM);
/* Ignore leading newlines */
while (*scanner.curptr=='\r' || *scanner.curptr=='\n')
pj_scan_get_char(&scanner);
PJ_TRY {
while (!pj_scan_is_eof(&scanner)) {
cur_name = *scanner.curptr;
switch (cur_name) {
case 'a':
attr = parse_attr(pool, &scanner, &ctx);
if (attr) {
if (media) {
if (media->attr_count < PJMEDIA_MAX_SDP_ATTR)
pjmedia_sdp_media_add_attr(media, attr);
else
PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,
"Error adding media attribute, "
"attribute is ignored"));
} else {
if (session->attr_count < PJMEDIA_MAX_SDP_ATTR)
pjmedia_sdp_session_add_attr(session, attr);
else
PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,
"Error adding session attribute"
", attribute is ignored"));
}
}
break;
case 'o':
parse_origin(&scanner, session, &ctx);
break;
case 's':
parse_generic_line(&scanner, &session->name, &ctx);
break;
case 'c':
conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn);
parse_connection_info(&scanner, conn, &ctx);
if (media) {
media->conn = conn;
} else {
session->conn = conn;
}
break;
case 't':
parse_time(&scanner, session, &ctx);
break;
case 'm':
media = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media);
parse_media(&scanner, media, &ctx);
if (session->media_count < PJMEDIA_MAX_SDP_MEDIA)
session->media[ session->media_count++ ] = media;
else
PJ_PERROR(2,(THIS_FILE, PJ_ETOOMANY,
"Error adding media, media is ignored"));
break;
case 'v':
parse_version(&scanner, &ctx);
break;
case 13:
case 10:
pj_scan_get_char(&scanner);
/* Allow empty newlines at the end of the message */
while (!pj_scan_is_eof(&scanner)) {
if (*scanner.curptr != 13 && *scanner.curptr != 10) {
ctx.last_error = PJMEDIA_SDP_EINSDP;
on_scanner_error(&scanner);
}
pj_scan_get_char(&scanner);
}
break;
case 'b':
bandw = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_bandw);
parse_bandwidth_info(&scanner, bandw, &ctx);
if (media) {
if (media->bandw_count < PJMEDIA_MAX_SDP_BANDW)
media->bandw[media->bandw_count++] = bandw;
else
PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,
"Error adding media bandwidth "
"info, info is ignored"));
} else {
if (session->bandw_count < PJMEDIA_MAX_SDP_BANDW)
session->bandw[session->bandw_count++] = bandw;
else
PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,
"Error adding session bandwidth "
"info, info is ignored"));
}
break;
default:
if (cur_name >= 'a' && cur_name <= 'z')
parse_generic_line(&scanner, &dummy, &ctx);
else {
ctx.last_error = PJMEDIA_SDP_EINSDP;
on_scanner_error(&scanner);
}
break;
}
}
ctx.last_error = PJ_SUCCESS;
}
PJ_CATCH_ANY {
PJ_PERROR(4, (THIS_FILE, ctx.last_error,
"Error parsing SDP in line %d col %d",
scanner.line, pj_scan_get_col(&scanner)));
session = NULL;
pj_assert(ctx.last_error != PJ_SUCCESS);
}
PJ_END;
pj_scan_fini(&scanner);
if (session)
apply_media_direction(session);
*p_sdp = session;
return ctx.last_error;
}
| 0
|
446,096
|
static void atusb_disconnect(struct usb_interface *interface)
{
struct atusb *atusb = usb_get_intfdata(interface);
dev_dbg(&atusb->usb_dev->dev, "%s\n", __func__);
atusb->shutdown = 1;
cancel_delayed_work_sync(&atusb->work);
usb_kill_anchored_urbs(&atusb->rx_urbs);
atusb_free_urbs(atusb);
usb_kill_urb(atusb->tx_urb);
usb_free_urb(atusb->tx_urb);
ieee802154_unregister_hw(atusb->hw);
usb_put_dev(atusb->usb_dev);
ieee802154_free_hw(atusb->hw);
usb_set_intfdata(interface, NULL);
pr_debug("%s done\n", __func__);
}
| 0
|
90,133
|
virtual void EnableOfflineMode(bool enable) {}
| 0
|
521,455
|
bool ZipFile::Builder::writeToStream (OutputStream& target, double* const progress) const
{
auto fileStart = target.getPosition();
for (int i = 0; i < items.size(); ++i)
{
if (progress != nullptr)
*progress = (i + 0.5) / items.size();
if (! items.getUnchecked (i)->writeData (target, fileStart))
return false;
}
auto directoryStart = target.getPosition();
for (auto* item : items)
if (! item->writeDirectoryEntry (target))
return false;
auto directoryEnd = target.getPosition();
target.writeInt (0x06054b50);
target.writeShort (0);
target.writeShort (0);
target.writeShort ((short) items.size());
target.writeShort ((short) items.size());
target.writeInt ((int) (directoryEnd - directoryStart));
target.writeInt ((int) (directoryStart - fileStart));
target.writeShort (0);
if (progress != nullptr)
*progress = 1.0;
return true;
}
| 0
|
292,167
|
void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,
const methodHandle& resolved_method,
Klass* resolved_klass,
Handle recv,
Klass* recv_klass,
bool check_null_and_abstract,
TRAPS) {
// setup default return values
int vtable_index = Method::invalid_vtable_index;
methodHandle selected_method;
// runtime method resolution
if (check_null_and_abstract && recv.is_null()) { // check if receiver exists
THROW(vmSymbols::java_lang_NullPointerException());
}
// Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s
// has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since
// a missing receiver might result in a bogus lookup.
assert(resolved_method->method_holder()->is_linked(), "must be linked");
// do lookup based on receiver klass using the vtable index
if (resolved_method->method_holder()->is_interface()) { // default or miranda method
vtable_index = vtable_index_of_interface_method(resolved_klass, resolved_method);
assert(vtable_index >= 0 , "we should have valid vtable index at this point");
selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index));
} else {
// at this point we are sure that resolved_method is virtual and not
// a default or miranda method; therefore, it must have a valid vtable index.
assert(!resolved_method->has_itable_index(), "");
vtable_index = resolved_method->vtable_index();
// We could get a negative vtable_index of nonvirtual_vtable_index for private
// methods, or for final methods. Private methods never appear in the vtable
// and never override other methods. As an optimization, final methods are
// never put in the vtable, unless they override an existing method.
// So if we do get nonvirtual_vtable_index, it means the selected method is the
// resolved method, and it can never be changed by an override.
if (vtable_index == Method::nonvirtual_vtable_index) {
assert(resolved_method->can_be_statically_bound(), "cannot override this method");
selected_method = resolved_method;
} else {
selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index));
}
}
// check if method exists
if (selected_method.is_null()) {
throw_abstract_method_error(resolved_method, recv_klass, CHECK);
}
// check if abstract
if (check_null_and_abstract && selected_method->is_abstract()) {
// Pass arguments for generating a verbose error message.
throw_abstract_method_error(resolved_method, selected_method, recv_klass, CHECK);
}
if (log_develop_is_enabled(Trace, vtables)) {
trace_method_resolution("invokevirtual selected method: receiver-class:",
recv_klass, resolved_klass, selected_method,
false, vtable_index);
}
// setup result
result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK);
}
| 0
|
336,623
|
void reds_enable_mm_time(RedsState *reds)
{
reds->mm_time_enabled = TRUE;
reds->mm_time_latency = MM_TIME_DELTA;
reds_send_mm_time(reds);
}
| 0
|
369,404
|
static inline void io_get_task_refs(int nr)
{
struct io_uring_task *tctx = current->io_uring;
tctx->cached_refs -= nr;
if (unlikely(tctx->cached_refs < 0))
io_task_refs_refill(tctx);
}
| 0
|
247,729
|
TEST_P(SslSocketTest, TestTransportSocketCallback) {
// Make MockTransportSocketCallbacks.
Network::MockIoHandle io_handle;
NiceMock<Network::MockTransportSocketCallbacks> callbacks;
ON_CALL(callbacks, ioHandle()).WillByDefault(ReturnRef(io_handle));
// Make SslSocket.
testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext> factory_context;
Stats::TestUtil::TestStore stats_store;
ON_CALL(factory_context, stats()).WillByDefault(ReturnRef(stats_store));
NiceMock<LocalInfo::MockLocalInfo> local_info;
ON_CALL(factory_context, localInfo()).WillByDefault(ReturnRef(local_info));
envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context;
auto client_cfg = std::make_unique<ClientContextConfigImpl>(tls_context, factory_context);
ContextManagerImpl manager(time_system_);
ClientSslSocketFactory client_ssl_socket_factory(std::move(client_cfg), manager, stats_store);
Network::TransportSocketPtr transport_socket =
client_ssl_socket_factory.createTransportSocket(nullptr);
SslSocket* ssl_socket = dynamic_cast<SslSocket*>(transport_socket.get());
// If no transport socket callbacks have been set, this method should return nullptr.
EXPECT_EQ(ssl_socket->transportSocketCallbacks(), nullptr);
// Otherwise, it should return a pointer to the set callbacks object.
ssl_socket->setTransportSocketCallbacks(callbacks);
EXPECT_EQ(ssl_socket->transportSocketCallbacks(), &callbacks);
}
| 0
|
259,156
|
static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVFragment *frag = &c->fragment;
AVStream *st = NULL;
MOVStreamContext *sc;
int version, i;
MOVFragmentStreamInfo * frag_stream_info;
int64_t base_media_decode_time;
for (i = 0; i < c->fc->nb_streams; i++) {
if (c->fc->streams[i]->id == frag->track_id) {
st = c->fc->streams[i];
break;
}
}
if (!st) {
av_log(c->fc, AV_LOG_WARNING, "could not find corresponding track id %u\n", frag->track_id);
return 0;
}
sc = st->priv_data;
if (sc->pseudo_stream_id + 1 != frag->stsd_id && sc->pseudo_stream_id != -1)
return 0;
version = avio_r8(pb);
avio_rb24(pb); /* flags */
if (version) {
base_media_decode_time = avio_rb64(pb);
} else {
base_media_decode_time = avio_rb32(pb);
}
frag_stream_info = get_current_frag_stream_info(&c->frag_index);
if (frag_stream_info)
frag_stream_info->tfdt_dts = base_media_decode_time;
sc->track_end = base_media_decode_time;
return 0;
}
| 0
|
415,194
|
cmd_checkpin (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
char *idstr;
if ( IS_LOCKED (ctrl) )
return gpg_error (GPG_ERR_LOCKED);
if ((rc = open_card (ctrl, NULL)))
return rc;
if (!ctrl->app_ctx)
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
/* We have to use a copy of the key ID because the function may use
the pin_cb which in turn uses the assuan line buffer and thus
overwriting the original line with the keyid. */
idstr = xtrystrdup (line);
if (!idstr)
return out_of_core ();
rc = app_check_pin (ctrl->app_ctx, idstr, pin_cb, ctx);
xfree (idstr);
if (rc)
log_error ("app_check_pin failed: %s\n", gpg_strerror (rc));
TEST_CARD_REMOVAL (ctrl, rc);
return rc;
}
| 0
|
508,412
|
mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
List<String> *using_fields, uint *found_using_fields)
{
Field_iterator_table_ref it_1, it_2;
Natural_join_column *nj_col_1, *nj_col_2;
Query_arena *arena, backup;
bool result= TRUE;
bool first_outer_loop= TRUE;
/*
Leaf table references to which new natural join columns are added
if the leaves are != NULL.
*/
TABLE_LIST *leaf_1= (table_ref_1->nested_join &&
!table_ref_1->is_natural_join) ?
NULL : table_ref_1;
TABLE_LIST *leaf_2= (table_ref_2->nested_join &&
!table_ref_2->is_natural_join) ?
NULL : table_ref_2;
DBUG_ENTER("mark_common_columns");
DBUG_PRINT("info", ("operand_1: %s operand_2: %s",
table_ref_1->alias, table_ref_2->alias));
*found_using_fields= 0;
arena= thd->activate_stmt_arena_if_needed(&backup);
for (it_1.set(table_ref_1); !it_1.end_of_fields(); it_1.next())
{
bool found= FALSE;
const char *field_name_1;
/* true if field_name_1 is a member of using_fields */
bool is_using_column_1;
if (!(nj_col_1= it_1.get_or_create_column_ref(thd, leaf_1)))
goto err;
field_name_1= nj_col_1->name();
is_using_column_1= using_fields &&
test_if_string_in_list(field_name_1, using_fields);
DBUG_PRINT ("info", ("field_name_1=%s.%s",
nj_col_1->table_name() ? nj_col_1->table_name() : "",
field_name_1));
/*
Find a field with the same name in table_ref_2.
Note that for the second loop, it_2.set() will iterate over
table_ref_2->join_columns and not generate any new elements or
lists.
*/
nj_col_2= NULL;
for (it_2.set(table_ref_2); !it_2.end_of_fields(); it_2.next())
{
Natural_join_column *cur_nj_col_2;
const char *cur_field_name_2;
if (!(cur_nj_col_2= it_2.get_or_create_column_ref(thd, leaf_2)))
goto err;
cur_field_name_2= cur_nj_col_2->name();
DBUG_PRINT ("info", ("cur_field_name_2=%s.%s",
cur_nj_col_2->table_name() ?
cur_nj_col_2->table_name() : "",
cur_field_name_2));
/*
Compare the two columns and check for duplicate common fields.
A common field is duplicate either if it was already found in
table_ref_2 (then found == TRUE), or if a field in table_ref_2
was already matched by some previous field in table_ref_1
(then cur_nj_col_2->is_common == TRUE).
Note that it is too early to check the columns outside of the
USING list for ambiguity because they are not actually "referenced"
here. These columns must be checked only on unqualified reference
by name (e.g. in SELECT list).
*/
if (!my_strcasecmp(system_charset_info, field_name_1, cur_field_name_2))
{
DBUG_PRINT ("info", ("match c1.is_common=%d", nj_col_1->is_common));
if (cur_nj_col_2->is_common ||
(found && (!using_fields || is_using_column_1)))
{
my_error(ER_NON_UNIQ_ERROR, MYF(0), field_name_1, thd->where);
goto err;
}
nj_col_2= cur_nj_col_2;
found= TRUE;
}
}
if (first_outer_loop && leaf_2)
{
/*
Make sure that the next inner loop "knows" that all columns
are materialized already.
*/
leaf_2->is_join_columns_complete= TRUE;
first_outer_loop= FALSE;
}
if (!found)
continue; // No matching field
/*
field_1 and field_2 have the same names. Check if they are in the USING
clause (if present), mark them as common fields, and add a new
equi-join condition to the ON clause.
*/
if (nj_col_2 && (!using_fields ||is_using_column_1))
{
/*
Create non-fixed fully qualified field and let fix_fields to
resolve it.
*/
Item *item_1= nj_col_1->create_item(thd);
Item *item_2= nj_col_2->create_item(thd);
Field *field_1= nj_col_1->field();
Field *field_2= nj_col_2->field();
Item_ident *item_ident_1, *item_ident_2;
Item_func_eq *eq_cond;
if (!item_1 || !item_2)
goto err; // out of memory
/*
The following assert checks that the two created items are of
type Item_ident.
*/
DBUG_ASSERT(!thd->lex->current_select->no_wrap_view_item);
/*
In the case of no_wrap_view_item == 0, the created items must be
of sub-classes of Item_ident.
*/
DBUG_ASSERT(item_1->type() == Item::FIELD_ITEM ||
item_1->type() == Item::REF_ITEM);
DBUG_ASSERT(item_2->type() == Item::FIELD_ITEM ||
item_2->type() == Item::REF_ITEM);
/*
We need to cast item_1,2 to Item_ident, because we need to hook name
resolution contexts specific to each item.
*/
item_ident_1= (Item_ident*) item_1;
item_ident_2= (Item_ident*) item_2;
/*
Create and hook special name resolution contexts to each item in the
new join condition . We need this to both speed-up subsequent name
resolution of these items, and to enable proper name resolution of
the items during the execute phase of PS.
*/
if (set_new_item_local_context(thd, item_ident_1, nj_col_1->table_ref) ||
set_new_item_local_context(thd, item_ident_2, nj_col_2->table_ref))
goto err;
if (!(eq_cond= new (thd->mem_root) Item_func_eq(thd, item_ident_1, item_ident_2)))
goto err; /* Out of memory. */
if (field_1 && field_1->vcol_info)
field_1->table->mark_virtual_col(field_1);
if (field_2 && field_2->vcol_info)
field_2->table->mark_virtual_col(field_2);
/*
Add the new equi-join condition to the ON clause. Notice that
fix_fields() is applied to all ON conditions in setup_conds()
so we don't do it here.
*/
add_join_on(thd, (table_ref_1->outer_join & JOIN_TYPE_RIGHT ?
table_ref_1 : table_ref_2),
eq_cond);
nj_col_1->is_common= nj_col_2->is_common= TRUE;
DBUG_PRINT ("info", ("%s.%s and %s.%s are common",
nj_col_1->table_name() ?
nj_col_1->table_name() : "",
nj_col_1->name(),
nj_col_2->table_name() ?
nj_col_2->table_name() : "",
nj_col_2->name()));
if (field_1)
{
TABLE *table_1= nj_col_1->table_ref->table;
/* Mark field_1 used for table cache. */
bitmap_set_bit(table_1->read_set, field_1->field_index);
table_1->covering_keys.intersect(field_1->part_of_key);
}
if (field_2)
{
TABLE *table_2= nj_col_2->table_ref->table;
/* Mark field_2 used for table cache. */
bitmap_set_bit(table_2->read_set, field_2->field_index);
table_2->covering_keys.intersect(field_2->part_of_key);
}
if (using_fields != NULL)
++(*found_using_fields);
}
}
if (leaf_1)
leaf_1->is_join_columns_complete= TRUE;
/*
Everything is OK.
Notice that at this point there may be some column names in the USING
clause that are not among the common columns. This is an SQL error and
we check for this error in store_natural_using_join_columns() when
(found_using_fields < length(join_using_fields)).
*/
result= FALSE;
err:
if (arena)
thd->restore_active_arena(arena, &backup);
DBUG_RETURN(result);
}
| 0
|
445,942
|
notify_action_open_archive_cb (NotifyNotification *notification,
char *action,
gpointer user_data)
{
NotifyData *notify_data = user_data;
FrWindow *window = notify_data->window;
GtkWidget *new_window;
new_window = fr_window_new ();
gtk_widget_show (new_window);
fr_window_archive_open (FR_WINDOW (new_window),
window->priv->saving_file,
GTK_WINDOW (new_window));
notify_data->window_closed = TRUE;
_fr_window_close_after_notification (window);
}
| 0
|
205,838
|
get_one_sourceline(source_cookie_T *sp)
{
garray_T ga;
int len;
int c;
char_u *buf;
#ifdef USE_CRNL
int has_cr; // CR-LF found
#endif
int have_read = FALSE;
// use a growarray to store the sourced line
ga_init2(&ga, 1, 250);
// Loop until there is a finished line (or end-of-file).
++sp->sourcing_lnum;
for (;;)
{
// make room to read at least 120 (more) characters
if (ga_grow(&ga, 120) == FAIL)
break;
if (sp->source_from_buf)
{
if (sp->buf_lnum >= sp->buflines.ga_len)
break; // all the lines are processed
ga_concat(&ga, ((char_u **)sp->buflines.ga_data)[sp->buf_lnum]);
sp->buf_lnum++;
buf = (char_u *)ga.ga_data;
}
else
{
buf = (char_u *)ga.ga_data;
if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
sp->fp) == NULL)
break;
}
len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);
#ifdef USE_CRNL
// Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the
// CTRL-Z by its own, or after a NL.
if ( (len == 1 || (len >= 2 && buf[len - 2] == '\n'))
&& sp->fileformat == EOL_DOS
&& buf[len - 1] == Ctrl_Z)
{
buf[len - 1] = NUL;
break;
}
#endif
have_read = TRUE;
ga.ga_len = len;
// If the line was longer than the buffer, read more.
if (ga.ga_maxlen - ga.ga_len == 1 && buf[len - 1] != '\n')
continue;
if (len >= 1 && buf[len - 1] == '\n') // remove trailing NL
{
#ifdef USE_CRNL
has_cr = (len >= 2 && buf[len - 2] == '\r');
if (sp->fileformat == EOL_UNKNOWN)
{
if (has_cr)
sp->fileformat = EOL_DOS;
else
sp->fileformat = EOL_UNIX;
}
if (sp->fileformat == EOL_DOS)
{
if (has_cr) // replace trailing CR
{
buf[len - 2] = '\n';
--len;
--ga.ga_len;
}
else // lines like ":map xx yy^M" will have failed
{
if (!sp->error)
{
msg_source(HL_ATTR(HLF_W));
emsg(_("W15: Warning: Wrong line separator, ^M may be missing"));
}
sp->error = TRUE;
sp->fileformat = EOL_UNIX;
}
}
#endif
// The '\n' is escaped if there is an odd number of ^V's just
// before it, first set "c" just before the 'V's and then check
// len&c parities (is faster than ((len-c)%2 == 0)) -- Acevedo
for (c = len - 2; c >= 0 && buf[c] == Ctrl_V; c--)
;
if ((len & 1) != (c & 1)) // escaped NL, read more
{
++sp->sourcing_lnum;
continue;
}
buf[len - 1] = NUL; // remove the NL
}
// Check for ^C here now and then, so recursive :so can be broken.
line_breakcheck();
break;
}
if (have_read)
return (char_u *)ga.ga_data;
vim_free(ga.ga_data);
return NULL;
}
| 1
|
221,130
|
GF_Err gf_odf_ac3_config_parse(u8 *dsi, u32 dsi_len, Bool is_ec3, GF_AC3Config *cfg)
{
GF_BitStream *bs;
GF_Err e;
if (!cfg || !dsi) return GF_BAD_PARAM;
bs = gf_bs_new(dsi, dsi_len, GF_BITSTREAM_READ);
e = gf_odf_ac3_config_parse_bs(bs, is_ec3, cfg);
gf_bs_del(bs);
return e;
}
| 0
|
222,490
|
const NameInfoItem* GetItemOrNull(const string& name) const {
return gtl::FindOrNull(index_, name);
}
| 0
|
428,226
|
CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
va_list param)
{
char *argptr;
CURLcode result = CURLE_OK;
long arg;
#ifndef CURL_DISABLE_HTTP
curl_off_t bigsize;
#endif
switch(option) {
case CURLOPT_DNS_CACHE_TIMEOUT:
data->set.dns_cache_timeout = va_arg(param, long);
break;
case CURLOPT_DNS_USE_GLOBAL_CACHE:
/* remember we want this enabled */
arg = va_arg(param, long);
data->set.global_dns_cache = (0 != arg)?TRUE:FALSE;
break;
case CURLOPT_SSL_CIPHER_LIST:
/* set a list of cipher we want to use in the SSL connection */
result = setstropt(&data->set.str[STRING_SSL_CIPHER_LIST],
va_arg(param, char *));
break;
case CURLOPT_RANDOM_FILE:
/*
* This is the path name to a file that contains random data to seed
* the random SSL stuff with. The file is only used for reading.
*/
result = setstropt(&data->set.str[STRING_SSL_RANDOM_FILE],
va_arg(param, char *));
break;
case CURLOPT_EGDSOCKET:
/*
* The Entropy Gathering Daemon socket pathname
*/
result = setstropt(&data->set.str[STRING_SSL_EGDSOCKET],
va_arg(param, char *));
break;
case CURLOPT_MAXCONNECTS:
/*
* Set the absolute number of maximum simultaneous alive connection that
* libcurl is allowed to have.
*/
data->set.maxconnects = va_arg(param, long);
break;
case CURLOPT_FORBID_REUSE:
/*
* When this transfer is done, it must not be left to be reused by a
* subsequent transfer but shall be closed immediately.
*/
data->set.reuse_forbid = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FRESH_CONNECT:
/*
* This transfer shall not use a previously cached connection but
* should be made with a fresh new connect!
*/
data->set.reuse_fresh = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_VERBOSE:
/*
* Verbose means infof() calls that give a lot of information about
* the connection and transfer procedures as well as internal choices.
*/
data->set.verbose = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_HEADER:
/*
* Set to include the header in the general data output stream.
*/
data->set.include_header = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_NOPROGRESS:
/*
* Shut off the internal supported progress meter
*/
data->set.hide_progress = (0 != va_arg(param, long))?TRUE:FALSE;
if(data->set.hide_progress)
data->progress.flags |= PGRS_HIDE;
else
data->progress.flags &= ~PGRS_HIDE;
break;
case CURLOPT_NOBODY:
/*
* Do not include the body part in the output data stream.
*/
data->set.opt_no_body = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FAILONERROR:
/*
* Don't output the >=400 error code HTML-page, but instead only
* return error.
*/
data->set.http_fail_on_error = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_UPLOAD:
case CURLOPT_PUT:
/*
* We want to sent data to the remote host. If this is HTTP, that equals
* using the PUT request.
*/
data->set.upload = (0 != va_arg(param, long))?TRUE:FALSE;
if(data->set.upload) {
/* If this is HTTP, PUT is what's needed to "upload" */
data->set.httpreq = HTTPREQ_PUT;
data->set.opt_no_body = FALSE; /* this is implied */
}
else
/* In HTTP, the opposite of upload is GET (unless NOBODY is true as
then this can be changed to HEAD later on) */
data->set.httpreq = HTTPREQ_GET;
break;
case CURLOPT_FILETIME:
/*
* Try to get the file time of the remote document. The time will
* later (possibly) become available using curl_easy_getinfo().
*/
data->set.get_filetime = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_CREATE_MISSING_DIRS:
/*
* An FTP option that modifies an upload to create missing directories on
* the server.
*/
switch(va_arg(param, long)) {
case 0:
data->set.ftp_create_missing_dirs = 0;
break;
case 1:
data->set.ftp_create_missing_dirs = 1;
break;
case 2:
data->set.ftp_create_missing_dirs = 2;
break;
default:
/* reserve other values for future use */
result = CURLE_UNKNOWN_OPTION;
break;
}
break;
case CURLOPT_SERVER_RESPONSE_TIMEOUT:
/*
* Option that specifies how quickly an server response must be obtained
* before it is considered failure. For pingpong protocols.
*/
data->set.server_response_timeout = va_arg( param , long ) * 1000;
break;
case CURLOPT_TFTP_BLKSIZE:
/*
* TFTP option that specifies the block size to use for data transmission
*/
data->set.tftp_blksize = va_arg(param, long);
break;
case CURLOPT_DIRLISTONLY:
/*
* An option that changes the command to one that asks for a list
* only, no file info details.
*/
data->set.ftp_list_only = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_APPEND:
/*
* We want to upload and append to an existing file.
*/
data->set.ftp_append = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_FILEMETHOD:
/*
* How do access files over FTP.
*/
data->set.ftp_filemethod = (curl_ftpfile)va_arg(param, long);
break;
case CURLOPT_NETRC:
/*
* Parse the $HOME/.netrc file
*/
data->set.use_netrc = (enum CURL_NETRC_OPTION)va_arg(param, long);
break;
case CURLOPT_NETRC_FILE:
/*
* Use this file instead of the $HOME/.netrc file
*/
result = setstropt(&data->set.str[STRING_NETRC_FILE],
va_arg(param, char *));
break;
case CURLOPT_TRANSFERTEXT:
/*
* This option was previously named 'FTPASCII'. Renamed to work with
* more protocols than merely FTP.
*
* Transfer using ASCII (instead of BINARY).
*/
data->set.prefer_ascii = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_TIMECONDITION:
/*
* Set HTTP time condition. This must be one of the defines in the
* curl/curl.h header file.
*/
data->set.timecondition = (curl_TimeCond)va_arg(param, long);
break;
case CURLOPT_TIMEVALUE:
/*
* This is the value to compare with the remote document with the
* method set with CURLOPT_TIMECONDITION
*/
data->set.timevalue = (time_t)va_arg(param, long);
break;
case CURLOPT_SSLVERSION:
/*
* Set explicit SSL version to try to connect with, as some SSL
* implementations are lame.
*/
data->set.ssl.version = va_arg(param, long);
break;
#ifndef CURL_DISABLE_HTTP
case CURLOPT_AUTOREFERER:
/*
* Switch on automatic referer that gets set if curl follows locations.
*/
data->set.http_auto_referer = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_ACCEPT_ENCODING:
/*
* String to use at the value of Accept-Encoding header.
*
* If the encoding is set to "" we use an Accept-Encoding header that
* encompasses all the encodings we support.
* If the encoding is set to NULL we don't send an Accept-Encoding header
* and ignore an received Content-Encoding header.
*
*/
argptr = va_arg(param, char *);
result = setstropt(&data->set.str[STRING_ENCODING],
(argptr && !*argptr)?
(char *) ALL_CONTENT_ENCODINGS: argptr);
break;
case CURLOPT_TRANSFER_ENCODING:
data->set.http_transfer_encoding = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FOLLOWLOCATION:
/*
* Follow Location: header hints on a HTTP-server.
*/
data->set.http_follow_location = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_UNRESTRICTED_AUTH:
/*
* Send authentication (user+password) when following locations, even when
* hostname changed.
*/
data->set.http_disable_hostname_check_before_authentication =
(0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_MAXREDIRS:
/*
* The maximum amount of hops you allow curl to follow Location:
* headers. This should mostly be used to detect never-ending loops.
*/
data->set.maxredirs = va_arg(param, long);
break;
case CURLOPT_POSTREDIR:
{
/*
* Set the behaviour of POST when redirecting
* CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302
* CURL_REDIR_POST_301 - POST is kept as POST after 301
* CURL_REDIR_POST_302 - POST is kept as POST after 302
* CURL_REDIR_POST_303 - POST is kept as POST after 303
* CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
* other - POST is kept as POST after 301 and 302
*/
int postRedir = curlx_sltosi(va_arg(param, long));
data->set.keep_post = postRedir & CURL_REDIR_POST_ALL;
}
break;
case CURLOPT_POST:
/* Does this option serve a purpose anymore? Yes it does, when
CURLOPT_POSTFIELDS isn't used and the POST data is read off the
callback! */
if(va_arg(param, long)) {
data->set.httpreq = HTTPREQ_POST;
data->set.opt_no_body = FALSE; /* this is implied */
}
else
data->set.httpreq = HTTPREQ_GET;
break;
case CURLOPT_COPYPOSTFIELDS:
/*
* A string with POST data. Makes curl HTTP POST. Even if it is NULL.
* If needed, CURLOPT_POSTFIELDSIZE must have been set prior to
* CURLOPT_COPYPOSTFIELDS and not altered later.
*/
argptr = va_arg(param, char *);
if(!argptr || data->set.postfieldsize == -1)
result = setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);
else {
/*
* Check that requested length does not overflow the size_t type.
*/
if((data->set.postfieldsize < 0) ||
((sizeof(curl_off_t) != sizeof(size_t)) &&
(data->set.postfieldsize > (curl_off_t)((size_t)-1))))
result = CURLE_OUT_OF_MEMORY;
else {
char * p;
(void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
/* Allocate even when size == 0. This satisfies the need of possible
later address compare to detect the COPYPOSTFIELDS mode, and
to mark that postfields is used rather than read function or
form data.
*/
p = malloc((size_t)(data->set.postfieldsize?
data->set.postfieldsize:1));
if(!p)
result = CURLE_OUT_OF_MEMORY;
else {
if(data->set.postfieldsize)
memcpy(p, argptr, (size_t)data->set.postfieldsize);
data->set.str[STRING_COPYPOSTFIELDS] = p;
}
}
}
data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS];
data->set.httpreq = HTTPREQ_POST;
break;
case CURLOPT_POSTFIELDS:
/*
* Like above, but use static data instead of copying it.
*/
data->set.postfields = va_arg(param, void *);
/* Release old copied data. */
(void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
data->set.httpreq = HTTPREQ_POST;
break;
case CURLOPT_POSTFIELDSIZE:
/*
* The size of the POSTFIELD data to prevent libcurl to do strlen() to
* figure it out. Enables binary posts.
*/
bigsize = va_arg(param, long);
if(data->set.postfieldsize < bigsize &&
data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
/* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
(void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
data->set.postfields = NULL;
}
data->set.postfieldsize = bigsize;
break;
case CURLOPT_POSTFIELDSIZE_LARGE:
/*
* The size of the POSTFIELD data to prevent libcurl to do strlen() to
* figure it out. Enables binary posts.
*/
bigsize = va_arg(param, curl_off_t);
if(data->set.postfieldsize < bigsize &&
data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
/* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
(void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
data->set.postfields = NULL;
}
data->set.postfieldsize = bigsize;
break;
case CURLOPT_HTTPPOST:
/*
* Set to make us do HTTP POST
*/
data->set.httppost = va_arg(param, struct curl_httppost *);
data->set.httpreq = HTTPREQ_POST_FORM;
data->set.opt_no_body = FALSE; /* this is implied */
break;
case CURLOPT_REFERER:
/*
* String to set in the HTTP Referer: field.
*/
if(data->change.referer_alloc) {
Curl_safefree(data->change.referer);
data->change.referer_alloc = FALSE;
}
result = setstropt(&data->set.str[STRING_SET_REFERER],
va_arg(param, char *));
data->change.referer = data->set.str[STRING_SET_REFERER];
break;
case CURLOPT_USERAGENT:
/*
* String to use in the HTTP User-Agent field
*/
result = setstropt(&data->set.str[STRING_USERAGENT],
va_arg(param, char *));
break;
case CURLOPT_HTTPHEADER:
/*
* Set a list with HTTP headers to use (or replace internals with)
*/
data->set.headers = va_arg(param, struct curl_slist *);
break;
case CURLOPT_PROXYHEADER:
/*
* Set a list with proxy headers to use (or replace internals with)
*
* Since CURLOPT_HTTPHEADER was the only way to set HTTP headers for a
* long time we remain doing it this way until CURLOPT_PROXYHEADER is
* used. As soon as this option has been used, if set to anything but
* NULL, custom headers for proxies are only picked from this list.
*
* Set this option to NULL to restore the previous behavior.
*/
data->set.proxyheaders = va_arg(param, struct curl_slist *);
break;
case CURLOPT_HEADEROPT:
/*
* Set header option.
*/
arg = va_arg(param, long);
data->set.sep_headers = (arg & CURLHEADER_SEPARATE)? TRUE: FALSE;
break;
case CURLOPT_HTTP200ALIASES:
/*
* Set a list of aliases for HTTP 200 in response header
*/
data->set.http200aliases = va_arg(param, struct curl_slist *);
break;
#if !defined(CURL_DISABLE_COOKIES)
case CURLOPT_COOKIE:
/*
* Cookie string to send to the remote server in the request.
*/
result = setstropt(&data->set.str[STRING_COOKIE],
va_arg(param, char *));
break;
case CURLOPT_COOKIEFILE:
/*
* Set cookie file to read and parse. Can be used multiple times.
*/
argptr = (char *)va_arg(param, void *);
if(argptr) {
struct curl_slist *cl;
/* append the cookie file name to the list of file names, and deal with
them later */
cl = curl_slist_append(data->change.cookielist, argptr);
if(!cl) {
curl_slist_free_all(data->change.cookielist);
data->change.cookielist = NULL;
return CURLE_OUT_OF_MEMORY;
}
data->change.cookielist = cl; /* store the list for later use */
}
break;
case CURLOPT_COOKIEJAR:
/*
* Set cookie file name to dump all cookies to when we're done.
*/
{
struct CookieInfo *newcookies;
result = setstropt(&data->set.str[STRING_COOKIEJAR],
va_arg(param, char *));
/*
* Activate the cookie parser. This may or may not already
* have been made.
*/
newcookies = Curl_cookie_init(data, NULL, data->cookies,
data->set.cookiesession);
if(!newcookies)
result = CURLE_OUT_OF_MEMORY;
data->cookies = newcookies;
}
break;
case CURLOPT_COOKIESESSION:
/*
* Set this option to TRUE to start a new "cookie session". It will
* prevent the forthcoming read-cookies-from-file actions to accept
* cookies that are marked as being session cookies, as they belong to a
* previous session.
*
* In the original Netscape cookie spec, "session cookies" are cookies
* with no expire date set. RFC2109 describes the same action if no
* 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds
* a 'Discard' action that can enforce the discard even for cookies that
* have a Max-Age.
*
* We run mostly with the original cookie spec, as hardly anyone implements
* anything else.
*/
data->set.cookiesession = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_COOKIELIST:
argptr = va_arg(param, char *);
if(argptr == NULL)
break;
if(Curl_raw_equal(argptr, "ALL")) {
/* clear all cookies */
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
Curl_cookie_clearall(data->cookies);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
else if(Curl_raw_equal(argptr, "SESS")) {
/* clear session cookies */
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
Curl_cookie_clearsess(data->cookies);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
else if(Curl_raw_equal(argptr, "FLUSH")) {
/* flush cookies to file, takes care of the locking */
Curl_flush_cookies(data, 0);
}
else if(Curl_raw_equal(argptr, "RELOAD")) {
/* reload cookies from file */
Curl_cookie_loadfiles(data);
break;
}
else {
if(!data->cookies)
/* if cookie engine was not running, activate it */
data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
argptr = strdup(argptr);
if(!argptr || !data->cookies) {
result = CURLE_OUT_OF_MEMORY;
Curl_safefree(argptr);
}
else {
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
if(checkprefix("Set-Cookie:", argptr))
/* HTTP Header format line */
Curl_cookie_add(data, data->cookies, TRUE, argptr + 11, NULL, NULL);
else
/* Netscape format line */
Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
free(argptr);
}
}
break;
#endif /* CURL_DISABLE_COOKIES */
case CURLOPT_HTTPGET:
/*
* Set to force us do HTTP GET
*/
if(va_arg(param, long)) {
data->set.httpreq = HTTPREQ_GET;
data->set.upload = FALSE; /* switch off upload */
data->set.opt_no_body = FALSE; /* this is implied */
}
break;
case CURLOPT_HTTP_VERSION:
/*
* This sets a requested HTTP version to be used. The value is one of
* the listed enums in curl/curl.h.
*/
arg = va_arg(param, long);
#ifndef USE_NGHTTP2
if(arg == CURL_HTTP_VERSION_2_0)
return CURLE_UNSUPPORTED_PROTOCOL;
#endif
data->set.httpversion = arg;
break;
case CURLOPT_HTTPAUTH:
/*
* Set HTTP Authentication type BITMASK.
*/
{
int bitcheck;
bool authbits;
unsigned long auth = va_arg(param, unsigned long);
if(auth == CURLAUTH_NONE) {
data->set.httpauth = auth;
break;
}
/* the DIGEST_IE bit is only used to set a special marker, for all the
rest we need to handle it as normal DIGEST */
data->state.authhost.iestyle = (auth & CURLAUTH_DIGEST_IE)?TRUE:FALSE;
if(auth & CURLAUTH_DIGEST_IE) {
auth |= CURLAUTH_DIGEST; /* set standard digest bit */
auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
}
/* switch off bits we can't support */
#ifndef USE_NTLM
auth &= ~CURLAUTH_NTLM; /* no NTLM support */
auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
#elif !defined(NTLM_WB_ENABLED)
auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
#endif
#ifndef USE_SPNEGO
auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
GSS-API or SSPI */
#endif
/* check if any auth bit lower than CURLAUTH_ONLY is still set */
bitcheck = 0;
authbits = FALSE;
while(bitcheck < 31) {
if(auth & (1UL << bitcheck++)) {
authbits = TRUE;
break;
}
}
if(!authbits)
return CURLE_NOT_BUILT_IN; /* no supported types left! */
data->set.httpauth = auth;
}
break;
case CURLOPT_EXPECT_100_TIMEOUT_MS:
/*
* Time to wait for a response to a HTTP request containing an
* Expect: 100-continue header before sending the data anyway.
*/
data->set.expect_100_timeout = va_arg(param, long);
break;
#endif /* CURL_DISABLE_HTTP */
case CURLOPT_CUSTOMREQUEST:
/*
* Set a custom string to use as request
*/
result = setstropt(&data->set.str[STRING_CUSTOMREQUEST],
va_arg(param, char *));
/* we don't set
data->set.httpreq = HTTPREQ_CUSTOM;
here, we continue as if we were using the already set type
and this just changes the actual request keyword */
break;
#ifndef CURL_DISABLE_PROXY
case CURLOPT_HTTPPROXYTUNNEL:
/*
* Tunnel operations through the proxy instead of normal proxy use
*/
data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_PROXYPORT:
/*
* Explicitly set HTTP proxy port number.
*/
data->set.proxyport = va_arg(param, long);
break;
case CURLOPT_PROXYAUTH:
/*
* Set HTTP Authentication type BITMASK.
*/
{
int bitcheck;
bool authbits;
unsigned long auth = va_arg(param, unsigned long);
if(auth == CURLAUTH_NONE) {
data->set.proxyauth = auth;
break;
}
/* the DIGEST_IE bit is only used to set a special marker, for all the
rest we need to handle it as normal DIGEST */
data->state.authproxy.iestyle = (auth & CURLAUTH_DIGEST_IE)?TRUE:FALSE;
if(auth & CURLAUTH_DIGEST_IE) {
auth |= CURLAUTH_DIGEST; /* set standard digest bit */
auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
}
/* switch off bits we can't support */
#ifndef USE_NTLM
auth &= ~CURLAUTH_NTLM; /* no NTLM support */
auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
#elif !defined(NTLM_WB_ENABLED)
auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
#endif
#ifndef USE_SPNEGO
auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
GSS-API or SSPI */
#endif
/* check if any auth bit lower than CURLAUTH_ONLY is still set */
bitcheck = 0;
authbits = FALSE;
while(bitcheck < 31) {
if(auth & (1UL << bitcheck++)) {
authbits = TRUE;
break;
}
}
if(!authbits)
return CURLE_NOT_BUILT_IN; /* no supported types left! */
data->set.proxyauth = auth;
}
break;
case CURLOPT_PROXY:
/*
* Set proxy server:port to use as HTTP proxy.
*
* If the proxy is set to "" we explicitly say that we don't want to use a
* proxy (even though there might be environment variables saying so).
*
* Setting it to NULL, means no proxy but allows the environment variables
* to decide for us.
*/
result = setstropt(&data->set.str[STRING_PROXY],
va_arg(param, char *));
break;
case CURLOPT_PROXYTYPE:
/*
* Set proxy type. HTTP/HTTP_1_0/SOCKS4/SOCKS4a/SOCKS5/SOCKS5_HOSTNAME
*/
data->set.proxytype = (curl_proxytype)va_arg(param, long);
break;
case CURLOPT_PROXY_TRANSFER_MODE:
/*
* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy
*/
switch (va_arg(param, long)) {
case 0:
data->set.proxy_transfer_mode = FALSE;
break;
case 1:
data->set.proxy_transfer_mode = TRUE;
break;
default:
/* reserve other values for future use */
result = CURLE_UNKNOWN_OPTION;
break;
}
break;
#endif /* CURL_DISABLE_PROXY */
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
case CURLOPT_SOCKS5_GSSAPI_SERVICE:
/*
* Set GSS-API service name
*/
result = setstropt(&data->set.str[STRING_SOCKS5_GSSAPI_SERVICE],
va_arg(param, char *));
break;
case CURLOPT_SOCKS5_GSSAPI_NEC:
/*
* set flag for nec socks5 support
*/
data->set.socks5_gssapi_nec = (0 != va_arg(param, long))?TRUE:FALSE;
break;
#endif
case CURLOPT_HEADERDATA:
/*
* Custom pointer to pass the header write callback function
*/
data->set.writeheader = (void *)va_arg(param, void *);
break;
case CURLOPT_ERRORBUFFER:
/*
* Error buffer provided by the caller to get the human readable
* error string in.
*/
data->set.errorbuffer = va_arg(param, char *);
break;
case CURLOPT_WRITEDATA:
/*
* FILE pointer to write to. Or possibly
* used as argument to the write callback.
*/
data->set.out = va_arg(param, void *);
break;
case CURLOPT_FTPPORT:
/*
* Use FTP PORT, this also specifies which IP address to use
*/
result = setstropt(&data->set.str[STRING_FTPPORT],
va_arg(param, char *));
data->set.ftp_use_port = (NULL != data->set.str[STRING_FTPPORT]) ?
TRUE:FALSE;
break;
case CURLOPT_FTP_USE_EPRT:
data->set.ftp_use_eprt = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_USE_EPSV:
data->set.ftp_use_epsv = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_USE_PRET:
data->set.ftp_use_pret = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_SSL_CCC:
data->set.ftp_ccc = (curl_ftpccc)va_arg(param, long);
break;
case CURLOPT_FTP_SKIP_PASV_IP:
/*
* Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the
* bypass of the IP address in PASV responses.
*/
data->set.ftp_skip_ip = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_READDATA:
/*
* FILE pointer to read the file to be uploaded from. Or possibly
* used as argument to the read callback.
*/
data->set.in = va_arg(param, void *);
break;
case CURLOPT_INFILESIZE:
/*
* If known, this should inform curl about the file size of the
* to-be-uploaded file.
*/
data->set.filesize = va_arg(param, long);
break;
case CURLOPT_INFILESIZE_LARGE:
/*
* If known, this should inform curl about the file size of the
* to-be-uploaded file.
*/
data->set.filesize = va_arg(param, curl_off_t);
break;
case CURLOPT_LOW_SPEED_LIMIT:
/*
* The low speed limit that if transfers are below this for
* CURLOPT_LOW_SPEED_TIME, the transfer is aborted.
*/
data->set.low_speed_limit=va_arg(param, long);
break;
case CURLOPT_MAX_SEND_SPEED_LARGE:
/*
* When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE
* bytes per second the transfer is throttled..
*/
data->set.max_send_speed=va_arg(param, curl_off_t);
break;
case CURLOPT_MAX_RECV_SPEED_LARGE:
/*
* When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per
* second the transfer is throttled..
*/
data->set.max_recv_speed=va_arg(param, curl_off_t);
break;
case CURLOPT_LOW_SPEED_TIME:
/*
* The low speed time that if transfers are below the set
* CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted.
*/
data->set.low_speed_time=va_arg(param, long);
break;
case CURLOPT_URL:
/*
* The URL to fetch.
*/
if(data->change.url_alloc) {
/* the already set URL is allocated, free it first! */
Curl_safefree(data->change.url);
data->change.url_alloc = FALSE;
}
result = setstropt(&data->set.str[STRING_SET_URL],
va_arg(param, char *));
data->change.url = data->set.str[STRING_SET_URL];
break;
case CURLOPT_PORT:
/*
* The port number to use when getting the URL
*/
data->set.use_port = va_arg(param, long);
break;
case CURLOPT_TIMEOUT:
/*
* The maximum time you allow curl to use for a single transfer
* operation.
*/
data->set.timeout = va_arg(param, long) * 1000L;
break;
case CURLOPT_TIMEOUT_MS:
data->set.timeout = va_arg(param, long);
break;
case CURLOPT_CONNECTTIMEOUT:
/*
* The maximum time you allow curl to use to connect.
*/
data->set.connecttimeout = va_arg(param, long) * 1000L;
break;
case CURLOPT_CONNECTTIMEOUT_MS:
data->set.connecttimeout = va_arg(param, long);
break;
case CURLOPT_ACCEPTTIMEOUT_MS:
/*
* The maximum time you allow curl to wait for server connect
*/
data->set.accepttimeout = va_arg(param, long);
break;
case CURLOPT_USERPWD:
/*
* user:password to use in the operation
*/
result = setstropt_userpwd(va_arg(param, char *),
&data->set.str[STRING_USERNAME],
&data->set.str[STRING_PASSWORD]);
break;
case CURLOPT_USERNAME:
/*
* authentication user name to use in the operation
*/
result = setstropt(&data->set.str[STRING_USERNAME],
va_arg(param, char *));
break;
case CURLOPT_PASSWORD:
/*
* authentication password to use in the operation
*/
result = setstropt(&data->set.str[STRING_PASSWORD],
va_arg(param, char *));
break;
case CURLOPT_LOGIN_OPTIONS:
/*
* authentication options to use in the operation
*/
result = setstropt(&data->set.str[STRING_OPTIONS],
va_arg(param, char *));
break;
case CURLOPT_XOAUTH2_BEARER:
/*
* XOAUTH2 bearer token to use in the operation
*/
result = setstropt(&data->set.str[STRING_BEARER],
va_arg(param, char *));
break;
case CURLOPT_POSTQUOTE:
/*
* List of RAW FTP commands to use after a transfer
*/
data->set.postquote = va_arg(param, struct curl_slist *);
break;
case CURLOPT_PREQUOTE:
/*
* List of RAW FTP commands to use prior to RETR (Wesley Laxton)
*/
data->set.prequote = va_arg(param, struct curl_slist *);
break;
case CURLOPT_QUOTE:
/*
* List of RAW FTP commands to use before a transfer
*/
data->set.quote = va_arg(param, struct curl_slist *);
break;
case CURLOPT_RESOLVE:
/*
* List of NAME:[address] names to populate the DNS cache with
* Prefix the NAME with dash (-) to _remove_ the name from the cache.
*
* Names added with this API will remain in the cache until explicitly
* removed or the handle is cleaned up.
*
* This API can remove any name from the DNS cache, but only entries
* that aren't actually in use right now will be pruned immediately.
*/
data->set.resolve = va_arg(param, struct curl_slist *);
data->change.resolve = data->set.resolve;
break;
case CURLOPT_PROGRESSFUNCTION:
/*
* Progress callback function
*/
data->set.fprogress = va_arg(param, curl_progress_callback);
if(data->set.fprogress)
data->progress.callback = TRUE; /* no longer internal */
else
data->progress.callback = FALSE; /* NULL enforces internal */
break;
case CURLOPT_XFERINFOFUNCTION:
/*
* Transfer info callback function
*/
data->set.fxferinfo = va_arg(param, curl_xferinfo_callback);
if(data->set.fxferinfo)
data->progress.callback = TRUE; /* no longer internal */
else
data->progress.callback = FALSE; /* NULL enforces internal */
break;
case CURLOPT_PROGRESSDATA:
/*
* Custom client data to pass to the progress callback
*/
data->set.progress_client = va_arg(param, void *);
break;
#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXYUSERPWD:
/*
* user:password needed to use the proxy
*/
result = setstropt_userpwd(va_arg(param, char *),
&data->set.str[STRING_PROXYUSERNAME],
&data->set.str[STRING_PROXYPASSWORD]);
break;
case CURLOPT_PROXYUSERNAME:
/*
* authentication user name to use in the operation
*/
result = setstropt(&data->set.str[STRING_PROXYUSERNAME],
va_arg(param, char *));
break;
case CURLOPT_PROXYPASSWORD:
/*
* authentication password to use in the operation
*/
result = setstropt(&data->set.str[STRING_PROXYPASSWORD],
va_arg(param, char *));
break;
case CURLOPT_NOPROXY:
/*
* proxy exception list
*/
result = setstropt(&data->set.str[STRING_NOPROXY],
va_arg(param, char *));
break;
#endif
case CURLOPT_RANGE:
/*
* What range of the file you want to transfer
*/
result = setstropt(&data->set.str[STRING_SET_RANGE],
va_arg(param, char *));
break;
case CURLOPT_RESUME_FROM:
/*
* Resume transfer at the give file position
*/
data->set.set_resume_from = va_arg(param, long);
break;
case CURLOPT_RESUME_FROM_LARGE:
/*
* Resume transfer at the give file position
*/
data->set.set_resume_from = va_arg(param, curl_off_t);
break;
case CURLOPT_DEBUGFUNCTION:
/*
* stderr write callback.
*/
data->set.fdebug = va_arg(param, curl_debug_callback);
/*
* if the callback provided is NULL, it'll use the default callback
*/
break;
case CURLOPT_DEBUGDATA:
/*
* Set to a void * that should receive all error writes. This
* defaults to CURLOPT_STDERR for normal operations.
*/
data->set.debugdata = va_arg(param, void *);
break;
case CURLOPT_STDERR:
/*
* Set to a FILE * that should receive all error writes. This
* defaults to stderr for normal operations.
*/
data->set.err = va_arg(param, FILE *);
if(!data->set.err)
data->set.err = stderr;
break;
case CURLOPT_HEADERFUNCTION:
/*
* Set header write callback
*/
data->set.fwrite_header = va_arg(param, curl_write_callback);
break;
case CURLOPT_WRITEFUNCTION:
/*
* Set data write callback
*/
data->set.fwrite_func = va_arg(param, curl_write_callback);
if(!data->set.fwrite_func) {
data->set.is_fwrite_set = 0;
/* When set to NULL, reset to our internal default function */
data->set.fwrite_func = (curl_write_callback)fwrite;
}
else
data->set.is_fwrite_set = 1;
break;
case CURLOPT_READFUNCTION:
/*
* Read data callback
*/
data->set.fread_func = va_arg(param, curl_read_callback);
if(!data->set.fread_func) {
data->set.is_fread_set = 0;
/* When set to NULL, reset to our internal default function */
data->set.fread_func = (curl_read_callback)fread;
}
else
data->set.is_fread_set = 1;
break;
case CURLOPT_SEEKFUNCTION:
/*
* Seek callback. Might be NULL.
*/
data->set.seek_func = va_arg(param, curl_seek_callback);
break;
case CURLOPT_SEEKDATA:
/*
* Seek control callback. Might be NULL.
*/
data->set.seek_client = va_arg(param, void *);
break;
case CURLOPT_CONV_FROM_NETWORK_FUNCTION:
/*
* "Convert from network encoding" callback
*/
data->set.convfromnetwork = va_arg(param, curl_conv_callback);
break;
case CURLOPT_CONV_TO_NETWORK_FUNCTION:
/*
* "Convert to network encoding" callback
*/
data->set.convtonetwork = va_arg(param, curl_conv_callback);
break;
case CURLOPT_CONV_FROM_UTF8_FUNCTION:
/*
* "Convert from UTF-8 encoding" callback
*/
data->set.convfromutf8 = va_arg(param, curl_conv_callback);
break;
case CURLOPT_IOCTLFUNCTION:
/*
* I/O control callback. Might be NULL.
*/
data->set.ioctl_func = va_arg(param, curl_ioctl_callback);
break;
case CURLOPT_IOCTLDATA:
/*
* I/O control data pointer. Might be NULL.
*/
data->set.ioctl_client = va_arg(param, void *);
break;
case CURLOPT_SSLCERT:
/*
* String that holds file name of the SSL certificate to use
*/
result = setstropt(&data->set.str[STRING_CERT],
va_arg(param, char *));
break;
case CURLOPT_SSLCERTTYPE:
/*
* String that holds file type of the SSL certificate to use
*/
result = setstropt(&data->set.str[STRING_CERT_TYPE],
va_arg(param, char *));
break;
case CURLOPT_SSLKEY:
/*
* String that holds file name of the SSL key to use
*/
result = setstropt(&data->set.str[STRING_KEY],
va_arg(param, char *));
break;
case CURLOPT_SSLKEYTYPE:
/*
* String that holds file type of the SSL key to use
*/
result = setstropt(&data->set.str[STRING_KEY_TYPE],
va_arg(param, char *));
break;
case CURLOPT_KEYPASSWD:
/*
* String that holds the SSL or SSH private key password.
*/
result = setstropt(&data->set.str[STRING_KEY_PASSWD],
va_arg(param, char *));
break;
case CURLOPT_SSLENGINE:
/*
* String that holds the SSL crypto engine.
*/
argptr = va_arg(param, char *);
if(argptr && argptr[0])
result = Curl_ssl_set_engine(data, argptr);
break;
case CURLOPT_SSLENGINE_DEFAULT:
/*
* flag to set engine as default.
*/
result = Curl_ssl_set_engine_default(data);
break;
case CURLOPT_CRLF:
/*
* Kludgy option to enable CRLF conversions. Subject for removal.
*/
data->set.crlf = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_INTERFACE:
/*
* Set what interface or address/hostname to bind the socket to when
* performing an operation and thus what from-IP your connection will use.
*/
result = setstropt(&data->set.str[STRING_DEVICE],
va_arg(param, char *));
break;
case CURLOPT_LOCALPORT:
/*
* Set what local port to bind the socket to when performing an operation.
*/
data->set.localport = curlx_sltous(va_arg(param, long));
break;
case CURLOPT_LOCALPORTRANGE:
/*
* Set number of local ports to try, starting with CURLOPT_LOCALPORT.
*/
data->set.localportrange = curlx_sltosi(va_arg(param, long));
break;
case CURLOPT_KRBLEVEL:
/*
* A string that defines the kerberos security level.
*/
result = setstropt(&data->set.str[STRING_KRB_LEVEL],
va_arg(param, char *));
data->set.krb = (NULL != data->set.str[STRING_KRB_LEVEL])?TRUE:FALSE;
break;
case CURLOPT_GSSAPI_DELEGATION:
/*
* GSS-API credential delegation
*/
data->set.gssapi_delegation = va_arg(param, long);
break;
case CURLOPT_SSL_VERIFYPEER:
/*
* Enable peer SSL verifying.
*/
data->set.ssl.verifypeer = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_SSL_VERIFYHOST:
/*
* Enable verification of the host name in the peer certificate
*/
arg = va_arg(param, long);
/* Obviously people are not reading documentation and too many thought
this argument took a boolean when it wasn't and misused it. We thus ban
1 as a sensible input and we warn about its use. Then we only have the
2 action internally stored as TRUE. */
if(1 == arg) {
failf(data, "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
data->set.ssl.verifyhost = (0 != arg)?TRUE:FALSE;
break;
case CURLOPT_SSL_CTX_FUNCTION:
#ifdef have_curlssl_ssl_ctx
/*
* Set a SSL_CTX callback
*/
data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback);
#else
result = CURLE_NOT_BUILT_IN;
#endif
break;
case CURLOPT_SSL_CTX_DATA:
#ifdef have_curlssl_ssl_ctx
/*
* Set a SSL_CTX callback parameter pointer
*/
data->set.ssl.fsslctxp = va_arg(param, void *);
#else
result = CURLE_NOT_BUILT_IN;
#endif
break;
case CURLOPT_CERTINFO:
#ifdef have_curlssl_certinfo
data->set.ssl.certinfo = (0 != va_arg(param, long))?TRUE:FALSE;
#else
result = CURLE_NOT_BUILT_IN;
#endif
break;
case CURLOPT_PINNEDPUBLICKEY:
/*
* Set pinned public key for SSL connection.
* Specify file name of the public key in DER format.
*/
result = setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY],
va_arg(param, char *));
break;
case CURLOPT_CAINFO:
/*
* Set CA info for SSL connection. Specify file name of the CA certificate
*/
result = setstropt(&data->set.str[STRING_SSL_CAFILE],
va_arg(param, char *));
break;
case CURLOPT_CAPATH:
#ifdef have_curlssl_ca_path /* not supported by all backends */
/*
* Set CA path info for SSL connection. Specify directory name of the CA
* certificates which have been prepared using openssl c_rehash utility.
*/
/* This does not work on windows. */
result = setstropt(&data->set.str[STRING_SSL_CAPATH],
va_arg(param, char *));
#else
result = CURLE_NOT_BUILT_IN;
#endif
break;
case CURLOPT_CRLFILE:
/*
* Set CRL file info for SSL connection. Specify file name of the CRL
* to check certificates revocation
*/
result = setstropt(&data->set.str[STRING_SSL_CRLFILE],
va_arg(param, char *));
break;
case CURLOPT_ISSUERCERT:
/*
* Set Issuer certificate file
* to check certificates issuer
*/
result = setstropt(&data->set.str[STRING_SSL_ISSUERCERT],
va_arg(param, char *));
break;
case CURLOPT_TELNETOPTIONS:
/*
* Set a linked list of telnet options
*/
data->set.telnet_options = va_arg(param, struct curl_slist *);
break;
case CURLOPT_BUFFERSIZE:
/*
* The application kindly asks for a differently sized receive buffer.
* If it seems reasonable, we'll use it.
*/
data->set.buffer_size = va_arg(param, long);
if((data->set.buffer_size> (BUFSIZE -1 )) ||
(data->set.buffer_size < 1))
data->set.buffer_size = 0; /* huge internal default */
break;
case CURLOPT_NOSIGNAL:
/*
* The application asks not to set any signal() or alarm() handlers,
* even when using a timeout.
*/
data->set.no_signal = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_SHARE:
{
struct Curl_share *set;
set = va_arg(param, struct Curl_share *);
/* disconnect from old share, if any */
if(data->share) {
Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
if(data->dns.hostcachetype == HCACHE_SHARED) {
data->dns.hostcache = NULL;
data->dns.hostcachetype = HCACHE_NONE;
}
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
if(data->share->cookies == data->cookies)
data->cookies = NULL;
#endif
if(data->share->sslsession == data->state.session)
data->state.session = NULL;
data->share->dirty--;
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
data->share = NULL;
}
/* use new share if it set */
data->share = set;
if(data->share) {
Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
data->share->dirty++;
if(data->share->hostcache) {
/* use shared host cache */
data->dns.hostcache = data->share->hostcache;
data->dns.hostcachetype = HCACHE_SHARED;
}
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
if(data->share->cookies) {
/* use shared cookie list, first free own one if any */
if(data->cookies)
Curl_cookie_cleanup(data->cookies);
/* enable cookies since we now use a share that uses cookies! */
data->cookies = data->share->cookies;
}
#endif /* CURL_DISABLE_HTTP */
if(data->share->sslsession) {
data->set.ssl.max_ssl_sessions = data->share->max_ssl_sessions;
data->state.session = data->share->sslsession;
}
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
}
/* check for host cache not needed,
* it will be done by curl_easy_perform */
}
break;
case CURLOPT_PRIVATE:
/*
* Set private data pointer.
*/
data->set.private_data = va_arg(param, void *);
break;
case CURLOPT_MAXFILESIZE:
/*
* Set the maximum size of a file to download.
*/
data->set.max_filesize = va_arg(param, long);
break;
#ifdef USE_SSL
case CURLOPT_USE_SSL:
/*
* Make transfers attempt to use SSL/TLS.
*/
data->set.use_ssl = (curl_usessl)va_arg(param, long);
break;
case CURLOPT_SSL_OPTIONS:
arg = va_arg(param, long);
data->set.ssl_enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
break;
#endif
case CURLOPT_FTPSSLAUTH:
/*
* Set a specific auth for FTP-SSL transfers.
*/
data->set.ftpsslauth = (curl_ftpauth)va_arg(param, long);
break;
case CURLOPT_IPRESOLVE:
data->set.ipver = va_arg(param, long);
break;
case CURLOPT_MAXFILESIZE_LARGE:
/*
* Set the maximum size of a file to download.
*/
data->set.max_filesize = va_arg(param, curl_off_t);
break;
case CURLOPT_TCP_NODELAY:
/*
* Enable or disable TCP_NODELAY, which will disable/enable the Nagle
* algorithm
*/
data->set.tcp_nodelay = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_ACCOUNT:
result = setstropt(&data->set.str[STRING_FTP_ACCOUNT],
va_arg(param, char *));
break;
case CURLOPT_IGNORE_CONTENT_LENGTH:
data->set.ignorecl = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_CONNECT_ONLY:
/*
* No data transfer, set up connection and let application use the socket
*/
data->set.connect_only = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_ALTERNATIVE_TO_USER:
result = setstropt(&data->set.str[STRING_FTP_ALTERNATIVE_TO_USER],
va_arg(param, char *));
break;
case CURLOPT_SOCKOPTFUNCTION:
/*
* socket callback function: called after socket() but before connect()
*/
data->set.fsockopt = va_arg(param, curl_sockopt_callback);
break;
case CURLOPT_SOCKOPTDATA:
/*
* socket callback data pointer. Might be NULL.
*/
data->set.sockopt_client = va_arg(param, void *);
break;
case CURLOPT_OPENSOCKETFUNCTION:
/*
* open/create socket callback function: called instead of socket(),
* before connect()
*/
data->set.fopensocket = va_arg(param, curl_opensocket_callback);
break;
case CURLOPT_OPENSOCKETDATA:
/*
* socket callback data pointer. Might be NULL.
*/
data->set.opensocket_client = va_arg(param, void *);
break;
case CURLOPT_CLOSESOCKETFUNCTION:
/*
* close socket callback function: called instead of close()
* when shutting down a connection
*/
data->set.fclosesocket = va_arg(param, curl_closesocket_callback);
break;
case CURLOPT_CLOSESOCKETDATA:
/*
* socket callback data pointer. Might be NULL.
*/
data->set.closesocket_client = va_arg(param, void *);
break;
case CURLOPT_SSL_SESSIONID_CACHE:
data->set.ssl.sessionid = (0 != va_arg(param, long))?TRUE:FALSE;
break;
#ifdef USE_LIBSSH2
/* we only include SSH options if explicitly built to support SSH */
case CURLOPT_SSH_AUTH_TYPES:
data->set.ssh_auth_types = va_arg(param, long);
break;
case CURLOPT_SSH_PUBLIC_KEYFILE:
/*
* Use this file instead of the $HOME/.ssh/id_dsa.pub file
*/
result = setstropt(&data->set.str[STRING_SSH_PUBLIC_KEY],
va_arg(param, char *));
break;
case CURLOPT_SSH_PRIVATE_KEYFILE:
/*
* Use this file instead of the $HOME/.ssh/id_dsa file
*/
result = setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY],
va_arg(param, char *));
break;
case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
/*
* Option to allow for the MD5 of the host public key to be checked
* for validation purposes.
*/
result = setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5],
va_arg(param, char *));
break;
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
case CURLOPT_SSH_KNOWNHOSTS:
/*
* Store the file name to read known hosts from.
*/
result = setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS],
va_arg(param, char *));
break;
case CURLOPT_SSH_KEYFUNCTION:
/* setting to NULL is fine since the ssh.c functions themselves will
then rever to use the internal default */
data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback);
break;
case CURLOPT_SSH_KEYDATA:
/*
* Custom client data to pass to the SSH keyfunc callback
*/
data->set.ssh_keyfunc_userp = va_arg(param, void *);
break;
#endif /* HAVE_LIBSSH2_KNOWNHOST_API */
#endif /* USE_LIBSSH2 */
case CURLOPT_HTTP_TRANSFER_DECODING:
/*
* disable libcurl transfer encoding is used
*/
data->set.http_te_skip = (0 == va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_HTTP_CONTENT_DECODING:
/*
* raw data passed to the application when content encoding is used
*/
data->set.http_ce_skip = (0 == va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_NEW_FILE_PERMS:
/*
* Uses these permissions instead of 0644
*/
data->set.new_file_perms = va_arg(param, long);
break;
case CURLOPT_NEW_DIRECTORY_PERMS:
/*
* Uses these permissions instead of 0755
*/
data->set.new_directory_perms = va_arg(param, long);
break;
case CURLOPT_ADDRESS_SCOPE:
/*
* We always get longs when passed plain numericals, but for this value we
* know that an unsigned int will always hold the value so we blindly
* typecast to this type
*/
data->set.scope_id = curlx_sltoui(va_arg(param, long));
break;
case CURLOPT_PROTOCOLS:
/* set the bitmask for the protocols that are allowed to be used for the
transfer, which thus helps the app which takes URLs from users or other
external inputs and want to restrict what protocol(s) to deal
with. Defaults to CURLPROTO_ALL. */
data->set.allowed_protocols = va_arg(param, long);
break;
case CURLOPT_REDIR_PROTOCOLS:
/* set the bitmask for the protocols that libcurl is allowed to follow to,
as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
to be set in both bitmasks to be allowed to get redirected to. Defaults
to all protocols except FILE and SCP. */
data->set.redir_protocols = va_arg(param, long);
break;
case CURLOPT_MAIL_FROM:
/* Set the SMTP mail originator */
result = setstropt(&data->set.str[STRING_MAIL_FROM],
va_arg(param, char *));
break;
case CURLOPT_MAIL_AUTH:
/* Set the SMTP auth originator */
result = setstropt(&data->set.str[STRING_MAIL_AUTH],
va_arg(param, char *));
break;
case CURLOPT_MAIL_RCPT:
/* Set the list of mail recipients */
data->set.mail_rcpt = va_arg(param, struct curl_slist *);
break;
case CURLOPT_SASL_IR:
/* Enable/disable SASL initial response */
data->set.sasl_ir = (0 != va_arg(param, long)) ? TRUE : FALSE;
break;
case CURLOPT_RTSP_REQUEST:
{
/*
* Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)
* Would this be better if the RTSPREQ_* were just moved into here?
*/
long curl_rtspreq = va_arg(param, long);
Curl_RtspReq rtspreq = RTSPREQ_NONE;
switch(curl_rtspreq) {
case CURL_RTSPREQ_OPTIONS:
rtspreq = RTSPREQ_OPTIONS;
break;
case CURL_RTSPREQ_DESCRIBE:
rtspreq = RTSPREQ_DESCRIBE;
break;
case CURL_RTSPREQ_ANNOUNCE:
rtspreq = RTSPREQ_ANNOUNCE;
break;
case CURL_RTSPREQ_SETUP:
rtspreq = RTSPREQ_SETUP;
break;
case CURL_RTSPREQ_PLAY:
rtspreq = RTSPREQ_PLAY;
break;
case CURL_RTSPREQ_PAUSE:
rtspreq = RTSPREQ_PAUSE;
break;
case CURL_RTSPREQ_TEARDOWN:
rtspreq = RTSPREQ_TEARDOWN;
break;
case CURL_RTSPREQ_GET_PARAMETER:
rtspreq = RTSPREQ_GET_PARAMETER;
break;
case CURL_RTSPREQ_SET_PARAMETER:
rtspreq = RTSPREQ_SET_PARAMETER;
break;
case CURL_RTSPREQ_RECORD:
rtspreq = RTSPREQ_RECORD;
break;
case CURL_RTSPREQ_RECEIVE:
rtspreq = RTSPREQ_RECEIVE;
break;
default:
rtspreq = RTSPREQ_NONE;
}
data->set.rtspreq = rtspreq;
break;
}
case CURLOPT_RTSP_SESSION_ID:
/*
* Set the RTSP Session ID manually. Useful if the application is
* resuming a previously established RTSP session
*/
result = setstropt(&data->set.str[STRING_RTSP_SESSION_ID],
va_arg(param, char *));
break;
case CURLOPT_RTSP_STREAM_URI:
/*
* Set the Stream URI for the RTSP request. Unless the request is
* for generic server options, the application will need to set this.
*/
result = setstropt(&data->set.str[STRING_RTSP_STREAM_URI],
va_arg(param, char *));
break;
case CURLOPT_RTSP_TRANSPORT:
/*
* The content of the Transport: header for the RTSP request
*/
result = setstropt(&data->set.str[STRING_RTSP_TRANSPORT],
va_arg(param, char *));
break;
case CURLOPT_RTSP_CLIENT_CSEQ:
/*
* Set the CSEQ number to issue for the next RTSP request. Useful if the
* application is resuming a previously broken connection. The CSEQ
* will increment from this new number henceforth.
*/
data->state.rtsp_next_client_CSeq = va_arg(param, long);
break;
case CURLOPT_RTSP_SERVER_CSEQ:
/* Same as the above, but for server-initiated requests */
data->state.rtsp_next_client_CSeq = va_arg(param, long);
break;
case CURLOPT_INTERLEAVEDATA:
data->set.rtp_out = va_arg(param, void *);
break;
case CURLOPT_INTERLEAVEFUNCTION:
/* Set the user defined RTP write function */
data->set.fwrite_rtp = va_arg(param, curl_write_callback);
break;
case CURLOPT_WILDCARDMATCH:
data->set.wildcardmatch = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_CHUNK_BGN_FUNCTION:
data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback);
break;
case CURLOPT_CHUNK_END_FUNCTION:
data->set.chunk_end = va_arg(param, curl_chunk_end_callback);
break;
case CURLOPT_FNMATCH_FUNCTION:
data->set.fnmatch = va_arg(param, curl_fnmatch_callback);
break;
case CURLOPT_CHUNK_DATA:
data->wildcard.customptr = va_arg(param, void *);
break;
case CURLOPT_FNMATCH_DATA:
data->set.fnmatch_data = va_arg(param, void *);
break;
#ifdef USE_TLS_SRP
case CURLOPT_TLSAUTH_USERNAME:
result = setstropt(&data->set.str[STRING_TLSAUTH_USERNAME],
va_arg(param, char *));
if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
break;
case CURLOPT_TLSAUTH_PASSWORD:
result = setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD],
va_arg(param, char *));
if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
break;
case CURLOPT_TLSAUTH_TYPE:
if(strnequal((char *)va_arg(param, char *), "SRP", strlen("SRP")))
data->set.ssl.authtype = CURL_TLSAUTH_SRP;
else
data->set.ssl.authtype = CURL_TLSAUTH_NONE;
break;
#endif
case CURLOPT_DNS_SERVERS:
result = Curl_set_dns_servers(data, va_arg(param, char *));
break;
case CURLOPT_DNS_INTERFACE:
result = Curl_set_dns_interface(data, va_arg(param, char *));
break;
case CURLOPT_DNS_LOCAL_IP4:
result = Curl_set_dns_local_ip4(data, va_arg(param, char *));
break;
case CURLOPT_DNS_LOCAL_IP6:
result = Curl_set_dns_local_ip6(data, va_arg(param, char *));
break;
case CURLOPT_TCP_KEEPALIVE:
data->set.tcp_keepalive = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_TCP_KEEPIDLE:
data->set.tcp_keepidle = va_arg(param, long);
break;
case CURLOPT_TCP_KEEPINTVL:
data->set.tcp_keepintvl = va_arg(param, long);
break;
case CURLOPT_SSL_ENABLE_NPN:
data->set.ssl_enable_npn = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_SSL_ENABLE_ALPN:
data->set.ssl_enable_alpn = (0 != va_arg(param, long))?TRUE:FALSE;
break;
#ifdef USE_UNIX_SOCKETS
case CURLOPT_UNIX_SOCKET_PATH:
result = setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
va_arg(param, char *));
break;
#endif
default:
/* unknown tag and its companion, just ignore: */
result = CURLE_UNKNOWN_OPTION;
break;
}
return result;
}
| 0
|
90,805
|
void QuotaManager::RegisterClient(QuotaClient* client) {
DCHECK(io_thread_->BelongsToCurrentThread());
DCHECK(!database_.get());
clients_.push_back(client);
}
| 0
|
432,251
|
static void test_mem_protect_map_ptr(void)
{
uc_engine *uc;
uint64_t val = 0x114514;
uint8_t *data1 = NULL;
uint8_t *data2 = NULL;
uint64_t mem;
data1 = calloc(sizeof(*data1), 0x4000);
data2 = calloc(sizeof(*data2), 0x2000);
OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc));
OK(uc_mem_map_ptr(uc, 0x4000, 0x4000, UC_PROT_ALL, data1));
OK(uc_mem_unmap(uc, 0x6000, 0x2000));
OK(uc_mem_map_ptr(uc, 0x6000, 0x2000, UC_PROT_ALL, data2));
OK(uc_mem_write(uc, 0x6004, &val, 8));
OK(uc_mem_protect(uc, 0x6000, 0x1000, UC_PROT_READ));
OK(uc_mem_read(uc, 0x6004, (void *)&mem, 8));
TEST_CHECK(val == mem);
OK(uc_close(uc));
}
| 0
|
369,402
|
static inline void io_poll_execute(struct io_kiocb *req, int res, int events)
{
if (io_poll_get_ownership(req))
__io_poll_execute(req, res, events);
| 0
|
226,273
|
void lsr1_box_del(GF_Box *s)
{
GF_LASeRSampleEntryBox *ptr = (GF_LASeRSampleEntryBox *)s;
if (ptr == NULL) return;
gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);
if (ptr->slc) gf_odf_desc_del((GF_Descriptor *)ptr->slc);
gf_free(ptr);
| 0
|
270,766
|
static int write_env_passwd(unsigned char *sum, size_t length)
{
int fd;
unsigned char c;
int ret = 0;
if (!sum && length < 1)
return -EINVAL;
fd = open(PASSWD_DIR, O_RDONLY);
if (fd < 0)
mkdir(PASSWD_DIR, 644);
close(fd);
fd = open(PASSWD_FILE, O_WRONLY | O_CREAT, 600);
if (fd < 0)
return fd;
do {
c = to_hexa(*sum >> 4 & 0xf);
ret = write(fd, &c, sizeof(unsigned char));
if (ret < 0)
goto exit;
c = to_hexa(*sum & 0xf);
ret = write(fd, &c, sizeof(unsigned char));
if (ret < 0)
goto exit;
sum++;
length--;
} while(length > 0);
ret = 0;
exit:
close(fd);
return ret;
}
| 0
|
225,932
|
GF_Err gnrm_box_size(GF_Box *s)
{
GF_GenericSampleEntryBox *ptr = (GF_GenericSampleEntryBox *)s;
s->type = GF_ISOM_BOX_TYPE_GNRM;
ptr->size += 8+ptr->data_size;
return GF_OK;
}
| 0
|
241,043
|
int main(int argc, char *argv[], char *envp[])
{
int rv;
const char *cp;
#ifdef LOGGING_LIBQB
enum qb_log_target_slot i;
#endif
init_set_proc_title(argc, argv, envp);
get_time(&start_time);
memset(&cl, 0, sizeof(cl));
strncpy(cl.configfile,
BOOTH_DEFAULT_CONF, BOOTH_PATH_LEN - 1);
cl.lockfile[0] = 0;
debug_level = 0;
cp = ((cp = strstr(argv[0], ATTR_PROG)) && !strcmp(cp, ATTR_PROG)
? ATTR_PROG
: "booth");
#ifndef LOGGING_LIBQB
cl_log_set_entity(cp);
#else
qb_log_init(cp, LOG_USER, LOG_DEBUG); /* prio driven by debug_level */
for (i = QB_LOG_TARGET_START; i < QB_LOG_TARGET_MAX; i++) {
if (i == QB_LOG_SYSLOG || i == QB_LOG_BLACKBOX)
continue;
qb_log_format_set(i, "%t %H %N: [%P]: %p: %b");
}
(void) qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,
QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
#endif
cl_log_enable_stderr(TRUE);
cl_log_set_facility(0);
rv = read_arguments(argc, argv);
if (rv < 0)
goto out;
switch (cl.type) {
case STATUS:
rv = do_status(cl.type);
break;
case ARBITRATOR:
case DAEMON:
case SITE:
rv = do_server(cl.type);
break;
case CLIENT:
rv = do_client();
break;
case GEOSTORE:
rv = do_attr();
break;
}
out:
#ifdef LOGGING_LIBQB
qb_log_fini();
#endif
/* Normalize values. 0x100 would be seen as "OK" by waitpid(). */
return (rv >= 0 && rv < 0x70) ? rv : 1;
}
| 0
|
224,567
|
Status AvgPoolGradShape(shape_inference::InferenceContext* c) {
ShapeHandle s;
TF_RETURN_IF_ERROR(c->MakeShapeFromShapeTensor(0, &s));
TF_RETURN_IF_ERROR(c->WithRank(s, 4, &s));
c->set_output(0, s);
return Status::OK();
}
| 0
|
270,776
|
int password(unsigned char *passwd, size_t length, int flags, int timeout)
{
unsigned char *buf = passwd;
int pos = 0;
unsigned char ch;
uint64_t start;
if (!passwd)
return -EINVAL;
start = get_time_ns();
do {
if (tstc()) {
ch = getchar();
switch (ch) {
case '\r':
case '\n':
*buf = '\0';
puts("\r\n");
return pos;
case '\0':
case '\t':
continue;
case CTL_CH('c'):
passwd[0] = '\0';
puts("\r\n");
return -EINTR;
case CTL_CH('h'):
case BB_KEY_DEL7:
case BB_KEY_DEL:
if (pos > 0) {
if (flags & STAR)
puts("\b \b");
*buf = '\0';
buf--;
pos--;
}
continue;
default:
if (pos < length - 1) {
if (flags & STAR)
putchar('*');
else if (flags & CLEAR)
putchar(ch);
*buf = ch;
buf++;
pos++;
} else {
if (flags & STAR)
putchar('\a');
}
}
}
} while (!is_timeout(start, timeout * SECOND) || timeout == 0);
return -ETIMEDOUT;
}
| 0
|
213,589
|
process_button(struct parsed_tag *tag)
{
Str tmp = NULL;
char *p, *q, *r, *qq = "";
int qlen, v;
if (cur_form_id < 0) {
char *s = "<form_int method=internal action=none>";
tmp = process_form(parse_tag(&s, TRUE));
}
if (tmp == NULL)
tmp = Strnew();
p = "submit";
parsedtag_get_value(tag, ATTR_TYPE, &p);
q = NULL;
parsedtag_get_value(tag, ATTR_VALUE, &q);
r = "";
parsedtag_get_value(tag, ATTR_NAME, &r);
v = formtype(p);
if (v == FORM_UNKNOWN)
return NULL;
if (!q) {
switch (v) {
case FORM_INPUT_SUBMIT:
case FORM_INPUT_BUTTON:
q = "SUBMIT";
break;
case FORM_INPUT_RESET:
q = "RESET";
break;
}
}
if (q) {
qq = html_quote(q);
qlen = strlen(q);
}
/* Strcat_charp(tmp, "<pre_int>"); */
Strcat(tmp, Sprintf("<input_alt hseq=\"%d\" fid=\"%d\" type=\"%s\" "
"name=\"%s\" value=\"%s\">",
cur_hseq++, cur_form_id, html_quote(p),
html_quote(r), qq));
return tmp;
}
| 1
|
445,949
|
fr_window_free_batch_data (FrWindow *window)
{
GList *scan;
for (scan = window->priv->batch_action_list; scan; scan = scan->next) {
FrBatchAction *adata = scan->data;
if ((adata->data != NULL) && (adata->free_func != NULL))
(*adata->free_func) (adata->data);
g_free (adata);
}
g_list_free (window->priv->batch_action_list);
window->priv->batch_action_list = NULL;
window->priv->batch_action = NULL;
fr_window_reset_current_batch_action (window);
}
| 0
|
289,326
|
static int _snd_pcm_hw_param_mask(struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var,
const struct snd_mask *val)
{
int changed;
changed = snd_mask_refine(hw_param_mask(params, var), val);
if (changed > 0) {
params->cmask |= 1 << var;
params->rmask |= 1 << var;
}
return changed;
}
| 0
|
218,992
|
Status ConstantFolding::FoldMergeNode(NodeDef* node, GraphDef* output_graph) {
// Merge nodes are special, in the sense that they execute as soon as one of
// their input is ready. We can therefore fold a merge node iff it has at
// least one constant input without control dependency.
// We still need to ensure that the nodes in the fanin of the merge node are
// scheduled. We'll therefore add a control dependency from the merge node
// to the folded constant. We end up with:
// * the merge node and its inputs are preserved as is
// * a new constant node C1, driven by the merge node through a control
// dependency, initialized to the value of the folded input
// * a new constant node C2, driven by the merge node through a control
// dependency, initialized to the index of the folded input
// * the fanout of the merge nodes is rewired to be driven by either C1 or
// C2.
for (int input_index = 0; input_index < node->input_size(); ++input_index) {
const auto& input = node->input(input_index);
if (IsControlInput(input)) {
// Try the next input.
continue;
}
NodeDef* input_node = node_map_->GetNode(input);
if (!IsReallyConstant(*input_node)) {
continue;
}
bool valid_input = true;
for (const string& fanin_of_input : input_node->input()) {
if (IsControlInput(fanin_of_input)) {
valid_input = false;
break;
}
}
if (!valid_input) {
// Try the next input
continue;
}
string const_out_name = OptimizedNodeName(*node, "_const");
string const_index_name = OptimizedNodeName(*node, "_index");
if (node_map_->GetNode(const_out_name) ||
node_map_->GetNode(const_index_name)) {
// Intended name already exists.
return errors::AlreadyExists(
strings::StrCat(const_out_name, " or ", const_index_name,
" already present in the graph"));
}
NodeDef* const_out = output_graph->add_node();
*const_out = *input_node;
const_out->set_name(const_out_name);
const_out->set_device(node->device());
*const_out->add_input() = AsControlDependency(*node);
node_map_->AddNode(const_out->name(), const_out);
node_map_->AddOutput(node->name(), const_out->name());
NodeDef* const_index = output_graph->add_node();
const_index->set_op("Const");
Tensor index(DT_INT32, TensorShape({}));
index.flat<int32>()(0) = input_index;
(*const_index->mutable_attr())["dtype"].set_type(DT_INT32);
index.AsProtoTensorContent(
(*const_index->mutable_attr())["value"].mutable_tensor());
const_index->set_name(const_index_name);
const_index->set_device(node->device());
*const_index->add_input() = AsControlDependency(*node);
node_map_->AddNode(const_index->name(), const_index);
node_map_->AddOutput(node->name(), const_index->name());
// We make a copy because we mutate the nodes.
auto outputs = node_map_->GetOutputs(node->name());
for (NodeDef* output : outputs) {
for (int i = 0; i < output->input_size(); i++) {
int port;
string node_name = ParseNodeName(output->input(i), &port);
if (node_name == node->name()) {
if (port == 0) {
*output->mutable_input(i) = const_out->name();
node_map_->AddOutput(const_out->name(), output->name());
} else if (port == 1) {
*output->mutable_input(i) = const_index->name();
node_map_->AddOutput(const_index->name(), output->name());
} else {
// This is a control dependency (or an invalid edge since the
// merge node has only 2 outputs): preserve them.
}
}
}
}
return Status::OK();
}
return Status::OK();
}
| 0
|
301,369
|
static uint64_t vfswrap_get_alloc_size(vfs_handle_struct *handle,
struct files_struct *fsp,
const SMB_STRUCT_STAT *sbuf)
{
uint64_t result;
START_PROFILE(syscall_get_alloc_size);
if(S_ISDIR(sbuf->st_ex_mode)) {
result = 0;
goto out;
}
#if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
/* The type of st_blocksize is blkcnt_t which *MUST* be
signed (according to POSIX) and can be less than 64-bits.
Ensure when we're converting to 64 bits wide we don't
sign extend. */
#if defined(SIZEOF_BLKCNT_T_8)
result = (uint64_t)STAT_ST_BLOCKSIZE * (uint64_t)sbuf->st_ex_blocks;
#elif defined(SIZEOF_BLKCNT_T_4)
{
uint64_t bs = ((uint64_t)sbuf->st_ex_blocks) & 0xFFFFFFFFLL;
result = (uint64_t)STAT_ST_BLOCKSIZE * bs;
}
#else
#error SIZEOF_BLKCNT_T_NOT_A_SUPPORTED_VALUE
#endif
#else
result = get_file_size_stat(sbuf);
#endif
if (fsp && fsp->initial_allocation_size)
result = MAX(result,fsp->initial_allocation_size);
result = smb_roundup(handle->conn, result);
out:
END_PROFILE(syscall_get_alloc_size);
return result;
}
| 0
|
512,722
|
static int cmp_decimal(void *cmp_arg, my_decimal *a, my_decimal *b)
{
/*
We need call of fixing buffer pointer, because fast sort just copy
decimal buffers in memory and pointers left pointing on old buffer place
*/
a->fix_buffer_pointer();
b->fix_buffer_pointer();
return my_decimal_cmp(a, b);
}
| 0
|
390,533
|
XkbWriteGeomOverlay(char *wire,XkbOverlayPtr ol,Bool swap)
{
register int r;
XkbOverlayRowPtr row;
xkbOverlayWireDesc * olWire;
olWire= (xkbOverlayWireDesc *)wire;
olWire->name= ol->name;
olWire->nRows= ol->num_rows;
if (swap) {
register int n;
swapl(&olWire->name,n);
}
wire= (char *)&olWire[1];
for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
unsigned int k;
XkbOverlayKeyPtr key;
xkbOverlayRowWireDesc * rowWire;
rowWire= (xkbOverlayRowWireDesc *)wire;
rowWire->rowUnder= row->row_under;
rowWire->nKeys= row->num_keys;
wire= (char *)&rowWire[1];
for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
xkbOverlayKeyWireDesc * keyWire;
keyWire= (xkbOverlayKeyWireDesc *)wire;
memcpy(keyWire->over,key->over.name,XkbKeyNameLength);
memcpy(keyWire->under,key->under.name,XkbKeyNameLength);
wire= (char *)&keyWire[1];
}
}
return wire;
}
| 0
|
336,588
|
static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
{
spice_debug("starting %s", VERSION);
if (core_interface->base.major_version != SPICE_INTERFACE_CORE_MAJOR) {
spice_warning("bad core interface version");
goto err;
}
reds->core = core_interface_adapter;
reds->core.public_interface = core_interface;
reds->agent_dev = red::make_shared<RedCharDeviceVDIPort>(reds);
reds_update_agent_properties(reds);
reds->main_dispatcher = red::make_shared<MainDispatcher>(reds);
reds->mig_target_clients = NULL;
reds->vm_running = TRUE; /* for backward compatibility */
if (!(reds->mig_timer = reds->core.timer_new(migrate_timeout, reds))) {
spice_error("migration timer create failed");
}
/* Note that this will not actually send the mm_time to the client because
* the main channel is not connected yet. This would have been redundant
* with the RED_PIPE_ITEM_TYPE_MAIN_INIT message anyway.
*/
reds_enable_mm_time(reds);
if (reds_init_net(reds) < 0) {
spice_warning("Failed to open SPICE sockets");
goto err;
}
if (reds->secure_listen_socket != -1) {
if (reds_init_ssl(reds) < 0) {
goto err;
}
}
#if HAVE_SASL
int saslerr;
if ((saslerr = sasl_server_init(NULL, reds->config->sasl_appname ?
reds->config->sasl_appname : "spice")) != SASL_OK) {
spice_error("Failed to initialize SASL auth %s",
sasl_errstring(saslerr, NULL, NULL));
goto err;
}
#endif
reds->main_channel = main_channel_new(reds);
reds->inputs_channel = inputs_channel_new(reds);
reds->mouse_mode = SPICE_MOUSE_MODE_SERVER;
spice_buffer_free(&reds->client_monitors_config);
reds->allow_multiple_clients = getenv(SPICE_DEBUG_ALLOW_MC_ENV) != NULL;
if (reds->allow_multiple_clients) {
spice_warning("spice: allowing multiple client connections");
}
pthread_mutex_lock(&global_reds_lock);
servers = g_list_prepend(servers, reds);
pthread_mutex_unlock(&global_reds_lock);
return 0;
err:
reds_cleanup_net(reds);
return -1;
}
| 0
|
512,930
|
void in_timestamp::value_to_item(uint pos, Item *item)
{
const Timestamp_or_zero_datetime &buff= (((Timestamp_or_zero_datetime*) base)[pos]);
static_cast<Item_timestamp_literal*>(item)->set_value(buff);
}
| 0
|
359,306
|
DEFUN (bgp_redistribute_ipv4_metric,
bgp_redistribute_ipv4_metric_cmd,
"redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
"Redistribute information from another routing protocol\n"
"Connected\n"
"Kernel routes\n"
"Open Shurtest Path First (OSPF)\n"
"Routing Information Protocol (RIP)\n"
"Static routes\n"
"Metric for redistributed routes\n"
"Default metric\n")
{
int type;
u_int32_t metric;
type = bgp_str2route_type (AFI_IP, argv[0]);
if (! type)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
}
VTY_GET_INTEGER ("metric", metric, argv[1]);
bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
return bgp_redistribute_set (vty->index, AFI_IP, type);
}
| 0
|
300,791
|
static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m,
int dlen, long timeout)
{
struct sock *sk = sock->sk;
struct tipc_uaddr *ua = (struct tipc_uaddr *)m->msg_name;
int blks = tsk_blocks(GROUP_H_SIZE + dlen);
struct tipc_sock *tsk = tipc_sk(sk);
struct net *net = sock_net(sk);
struct tipc_member *mb = NULL;
u32 node, port;
int rc;
node = ua->sk.node;
port = ua->sk.ref;
if (!port && !node)
return -EHOSTUNREACH;
/* Block or return if destination link or member is congested */
rc = tipc_wait_for_cond(sock, &timeout,
!tipc_dest_find(&tsk->cong_links, node, 0) &&
tsk->group &&
!tipc_group_cong(tsk->group, node, port, blks,
&mb));
if (unlikely(rc))
return rc;
if (unlikely(!mb))
return -EHOSTUNREACH;
rc = tipc_send_group_msg(net, tsk, m, mb, node, port, dlen);
return rc ? rc : dlen;
}
| 0
|
473,973
|
onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,
UChar* pat, UChar* pat_end, const UChar *fmt, va_list args)
{
size_t need;
int n, len;
UChar *p, *s, *bp;
UChar bs[6];
n = xvsnprintf((char* )buf, bufsize, (const char* )fmt, args);
need = (pat_end - pat) * 4 + 4;
if (n + need < (size_t)bufsize) {
strcat((char* )buf, ": /");
s = buf + onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, buf);
p = pat;
while (p < pat_end) {
if (*p == '\\') {
*s++ = *p++;
len = enclen(enc, p, pat_end);
while (len-- > 0) *s++ = *p++;
}
else if (*p == '/') {
*s++ = (unsigned char )'\\';
*s++ = *p++;
}
else if (ONIGENC_IS_MBC_HEAD(enc, p, pat_end)) {
len = enclen(enc, p, pat_end);
if (ONIGENC_MBC_MINLEN(enc) == 1) {
while (len-- > 0) *s++ = *p++;
}
else { /* for UTF16 */
int blen;
while (len-- > 0) {
sprint_byte_with_x((char* )bs, (unsigned int )(*p++));
blen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
bp = bs;
while (blen-- > 0) *s++ = *bp++;
}
}
}
else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&
!ONIGENC_IS_CODE_SPACE(enc, *p)) {
sprint_byte_with_x((char* )bs, (unsigned int )(*p++));
len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
bp = bs;
while (len-- > 0) *s++ = *bp++;
}
else {
*s++ = *p++;
}
}
*s++ = '/';
*s = '\0';
}
}
| 0
|
353,002
|
serialNumberAndIssuerSerialNormalize(
slap_mask_t usage,
Syntax *syntax,
MatchingRule *mr,
struct berval *in,
struct berval *out,
void *ctx )
{
struct berval i, ni = BER_BVNULL,
sn, sn2 = BER_BVNULL, sn3 = BER_BVNULL,
i_sn, i_sn2 = BER_BVNULL, i_sn3 = BER_BVNULL;
char sbuf2[SLAP_SN_BUFLEN], i_sbuf2[SLAP_SN_BUFLEN],
sbuf3[SLAP_SN_BUFLEN], i_sbuf3[SLAP_SN_BUFLEN];
char *p;
int rc;
assert( in != NULL );
assert( out != NULL );
Debug( LDAP_DEBUG_TRACE, ">>> serialNumberAndIssuerSerialNormalize: <%s>\n",
in->bv_val );
rc = serialNumberAndIssuerSerialCheck( in, &sn, &i, &i_sn, ctx );
if ( rc ) {
goto func_leave;
}
rc = dnNormalize( usage, syntax, mr, &i, &ni, ctx );
if ( in->bv_val[0] == '{' && in->bv_val[in->bv_len-1] == '}' ) {
slap_sl_free( i.bv_val, ctx );
}
if ( rc ) {
rc = LDAP_INVALID_SYNTAX;
goto func_leave;
}
/* Convert sn to canonical hex */
sn2.bv_val = sbuf2;
sn2.bv_len = sn.bv_len;
if ( sn.bv_len > sizeof( sbuf2 ) ) {
sn2.bv_val = slap_sl_malloc( sn.bv_len, ctx );
}
if ( lutil_str2bin( &sn, &sn2, ctx ) ) {
rc = LDAP_INVALID_SYNTAX;
goto func_leave;
}
/* Convert i_sn to canonical hex */
i_sn2.bv_val = i_sbuf2;
i_sn2.bv_len = i_sn.bv_len;
if ( i_sn.bv_len > sizeof( i_sbuf2 ) ) {
i_sn2.bv_val = slap_sl_malloc( i_sn.bv_len, ctx );
}
if ( lutil_str2bin( &i_sn, &i_sn2, ctx ) ) {
rc = LDAP_INVALID_SYNTAX;
goto func_leave;
}
sn3.bv_val = sbuf3;
sn3.bv_len = sizeof(sbuf3);
if ( slap_bin2hex( &sn2, &sn3, ctx ) ) {
rc = LDAP_INVALID_SYNTAX;
goto func_leave;
}
i_sn3.bv_val = i_sbuf3;
i_sn3.bv_len = sizeof(i_sbuf3);
if ( slap_bin2hex( &i_sn2, &i_sn3, ctx ) ) {
rc = LDAP_INVALID_SYNTAX;
goto func_leave;
}
out->bv_len = STRLENOF("{ serialNumber , issuer { baseCertificateID { issuer { directoryName:rdnSequence:\"\" }, serial } } }")
+ sn3.bv_len + ni.bv_len + i_sn3.bv_len;
out->bv_val = slap_sl_malloc( out->bv_len + 1, ctx );
if ( out->bv_val == NULL ) {
out->bv_len = 0;
rc = LDAP_OTHER;
goto func_leave;
}
p = out->bv_val;
p = lutil_strcopy( p, "{ serialNumber " );
p = lutil_strbvcopy( p, &sn3 );
p = lutil_strcopy( p, ", issuer { baseCertificateID { issuer { directoryName:rdnSequence:\"" );
p = lutil_strbvcopy( p, &ni );
p = lutil_strcopy( p, "\" }, serial " );
p = lutil_strbvcopy( p, &i_sn3 );
p = lutil_strcopy( p, " } } }" );
assert( p == &out->bv_val[out->bv_len] );
func_leave:
Debug( LDAP_DEBUG_TRACE, "<<< serialNumberAndIssuerSerialNormalize: <%s> => <%s>\n",
in->bv_val, rc == LDAP_SUCCESS ? out->bv_val : "(err)" );
if ( sn2.bv_val != sbuf2 ) {
slap_sl_free( sn2.bv_val, ctx );
}
if ( i_sn2.bv_val != i_sbuf2 ) {
slap_sl_free( i_sn2.bv_val, ctx );
}
if ( sn3.bv_val != sbuf3 ) {
slap_sl_free( sn3.bv_val, ctx );
}
if ( i_sn3.bv_val != i_sbuf3 ) {
slap_sl_free( i_sn3.bv_val, ctx );
}
slap_sl_free( ni.bv_val, ctx );
return rc;
}
| 0
|
489,154
|
sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,
const struct sctp_association *asoc,
const sctp_subtype_t type,
void *arg,
sctp_cmd_seq_t *commands)
{
struct sctp_chunk *chunk = arg;
if (!sctp_vtag_verify_either(chunk, asoc))
return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
/* Make sure that the ABORT chunk has a valid length.
* Since this is an ABORT chunk, we have to discard it
* because of the following text:
* RFC 2960, Section 3.3.7
* If an endpoint receives an ABORT with a format error or for an
* association that doesn't exist, it MUST silently discard it.
* Becasue the length is "invalid", we can't really discard just
* as we do not know its true length. So, to be safe, discard the
* packet.
*/
if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t)))
return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
/* ADD-IP: Special case for ABORT chunks
* F4) One special consideration is that ABORT Chunks arriving
* destined to the IP address being deleted MUST be
* ignored (see Section 5.3.1 for further details).
*/
if (SCTP_ADDR_DEL ==
sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
return sctp_sf_discard_chunk(ep, asoc, type, arg, commands);
return __sctp_sf_do_9_1_abort(ep, asoc, type, arg, commands);
}
| 0
|
437,363
|
setup_call(Node* node, ScanEnv* env, int state)
{
int r;
switch (NODE_TYPE(node)) {
case NODE_LIST:
case NODE_ALT:
do {
r = setup_call(NODE_CAR(node), env, state);
} while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));
break;
case NODE_QUANT:
if (QUANT_(node)->upper == 0)
state |= IN_ZERO_REPEAT;
r = setup_call(NODE_BODY(node), env, state);
break;
case NODE_ANCHOR:
if (ANCHOR_HAS_BODY(ANCHOR_(node)))
r = setup_call(NODE_BODY(node), env, state);
else
r = 0;
break;
case NODE_ENCLOSURE:
{
EnclosureNode* en = ENCLOSURE_(node);
if (en->type == ENCLOSURE_MEMORY) {
if ((state & IN_ZERO_REPEAT) != 0) {
NODE_STATUS_ADD(node, IN_ZERO_REPEAT);
ENCLOSURE_(node)->m.entry_count--;
}
r = setup_call(NODE_BODY(node), env, state);
}
else if (en->type == ENCLOSURE_IF_ELSE) {
r = setup_call(NODE_BODY(node), env, state);
if (r != 0) return r;
if (IS_NOT_NULL(en->te.Then)) {
r = setup_call(en->te.Then, env, state);
if (r != 0) return r;
}
if (IS_NOT_NULL(en->te.Else))
r = setup_call(en->te.Else, env, state);
}
else
r = setup_call(NODE_BODY(node), env, state);
}
break;
case NODE_CALL:
if ((state & IN_ZERO_REPEAT) != 0) {
NODE_STATUS_ADD(node, IN_ZERO_REPEAT);
CALL_(node)->entry_count--;
}
r = setup_call_node_call(CALL_(node), env, state);
break;
default:
r = 0;
break;
}
return r;
}
| 0
|
238,608
|
static void __mark_reg32_known(struct bpf_reg_state *reg, u64 imm)
{
reg->var_off = tnum_const_subreg(reg->var_off, imm);
reg->s32_min_value = (s32)imm;
reg->s32_max_value = (s32)imm;
reg->u32_min_value = (u32)imm;
reg->u32_max_value = (u32)imm;
}
| 0
|
462,301
|
status_symbol_sets(stream * s, pcl_state_t * pcs, pcl_data_storage_t storage)
{
gs_const_string key;
void *value;
pl_dict_enum_t denum;
ushort *idlist;
int nid;
if (storage == 0)
return 0; /* no "currently selected" symbol set */
/* Note carefully the meaning of this status inquiry. First,
* we return only symbol sets applicable to unbound fonts. Second,
* the "storage" value refers to the location of fonts. */
/* total up built-in symbol sets, downloaded ones */
nid = pl_dict_length(&pcs->soft_symbol_sets, false) +
pl_dict_length(&pcs->built_in_symbol_sets, false);
idlist = (ushort *) gs_alloc_bytes(pcs->memory, nid * sizeof(ushort),
"status_symbol_sets(idlist)");
if (idlist == NULL)
return e_Memory;
nid = 0;
/* For each symbol set,
* for each font in appropriate storage,
* if the font supports that symbol set, list the symbol set
* and break (because we only need to find one such font). */
/* NOTE: Temporarily chain soft, built-in symbol sets. DON'T
* exit this section without unchaining them. */
pl_dict_set_parent(&pcs->soft_symbol_sets, &pcs->built_in_symbol_sets);
pl_dict_enum_begin(&pcs->soft_symbol_sets, &denum);
while (pl_dict_enum_next(&denum, &key, &value)) {
pcl_symbol_set_t *ssp = (pcl_symbol_set_t *) value;
pl_glyph_vocabulary_t gx;
for (gx = plgv_MSL; gx < plgv_next; gx++)
if (ssp->maps[gx] != NULL &&
status_check_symbol_set(pcs, ssp->maps[gx], storage)) {
nid = status_add_symbol_id(idlist, nid,
(ssp->maps[gx]->id[0] << 8) +
ssp->maps[gx]->id[1]);
break; /* one will suffice */
}
}
pl_dict_set_parent(&pcs->soft_symbol_sets, NULL);
/* Symbol sets are back to normal. */
status_print_idlist(s, idlist, nid, "IDLIST");
gs_free_object(pcs->memory, (void *)idlist, "status_symbol_sets(idlist)");
return 0;
}
| 0
|
231,045
|
BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,
void * const pvBuffer )
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
int8_t * pcOriginalReadPosition;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
configASSERT( pxQueue->uxItemSize != 0 ); /* Can't peek a semaphore. */
/* RTOS ports that support interrupt nesting have the concept of a maximum
* system call (or maximum API call) interrupt priority. Interrupts that are
* above the maximum system call priority are kept permanently enabled, even
* when the RTOS kernel is in a critical section, but cannot make any calls to
* FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h
* then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion
* failure if a FreeRTOS API function is called from an interrupt that has been
* assigned a priority above the configured maximum system call priority.
* Only FreeRTOS functions that end in FromISR can be called from interrupts
* that have been assigned a priority at or (logically) below the maximum
* system call interrupt priority. FreeRTOS maintains a separate interrupt
* safe API to ensure interrupt entry is as fast and as simple as possible.
* More information (albeit Cortex-M specific) is provided on the following
* link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
{
/* Cannot block in an ISR, so check there is data available. */
if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
{
traceQUEUE_PEEK_FROM_ISR( pxQueue );
/* Remember the read position so it can be reset as nothing is
* actually being removed from the queue. */
pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom;
prvCopyDataFromQueue( pxQueue, pvBuffer );
pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition;
xReturn = pdPASS;
}
else
{
xReturn = pdFAIL;
traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue );
}
}
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
return xReturn;
}
| 0
|
265,047
|
set_colour_code(char *str, char **var)
{
char *keyseq;
int len;
zsfree(*var);
keyseq = getkeystring(str, &len, GETKEYS_BINDKEY, NULL);
*var = metafy(keyseq, len, META_DUP);
}
| 0
|
294,559
|
jd_utc_to_local(int jd, int df, int of)
{
df += of;
if (df < 0)
jd -= 1;
else if (df >= DAY_IN_SECONDS)
jd += 1;
return jd;
}
| 0
|
162,322
|
bool decode(ArgumentDecoder* decoder, RetainPtr<CFURLRef>& result)
{
RetainPtr<CFURLRef> baseURL;
bool hasBaseURL;
if (!decoder->decodeBool(hasBaseURL))
return false;
if (hasBaseURL) {
if (!decode(decoder, baseURL))
return false;
}
RetainPtr<CFStringRef> string;
if (!decode(decoder, string))
return false;
#if PLATFORM(MAC)
// FIXME: Move this to ArgumentCodersCFMac.mm and change this file back to be C++
// instead of Objective-C++.
if (!CFStringGetLength(string.get())) {
// CFURL can't hold an empty URL, unlike NSURL.
result = reinterpret_cast<CFURLRef>([NSURL URLWithString:@""]);
return true;
}
#endif
CFURLRef url = CFURLCreateWithString(0, string.get(), baseURL.get());
if (!url)
return false;
result.adoptCF(url);
return true;
}
| 0
|
517,433
|
static char *get_service_status(Output_Type type, Service_T s, char *buf, int buflen) {
ASSERT(s);
ASSERT(buf);
if (s->monitor == Monitor_Not || s->monitor & Monitor_Init) {
get_monitoring_status(type, s, buf, buflen);
} else if (s->error == 0) {
snprintf(buf, buflen, type == HTML ? "<span class='green-text'>OK</span>" : Color_lightGreen("OK"));
} else {
// In the case that the service has actualy some failure, the error bitmap will be non zero
char *p = buf;
EventTable_T *et = Event_Table;
while ((*et).id) {
if (s->error & (*et).id) {
if (p > buf)
p += snprintf(p, buflen - (p - buf), " | ");
if (s->error_hint & (*et).id) {
if (type == HTML)
p += snprintf(p, buflen - (p - buf), "<span class='orange-text'>%s</span>", (*et).description_changed);
else
p += snprintf(p, buflen - (p - buf), Color_lightYellow("%s", (*et).description_changed));
} else {
if (type == HTML)
p += snprintf(p, buflen - (p - buf), "<span class='red-text'>%s</span>", (*et).description_failed);
else
p += snprintf(p, buflen - (p - buf), Color_lightRed("%s", (*et).description_failed));
}
}
et++;
}
}
if (s->doaction)
snprintf(buf + strlen(buf), buflen - strlen(buf) - 1, " - %s pending", actionnames[s->doaction]);
return buf;
}
| 0
|
513,197
|
plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, int type)
{
LEX *lex= thd ? thd->lex : 0;
plugin_ref rc= NULL;
st_plugin_int *plugin;
DBUG_ENTER("plugin_lock_by_name");
mysql_mutex_lock(&LOCK_plugin);
if ((plugin= plugin_find_internal(name, type)))
rc= intern_plugin_lock(lex, plugin_int_to_ref(plugin));
mysql_mutex_unlock(&LOCK_plugin);
DBUG_RETURN(rc);
}
| 0
|
259,288
|
static int64_t get_frag_time(AVFormatContext *s, AVStream *dst_st,
MOVFragmentIndex *frag_index, int index)
{
MOVFragmentStreamInfo * frag_stream_info;
MOVStreamContext *sc = dst_st->priv_data;
int64_t timestamp;
int i, j;
// If the stream is referenced by any sidx, limit the search
// to fragments that referenced this stream in the sidx
if (sc->has_sidx) {
frag_stream_info = get_frag_stream_info(frag_index, index, dst_st->id);
if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE)
return frag_stream_info->sidx_pts;
if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE)
return frag_stream_info->first_tfra_pts;
return frag_stream_info->sidx_pts;
}
for (i = 0; i < frag_index->item[index].nb_stream_info; i++) {
AVStream *frag_stream = NULL;
frag_stream_info = &frag_index->item[index].stream_info[i];
for (j = 0; j < s->nb_streams; j++)
if (s->streams[j]->id == frag_stream_info->id)
frag_stream = s->streams[j];
if (!frag_stream) {
av_log(s, AV_LOG_WARNING, "No stream matching sidx ID found.\n");
continue;
}
timestamp = get_stream_info_time(frag_stream_info);
if (timestamp != AV_NOPTS_VALUE)
return av_rescale_q(timestamp, frag_stream->time_base, dst_st->time_base);
}
return AV_NOPTS_VALUE;
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.