idx
int64 | func
string | target
int64 |
|---|---|---|
331,761
|
QPaintEngineEx::QPaintEngineEx(QPaintEngineExPrivate &data)
: QPaintEngine(data, AllFeatures)
{
extended = true;
}
| 0
|
364,781
|
do_tags(exarg_T *eap UNUSED)
{
int i;
char_u *name;
taggy_T *tagstack = curwin->w_tagstack;
int tagstackidx = curwin->w_tagstackidx;
int tagstacklen = curwin->w_tagstacklen;
// Highlight title
msg_puts_title(_("\n # TO tag FROM line in file/text"));
for (i = 0; i < tagstacklen; ++i)
{
if (tagstack[i].tagname != NULL)
{
name = fm_getname(&(tagstack[i].fmark), 30);
if (name == NULL) // file name not available
continue;
msg_putchar('\n');
vim_snprintf((char *)IObuff, IOSIZE, "%c%2d %2d %-15s %5ld ",
i == tagstackidx ? '>' : ' ',
i + 1,
tagstack[i].cur_match + 1,
tagstack[i].tagname,
tagstack[i].fmark.mark.lnum);
msg_outtrans(IObuff);
msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum
? HL_ATTR(HLF_D) : 0);
vim_free(name);
}
out_flush(); // show one line at a time
}
if (tagstackidx == tagstacklen) // idx at top of stack
msg_puts("\n>");
}
| 0
|
328,919
|
R_API ut64 r_bin_java_annotation_calc_size(RBinJavaAnnotation *annotation) {
ut64 sz = 0;
RListIter *iter, *iter_tmp;
RBinJavaElementValuePair *evps = NULL;
if (!annotation) {
// TODO eprintf allocation fail
return sz;
}
// annotation->type_idx = R_BIN_JAVA_USHORT (buffer, offset);
sz += 2;
// annotation->num_element_value_pairs = R_BIN_JAVA_USHORT (buffer, offset);
sz += 2;
r_list_foreach_safe (annotation->element_value_pairs, iter, iter_tmp, evps) {
if (evps) {
sz += r_bin_java_element_pair_calc_size (evps);
}
}
return sz;
}
| 0
|
238,568
|
static int is_branch64_taken(struct bpf_reg_state *reg, u64 val, u8 opcode)
{
s64 sval = (s64)val;
switch (opcode) {
case BPF_JEQ:
if (tnum_is_const(reg->var_off))
return !!tnum_equals_const(reg->var_off, val);
break;
case BPF_JNE:
if (tnum_is_const(reg->var_off))
return !tnum_equals_const(reg->var_off, val);
break;
case BPF_JSET:
if ((~reg->var_off.mask & reg->var_off.value) & val)
return 1;
if (!((reg->var_off.mask | reg->var_off.value) & val))
return 0;
break;
case BPF_JGT:
if (reg->umin_value > val)
return 1;
else if (reg->umax_value <= val)
return 0;
break;
case BPF_JSGT:
if (reg->smin_value > sval)
return 1;
else if (reg->smax_value <= sval)
return 0;
break;
case BPF_JLT:
if (reg->umax_value < val)
return 1;
else if (reg->umin_value >= val)
return 0;
break;
case BPF_JSLT:
if (reg->smax_value < sval)
return 1;
else if (reg->smin_value >= sval)
return 0;
break;
case BPF_JGE:
if (reg->umin_value >= val)
return 1;
else if (reg->umax_value < val)
return 0;
break;
case BPF_JSGE:
if (reg->smin_value >= sval)
return 1;
else if (reg->smax_value < sval)
return 0;
break;
case BPF_JLE:
if (reg->umax_value <= val)
return 1;
else if (reg->umin_value > val)
return 0;
break;
case BPF_JSLE:
if (reg->smax_value <= sval)
return 1;
else if (reg->smin_value > sval)
return 0;
break;
}
return -1;
}
| 0
|
261,419
|
int read_transform_unit(thread_context* tctx,
int x0, int y0, // position of TU in frame
int xBase, int yBase, // position of parent TU in frame
int xCUBase,int yCUBase, // position of CU in frame
int log2TrafoSize,
int trafoDepth,
int blkIdx,
int cbf_luma, int cbf_cb, int cbf_cr)
{
logtrace(LogSlice,"- read_transform_unit x0:%d y0:%d xBase:%d yBase:%d nT:%d cbf:%d:%d:%d\n",
x0,y0,xBase,yBase, 1<<log2TrafoSize, cbf_luma, cbf_cb, cbf_cr);
assert(cbf_cb != -1);
assert(cbf_cr != -1);
assert(cbf_luma != -1);
const seq_parameter_set& sps = tctx->img->get_sps();
const int ChromaArrayType = sps.ChromaArrayType;
int log2TrafoSizeC = (ChromaArrayType==CHROMA_444 ? log2TrafoSize : log2TrafoSize-1);
log2TrafoSizeC = libde265_max(2, log2TrafoSizeC);
const int cbfLuma = cbf_luma;
const int cbfChroma = cbf_cb | cbf_cr;
tctx->transform_skip_flag[0]=0;
tctx->transform_skip_flag[1]=0;
tctx->transform_skip_flag[2]=0;
tctx->explicit_rdpcm_flag = false;
enum PredMode cuPredMode = tctx->img->get_pred_mode(x0,y0);
if (cbfLuma || cbfChroma)
{
bool doDecodeQuantParameters = false;
if (tctx->img->get_pps().cu_qp_delta_enabled_flag &&
!tctx->IsCuQpDeltaCoded) {
int cu_qp_delta_abs = decode_cu_qp_delta_abs(tctx);
int cu_qp_delta_sign=0;
if (cu_qp_delta_abs) {
cu_qp_delta_sign = decode_CABAC_bypass(&tctx->cabac_decoder);
}
tctx->IsCuQpDeltaCoded = 1;
tctx->CuQpDelta = cu_qp_delta_abs*(1-2*cu_qp_delta_sign);
//printf("read cu_qp_delta (%d;%d) = %d\n",x0,y0,tctx->CuQpDelta);
logtrace(LogSlice,"cu_qp_delta_abs = %d\n",cu_qp_delta_abs);
logtrace(LogSlice,"cu_qp_delta_sign = %d\n",cu_qp_delta_sign);
logtrace(LogSlice,"CuQpDelta = %d\n",tctx->CuQpDelta);
doDecodeQuantParameters = true;
//decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);
}
if (tctx->shdr->cu_chroma_qp_offset_enabled_flag && cbfChroma &&
!tctx->cu_transquant_bypass_flag && !tctx->IsCuChromaQpOffsetCoded ) {
logtrace(LogSlice,"# cu_chroma_qp_offset_flag\n");
int cu_chroma_qp_offset_flag = decode_CABAC_bit(&tctx->cabac_decoder,
&tctx->ctx_model[CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_FLAG]);
const pic_parameter_set& pps = tctx->img->get_pps();
int cu_chroma_qp_offset_idx = 0;
if (cu_chroma_qp_offset_flag && pps.range_extension.chroma_qp_offset_list_len > 1) {
cu_chroma_qp_offset_idx = decode_CABAC_bit(&tctx->cabac_decoder,
&tctx->ctx_model[CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_IDX]);
}
tctx->IsCuChromaQpOffsetCoded = 1;
if (cu_chroma_qp_offset_flag) {
tctx->CuQpOffsetCb = pps.range_extension.cb_qp_offset_list[ cu_chroma_qp_offset_idx ];
tctx->CuQpOffsetCr = pps.range_extension.cr_qp_offset_list[ cu_chroma_qp_offset_idx ];
}
else {
tctx->CuQpOffsetCb = 0;
tctx->CuQpOffsetCr = 0;
}
doDecodeQuantParameters = true;
//decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);
}
if (doDecodeQuantParameters) {
decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);
}
}
// position of TU in local CU
int xL = x0 - xCUBase;
int yL = y0 - yCUBase;
int nT = 1<<log2TrafoSize;
int nTC = 1<<log2TrafoSizeC;
const int SubWidthC = sps.SubWidthC;
const int SubHeightC = sps.SubHeightC;
// --- luma ---
tctx->ResScaleVal = 0;
int err;
if (cbf_luma) {
if ((err=residual_coding(tctx,x0,y0, log2TrafoSize,0)) != DE265_OK) return err;
}
decode_TU(tctx, x0,y0, xCUBase,yCUBase, nT, 0, cuPredMode, cbf_luma);
// --- chroma ---
const int yOffset422 = 1<<log2TrafoSizeC;
if (log2TrafoSize>2 || ChromaArrayType == CHROMA_444) {
// TODO: cross-component prediction
const bool do_cross_component_prediction =
(tctx->img->get_pps().range_extension.cross_component_prediction_enabled_flag &&
cbf_luma &&
(cuPredMode == MODE_INTER || tctx->img->is_IntraPredModeC_Mode4(x0,y0)));
if (do_cross_component_prediction) {
read_cross_comp_pred(tctx, 0);
}
else {
tctx->ResScaleVal = 0;
}
{
if (cbf_cb & 1) {
if ((err=residual_coding(tctx,x0,y0,log2TrafoSizeC,1)) != DE265_OK) return err;
}
if (sps.ChromaArrayType != CHROMA_MONO) {
decode_TU(tctx,
x0/SubWidthC,y0/SubHeightC,
xCUBase/SubWidthC,yCUBase/SubHeightC, nTC, 1, cuPredMode, cbf_cb & 1);
}
}
// 4:2:2
if (ChromaArrayType == CHROMA_422) {
const int yOffset = 1<<log2TrafoSizeC;
if (cbf_cb & 2) {
if ((err=residual_coding(tctx,
x0,y0+yOffset*SubHeightC,
log2TrafoSizeC,1)) != DE265_OK) return err;
}
decode_TU(tctx,
x0/SubWidthC,y0/SubHeightC + yOffset,
xCUBase/SubWidthC,yCUBase/SubHeightC +yOffset,
nTC, 1, cuPredMode, cbf_cb & 2);
}
if (do_cross_component_prediction) {
read_cross_comp_pred(tctx, 1);
}
else {
tctx->ResScaleVal = 0;
}
{
if (cbf_cr & 1) {
if ((err=residual_coding(tctx,x0,y0,log2TrafoSizeC,2)) != DE265_OK) return err;
}
if (sps.ChromaArrayType != CHROMA_MONO) {
decode_TU(tctx,
x0/SubWidthC,y0/SubHeightC,
xCUBase/SubWidthC,yCUBase/SubHeightC,
nTC, 2, cuPredMode, cbf_cr & 1);
}
}
// 4:2:2
if (ChromaArrayType == CHROMA_422) {
const int yOffset = 1<<log2TrafoSizeC;
if (cbf_cr & 2) {
if ((err=residual_coding(tctx,
x0,y0+yOffset*SubHeightC,
log2TrafoSizeC,2)) != DE265_OK) return err;
}
decode_TU(tctx,
x0/SubWidthC,y0/SubHeightC+yOffset,
xCUBase/SubWidthC,yCUBase/SubHeightC+yOffset,
nTC, 2, cuPredMode, cbf_cr & 2);
}
}
else if (blkIdx==3) {
if (cbf_cb & 1) {
if ((err=residual_coding(tctx,xBase,yBase,
log2TrafoSize,1)) != DE265_OK) return err;
}
if (sps.ChromaArrayType != CHROMA_MONO) {
decode_TU(tctx,
xBase/SubWidthC, yBase/SubHeightC,
xCUBase/SubWidthC,yCUBase/SubHeightC, nT, 1, cuPredMode, cbf_cb & 1);
}
// 4:2:2
if (cbf_cb & 2) {
if ((err=residual_coding(tctx,
xBase ,yBase +(1<<log2TrafoSize),
log2TrafoSize,1)) != DE265_OK) return err;
}
if (ChromaArrayType == CHROMA_422) {
decode_TU(tctx,
xBase/SubWidthC, yBase/SubHeightC + (1<<log2TrafoSize),
xCUBase/SubWidthC,yCUBase/SubHeightC, nT, 1, cuPredMode, cbf_cb & 2);
}
if (cbf_cr & 1) {
if ((err=residual_coding(tctx,xBase,yBase,
log2TrafoSize,2)) != DE265_OK) return err;
}
if (sps.ChromaArrayType != CHROMA_MONO) {
decode_TU(tctx,
xBase/SubWidthC, yBase/SubHeightC,
xCUBase/SubWidthC,yCUBase/SubHeightC, nT, 2, cuPredMode, cbf_cr & 1);
}
// 4:2:2
if (cbf_cr & 2) {
if ((err=residual_coding(tctx,
xBase ,yBase +(1<<log2TrafoSizeC),
log2TrafoSize,2)) != DE265_OK) return err;
}
if (ChromaArrayType == CHROMA_422) {
decode_TU(tctx,
xBase/SubWidthC, yBase/SubHeightC + (1<<log2TrafoSize),
xCUBase/SubWidthC,yCUBase/SubHeightC, nT, 2, cuPredMode, cbf_cr & 2);
}
}
return DE265_OK;
}
| 0
|
246,670
|
static Bool create_new_track_action(char *arg_val, u32 act_type, u32 dump_type)
{
TrackAction *tka;
char *param = arg_val;
tracks = (TrackAction *)gf_realloc(tracks, sizeof(TrackAction) * (nb_track_act+1));
if (!tracks) return GF_FALSE;
tka = & tracks[nb_track_act];
nb_track_act++;
memset(tka, 0, sizeof(TrackAction) );
tka->act_type = act_type;
tka->dump_type = dump_type;
if (act_type != TRAC_ACTION_RAW_EXTRACT) {
open_edit = GF_TRUE;
do_save = GF_TRUE;
}
if ((act_type==TRAC_ACTION_SET_ID) || (act_type==TRAC_ACTION_SWAP_ID)) {
if (sscanf(param, "%d:%u", &tka->trackID, &tka->newTrackID) != 2) {
M4_LOG(GF_LOG_ERROR, ("Bad format for -set-track-id - expecting \"id1:id2\" got \"%s\"\n", param));
return GF_FALSE;
}
return GF_TRUE;
}
if (act_type==TRAC_ACTION_SET_PAR) {
char *ext;
ext = strchr(param, '=');
if (!ext) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track par - expecting tkID=none or tkID=PAR_NUM:PAR_DEN got %s\n", param));
return GF_FALSE;
}
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
if (!stricmp(ext+1, "none"))
tka->par_num = tka->par_den = 0;
else if (!stricmp(ext+1, "auto")) {
tka->par_num = tka->par_den = -1;
tka->force_par = 1;
}
else if (!stricmp(ext+1, "force")) {
tka->par_num = tka->par_den = 1;
tka->force_par = 1;
}
else {
if (ext[1]=='w') {
tka->rewrite_bs = 1;
ext++;
}
if (sscanf(ext+1, "%d:%d", &tka->par_num, &tka->par_den) != 2) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track par - expecting tkID=PAR_NUM:PAR_DEN got %s\n", param));
return GF_FALSE;
}
}
return GF_TRUE;
}
if (act_type==TRAC_ACTION_SET_CLAP) {
char *ext = strchr(param, '=');
if (!ext) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track clap - expecting tkID=none or tkID=Wn,Wd,Hn,Hd,HOn,HOd,VOn,VOd got %s\n", param));
return GF_FALSE;
}
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
if (stricmp(ext + 1, "none")) {
if (sscanf(ext + 1, "%d,%d,%d,%d,%d,%d,%d,%d", &tka->clap_wnum, &tka->clap_wden, &tka->clap_hnum, &tka->clap_hden, &tka->clap_honum, &tka->clap_hoden, &tka->clap_vonum, &tka->clap_voden) != 8) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track clap - expecting tkID=none or tkID=Wn,Wd,Hn,Hd,HOn,HOd,VOn,VOd got %s\n", param));
return GF_FALSE;
}
}
return GF_TRUE;
}
if (act_type==TRAC_ACTION_SET_MX) {
char *ext = strchr(param, '=');
if (!ext) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track matrix - expecting ID=none or ID=M1:M2:M3:M4:M5:M6:M7:M8:M9 got %s\n", param));
return GF_FALSE;
}
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
if (!stricmp(ext + 1, "none")) {
memset(tka->mx, 0, sizeof(s32)*9);
tka->mx[0] = tka->mx[4] = tka->mx[8] = 1;
} else {
s32 res;
if (strstr(ext+1, "0x")) {
res = sscanf(ext + 1, "0x%d:0x%d:0x%d:0x%d:0x%d:0x%d:0x%d:0x%d:0x%d", &tka->mx[0], &tka->mx[1], &tka->mx[2], &tka->mx[3], &tka->mx[4], &tka->mx[5], &tka->mx[6], &tka->mx[7], &tka->mx[8]);
} else {
res = sscanf(ext + 1, "%d:%d:%d:%d:%d:%d:%d:%d:%d", &tka->mx[0], &tka->mx[1], &tka->mx[2], &tka->mx[3], &tka->mx[4], &tka->mx[5], &tka->mx[6], &tka->mx[7], &tka->mx[8]);
}
if (res != 9) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track matrix - expecting ID=none or ID=M1:M2:M3:M4:M5:M6:M7:M8:M9 got %s\n", param));
return GF_FALSE;
}
}
return GF_TRUE;
}
if (act_type==TRAC_ACTION_SET_EDITS) {
char *ext = strchr(param, '=');
if (!ext) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track edits - expecting ID=EDITS got %s\n", param));
return GF_FALSE;
}
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
tka->string = gf_strdup(ext+1);
return GF_TRUE;
}
if (act_type==TRAC_ACTION_SET_LANGUAGE) {
char *ext = strchr(param, '=');
if (!strnicmp(param, "all=", 4)) {
strncpy(tka->lang, param + 4, 10-1);
}
else if (!ext) {
strncpy(tka->lang, param, 10-1);
} else {
strncpy(tka->lang, ext + 1, 10-1);
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
}
return GF_TRUE;
}
if ((act_type==TRAC_ACTION_SET_KIND) || (act_type==TRAC_ACTION_REM_KIND)) {
char *ext;
char *scheme_start = NULL;
//extract trackID
if (!strnicmp(param, "all=", 4)) {
scheme_start = param + 4;
} else {
ext = strchr(param, '=');
if (ext) {
ext[0] = 0;
if (sscanf(param, "%d", &tka->trackID) == 1) {
scheme_start = ext + 1;
} else {
scheme_start = param;
}
ext[0] = '=';
} else {
scheme_start = param;
}
}
//extract scheme and value - if not, remove kind
if (!scheme_start || !scheme_start[0]) {
M4_LOG(GF_LOG_ERROR, ("Missing kind scheme - expecting ID=schemeURI=value got %s\n", param));
return GF_FALSE;
} else {
ext = strchr(scheme_start, '=');
if (!ext) {
tka->kind_scheme = gf_strdup(scheme_start);
} else {
ext[0] = 0;
tka->kind_scheme = gf_strdup(scheme_start);
ext[0] = '=';
tka->kind_value = gf_strdup(ext + 1);
}
}
return GF_TRUE;
}
if (act_type==TRAC_ACTION_SET_DELAY) {
char *ext = strchr(param, '=');
if (!ext) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track delay - expecting tkID=DLAY got %s\n", param));
return GF_FALSE;
}
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
if (sscanf(ext+1, "%d/%u", &tka->delay.num, &tka->delay.den) != 2) {
tka->delay.num = atoi(ext + 1);
tka->delay.den = 1000;
}
return GF_TRUE;
}
if (act_type==TRAC_ACTION_REFERENCE) {
char *ext = strchr(param, '=');
if (!ext) ext = strchr(param, ':');
if (!ext) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track reference - expecting tkID:XXXX:refID got %s\n", param));
return GF_FALSE;
}
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
char *ext2 = strchr(ext, ':');
if (!ext2) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track reference - expecting tkID:XXXX:refID got %s\n", param));
return GF_FALSE;
}
ext2[0] = 0;
strncpy(tka->lang, ext+1, 9);
ext2[0] = ':';
tka->newTrackID = (s32) atoi(ext2 + 1);
return GF_TRUE;
}
if (act_type==TRAC_ACTION_SET_HANDLER_NAME) {
char *ext = strchr(param, '=');
if (!ext) {
M4_LOG(GF_LOG_ERROR, ("Bad format for track name - expecting tkID=name got %s\n", param));
return GF_FALSE;
}
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
tka->hdl_name = ext + 1;
return GF_TRUE;
}
if (act_type==TRAC_ACTION_SET_KMS_URI) {
char *ext = strchr(param, '=');
if (!strnicmp(param, "all=", 4)) {
tka->kms = param + 4;
} else if (!ext) {
tka->kms = param;
} else {
tka->kms = ext + 1;
ext[0] = 0;
tka->trackID = atoi(param);
ext[0] = '=';
}
return GF_TRUE;
}
if ((act_type==TRAC_ACTION_SET_TIME) || (act_type==TRAC_ACTION_SET_MEDIA_TIME)) {
struct tm time;
char *ext = strchr(arg_val, '=');
if (ext) {
ext[0] = 0;
tka->trackID = atoi(arg_val);
ext[0] = '=';
arg_val = ext+1;
}
memset(&time, 0, sizeof(struct tm));
sscanf(arg_val, "%d/%d/%d-%d:%d:%d", &time.tm_mday, &time.tm_mon, &time.tm_year, &time.tm_hour, &time.tm_min, &time.tm_sec);
time.tm_isdst = 0;
time.tm_year -= 1900;
time.tm_mon -= 1;
tka->time = 2082758400;
tka->time += mktime(&time);
return GF_TRUE;
}
while (param) {
param = gf_url_colon_suffix(param);
if (param) {
*param = 0;
param++;
#ifndef GPAC_DISABLE_MEDIA_EXPORT
if (!strncmp("vttnomerge", param, 10)) {
tka->dump_type |= GF_EXPORT_WEBVTT_NOMERGE;
} else if (!strncmp("layer", param, 5)) {
tka->dump_type |= GF_EXPORT_SVC_LAYER;
} else if (!strncmp("full", param, 4)) {
tka->dump_type |= GF_EXPORT_NHML_FULL;
} else if (!strncmp("embedded", param, 8)) {
tka->dump_type |= GF_EXPORT_WEBVTT_META_EMBEDDED;
} else if (!strncmp("output=", param, 7)) {
tka->out_name = gf_strdup(param+7);
} else if (!strncmp("src=", param, 4)) {
tka->src_name = gf_strdup(param+4);
} else if (!strncmp("str=", param, 4)) {
tka->string = gf_strdup(param+4);
} else if (!strncmp("box=", param, 4)) {
tka->src_name = gf_strdup(param+4);
tka->sample_num = 1;
} else if (!strncmp("type=", param, 4)) {
tka->udta_type = GF_4CC(param[5], param[6], param[7], param[8]);
} else if (tka->dump_type == GF_EXPORT_RAW_SAMPLES) {
tka->sample_num = atoi(param);
}
#endif
}
}
if (arg_val) {
if (!strcmp(arg_val, "*")) {
tka->trackID = (u32) -1;
} else {
if (act_type==TRAC_ACTION_RAW_EXTRACT) {
if (!strncmp(arg_val, "video", 5)) {
arg_val += 5;
tka->dump_track_type = 1;
}
else if (!strncmp(arg_val, "audio", 5)) {
arg_val += 5;
tka->dump_track_type = 2;
}
}
if (arg_val[0])
tka->trackID = atoi(arg_val);
}
}
return GF_TRUE;
}
| 0
|
201,353
|
static int rsi_init_usb_interface(struct rsi_hw *adapter,
struct usb_interface *pfunction)
{
struct rsi_91x_usbdev *rsi_dev;
int status;
rsi_dev = kzalloc(sizeof(*rsi_dev), GFP_KERNEL);
if (!rsi_dev)
return -ENOMEM;
adapter->rsi_dev = rsi_dev;
rsi_dev->usbdev = interface_to_usbdev(pfunction);
rsi_dev->priv = (void *)adapter;
if (rsi_find_bulk_in_and_out_endpoints(pfunction, adapter)) {
status = -EINVAL;
goto fail_eps;
}
adapter->device = &pfunction->dev;
usb_set_intfdata(pfunction, adapter);
rsi_dev->tx_buffer = kmalloc(2048, GFP_KERNEL);
if (!rsi_dev->tx_buffer) {
status = -ENOMEM;
goto fail_eps;
}
if (rsi_usb_init_rx(adapter)) {
rsi_dbg(ERR_ZONE, "Failed to init RX handle\n");
status = -ENOMEM;
goto fail_rx;
}
rsi_dev->tx_blk_size = 252;
adapter->block_size = rsi_dev->tx_blk_size;
/* Initializing function callbacks */
adapter->check_hw_queue_status = rsi_usb_check_queue_status;
adapter->determine_event_timeout = rsi_usb_event_timeout;
adapter->rsi_host_intf = RSI_HOST_INTF_USB;
adapter->host_intf_ops = &usb_host_intf_ops;
#ifdef CONFIG_RSI_DEBUGFS
/* In USB, one less than the MAX_DEBUGFS_ENTRIES entries is required */
adapter->num_debugfs_entries = (MAX_DEBUGFS_ENTRIES - 1);
#endif
rsi_dbg(INIT_ZONE, "%s: Enabled the interface\n", __func__);
return 0;
fail_rx:
kfree(rsi_dev->tx_buffer);
fail_eps:
kfree(rsi_dev);
return status;
}
| 1
|
390,528
|
ProcXkbGetGeometry(ClientPtr client)
{
DeviceIntPtr dev;
xkbGetGeometryReply rep;
XkbGeometryPtr geom;
Bool shouldFree;
Status status;
REQUEST(xkbGetGeometryReq);
REQUEST_SIZE_MATCH(xkbGetGeometryReq);
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
CHK_ATOM_OR_NONE(stuff->name);
geom= XkbLookupNamedGeometry(dev,stuff->name,&shouldFree);
rep.type= X_Reply;
rep.deviceID= dev->id;
rep.sequenceNumber= client->sequence;
rep.length= 0;
status= XkbComputeGetGeometryReplySize(geom,&rep,stuff->name);
if (status!=Success)
return status;
else return XkbSendGeometry(client,geom,&rep,shouldFree);
}
| 0
|
244,195
|
GF_Box *saiz_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_SampleAuxiliaryInfoSizeBox, GF_ISOM_BOX_TYPE_SAIZ);
return (GF_Box *)tmp;
}
| 0
|
246,675
|
u32 parse_dash_profile(char *arg_val, u32 opt)
{
if (!stricmp(arg_val, "live") || !stricmp(arg_val, "simple")) dash_profile = GF_DASH_PROFILE_LIVE;
else if (!stricmp(arg_val, "onDemand")) dash_profile = GF_DASH_PROFILE_ONDEMAND;
else if (!stricmp(arg_val, "hbbtv1.5:live") || !stricmp(arg_val, "hbbtv1.5.live"))
dash_profile = GF_DASH_PROFILE_HBBTV_1_5_ISOBMF_LIVE;
else if (!stricmp(arg_val, "dashavc264:live") || !stricmp(arg_val, "dashavc264.live"))
dash_profile = GF_DASH_PROFILE_AVC264_LIVE;
else if (!stricmp(arg_val, "dashavc264:onDemand") || !stricmp(arg_val, "dashavc264.onDemand"))
dash_profile = GF_DASH_PROFILE_AVC264_ONDEMAND;
else if (!stricmp(arg_val, "dashif.ll")) dash_profile = GF_DASH_PROFILE_DASHIF_LL;
else if (!stricmp(arg_val, "main")) dash_profile = GF_DASH_PROFILE_MAIN;
else if (!stricmp(arg_val, "full")) dash_profile = GF_DASH_PROFILE_FULL;
else {
M4_LOG(GF_LOG_ERROR, ("Unrecognized DASH profile \"%s\" - please check usage\n", arg_val));
return 2;
}
return 0;
}
| 0
|
366,231
|
int sb_prepare_remount_readonly(struct super_block *sb)
{
struct mount *mnt;
int err = 0;
/* Racy optimization. Recheck the counter under MNT_WRITE_HOLD */
if (atomic_long_read(&sb->s_remove_count))
return -EBUSY;
lock_mount_hash();
list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
if (!(mnt->mnt.mnt_flags & MNT_READONLY)) {
mnt->mnt.mnt_flags |= MNT_WRITE_HOLD;
smp_mb();
if (mnt_get_writers(mnt) > 0) {
err = -EBUSY;
break;
}
}
}
if (!err && atomic_long_read(&sb->s_remove_count))
err = -EBUSY;
if (!err) {
sb->s_readonly_remount = 1;
smp_wmb();
}
list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
if (mnt->mnt.mnt_flags & MNT_WRITE_HOLD)
mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;
}
unlock_mount_hash();
return err;
}
| 0
|
238,319
|
int digest_algo_register(struct digest_algo *d)
{
if (!d || !d->base.name || !d->update || !d->final || !d->verify)
return -EINVAL;
if (!d->init)
d->init = dummy_init;
if (!d->alloc)
d->alloc = dummy_init;
if (!d->free)
d->free = dummy_free;
list_add_tail(&d->list, &digests);
return 0;
}
| 0
|
402,624
|
generate_time(cms_context *cms, SECItem *encoded, time_t when)
{
static char timebuf[32];
SECItem whenitem = {.type = SEC_ASN1_UTC_TIME,
.data = (unsigned char *)timebuf,
.len = 0
};
struct tm *tm;
tm = gmtime(&when);
whenitem.len = snprintf(timebuf, 32, "%02d%02d%02d%02d%02d%02dZ",
tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
if (whenitem.len == 32)
cmsreterr(-1, cms, "could not encode timestamp");
if (SEC_ASN1EncodeItem(cms->arena, encoded, &whenitem,
SEC_UTCTimeTemplate) == NULL)
cmsreterr(-1, cms, "could not encode timestamp");
return 0;
}
| 0
|
500,060
|
kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session)
{
int length;
krb5_enctype enctype;
krb5_octet FAR *contents = NULL;
if (!kssl_ctx) return KSSL_CTX_ERR;
if (kssl_ctx->key)
{
OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length);
kssl_free(kssl_ctx->key);
}
if (session)
{
#ifdef KRB5_HEIMDAL
length = session->keyvalue->length;
enctype = session->keytype;
contents = session->keyvalue->contents;
#else
length = session->length;
enctype = session->enctype;
contents = session->contents;
#endif
kssl_ctx->enctype = enctype;
kssl_ctx->length = length;
}
else
{
kssl_ctx->enctype = ENCTYPE_UNKNOWN;
kssl_ctx->length = 0;
return KSSL_CTX_OK;
}
if ((kssl_ctx->key =
(krb5_octet FAR *) kssl_calloc(1, kssl_ctx->length)) == NULL)
{
kssl_ctx->length = 0;
return KSSL_CTX_ERR;
}
else
memcpy(kssl_ctx->key, contents, length);
return KSSL_CTX_OK;
}
| 0
|
508,787
|
void st_select_lex::alloc_index_hints (THD *thd)
{
index_hints= new (thd->mem_root) List<Index_hint>();
}
| 0
|
384,880
|
skipbin(char_u *q)
{
char_u *p = q;
while (vim_isbdigit(*p)) // skip to next non-digit
++p;
return p;
}
| 0
|
366,302
|
void put_mnt_ns(struct mnt_namespace *ns)
{
if (!refcount_dec_and_test(&ns->ns.count))
return;
drop_collected_mounts(&ns->root->mnt);
free_mnt_ns(ns);
}
| 0
|
220,852
|
inline int32_t MultiplyByQuantizedMultiplierSmallerThanOneExp(
int32_t x, int32_t quantized_multiplier, int left_shift) {
using gemmlowp::RoundingDivideByPOT;
using gemmlowp::SaturatingRoundingDoublingHighMul;
return RoundingDivideByPOT(
SaturatingRoundingDoublingHighMul(x, quantized_multiplier), -left_shift);
}
| 0
|
212,822
|
pcl_status_read(byte * data, uint max_data, pcl_state_t * pcs)
{
uint count = min(max_data,
pcs->status.write_pos - pcs->status.read_pos);
if (count)
memcpy(data, pcs->status.buffer + pcs->status.read_pos, count);
pcs->status.read_pos += count;
if (pcs->status.read_pos == pcs->status.write_pos) {
gs_free_object(pcs->memory, pcs->status.buffer, "status buffer");
pcs->status.write_pos = pcs->status.read_pos = 0;
}
return count;
}
| 1
|
386,524
|
void DL_Dxf::writeImageDef(DL_WriterA& dw,
int handle,
const DL_ImageData& data) {
/*if (data.file.empty()) {
std::cerr << "DL_Dxf::writeImage: "
<< "Image file must not be empty\n";
return;
}*/
dw.dxfString(0, "IMAGEDEF");
if (version==DL_VERSION_2000) {
dw.dxfHex(5, handle);
}
if (version==DL_VERSION_2000) {
dw.dxfString(100, "AcDbRasterImageDef");
dw.dxfInt(90, 0);
}
// file name:
dw.dxfString(1, data.ref);
// image size in pixel
dw.dxfReal(10, data.width);
dw.dxfReal(20, data.height);
dw.dxfReal(11, 1.0);
dw.dxfReal(21, 1.0);
// loaded:
dw.dxfInt(280, 1);
// units:
dw.dxfInt(281, 0);
}
| 0
|
274,684
|
callbacks_reduce_object_area_clicked (GtkButton *button, gpointer user_data){
/* for testing, just hard code in some parameters */
gerbv_image_reduce_area_of_selected_objects (screen.selectionInfo.selectedNodeArray, 0.20, 3, 3, 0.01);
selection_clear (&screen.selectionInfo);
update_selected_object_message (FALSE);
render_refresh_rendered_image_on_screen ();
}
| 0
|
220,911
|
bool DependencyOptimizer::SafeToConvertToNoOp(const NodeDef& node) const {
if (HasRegularOutputs(node, *node_map_)) {
// The output values of this node may be needed.
VLOG(3) << "Not safe to convert '" << node.name()
<< " to NoOp. Node has outputs.";
return false;
}
if (!fetch_nodes_known_) {
VLOG(3) << "Not safe to convert '" << node.name()
<< " to NoOp. Fetches unknown.";
return false;
}
if (nodes_to_preserve_.find(node.name()) != nodes_to_preserve_.end()) {
VLOG(3) << "Not safe to convert to NoOp: " << node.name()
<< " is in preserve set.";
return false;
}
if (IsMerge(node) || IsSwitch(node) || ModifiesFrameInfo(node)) {
VLOG(3) << "Not safe to convert '" << node.name()
<< " to NoOp. Node modifies frame info.";
return false;
}
// Ops reading variables are marked as stateful, but are safe to remove if
// redundant.
static const absl::flat_hash_set<string>* gather_ops =
new absl::flat_hash_set<string>{"Gather", "GatherV2", "GatherNd",
"ResourceGather", "ResourceGatherNd"};
const bool is_variable_read =
IsReadVariableOp(node) || IsReadVariablesOp(node) ||
gather_ops->find(node.op()) != gather_ops->end();
if (!is_variable_read && !IsFreeOfSideEffect(node)) {
VLOG(3) << "Not safe to convert '" << node.name()
<< " to NoOp. Node has side effect.";
return false;
}
if (node.op().rfind("Submodel", 0) == 0) {
return false;
}
const OpDef* op_def = nullptr;
Status status = OpRegistry::Global()->LookUpOpDef(node.op(), &op_def);
if (!status.ok() || op_def->output_arg_size() == 0) {
return false;
}
const std::unordered_set<string> do_not_rewrite_ops{
"Assert", "CheckNumerics", "_Retval",
"_Arg", "_ParallelConcatUpdate", "TPUExecute",
"TPUCompile", "ControlTrigger"};
if (do_not_rewrite_ops.find(node.op()) != do_not_rewrite_ops.end()) {
return false;
}
if (!SafeToRemoveIdentity(node)) {
return false;
}
return true;
}
| 0
|
512,588
|
void copy_with_sum_func(const Item *item)
{
m_with_sum_func= item->with_sum_func();
}
| 0
|
265,434
|
void sqfs_close(void)
{
sqfs_decompressor_cleanup(&ctxt);
free(ctxt.sblk);
ctxt.sblk = NULL;
ctxt.cur_dev = NULL;
}
| 0
|
229,308
|
client_data cql_server::connection::make_client_data() const {
client_data cd;
std::tie(cd.ip, cd.port, cd.ct) = make_client_key(_client_state);
cd.shard_id = this_shard_id();
cd.protocol_version = _version;
cd.driver_name = _client_state.get_driver_name();
cd.driver_version = _client_state.get_driver_version();
if (const auto user_ptr = _client_state.user(); user_ptr) {
cd.username = user_ptr->name;
}
if (_ready) {
cd.connection_stage = client_connection_stage::ready;
} else if (_authenticating) {
cd.connection_stage = client_connection_stage::authenticating;
}
return cd;
}
| 0
|
90,832
|
QuotaManagerProxy::~QuotaManagerProxy() {
}
| 0
|
352,989
|
xutcTimeNormalize(
Syntax *syntax,
struct berval *val,
struct berval *normalized )
{
int parts[9], rc;
rc = check_time_syntax(val, 1, parts, NULL);
if (rc != LDAP_SUCCESS) {
return rc;
}
normalized->bv_val = ch_malloc( 14 );
if ( normalized->bv_val == NULL ) {
return LBER_ERROR_MEMORY;
}
sprintf( normalized->bv_val, "%02d%02d%02d%02d%02d%02dZ",
parts[1], parts[2] + 1, parts[3] + 1,
parts[4], parts[5], parts[6] );
normalized->bv_len = 13;
return LDAP_SUCCESS;
}
| 0
|
317,039
|
static void smack_sock_graft(struct sock *sk, struct socket *parent)
{
struct socket_smack *ssp;
struct smack_known *skp = smk_of_current();
if (sk == NULL ||
(sk->sk_family != PF_INET && sk->sk_family != PF_INET6))
return;
ssp = sk->sk_security;
ssp->smk_in = skp;
ssp->smk_out = skp;
/* cssp->smk_packet is already set in smack_inet_csk_clone() */
}
| 0
|
234,748
|
static struct btrfs_fs_devices *find_fsid_reverted_metadata(
struct btrfs_super_block *disk_super)
{
struct btrfs_fs_devices *fs_devices;
/*
* Handle the case where the scanned device is part of an fs whose last
* metadata UUID change reverted it to the original FSID. At the same
* time * fs_devices was first created by another constitutent device
* which didn't fully observe the operation. This results in an
* btrfs_fs_devices created with metadata/fsid different AND
* btrfs_fs_devices::fsid_change set AND the metadata_uuid of the
* fs_devices equal to the FSID of the disk.
*/
list_for_each_entry(fs_devices, &fs_uuids, fs_list) {
if (memcmp(fs_devices->fsid, fs_devices->metadata_uuid,
BTRFS_FSID_SIZE) != 0 &&
memcmp(fs_devices->metadata_uuid, disk_super->fsid,
BTRFS_FSID_SIZE) == 0 &&
fs_devices->fsid_change)
return fs_devices;
}
return NULL;
}
| 0
|
387,817
|
void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
// SystemDictionary::add_to_hierarchy() sets the init_state to loaded
// before the InstanceKlass is added to the SystemDictionary. Make
// sure the current state is <loaded.
assert(!is_loaded(), "invalid init state");
set_package(loader_data, CHECK);
Klass::restore_unshareable_info(loader_data, protection_domain, CHECK);
Array<Method*>* methods = this->methods();
int num_methods = methods->length();
for (int index2 = 0; index2 < num_methods; ++index2) {
methodHandle m(THREAD, methods->at(index2));
m->restore_unshareable_info(CHECK);
}
if (JvmtiExport::has_redefined_a_class()) {
// Reinitialize vtable because RedefineClasses may have changed some
// entries in this vtable for super classes so the CDS vtable might
// point to old or obsolete entries. RedefineClasses doesn't fix up
// vtables in the shared system dictionary, only the main one.
// It also redefines the itable too so fix that too.
ResourceMark rm(THREAD);
vtable().initialize_vtable(false, CHECK);
itable().initialize_itable(false, CHECK);
}
// restore constant pool resolved references
constants()->restore_unshareable_info(CHECK);
if (array_klasses() != NULL) {
// Array classes have null protection domain.
// --> see ArrayKlass::complete_create_array_klass()
array_klasses()->restore_unshareable_info(ClassLoaderData::the_null_class_loader_data(), Handle(), CHECK);
}
}
| 0
|
225,722
|
void hmhd_box_del(GF_Box *s)
{
GF_HintMediaHeaderBox *ptr = (GF_HintMediaHeaderBox *)s;
if (ptr == NULL) return;
gf_free(ptr);
}
| 0
|
359,520
|
DEFUN (show_ip_bgp_vpnv4_all_summary,
show_ip_bgp_vpnv4_all_summary_cmd,
"show ip bgp vpnv4 all summary",
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Display information about all VPNv4 NLRIs\n"
"Summary of BGP neighbor status\n")
{
return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
}
| 0
|
462,414
|
for(inst = pModConf->root ; inst != NULL ; ) {
free(inst->pszBindPort);
free(inst->pszBindPath);
free(inst->pszBindAddr);
free(inst->pszBindRuleset);
free(inst->pszInputName);
free(inst->dfltTZ);
del = inst;
inst = inst->next;
free(del);
}
| 0
|
369,232
|
static __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx,
struct seq_file *m)
{
struct io_sq_data *sq = NULL;
struct io_overflow_cqe *ocqe;
struct io_rings *r = ctx->rings;
unsigned int sq_mask = ctx->sq_entries - 1, cq_mask = ctx->cq_entries - 1;
unsigned int sq_head = READ_ONCE(r->sq.head);
unsigned int sq_tail = READ_ONCE(r->sq.tail);
unsigned int cq_head = READ_ONCE(r->cq.head);
unsigned int cq_tail = READ_ONCE(r->cq.tail);
unsigned int sq_entries, cq_entries;
bool has_lock;
unsigned int i;
/*
* we may get imprecise sqe and cqe info if uring is actively running
* since we get cached_sq_head and cached_cq_tail without uring_lock
* and sq_tail and cq_head are changed by userspace. But it's ok since
* we usually use these info when it is stuck.
*/
seq_printf(m, "SqMask:\t0x%x\n", sq_mask);
seq_printf(m, "SqHead:\t%u\n", sq_head);
seq_printf(m, "SqTail:\t%u\n", sq_tail);
seq_printf(m, "CachedSqHead:\t%u\n", ctx->cached_sq_head);
seq_printf(m, "CqMask:\t0x%x\n", cq_mask);
seq_printf(m, "CqHead:\t%u\n", cq_head);
seq_printf(m, "CqTail:\t%u\n", cq_tail);
seq_printf(m, "CachedCqTail:\t%u\n", ctx->cached_cq_tail);
seq_printf(m, "SQEs:\t%u\n", sq_tail - ctx->cached_sq_head);
sq_entries = min(sq_tail - sq_head, ctx->sq_entries);
for (i = 0; i < sq_entries; i++) {
unsigned int entry = i + sq_head;
unsigned int sq_idx = READ_ONCE(ctx->sq_array[entry & sq_mask]);
struct io_uring_sqe *sqe;
if (sq_idx > sq_mask)
continue;
sqe = &ctx->sq_sqes[sq_idx];
seq_printf(m, "%5u: opcode:%d, fd:%d, flags:%x, user_data:%llu\n",
sq_idx, sqe->opcode, sqe->fd, sqe->flags,
sqe->user_data);
}
seq_printf(m, "CQEs:\t%u\n", cq_tail - cq_head);
cq_entries = min(cq_tail - cq_head, ctx->cq_entries);
for (i = 0; i < cq_entries; i++) {
unsigned int entry = i + cq_head;
struct io_uring_cqe *cqe = &r->cqes[entry & cq_mask];
seq_printf(m, "%5u: user_data:%llu, res:%d, flag:%x\n",
entry & cq_mask, cqe->user_data, cqe->res,
cqe->flags);
}
/*
* Avoid ABBA deadlock between the seq lock and the io_uring mutex,
* since fdinfo case grabs it in the opposite direction of normal use
* cases. If we fail to get the lock, we just don't iterate any
* structures that could be going away outside the io_uring mutex.
*/
has_lock = mutex_trylock(&ctx->uring_lock);
if (has_lock && (ctx->flags & IORING_SETUP_SQPOLL)) {
sq = ctx->sq_data;
if (!sq->thread)
sq = NULL;
}
seq_printf(m, "SqThread:\t%d\n", sq ? task_pid_nr(sq->thread) : -1);
seq_printf(m, "SqThreadCpu:\t%d\n", sq ? task_cpu(sq->thread) : -1);
seq_printf(m, "UserFiles:\t%u\n", ctx->nr_user_files);
for (i = 0; has_lock && i < ctx->nr_user_files; i++) {
struct file *f = io_file_from_index(ctx, i);
if (f)
seq_printf(m, "%5u: %s\n", i, file_dentry(f)->d_iname);
else
seq_printf(m, "%5u: <none>\n", i);
}
seq_printf(m, "UserBufs:\t%u\n", ctx->nr_user_bufs);
for (i = 0; has_lock && i < ctx->nr_user_bufs; i++) {
struct io_mapped_ubuf *buf = ctx->user_bufs[i];
unsigned int len = buf->ubuf_end - buf->ubuf;
seq_printf(m, "%5u: 0x%llx/%u\n", i, buf->ubuf, len);
}
if (has_lock && !xa_empty(&ctx->personalities)) {
unsigned long index;
const struct cred *cred;
seq_printf(m, "Personalities:\n");
xa_for_each(&ctx->personalities, index, cred)
io_uring_show_cred(m, index, cred);
}
if (has_lock)
mutex_unlock(&ctx->uring_lock);
seq_puts(m, "PollList:\n");
spin_lock(&ctx->completion_lock);
for (i = 0; i < (1U << ctx->cancel_hash_bits); i++) {
struct hlist_head *list = &ctx->cancel_hash[i];
struct io_kiocb *req;
hlist_for_each_entry(req, list, hash_node)
seq_printf(m, " op=%d, task_works=%d\n", req->opcode,
task_work_pending(req->task));
}
seq_puts(m, "CqOverflowList:\n");
list_for_each_entry(ocqe, &ctx->cq_overflow_list, list) {
struct io_uring_cqe *cqe = &ocqe->cqe;
seq_printf(m, " user_data=%llu, res=%d, flags=%x\n",
cqe->user_data, cqe->res, cqe->flags);
}
spin_unlock(&ctx->completion_lock);
| 0
|
343,298
|
void dostor(char *name, const int append, const int autorename)
{
ULHandler ulhandler;
int f;
const char *ul_name = NULL;
const char *atomic_file = NULL;
off_t filesize = (off_t) 0U;
struct stat st;
double started = 0.0;
signed char overwrite = 0;
int overflow = 0;
int ret = -1;
off_t max_filesize = (off_t) -1;
#ifdef QUOTAS
Quota quota;
#endif
const char *name2 = NULL;
if (type < 1 || (type == 1 && restartat > (off_t) 1)) {
addreply_noformat(503, MSG_NO_ASCII_RESUME);
goto end;
}
#ifndef ANON_CAN_RESUME
if (guest != 0 && anon_noupload != 0) {
addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);
goto end;
}
#endif
if (ul_check_free_space(name, -1.0) == 0) {
addreply_noformat(552, MSG_NO_DISK_SPACE);
goto end;
}
if (checknamesanity(name, dot_write_ok) != 0) {
addreply(553, MSG_SANITY_FILE_FAILURE, name);
goto end;
}
if (autorename != 0) {
no_truncate = 1;
}
if (restartat > (off_t) 0 || no_truncate != 0) {
if ((atomic_file = get_atomic_file(name)) == NULL) {
addreply(553, MSG_SANITY_FILE_FAILURE, name);
goto end;
}
if (restartat > (off_t) 0 &&
rename(name, atomic_file) != 0 && errno != ENOENT) {
error(553, MSG_RENAME_FAILURE);
atomic_file = NULL;
goto end;
}
}
if (atomic_file != NULL) {
ul_name = atomic_file;
} else {
ul_name = name;
}
if (atomic_file == NULL &&
(f = open(ul_name, O_WRONLY | O_NOFOLLOW)) != -1) {
overwrite++;
} else if ((f = open(ul_name, O_CREAT | O_WRONLY | O_NOFOLLOW,
(mode_t) 0777 & ~u_mask)) == -1) {
error(553, MSG_OPEN_FAILURE2);
goto end;
}
if (fstat(f, &st) < 0) {
(void) close(f);
error(553, MSG_STAT_FAILURE2);
goto end;
}
if (!S_ISREG(st.st_mode)) {
(void) close(f);
addreply_noformat(550, MSG_NOT_REGULAR_FILE);
goto end;
}
alarm(MAX_SESSION_XFER_IDLE);
/* Anonymous users *CAN* overwrite 0-bytes files - This is the right behavior */
if (st.st_size > (off_t) 0) {
#ifndef ANON_CAN_RESUME
if (guest != 0) {
addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);
(void) close(f);
goto end;
}
#endif
if (append != 0) {
restartat = st.st_size;
}
} else {
restartat = (off_t) 0;
}
if (restartat > st.st_size) {
restartat = st.st_size;
}
if (restartat > (off_t) 0 && lseek(f, restartat, SEEK_SET) < (off_t) 0) {
(void) close(f);
error(451, "seek");
goto end;
}
if (restartat < st.st_size) {
if (ftruncate(f, restartat) < 0) {
(void) close(f);
error(451, "ftruncate");
goto end;
}
#ifdef QUOTAS
if (restartat != st.st_size) {
(void) quota_update(NULL, 0LL,
(long long) (restartat - st.st_size),
&overflow);
}
#endif
}
#ifdef QUOTAS
if (quota_update("a, 0LL, 0LL, &overflow) == 0 &&
(overflow > 0 || quota.files >= user_quota_files ||
quota.size > user_quota_size ||
(max_filesize = user_quota_size - quota.size) < (off_t) 0)) {
overflow = 1;
(void) close(f);
goto afterquota;
}
#endif
opendata();
if (xferfd == -1) {
(void) close(f);
goto end;
}
doreply();
# ifdef WITH_TLS
if (data_protection_level == CPL_PRIVATE) {
tls_init_data_session(xferfd, passive);
}
# endif
state_needs_update = 1;
setprocessname("pure-ftpd (UPLOAD)");
filesize = restartat;
#ifdef FTPWHO
if (shm_data_cur != NULL) {
const size_t sl = strlen(name);
ftpwho_lock();
shm_data_cur->state = FTPWHO_STATE_UPLOAD;
shm_data_cur->download_total_size = (off_t) 0U;
shm_data_cur->download_current_size = (off_t) filesize;
shm_data_cur->restartat = restartat;
(void) time(&shm_data_cur->xfer_date);
if (sl < sizeof shm_data_cur->filename) {
memcpy(shm_data_cur->filename, name, sl);
shm_data_cur->filename[sl] = 0;
} else {
memcpy(shm_data_cur->filename,
&name[sl - sizeof shm_data_cur->filename - 1U],
sizeof shm_data_cur->filename);
}
ftpwho_unlock();
}
#endif
/* Here starts the real upload code */
started = get_usec_time();
if (ul_init(&ulhandler, clientfd, tls_cnx, xferfd, name, f, tls_data_cnx,
restartat, type == 1, throttling_bandwidth_ul,
max_filesize) == 0) {
ret = ul_send(&ulhandler);
ul_exit(&ulhandler);
} else {
ret = -1;
}
(void) close(f);
closedata();
/* Here ends the real upload code */
#ifdef SHOW_REAL_DISK_SPACE
if (FSTATFS(f, &statfsbuf) == 0) {
double space;
space = (double) STATFS_BAVAIL(statfsbuf) *
(double) STATFS_FRSIZE(statfsbuf);
if (space > 524288.0) {
addreply(0, MSG_SPACE_FREE_M, space / 1048576.0);
} else {
addreply(0, MSG_SPACE_FREE_K, space / 1024.0);
}
}
#endif
uploaded += (unsigned long long) ulhandler.total_uploaded;
{
off_t atomic_file_size;
off_t original_file_size;
int files_count;
if (overwrite == 0) {
files_count = 1;
} else {
files_count = 0;
}
if (autorename != 0 && restartat == (off_t) 0) {
if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {
goto afterquota;
}
if (tryautorename(atomic_file, name, &name2) != 0) {
error(553, MSG_RENAME_FAILURE);
goto afterquota;
} else {
#ifdef QUOTAS
ul_quota_update(name2 ? name2 : name, 1, atomic_file_size);
#endif
atomic_file = NULL;
}
} else if (atomic_file != NULL) {
if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {
goto afterquota;
}
if ((original_file_size = get_file_size(name)) < (off_t) 0 ||
restartat > original_file_size) {
original_file_size = restartat;
}
if (rename(atomic_file, name) != 0) {
error(553, MSG_RENAME_FAILURE);
goto afterquota;
} else {
#ifdef QUOTAS
overflow = ul_quota_update
(name, files_count, atomic_file_size - original_file_size);
#endif
atomic_file = NULL;
}
} else {
#ifdef QUOTAS
overflow = ul_quota_update
(name, files_count, ulhandler.total_uploaded);
#endif
}
}
afterquota:
if (overflow > 0) {
addreply(552, MSG_QUOTA_EXCEEDED, name);
} else {
if (ret == 0) {
addreply_noformat(226, MSG_TRANSFER_SUCCESSFUL);
} else {
addreply_noformat(451, MSG_ABORTED);
}
displayrate(MSG_UPLOADED, ulhandler.total_uploaded, started,
name2 ? name2 : name, 1);
}
end:
restartat = (off_t) 0;
if (atomic_file != NULL) {
unlink(atomic_file);
atomic_file = NULL;
}
}
| 0
|
226,090
|
GF_Err cslg_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_CompositionToDecodeBox *ptr = (GF_CompositionToDecodeBox *)s;
e = gf_isom_full_box_write(s, bs);
if (e) return e;
gf_bs_write_int(bs, ptr->compositionToDTSShift, 32);
gf_bs_write_int(bs, ptr->leastDecodeToDisplayDelta, 32);
gf_bs_write_int(bs, ptr->greatestDecodeToDisplayDelta, 32);
gf_bs_write_int(bs, ptr->compositionStartTime, 32);
gf_bs_write_int(bs, ptr->compositionEndTime, 32);
return GF_OK;
}
| 0
|
346,448
|
estack_push_ufunc(ufunc_T *ufunc, long lnum)
{
estack_T *entry = estack_push(ETYPE_UFUNC,
ufunc->uf_name_exp != NULL
? ufunc->uf_name_exp : ufunc->uf_name, lnum);
if (entry != NULL)
entry->es_info.ufunc = ufunc;
return entry;
}
| 0
|
512,602
|
virtual uint32 max_display_length() const
{
return type_handler()->max_display_length(this);
}
| 0
|
455,325
|
bash_kill_shellword (count, key)
int count, key;
{
int p;
if (count < 0)
return (bash_backward_kill_shellword (-count, key));
p = rl_point;
bash_forward_shellword (count, key);
if (rl_point != p)
rl_kill_text (p, rl_point);
rl_point = p;
if (rl_editing_mode == EMACS_EDITING_MODE) /* 1 == emacs_mode */
rl_mark = rl_point;
return 0;
}
| 0
|
267,948
|
R_IPI void r_bin_class_free(RBinClass *k) {
if (k) {
free (k->name);
free (k->super);
free (k->visibility_str);
r_list_free (k->methods);
r_list_free (k->fields);
free (k);
}
}
| 0
|
90,138
|
virtual void ForgetWifiNetwork(const std::string& service_path) {
if (!EnsureCrosLoaded())
return;
if (DeleteRememberedService(service_path.c_str())) {
for (WifiNetworkVector::iterator iter =
remembered_wifi_networks_.begin();
iter != remembered_wifi_networks_.end();
++iter) {
if ((*iter)->service_path() == service_path) {
delete (*iter);
remembered_wifi_networks_.erase(iter);
break;
}
}
NotifyNetworkManagerChanged();
}
}
| 0
|
281,081
|
void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)
{
while ((dst = dst->child) && dst->xfrm && dst->dev == dev) {
dst->dev = dev_net(dev)->loopback_dev;
dev_hold(dst->dev);
dev_put(dev);
}
}
| 0
|
484,061
|
START_TEST(SecureChannel_sendAsymmetricOPNMessage_sentDataIsValid) {
UA_OpenSecureChannelResponse dummyResponse;
createDummyResponse(&dummyResponse);
/* Enable encryption for the SecureChannel */
#ifdef UA_ENABLE_ENCRYPTION
testChannel.securityMode = UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;
#else
testChannel.securityMode = UA_MESSAGESECURITYMODE_NONE;
#endif
UA_UInt32 requestId = UA_UInt32_random();
UA_StatusCode retval =
UA_SecureChannel_sendAsymmetricOPNMessage(&testChannel, requestId, &dummyResponse,
&UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE]);
ck_assert_msg(retval == UA_STATUSCODE_GOOD, "Expected function to succeed");
size_t offset = 0;
UA_TcpMessageHeader header;
UA_TcpMessageHeader_decodeBinary(&sentData, &offset, &header);
UA_UInt32 secureChannelId;
UA_UInt32_decodeBinary(&sentData, &offset, &secureChannelId);
UA_AsymmetricAlgorithmSecurityHeader asymSecurityHeader;
UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(&sentData, &offset, &asymSecurityHeader);
ck_assert_msg(UA_ByteString_equal(&testChannel.securityPolicy->policyUri,
&asymSecurityHeader.securityPolicyUri),
"Expected securityPolicyUri to be equal to the one used by the secureChannel");
#ifdef UA_ENABLE_ENCRYPTION
ck_assert_msg(UA_ByteString_equal(&dummyCertificate, &asymSecurityHeader.senderCertificate),
"Expected the certificate to be equal to the one used by the secureChannel");
UA_ByteString thumbPrint = {20, testChannel.remoteCertificateThumbprint};
ck_assert_msg(UA_ByteString_equal(&thumbPrint,
&asymSecurityHeader.receiverCertificateThumbprint),
"Expected receiverCertificateThumbprint to be equal to the one set "
"in the secureChannel");
/* Dummy encryption */
for(size_t i = offset; i < header.messageSize; ++i) {
sentData.data[i] = (UA_Byte)((sentData.data[i] - 1) % (UA_BYTE_MAX + 1));
}
#endif
UA_SequenceHeader sequenceHeader;
UA_SequenceHeader_decodeBinary(&sentData, &offset, &sequenceHeader);
ck_assert_msg(sequenceHeader.requestId == requestId, "Expected requestId to be %i but was %i",
requestId,
sequenceHeader.requestId);
UA_NodeId requestTypeId;
UA_NodeId_decodeBinary(&sentData, &offset, &requestTypeId);
ck_assert_msg(UA_NodeId_equal(&UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE].binaryEncodingId, &requestTypeId), "Expected nodeIds to be equal");
UA_OpenSecureChannelResponse sentResponse;
UA_OpenSecureChannelResponse_decodeBinary(&sentData, &offset, &sentResponse);
ck_assert_msg(memcmp(&sentResponse, &dummyResponse, sizeof(UA_OpenSecureChannelResponse)) == 0,
"Expected the sent response to be equal to the one supplied to the send function");
#ifdef UA_ENABLE_ENCRYPTION
UA_Byte paddingByte = sentData.data[offset];
size_t paddingSize = (size_t)paddingByte;
for(size_t i = 0; i <= paddingSize; ++i) {
ck_assert_msg(sentData.data[offset + i] == paddingByte,
"Expected padding byte %i to be %i but got value %i",
(int)i, paddingByte, sentData.data[offset + i]);
}
ck_assert_msg(sentData.data[offset + paddingSize + 1] == '*', "Expected first byte of signature");
#endif
UA_AsymmetricAlgorithmSecurityHeader_clear(&asymSecurityHeader);
UA_SequenceHeader_clear(&sequenceHeader);
UA_OpenSecureChannelResponse_clear(&sentResponse);
} END_TEST
| 0
|
386,495
|
void DL_Dxf::writeLeader(DL_WriterA& dw,
const DL_LeaderData& data,
const DL_Attributes& attrib) {
if (version>DL_VERSION_R12) {
dw.entity("LEADER");
if (version==DL_VERSION_2000) {
dw.dxfString(100, "AcDbEntity");
}
dw.entityAttributes(attrib);
if (version==DL_VERSION_2000) {
dw.dxfString(100, "AcDbLeader");
}
dw.dxfString(3, "Standard");
dw.dxfInt(71, data.arrowHeadFlag);
dw.dxfInt(72, data.leaderPathType);
dw.dxfInt(73, data.leaderCreationFlag);
dw.dxfInt(74, data.hooklineDirectionFlag);
dw.dxfInt(75, data.hooklineFlag);
dw.dxfReal(40, data.textAnnotationHeight);
dw.dxfReal(41, data.textAnnotationWidth);
dw.dxfInt(76, data.number);
}
}
| 0
|
387,631
|
static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
struct snd_ctl_elem_value *control)
{
struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd;
unsigned int index_offset;
int result;
down_write(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &control->id);
if (kctl == NULL) {
up_write(&card->controls_rwsem);
return -ENOENT;
}
index_offset = snd_ctl_get_ioff(kctl, &control->id);
vd = &kctl->vd[index_offset];
if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) || kctl->put == NULL ||
(file && vd->owner && vd->owner != file)) {
up_write(&card->controls_rwsem);
return -EPERM;
}
snd_ctl_build_ioff(&control->id, kctl, index_offset);
result = snd_power_ref_and_wait(card);
/* validate input values */
if (IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION) && !result) {
struct snd_ctl_elem_info info;
memset(&info, 0, sizeof(info));
info.id = control->id;
result = __snd_ctl_elem_info(card, kctl, &info, NULL);
if (!result)
result = sanity_check_input_values(card, control, &info,
false);
}
if (!result)
result = kctl->put(kctl, control);
snd_power_unref(card);
if (result < 0) {
up_write(&card->controls_rwsem);
return result;
}
if (result > 0) {
downgrade_write(&card->controls_rwsem);
snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_VALUE, kctl, index_offset);
up_read(&card->controls_rwsem);
} else {
up_write(&card->controls_rwsem);
}
return 0;
}
| 0
|
359,465
|
bgp_capability_vty_out (struct vty *vty, struct peer *peer)
{
char *pnt;
char *end;
struct capability_mp_data mpc;
struct capability_header *hdr;
pnt = peer->notify.data;
end = pnt + peer->notify.length;
while (pnt < end)
{
if (pnt + sizeof (struct capability_mp_data) + 2 > end)
return;
hdr = (struct capability_header *)pnt;
if (pnt + hdr->length + 2 > end)
return;
memcpy (&mpc, pnt + 2, sizeof(struct capability_mp_data));
if (hdr->code == CAPABILITY_CODE_MP)
{
vty_out (vty, " Capability error for: Multi protocol ");
switch (ntohs (mpc.afi))
{
case AFI_IP:
vty_out (vty, "AFI IPv4, ");
break;
case AFI_IP6:
vty_out (vty, "AFI IPv6, ");
break;
default:
vty_out (vty, "AFI Unknown %d, ", ntohs (mpc.afi));
break;
}
switch (mpc.safi)
{
case SAFI_UNICAST:
vty_out (vty, "SAFI Unicast");
break;
case SAFI_MULTICAST:
vty_out (vty, "SAFI Multicast");
break;
case SAFI_UNICAST_MULTICAST:
vty_out (vty, "SAFI Unicast Multicast");
break;
case BGP_SAFI_VPNV4:
vty_out (vty, "SAFI MPLS-VPN");
break;
default:
vty_out (vty, "SAFI Unknown %d ", mpc.safi);
break;
}
vty_out (vty, "%s", VTY_NEWLINE);
}
else if (hdr->code >= 128)
vty_out (vty, " Capability error: vendor specific capability code %d",
hdr->code);
else
vty_out (vty, " Capability error: unknown capability code %d",
hdr->code);
pnt += hdr->length + 2;
}
}
| 0
|
261,417
|
static int decode_pred_mode_flag(thread_context* tctx)
{
logtrace(LogSlice,"# pred_mode_flag\n");
int bit = decode_CABAC_bit(&tctx->cabac_decoder,
&tctx->ctx_model[CONTEXT_MODEL_PRED_MODE_FLAG]);
logtrace(LogSymbols,"$1 pred_mode=%d\n",bit);
return bit;
}
| 0
|
466,129
|
static int em_jcxz(struct x86_emulate_ctxt *ctxt)
{
if (address_mask(ctxt, ctxt->regs[VCPU_REGS_RCX]) == 0)
jmp_rel(ctxt, ctxt->src.val);
return X86EMUL_CONTINUE;
}
| 0
|
294,468
|
dup_obj(VALUE self)
{
get_d1a(self);
if (simple_dat_p(adat)) {
VALUE new = d_lite_s_alloc_simple(rb_obj_class(self));
{
get_d1b(new);
bdat->s = adat->s;
RB_OBJ_WRITTEN(new, Qundef, bdat->s.nth);
return new;
}
}
else {
VALUE new = d_lite_s_alloc_complex(rb_obj_class(self));
{
get_d1b(new);
bdat->c = adat->c;
RB_OBJ_WRITTEN(new, Qundef, bdat->c.nth);
RB_OBJ_WRITTEN(new, Qundef, bdat->c.sf);
return new;
}
}
}
| 0
|
512,577
|
Item *Item_func_nop_all::neg_transformer(THD *thd)
{
/* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
Item_func_not_all *new_item= new (thd->mem_root) Item_func_not_all(thd, args[0]);
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
allany->create_comp_func(FALSE);
allany->all= !allany->all;
allany->upper_item= new_item;
return new_item;
}
| 0
|
437,310
|
setup_called_state_call(Node* node, int state)
{
switch (NODE_TYPE(node)) {
case NODE_ALT:
state |= IN_ALT;
/* fall */
case NODE_LIST:
do {
setup_called_state_call(NODE_CAR(node), state);
} while (IS_NOT_NULL(node = NODE_CDR(node)));
break;
case NODE_QUANT:
{
QuantNode* qn = QUANT_(node);
if (IS_REPEAT_INFINITE(qn->upper) || qn->upper >= 2)
state |= IN_REAL_REPEAT;
if (qn->lower != qn->upper)
state |= IN_VAR_REPEAT;
setup_called_state_call(NODE_QUANT_BODY(qn), state);
}
break;
case NODE_ANCHOR:
{
AnchorNode* an = ANCHOR_(node);
switch (an->type) {
case ANCHOR_PREC_READ_NOT:
case ANCHOR_LOOK_BEHIND_NOT:
state |= IN_NOT;
/* fall */
case ANCHOR_PREC_READ:
case ANCHOR_LOOK_BEHIND:
setup_called_state_call(NODE_ANCHOR_BODY(an), state);
break;
default:
break;
}
}
break;
case NODE_ENCLOSURE:
{
EnclosureNode* en = ENCLOSURE_(node);
if (en->type == ENCLOSURE_MEMORY) {
if (NODE_IS_MARK1(node)) {
if ((~en->m.called_state & state) != 0) {
en->m.called_state |= state;
setup_called_state_call(NODE_BODY(node), state);
}
}
else {
NODE_STATUS_ADD(node, MARK1);
en->m.called_state |= state;
setup_called_state_call(NODE_BODY(node), state);
NODE_STATUS_REMOVE(node, MARK1);
}
}
else if (en->type == ENCLOSURE_IF_ELSE) {
if (IS_NOT_NULL(en->te.Then)) {
setup_called_state_call(en->te.Then, state);
}
if (IS_NOT_NULL(en->te.Else))
setup_called_state_call(en->te.Else, state);
}
else {
setup_called_state_call(NODE_BODY(node), state);
}
}
break;
case NODE_CALL:
setup_called_state_call(NODE_BODY(node), state);
break;
default:
break;
}
}
| 0
|
230,300
|
njs_array_handler_for_each(njs_vm_t *vm, njs_iterator_args_t *args,
njs_value_t *entry, int64_t n)
{
if (njs_is_valid(entry)) {
return njs_array_iterator_call(vm, args, entry, n);
}
return NJS_OK;
}
| 0
|
230,139
|
static int check_certificate(struct config_module * config, json_t * j_params, const char * credential_id, json_int_t gswu_id) {
json_t * j_query, * j_result;
int res, ret;
char * credential_id_escaped, * mod_name_escaped, * where_clause;
credential_id_escaped = h_escape_string_with_quotes(config->conn, credential_id);
mod_name_escaped = h_escape_string_with_quotes(config->conn, json_string_value(json_object_get(j_params, "mod_name")));
where_clause = msprintf(" IN (SELECT gswu_id FROM " G_TABLE_WEBAUTHN_CREDENTIAL " WHERE gswc_credential_id=%s AND gswc_status=1 AND gswu_id IN (SELECT gswu_id FROM " G_TABLE_WEBAUTHN_USER " WHERE gswu_mod_name=%s))", credential_id_escaped, mod_name_escaped);
j_query = json_pack("{sss[s]s{s{ssss}si}}",
"table",
G_TABLE_WEBAUTHN_CREDENTIAL,
"columns",
"gswu_id",
"where",
"gswu_id",
"operator",
"raw",
"value",
where_clause,
"gswc_status",
1);
o_free(where_clause);
o_free(mod_name_escaped);
o_free(credential_id_escaped);
res = h_select(config->conn, j_query, &j_result, NULL);
json_decref(j_query);
if (res == H_OK) {
if (json_array_size(j_result)) {
if (json_integer_value(json_object_get(json_array_get(j_result, 0), "gswu_id")) == gswu_id) {
ret = G_OK;
} else {
ret = G_ERROR_UNAUTHORIZED;
}
} else {
ret = G_ERROR_NOT_FOUND;
}
json_decref(j_result);
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "check_credential_id - Error executing j_query");
config->glewlwyd_module_callback_metrics_increment_counter(config, GLWD_METRICS_DATABSE_ERROR, 1, NULL);
ret = G_ERROR_DB;
}
return ret;
}
| 0
|
336,692
|
SPICE_GNUC_VISIBLE int spice_server_set_port(SpiceServer *reds, int port)
{
if (port < 0 || port > 0xffff) {
return -1;
}
reds->config->spice_port = port;
return 0;
}
| 0
|
337,802
|
struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc,
const struct sctp_chunk *chunk)
{
struct sctp_chunk *retval;
retval = sctp_make_control(asoc, SCTP_CID_COOKIE_ACK, 0, 0, GFP_ATOMIC);
/* RFC 2960 6.4 Multi-homed SCTP Endpoints
*
* An endpoint SHOULD transmit reply chunks (e.g., SACK,
* HEARTBEAT ACK, * etc.) to the same destination transport
* address from which it * received the DATA or control chunk
* to which it is replying.
*
* [COOKIE ACK back to where the COOKIE ECHO came from.]
*/
if (retval && chunk && chunk->transport)
retval->transport =
sctp_assoc_lookup_paddr(asoc,
&chunk->transport->ipaddr);
return retval;
}
| 0
|
225,970
|
GF_Err strk_box_size(GF_Box *s)
{
return GF_OK;
| 0
|
317,168
|
static int selinux_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
{
return security_sid_to_context(&selinux_state, secid,
secdata, seclen);
}
| 0
|
450,321
|
static void press_key(VncState *vs, QKeyCode qcode)
{
qkbd_state_key_event(vs->vd->kbd, qcode, true);
qkbd_state_key_event(vs->vd->kbd, qcode, false);
}
| 0
|
372,858
|
static int irda_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len)
{
struct sock *sk = sock->sk;
struct irda_sock *self;
struct sk_buff *skb;
int err = -EPIPE;
IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len);
/* Note : socket.c set MSG_EOR on SEQPACKET sockets */
if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_EOR | MSG_CMSG_COMPAT |
MSG_NOSIGNAL)) {
err = -EINVAL;
goto out;
}
lock_sock(sk);
if (sk->sk_shutdown & SEND_SHUTDOWN)
goto out_err;
if (sk->sk_state != TCP_ESTABLISHED) {
err = -ENOTCONN;
goto out;
}
self = irda_sk(sk);
/* Check if IrTTP is wants us to slow down */
if (wait_event_interruptible(*(sk_sleep(sk)),
(self->tx_flow != FLOW_STOP || sk->sk_state != TCP_ESTABLISHED))) {
err = -ERESTARTSYS;
goto out;
}
/* Check if we are still connected */
if (sk->sk_state != TCP_ESTABLISHED) {
err = -ENOTCONN;
goto out;
}
/* Check that we don't send out too big frames */
if (len > self->max_data_size) {
IRDA_DEBUG(2, "%s(), Chopping frame from %zd to %d bytes!\n",
__func__, len, self->max_data_size);
len = self->max_data_size;
}
skb = sock_alloc_send_skb(sk, len + self->max_header_size + 16,
msg->msg_flags & MSG_DONTWAIT, &err);
if (!skb)
goto out_err;
skb_reserve(skb, self->max_header_size + 16);
skb_reset_transport_header(skb);
skb_put(skb, len);
err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len);
if (err) {
kfree_skb(skb);
goto out_err;
}
/*
* Just send the message to TinyTP, and let it deal with possible
* errors. No need to duplicate all that here
*/
err = irttp_data_request(self->tsap, skb);
if (err) {
IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err);
goto out_err;
}
release_sock(sk);
/* Tell client how much data we actually sent */
return len;
out_err:
err = sk_stream_error(sk, msg->msg_flags, err);
out:
release_sock(sk);
return err;
}
| 0
|
238,455
|
static bool may_update_sockmap(struct bpf_verifier_env *env, int func_id)
{
enum bpf_attach_type eatype = env->prog->expected_attach_type;
enum bpf_prog_type type = resolve_prog_type(env->prog);
if (func_id != BPF_FUNC_map_update_elem)
return false;
/* It's not possible to get access to a locked struct sock in these
* contexts, so updating is safe.
*/
switch (type) {
case BPF_PROG_TYPE_TRACING:
if (eatype == BPF_TRACE_ITER)
return true;
break;
case BPF_PROG_TYPE_SOCKET_FILTER:
case BPF_PROG_TYPE_SCHED_CLS:
case BPF_PROG_TYPE_SCHED_ACT:
case BPF_PROG_TYPE_XDP:
case BPF_PROG_TYPE_SK_REUSEPORT:
case BPF_PROG_TYPE_FLOW_DISSECTOR:
case BPF_PROG_TYPE_SK_LOOKUP:
return true;
default:
break;
}
verbose(env, "cannot update sockmap in this context\n");
return false;
}
| 0
|
310,145
|
valid_db_path(const char *nominal)
{
struct stat sb;
#if USE_HASHED_DB
char suffix[] = DBM_SUFFIX;
size_t need = strlen(nominal) + sizeof(suffix);
char *result = malloc(need);
if (result == 0)
failed("valid_db_path");
_nc_STRCPY(result, nominal, need);
if (strcmp(result + need - sizeof(suffix), suffix)) {
_nc_STRCAT(result, suffix, need);
}
#else
char *result = strdup(nominal);
#endif
DEBUG(1, ("** stat(%s)", result));
if (stat(result, &sb) >= 0) {
#if USE_HASHED_DB
if (!S_ISREG(sb.st_mode)
|| access(result, R_OK | W_OK) != 0) {
DEBUG(1, ("...not a writable file"));
free(result);
result = 0;
}
#else
if (!S_ISDIR(sb.st_mode)
|| access(result, R_OK | W_OK | X_OK) != 0) {
DEBUG(1, ("...not a writable directory"));
free(result);
result = 0;
}
#endif
} else {
/* check if parent is directory and is writable */
unsigned leaf = _nc_pathlast(result);
DEBUG(1, ("...not found"));
if (leaf) {
char save = result[leaf];
result[leaf] = 0;
if (stat(result, &sb) >= 0
&& S_ISDIR(sb.st_mode)
&& access(result, R_OK | W_OK | X_OK) == 0) {
result[leaf] = save;
} else {
DEBUG(1, ("...parent directory %s is not writable", result));
free(result);
result = 0;
}
} else {
DEBUG(1, ("... no parent directory"));
free(result);
result = 0;
}
}
return result;
}
| 0
|
484,787
|
static int xennet_set_skb_gso(struct sk_buff *skb,
struct xen_netif_extra_info *gso)
{
if (!gso->u.gso.size) {
if (net_ratelimit())
pr_warn("GSO size must not be zero\n");
return -EINVAL;
}
if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4 &&
gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV6) {
if (net_ratelimit())
pr_warn("Bad GSO type %d\n", gso->u.gso.type);
return -EINVAL;
}
skb_shinfo(skb)->gso_size = gso->u.gso.size;
skb_shinfo(skb)->gso_type =
(gso->u.gso.type == XEN_NETIF_GSO_TYPE_TCPV4) ?
SKB_GSO_TCPV4 :
SKB_GSO_TCPV6;
/* Header must be checked, and gso_segs computed. */
skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
skb_shinfo(skb)->gso_segs = 0;
return 0;
}
| 0
|
364,746
|
jumpto_tag(
char_u *lbuf_arg, // line from the tags file for this tag
int forceit, // :ta with !
int keep_help) // keep help flag (FALSE for cscope)
{
optmagic_T save_magic_overruled;
int save_p_ws, save_p_scs, save_p_ic;
linenr_T save_lnum;
char_u *str;
char_u *pbuf; // search pattern buffer
char_u *pbuf_end;
char_u *tofree_fname = NULL;
char_u *fname;
tagptrs_T tagp;
int retval = FAIL;
int getfile_result = GETFILE_UNUSED;
int search_options;
#ifdef FEAT_SEARCH_EXTRA
int save_no_hlsearch;
#endif
#if defined(FEAT_QUICKFIX)
win_T *curwin_save = NULL;
#endif
char_u *full_fname = NULL;
#ifdef FEAT_FOLDING
int old_KeyTyped = KeyTyped; // getting the file may reset it
#endif
size_t len;
char_u *lbuf;
// Make a copy of the line, it can become invalid when an autocommand calls
// back here recursively.
len = matching_line_len(lbuf_arg) + 1;
lbuf = alloc(len);
if (lbuf != NULL)
mch_memmove(lbuf, lbuf_arg, len);
pbuf = alloc(LSIZE);
// parse the match line into the tagp structure
if (pbuf == NULL || lbuf == NULL || parse_match(lbuf, &tagp) == FAIL)
{
tagp.fname_end = NULL;
goto erret;
}
// truncate the file name, so it can be used as a string
*tagp.fname_end = NUL;
fname = tagp.fname;
// copy the command to pbuf[], remove trailing CR/NL
str = tagp.command;
for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; )
{
#ifdef FEAT_EMACS_TAGS
if (tagp.is_etag && *str == ',')// stop at ',' after line number
break;
#endif
*pbuf_end++ = *str++;
if (pbuf_end - pbuf + 1 >= LSIZE)
break;
}
*pbuf_end = NUL;
#ifdef FEAT_EMACS_TAGS
if (!tagp.is_etag)
#endif
{
/*
* Remove the "<Tab>fieldname:value" stuff; we don't need it here.
*/
str = pbuf;
if (find_extra(&str) == OK)
{
pbuf_end = str;
*pbuf_end = NUL;
}
}
/*
* Expand file name, when needed (for environment variables).
* If 'tagrelative' option set, may change file name.
*/
fname = expand_tag_fname(fname, tagp.tag_fname, TRUE);
if (fname == NULL)
goto erret;
tofree_fname = fname; // free() it later
/*
* Check if the file with the tag exists before abandoning the current
* file. Also accept a file name for which there is a matching BufReadCmd
* autocommand event (e.g., http://sys/file).
*/
if (mch_getperm(fname) < 0 && !has_autocmd(EVENT_BUFREADCMD, fname, NULL))
{
retval = NOTAGFILE;
vim_free(nofile_fname);
nofile_fname = vim_strsave(fname);
if (nofile_fname == NULL)
nofile_fname = empty_option;
goto erret;
}
++RedrawingDisabled;
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
{
postponed_split = 0; // don't split again below
curwin_save = curwin; // Save current window
/*
* If we are reusing a window, we may change dir when
* entering it (autocommands) so turn the tag filename
* into a fullpath
*/
if (!curwin->w_p_pvw)
{
full_fname = FullName_save(fname, FALSE);
fname = full_fname;
/*
* Make the preview window the current window.
* Open a preview window when needed.
*/
prepare_tagpreview(TRUE, TRUE, FALSE);
}
}
// If it was a CTRL-W CTRL-] command split window now. For ":tab tag"
// open a new tab page.
if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB)))
{
buf_T *existing_buf = buflist_findname_exp(fname);
if (existing_buf != NULL)
{
win_T *wp = NULL;
if (swb_flags & SWB_USEOPEN)
wp = buf_jump_open_win(existing_buf);
// If 'switchbuf' contains "usetab": jump to first window in any tab
// page containing "existing_buf" if one exists
if (wp == NULL && (swb_flags & SWB_USETAB))
wp = buf_jump_open_tab(existing_buf);
// We've switched to the buffer, the usual loading of the file must
// be skipped.
if (wp != NULL)
getfile_result = GETFILE_SAME_FILE;
}
}
if (getfile_result == GETFILE_UNUSED
&& (postponed_split || cmdmod.cmod_tab != 0))
{
if (win_split(postponed_split > 0 ? postponed_split : 0,
postponed_split_flags) == FAIL)
{
--RedrawingDisabled;
goto erret;
}
RESET_BINDING(curwin);
}
#endif
if (keep_help)
{
// A :ta from a help file will keep the b_help flag set. For ":ptag"
// we need to use the flag from the window where we came from.
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
keep_help_flag = bt_help(curwin_save->w_buffer);
else
#endif
keep_help_flag = curbuf->b_help;
}
if (getfile_result == GETFILE_UNUSED)
// Careful: getfile() may trigger autocommands and call jumpto_tag()
// recursively.
getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit);
keep_help_flag = FALSE;
if (GETFILE_SUCCESS(getfile_result)) // got to the right file
{
curwin->w_set_curswant = TRUE;
postponed_split = 0;
save_magic_overruled = magic_overruled;
magic_overruled = OPTION_MAGIC_OFF; // always execute with 'nomagic'
#ifdef FEAT_SEARCH_EXTRA
// Save value of no_hlsearch, jumping to a tag is not a real search
save_no_hlsearch = no_hlsearch;
#endif
#if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)
// getfile() may have cleared options, apply 'previewpopup' again.
if (g_do_tagpreview != 0 && *p_pvp != NUL)
parse_previewpopup(curwin);
#endif
/*
* If 'cpoptions' contains 't', store the search pattern for the "n"
* command. If 'cpoptions' does not contain 't', the search pattern
* is not stored.
*/
if (vim_strchr(p_cpo, CPO_TAGPAT) != NULL)
search_options = 0;
else
search_options = SEARCH_KEEP;
/*
* If the command is a search, try here.
*
* Reset 'smartcase' for the search, since the search pattern was not
* typed by the user.
* Only use do_search() when there is a full search command, without
* anything following.
*/
str = pbuf;
if (pbuf[0] == '/' || pbuf[0] == '?')
str = skip_regexp(pbuf + 1, pbuf[0], FALSE) + 1;
if (str > pbuf_end - 1) // search command with nothing following
{
save_p_ws = p_ws;
save_p_ic = p_ic;
save_p_scs = p_scs;
p_ws = TRUE; // need 'wrapscan' for backward searches
p_ic = FALSE; // don't ignore case now
p_scs = FALSE;
save_lnum = curwin->w_cursor.lnum;
if (tagp.tagline > 0)
// start search before line from "line:" field
curwin->w_cursor.lnum = tagp.tagline - 1;
else
// start search before first line
curwin->w_cursor.lnum = 0;
if (do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1,
search_options, NULL))
retval = OK;
else
{
int found = 1;
int cc;
/*
* try again, ignore case now
*/
p_ic = TRUE;
if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1,
search_options, NULL))
{
/*
* Failed to find pattern, take a guess: "^func ("
*/
found = 2;
(void)test_for_static(&tagp);
cc = *tagp.tagname_end;
*tagp.tagname_end = NUL;
sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname);
if (!do_search(NULL, '/', '/', pbuf, (long)1,
search_options, NULL))
{
// Guess again: "^char * \<func ("
sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(",
tagp.tagname);
if (!do_search(NULL, '/', '/', pbuf, (long)1,
search_options, NULL))
found = 0;
}
*tagp.tagname_end = cc;
}
if (found == 0)
{
emsg(_(e_canot_find_tag_pattern));
curwin->w_cursor.lnum = save_lnum;
}
else
{
/*
* Only give a message when really guessed, not when 'ic'
* is set and match found while ignoring case.
*/
if (found == 2 || !save_p_ic)
{
msg(_(e_couldnt_find_tag_just_guessing));
if (!msg_scrolled && msg_silent == 0)
{
out_flush();
ui_delay(1010L, TRUE);
}
}
retval = OK;
}
}
p_ws = save_p_ws;
p_ic = save_p_ic;
p_scs = save_p_scs;
// A search command may have positioned the cursor beyond the end
// of the line. May need to correct that here.
check_cursor();
}
else
{
int save_secure = secure;
// Setup the sandbox for executing the command from the tags file.
secure = 1;
#ifdef HAVE_SANDBOX
++sandbox;
#endif
curwin->w_cursor.lnum = 1; // start command in line 1
do_cmdline_cmd(pbuf);
retval = OK;
// When the command has done something that is not allowed make
// sure the error message can be seen.
if (secure == 2)
wait_return(TRUE);
secure = save_secure;
#ifdef HAVE_SANDBOX
--sandbox;
#endif
}
magic_overruled = save_magic_overruled;
#ifdef FEAT_SEARCH_EXTRA
// restore no_hlsearch when keeping the old search pattern
if (search_options)
set_no_hlsearch(save_no_hlsearch);
#endif
// Return OK if jumped to another file (at least we found the file!).
if (getfile_result == GETFILE_OPEN_OTHER)
retval = OK;
if (retval == OK)
{
/*
* For a help buffer: Put the cursor line at the top of the window,
* the help subject will be below it.
*/
if (curbuf->b_help)
set_topline(curwin, curwin->w_cursor.lnum);
#ifdef FEAT_FOLDING
if ((fdo_flags & FDO_TAG) && old_KeyTyped)
foldOpenCursor();
#endif
}
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0
&& curwin != curwin_save && win_valid(curwin_save))
{
// Return cursor to where we were
validate_cursor();
redraw_later(UPD_VALID);
win_enter(curwin_save, TRUE);
}
#endif
--RedrawingDisabled;
}
else
{
--RedrawingDisabled;
got_int = FALSE; // don't want entering window to fail
if (postponed_split) // close the window
{
win_close(curwin, FALSE);
postponed_split = 0;
}
#if defined(FEAT_QUICKFIX) && defined(FEAT_PROP_POPUP)
else if (WIN_IS_POPUP(curwin))
{
win_T *wp = curwin;
if (win_valid(curwin_save))
win_enter(curwin_save, TRUE);
popup_close(wp->w_id, FALSE);
}
#endif
}
#if defined(FEAT_QUICKFIX) && defined(FEAT_PROP_POPUP)
if (WIN_IS_POPUP(curwin))
// something went wrong, still in popup, but it can't have focus
win_enter(firstwin, TRUE);
#endif
erret:
#if defined(FEAT_QUICKFIX)
g_do_tagpreview = 0; // For next time
#endif
vim_free(lbuf);
vim_free(pbuf);
vim_free(tofree_fname);
vim_free(full_fname);
return retval;
}
| 0
|
255,774
|
deinit_authz(void *data)
{
/* The two object pools run their own cleanup handlers. */
authz_pool = NULL;
filtered_pool = NULL;
authz_pool_initialized = FALSE;
return APR_SUCCESS;
}
| 0
|
413,863
|
Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
bool checkpolymorphism,
bool in_imethod_resolve) {
NoSafepointVerifier nsv; // Method* returned may not be reclaimed
Klass* klass = link_info.resolved_klass();
Symbol* name = link_info.name();
Symbol* signature = link_info.signature();
// Ignore overpasses so statics can be found during resolution
Method* result = klass->uncached_lookup_method(name, signature, Klass::OverpassLookupMode::skip);
if (klass->is_array_klass()) {
// Only consider klass and super klass for arrays
return result;
}
InstanceKlass* ik = InstanceKlass::cast(klass);
// JDK 8, JVMS 5.4.3.4: Interface method resolution should
// ignore static and non-public methods of java.lang.Object,
// like clone and finalize.
if (in_imethod_resolve &&
result != NULL &&
ik->is_interface() &&
(result->is_static() || !result->is_public()) &&
result->method_holder() == vmClasses::Object_klass()) {
result = NULL;
}
// Before considering default methods, check for an overpass in the
// current class if a method has not been found.
if (result == NULL) {
result = ik->find_method(name, signature);
}
if (result == NULL) {
Array<Method*>* default_methods = ik->default_methods();
if (default_methods != NULL) {
result = InstanceKlass::find_method(default_methods, name, signature);
}
}
if (checkpolymorphism && result != NULL) {
vmIntrinsics::ID iid = result->intrinsic_id();
if (MethodHandles::is_signature_polymorphic(iid)) {
// Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method.
return NULL;
}
}
return result;
}
| 0
|
472,374
|
ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
int index, Bytecodes::Code bc,
ciInstanceKlass* accessor) {
assert(cpool.not_null(), "need constant pool");
assert(accessor != NULL, "need origin of access");
if (bc == Bytecodes::_invokedynamic) {
ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index);
bool is_resolved = !cpce->is_f1_null();
// FIXME: code generation could allow for null (unlinked) call site
// The call site could be made patchable as follows:
// Load the appendix argument from the constant pool.
// Test the appendix argument and jump to a known deopt routine if it is null.
// Jump through a patchable call site, which is initially a deopt routine.
// Patch the call site to the nmethod entry point of the static compiled lambda form.
// As with other two-component call sites, both values must be independently verified.
if (is_resolved) {
// Get the invoker Method* from the constant pool.
// (The appendix argument, if any, will be noted in the method's signature.)
Method* adapter = cpce->f1_as_method();
return get_method(adapter);
}
// Fake a method that is equivalent to a declared method.
ciInstanceKlass* holder = get_instance_klass(vmClasses::MethodHandle_klass());
ciSymbol* name = ciSymbols::invokeBasic_name();
ciSymbol* signature = get_symbol(cpool->signature_ref_at(index));
return get_unloaded_method(holder, name, signature, accessor);
} else {
const int holder_index = cpool->klass_ref_index_at(index);
bool holder_is_accessible;
ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
// Get the method's name and signature.
Symbol* name_sym = cpool->name_ref_at(index);
Symbol* sig_sym = cpool->signature_ref_at(index);
if (cpool->has_preresolution()
|| ((holder == ciEnv::MethodHandle_klass() || holder == ciEnv::VarHandle_klass()) &&
MethodHandles::is_signature_polymorphic_name(holder->get_Klass(), name_sym))) {
// Short-circuit lookups for JSR 292-related call sites.
// That is, do not rely only on name-based lookups, because they may fail
// if the names are not resolvable in the boot class loader (7056328).
switch (bc) {
case Bytecodes::_invokevirtual:
case Bytecodes::_invokeinterface:
case Bytecodes::_invokespecial:
case Bytecodes::_invokestatic:
{
Method* m = ConstantPool::method_at_if_loaded(cpool, index);
if (m != NULL) {
return get_method(m);
}
}
break;
default:
break;
}
}
if (holder_is_accessible) { // Our declared holder is loaded.
constantTag tag = cpool->tag_ref_at(index);
assert(accessor->get_instanceKlass() == cpool->pool_holder(), "not the pool holder?");
Method* m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag);
if (m != NULL &&
(bc == Bytecodes::_invokestatic
? m->method_holder()->is_not_initialized()
: !m->method_holder()->is_loaded())) {
m = NULL;
}
#ifdef ASSERT
if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) {
m = NULL;
}
#endif
if (m != NULL) {
// We found the method.
return get_method(m);
}
}
// Either the declared holder was not loaded, or the method could
// not be found. Create a dummy ciMethod to represent the failed
// lookup.
ciSymbol* name = get_symbol(name_sym);
ciSymbol* signature = get_symbol(sig_sym);
return get_unloaded_method(holder, name, signature, accessor);
}
}
| 0
|
247,101
|
void gf_fs_set_ui_callback(GF_FilterSession *fs, Bool (*ui_event_proc)(void *opaque, GF_Event *event), void *cbk_udta)
{
if (fs) {
fs->ui_event_proc = ui_event_proc;
fs->ui_opaque = cbk_udta;
if (!fs->ui_event_proc) {
fs->ui_event_proc = fs_default_event_proc;
fs->ui_opaque = fs;
}
}
}
| 0
|
391,650
|
NTSTATUS fd_open(struct connection_struct *conn,
files_struct *fsp,
int flags,
mode_t mode)
{
struct smb_filename *smb_fname = fsp->fsp_name;
NTSTATUS status = NT_STATUS_OK;
#ifdef O_NOFOLLOW
/*
* Never follow symlinks on a POSIX client. The
* client should be doing this.
*/
if (fsp->posix_open || !lp_symlinks(SNUM(conn))) {
flags |= O_NOFOLLOW;
}
#endif
fsp->fh->fd = SMB_VFS_OPEN(conn, smb_fname, fsp, flags, mode);
if (fsp->fh->fd == -1) {
int posix_errno = errno;
#ifdef O_NOFOLLOW
#if defined(ENOTSUP) && defined(OSF1)
/* handle special Tru64 errno */
if (errno == ENOTSUP) {
posix_errno = ELOOP;
}
#endif /* ENOTSUP */
#ifdef EFTYPE
/* fix broken NetBSD errno */
if (errno == EFTYPE) {
posix_errno = ELOOP;
}
#endif /* EFTYPE */
/* fix broken FreeBSD errno */
if (errno == EMLINK) {
posix_errno = ELOOP;
}
#endif /* O_NOFOLLOW */
status = map_nt_error_from_unix(posix_errno);
if (errno == EMFILE) {
static time_t last_warned = 0L;
if (time((time_t *) NULL) > last_warned) {
DEBUG(0,("Too many open files, unable "
"to open more! smbd's max "
"open files = %d\n",
lp_max_open_files()));
last_warned = time((time_t *) NULL);
}
}
}
DEBUG(10,("fd_open: name %s, flags = 0%o mode = 0%o, fd = %d. %s\n",
smb_fname_str_dbg(smb_fname), flags, (int)mode, fsp->fh->fd,
(fsp->fh->fd == -1) ? strerror(errno) : "" ));
return status;
}
| 0
|
444,894
|
drop_capabilities(int parent)
{
return 0;
}
| 0
|
195,309
|
gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
{
char *pos = inbuf;
char *lpos = NULL;
char *tline = NULL;
LOCAL_ARRAY(char, line, TEMP_BUF_SIZE);
LOCAL_ARRAY(char, tmpbuf, TEMP_BUF_SIZE);
char *name = NULL;
char *selector = NULL;
char *host = NULL;
char *port = NULL;
char *escaped_selector = NULL;
const char *icon_url = NULL;
char gtype;
StoreEntry *entry = NULL;
memset(tmpbuf, '\0', TEMP_BUF_SIZE);
memset(line, '\0', TEMP_BUF_SIZE);
entry = gopherState->entry;
if (gopherState->conversion == GopherStateData::HTML_INDEX_PAGE) {
char *html_url = html_quote(entry->url());
gopherHTMLHeader(entry, "Gopher Index %s", html_url);
storeAppendPrintf(entry,
"<p>This is a searchable Gopher index. Use the search\n"
"function of your browser to enter search terms.\n"
"<ISINDEX>\n");
gopherHTMLFooter(entry);
/* now let start sending stuff to client */
entry->flush();
gopherState->HTML_header_added = 1;
return;
}
if (gopherState->conversion == GopherStateData::HTML_CSO_PAGE) {
char *html_url = html_quote(entry->url());
gopherHTMLHeader(entry, "CSO Search of %s", html_url);
storeAppendPrintf(entry,
"<P>A CSO database usually contains a phonebook or\n"
"directory. Use the search function of your browser to enter\n"
"search terms.</P><ISINDEX>\n");
gopherHTMLFooter(entry);
/* now let start sending stuff to client */
entry->flush();
gopherState->HTML_header_added = 1;
return;
}
String outbuf;
if (!gopherState->HTML_header_added) {
if (gopherState->conversion == GopherStateData::HTML_CSO_RESULT)
gopherHTMLHeader(entry, "CSO Search Result", NULL);
else
gopherHTMLHeader(entry, "Gopher Menu", NULL);
outbuf.append ("<PRE>");
gopherState->HTML_header_added = 1;
gopherState->HTML_pre = 1;
}
while (pos < inbuf + len) {
int llen;
int left = len - (pos - inbuf);
lpos = (char *)memchr(pos, '\n', left);
if (lpos) {
++lpos; /* Next line is after \n */
llen = lpos - pos;
} else {
llen = left;
}
if (gopherState->len + llen >= TEMP_BUF_SIZE) {
debugs(10, DBG_IMPORTANT, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url() );
llen = TEMP_BUF_SIZE - gopherState->len - 1;
gopherState->overflowed = true; // may already be true
}
if (!lpos) {
/* there is no complete line in inbuf */
/* copy it to temp buffer */
/* note: llen is adjusted above */
memcpy(gopherState->buf + gopherState->len, pos, llen);
gopherState->len += llen;
break;
}
if (gopherState->len != 0) {
/* there is something left from last tx. */
memcpy(line, gopherState->buf, gopherState->len);
memcpy(line + gopherState->len, pos, llen);
llen += gopherState->len;
gopherState->len = 0;
} else {
memcpy(line, pos, llen);
}
line[llen + 1] = '\0';
/* move input to next line */
pos = lpos;
/* at this point. We should have one line in buffer to process */
if (*line == '.') {
/* skip it */
memset(line, '\0', TEMP_BUF_SIZE);
continue;
}
switch (gopherState->conversion) {
case GopherStateData::HTML_INDEX_RESULT:
case GopherStateData::HTML_DIR: {
tline = line;
gtype = *tline;
++tline;
name = tline;
selector = strchr(tline, TAB);
if (selector) {
*selector = '\0';
++selector;
host = strchr(selector, TAB);
if (host) {
*host = '\0';
++host;
port = strchr(host, TAB);
if (port) {
char *junk;
port[0] = ':';
junk = strchr(host, TAB);
if (junk)
*junk++ = 0; /* Chop port */
else {
junk = strchr(host, '\r');
if (junk)
*junk++ = 0; /* Chop port */
else {
junk = strchr(host, '\n');
if (junk)
*junk++ = 0; /* Chop port */
}
}
if ((port[1] == '0') && (!port[2]))
port[0] = 0; /* 0 means none */
}
/* escape a selector here */
escaped_selector = xstrdup(rfc1738_escape_part(selector));
switch (gtype) {
case GOPHER_DIRECTORY:
icon_url = mimeGetIconURL("internal-menu");
break;
case GOPHER_HTML:
case GOPHER_FILE:
icon_url = mimeGetIconURL("internal-text");
break;
case GOPHER_INDEX:
case GOPHER_CSO:
icon_url = mimeGetIconURL("internal-index");
break;
case GOPHER_IMAGE:
case GOPHER_GIF:
case GOPHER_PLUS_IMAGE:
icon_url = mimeGetIconURL("internal-image");
break;
case GOPHER_SOUND:
case GOPHER_PLUS_SOUND:
icon_url = mimeGetIconURL("internal-sound");
break;
case GOPHER_PLUS_MOVIE:
icon_url = mimeGetIconURL("internal-movie");
break;
case GOPHER_TELNET:
case GOPHER_3270:
icon_url = mimeGetIconURL("internal-telnet");
break;
case GOPHER_BIN:
case GOPHER_MACBINHEX:
case GOPHER_DOSBIN:
case GOPHER_UUENCODED:
icon_url = mimeGetIconURL("internal-binary");
break;
case GOPHER_INFO:
icon_url = NULL;
break;
case GOPHER_WWW:
icon_url = mimeGetIconURL("internal-link");
break;
default:
icon_url = mimeGetIconURL("internal-unknown");
break;
}
memset(tmpbuf, '\0', TEMP_BUF_SIZE);
if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) {
if (strlen(escaped_selector) != 0)
snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"telnet://%s@%s%s%s/\">%s</A>\n",
icon_url, escaped_selector, rfc1738_escape_part(host),
*port ? ":" : "", port, html_quote(name));
else
snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"telnet://%s%s%s/\">%s</A>\n",
icon_url, rfc1738_escape_part(host), *port ? ":" : "",
port, html_quote(name));
} else if (gtype == GOPHER_INFO) {
snprintf(tmpbuf, TEMP_BUF_SIZE, "\t%s\n", html_quote(name));
} else {
if (strncmp(selector, "GET /", 5) == 0) {
/* WWW link */
snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"http://%s/%s\">%s</A>\n",
icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name));
} else if (gtype == GOPHER_WWW) {
snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"%s\">%s</A>\n",
icon_url, rfc1738_escape_unescaped(selector), html_quote(name));
} else {
/* Standard link */
snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n",
icon_url, host, gtype, escaped_selector, html_quote(name));
}
}
safe_free(escaped_selector);
outbuf.append(tmpbuf);
} else {
memset(line, '\0', TEMP_BUF_SIZE);
continue;
}
} else {
memset(line, '\0', TEMP_BUF_SIZE);
continue;
}
break;
} /* HTML_DIR, HTML_INDEX_RESULT */
case GopherStateData::HTML_CSO_RESULT: {
if (line[0] == '-') {
int code, recno;
char *s_code, *s_recno, *result;
s_code = strtok(line + 1, ":\n");
s_recno = strtok(NULL, ":\n");
result = strtok(NULL, "\n");
if (!result)
break;
code = atoi(s_code);
recno = atoi(s_recno);
if (code != 200)
break;
if (gopherState->cso_recno != recno) {
snprintf(tmpbuf, TEMP_BUF_SIZE, "</PRE><HR noshade size=\"1px\"><H2>Record# %d<br><i>%s</i></H2>\n<PRE>", recno, html_quote(result));
gopherState->cso_recno = recno;
} else {
snprintf(tmpbuf, TEMP_BUF_SIZE, "%s\n", html_quote(result));
}
outbuf.append(tmpbuf);
break;
} else {
int code;
char *s_code, *result;
s_code = strtok(line, ":");
result = strtok(NULL, "\n");
if (!result)
break;
code = atoi(s_code);
switch (code) {
case 200: {
/* OK */
/* Do nothing here */
break;
}
case 102: /* Number of matches */
case 501: /* No Match */
case 502: { /* Too Many Matches */
/* Print the message the server returns */
snprintf(tmpbuf, TEMP_BUF_SIZE, "</PRE><HR noshade size=\"1px\"><H2>%s</H2>\n<PRE>", html_quote(result));
outbuf.append(tmpbuf);
break;
}
}
}
break;
} /* HTML_CSO_RESULT */
default:
break; /* do nothing */
} /* switch */
} /* while loop */
if (outbuf.size() > 0) {
entry->append(outbuf.rawBuf(), outbuf.size());
/* now let start sending stuff to client */
entry->flush();
}
outbuf.clean();
return;
}
| 1
|
252,290
|
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip,
const char *pFilename) {
mz_zip_internal_state *pState;
if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))
return MZ_FALSE;
// No sense in trying to write to an archive that's already at the support max
// size
if ((pZip->m_total_files == 0xFFFF) ||
((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +
MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF))
return MZ_FALSE;
pState = pZip->m_pState;
if (pState->m_pFile) {
#ifdef MINIZ_NO_STDIO
pFilename;
return MZ_FALSE;
#else
// Archive is being read from stdio - try to reopen as writable.
if (pZip->m_pIO_opaque != pZip) return MZ_FALSE;
if (!pFilename) return MZ_FALSE;
pZip->m_pWrite = mz_zip_file_write_func;
if (NULL ==
(pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile))) {
// The mz_zip_archive is now in a bogus state because pState->m_pFile is
// NULL, so just close it.
mz_zip_reader_end(pZip);
return MZ_FALSE;
}
#endif // #ifdef MINIZ_NO_STDIO
} else if (pState->m_pMem) {
// Archive lives in a memory block. Assume it's from the heap that we can
// resize using the realloc callback.
if (pZip->m_pIO_opaque != pZip) return MZ_FALSE;
pState->m_mem_capacity = pState->m_mem_size;
pZip->m_pWrite = mz_zip_heap_write_func;
}
// Archive is being read via a user provided read function - make sure the
// user has specified a write function too.
else if (!pZip->m_pWrite)
return MZ_FALSE;
// Start writing new files at the archive's current central directory
// location.
pZip->m_archive_size = pZip->m_central_directory_file_ofs;
pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;
pZip->m_central_directory_file_ofs = 0;
return MZ_TRUE;
}
| 0
|
409,452
|
term_cursor_right(int i)
{
OUT_STR(tgoto((char *)T_CRI, 0, i));
}
| 0
|
197,808
|
mrb_f_send(mrb_state *mrb, mrb_value self)
{
mrb_sym name;
mrb_value block, *regs;
mrb_method_t m;
struct RClass *c;
mrb_callinfo *ci = mrb->c->ci;
int n = ci->n;
if (ci->cci > CINFO_NONE) {
funcall:;
const mrb_value *argv;
mrb_int argc;
mrb_get_args(mrb, "n*&", &name, &argv, &argc, &block);
return mrb_funcall_with_block(mrb, self, name, argc, argv, block);
}
regs = mrb->c->ci->stack+1;
if (n == 0) {
mrb_argnum_error(mrb, 0, 1, -1);
}
else if (n == 15) {
name = mrb_obj_to_sym(mrb, RARRAY_PTR(regs[0])[0]);
}
else {
name = mrb_obj_to_sym(mrb, regs[0]);
}
c = mrb_class(mrb, self);
m = mrb_method_search_vm(mrb, &c, name);
if (MRB_METHOD_UNDEF_P(m)) { /* call method_mising */
goto funcall;
}
ci->mid = name;
ci->u.target_class = c;
/* remove first symbol from arguments */
if (n == 15) { /* variable length arguments */
regs[0] = mrb_ary_subseq(mrb, regs[0], 1, RARRAY_LEN(regs[0]) - 1);
}
else { /* n > 0 */
for (int i=0; i<n; i++) {
regs[i] = regs[i+1];
}
regs[n] = regs[n+1]; /* copy kdict or block */
if (ci->nk > 0) {
regs[n+1] = regs[n+2]; /* copy block */
}
ci->n--;
}
if (MRB_METHOD_CFUNC_P(m)) {
if (MRB_METHOD_NOARG_P(m)) {
check_method_noarg(mrb, ci);
}
if (MRB_METHOD_PROC_P(m)) {
mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));
}
return MRB_METHOD_CFUNC(m)(mrb, self);
}
return exec_irep(mrb, self, MRB_METHOD_PROC(m));
}
| 1
|
369,348
|
static bool io_cancel_task_cb(struct io_wq_work *work, void *data)
{
struct io_kiocb *req = container_of(work, struct io_kiocb, work);
struct io_task_cancel *cancel = data;
return io_match_task_safe(req, cancel->task, cancel->all);
| 0
|
405,375
|
static void xfrm_policy_fini(struct net *net)
{
struct xfrm_pol_inexact_bin *b, *t;
unsigned int sz;
int dir;
flush_work(&net->xfrm.policy_hash_work);
#ifdef CONFIG_XFRM_SUB_POLICY
xfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, false);
#endif
xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, false);
WARN_ON(!list_empty(&net->xfrm.policy_all));
for (dir = 0; dir < XFRM_POLICY_MAX; dir++) {
struct xfrm_policy_hash *htab;
WARN_ON(!hlist_empty(&net->xfrm.policy_inexact[dir]));
htab = &net->xfrm.policy_bydst[dir];
sz = (htab->hmask + 1) * sizeof(struct hlist_head);
WARN_ON(!hlist_empty(htab->table));
xfrm_hash_free(htab->table, sz);
}
sz = (net->xfrm.policy_idx_hmask + 1) * sizeof(struct hlist_head);
WARN_ON(!hlist_empty(net->xfrm.policy_byidx));
xfrm_hash_free(net->xfrm.policy_byidx, sz);
spin_lock_bh(&net->xfrm.xfrm_policy_lock);
list_for_each_entry_safe(b, t, &net->xfrm.inexact_bins, inexact_bins)
__xfrm_policy_inexact_prune_bin(b, true);
spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
}
| 0
|
343,148
|
static struct ip_esp_hdr *esp_output_set_esn(struct sk_buff *skb,
struct xfrm_state *x,
struct ip_esp_hdr *esph,
struct esp_output_extra *extra)
{
/* For ESN we move the header forward by 4 bytes to
* accomodate the high bits. We will move it back after
* encryption.
*/
if ((x->props.flags & XFRM_STATE_ESN)) {
__u32 seqhi;
struct xfrm_offload *xo = xfrm_offload(skb);
if (xo)
seqhi = xo->seq.hi;
else
seqhi = XFRM_SKB_CB(skb)->seq.output.hi;
extra->esphoff = (unsigned char *)esph -
skb_transport_header(skb);
esph = (struct ip_esp_hdr *)((unsigned char *)esph - 4);
extra->seqhi = esph->spi;
esph->seq_no = htonl(seqhi);
}
esph->spi = x->id.spi;
return esph;
}
| 0
|
259,160
|
static void mov_update_dts_shift(MOVStreamContext *sc, int duration, void *logctx)
{
if (duration < 0) {
if (duration == INT_MIN) {
av_log(logctx, AV_LOG_WARNING, "mov_update_dts_shift(): dts_shift set to %d\n", INT_MAX);
duration++;
}
sc->dts_shift = FFMAX(sc->dts_shift, -duration);
}
}
| 0
|
488,375
|
static void remove_migration_pte(struct vm_area_struct *vma,
struct page *old, struct page *new)
{
struct mm_struct *mm = vma->vm_mm;
swp_entry_t entry;
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
pte_t *ptep, pte;
spinlock_t *ptl;
unsigned long addr = page_address_in_vma(new, vma);
if (addr == -EFAULT)
return;
pgd = pgd_offset(mm, addr);
if (!pgd_present(*pgd))
return;
pud = pud_offset(pgd, addr);
if (!pud_present(*pud))
return;
pmd = pmd_offset(pud, addr);
if (!pmd_present(*pmd))
return;
ptep = pte_offset_map(pmd, addr);
if (!is_swap_pte(*ptep)) {
pte_unmap(ptep);
return;
}
ptl = pte_lockptr(mm, pmd);
spin_lock(ptl);
pte = *ptep;
if (!is_swap_pte(pte))
goto out;
entry = pte_to_swp_entry(pte);
if (!is_migration_entry(entry) || migration_entry_to_page(entry) != old)
goto out;
/*
* Yes, ignore the return value from a GFP_ATOMIC mem_cgroup_charge.
* Failure is not an option here: we're now expected to remove every
* migration pte, and will cause crashes otherwise. Normally this
* is not an issue: mem_cgroup_prepare_migration bumped up the old
* page_cgroup count for safety, that's now attached to the new page,
* so this charge should just be another incrementation of the count,
* to keep in balance with rmap.c's mem_cgroup_uncharging. But if
* there's been a force_empty, those reference counts may no longer
* be reliable, and this charge can actually fail: oh well, we don't
* make the situation any worse by proceeding as if it had succeeded.
*/
mem_cgroup_charge(new, mm, GFP_ATOMIC);
get_page(new);
pte = pte_mkold(mk_pte(new, vma->vm_page_prot));
if (is_write_migration_entry(entry))
pte = pte_mkwrite(pte);
flush_cache_page(vma, addr, pte_pfn(pte));
set_pte_at(mm, addr, ptep, pte);
if (PageAnon(new))
page_add_anon_rmap(new, vma, addr);
else
page_add_file_rmap(new);
/* No need to invalidate - it was non-present before */
update_mmu_cache(vma, addr, pte);
out:
pte_unmap_unlock(ptep, ptl);
}
| 0
|
247,746
|
TEST_P(SslSocketTest, TicketSessionResumptionWithClientCA) {
const std::string server_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
certificate_chain:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem"
private_key:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem"
validation_context:
trusted_ca:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem"
session_ticket_keys:
keys:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ticket_key_a"
)EOF";
const std::string client_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
certificate_chain:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/no_san_cert.pem"
private_key:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/no_san_key.pem"
)EOF";
testTicketSessionResumption(server_ctx_yaml, {}, server_ctx_yaml, {}, client_ctx_yaml, true,
GetParam());
}
| 0
|
476,145
|
int usb_add_function(struct usb_configuration *config,
struct usb_function *function)
{
int value = -EINVAL;
DBG(config->cdev, "adding '%s'/%p to config '%s'/%p\n",
function->name, function,
config->label, config);
if (!function->set_alt || !function->disable)
goto done;
function->config = config;
list_add_tail(&function->list, &config->functions);
if (function->bind_deactivated) {
value = usb_function_deactivate(function);
if (value)
goto done;
}
/* REVISIT *require* function->bind? */
if (function->bind) {
value = function->bind(config, function);
if (value < 0) {
list_del(&function->list);
function->config = NULL;
}
} else
value = 0;
/* We allow configurations that don't work at both speeds.
* If we run into a lowspeed Linux system, treat it the same
* as full speed ... it's the function drivers that will need
* to avoid bulk and ISO transfers.
*/
if (!config->fullspeed && function->fs_descriptors)
config->fullspeed = true;
if (!config->highspeed && function->hs_descriptors)
config->highspeed = true;
if (!config->superspeed && function->ss_descriptors)
config->superspeed = true;
if (!config->superspeed_plus && function->ssp_descriptors)
config->superspeed_plus = true;
done:
if (value)
DBG(config->cdev, "adding '%s'/%p --> %d\n",
function->name, function, value);
return value;
}
| 0
|
226,323
|
GF_Box *rvcc_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_RVCConfigurationBox, GF_ISOM_BOX_TYPE_RVCC);
return (GF_Box *)tmp;
| 0
|
261,213
|
static int MqttClient_RespList_Find(MqttClient *client,
MqttPacketType packet_type, word16 packet_id, MqttPendResp **retResp)
{
int rc = 0;
MqttPendResp *tmpResp;
if (client == NULL)
return MQTT_CODE_ERROR_BAD_ARG;
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("PendResp Find: Type %s (%d), ID %d",
MqttPacket_TypeDesc(packet_type), packet_type, packet_id);
#endif
if (retResp)
*retResp = NULL; /* clear */
/* Find pending response entry */
for (tmpResp = client->firstPendResp;
tmpResp != NULL;
tmpResp = tmpResp->next)
{
if (packet_type == tmpResp->packet_type &&
(packet_id == tmpResp->packet_id))
{
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("PendResp Found: %p, Type %s (%d), ID %d",
tmpResp, MqttPacket_TypeDesc(tmpResp->packet_type),
tmpResp->packet_type, tmpResp->packet_id);
#endif
if (retResp)
*retResp = tmpResp;
rc = 1;
break;
}
}
return rc;
}
| 0
|
506,689
|
static int set_cn_and_email(X509 *crt, const char *name)
{
return set_cn(crt, NID_commonName, name,
NID_pkcs9_emailAddress, "dummy@example.com", 0);
}
| 0
|
309,893
|
main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
_nc_STRCPY(tname, getenv("TERM"), sizeof(tname));
load_term();
_nc_setupscreen(lines, columns, stdout, FALSE, 0);
baudrate();
_nc_mvcur_init();
(void) puts("The mvcur tester. Type ? for help");
fputs("smcup:", stdout);
putchar('\n');
for (;;) {
int fy, fx, ty, tx, n, i;
char buf[BUFSIZ], capname[BUFSIZ];
if (fputs("> ", stdout) == EOF)
break;
if (fgets(buf, sizeof(buf), stdin) == 0)
break;
#define PUTS(s) (void) puts(s)
#define PUTF(s,t) (void) printf(s,t)
if (buf[0] == '?') {
PUTS("? -- display this help message");
PUTS("fy fx ty tx -- (4 numbers) display (fy,fx)->(ty,tx) move");
PUTS("s[croll] n t b m -- display scrolling sequence");
PUTF("r[eload] -- reload terminal info for %s\n",
termname());
PUTS("l[oad] <term> -- load terminal info for type <term>");
PUTS("d[elete] <cap> -- delete named capability");
PUTS("i[nspect] -- display terminal capabilities");
PUTS("c[ost] -- dump cursor-optimization cost table");
PUTS("o[optimize] -- toggle movement optimization");
PUTS("t[orture] <num> -- torture-test with <num> random moves");
PUTS("q[uit] -- quit the program");
} else if (sscanf(buf, "%d %d %d %d", &fy, &fx, &ty, &tx) == 4) {
struct timeval before, after;
putchar('"');
gettimeofday(&before, NULL);
mvcur(fy, fx, ty, tx);
gettimeofday(&after, NULL);
printf("\" (%ld msec)\n",
(long) (after.tv_usec - before.tv_usec
+ (after.tv_sec - before.tv_sec)
* 1000000));
} else if (sscanf(buf, "s %d %d %d %d", &fy, &fx, &ty, &tx) == 4) {
struct timeval before, after;
putchar('"');
gettimeofday(&before, NULL);
_nc_scrolln(fy, fx, ty, tx);
gettimeofday(&after, NULL);
printf("\" (%ld msec)\n",
(long) (after.tv_usec - before.tv_usec + (after.tv_sec -
before.tv_sec)
* 1000000));
} else if (buf[0] == 'r') {
_nc_STRCPY(tname, termname(), sizeof(tname));
load_term();
} else if (sscanf(buf, "l %s", tname) == 1) {
load_term();
} else if (sscanf(buf, "d %s", capname) == 1) {
struct name_table_entry const *np = _nc_find_entry(capname,
_nc_get_hash_table(FALSE));
if (np == NULL)
(void) printf("No such capability as \"%s\"\n", capname);
else {
switch (np->nte_type) {
case BOOLEAN:
cur_term->type.Booleans[np->nte_index] = FALSE;
(void)
printf("Boolean capability `%s' (%d) turned off.\n",
np->nte_name, np->nte_index);
break;
case NUMBER:
cur_term->type.Numbers[np->nte_index] = ABSENT_NUMERIC;
(void) printf("Number capability `%s' (%d) set to -1.\n",
np->nte_name, np->nte_index);
break;
case STRING:
cur_term->type.Strings[np->nte_index] = ABSENT_STRING;
(void) printf("String capability `%s' (%d) deleted.\n",
np->nte_name, np->nte_index);
break;
}
}
} else if (buf[0] == 'i') {
dump_init(NULL, F_TERMINFO, S_TERMINFO,
FALSE, 70, 0, 0, FALSE, FALSE, 0);
dump_entry(&TerminalType(cur_term), FALSE, TRUE, 0, 0);
putchar('\n');
} else if (buf[0] == 'o') {
if (_nc_optimize_enable & OPTIMIZE_MVCUR) {
_nc_optimize_enable &= ~OPTIMIZE_MVCUR;
(void) puts("Optimization is now off.");
} else {
_nc_optimize_enable |= OPTIMIZE_MVCUR;
(void) puts("Optimization is now on.");
}
}
/*
* You can use the `t' test to profile and tune the movement
* optimizer. Use iteration values in three digits or more.
* At above 5000 iterations the profile timing averages are stable
* to within a millisecond or three.
*
* The `overhead' field of the report will help you pick a
* COMPUTE_OVERHEAD figure appropriate for your processor and
* expected line speed. The `total estimated time' is
* computation time plus a character-transmission time
* estimate computed from the number of transmits and the baud
* rate.
*
* Use this together with the `o' command to get a read on the
* optimizer's effectiveness. Compare the total estimated times
* for `t' runs of the same length in both optimized and un-optimized
* modes. As long as the optimized times are less, the optimizer
* is winning.
*/
else if (sscanf(buf, "t %d", &n) == 1) {
float cumtime = 0.0, perchar;
int speeds[] =
{2400, 9600, 14400, 19200, 28800, 38400, 0};
srand((unsigned) (getpid() + time((time_t *) 0)));
profiling = TRUE;
xmits = 0;
for (i = 0; i < n; i++) {
/*
* This does a move test between two random locations,
* Random moves probably short-change the optimizer,
* which will work better on the short moves probably
* typical of doupdate()'s usage pattern. Still,
* until we have better data...
*/
#ifdef FIND_COREDUMP
int from_y = roll(lines);
int to_y = roll(lines);
int from_x = roll(columns);
int to_x = roll(columns);
printf("(%d,%d) -> (%d,%d)\n", from_y, from_x, to_y, to_x);
mvcur(from_y, from_x, to_y, to_x);
#else
mvcur(roll(lines), roll(columns), roll(lines), roll(columns));
#endif /* FIND_COREDUMP */
if (diff)
cumtime += diff;
}
profiling = FALSE;
/*
* Average milliseconds per character optimization time.
* This is the key figure to watch when tuning the optimizer.
*/
perchar = cumtime / n;
(void) printf("%d moves (%ld chars) in %d msec, %f msec each:\n",
n, xmits, (int) cumtime, perchar);
for (i = 0; speeds[i]; i++) {
/*
* Total estimated time for the moves, computation and
* transmission both. Transmission time is an estimate
* assuming 9 bits/char, 8 bits + 1 stop bit.
*/
float totalest = cumtime + xmits * 9 * 1e6 / speeds[i];
/*
* Per-character optimization overhead in character transmits
* at the current speed. Round this to the nearest integer
* to figure COMPUTE_OVERHEAD for the speed.
*/
float overhead = speeds[i] * perchar / 1e6;
(void)
printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n",
speeds[i], overhead, totalest);
}
} else if (buf[0] == 'c') {
(void) printf("char padding: %d\n", CURRENT_SCREEN->_char_padding);
(void) printf("cr cost: %d\n", CURRENT_SCREEN->_cr_cost);
(void) printf("cup cost: %d\n", CURRENT_SCREEN->_cup_cost);
(void) printf("home cost: %d\n", CURRENT_SCREEN->_home_cost);
(void) printf("ll cost: %d\n", CURRENT_SCREEN->_ll_cost);
#if USE_HARD_TABS
(void) printf("ht cost: %d\n", CURRENT_SCREEN->_ht_cost);
(void) printf("cbt cost: %d\n", CURRENT_SCREEN->_cbt_cost);
#endif /* USE_HARD_TABS */
(void) printf("cub1 cost: %d\n", CURRENT_SCREEN->_cub1_cost);
(void) printf("cuf1 cost: %d\n", CURRENT_SCREEN->_cuf1_cost);
(void) printf("cud1 cost: %d\n", CURRENT_SCREEN->_cud1_cost);
(void) printf("cuu1 cost: %d\n", CURRENT_SCREEN->_cuu1_cost);
(void) printf("cub cost: %d\n", CURRENT_SCREEN->_cub_cost);
(void) printf("cuf cost: %d\n", CURRENT_SCREEN->_cuf_cost);
(void) printf("cud cost: %d\n", CURRENT_SCREEN->_cud_cost);
(void) printf("cuu cost: %d\n", CURRENT_SCREEN->_cuu_cost);
(void) printf("hpa cost: %d\n", CURRENT_SCREEN->_hpa_cost);
(void) printf("vpa cost: %d\n", CURRENT_SCREEN->_vpa_cost);
} else if (buf[0] == 'x' || buf[0] == 'q')
break;
else
(void) puts("Invalid command.");
}
(void) fputs("rmcup:", stdout);
_nc_mvcur_wrap();
putchar('\n');
return (0);
}
| 0
|
278,250
|
f_lispindent(typval_T *argvars UNUSED, typval_T *rettv)
{
pos_T pos;
linenr_T lnum;
if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL)
return;
pos = curwin->w_cursor;
lnum = tv_get_lnum(argvars);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
{
curwin->w_cursor.lnum = lnum;
rettv->vval.v_number = get_lisp_indent();
curwin->w_cursor = pos;
}
else if (in_vim9script())
semsg(_(e_invalid_line_number_nr), lnum);
else
rettv->vval.v_number = -1;
}
| 0
|
222,922
|
void VerboseLogUnknownDimensionSources(
const GraphDef& graph,
const absl::flat_hash_map<string, std::vector<OpInfo::TensorProperties>>&
input_properties_map,
const absl::flat_hash_map<string, std::vector<OpInfo::TensorProperties>>&
output_properties_map) {
if (!VLOG_IS_ON(2)) {
return;
}
VLOG(2) << "Nodes with known inputs, but with unknown output dimensions:";
// Find all nodes in the graph for which we
// do not have any unknown dimensions in their inputs, but
// we have some unknown dimensions in their outputs.
std::map<string, int> op_to_count;
for (const NodeDef& node : graph.node()) {
const auto& input_properties = input_properties_map.at(node.name());
const auto& output_properties = output_properties_map.at(node.name());
bool has_unknown_inputs = false;
for (const auto& input_prop : input_properties) {
if (HasAnyUnknownDimensions(input_prop.shape())) {
has_unknown_inputs = true;
break;
}
}
if (has_unknown_inputs) {
continue;
}
for (const auto& output_prop : output_properties) {
if (HasAnyUnknownDimensions(output_prop.shape())) {
string inputs = "input_shapes=[";
for (const auto& input_prop : input_properties) {
inputs += PartialTensorShape::DebugString(input_prop.shape());
}
inputs += "]";
string outputs = "output_shapes=[";
for (const auto& output_prop : output_properties) {
outputs += PartialTensorShape::DebugString(output_prop.shape());
}
outputs += "]";
VLOG(2) << "Node: " << node.name() << ", Op: " << node.op() << ", "
<< inputs << ", " << outputs;
op_to_count[node.op()]++;
// don't log again for this node
break;
}
}
}
VLOG(2) << "Op types with known inputs, but with unknown output dimensions "
<< "(format: <op_type> (<count>)):";
for (const auto& p : op_to_count) {
VLOG(2) << p.first << " (" << p.second << ")";
}
}
| 0
|
211,473
|
read_bitmap_file_data (FILE *fstream,
guint *width,
guint *height,
guchar **data,
int *x_hot,
int *y_hot)
{
guchar *bits = NULL; /* working variable */
char line[MAX_SIZE]; /* input line from file */
int size; /* number of bytes of data */
char name_and_type[MAX_SIZE]; /* an input line */
char *type; /* for parsing */
int value; /* from an input line */
int version10p; /* boolean, old format */
int padding; /* to handle alignment */
int bytes_per_line; /* per scanline of data */
guint ww = 0; /* width */
guint hh = 0; /* height */
int hx = -1; /* x hotspot */
int hy = -1; /* y hotspot */
/* first time initialization */
if (!initialized) {
init_hex_table ();
}
/* error cleanup and return macro */
#define RETURN(code) { g_free (bits); return code; }
while (fgets (line, MAX_SIZE, fstream)) {
if (strlen (line) == MAX_SIZE-1)
RETURN (FALSE);
if (sscanf (line,"#define %s %d",name_and_type,&value) == 2) {
if (!(type = strrchr (name_and_type, '_')))
type = name_and_type;
else {
type++;
}
if (!strcmp ("width", type))
ww = (unsigned int) value;
if (!strcmp ("height", type))
hh = (unsigned int) value;
if (!strcmp ("hot", type)) {
if (type-- == name_and_type
|| type-- == name_and_type)
continue;
if (!strcmp ("x_hot", type))
hx = value;
if (!strcmp ("y_hot", type))
hy = value;
}
continue;
}
if (sscanf (line, "static short %s = {", name_and_type) == 1)
version10p = 1;
else if (sscanf (line,"static const unsigned char %s = {",name_and_type) == 1)
version10p = 0;
else if (sscanf (line,"static unsigned char %s = {",name_and_type) == 1)
version10p = 0;
else if (sscanf (line, "static const char %s = {", name_and_type) == 1)
version10p = 0;
else if (sscanf (line, "static char %s = {", name_and_type) == 1)
version10p = 0;
else
continue;
if (!(type = strrchr (name_and_type, '_')))
type = name_and_type;
else
type++;
if (strcmp ("bits[]", type))
continue;
if (!ww || !hh)
RETURN (FALSE);
if ((ww % 16) && ((ww % 16) < 9) && version10p)
padding = 1;
else
padding = 0;
bytes_per_line = (ww+7)/8 + padding;
size = bytes_per_line * hh;
bits = g_malloc (size);
if (version10p) {
unsigned char *ptr;
int bytes;
for (bytes = 0, ptr = bits; bytes < size; (bytes += 2)) {
if ((value = next_int (fstream)) < 0)
RETURN (FALSE);
*(ptr++) = value;
if (!padding || ((bytes+2) % bytes_per_line))
*(ptr++) = value >> 8;
}
} else {
unsigned char *ptr;
int bytes;
for (bytes = 0, ptr = bits; bytes < size; bytes++, ptr++) {
if ((value = next_int (fstream)) < 0)
RETURN (FALSE);
*ptr=value;
}
}
break;
}
if (!bits)
RETURN (FALSE);
*data = bits;
*width = ww;
*height = hh;
if (x_hot)
*x_hot = hx;
if (y_hot)
*y_hot = hy;
return TRUE;
}
| 1
|
238,816
|
f_searchcount(typval_T *argvars, typval_T *rettv)
{
pos_T pos = curwin->w_cursor;
char_u *pattern = NULL;
int maxcount = SEARCH_STAT_DEF_MAX_COUNT;
long timeout = SEARCH_STAT_DEF_TIMEOUT;
int recompute = TRUE;
searchstat_T stat;
if (rettv_dict_alloc(rettv) == FAIL)
return;
if (in_vim9script() && check_for_opt_dict_arg(argvars, 0) == FAIL)
return;
if (shortmess(SHM_SEARCHCOUNT)) // 'shortmess' contains 'S' flag
recompute = TRUE;
if (argvars[0].v_type != VAR_UNKNOWN)
{
dict_T *dict;
dictitem_T *di;
listitem_T *li;
int error = FALSE;
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)
{
emsg(_(e_dictionary_required));
return;
}
dict = argvars[0].vval.v_dict;
di = dict_find(dict, (char_u *)"timeout", -1);
if (di != NULL)
{
timeout = (long)tv_get_number_chk(&di->di_tv, &error);
if (error)
return;
}
di = dict_find(dict, (char_u *)"maxcount", -1);
if (di != NULL)
{
maxcount = (int)tv_get_number_chk(&di->di_tv, &error);
if (error)
return;
}
recompute = dict_get_bool(dict, (char_u *)"recompute", recompute);
di = dict_find(dict, (char_u *)"pattern", -1);
if (di != NULL)
{
pattern = tv_get_string_chk(&di->di_tv);
if (pattern == NULL)
return;
}
di = dict_find(dict, (char_u *)"pos", -1);
if (di != NULL)
{
if (di->di_tv.v_type != VAR_LIST)
{
semsg(_(e_invalid_argument_str), "pos");
return;
}
if (list_len(di->di_tv.vval.v_list) != 3)
{
semsg(_(e_invalid_argument_str), "List format should be [lnum, col, off]");
return;
}
li = list_find(di->di_tv.vval.v_list, 0L);
if (li != NULL)
{
pos.lnum = tv_get_number_chk(&li->li_tv, &error);
if (error)
return;
}
li = list_find(di->di_tv.vval.v_list, 1L);
if (li != NULL)
{
pos.col = tv_get_number_chk(&li->li_tv, &error) - 1;
if (error)
return;
}
li = list_find(di->di_tv.vval.v_list, 2L);
if (li != NULL)
{
pos.coladd = tv_get_number_chk(&li->li_tv, &error);
if (error)
return;
}
}
}
save_last_search_pattern();
#ifdef FEAT_SEARCH_EXTRA
save_incsearch_state();
#endif
if (pattern != NULL)
{
if (*pattern == NUL)
goto the_end;
vim_free(spats[last_idx].pat);
spats[last_idx].pat = vim_strsave(pattern);
}
if (spats[last_idx].pat == NULL || *spats[last_idx].pat == NUL)
goto the_end; // the previous pattern was never defined
update_search_stat(0, &pos, &pos, &stat, recompute, maxcount, timeout);
dict_add_number(rettv->vval.v_dict, "current", stat.cur);
dict_add_number(rettv->vval.v_dict, "total", stat.cnt);
dict_add_number(rettv->vval.v_dict, "exact_match", stat.exact_match);
dict_add_number(rettv->vval.v_dict, "incomplete", stat.incomplete);
dict_add_number(rettv->vval.v_dict, "maxcount", stat.last_maxcount);
the_end:
restore_last_search_pattern();
#ifdef FEAT_SEARCH_EXTRA
restore_incsearch_state();
#endif
}
| 0
|
281,640
|
void CLASS lossless_jpeg_load_raw()
{
int jwide, jrow, jcol, val, jidx, i, j, row=0, col=0;
struct jhead jh;
ushort *rp;
if (!ljpeg_start (&jh, 0)) return;
if(jh.wide<1 || jh.high<1 || jh.clrs<1 || jh.bits <1)
#ifdef LIBRAW_LIBRARY_BUILD
throw LIBRAW_EXCEPTION_IO_CORRUPT;
#else
longjmp (failure, 2);
#endif
jwide = jh.wide * jh.clrs;
#ifdef LIBRAW_LIBRARY_BUILD
try {
#endif
for (jrow=0; jrow < jh.high; jrow++) {
#ifdef LIBRAW_LIBRARY_BUILD
checkCancel();
#endif
rp = ljpeg_row (jrow, &jh);
if (load_flags & 1)
row = jrow & 1 ? height-1-jrow/2 : jrow/2;
for (jcol=0; jcol < jwide; jcol++) {
val = curve[*rp++];
if (cr2_slice[0]) {
jidx = jrow*jwide + jcol;
i = jidx / (cr2_slice[1]*jh.high);
if ((j = i >= cr2_slice[0]))
i = cr2_slice[0];
jidx -= i * (cr2_slice[1]*jh.high);
row = jidx / cr2_slice[1+j];
col = jidx % cr2_slice[1+j] + i*cr2_slice[1];
}
if (raw_width == 3984 && (col -= 2) < 0)
col += (row--,raw_width);
if(row>raw_height)
#ifdef LIBRAW_LIBRARY_BUILD
throw LIBRAW_EXCEPTION_IO_CORRUPT;
#else
longjmp (failure, 3);
#endif
if ((unsigned) row < raw_height) RAW(row,col) = val;
if (++col >= raw_width)
col = (row++,0);
}
}
#ifdef LIBRAW_LIBRARY_BUILD
} catch (...) {
ljpeg_end (&jh);
throw;
}
#endif
ljpeg_end (&jh);
}
| 0
|
175,782
|
const OriginInfoTableEntries& origin_info_entries() const {
return origin_info_entries_;
}
| 0
|
309,906
|
color_content(NCURSES_COLOR_T color,
NCURSES_COLOR_T *r,
NCURSES_COLOR_T *g,
NCURSES_COLOR_T *b)
{
return NCURSES_SP_NAME(color_content) (CURRENT_SCREEN, color, r, g, b);
}
| 0
|
301,376
|
static NTSTATUS vfswrap_durable_disconnect(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const DATA_BLOB old_cookie,
TALLOC_CTX *mem_ctx,
DATA_BLOB *new_cookie)
{
return vfs_default_durable_disconnect(fsp, old_cookie, mem_ctx,
new_cookie);
}
| 0
|
221,170
|
void gf_odf_vvc_cfg_del(GF_VVCConfig *cfg)
{
if (!cfg) return;
while (gf_list_count(cfg->param_array)) {
GF_NALUFFParamArray *pa = (GF_NALUFFParamArray*)gf_list_get(cfg->param_array, 0);
gf_list_rem(cfg->param_array, 0);
while (gf_list_count(pa->nalus)) {
GF_NALUFFParam *n = (GF_NALUFFParam*)gf_list_get(pa->nalus, 0);
gf_list_rem(pa->nalus, 0);
if (n->data) gf_free(n->data);
gf_free(n);
}
gf_list_del(pa->nalus);
gf_free(pa);
}
gf_list_del(cfg->param_array);
if (cfg->general_constraint_info)
gf_free(cfg->general_constraint_info);
if (cfg->sub_profiles_idc)
gf_free(cfg->sub_profiles_idc);
gf_free(cfg);
}
| 0
|
240,604
|
explicit AssignVariableOp(OpKernelConstruction* c) : OpKernel(c) {
OP_REQUIRES_OK(c, c->GetAttr("dtype", &dtype_));
OP_REQUIRES(c, dtype_ == DT_VARIANT,
errors::Internal("Variant kernel called with dtype: ",
DataTypeString(dtype_)));
}
| 0
|
261,964
|
njs_string_prototype_trim(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
njs_index_t mode)
{
uint32_t u, trim, length;
njs_int_t ret;
njs_value_t *value;
const u_char *p, *prev, *start, *end;
njs_string_prop_t string;
njs_unicode_decode_t ctx;
value = njs_argument(args, 0);
ret = njs_string_object_validate(vm, value);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
trim = 0;
njs_string_prop(&string, value);
start = string.start;
end = string.start + string.size;
if (njs_is_byte_or_ascii_string(&string)) {
if (mode & NJS_TRIM_START) {
for ( ;; ) {
if (start == end) {
goto empty;
}
if (njs_is_whitespace(*start)) {
start++;
trim++;
continue;
}
break;
}
}
if (mode & NJS_TRIM_END) {
for ( ;; ) {
if (start == end) {
goto empty;
}
end--;
if (njs_is_whitespace(*end)) {
trim++;
continue;
}
end++;
break;
}
}
} else {
/* UTF-8 string. */
if (mode & NJS_TRIM_START) {
njs_utf8_decode_init(&ctx);
for ( ;; ) {
if (start == end) {
goto empty;
}
p = start;
u = njs_utf8_decode(&ctx, &start, end);
if (njs_utf8_is_whitespace(u)) {
trim++;
continue;
}
start = p;
break;
}
}
if (mode & NJS_TRIM_END) {
prev = end;
njs_utf8_decode_init(&ctx);
for ( ;; ) {
if (start == prev) {
goto empty;
}
prev = njs_utf8_prev(prev);
p = prev;
u = njs_utf8_decode(&ctx, &p, end);
if (njs_utf8_is_whitespace(u)) {
trim++;
continue;
}
end = p;
break;
}
}
}
if (trim == 0) {
/* GC: retain. */
vm->retval = *value;
return NJS_OK;
}
length = (string.length != 0) ? string.length - trim : 0;
return njs_string_new(vm, &vm->retval, start, end - start, length);
empty:
vm->retval = njs_string_empty;
return NJS_OK;
}
| 0
|
439,087
|
static MagickBooleanType WritePALMImage(const ImageInfo *image_info,
Image *image)
{
ExceptionInfo
*exception;
MagickBooleanType
status;
MagickOffsetType
currentOffset,
offset,
scene;
MagickSizeType
cc;
PixelPacket
transpix;
QuantizeInfo
*quantize_info;
register IndexPacket
*indexes;
register ssize_t
x;
register PixelPacket
*p;
ssize_t
y;
size_t
count,
bits_per_pixel,
bytes_per_row,
imageListLength,
nextDepthOffset,
one;
unsigned char
bit,
byte,
color,
*last_row,
*one_row,
*ptr,
version;
unsigned int
transparentIndex;
unsigned short
color16,
flags;
/*
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
exception=AcquireExceptionInfo();
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
quantize_info=AcquireQuantizeInfo(image_info);
flags=0;
currentOffset=0;
transparentIndex=0;
transpix.red=0;
transpix.green=0;
transpix.blue=0;
transpix.opacity=0;
one=1;
version=0;
scene=0;
imageListLength=GetImageListLength(image);
do
{
(void) TransformImageColorspace(image,sRGBColorspace);
count=GetNumberColors(image,NULL,exception);
for (bits_per_pixel=1; (one << bits_per_pixel) < count; bits_per_pixel*=2) ;
if (bits_per_pixel > 16)
bits_per_pixel=16;
else
if (bits_per_pixel < 16)
(void) TransformImageColorspace(image,image->colorspace);
if (bits_per_pixel < 8)
{
(void) TransformImageColorspace(image,GRAYColorspace);
(void) SetImageType(image,PaletteType);
(void) SortColormapByIntensity(image);
}
if ((image->storage_class == PseudoClass) && (image->colors > 256))
(void) SetImageStorageClass(image,DirectClass);
if (image->storage_class == PseudoClass)
flags|=PALM_HAS_COLORMAP_FLAG;
else
flags|=PALM_IS_DIRECT_COLOR;
(void) WriteBlobMSBShort(image,(unsigned short) image->columns); /* width */
(void) WriteBlobMSBShort(image,(unsigned short) image->rows); /* height */
bytes_per_row=((image->columns+(16/bits_per_pixel-1))/(16/
bits_per_pixel))*2;
(void) WriteBlobMSBShort(image,(unsigned short) bytes_per_row);
if ((image_info->compression == RLECompression) ||
(image_info->compression == FaxCompression))
flags|=PALM_IS_COMPRESSED_FLAG;
(void) WriteBlobMSBShort(image, flags);
(void) WriteBlobByte(image,(unsigned char) bits_per_pixel);
if (bits_per_pixel > 1)
version=1;
if ((image_info->compression == RLECompression) ||
(image_info->compression == FaxCompression))
version=2;
(void) WriteBlobByte(image,version);
(void) WriteBlobMSBShort(image,0); /* nextDepthOffset */
(void) WriteBlobByte(image,(unsigned char) transparentIndex);
if (image_info->compression == RLECompression)
(void) WriteBlobByte(image,PALM_COMPRESSION_RLE);
else
if (image_info->compression == FaxCompression)
(void) WriteBlobByte(image,PALM_COMPRESSION_SCANLINE);
else
(void) WriteBlobByte(image,PALM_COMPRESSION_NONE);
(void) WriteBlobMSBShort(image,0); /* reserved */
offset=16;
if (bits_per_pixel == 16)
{
(void) WriteBlobByte(image,5); /* # of bits of red */
(void) WriteBlobByte(image,6); /* # of bits of green */
(void) WriteBlobByte(image,5); /* # of bits of blue */
(void) WriteBlobByte(image,0); /* reserved by Palm */
(void) WriteBlobMSBLong(image,0); /* no transparent color, YET */
offset+=8;
}
if (bits_per_pixel == 8)
{
if (flags & PALM_HAS_COLORMAP_FLAG) /* Write out colormap */
{
quantize_info->dither=IsPaletteImage(image,&image->exception);
quantize_info->number_colors=image->colors;
(void) QuantizeImage(quantize_info,image);
(void) WriteBlobMSBShort(image,(unsigned short) image->colors);
for (count = 0; count < image->colors; count++)
{
(void) WriteBlobByte(image,(unsigned char) count);
(void) WriteBlobByte(image,ScaleQuantumToChar(
image->colormap[count].red));
(void) WriteBlobByte(image,
ScaleQuantumToChar(image->colormap[count].green));
(void) WriteBlobByte(image,
ScaleQuantumToChar(image->colormap[count].blue));
}
offset+=2+count*4;
}
else /* Map colors to Palm standard colormap */
{
Image
*affinity_image;
affinity_image=ConstituteImage(256,1,"RGB",CharPixel,&PalmPalette,
exception);
(void) TransformImageColorspace(affinity_image,
affinity_image->colorspace);
(void) RemapImage(quantize_info,image,affinity_image);
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetAuthenticPixels(image,0,y,image->columns,1,exception);
indexes=GetAuthenticIndexQueue(image);
for (x=0; x < (ssize_t) image->columns; x++)
SetPixelIndex(indexes+x,FindColor(&image->colormap[
(ssize_t) GetPixelIndex(indexes+x)]));
}
affinity_image=DestroyImage(affinity_image);
}
}
if (flags & PALM_IS_COMPRESSED_FLAG)
(void) WriteBlobMSBShort(image,0); /* fill in size later */
last_row=(unsigned char *) NULL;
if (image_info->compression == FaxCompression)
{
last_row=(unsigned char *) AcquireQuantumMemory(bytes_per_row,
sizeof(*last_row));
if (last_row == (unsigned char *) NULL)
{
quantize_info=DestroyQuantizeInfo(quantize_info);
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
}
}
one_row=(unsigned char *) AcquireQuantumMemory(bytes_per_row,
sizeof(*one_row));
if (one_row == (unsigned char *) NULL)
{
if (last_row != (unsigned char *) NULL)
last_row=(unsigned char *) RelinquishMagickMemory(last_row);
quantize_info=DestroyQuantizeInfo(quantize_info);
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
}
for (y=0; y < (ssize_t) image->rows; y++)
{
ptr=one_row;
(void) memset(ptr,0,bytes_per_row);
p=GetAuthenticPixels(image,0,y,image->columns,1,exception);
if (p == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
if (bits_per_pixel == 16)
{
for (x=0; x < (ssize_t) image->columns; x++)
{
color16=(unsigned short) ((((31*(size_t) GetPixelRed(p))/
(size_t) QuantumRange) << 11) |
(((63*(size_t) GetPixelGreen(p))/(size_t) QuantumRange) << 5) |
((31*(size_t) GetPixelBlue(p))/(size_t) QuantumRange));
if (GetPixelOpacity(p) == (Quantum) TransparentOpacity)
{
transpix.red=GetPixelRed(p);
transpix.green=GetPixelGreen(p);
transpix.blue=GetPixelBlue(p);
transpix.opacity=GetPixelOpacity(p);
flags|=PALM_HAS_TRANSPARENCY_FLAG;
}
*ptr++=(unsigned char) ((color16 >> 8) & 0xff);
*ptr++=(unsigned char) (color16 & 0xff);
p++;
}
}
else
{
byte=0x00;
bit=(unsigned char) (8-bits_per_pixel);
for (x=0; x < (ssize_t) image->columns; x++)
{
if (bits_per_pixel >= 8)
color=(unsigned char) GetPixelIndex(indexes+x);
else
color=(unsigned char) (GetPixelIndex(indexes+x)*
((one << bits_per_pixel)-1)/MagickMax(1*image->colors-1,1));
byte|=color << bit;
if (bit != 0)
bit-=(unsigned char) bits_per_pixel;
else
{
*ptr++=byte;
byte=0x00;
bit=(unsigned char) (8-bits_per_pixel);
}
}
if ((image->columns % (8/bits_per_pixel)) != 0)
*ptr++=byte;
}
if (image_info->compression == RLECompression)
{
x=0;
while (x < (ssize_t) bytes_per_row)
{
byte=one_row[x];
count=1;
while ((one_row[++x] == byte) && (count < 255) &&
(x < (ssize_t) bytes_per_row))
count++;
(void) WriteBlobByte(image,(unsigned char) count);
(void) WriteBlobByte(image,(unsigned char) byte);
}
}
else
if (image_info->compression == FaxCompression)
{
char
tmpbuf[8],
*tptr;
for (x = 0; x < (ssize_t) bytes_per_row; x += 8)
{
tptr = tmpbuf;
for (bit=0, byte=0; bit < (unsigned char) MagickMin(8,(ssize_t) bytes_per_row-x); bit++)
{
if ((y == 0) || (last_row[x + bit] != one_row[x + bit]))
{
byte |= (1 << (7 - bit));
*tptr++ = (char) one_row[x + bit];
}
}
(void) WriteBlobByte(image, byte);
(void) WriteBlob(image,tptr-tmpbuf,(unsigned char *) tmpbuf);
}
(void) memcpy(last_row,one_row,bytes_per_row);
}
else
(void) WriteBlob(image,bytes_per_row,one_row);
}
if (flags & PALM_HAS_TRANSPARENCY_FLAG)
{
offset=SeekBlob(image,currentOffset+6,SEEK_SET);
(void) WriteBlobMSBShort(image,flags);
offset=SeekBlob(image,currentOffset+12,SEEK_SET);
(void) WriteBlobByte(image,(unsigned char) transparentIndex); /* trans index */
}
if (bits_per_pixel == 16)
{
offset=SeekBlob(image,currentOffset+20,SEEK_SET);
(void) WriteBlobByte(image,0); /* reserved by Palm */
(void) WriteBlobByte(image,(unsigned char) ((31*transpix.red)/
QuantumRange));
(void) WriteBlobByte(image,(unsigned char) ((63*transpix.green)/
QuantumRange));
(void) WriteBlobByte(image,(unsigned char) ((31*transpix.blue)/
QuantumRange));
}
if (flags & PALM_IS_COMPRESSED_FLAG) /* fill in size now */
{
offset=SeekBlob(image,currentOffset+offset,SEEK_SET);
(void) WriteBlobMSBShort(image,(unsigned short) (GetBlobSize(image)-
currentOffset-offset));
}
if (one_row != (unsigned char *) NULL)
one_row=(unsigned char *) RelinquishMagickMemory(one_row);
if (last_row != (unsigned char *) NULL)
last_row=(unsigned char *) RelinquishMagickMemory(last_row);
if (GetNextImageInList(image) == (Image *) NULL)
break;
/* padding to 4 byte word */
for (cc=(GetBlobSize(image)) % 4; cc > 0; cc--)
(void) WriteBlobByte(image,0);
/* write nextDepthOffset and return to end of image */
(void) SeekBlob(image,currentOffset+10,SEEK_SET);
nextDepthOffset=(size_t) ((GetBlobSize(image)-currentOffset)/4);
(void) WriteBlobMSBShort(image,(unsigned short) nextDepthOffset);
currentOffset=(MagickOffsetType) GetBlobSize(image);
(void) SeekBlob(image,currentOffset,SEEK_SET);
image=SyncNextImageInList(image);
status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);
if (status == MagickFalse)
break;
} while (image_info->adjoin != MagickFalse);
quantize_info=DestroyQuantizeInfo(quantize_info);
(void) CloseBlob(image);
(void) DestroyExceptionInfo(exception);
return(MagickTrue);
}
| 0
|
301,386
|
static int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
{
#ifdef HAVE_NO_ACL
errno = ENOSYS;
return -1;
#else
int result;
START_PROFILE(fchmod_acl);
result = fchmod_acl(fsp, mode);
END_PROFILE(fchmod_acl);
return result;
#endif
}
| 0
|
437,356
|
is_good_case_fold_items_for_search(OnigEncoding enc, int slen,
int n, OnigCaseFoldCodeItem items[])
{
int i, len;
UChar buf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
for (i = 0; i < n; i++) {
OnigCaseFoldCodeItem* item = items + i;
if (item->code_len != 1) return 0;
if (item->byte_len != slen) return 0;
len = ONIGENC_CODE_TO_MBC(enc, item->code[0], buf);
if (len != slen) return 0;
}
return 1;
}
| 0
|
352,974
|
countryStringValidate(
Syntax *syntax,
struct berval *val )
{
if( val->bv_len != 2 ) return LDAP_INVALID_SYNTAX;
if( !SLAP_PRINTABLE(val->bv_val[0]) ) {
return LDAP_INVALID_SYNTAX;
}
if( !SLAP_PRINTABLE(val->bv_val[1]) ) {
return LDAP_INVALID_SYNTAX;
}
return LDAP_SUCCESS;
}
| 0
|
231,704
|
auto& lossTimeout() {
return lossTimeout_;
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.