processed_func string | target int64 | flaw_line string | flaw_line_index int64 | commit_url string | language class label |
|---|---|---|---|---|---|
static void io_clean_op(struct io_kiocb *req)
{
if (req->flags & REQ_F_BUFFER_SELECTED) {
spin_lock(&req->ctx->completion_lock);
io_put_kbuf_comp(req);
spin_unlock(&req->ctx->completion_lock);
}
if (req->flags & REQ_F_NEED_CLEANUP) {
switch (req->opcode) {
case IORING_OP_READV:
case IORING_OP_READ_FIXED:
case IORING_OP_READ:
case IORING_OP_WRITEV:
case IORING_OP_WRITE_FIXED:
case IORING_OP_WRITE: {
struct io_async_rw *io = req->async_data;
kfree(io->free_iovec);
break;
}
case IORING_OP_RECVMSG:
case IORING_OP_SENDMSG: {
struct io_async_msghdr *io = req->async_data;
kfree(io->free_iov);
break;
}
case IORING_OP_OPENAT:
case IORING_OP_OPENAT2:
if (req->open.filename)
putname(req->open.filename);
break;
case IORING_OP_RENAMEAT:
putname(req->rename.oldpath);
putname(req->rename.newpath);
break;
case IORING_OP_UNLINKAT:
putname(req->unlink.filename);
break;
case IORING_OP_MKDIRAT:
putname(req->mkdir.filename);
break;
case IORING_OP_SYMLINKAT:
putname(req->symlink.oldpath);
putname(req->symlink.newpath);
break;
case IORING_OP_LINKAT:
putname(req->hardlink.oldpath);
putname(req->hardlink.newpath);
break;
case IORING_OP_STATX:
if (req->statx.filename)
putname(req->statx.filename);
break;
}
}
if ((req->flags & REQ_F_POLLED) && req->apoll) {
kfree(req->apoll->double_poll);
kfree(req->apoll);
req->apoll = NULL;
}
if (req->flags & REQ_F_CREDS)
put_cred(req->creds);
if (req->flags & REQ_F_ASYNC_DATA) {
kfree(req->async_data);
req->async_data = NULL;
}
req->flags &= ~IO_REQ_CLEAN_FLAGS; | 0 | null | -1 | https://github.com/torvalds/linux/commit/e677edbcabee849bfdd43f1602bccbecf736a646 | 0CCPP |
public WebSocketEventListener(List<IPEndPoint> endpoints, WebSocketListenerOptions options)
{
foreach (var endpoint in endpoints)
{
var listener = new WebSocketListener(endpoint, options);
var rfc6455 = new WebSocketFactoryRfc6455(listener);
listener.Standards.RegisterStandard(rfc6455);
_listeners.Add(listener);
}
} | 1 | 0,2,3,4,5,6,7,8 | -1 | https://github.com/Ulterius/server/commit/770d1821de43cf1d0a93c79025995bdd812a76ee | 1CS |
function(aa){T--;N()}),!0,null,"data:"+Z+";charset=utf-8;base64,")}))}})(Editor.trimCssUrl(J[u].substring(0,Q)),R)}N()}else E(u)};Editor.prototype.loadFonts=function(u){null!=this.fontCss&&null==this.resolvedFontCss?this.embedCssFonts(this.fontCss,mxUtils.bind(this,function(E){this.resolvedFontCss=E;null!=u&&u()})):null!=u&&u()};Editor.prototype.createGoogleFontCache=function(){var u={},E;for(E in Graph.fontMapping)Graph.isCssFontUrl(E)&&(u[E]=Graph.fontMapping[E]);return u};Editor.prototype.embedExtFonts= | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
function editComment(comment, cdiv, saveCallback, deleteOnCancel)
{
curEdited = {div: cdiv, comment: comment, saveCallback: saveCallback, deleteOnCancel: deleteOnCancel};
var commentTxt = cdiv.querySelector('.geCommentTxt');
var actionsDiv = cdiv.querySelector('.geCommentActionsList');
var textArea = document.createElement('textarea');
textArea.className = 'geCommentEditTxtArea';
textArea.style.minHeight = commentTxt.offsetHeight + 'px';
textArea.value = comment.content;
cdiv.insertBefore(textArea, commentTxt);
var btnDiv = document.createElement('div');
btnDiv.className = 'geCommentEditBtns';
function reset()
{
cdiv.removeChild(textArea);
cdiv.removeChild(btnDiv);
actionsDiv.style.display = 'block';
commentTxt.style.display = 'block';
};
var cancelBtn = mxUtils.button(mxResources.get('cancel'), function()
{
if (deleteOnCancel)
{
cdiv.parentNode.removeChild(cdiv);
updateNoComments();
}
else
{
reset();
}
curEdited = null;
});
cancelBtn.className = 'geCommentEditBtn';
btnDiv.appendChild(cancelBtn);
var saveBtn = mxUtils.button(mxResources.get('save'), function()
{
commentTxt.innerHTML = '';
comment.content = textArea.value;
mxUtils.write(commentTxt, comment.content);
reset();
saveCallback(comment);
curEdited = null;
});
mxEvent.addListener(textArea, 'keydown', mxUtils.bind(this, function(evt)
{
if (!mxEvent.isConsumed(evt))
{
if ((mxEvent.isControlDown(evt) || (mxClient.IS_MAC &&
mxEvent.isMetaDown(evt))) && evt.keyCode == 13 )
{
saveBtn.click();
mxEvent.consume(evt);
}
else if (evt.keyCode == 27 )
{
cancelBtn.click();
mxEvent.consume(evt);
}
}
}));
saveBtn.focus();
saveBtn.className = 'geCommentEditBtn gePrimaryBtn';
btnDiv.appendChild(saveBtn);
cdiv.insertBefore(btnDiv, commentTxt);
actionsDiv.style.display = 'none';
commentTxt.style.display = 'none';
textArea.focus();
}; | 1 | 36 | -1 | https://github.com/jgraph/drawio/commit/3d3f819d7a04da7d53b37cc0ca4269c157ba2825 | 3JavaScript |
nvmet_fc_rcv_ls_req(struct nvmet_fc_target_port *target_port,
struct nvmefc_tgt_ls_req *lsreq,
void *lsreqbuf, u32 lsreqbuf_len)
{
struct nvmet_fc_tgtport *tgtport = targetport_to_tgtport(target_port);
struct nvmet_fc_ls_iod *iod;
if (lsreqbuf_len > NVME_FC_MAX_LS_BUFFER_SIZE)
return -E2BIG;
if (!nvmet_fc_tgtport_get(tgtport))
return -ESHUTDOWN;
iod = nvmet_fc_alloc_ls_iod(tgtport);
if (!iod) {
nvmet_fc_tgtport_put(tgtport);
return -ENOENT;
}
iod->lsreq = lsreq;
iod->fcpreq = NULL;
memcpy(iod->rqstbuf, lsreqbuf, lsreqbuf_len);
iod->rqstdatalen = lsreqbuf_len;
schedule_work(&iod->work);
return 0;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/0c319d3a144d4b8f1ea2047fd614d2149b68f889 | 0CCPP |
expression: function() {
return this.assignment();
}, | 1 | 0,1,2 | -1 | https://github.com/peerigon/angular-expressions/commit/061addfb9a9e932a970e5fcb913d020038e65667 | 3JavaScript |
this.exec = function() {
return this.fm.history.forward();
} | 1 | 0,1,2 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
{},J=u.vertices,T=u.edges,N=0;N<J.length;N++)this.findCommonProperties(J[N],E,0==N);for(N=0;N<T.length;N++)this.findCommonProperties(T[N],E,0==J.length&&0==N);null!=Object.getOwnPropertyNames&&0<Object.getOwnPropertyNames(E).length&&this.container.appendChild(this.addProperties(this.createPanel(),E,u))}};var y=StyleFormatPanel.prototype.addStyleOps;StyleFormatPanel.prototype.addStyleOps=function(u){this.addActions(u,["copyStyle","pasteStyle"]);return y.apply(this,arguments)};EditorUi.prototype.propertiesCollapsed= | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
static int pad_pkcs2(bn_t m, int *p_len, int m_len, int k_len, int operation) {
uint8_t pad, h1[RLC_MD_LEN], h2[RLC_MD_LEN];
uint8_t *mask = RLC_ALLOCA(uint8_t, k_len);
int result = RLC_OK;
bn_t t;
bn_null(t);
RLC_TRY {
bn_new(t);
switch (operation) {
case RSA_ENC:
md_map(h1, NULL, 0);
bn_read_bin(m, h1, RLC_MD_LEN);
*p_len = k_len - 2 * RLC_MD_LEN - 2 - m_len;
bn_lsh(m, m, *p_len * 8);
bn_lsh(m, m, 8);
bn_add_dig(m, m, 0x01);
bn_lsh(m, m, m_len * 8);
break;
case RSA_ENC_FIN:
rand_bytes(h1, RLC_MD_LEN);
md_mgf(mask, k_len - RLC_MD_LEN - 1, h1, RLC_MD_LEN);
bn_read_bin(t, mask, k_len - RLC_MD_LEN - 1);
for (int i = 0; i < t->used; i++) {
m->dp[i] ^= t->dp[i];
}
bn_write_bin(mask, k_len - RLC_MD_LEN - 1, m);
md_mgf(h2, RLC_MD_LEN, mask, k_len - RLC_MD_LEN - 1);
for (int i = 0; i < RLC_MD_LEN; i++) {
h1[i] ^= h2[i];
}
bn_read_bin(t, h1, RLC_MD_LEN);
bn_lsh(t, t, 8 * (k_len - RLC_MD_LEN - 1));
bn_add(t, t, m);
bn_copy(m, t);
break;
case RSA_DEC:
m_len = k_len - 1;
bn_rsh(t, m, 8 * m_len);
if (!bn_is_zero(t)) {
result = RLC_ERR;
}
m_len -= RLC_MD_LEN;
bn_rsh(t, m, 8 * m_len);
bn_write_bin(h1, RLC_MD_LEN, t);
bn_mod_2b(m, m, 8 * m_len);
bn_write_bin(mask, m_len, m);
md_mgf(h2, RLC_MD_LEN, mask, m_len);
for (int i = 0; i < RLC_MD_LEN; i++) {
h1[i] ^= h2[i];
}
md_mgf(mask, k_len - RLC_MD_LEN - 1, h1, RLC_MD_LEN);
bn_read_bin(t, mask, k_len - RLC_MD_LEN - 1);
for (int i = 0; i < t->used; i++) {
m->dp[i] ^= t->dp[i];
}
m_len -= RLC_MD_LEN;
bn_rsh(t, m, 8 * m_len);
bn_write_bin(h2, RLC_MD_LEN, t);
md_map(h1, NULL, 0);
pad = 0;
for (int i = 0; i < RLC_MD_LEN; i++) {
pad |= h1[i] - h2[i];
}
if (result == RLC_OK) {
result = (pad ? RLC_ERR : RLC_OK);
}
bn_mod_2b(m, m, 8 * m_len);
*p_len = bn_size_bin(m);
(*p_len)--;
bn_rsh(t, m, *p_len * 8);
if (bn_cmp_dig(t, 1) != RLC_EQ) {
result = RLC_ERR;
}
bn_mod_2b(m, m, *p_len * 8);
*p_len = k_len - *p_len;
break;
case RSA_SIG:
case RSA_SIG_HASH:
bn_zero(m);
bn_lsh(m, m, 64);
bn_lsh(m, m, RLC_MD_LEN * 8);
break;
case RSA_SIG_FIN:
memset(mask, 0, 8);
bn_write_bin(mask + 8, RLC_MD_LEN, m);
md_map(h1, mask, RLC_MD_LEN + 8);
bn_read_bin(m, h1, RLC_MD_LEN);
md_mgf(mask, k_len - RLC_MD_LEN - 1, h1, RLC_MD_LEN);
bn_read_bin(t, mask, k_len - RLC_MD_LEN - 1);
t->dp[0] ^= 0x01;
bn_lsh(t, t, 8 * RLC_MD_LEN);
bn_add(m, t, m);
bn_lsh(m, m, 8);
bn_add_dig(m, m, RSA_PSS);
for (int i = m_len - 1; i < 8 * k_len; i++) {
bn_set_bit(m, i, 0);
}
break;
case RSA_VER:
case RSA_VER_HASH:
bn_mod_2b(t, m, 8);
if (bn_cmp_dig(t, RSA_PSS) != RLC_EQ) {
result = RLC_ERR;
} else {
for (int i = m_len; i < 8 * k_len; i++) {
if (bn_get_bit(m, i) != 0) {
result = RLC_ERR;
}
}
bn_rsh(m, m, 8);
bn_mod_2b(t, m, 8 * RLC_MD_LEN);
bn_write_bin(h2, RLC_MD_LEN, t);
bn_rsh(m, m, 8 * RLC_MD_LEN);
bn_write_bin(h1, RLC_MD_LEN, t);
md_mgf(mask, k_len - RLC_MD_LEN - 1, h1, RLC_MD_LEN);
bn_read_bin(t, mask, k_len - RLC_MD_LEN - 1);
for (int i = 0; i < t->used; i++) {
m->dp[i] ^= t->dp[i];
}
m->dp[0] ^= 0x01;
for (int i = m_len - 1; i < 8 * k_len; i++) {
bn_set_bit(m, i - ((RLC_MD_LEN + 1) * 8), 0);
}
if (!bn_is_zero(m)) {
result = RLC_ERR;
}
bn_read_bin(m, h2, RLC_MD_LEN);
*p_len = k_len - RLC_MD_LEN;
}
break;
}
}
RLC_CATCH_ANY {
result = RLC_ERR;
}
RLC_FINALLY {
bn_free(t);
}
RLC_FREE(mask);
return result;
} | 1 | 3,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,73,74,101,102,103,106,123,124 | -1 | https://github.com/relic-toolkit/relic/commit/76c9a1fdf19d9e92e566a77376673e522aae9f80 | 0CCPP |
static char *clean_path(char *path)
{
char *ch;
char *ch2;
char *str;
str = xmalloc(strlen(path));
ch = path;
ch2 = str;
while (true) {
*ch2 = *ch;
ch++;
ch2++;
if (!*(ch-1))
break;
while (*(ch - 1) == '/' && *ch == '/')
ch++;
}
while ((ch = strrchr(str, '/'))) {
if (ch == str)
break;
if (!*(ch+1))
*ch = 0;
else
break;
}
return str;
} | 1 | 5 | -1 | https://github.com/OpenRC/openrc/commit/bb8334104baf4d5a4a442a8647fb9204738f2204 | 0CCPP |
void *read_inode_table(long long start, long long end)
{
int res;
long long size = 0;
long long bytes = 0;
void *inode_table = NULL;
int alloc_size;
TRACE("read_inode_table: start %lld, end %lld\n", start, end);
alloc_size = ((end - start) + SQUASHFS_METADATA_SIZE) & ~(SQUASHFS_METADATA_SIZE - 1);
while(start < end) {
if(size - bytes < SQUASHFS_METADATA_SIZE) {
inode_table = realloc(inode_table, size += alloc_size);
if(inode_table == NULL) {
ERROR("Out of memory in read_inode_table");
goto failed;
}
}
add_entry(inode_table_hash, start, bytes);
res = read_block(fd, start, &start, 0, inode_table + bytes);
if(res == 0) {
ERROR("read_inode_table: failed to read block\n");
goto failed;
}
bytes += res;
if(start != end && res != SQUASHFS_METADATA_SIZE) {
ERROR("read_inode_table: metadata block should be %d "
"bytes in length, it is %d bytes\n",
SQUASHFS_METADATA_SIZE, res);
goto failed;
}
}
inode_table = realloc(inode_table, bytes);
return inode_table;
failed:
free(inode_table);
return NULL;
} | 0 | null | -1 | https://github.com/plougher/squashfs-tools/commit/79b5a555058eef4e1e7ff220c344d39f8cd09646 | 0CCPP |
static void __br_mdb_notify(struct net_device *dev, struct br_mdb_entry *entry,
int type)
{
struct net *net = dev_net(dev);
struct sk_buff *skb;
int err = -ENOBUFS;
skb = nlmsg_new(rtnl_mdb_nlmsg_size(), GFP_ATOMIC);
if (!skb)
goto errout;
err = nlmsg_populate_mdb_fill(skb, dev, entry, 0, 0, type, NTF_SELF);
if (err < 0) {
kfree_skb(skb);
goto errout;
}
rtnl_notify(skb, net, 0, RTNLGRP_MDB, NULL, GFP_ATOMIC);
return;
errout:
rtnl_set_sk_err(net, RTNLGRP_MDB, err);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/c7e8e8a8f7a70b343ca1e0f90a31e35ab2d16de1 | 0CCPP |
CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
{
size_t origin = parameters.size() > 1 ? 1 : 0;
if (parameters[origin].empty())
{
user->WriteNumeric(ERR_NOORIGIN, "No origin specified");
return CMD_FAILURE;
}
ClientProtocol::Messages::Pong pong(parameters[0], origin ? parameters[1] : "");
user->Send(ServerInstance->GetRFCEvents().pong, pong);
return CMD_SUCCESS;
} | 1 | 8 | -1 | https://github.com/inspircd/inspircd/commit/4350a11c663b0d75f8119743bffb7736d87abd4d | 0CCPP |
function getSlideByAnchor(slideAnchor, section) {
var slide = section.slides.filter(function (slide) {
return slide.anchor === slideAnchor;
})[0];
if (slide == null) {
slideAnchor = typeof slideAnchor !== 'undefined' ? slideAnchor : 0;
slide = section.slides[slideAnchor];
}
return slide ? slide.item : null;
} | 0 | null | -1 | https://github.com/alvarotrigo/fullpage.js/commit/48c474e366163ef341121a8c8f56aa2dc94ea60e | 3JavaScript |
this.getstate = function() {
return this.fm.selected().length == 1 ? state == opened ? 1 : 0 : -1;
} | 1 | 0,1,2 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
int LibRaw::raw2image_ex(int do_subtract_black)
{
CHECK_ORDER_LOW(LIBRAW_PROGRESS_LOAD_RAW);
try {
raw2image_start();
if (is_phaseone_compressed())
{
phase_one_allocate_tempbuffer();
phase_one_subtract_black((ushort*)imgdata.rawdata.raw_alloc,imgdata.rawdata.raw_image);
phase_one_correct();
}
int do_crop = 0;
unsigned save_width = S.width;
if (~O.cropbox[2] && ~O.cropbox[3] && load_raw != &LibRaw::foveon_sd_load_raw)
{
int crop[4],c,filt;
for(int c=0;c<4;c++)
{
crop[c] = O.cropbox[c];
if(crop[c]<0)
crop[c]=0;
}
if(IO.fuji_width && imgdata.idata.filters >= 1000)
{
crop[0] = (crop[0]/4)*4;
crop[1] = (crop[1]/4)*4;
if(!libraw_internal_data.unpacker_data.fuji_layout)
{
crop[2]*=sqrt(2.0);
crop[3]/=sqrt(2.0);
}
crop[2] = (crop[2]/4+1)*4;
crop[3] = (crop[3]/4+1)*4;
}
else if (imgdata.idata.filters == 1)
{
crop[0] = (crop[0]/16)*16;
crop[1] = (crop[1]/16)*16;
}
else if(imgdata.idata.filters == 2)
{
crop[0] = (crop[0]/6)*6;
crop[1] = (crop[1]/6)*6;
}
do_crop = 1;
crop[2] = MIN (crop[2], (signed) S.width-crop[0]);
crop[3] = MIN (crop[3], (signed) S.height-crop[1]);
if (crop[2] <= 0 || crop[3] <= 0)
throw LIBRAW_EXCEPTION_BAD_CROP;
S.left_margin+=crop[0];
S.top_margin+=crop[1];
S.width=crop[2];
S.height=crop[3];
S.iheight = (S.height + IO.shrink) >> IO.shrink;
S.iwidth = (S.width + IO.shrink) >> IO.shrink;
if(!IO.fuji_width && imgdata.idata.filters && imgdata.idata.filters >= 1000)
{
for (filt=c=0; c < 16; c++)
filt |= FC((c >> 1)+(crop[1]),
(c & 1)+(crop[0])) << c*2;
imgdata.idata.filters = filt;
}
}
int alloc_width = S.iwidth;
int alloc_height = S.iheight;
if(IO.fuji_width && do_crop)
{
int IO_fw = S.width >> !libraw_internal_data.unpacker_data.fuji_layout;
int t_alloc_width = (S.height >> libraw_internal_data.unpacker_data.fuji_layout) + IO_fw;
int t_alloc_height = t_alloc_width - 1;
alloc_height = (t_alloc_height + IO.shrink) >> IO.shrink;
alloc_width = (t_alloc_width + IO.shrink) >> IO.shrink;
}
int alloc_sz = alloc_width*alloc_height;
if(imgdata.image)
{
imgdata.image = (ushort (*)[4]) realloc (imgdata.image,alloc_sz *sizeof (*imgdata.image));
memset(imgdata.image,0,alloc_sz *sizeof (*imgdata.image));
}
else
imgdata.image = (ushort (*)[4]) calloc (alloc_sz, sizeof (*imgdata.image));
merror (imgdata.image, "raw2image_ex()");
libraw_decoder_info_t decoder_info;
get_decoder_info(&decoder_info);
unsigned short cblack[4]={0,0,0,0};
unsigned short dmax = 0;
if(do_subtract_black)
{
adjust_bl();
for(int i=0; i< 4; i++)
cblack[i] = (unsigned short)C.cblack[i];
}
if(decoder_info.decoder_flags & LIBRAW_DECODER_FLATFIELD)
{
if (IO.fuji_width)
{
if(do_crop)
{
IO.fuji_width = S.width >> !libraw_internal_data.unpacker_data.fuji_layout;
int IO_fwidth = (S.height >> libraw_internal_data.unpacker_data.fuji_layout) + IO.fuji_width;
int IO_fheight = IO_fwidth - 1;
int row,col;
for(row=0;row<S.height;row++)
{
for(col=0;col<S.width;col++)
{
int r,c;
if (libraw_internal_data.unpacker_data.fuji_layout) {
r = IO.fuji_width - 1 - col + (row >> 1);
c = col + ((row+1) >> 1);
} else {
r = IO.fuji_width - 1 + row - (col >> 1);
c = row + ((col+1) >> 1);
}
unsigned short val = imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_pitch/2
+(col+S.left_margin)];
int cc = FCF(row,col);
if(val > cblack[cc])
{
val-=cblack[cc];
if(dmax < val) dmax = val;
}
else
val = 0;
imgdata.image[((r) >> IO.shrink)*alloc_width + ((c) >> IO.shrink)][cc] = val;
}
}
S.height = IO_fheight;
S.width = IO_fwidth;
S.iheight = (S.height + IO.shrink) >> IO.shrink;
S.iwidth = (S.width + IO.shrink) >> IO.shrink;
S.raw_height -= 2*S.top_margin;
}
else
{
copy_fuji_uncropped(cblack,&dmax);
}
}
else
{
copy_bayer(cblack,&dmax);
}
}
else if(decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)
{
if(imgdata.rawdata.color4_image)
{
if(S.raw_pitch != S.width*8)
{
for(int row = 0; row < S.height; row++)
memmove(&imgdata.image[row*S.width],
&imgdata.rawdata.color4_image[(row+S.top_margin)*S.raw_pitch/8+S.left_margin],
S.width*sizeof(*imgdata.image));
}
else
{
memmove(imgdata.image,imgdata.rawdata.color4_image,S.width*S.height*sizeof(*imgdata.image));
}
}
else if(imgdata.rawdata.color3_image)
{
unsigned char *c3image = (unsigned char*) imgdata.rawdata.color3_image;
for(int row = 0; row < S.height; row++)
{
ushort (*srcrow)[3] = (ushort (*)[3]) &c3image[(row+S.top_margin)*S.raw_pitch];
ushort (*dstrow)[4] = (ushort (*)[4]) &imgdata.image[row*S.width];
for(int col=0; col < S.width; col++)
{
for(int c=0; c< 3; c++)
dstrow[col][c] = srcrow[S.left_margin+col][c];
dstrow[col][3]=0;
}
}
}
else
{
throw LIBRAW_EXCEPTION_DECODE_RAW;
}
}
if (is_phaseone_compressed())
{
phase_one_free_tempbuffer();
}
if (load_raw == &CLASS canon_600_load_raw && S.width < S.raw_width)
{
canon_600_correct();
}
if(do_subtract_black)
{
C.data_maximum = (int)dmax;
C.maximum -= C.black;
ZERO(C.cblack);
C.black = 0;
}
imgdata.progress_flags
= LIBRAW_PROGRESS_START|LIBRAW_PROGRESS_OPEN | LIBRAW_PROGRESS_RAW2_IMAGE
|LIBRAW_PROGRESS_IDENTIFY|LIBRAW_PROGRESS_SIZE_ADJUST|LIBRAW_PROGRESS_LOAD_RAW;
return 0;
}
catch ( LibRaw_exceptions err) {
EXCEPTION_HANDLER(err);
}
} | 0 | null | -1 | https://github.com/LibRaw/LibRaw/commit/19ffddb0fe1a4ffdb459b797ffcf7f490d28b5a6 | 0CCPP |
static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
get_block_t *get_block;
if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
return 0;
if (iocb->ki_pos + iter->count > i_size_read(inode) &&
!ocfs2_supports_append_dio(osb))
return 0;
if (iov_iter_rw(iter) == READ)
get_block = ocfs2_get_block;
else
get_block = ocfs2_dio_get_block;
return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev,
iter, get_block,
ocfs2_dio_end_io, NULL, 0);
} | 1 | 12,14 | -1 | https://github.com/torvalds/linux/commit/3e4c56d41eef5595035872a2ec5a483f42e8917f | 0CCPP |
null!=sa[ra]&&(ra=sa[ra]);ra={url:pa.getAttribute("url"),libs:pa.getAttribute("libs"),title:pa.getAttribute("title"),tooltip:pa.getAttribute("name")||pa.getAttribute("url"),preview:pa.getAttribute("preview"),clibs:ra,tags:pa.getAttribute("tags")};xa.push(ra);null!=ya&&(xa=Fa[wa],null==xa&&(xa={},Fa[wa]=xa),wa=xa[ya],null==wa&&(wa=[],xa[ya]=wa),wa.push(ra))}pa=pa.nextSibling}R.stop();A()}})};G.appendChild(ea);G.appendChild(Aa);G.appendChild(Z);var ta=!1,ka=k;/^https?:\/\//.test(ka)&&!b.editor.isCorsEnabledForUrl(ka)&& | 0 | null | -1 | https://github.com/jgraph/drawio/commit/c287bef9101d024b1fd59d55ecd530f25000f9d8 | 3JavaScript |
Variant HHVM_FUNCTION(nl_langinfo, int item) {
#ifdef _MSC_VER
raise_warning("nl_langinfo is not yet implemented on Windows!");
return empty_string();
#else
switch(item) {
#ifdef ABDAY_1
case ABDAY_1:
case ABDAY_2:
case ABDAY_3:
case ABDAY_4:
case ABDAY_5:
case ABDAY_6:
case ABDAY_7:
#endif
#ifdef DAY_1
case DAY_1:
case DAY_2:
case DAY_3:
case DAY_4:
case DAY_5:
case DAY_6:
case DAY_7:
#endif
#ifdef ABMON_1
case ABMON_1:
case ABMON_2:
case ABMON_3:
case ABMON_4:
case ABMON_5:
case ABMON_6:
case ABMON_7:
case ABMON_8:
case ABMON_9:
case ABMON_10:
case ABMON_11:
case ABMON_12:
#endif
#ifdef MON_1
case MON_1:
case MON_2:
case MON_3:
case MON_4:
case MON_5:
case MON_6:
case MON_7:
case MON_8:
case MON_9:
case MON_10:
case MON_11:
case MON_12:
#endif
#ifdef AM_STR
case AM_STR:
#endif
#ifdef PM_STR
case PM_STR:
#endif
#ifdef D_T_FMT
case D_T_FMT:
#endif
#ifdef D_FMT
case D_FMT:
#endif
#ifdef T_FMT
case T_FMT:
#endif
#ifdef T_FMT_AMPM
case T_FMT_AMPM:
#endif
#ifdef ERA
case ERA:
#endif
#ifdef ERA_YEAR
case ERA_YEAR:
#endif
#ifdef ERA_D_T_FMT
case ERA_D_T_FMT:
#endif
#ifdef ERA_D_FMT
case ERA_D_FMT:
#endif
#ifdef ERA_T_FMT
case ERA_T_FMT:
#endif
#ifdef ALT_DIGITS
case ALT_DIGITS:
#endif
#ifdef INT_CURR_SYMBOL
case INT_CURR_SYMBOL:
#endif
#ifdef CURRENCY_SYMBOL
case CURRENCY_SYMBOL:
#endif
#ifdef CRNCYSTR
case CRNCYSTR:
#endif
#ifdef MON_DECIMAL_POINT
case MON_DECIMAL_POINT:
#endif
#ifdef MON_THOUSANDS_SEP
case MON_THOUSANDS_SEP:
#endif
#ifdef MON_GROUPING
case MON_GROUPING:
#endif
#ifdef POSITIVE_SIGN
case POSITIVE_SIGN:
#endif
#ifdef NEGATIVE_SIGN
case NEGATIVE_SIGN:
#endif
#ifdef INT_FRAC_DIGITS
case INT_FRAC_DIGITS:
#endif
#ifdef FRAC_DIGITS
case FRAC_DIGITS:
#endif
#ifdef P_CS_PRECEDES
case P_CS_PRECEDES:
#endif
#ifdef P_SEP_BY_SPACE
case P_SEP_BY_SPACE:
#endif
#ifdef N_CS_PRECEDES
case N_CS_PRECEDES:
#endif
#ifdef N_SEP_BY_SPACE
case N_SEP_BY_SPACE:
#endif
#ifdef P_SIGN_POSN
case P_SIGN_POSN:
#endif
#ifdef N_SIGN_POSN
case N_SIGN_POSN:
#endif
#ifdef DECIMAL_POINT
case DECIMAL_POINT:
#elif defined(RADIXCHAR)
case RADIXCHAR:
#endif
#ifdef THOUSANDS_SEP
case THOUSANDS_SEP:
#elif defined(THOUSEP)
case THOUSEP:
#endif
#ifdef GROUPING
case GROUPING:
#endif
#ifdef YESEXPR
case YESEXPR:
#endif
#ifdef NOEXPR
case NOEXPR:
#endif
#ifdef YESSTR
case YESSTR:
#endif
#ifdef NOSTR
case NOSTR:
#endif
#ifdef CODESET
case CODESET:
#endif
break;
default:
raise_warning("Item '%d' is not valid", item);
return false;
}
auto const ret = nl_langinfo(item);
if (ret == nullptr) {
return false;
}
return String(ret);
#endif
} | 0 | null | -1 | https://github.com/facebook/hhvm/commit/08193b7f0cd3910256e00d599f0f3eb2519c44ca | 0CCPP |
function andLogAndFinish (spec, tracker, done) {
validate('SOF|SZF|OOF|OZF', [spec, tracker, done])
return (er, pkg) => {
if (er) {
log.silly('fetchPackageMetaData', 'error for ' + String(spec), er.message)
if (tracker) tracker.finish()
}
return done(er, pkg)
}
} | 1 | 4 | -1 | https://github.com/npm/cli/commit/a9857b8f6869451ff058789c4631fadfde5bbcbc | 3JavaScript |
static void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
{
spin_lock_irq(&tsk->sighand->siglock);
__proc_set_tty(tsk, tty);
spin_unlock_irq(&tsk->sighand->siglock);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/c290f8358acaeffd8e0c551ddcc24d1206143376 | 0CCPP |
def test_captcha_jinja_global_empty_while_disabled(self):
self.app.config["CAPTCHA_ENABLE"] = False
captcha = FlaskSessionCaptcha(self.app)
with self.app.test_request_context("/"):
function = self.app.jinja_env.globals["captcha"]
try:
captcha.get_answer()
assert False
except:
pass
img = function()
assert img == ""
| 0 | null | -1 | https://github.com/Tethik/flask-session-captcha.git/commit/2811ae23a38d33b620fb7a07de8837c6d65c13e4 | 4Python |
const getRangev4 = (ip1: string, ip2: string) => {
const ips = [];
let firstAddressLong = toLong(ip1);
const lastAddressLong = toLong(ip2);
for (firstAddressLong; firstAddressLong <= lastAddressLong; firstAddressLong++)
ips.push(fromLong(firstAddressLong));
return ips;
}; | 1 | null | -1 | https://github.com/JoeScho/get-ip-range/commit/98ca22b815c77273cbab259811ab0976118e13b6 | 5TypeScript |
pim_print(netdissect_options *ndo,
register const u_char *bp, register u_int len, const u_char *bp2)
{
register const u_char *ep;
register const struct pim *pim = (const struct pim *)bp;
ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
#ifdef notyet
ND_TCHECK(pim->pim_rsv);
#endif
switch (PIM_VER(pim->pim_typever)) {
case 2:
if (!ndo->ndo_vflag) {
ND_PRINT((ndo, "PIMv%u, %s, length %u",
PIM_VER(pim->pim_typever),
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
len));
return;
} else {
ND_PRINT((ndo, "PIMv%u, length %u\n\t%s",
PIM_VER(pim->pim_typever),
len,
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever))));
pimv2_print(ndo, bp, len, bp2);
}
break;
default:
ND_PRINT((ndo, "PIMv%u, length %u",
PIM_VER(pim->pim_typever),
len));
break;
}
return;
} | 1 | 3,5,6,7 | -1 | https://github.com/the-tcpdump-group/tcpdump/commit/5dc1860d8267b1e0cb78c9ffa2a40bea2fdb3ddc | 0CCPP |
static int flv_write_trailer(AVFormatContext *s)
{
int64_t file_size;
AVIOContext *pb = s->pb;
FLVContext *flv = s->priv_data;
int build_keyframes_idx = flv->flags & FLV_ADD_KEYFRAME_INDEX;
int i, res;
int64_t cur_pos = avio_tell(s->pb);
if (build_keyframes_idx) {
FLVFileposition *newflv_posinfo, *p;
avio_seek(pb, flv->videosize_offset, SEEK_SET);
put_amf_double(pb, flv->videosize);
avio_seek(pb, flv->audiosize_offset, SEEK_SET);
put_amf_double(pb, flv->audiosize);
avio_seek(pb, flv->lasttimestamp_offset, SEEK_SET);
put_amf_double(pb, flv->lasttimestamp);
avio_seek(pb, flv->lastkeyframetimestamp_offset, SEEK_SET);
put_amf_double(pb, flv->lastkeyframetimestamp);
avio_seek(pb, flv->lastkeyframelocation_offset, SEEK_SET);
put_amf_double(pb, flv->lastkeyframelocation + flv->keyframe_index_size);
avio_seek(pb, cur_pos, SEEK_SET);
res = shift_data(s);
if (res < 0) {
goto end;
}
avio_seek(pb, flv->keyframes_info_offset, SEEK_SET);
put_amf_string(pb, "filepositions");
put_amf_dword_array(pb, flv->filepositions_count);
for (newflv_posinfo = flv->head_filepositions; newflv_posinfo; newflv_posinfo = newflv_posinfo->next) {
put_amf_double(pb, newflv_posinfo->keyframe_position + flv->keyframe_index_size);
}
put_amf_string(pb, "times");
put_amf_dword_array(pb, flv->filepositions_count);
for (newflv_posinfo = flv->head_filepositions; newflv_posinfo; newflv_posinfo = newflv_posinfo->next) {
put_amf_double(pb, newflv_posinfo->keyframe_timestamp);
}
newflv_posinfo = flv->head_filepositions;
while (newflv_posinfo) {
p = newflv_posinfo->next;
if (p) {
newflv_posinfo->next = p->next;
av_free(p);
p = NULL;
} else {
av_free(newflv_posinfo);
newflv_posinfo = NULL;
}
}
put_amf_string(pb, "");
avio_w8(pb, AMF_END_OF_OBJECT);
avio_seek(pb, cur_pos + flv->keyframe_index_size, SEEK_SET);
}
end:
if (flv->flags & FLV_NO_SEQUENCE_END) {
av_log(s, AV_LOG_DEBUG, "FLV no sequence end mode open\n");
} else {
for (i = 0; i < s->nb_streams; i++) {
AVCodecParameters *par = s->streams[i]->codecpar;
FLVStreamContext *sc = s->streams[i]->priv_data;
if (par->codec_type == AVMEDIA_TYPE_VIDEO &&
(par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4))
put_avc_eos_tag(pb, sc->last_ts);
}
}
file_size = avio_tell(pb);
if (build_keyframes_idx) {
flv->datasize = file_size - flv->datastart_offset;
avio_seek(pb, flv->datasize_offset, SEEK_SET);
put_amf_double(pb, flv->datasize);
}
if (!(flv->flags & FLV_NO_METADATA)) {
if (!(flv->flags & FLV_NO_DURATION_FILESIZE)) {
if (avio_seek(pb, flv->duration_offset, SEEK_SET) < 0) {
av_log(s, AV_LOG_WARNING, "Failed to update header with correct duration.\n");
} else {
put_amf_double(pb, flv->duration / (double)1000);
}
if (avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0) {
av_log(s, AV_LOG_WARNING, "Failed to update header with correct filesize.\n");
} else {
put_amf_double(pb, file_size);
}
}
}
return 0;
} | 0 | null | -1 | https://github.com/FFmpeg/FFmpeg/commit/6b67d7f05918f7a1ee8fc6ff21355d7e8736aa10 | 0CCPP |
void CWebServer::GetFloorplanImage(WebEmSession & session, const request& req, reply & rep)
{
std::string idx = request::findValue(&req, "idx");
if (idx == "") {
return;
}
std::vector<std::vector<std::string> > result;
result = m_sql.safe_queryBlob("SELECT Image FROM Floorplans WHERE ID=%s", idx.c_str());
if (result.empty())
return;
reply::set_content(&rep, result[0][0].begin(), result[0][0].end());
std::string oname = "floorplan";
if (result[0][0].size() > 10)
{
if (result[0][0][0] == 'P')
oname += ".png";
else if (result[0][0][0] == -1)
oname += ".jpg";
else if (result[0][0][0] == 'B')
oname += ".bmp";
else if (result[0][0][0] == 'G')
oname += ".gif";
}
reply::add_header_attachment(&rep, oname);
} | 1 | 7 | -1 | https://github.com/domoticz/domoticz/commit/ee70db46f81afa582c96b887b73bcd2a86feda00 | 0CCPP |
mcs_parse_domain_params(STREAM s)
{
int length;
ber_parse_header(s, MCS_TAG_DOMAIN_PARAMS, &length);
in_uint8s(s, length);
return s_check(s);
} | 1 | 2 | -1 | https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1 | 0CCPP |
def __str__(self):
return "Unknown#0000"
| 1 | null | -1 | https://github.com/laggron42/Laggrons-Dumb-Cogs.git/commit/c79dd2cc879989cf2018e76ba2aad0baef3b4ec8 | 4Python |
PyMem_Free(void *ptr)
{
_PyMem.free(_PyMem.ctx, ptr);
} | 1 | 0,1,2,3 | -1 | https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce | 0CCPP |
static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
const PrimitiveInfo *primitive_info)
{
typedef struct _LineSegment
{
double
p,
q;
} LineSegment;
LineSegment
dx,
dy,
inverse_slope,
slope,
theta;
MagickBooleanType
closed_path;
double
delta_theta,
dot_product,
mid,
miterlimit;
PointInfo
box_p[5],
box_q[5],
center,
offset,
*path_p,
*path_q;
PrimitiveInfo
*polygon_primitive,
*stroke_polygon;
register ssize_t
i;
size_t
arc_segments,
max_strokes,
number_vertices;
ssize_t
j,
n,
p,
q;
number_vertices=primitive_info->coordinates;
max_strokes=2*number_vertices+6*BezierQuantum+360;
path_p=(PointInfo *) AcquireQuantumMemory((size_t) max_strokes,
sizeof(*path_p));
path_q=(PointInfo *) AcquireQuantumMemory((size_t) max_strokes,
sizeof(*path_q));
polygon_primitive=(PrimitiveInfo *) AcquireQuantumMemory((size_t)
number_vertices+2UL,sizeof(*polygon_primitive));
if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL) ||
(polygon_primitive == (PrimitiveInfo *) NULL))
return((PrimitiveInfo *) NULL);
(void) CopyMagickMemory(polygon_primitive,primitive_info,(size_t)
number_vertices*sizeof(*polygon_primitive));
closed_path=
(primitive_info[number_vertices-1].point.x == primitive_info[0].point.x) &&
(primitive_info[number_vertices-1].point.y == primitive_info[0].point.y) ?
MagickTrue : MagickFalse;
if ((draw_info->linejoin == RoundJoin) ||
((draw_info->linejoin == MiterJoin) && (closed_path != MagickFalse)))
{
polygon_primitive[number_vertices]=primitive_info[1];
number_vertices++;
}
polygon_primitive[number_vertices].primitive=UndefinedPrimitive;
dx.p=0.0;
dy.p=0.0;
for (n=1; n < (ssize_t) number_vertices; n++)
{
dx.p=polygon_primitive[n].point.x-polygon_primitive[0].point.x;
dy.p=polygon_primitive[n].point.y-polygon_primitive[0].point.y;
if ((fabs(dx.p) >= MagickEpsilon) || (fabs(dy.p) >= MagickEpsilon))
break;
}
if (n == (ssize_t) number_vertices)
n=(ssize_t) number_vertices-1L;
slope.p=DrawEpsilonReciprocal(dx.p)*dy.p;
inverse_slope.p=(-1.0*DrawEpsilonReciprocal(slope.p));
mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
miterlimit=(double) (draw_info->miterlimit*draw_info->miterlimit*
mid*mid);
if ((draw_info->linecap == SquareCap) && (closed_path == MagickFalse))
TraceSquareLinecap(polygon_primitive,number_vertices,mid);
offset.x=sqrt((double) (mid*mid/(inverse_slope.p*inverse_slope.p+1.0)));
offset.y=(double) (offset.x*inverse_slope.p);
if ((dy.p*offset.x-dx.p*offset.y) > 0.0)
{
box_p[0].x=polygon_primitive[0].point.x-offset.x;
box_p[0].y=polygon_primitive[0].point.y-offset.x*inverse_slope.p;
box_p[1].x=polygon_primitive[n].point.x-offset.x;
box_p[1].y=polygon_primitive[n].point.y-offset.x*inverse_slope.p;
box_q[0].x=polygon_primitive[0].point.x+offset.x;
box_q[0].y=polygon_primitive[0].point.y+offset.x*inverse_slope.p;
box_q[1].x=polygon_primitive[n].point.x+offset.x;
box_q[1].y=polygon_primitive[n].point.y+offset.x*inverse_slope.p;
}
else
{
box_p[0].x=polygon_primitive[0].point.x+offset.x;
box_p[0].y=polygon_primitive[0].point.y+offset.y;
box_p[1].x=polygon_primitive[n].point.x+offset.x;
box_p[1].y=polygon_primitive[n].point.y+offset.y;
box_q[0].x=polygon_primitive[0].point.x-offset.x;
box_q[0].y=polygon_primitive[0].point.y-offset.y;
box_q[1].x=polygon_primitive[n].point.x-offset.x;
box_q[1].y=polygon_primitive[n].point.y-offset.y;
}
p=0;
q=0;
path_q[p++]=box_q[0];
path_p[q++]=box_p[0];
for (i=(ssize_t) n+1; i < (ssize_t) number_vertices; i++)
{
dx.q=polygon_primitive[i].point.x-polygon_primitive[n].point.x;
dy.q=polygon_primitive[i].point.y-polygon_primitive[n].point.y;
dot_product=dx.q*dx.q+dy.q*dy.q;
if (dot_product < 0.25)
continue;
slope.q=DrawEpsilonReciprocal(dx.q)*dy.q;
inverse_slope.q=(-1.0*DrawEpsilonReciprocal(slope.q));
offset.x=sqrt((double) (mid*mid/(inverse_slope.q*inverse_slope.q+1.0)));
offset.y=(double) (offset.x*inverse_slope.q);
dot_product=dy.q*offset.x-dx.q*offset.y;
if (dot_product > 0.0)
{
box_p[2].x=polygon_primitive[n].point.x-offset.x;
box_p[2].y=polygon_primitive[n].point.y-offset.y;
box_p[3].x=polygon_primitive[i].point.x-offset.x;
box_p[3].y=polygon_primitive[i].point.y-offset.y;
box_q[2].x=polygon_primitive[n].point.x+offset.x;
box_q[2].y=polygon_primitive[n].point.y+offset.y;
box_q[3].x=polygon_primitive[i].point.x+offset.x;
box_q[3].y=polygon_primitive[i].point.y+offset.y;
}
else
{
box_p[2].x=polygon_primitive[n].point.x+offset.x;
box_p[2].y=polygon_primitive[n].point.y+offset.y;
box_p[3].x=polygon_primitive[i].point.x+offset.x;
box_p[3].y=polygon_primitive[i].point.y+offset.y;
box_q[2].x=polygon_primitive[n].point.x-offset.x;
box_q[2].y=polygon_primitive[n].point.y-offset.y;
box_q[3].x=polygon_primitive[i].point.x-offset.x;
box_q[3].y=polygon_primitive[i].point.y-offset.y;
}
if (fabs((double) (slope.p-slope.q)) < MagickEpsilon)
{
box_p[4]=box_p[1];
box_q[4]=box_q[1];
}
else
{
box_p[4].x=(double) ((slope.p*box_p[0].x-box_p[0].y-slope.q*box_p[3].x+
box_p[3].y)/(slope.p-slope.q));
box_p[4].y=(double) (slope.p*(box_p[4].x-box_p[0].x)+box_p[0].y);
box_q[4].x=(double) ((slope.p*box_q[0].x-box_q[0].y-slope.q*box_q[3].x+
box_q[3].y)/(slope.p-slope.q));
box_q[4].y=(double) (slope.p*(box_q[4].x-box_q[0].x)+box_q[0].y);
}
if (q >= (ssize_t) (max_strokes-6*BezierQuantum-360))
{
max_strokes+=6*BezierQuantum+360;
path_p=(PointInfo *) ResizeQuantumMemory(path_p,(size_t) max_strokes,
sizeof(*path_p));
path_q=(PointInfo *) ResizeQuantumMemory(path_q,(size_t) max_strokes,
sizeof(*path_q));
if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL))
{
polygon_primitive=(PrimitiveInfo *)
RelinquishMagickMemory(polygon_primitive);
return((PrimitiveInfo *) NULL);
}
}
dot_product=dx.q*dy.p-dx.p*dy.q;
if (dot_product <= 0.0)
switch (draw_info->linejoin)
{
case BevelJoin:
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
path_p[p++]=box_p[4];
else
{
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
}
break;
}
case MiterJoin:
{
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
{
path_q[q++]=box_q[4];
path_p[p++]=box_p[4];
}
else
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
}
break;
}
case RoundJoin:
{
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
path_p[p++]=box_p[4];
else
{
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
}
center=polygon_primitive[n].point;
theta.p=atan2(box_q[1].y-center.y,box_q[1].x-center.x);
theta.q=atan2(box_q[2].y-center.y,box_q[2].x-center.x);
if (theta.q < theta.p)
theta.q+=(double) (2.0*MagickPI);
arc_segments=(size_t) ceil((double) ((theta.q-theta.p)/
(2.0*sqrt((double) (1.0/mid)))));
path_q[q].x=box_q[1].x;
path_q[q].y=box_q[1].y;
q++;
for (j=1; j < (ssize_t) arc_segments; j++)
{
delta_theta=(double) (j*(theta.q-theta.p)/arc_segments);
path_q[q].x=(double) (center.x+mid*cos(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
path_q[q].y=(double) (center.y+mid*sin(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
q++;
}
path_q[q++]=box_q[2];
break;
}
default:
break;
}
else
switch (draw_info->linejoin)
{
case BevelJoin:
{
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
path_q[q++]=box_q[4];
else
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
}
break;
}
case MiterJoin:
{
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
{
path_q[q++]=box_q[4];
path_p[p++]=box_p[4];
}
else
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
}
break;
}
case RoundJoin:
{
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
path_q[q++]=box_q[4];
else
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
}
center=polygon_primitive[n].point;
theta.p=atan2(box_p[1].y-center.y,box_p[1].x-center.x);
theta.q=atan2(box_p[2].y-center.y,box_p[2].x-center.x);
if (theta.p < theta.q)
theta.p+=(double) (2.0*MagickPI);
arc_segments=(size_t) ceil((double) ((theta.p-theta.q)/
(2.0*sqrt((double) (1.0/mid)))));
path_p[p++]=box_p[1];
for (j=1; j < (ssize_t) arc_segments; j++)
{
delta_theta=(double) (j*(theta.q-theta.p)/arc_segments);
path_p[p].x=(double) (center.x+mid*cos(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
path_p[p].y=(double) (center.y+mid*sin(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
p++;
}
path_p[p++]=box_p[2];
break;
}
default:
break;
}
slope.p=slope.q;
inverse_slope.p=inverse_slope.q;
box_p[0]=box_p[2];
box_p[1]=box_p[3];
box_q[0]=box_q[2];
box_q[1]=box_q[3];
dx.p=dx.q;
dy.p=dy.q;
n=i;
}
path_p[p++]=box_p[1];
path_q[q++]=box_q[1];
stroke_polygon=(PrimitiveInfo *) AcquireQuantumMemory((size_t)
(p+q+2UL*closed_path+2UL),sizeof(*stroke_polygon));
if (stroke_polygon != (PrimitiveInfo *) NULL)
{
for (i=0; i < (ssize_t) p; i++)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=path_p[i];
}
if (closed_path != MagickFalse)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=stroke_polygon[0].point;
i++;
}
for ( ; i < (ssize_t) (p+q+closed_path); i++)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=path_q[p+q+closed_path-(i+1)];
}
if (closed_path != MagickFalse)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=stroke_polygon[p+closed_path].point;
i++;
}
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=stroke_polygon[0].point;
i++;
stroke_polygon[i].primitive=UndefinedPrimitive;
stroke_polygon[0].coordinates=(size_t) (p+q+2*closed_path+1);
}
path_p=(PointInfo *) RelinquishMagickMemory(path_p);
path_q=(PointInfo *) RelinquishMagickMemory(path_q);
polygon_primitive=(PrimitiveInfo *) RelinquishMagickMemory(polygon_primitive);
return(stroke_polygon);
} | 1 | 163,164,165,166,167,168,169,170,171,172,173 | -1 | https://github.com/ImageMagick/ImageMagick/commit/726812fa2fa7ce16bcf58f6e115f65427a1c0950 | 0CCPP |
void *cpu_physical_memory_map(hwaddr addr,
hwaddr *plen,
bool is_write)
{
return address_space_map(&address_space_memory, addr, plen, is_write,
MEMTXATTRS_UNSPECIFIED);
} | 0 | null | -1 | https://github.com/qemu/qemu/commit/418ade7849ce7641c0f7333718caf5091a02fd4c | 0CCPP |
return a},remove:function(a,b){var c=null;if("object"==typeof b)for(var d=mxUtils.indexOf(b,a);0<=d;)b.splice(d,1),c=a,d=mxUtils.indexOf(b,a);for(var e in b)b[e]==a&&(delete b[e],c=a);return c},isNode:function(a,b,c,d){return null==a||isNaN(a.nodeType)||null!=b&&a.nodeName.toLowerCase()!=b.toLowerCase()?!1:null==c||a.getAttribute(c)==d},isAncestorNode:function(a,b){for(;null!=b;){if(b==a)return!0;b=b.parentNode}return!1},getChildNodes:function(a,b){b=b||mxConstants.NODETYPE_ELEMENT;var c=[];for(a=
a.firstChild;null!=a;)a.nodeType==b&&c.push(a),a=a.nextSibling;return c},importNode:function(a,b,c){return mxClient.IS_IE&&(null==document.documentMode||10>document.documentMode)?mxUtils.importNodeImplementation(a,b,c):a.importNode(b,c)},importNodeImplementation:function(a,b,c){switch(b.nodeType){case 1:var d=a.createElement(b.nodeName);if(b.attributes&&0<b.attributes.length)for(var e=0;e<b.attributes.length;e++)d.setAttribute(b.attributes[e].nodeName,b.getAttribute(b.attributes[e].nodeName));if(c&& | 1 | 0,1 | -1 | https://github.com/jgraph/drawio/commit/3d3f819d7a04da7d53b37cc0ca4269c157ba2825 | 3JavaScript |
ka&&null!=ka.message?ka.message:mxResources.get("disconnected")));mxEvent.consume(U)}));ea.setAttribute("title",X);O.style.paddingRight="4px";O.appendChild(ea)}}}};var y=App.prototype.updateButtonContainer;App.prototype.updateButtonContainer=function(){y.apply(this,arguments);if(null!=this.shareButton){var O=this.shareButton;O.style.cssText="display:inline-block;position:relative;box-sizing:border-box;margin-right:4px;cursor:pointer;";O.className="geToolbarButton";O.innerHTML="";O.style.backgroundImage=
"url("+Editor.shareImage+")";O.style.backgroundPosition="center center";O.style.backgroundRepeat="no-repeat";O.style.backgroundSize="24px 24px";O.style.height="24px";O.style.width="24px";"1"==urlParams.sketch&&(this.shareButton.style.display="none")}null!=this.buttonContainer&&(this.buttonContainer.style.marginTop="-2px",this.buttonContainer.style.paddingTop="4px")};EditorUi.prototype.addEmbedButtons=function(){if(null!=this.buttonContainer&&"1"!=urlParams.embedInline){var O=document.createElement("div"); | 1 | 0,1 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
unsigned long param)
{
int drive = (long)bdev->bd_disk->private_data;
int type = ITYPE(drive_state[drive].fd_device);
int i;
int ret;
int size;
union inparam {
struct floppy_struct g;
struct format_descr f;
struct floppy_max_errors max_errors;
struct floppy_drive_params dp;
} inparam;
const void *outparam;
if (cmd == CDROMEJECT ||
cmd == 0x6470) {
DPRINT("obsolete eject ioctl\n");
DPRINT("please use floppycontrol --eject\n");
cmd = FDEJECT;
}
if (!((cmd & 0xff00) == 0x0200))
return -EINVAL;
ret = normalize_ioctl(&cmd, &size);
if (ret)
return ret;
if (((cmd & 0x40) && !(mode & (FMODE_WRITE | FMODE_WRITE_IOCTL))) ||
((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
return -EPERM;
if (WARN_ON(size < 0 || size > sizeof(inparam)))
return -EINVAL;
memset(&inparam, 0, sizeof(inparam));
if (_IOC_DIR(cmd) & _IOC_WRITE) {
ret = fd_copyin((void __user *)param, &inparam, size);
if (ret)
return ret;
}
switch (cmd) {
case FDEJECT:
if (drive_state[drive].fd_ref != 1)
return -EBUSY;
if (lock_fdc(drive))
return -EINTR;
ret = fd_eject(UNIT(drive));
set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags);
set_bit(FD_VERIFY_BIT, &drive_state[drive].flags);
process_fd_request();
return ret;
case FDCLRPRM:
if (lock_fdc(drive))
return -EINTR;
current_type[drive] = NULL;
floppy_sizes[drive] = MAX_DISK_SIZE << 1;
drive_state[drive].keep_data = 0;
return invalidate_drive(bdev);
case FDSETPRM:
case FDDEFPRM:
return set_geometry(cmd, &inparam.g, drive, type, bdev);
case FDGETPRM:
ret = get_floppy_geometry(drive, type,
(struct floppy_struct **)&outparam);
if (ret)
return ret;
memcpy(&inparam.g, outparam,
offsetof(struct floppy_struct, name));
outparam = &inparam.g;
break;
case FDMSGON:
drive_params[drive].flags |= FTD_MSG;
return 0;
case FDMSGOFF:
drive_params[drive].flags &= ~FTD_MSG;
return 0;
case FDFMTBEG:
if (lock_fdc(drive))
return -EINTR;
if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
return -EINTR;
ret = drive_state[drive].flags;
process_fd_request();
if (ret & FD_VERIFY)
return -ENODEV;
if (!(ret & FD_DISK_WRITABLE))
return -EROFS;
return 0;
case FDFMTTRK:
if (drive_state[drive].fd_ref != 1)
return -EBUSY;
return do_format(drive, &inparam.f);
case FDFMTEND:
case FDFLUSH:
if (lock_fdc(drive))
return -EINTR;
return invalidate_drive(bdev);
case FDSETEMSGTRESH:
drive_params[drive].max_errors.reporting = (unsigned short)(param & 0x0f);
return 0;
case FDGETMAXERRS:
outparam = &drive_params[drive].max_errors;
break;
case FDSETMAXERRS:
drive_params[drive].max_errors = inparam.max_errors;
break;
case FDGETDRVTYP:
outparam = drive_name(type, drive);
SUPBOUND(size, strlen((const char *)outparam) + 1);
break;
case FDSETDRVPRM:
if (!valid_floppy_drive_params(inparam.dp.autodetect,
inparam.dp.native_format))
return -EINVAL;
drive_params[drive] = inparam.dp;
break;
case FDGETDRVPRM:
outparam = &drive_params[drive];
break;
case FDPOLLDRVSTAT:
if (lock_fdc(drive))
return -EINTR;
if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
return -EINTR;
process_fd_request();
fallthrough;
case FDGETDRVSTAT:
outparam = &drive_state[drive];
break;
case FDRESET:
return user_reset_fdc(drive, (int)param, true);
case FDGETFDCSTAT:
outparam = &fdc_state[FDC(drive)];
break;
case FDWERRORCLR:
memset(&write_errors[drive], 0, sizeof(write_errors[drive]));
return 0;
case FDWERRORGET:
outparam = &write_errors[drive];
break;
case FDRAWCMD:
if (type)
return -EINVAL;
if (lock_fdc(drive))
return -EINTR;
set_floppy(drive);
i = raw_cmd_ioctl(cmd, (void __user *)param);
if (i == -EINTR)
return -EINTR;
process_fd_request();
return i;
case FDTWADDLE:
if (lock_fdc(drive))
return -EINTR;
twaddle(current_fdc, current_drive);
process_fd_request();
return 0;
default:
return -EINVAL;
}
if (_IOC_DIR(cmd) & _IOC_READ)
return fd_copyout((void __user *)param, outparam, size);
return 0;
} | 1 | 5,138,139,140,141,142,143,144,145,146,147 | -1 | https://github.com/torvalds/linux/commit/233087ca063686964a53c829d547c7571e3f67bf | 0CCPP |
graph.getModel().endUpdate();
}
mxEvent.consume(evt);
});
mxEvent.addListener(styleSelect, 'click', function(evt)
{
mxEvent.consume(evt);
});
container.appendChild(styleSelect);
var jumpSizeUpdate;
var jumpSize = this.addUnitInput(container, 'pt', 16, 42, function()
{
jumpSizeUpdate.apply(this, arguments);
});
jumpSizeUpdate = this.installInputHandler(jumpSize, 'jumpSize',
Graph.defaultJumpSize, 0, 999, ' pt');
var listener = mxUtils.bind(this, function(sender, evt, force)
{
ss = ui.getSelectionState();
styleSelect.value = mxUtils.getValue(ss.style, 'jumpStyle', 'none');
if (force || document.activeElement != jumpSize)
{
var tmp = parseInt(mxUtils.getValue(ss.style, 'jumpSize', Graph.defaultJumpSize));
jumpSize.value = (isNaN(tmp)) ? '' : tmp + ' pt';
}
});
this.addKeyHandler(jumpSize, listener);
graph.getModel().addListener(mxEvent.CHANGE, listener);
this.listeners.push({destroy: function() { graph.getModel().removeListener(listener); }});
listener();
}
else
{
container.style.display = 'none';
}
return container;
}; | 0 | null | -1 | https://github.com/jgraph/drawio/commit/3d3f819d7a04da7d53b37cc0ca4269c157ba2825 | 3JavaScript |
Status ConvertGraphDefToGraph(const GraphConstructorOptions& opts,
GraphDef&& gdef, Graph* g) {
ShapeRefiner refiner(gdef.versions().producer(), g->op_registry());
return GraphConstructor::Construct(opts, std::move(gdef), g, &refiner,
nullptr,
nullptr,
nullptr);
} | 0 | null | -1 | https://github.com/tensorflow/tensorflow/commit/0cc38aaa4064fd9e79101994ce9872c6d91f816b | 0CCPP |
void CUtf8Converter::GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount, std::wstring& sOutput )
{
WCHAR* pUnicodeString = new WCHAR[lCount + 1];
WCHAR* pStart = pUnicodeString;
LONG lIndex = 0;
while (lIndex < lCount)
{
BYTE byteMain = pBuffer[lIndex];
if (0x00 == (byteMain & 0x80))
{
*pUnicodeString++ = (WCHAR)byteMain;
++lIndex;
}
else if (0x00 == (byteMain & 0x20))
{
int val = (int)(((byteMain & 0x1F) << 6) |
(pBuffer[lIndex + 1] & 0x3F));
*pUnicodeString++ = (WCHAR)(val);
lIndex += 2;
}
else if (0x00 == (byteMain & 0x10))
{
int val = (int)(((byteMain & 0x0F) << 12) |
((pBuffer[lIndex + 1] & 0x3F) << 6) |
(pBuffer[lIndex + 2] & 0x3F));
WriteUtf16_WCHAR(val, pUnicodeString);
lIndex += 3;
}
else if (0x00 == (byteMain & 0x0F))
{
int val = (int)(((byteMain & 0x07) << 18) |
((pBuffer[lIndex + 1] & 0x3F) << 12) |
((pBuffer[lIndex + 2] & 0x3F) << 6) |
(pBuffer[lIndex + 3] & 0x3F));
WriteUtf16_WCHAR(val, pUnicodeString);
lIndex += 4;
}
else if (0x00 == (byteMain & 0x08))
{
int val = (int)(((byteMain & 0x07) << 18) |
((pBuffer[lIndex + 1] & 0x3F) << 12) |
((pBuffer[lIndex + 2] & 0x3F) << 6) |
(pBuffer[lIndex + 3] & 0x3F));
WriteUtf16_WCHAR(val, pUnicodeString);
lIndex += 4;
}
else if (0x00 == (byteMain & 0x04))
{
int val = (int)(((byteMain & 0x03) << 24) |
((pBuffer[lIndex + 1] & 0x3F) << 18) |
((pBuffer[lIndex + 2] & 0x3F) << 12) |
((pBuffer[lIndex + 3] & 0x3F) << 6) |
(pBuffer[lIndex + 4] & 0x3F));
WriteUtf16_WCHAR(val, pUnicodeString);
lIndex += 5;
}
else
{
int val = (int)(((byteMain & 0x01) << 30) |
((pBuffer[lIndex + 1] & 0x3F) << 24) |
((pBuffer[lIndex + 2] & 0x3F) << 18) |
((pBuffer[lIndex + 3] & 0x3F) << 12) |
((pBuffer[lIndex + 4] & 0x3F) << 6) |
(pBuffer[lIndex + 5] & 0x3F));
WriteUtf16_WCHAR(val, pUnicodeString);
lIndex += 5;
}
}
*pUnicodeString++ = 0;
sOutput.append(pStart);
delete [] pStart;
} | 1 | 15,16,22,23,24,30,31,32,33,39,40,41,42,48,49,50,51,52,58,59,60,61,62,63 | -1 | https://github.com/ONLYOFFICE/core/commit/88cf60a3ed4a2b40d71a1c2ced72fa3902a30967 | 0CCPP |
int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
{
struct bpf_verifier_env *env;
struct bpf_verifer_log *log;
int ret = -EINVAL;
if (ARRAY_SIZE(bpf_verifier_ops) == 0)
return -EINVAL;
env = kzalloc(sizeof(struct bpf_verifier_env), GFP_KERNEL);
if (!env)
return -ENOMEM;
log = &env->log;
env->insn_aux_data = vzalloc(sizeof(struct bpf_insn_aux_data) *
(*prog)->len);
ret = -ENOMEM;
if (!env->insn_aux_data)
goto err_free_env;
env->prog = *prog;
env->ops = bpf_verifier_ops[env->prog->type];
mutex_lock(&bpf_verifier_lock);
if (attr->log_level || attr->log_buf || attr->log_size) {
log->level = attr->log_level;
log->ubuf = (char __user *) (unsigned long) attr->log_buf;
log->len_total = attr->log_size;
ret = -EINVAL;
if (log->len_total < 128 || log->len_total > UINT_MAX >> 8 ||
!log->level || !log->ubuf)
goto err_unlock;
}
env->strict_alignment = !!(attr->prog_flags & BPF_F_STRICT_ALIGNMENT);
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
env->strict_alignment = true;
if (env->prog->aux->offload) {
ret = bpf_prog_offload_verifier_prep(env);
if (ret)
goto err_unlock;
}
ret = replace_map_fd_with_map_ptr(env);
if (ret < 0)
goto skip_full_check;
env->explored_states = kcalloc(env->prog->len,
sizeof(struct bpf_verifier_state_list *),
GFP_USER);
ret = -ENOMEM;
if (!env->explored_states)
goto skip_full_check;
ret = check_cfg(env);
if (ret < 0)
goto skip_full_check;
env->allow_ptr_leaks = capable(CAP_SYS_ADMIN);
ret = do_check(env);
if (env->cur_state) {
free_verifier_state(env->cur_state, true);
env->cur_state = NULL;
}
skip_full_check:
while (!pop_stack(env, NULL, NULL));
free_states(env);
if (ret == 0)
ret = convert_ctx_accesses(env);
if (ret == 0)
ret = fixup_bpf_calls(env);
if (log->level && bpf_verifier_log_full(log))
ret = -ENOSPC;
if (log->level && !log->ubuf) {
ret = -EFAULT;
goto err_release_maps;
}
if (ret == 0 && env->used_map_cnt) {
env->prog->aux->used_maps = kmalloc_array(env->used_map_cnt,
sizeof(env->used_maps[0]),
GFP_KERNEL);
if (!env->prog->aux->used_maps) {
ret = -ENOMEM;
goto err_release_maps;
}
memcpy(env->prog->aux->used_maps, env->used_maps,
sizeof(env->used_maps[0]) * env->used_map_cnt);
env->prog->aux->used_map_cnt = env->used_map_cnt;
convert_pseudo_ld_imm64(env);
}
err_release_maps:
if (!env->prog->aux->used_maps)
release_maps(env);
*prog = env->prog;
err_unlock:
mutex_unlock(&bpf_verifier_lock);
vfree(env->insn_aux_data);
err_free_env:
kfree(env);
return ret;
} | 1 | null | -1 | https://github.com/torvalds/linux/commit/c131187db2d3fa2f8bf32fdf4e9a4ef805168467 | 0CCPP |
mxCellEditor.prototype.installListeners=function(a){mxEvent.addListener(a,"dragstart",mxUtils.bind(this,function(d){this.graph.stopEditing(!1);mxEvent.consume(d)}));mxEvent.addListener(a,"blur",mxUtils.bind(this,function(d){this.blurEnabled&&this.focusLost(d)}));mxEvent.addListener(a,"keydown",mxUtils.bind(this,function(d){mxEvent.isConsumed(d)||(this.isStopEditingEvent(d)?(this.graph.stopEditing(!1),mxEvent.consume(d)):27==d.keyCode&&(this.graph.stopEditing(this.isCancelEditingKeyEvent(d)),mxEvent.consume(d)))}));
var b=mxUtils.bind(this,function(d){null!=this.editingCell&&this.clearOnChange&&a.innerHTML==this.getEmptyLabelText()&&(!mxClient.IS_FF||8!=d.keyCode&&46!=d.keyCode)&&(this.clearOnChange=!1,a.innerHTML="")});mxEvent.addListener(a,"keypress",b);mxEvent.addListener(a,"paste",b);b=mxUtils.bind(this,function(d){null!=this.editingCell&&(0==this.textarea.innerHTML.length||"<br>"==this.textarea.innerHTML?(this.textarea.innerHTML=this.getEmptyLabelText(),this.clearOnChange=0<this.textarea.innerHTML.length):
this.clearOnChange=!1)});mxEvent.addListener(a,mxClient.IS_IE11||mxClient.IS_IE?"keyup":"input",b);mxEvent.addListener(a,"cut",b);mxEvent.addListener(a,"paste",b);b=mxClient.IS_IE11||mxClient.IS_IE?"keydown":"input";var c=mxUtils.bind(this,function(d){null!=this.editingCell&&this.autoSize&&!mxEvent.isConsumed(d)&&(null!=this.resizeThread&&window.clearTimeout(this.resizeThread),this.resizeThread=window.setTimeout(mxUtils.bind(this,function(){this.resizeThread=null;this.resize()}),0))});mxEvent.addListener(a,
b,c);mxEvent.addListener(window,"resize",c);9<=document.documentMode?(mxEvent.addListener(a,"DOMNodeRemoved",c),mxEvent.addListener(a,"DOMNodeInserted",c)):(mxEvent.addListener(a,"cut",c),mxEvent.addListener(a,"paste",c))};mxCellEditor.prototype.isStopEditingEvent=function(a){return 113==a.keyCode||this.graph.isEnterStopsCellEditing()&&13==a.keyCode&&!mxEvent.isControlDown(a)&&!mxEvent.isShiftDown(a)};mxCellEditor.prototype.isEventSource=function(a){return mxEvent.getSource(a)==this.textarea}; | 1 | 1 | -1 | https://github.com/jgraph/drawio/commit/3d3f819d7a04da7d53b37cc0ca4269c157ba2825 | 3JavaScript |
static int __packet_rcv_vnet(const struct sk_buff *skb,
struct virtio_net_hdr *vnet_hdr)
{
*vnet_hdr = (const struct virtio_net_hdr) { 0 };
if (virtio_net_hdr_from_skb(skb, vnet_hdr, vio_le()))
BUG();
return 0;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/84ac7260236a49c79eede91617700174c2c19b0c | 0CCPP |
void ItemStackMetadata::serialize(std::ostream &os) const
{
std::ostringstream os2;
os2 << DESERIALIZE_START;
for (const auto &stringvar : m_stringvars) {
if (!stringvar.first.empty() || !stringvar.second.empty())
os2 << stringvar.first << DESERIALIZE_KV_DELIM
<< stringvar.second << DESERIALIZE_PAIR_DELIM;
}
os << serializeJsonStringIfNeeded(os2.str());
} | 0 | null | -1 | https://github.com/minetest/minetest/commit/b5956bde259faa240a81060ff4e598e25ad52dae | 0CCPP |
static int hgcm_call_preprocess_linaddr(
const struct vmmdev_hgcm_function_parameter *src_parm,
void **bounce_buf_ret, size_t *extra)
{
void *buf, *bounce_buf;
bool copy_in;
u32 len;
int ret;
buf = (void *)src_parm->u.pointer.u.linear_addr;
len = src_parm->u.pointer.size;
copy_in = src_parm->type != VMMDEV_HGCM_PARM_TYPE_LINADDR_OUT;
if (len > VBG_MAX_HGCM_USER_PARM)
return -E2BIG;
bounce_buf = kvmalloc(len, GFP_KERNEL);
if (!bounce_buf)
return -ENOMEM;
if (copy_in) {
ret = copy_from_user(bounce_buf, (void __user *)buf, len);
if (ret)
return -EFAULT;
} else {
memset(bounce_buf, 0, len);
}
*bounce_buf_ret = bounce_buf;
hgcm_call_add_pagelist_size(bounce_buf, len, extra);
return 0;
} | 1 | 23 | -1 | https://github.com/torvalds/linux/commit/e0b0cb9388642c104838fac100a4af32745621e2 | 0CCPP |
public get(section: any, defaultValue?: any) {
if (SECURITY_SENSITIVE_CONFIG.includes(section)) {
const inspect = this._wrapped.inspect(section);
return inspect.globalValue ?? defaultValue ?? inspect.defaultValue;
}
return this._wrapped.get(section, defaultValue);
} | 0 | null | -1 | https://github.com/vscode-restructuredtext/vscode-restructuredtext/commit/1dd3e878a5559e3dfe0e48f145c90418b208c5af | 5TypeScript |
Runnable.prototype.inspect = function(){
return JSON.stringify(this, function(key, val){
if ('_' == key[0]) return;
if ('parent' == key) return '#<Suite>';
if ('ctx' == key) return '#<Context>';
return val;
}, 2);
}; | 1 | 0,1 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
start: this.data[this.hitTest(start)].x,
end: this.data[this.hitTest(end)].x
});
return this.selectFrom = null;
}
};
Grid.prototype.resizeHandler = function() {
this.timeoutId = null;
this.raphael.setSize(this.el.width(), this.el.height());
return this.redraw();
};
return Grid;
})(Morris.EventEmitter); | 0 | null | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
static void hash_sock_destruct(struct sock *sk)
{
struct alg_sock *ask = alg_sk(sk);
struct hash_ctx *ctx = ask->private;
sock_kfree_s(sk, ctx->result,
crypto_ahash_digestsize(crypto_ahash_reqtfm(&ctx->req)));
sock_kfree_s(sk, ctx, ctx->len);
af_alg_release_parent(sk);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c | 0CCPP |
void modbusServerRegisterConnectionEvents(ModbusClientConnection *connection,
SocketEventDesc *eventDesc)
{
if(connection->state == MODBUS_CONNECTION_STATE_CONNECT_TLS)
{
#if (MODBUS_SERVER_TLS_SUPPORT == ENABLED)
if(tlsIsTxReady(connection->tlsContext))
{
eventDesc->socket = connection->socket;
eventDesc->eventMask = SOCKET_EVENT_TX_READY;
}
else
{
eventDesc->socket = connection->socket;
eventDesc->eventMask = SOCKET_EVENT_RX_READY;
}
#endif
}
else if(connection->state == MODBUS_CONNECTION_STATE_RECEIVE)
{
#if (MODBUS_SERVER_TLS_SUPPORT == ENABLED)
if(connection->tlsContext != NULL &&
tlsIsRxReady(connection->tlsContext))
{
eventDesc->eventFlags |= SOCKET_EVENT_RX_READY;
}
else
#endif
{
eventDesc->socket = connection->socket;
eventDesc->eventMask = SOCKET_EVENT_RX_READY;
}
}
else if(connection->state == MODBUS_CONNECTION_STATE_SEND ||
connection->state == MODBUS_CONNECTION_STATE_SHUTDOWN_TLS)
{
eventDesc->socket = connection->socket;
eventDesc->eventMask = SOCKET_EVENT_TX_READY;
}
else if(connection->state == MODBUS_CONNECTION_STATE_SHUTDOWN_TX)
{
eventDesc->socket = connection->socket;
eventDesc->eventMask = SOCKET_EVENT_TX_SHUTDOWN;
}
else if(connection->state == MODBUS_CONNECTION_STATE_SHUTDOWN_RX)
{
eventDesc->socket = connection->socket;
eventDesc->eventMask = SOCKET_EVENT_RX_SHUTDOWN;
}
else
{
}
} | 0 | null | -1 | https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366 | 0CCPP |
public virtual async Task<ParentsResponse> ParentsAsync(ParentsCommand cmd, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var parentsResp = new ParentsResponse();
var targetPath = cmd.TargetPath;
var targetDir = targetPath.Directory;
var volume = targetPath.Volume;
var targetHash = targetPath.HashedTarget;
if (targetPath.IsRoot)
{
parentsResp.tree.Add(await targetDir.ToFileInfoAsync(targetHash, null, volume, connector.Options, cancellationToken: cancellationToken));
}
else
{
await AddParentsToListAsync(targetPath, parentsResp.tree, cancellationToken: cancellationToken);
}
return parentsResp;
} | 0 | null | -1 | https://github.com/trannamtrung1st/elFinder.Net.Core/commit/5498c8a86b76ef089cfbd7ef8be014b61fa11c73 | 1CS |
def handle_logged_in(self, request, conn, connector):
if request.session.get("active_group"):
if (
request.session.get("active_group")
not in conn.getEventContext().memberOfGroups
):
del request.session["active_group"]
if request.session.get("user_id"):
del request.session["user_id"]
if request.session.get("server_settings"):
del request.session["server_settings"]
if request.POST.get("noredirect"):
return HttpResponse("OK")
url = request.GET.get("url")
if url is None or len(url) == 0:
try:
url = parse_url(settings.LOGIN_REDIRECT)
except Exception:
url = reverse("webindex")
return HttpResponseRedirect(url)
| 1 | null | -1 | https://github.com/ome/omero-web.git/commit/952f8e5d28532fbb14fb665982211329d137908c | 4Python |
Server.prototype.address = function() {
return this._srv.address();
}; | 1 | 0,1,2 | -1 | https://github.com/mscdex/ssh2/commit/f763271f41320e71d5cbee02ea5bc6a2ded3ca21 | 3JavaScript |
var extractImageFromDataUrl = (jsPDFAPI.__addimage__.extractImageFromDataUrl = function(
dataUrl
) {
dataUrl = dataUrl || "";
var dataUrlParts = dataUrl.split("base64,");
var result = null;
if (dataUrlParts.length === 2) {
var extractedInfo = /^data:(\w*\/\w*);*(charset=[\w=-]*)*;*$/.exec(
dataUrlParts[0]
);
if (Array.isArray(extractedInfo)) {
result = {
mimeType: extractedInfo[1],
charset: extractedInfo[2],
data: dataUrlParts[1]
};
}
}
return result;
}); | 1 | 7 | -1 | https://github.com/parallax/jsPDF/commit/d8bb3b39efcd129994f7a3b01b632164144ec43e | 3JavaScript |
static ssize_t map_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos,
int cap_setid,
struct uid_gid_map *map,
struct uid_gid_map *parent_map)
{
struct seq_file *seq = file->private_data;
struct user_namespace *ns = seq->private;
struct uid_gid_map new_map;
unsigned idx;
struct uid_gid_extent extent;
char *kbuf = NULL, *pos, *next_line;
ssize_t ret;
if ((*ppos != 0) || (count >= PAGE_SIZE))
return -EINVAL;
kbuf = memdup_user_nul(buf, count);
if (IS_ERR(kbuf))
return PTR_ERR(kbuf);
mutex_lock(&userns_state_mutex);
memset(&new_map, 0, sizeof(struct uid_gid_map));
ret = -EPERM;
if (map->nr_extents != 0)
goto out;
if (cap_valid(cap_setid) && !file_ns_capable(file, ns, CAP_SYS_ADMIN))
goto out;
ret = -EINVAL;
pos = kbuf;
for (; pos; pos = next_line) {
next_line = strchr(pos, '\n');
if (next_line) {
*next_line = '\0';
next_line++;
if (*next_line == '\0')
next_line = NULL;
}
pos = skip_spaces(pos);
extent.first = simple_strtoul(pos, &pos, 10);
if (!isspace(*pos))
goto out;
pos = skip_spaces(pos);
extent.lower_first = simple_strtoul(pos, &pos, 10);
if (!isspace(*pos))
goto out;
pos = skip_spaces(pos);
extent.count = simple_strtoul(pos, &pos, 10);
if (*pos && !isspace(*pos))
goto out;
pos = skip_spaces(pos);
if (*pos != '\0')
goto out;
if ((extent.first == (u32) -1) ||
(extent.lower_first == (u32) -1))
goto out;
if ((extent.first + extent.count) <= extent.first)
goto out;
if ((extent.lower_first + extent.count) <=
extent.lower_first)
goto out;
if (mappings_overlap(&new_map, &extent))
goto out;
if ((new_map.nr_extents + 1) == UID_GID_MAP_MAX_EXTENTS &&
(next_line != NULL))
goto out;
ret = insert_extent(&new_map, &extent);
if (ret < 0)
goto out;
ret = -EINVAL;
}
if (new_map.nr_extents == 0)
goto out;
ret = -EPERM;
if (!new_idmap_permitted(file, ns, cap_setid, &new_map))
goto out;
ret = sort_idmaps(&new_map);
if (ret < 0)
goto out;
ret = -EPERM;
for (idx = 0; idx < new_map.nr_extents; idx++) {
struct uid_gid_extent *e;
u32 lower_first;
if (new_map.nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS)
e = &new_map.extent[idx];
else
e = &new_map.forward[idx];
lower_first = map_id_range_down(parent_map,
e->lower_first,
e->count);
if (lower_first == (u32) -1)
goto out;
e->lower_first = lower_first;
}
if (new_map.nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS) {
memcpy(map->extent, new_map.extent,
new_map.nr_extents * sizeof(new_map.extent[0]));
} else {
map->forward = new_map.forward;
map->reverse = new_map.reverse;
}
smp_wmb();
map->nr_extents = new_map.nr_extents;
*ppos = count;
ret = count;
out:
if (ret < 0 && new_map.nr_extents > UID_GID_MAP_MAX_BASE_EXTENTS) {
kfree(new_map.forward);
kfree(new_map.reverse);
map->forward = NULL;
map->reverse = NULL;
map->nr_extents = 0;
}
mutex_unlock(&userns_state_mutex);
kfree(kbuf);
return ret;
} | 1 | 73,74,75 | -1 | https://github.com/torvalds/linux/commit/d2f007dbe7e4c9583eea6eb04d60001e85c6f1bd | 0CCPP |
uint64 FunctionDefHash(const FunctionDef& fdef) {
uint64 h = OpDefHash(fdef.signature());
std::map<string, AttrValue> attrs = GetSetAttrs(fdef);
for (const auto& p : attrs) {
h = Hash64(p.first.data(), p.first.size(), h);
h = Hash64Combine(AttrValueHash(p.second), h);
}
h = Hash64Combine(RepeatedNodeDefHash(fdef.node_def()), h);
std::map<string, string> ret(fdef.ret().begin(), fdef.ret().end());
for (const auto& p : ret) {
h = Hash64(p.first.data(), p.first.size(), h);
h = Hash64(p.second.data(), p.second.size(), h);
}
std::map<string, string> control_ret(fdef.control_ret().begin(),
fdef.control_ret().end());
for (const auto& p : control_ret) {
h = Hash64(p.first.data(), p.first.size(), h);
h = Hash64(p.second.data(), p.second.size(), h);
}
return h;
} | 0 | null | -1 | https://github.com/tensorflow/tensorflow/commit/dcc21c7bc972b10b6fb95c2fb0f4ab5a59680ec2 | 0CCPP |
public String getSQL(Select select) {
StringBuilder sql = new StringBuilder();
String selectClause = getSelectSQL(select);
sql.append(selectClause);
sql.append(" ").append(getFromSQL(select));
List<Condition> wheres = select.getWheres();
if (!wheres.isEmpty()) {
sql.append(" ").append(getWhereSQL(select));
}
List<Column> groupBys = select.getGroupBys();
if (!groupBys.isEmpty()) {
sql.append(" ").append(getGroupBySQL(select));
}
List<SortColumn> orderBys = select.getOrderBys();
if (!orderBys.isEmpty()) {
sql.append(" ").append(getOrderBySQL(select));
}
int limit = select.getLimit();
int offset = select.getOffset();
if (limit > 0 || offset > 0) {
String limitSql = getOffsetLimitSQL(select);
if (!StringUtils.isBlank(limitSql)) {
sql.append(limitSql);
}
}
return sql.toString();
} | 0 | null | -1 | https://github.com/dashbuilder/dashbuilder/commit/8574899e3b6455547b534f570b2330ff772e524b | 2Java |
RawTile TileManager::getRegion( unsigned int res, int seq, int ang, int layers, unsigned int x, unsigned int y, unsigned int width, unsigned int height ){
if( image->regionDecoding() ){
if( loglevel >= 3 ){
*logfile << "TileManager getRegion :: requesting region directly from image" << endl;
}
return image->getRegion( seq, ang, res, layers, x, y, width, height );
}
unsigned int src_tile_width = image->getTileWidth();
unsigned int src_tile_height = image->getTileHeight();
unsigned int dst_tile_width = src_tile_width;
unsigned int dst_tile_height = src_tile_height;
unsigned int basic_tile_width = src_tile_width;
unsigned int basic_tile_height = src_tile_height;
int num_res = image->getNumResolutions();
unsigned int im_width = image->image_widths[num_res-res-1];
unsigned int im_height = image->image_heights[num_res-res-1];
unsigned int rem_x = im_width % src_tile_width;
unsigned int rem_y = im_height % src_tile_height;
unsigned int ntlx = (im_width / src_tile_width) + (rem_x == 0 ? 0 : 1);
unsigned int ntly = (im_height / src_tile_height) + (rem_y == 0 ? 0 : 1);
unsigned int startx, endx, starty, endy, xoffset, yoffset;
if( ! ( x==0 && y==0 && width==im_width && height==im_height ) ){
startx = (unsigned int) ( x / src_tile_width );
starty = (unsigned int) ( y / src_tile_height );
xoffset = x % src_tile_width;
yoffset = y % src_tile_height;
endx = (unsigned int) ceil( (float)(width + x) / (float)src_tile_width );
endy = (unsigned int) ceil( (float)(height + y) / (float)src_tile_height );
if( loglevel >= 3 ){
*logfile << "TileManager getRegion :: Total tiles in image: " << ntlx << "x" << ntly << " tiles" << endl
<< "TileManager getRegion :: Tile start: " << startx << "," << starty << " with offset: "
<< xoffset << "," << yoffset << endl
<< "TileManager getRegion :: Tile end: " << endx-1 << "," << endy-1 << endl;
}
}
else{
startx = starty = xoffset = yoffset = 0;
endx = ntlx;
endy = ntly;
}
unsigned int channels = image->getNumChannels();
unsigned int bpc = image->getNumBitsPerPixel();
SampleType sampleType = image->getSampleType();
if( bpc == 1 ) bpc = 8;
RawTile region( 0, res, seq, ang, width, height, channels, bpc );
region.dataLength = width * height * channels * (bpc/8);
region.sampleType = sampleType;
if( bpc == 8 ) region.data = new unsigned char[width*height*channels];
else if( bpc == 16 ) region.data = new unsigned short[width*height*channels];
else if( bpc == 32 && sampleType == FIXEDPOINT ) region.data = new int[width*height*channels];
else if( bpc == 32 && sampleType == FLOATINGPOINT ) region.data = new float[width*height*channels];
unsigned int current_height = 0;
for( unsigned int i=starty; i<endy; i++ ){
unsigned int buffer_index = 0;
unsigned int current_width = 0;
for( unsigned int j=startx; j<endx; j++ ){
if( loglevel >= 3 ) tile_timer.start();
RawTile rawtile = this->getTile( res, (i*ntlx) + j, seq, ang, layers, UNCOMPRESSED );
if( loglevel >= 5 ){
*logfile << "TileManager getRegion :: Tile access time " << tile_timer.getTime() << " microseconds for tile "
<< (i*ntlx) + j << " at resolution " << res << endl;
}
if( (loglevel >= 5) && (i==starty) && (j==starty) ){
*logfile << "TileManager getRegion :: Tile data is " << rawtile.channels << " channels, "
<< rawtile.bpc << " bits per channel" << endl;
}
src_tile_width = rawtile.width;
src_tile_height = rawtile.height;
dst_tile_width = src_tile_width;
dst_tile_height = src_tile_height;
unsigned int xf = 0;
unsigned int yf = 0;
if( !( x==0 && y==0 && width==im_width && height==im_height ) ){
unsigned int remainder;
if( j == startx ){
if( j < endx - 1 ) dst_tile_width = src_tile_width - xoffset;
else dst_tile_width = width;
xf = xoffset;
}
else if( j == endx-1 ){
remainder = (width+x) % basic_tile_width;
if( remainder != 0 ) dst_tile_width = remainder;
}
if( i == starty ){
if( i < endy - 1 ) dst_tile_height = src_tile_height - yoffset;
else dst_tile_height = height;
yf = yoffset;
}
else if( i == endy-1 ){
remainder = (height+y) % basic_tile_height;
if( remainder != 0 ) dst_tile_height = remainder;
}
if( loglevel >= 5 ){
*logfile << "TileManager getRegion :: destination tile width: " << dst_tile_width
<< ", tile height: " << dst_tile_height << endl;
}
}
for( unsigned int k=0; k<dst_tile_height; k++ ){
buffer_index = (current_width*channels) + (k*width*channels) + (current_height*width*channels);
unsigned int inx = ((k+yf)*rawtile.width*channels) + (xf*channels);
if( bpc == 8 ){
unsigned char* ptr = (unsigned char*) rawtile.data;
unsigned char* buf = (unsigned char*) region.data;
memcpy( &buf[buffer_index], &ptr[inx], dst_tile_width*channels );
}
else if( bpc == 16 ){
unsigned short* ptr = (unsigned short*) rawtile.data;
unsigned short* buf = (unsigned short*) region.data;
memcpy( &buf[buffer_index], &ptr[inx], dst_tile_width*channels*2 );
}
else if( bpc == 32 && sampleType == FIXEDPOINT ){
unsigned int* ptr = (unsigned int*) rawtile.data;
unsigned int* buf = (unsigned int*) region.data;
memcpy( &buf[buffer_index], &ptr[inx], dst_tile_width*channels*4 );
}
else if( bpc == 32 && sampleType == FLOATINGPOINT ){
float* ptr = (float*) rawtile.data;
float* buf = (float*) region.data;
memcpy( &buf[buffer_index], &ptr[inx], dst_tile_width*channels*4 );
}
}
current_width += dst_tile_width;
}
current_height += dst_tile_height;
}
return region;
} | 1 | 45,47,48,49,50,53 | -1 | https://github.com/ruven/iipsrv/commit/882925b295a80ec992063deffc2a3b0d803c3195 | 0CCPP |
static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg)
{
return &tg->cfs_bandwidth;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/c40f7d74c741a907cfaeb73a7697081881c497d0 | 0CCPP |
ternary: function() {
var test = this.logicalOR();
var alternate;
var consequent;
if (this.expect('?')) {
alternate = this.expression();
if (this.consume(':')) {
consequent = this.expression();
return { type: AST.ConditionalExpression, test: test, alternate: alternate, consequent: consequent};
}
}
return test;
}, | 1 | 0,1,2,3,4,5,6,7,8,9,10,11,12 | -1 | https://github.com/peerigon/angular-expressions/commit/061addfb9a9e932a970e5fcb913d020038e65667 | 3JavaScript |
static void perf_event_for_each(struct perf_event *event,
void (*func)(struct perf_event *))
{
struct perf_event_context *ctx = event->ctx;
struct perf_event *sibling;
WARN_ON_ONCE(ctx->parent_ctx);
mutex_lock(&ctx->mutex);
event = event->group_leader;
perf_event_for_each_child(event, func);
list_for_each_entry(sibling, &event->sibling_list, group_entry)
perf_event_for_each_child(sibling, func);
mutex_unlock(&ctx->mutex);
} | 1 | 5,6,11 | -1 | https://github.com/torvalds/linux/commit/f63a8daa5812afef4f06c962351687e1ff9ccb2b | 0CCPP |
function checkArrayTypes() {
for (var i = 0; i < arguments.length; i++) {
if (!(arguments[i] instanceof Uint8Array))
throw new TypeError('unexpected type, use Uint8Array');
}
} | 0 | null | -1 | https://github.com/TogaTech/tEnvoy/commit/a121b34a45e289d775c62e58841522891dee686b | 3JavaScript |
static word32 SetOctetString8Bit(word32 len, byte* output)
{
output[0] = ASN_OCTET_STRING;
output[1] = (byte)len;
return 2;
} | 0 | null | -1 | https://github.com/wolfSSL/wolfssl/commit/f93083be72a3b3d956b52a7ec13f307a27b6e093 | 0CCPP |
def destroy(self):
for message_client in self.message_clients:
message_client.destroy()
self.message_clients = []
| 0 | null | -1 | https://github.com/saltstack/salt.git/commit/5f8b5e1a0f23fe0f2be5b3c3e04199b57a53db5b | 4Python |
std::string WC2MB(const std::wstring& input, unsigned int code_page) {
if (input.empty()) {
return "";
}
// There do have other code pages which require the flags to be 0, e.g.,
// 50220, 50211, and so on. But they are not included in our charset
// dictionary. So, only consider 65001 (UTF-8) and 54936 (GB18030).
DWORD flags = 0;
if (code_page != 65001 && code_page != 54936) {
flags = WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR;
}
int length = ::WideCharToMultiByte(code_page, flags, &input[0],
static_cast<int>(input.size()), NULL, 0,
NULL, NULL);
std::string output(length, '\0');
::WideCharToMultiByte(code_page, flags, &input[0],
static_cast<int>(input.size()), &output[0],
static_cast<int>(output.size()), NULL, NULL);
return output;
} | 1 | 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 | -1 | https://github.com/sprinfall/webcc/commit/55a45fd5039061d5cc62e9f1b9d1f7e97a15143f | 0CCPP |
int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len,
const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)
{
ECDSA_SIG *s;
int ret=-1;
s = ECDSA_SIG_new();
if (s == NULL) return(ret);
if (d2i_ECDSA_SIG(&s, &sigbuf, sig_len) == NULL) goto err;
ret=ECDSA_do_verify(dgst, dgst_len, s, eckey);
err:
ECDSA_SIG_free(s);
return(ret);
} | 1 | 7 | -1 | https://github.com/openssl/openssl/commit/684400ce192dac51df3d3e92b61830a6ef90be3e | 0CCPP |
[CHECKPATH] (entry) {
if (this.strip) {
const parts = entry.path.split(/\/|\\/)
if (parts.length < this.strip)
return false
entry.path = parts.slice(this.strip).join('/')
if (entry.type === 'Link') {
const linkparts = entry.linkpath.split(/\/|\\/)
if (linkparts.length >= this.strip)
entry.linkpath = linkparts.slice(this.strip).join('/')
}
}
if (!this.preservePaths) {
const p = entry.path
if (p.match(/(^|\/|\\)\.\.(\\|\/|$)/)) {
this.warn('TAR_ENTRY_ERROR', `path contains '..'`, {
entry,
path: p,
})
return false
}
if (path.win32.isAbsolute(p)) {
const parsed = path.win32.parse(p)
entry.path = p.substr(parsed.root.length)
const r = parsed.root
this.warn('TAR_ENTRY_INFO', `stripping ${r} from absolute path`, {
entry,
path: p,
})
}
}
if (this.win32) {
const parsed = path.win32.parse(entry.path)
entry.path = parsed.root === '' ? wc.encode(entry.path)
: parsed.root + wc.encode(entry.path.substr(parsed.root.length))
}
if (path.isAbsolute(entry.path))
entry.absolute = entry.path
else
entry.absolute = path.resolve(this.cwd, entry.path)
return true
} | 1 | 21,22,23,24,25 | -1 | https://github.com/isaacs/node-tar/commit/1f036ca23f64a547bdd6c79c1a44bc62e8115da4 | 3JavaScript |
rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
const struct rpc_call_ops *tk_ops, void *data)
{
struct rpc_task *task;
struct rpc_task_setup task_setup_data = {
.rpc_client = clnt,
.rpc_message = msg,
.callback_ops = tk_ops,
.callback_data = data,
.flags = flags|RPC_TASK_ASYNC,
};
task = rpc_run_task(&task_setup_data);
if (IS_ERR(task))
return PTR_ERR(task);
rpc_put_task(task);
return 0;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/0b760113a3a155269a3fba93a409c640031dd68f | 0CCPP |
Elf32_Sym const *PackLinuxElf32::elf_lookup(char const *name) const
{
if (hashtab && dynsym && dynstr) {
unsigned const nbucket = get_te32(&hashtab[0]);
unsigned const *const buckets = &hashtab[2];
unsigned const *const chains = &buckets[nbucket];
unsigned const m = elf_hash(name) % nbucket;
unsigned si;
for (si= get_te32(&buckets[m]); 0!=si; si= get_te32(&chains[si])) {
char const *const p= get_dynsym_name(si, (unsigned)-1);
if (0==strcmp(name, p)) {
return &dynsym[si];
}
}
}
if (gashtab && dynsym && dynstr) {
unsigned const n_bucket = get_te32(&gashtab[0]);
unsigned const symbias = get_te32(&gashtab[1]);
unsigned const n_bitmask = get_te32(&gashtab[2]);
unsigned const gnu_shift = get_te32(&gashtab[3]);
unsigned const *const bitmask = &gashtab[4];
unsigned const *const buckets = &bitmask[n_bitmask];
unsigned const *const hasharr = &buckets[n_bucket];
unsigned const h = gnu_hash(name);
unsigned const hbit1 = 037& h;
unsigned const hbit2 = 037& (h>>gnu_shift);
unsigned const w = get_te32(&bitmask[(n_bitmask -1) & (h>>5)]);
if (1& (w>>hbit1) & (w>>hbit2)) {
unsigned bucket = get_te32(&buckets[h % n_bucket]);
if (0!=bucket) {
Elf32_Sym const *dsp = &dynsym[bucket];
unsigned const *hp = &hasharr[bucket - symbias];
do if (0==((h ^ get_te32(hp))>>1)) {
unsigned st_name = get_te32(&dsp->st_name);
char const *const p = get_str_name(st_name, (unsigned)-1);
if (0==strcmp(name, p)) {
return dsp;
}
} while (++dsp, 0==(1u& get_te32(hp++)));
}
}
}
return 0;
} | 0 | null | -1 | https://github.com/upx/upx/commit/8be9da8280dfa69d5df4417d4d81bda1cab78010 | 0CCPP |
static unsigned readChunk_pHYs(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
if(chunkLength != 9) return 74;
info->phys_defined = 1;
info->phys_x = 16777216u * data[0] + 65536u * data[1] + 256u * data[2] + data[3];
info->phys_y = 16777216u * data[4] + 65536u * data[5] + 256u * data[6] + data[7];
info->phys_unit = data[8];
return 0;
} | 0 | null | -1 | https://github.com/FreeRDP/FreeRDP/commit/9fee4ae076b1ec97b97efb79ece08d1dab4df29a | 0CCPP |
!0,d=JSON.parse(this.getPersistentToken(!0));null!=d?(new mxXmlRequest(this.redirectUri+"?state="+encodeURIComponent("cId="+this.clientId+"&domain="+window.location.hostname+"&token="+e),null,"GET")).send(mxUtils.bind(this,function(g){200<=g.getStatus()&&299>=g.getStatus()?this.updateAuthInfo(JSON.parse(g.getText()),d.remember,!1,f,c):(this.clearPersistentToken(),this.setUser(null),b=null,401!=g.getStatus()||m?c({message:mxResources.get("accessDenied"),retry:n}):n())}),c):this.ui.showAuthDialog(this, | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
static void vgacon_scrollback_switch(int vc_num)
{
if (!scrollback_persistent)
vc_num = 0;
if (!vgacon_scrollbacks[vc_num].data) {
vgacon_scrollback_init(vc_num);
} else {
if (scrollback_persistent) {
vgacon_scrollback_cur = &vgacon_scrollbacks[vc_num];
} else {
size_t size = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024;
vgacon_scrollback_reset(vc_num, size);
}
}
} | 1 | 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 | -1 | https://github.com/torvalds/linux/commit/973c096f6a85e5b5f2a295126ba6928d9a6afd45 | 0CCPP |
def get_read_status_for_kobo(ub_book_read):
enum_to_string_map = {
None: "ReadyToRead",
ub.ReadBook.STATUS_UNREAD: "ReadyToRead",
ub.ReadBook.STATUS_FINISHED: "Finished",
ub.ReadBook.STATUS_IN_PROGRESS: "Reading",
}
return enum_to_string_map[ub_book_read.read_status]
| 0 | null | -1 | https://github.com/janeczku/calibre-web.git/commit/50919d47212066c75f03ee7a5332ecf2d584b98e | 4Python |
*/
int skb_checksum_setup(struct sk_buff *skb, bool recalculate)
{
int err;
switch (skb->protocol) {
case htons(ETH_P_IP):
err = skb_checksum_setup_ipv4(skb, recalculate);
break;
case htons(ETH_P_IPV6):
err = skb_checksum_setup_ipv6(skb, recalculate);
break;
default:
err = -EPROTO;
break;
}
return err; | 0 | null | -1 | https://github.com/torvalds/linux/commit/4ef1b2869447411ad3ef91ad7d4891a83c1a509a | 0CCPP |
static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
u16 selector, int seg)
{
u8 cpl = ctxt->ops->cpl(ctxt);
return __load_segment_descriptor(ctxt, selector, seg, cpl, false);
} | 1 | 4 | -1 | https://github.com/torvalds/linux/commit/d1442d85cc30ea75f7d399474ca738e0bc96f715 | 0CCPP |
static void icmp_address_reply(struct sk_buff *skb)
{
struct rtable *rt = skb_rtable(skb);
struct net_device *dev = skb->dev;
struct in_device *in_dev;
struct in_ifaddr *ifa;
if (skb->len < 4 || !(rt->rt_flags&RTCF_DIRECTSRC))
return;
in_dev = __in_dev_get_rcu(dev);
if (!in_dev)
return;
if (in_dev->ifa_list &&
IN_DEV_LOG_MARTIANS(in_dev) &&
IN_DEV_FORWARD(in_dev)) {
__be32 _mask, *mp;
mp = skb_header_pointer(skb, 0, sizeof(_mask), &_mask);
BUG_ON(mp == NULL);
for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
if (*mp == ifa->ifa_mask &&
inet_ifa_match(rt->rt_src, ifa))
break;
}
if (!ifa && net_ratelimit()) {
printk(KERN_INFO "Wrong address mask %pI4 from %s/%pI4\n",
mp, dev->name, &rt->rt_src);
}
}
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259 | 0CCPP |
static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
struct nlattr **attrs)
{
struct crypto_alg *alg;
struct crypto_user_alg *p = nlmsg_data(nlh);
int err;
if (!netlink_capable(skb, CAP_NET_ADMIN))
return -EPERM;
if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
return -EINVAL;
alg = crypto_alg_match(p, 1);
if (!alg)
return -ENOENT;
err = -EINVAL;
if (!(alg->cra_flags & CRYPTO_ALG_INSTANCE))
goto drop_alg;
err = -EBUSY;
if (refcount_read(&alg->cra_refcnt) > 2)
goto drop_alg;
err = crypto_unregister_instance((struct crypto_instance *)alg);
drop_alg:
crypto_mod_put(alg);
return err;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/f43f39958beb206b53292801e216d9b8a660f087 | 0CCPP |
fm.trigger('hover', {hash : $(this).attr('id'), type : e.type});
$(this).toggleClass('ui-state-hover');
}) | 1 | 0,1,2 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
vc4_job_done_work(struct work_struct *work)
{
struct vc4_dev *vc4 =
container_of(work, struct vc4_dev, job_done_work);
vc4_job_handle_completed(vc4);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/6b8ac63847bc2f958dd93c09edc941a0118992d9 | 0CCPP |
static int __init init_opl3 (void)
{
printk(KERN_INFO "YM3812 and OPL-3 driver Copyright (C) by Hannu Savolainen, Rob Hooft 1993-1996\n");
if (io != -1)
{
if (!opl3_detect(io))
{
return -ENODEV;
}
me = opl3_init(io, THIS_MODULE);
}
return 0;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/b769f49463711205d57286e64cf535ed4daf59e9 | 0CCPP |
fm.trigger('unlockfiles', {files : helper.data('files'), helper: helper});
}, | 1 | 0 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
static int checkout_action(
int *action,
checkout_data *data,
git_diff_delta *delta,
git_iterator *workdir,
const git_index_entry **wditem,
git_vector *pathspec)
{
int cmp = -1, error;
int (*strcomp)(const char *, const char *) = data->diff->strcomp;
int (*pfxcomp)(const char *str, const char *pfx) = data->diff->pfxcomp;
int (*advance)(const git_index_entry **, git_iterator *) = NULL;
while (1) {
const git_index_entry *wd = *wditem;
if (!wd)
return checkout_action_no_wd(action, data, delta);
cmp = strcomp(wd->path, delta->old_file.path);
if (cmp < 0) {
cmp = pfxcomp(delta->old_file.path, wd->path);
if (cmp == 0) {
if (wd->mode == GIT_FILEMODE_TREE) {
error = git_iterator_advance_into(wditem, workdir);
if (error < 0 && error != GIT_ITEROVER)
goto done;
continue;
}
if (delta->old_file.path[strlen(wd->path)] == '/') {
error = checkout_action_with_wd_blocker(
action, data, delta, wd);
advance = git_iterator_advance;
goto done;
}
}
error = checkout_action_wd_only(data, workdir, wditem, pathspec);
if (error && error != GIT_ITEROVER)
goto done;
continue;
}
if (cmp == 0) {
error = checkout_action_with_wd(action, data, delta, workdir, wd);
advance = git_iterator_advance;
goto done;
}
cmp = pfxcomp(wd->path, delta->old_file.path);
if (cmp == 0) {
if (wd->path[strlen(delta->old_file.path)] != '/')
return checkout_action_no_wd(action, data, delta);
if (delta->status == GIT_DELTA_TYPECHANGE) {
if (delta->old_file.mode == GIT_FILEMODE_TREE) {
error = checkout_action_with_wd(action, data, delta, workdir, wd);
advance = git_iterator_advance_into;
goto done;
}
if (delta->new_file.mode == GIT_FILEMODE_TREE ||
delta->new_file.mode == GIT_FILEMODE_COMMIT ||
delta->old_file.mode == GIT_FILEMODE_COMMIT)
{
error = checkout_action_with_wd(action, data, delta, workdir, wd);
advance = git_iterator_advance;
goto done;
}
}
return checkout_is_empty_dir(data, wd->path) ?
checkout_action_with_wd_dir_empty(action, data, delta) :
checkout_action_with_wd_dir(action, data, delta, workdir, wd);
}
return checkout_action_no_wd(action, data, delta);
}
done:
if (!error && advance != NULL &&
(error = advance(wditem, workdir)) < 0) {
*wditem = NULL;
if (error == GIT_ITEROVER)
error = 0;
}
return error;
} | 0 | null | -1 | https://github.com/libgit2/libgit2/commit/64c612cc3e25eff5fb02c59ef5a66ba7a14751e4 | 0CCPP |
def get_search_results(
self,
term,
offset=None,
order=None,
limit=None,
allow_show_archived=False,
config_read_column=False,
*join
):
order = order[0] if order else [Books.sort]
pagination = None
result = self.search_query(term, config_read_column, *join).order_by(*order).all()
result_count = len(result)
if offset != None and limit != None:
offset = int(offset)
limit_all = offset + int(limit)
pagination = Pagination((offset / (int(limit)) + 1), limit, result_count)
else:
offset = 0
limit_all = result_count
ub.store_combo_ids(result)
entries = self.order_authors(
result[offset:limit_all], list_return=True, combined=True
)
return entries, result_count, pagination
| 1 | 6 | -1 | https://github.com/janeczku/calibre-web.git/commit/4545f4a20d9ff90b99bbd4e3e34b6de4441d6367 | 4Python |
public ViteroGroupRoles getGroupRoles(int id)
throws VmsNotAvailableException {
try {
Group groupWs = getGroupWebService();
Groupid groupId = new Groupid();
groupId.setGroupid(id);
Group_Type group = groupWs.getGroup(groupId);
Completegrouptype groupType = group.getGroup();
List<Completegrouptype.Participant> participants = groupType.getParticipant();
int numOfParticipants = participants == null ? 0 : participants.size();
ViteroGroupRoles groupRoles = new ViteroGroupRoles();
if(numOfParticipants > 0) {
Map<Integer,String> idToEmails = new HashMap<>();
List<Usertype> vmsUsers = getVmsUsersByGroup(id);
if(vmsUsers != null) {
for(Usertype vmsUser:vmsUsers) {
Integer userId = Integer.valueOf(vmsUser.getId());
String email = vmsUser.getEmail();
groupRoles.getEmailsOfParticipants().add(email);
idToEmails.put(userId, email);
}
}
for(int i=0; i<numOfParticipants; i++) {
Completegrouptype.Participant participant = participants.get(i);
Integer userId = Integer.valueOf(participant.getUserid());
String email = idToEmails.get(userId);
if(email != null) {
GroupRole role = GroupRole.valueOf(participant.getRole());
groupRoles.getEmailsToRole().put(email, role);
groupRoles.getEmailsToVmsUserId().put(email, userId);
}
}
}
return groupRoles;
} catch(SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
default: logAxisError("Cannot get group roles",f);
}
return null;
} catch (WebServiceException e) {
if(e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
return null;
}
} | 0 | null | -1 | https://github.com/OpenOLAT/OpenOLAT/commit/3f219ac457afde82e3be57bc614352ab92c05684 | 2Java |
public synchronized MultiMap headers() {
if (headers == null) {
headers = new CaseInsensitiveHeaders();
}
return headers;
} | 1 | 2 | -1 | https://github.com/eclipse-vertx/vert.x/commit/1bb6445226c39a95e7d07ce3caaf56828e8aab72 | 2Java |
static void caif_ctrl_cb(struct cflayer *layr,
enum caif_ctrlcmd flow,
int phyid)
{
struct caifsock *cf_sk = container_of(layr, struct caifsock, layer);
switch (flow) {
case CAIF_CTRLCMD_FLOW_ON_IND:
set_tx_flow_on(cf_sk);
cf_sk->sk.sk_state_change(&cf_sk->sk);
break;
case CAIF_CTRLCMD_FLOW_OFF_IND:
set_tx_flow_off(cf_sk);
cf_sk->sk.sk_state_change(&cf_sk->sk);
break;
case CAIF_CTRLCMD_INIT_RSP:
caif_client_register_refcnt(&cf_sk->layer,
cfsk_hold, cfsk_put);
cf_sk->sk.sk_state = CAIF_CONNECTED;
set_tx_flow_on(cf_sk);
cf_sk->sk.sk_shutdown = 0;
cf_sk->sk.sk_state_change(&cf_sk->sk);
break;
case CAIF_CTRLCMD_DEINIT_RSP:
cf_sk->sk.sk_state = CAIF_DISCONNECTED;
cf_sk->sk.sk_state_change(&cf_sk->sk);
break;
case CAIF_CTRLCMD_INIT_FAIL_RSP:
cf_sk->sk.sk_err = ECONNREFUSED;
cf_sk->sk.sk_state = CAIF_DISCONNECTED;
cf_sk->sk.sk_shutdown = SHUTDOWN_MASK;
set_tx_flow_on(cf_sk);
cf_sk->sk.sk_state_change(&cf_sk->sk);
break;
case CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND:
cf_sk->sk.sk_shutdown = SHUTDOWN_MASK;
cf_sk->sk.sk_err = ECONNRESET;
set_rx_flow_on(cf_sk);
cf_sk->sk.sk_error_report(&cf_sk->sk);
break;
default:
pr_debug("Unexpected flow command %d\n", flow);
}
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/2d6fbfe733f35c6b355c216644e08e149c61b271 | 0CCPP |
static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
int op_flag,
unsigned int size,
unsigned int __user *tlv)
{
struct user_element *ue = kcontrol->private_data;
int change = 0;
void *new_data;
if (op_flag > 0) {
if (size > 1024 * 128)
return -EINVAL;
new_data = memdup_user(tlv, size);
if (IS_ERR(new_data))
return PTR_ERR(new_data);
change = ue->tlv_data_size != size;
if (!change)
change = memcmp(ue->tlv_data, new_data, size);
kfree(ue->tlv_data);
ue->tlv_data = new_data;
ue->tlv_data_size = size;
} else {
if (! ue->tlv_data_size || ! ue->tlv_data)
return -ENXIO;
if (size < ue->tlv_data_size)
return -ENOSPC;
if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size))
return -EFAULT;
}
return change;
} | 1 | 21,22,23,24,26 | -1 | https://github.com/torvalds/linux/commit/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92 | 0CCPP |
def is_valid_client_secret(client_secret):
return client_secret_regex.match(client_secret) is not None
| 1 | 1 | -1 | https://github.com/matrix-org/sydent.git/commit/3175fd358ebc2c310eab7a3dbf296ce2bd54c1da | 4Python |
void ModuleSQL::init()
{
Dispatcher = new DispatcherThread(this);
ServerInstance->Threads.Start(Dispatcher);
} | 1 | null | -1 | https://github.com/inspircd/inspircd/commit/8745660fcdac7c1b80c94cfc0ff60928cd4dd4b7 | 0CCPP |
void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, unsigned int vector)
{
struct kvm_segment cs;
kvm_get_segment(vcpu, &cs, VCPU_SREG_CS);
cs.selector = vector << 8;
cs.base = vector << 12;
kvm_set_segment(vcpu, &cs, VCPU_SREG_CS);
kvm_rip_write(vcpu, 0);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/fda4e2e85589191b123d31cdc21fd33ee70f50fd | 0CCPP |
arith_shift_left (int32_t x, int shift)
{ return (int32_t) (((uint32_t) x) << shift) ;
} | 0 | null | -1 | https://github.com/libsndfile/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074 | 0CCPP |
private void ChangeScreenResolution()
{
var width = int.Parse(_packet.Args[0].ToString());
var height = int.Parse(_packet.Args[1].ToString());
var bbp = int.Parse(_packet.Args[2].ToString());
var freq = int.Parse(_packet.Args[3].ToString());
var device = _packet.Args[4].ToString();
var message = Display.ChangeResolution(device, width, height, bbp, freq);
var formThread = new
{
message
};
_builder.WriteMessage(formThread);
} | 1 | 2,12 | -1 | https://github.com/Ulterius/server/commit/770d1821de43cf1d0a93c79025995bdd812a76ee | 1CS |
out : function(e, ui) {
var helper = ui.helper;
e.stopPropagation();
helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus').data('dropover', Math.max(helper.data('dropover') - 1, 0));
$(this).removeData('dropover')
.removeClass(dropover);
fm.trigger('unlockfiles', {files : helper.data('files'), helper: helper});
},
drop : function(e, ui) {
var helper = ui.helper,
resolve = true;
$.each(helper.data('files'), function(i, hash) {
var dir = fm.file(hash);
if (dir && dir.mime == 'directory' && !dirs[dir.hash]) {
add(dir);
} else {
resolve = false;
}
})
save();
resolve && helper.hide();
}
})
.on('touchstart', '.'+navdir+':not(.'+clroot+')', function(e) {
var hash = $(this).attr('id').substr(6),
p = $(this)
.addClass(hover)
.data('longtap', null)
.data('tmlongtap', setTimeout(function(){
p.data('longtap', true);
fm.trigger('contextmenu', {
raw : [{
label : fm.i18n('rmFromPlaces'),
icon : 'rm',
callback : function() { remove(hash); save(); }
}],
'x' : e.originalEvent.touches[0].pageX,
'y' : e.originalEvent.touches[0].pageY
});
}, 500));
})
.on('touchmove touchend', '.'+navdir+':not(.'+clroot+')', function(e) {
clearTimeout($(this).data('tmlongtap'));
if (e.type == 'touchmove') {
$(this).removeClass(hover);
}
});
$(this).on('regist', function(e, files){
var added = false;
$.each(files, function(i, dir) {
if (dir && dir.mime == 'directory' && !dirs[dir.hash]) {
if (add(dir)) {
added = true;
}
}
});
added && save();
});
fm.one('load', function() {
var dat, hashes;
if (fm.oldAPI) {
return;
}
places.show().parent().show();
dirs = {};
dat = $.map((fm.storage(key) || '').split(','), function(hash) { return hash || null;});
$.each(dat, function(i, d) {
var dir = d.split('#')
dirs[dir[0]] = dir[1]? dir[1] : dir[0];
});
fm.trigger('placesload', {dirs: dirs, storageKey: key}, true);
hashes = Object.keys(dirs);
if (hashes.length) {
root.prepend(spinner);
fm.request({
data : {cmd : 'info', targets : hashes},
preventDefault : true
})
.done(function(data) {
var exists = {};
$.each(data.files, function(i, f) {
var hash = f.hash;
exists[hash] = f;
});
$.each(dirs, function(h, f) {
add(exists[h] || { hash: h, name: f, mime: 'directory', notfound: true });
});
if (fm.storage('placesState') > 0) {
root.click();
}
})
.always(function() {
spinner.remove();
})
}
fm.change(function(e) {
var changed = false;
$.each(e.data.changed, function(i, file) {
if (dirs[file.hash]) {
if (file.mime !== 'directory') {
if (remove(file.hash)) {
changed = true;
}
} else {
if (update(file)) {
changed = true;
}
}
}
});
changed && save();
})
.bind('rename', function(e) {
var changed = false;
if (e.data.removed) {
$.each(e.data.removed, function(i, hash) {
if (e.data.added[i]) {
if (update(e.data.added[i], hash)) {
changed = true;
}
}
});
}
changed && save();
})
.bind('rm paste', function(e) {
var names = [],
changed = false;
if (e.data.removed) {
$.each(e.data.removed, function(i, hash) {
var name = remove(hash);
name && names.push(name);
});
}
if (names.length) {
changed = true;
}
if (e.data.added && names.length) {
$.each(e.data.added, function(i, file) {
if ($.inArray(file.name, names) !== 1) {
file.mime == 'directory' && add(file);
}
});
}
changed && save();
})
.bind('sync', function() {
var hashes = Object.keys(dirs);
if (hashes.length) {
root.prepend(spinner);
fm.request({
data : {cmd : 'info', targets : hashes},
preventDefault : true
})
.done(function(data) {
var exists = {},
updated = false,
cwd = fm.cwd().hash;
$.each(data.files || [], function(i, file) {
var hash = file.hash;
exists[hash] = file;
if (!fm.files().hasOwnProperty(file.hash)) {
fm.trigger('tree', {tree: [file]});
}
});
$.each(dirs, function(h, f) {
if (!f.notfound != !!exists[h]) {
if (f.phash === cwd || (exists[h] && exists[h].mime !== 'directory')) {
if (remove(h)) {
updated = true;
}
} else {
if (update(exists[h] || { hash: h, name: f.name, mime: 'directory', notfound: true })) {
updated = true;
}
}
} else if (exists[h] && exists[h].phash != cwd) {
update(exists[h]);
}
});
updated && save();
})
.always(function() {
spinner.remove();
});
}
})
})
});
} | 1 | 1,3,6,28,47,65,66,67,68,69,85,146,167,172,189 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
'z-index' : 100 + fm.getUI('workzone').zIndex()
};
menu.css(css)
.show();
css = {'z-index' : css['z-index']+10};
css[subpos] = parseInt(menu.width());
menu.find('.elfinder-contextmenu-sub').css(css);
}, | 1 | 0,1,2,3,4,5,6,7 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
dtls1_process_record(SSL *s)
{
int i,al;
int enc_err;
SSL_SESSION *sess;
SSL3_RECORD *rr;
unsigned int mac_size;
unsigned char md[EVP_MAX_MD_SIZE];
rr= &(s->s3->rrec);
sess = s->session;
rr->input= &(s->packet[DTLS1_RT_HEADER_LENGTH]);
if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH)
{
al=SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG);
goto f_err;
}
rr->data=rr->input;
rr->orig_len=rr->length;
enc_err = s->method->ssl3_enc->enc(s,0);
if (enc_err == 0)
{
rr->length = 0;
s->packet_length = 0;
goto err;
}
#ifdef TLS_DEBUG
printf("dec %d\n",rr->length);
{ unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); }
printf("\n");
#endif
if ((sess != NULL) &&
(s->enc_read_ctx != NULL) &&
(EVP_MD_CTX_md(s->read_hash) != NULL))
{
unsigned char *mac = NULL;
unsigned char mac_tmp[EVP_MAX_MD_SIZE];
mac_size=EVP_MD_CTX_size(s->read_hash);
OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);
if (rr->orig_len < mac_size ||
(EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
rr->orig_len < mac_size+1))
{
al=SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_LENGTH_TOO_SHORT);
goto f_err;
}
if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE)
{
mac = mac_tmp;
ssl3_cbc_copy_mac(mac_tmp, rr, mac_size);
rr->length -= mac_size;
}
else
{
rr->length -= mac_size;
mac = &rr->data[rr->length];
}
i=s->method->ssl3_enc->mac(s,md,0 );
if (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)
enc_err = -1;
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+mac_size)
enc_err = -1;
}
if (enc_err < 0)
{
rr->length = 0;
s->packet_length = 0;
goto err;
}
if (s->expand != NULL)
{
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH)
{
al=SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG);
goto f_err;
}
if (!ssl3_do_uncompress(s))
{
al=SSL_AD_DECOMPRESSION_FAILURE;
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_BAD_DECOMPRESSION);
goto f_err;
}
}
if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH)
{
al=SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_DATA_LENGTH_TOO_LONG);
goto f_err;
}
rr->off=0;
s->packet_length=0;
dtls1_record_bitmap_update(s, &(s->d1->bitmap));/*
return(1);
f_err:
ssl3_send_alert(s,SSL3_AL_FATAL,al);
err:
return(0);
} | 1 | 93 | -1 | https://github.com/openssl/openssl/commit/103b171d8fc282ef435f8de9afbf7782e312961f | 0CCPP |
_archive_write_data(struct archive *_a, const void *buff, size_t s)
{
struct archive_write *a = (struct archive_write *)_a;
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_DATA, "archive_write_data");
archive_clear_error(&a->archive);
return ((a->format_write_data)(a, buff, s));
} | 1 | null | -1 | https://github.com/libarchive/libarchive/commit/22531545514043e04633e1c015c7540b9de9dbe4 | 0CCPP |
static inline void prepare_urlencoded(zval *zv TSRMLS_DC)
{
int len;
char *str = php_raw_url_encode(Z_STRVAL_P(zv), Z_STRLEN_P(zv), &len);
zval_dtor(zv);
ZVAL_STRINGL(zv, str, len, 0);
} | 0 | null | -1 | https://github.com/m6w6/ext-http/commit/17137d4ab1ce81a2cee0fae842340a344ef3da83 | 0CCPP |
int Com_RealTime( qtime_t *qtime ) {
time_t t;
struct tm *tms;
t = time( NULL );
if ( !qtime ) {
return t;
}
tms = localtime( &t );
if ( tms ) {
qtime->tm_sec = tms->tm_sec;
qtime->tm_min = tms->tm_min;
qtime->tm_hour = tms->tm_hour;
qtime->tm_mday = tms->tm_mday;
qtime->tm_mon = tms->tm_mon;
qtime->tm_year = tms->tm_year;
qtime->tm_wday = tms->tm_wday;
qtime->tm_yday = tms->tm_yday;
qtime->tm_isdst = tms->tm_isdst;
}
return t;
} | 0 | null | -1 | https://github.com/iortcw/iortcw/commit/11a83410153756ae350a82ed41b08d128ff7f998 | 0CCPP |
RCoreSymCacheElement *r_coresym_cache_element_new(RBinFile *bf, RBuffer *buf, ut64 off, int bits, char * file_name) {
RCoreSymCacheElement *result = NULL;
ut8 *b = NULL;
RCoreSymCacheElementHdr *hdr = r_coresym_cache_element_header_new (buf, off, bits);
if (!hdr) {
return NULL;
}
if (hdr->version != 1) {
eprintf ("Unsupported CoreSymbolication cache version (%d)\n", hdr->version);
goto beach;
}
if (hdr->size == 0 || hdr->size > r_buf_size (buf) - off) {
eprintf ("Corrupted CoreSymbolication header: size out of bounds (0x%x)\n", hdr->size);
goto beach;
}
result = R_NEW0 (RCoreSymCacheElement);
if (!result) {
goto beach;
}
result->hdr = hdr;
b = malloc (hdr->size);
if (!b) {
goto beach;
}
if (r_buf_read_at (buf, off, b, hdr->size) != hdr->size) {
goto beach;
}
ut8 *end = b + hdr->size;
if (file_name) {
result->file_name = file_name;
} else if (hdr->file_name_off) {
result->file_name = str_dup_safe (b, b + (size_t)hdr->file_name_off, end);
}
if (hdr->version_off) {
result->binary_version = str_dup_safe (b, b + (size_t)hdr->version_off, end);
}
const size_t word_size = bits / 8;
const ut64 start_of_sections = (ut64)hdr->n_segments * R_CS_EL_SIZE_SEG + R_CS_EL_OFF_SEGS;
const ut64 sect_size = (bits == 32) ? R_CS_EL_SIZE_SECT_32 : R_CS_EL_SIZE_SECT_64;
const ut64 start_of_symbols = start_of_sections + (ut64)hdr->n_sections * sect_size;
const ut64 start_of_lined_symbols = start_of_symbols + (ut64)hdr->n_symbols * R_CS_EL_SIZE_SYM;
const ut64 start_of_line_info = start_of_lined_symbols + (ut64)hdr->n_lined_symbols * R_CS_EL_SIZE_LSYM;
const ut64 start_of_unknown_pairs = start_of_line_info + (ut64)hdr->n_line_info * R_CS_EL_SIZE_LINFO;
const ut64 start_of_strings = start_of_unknown_pairs + (ut64)hdr->n_symbols * 8;
ut64 page_zero_size = 0;
size_t page_zero_idx = 0;
if (UT32_MUL_OVFCHK (hdr->n_segments, sizeof (RCoreSymCacheElementSegment))) {
goto beach;
} else if (UT32_MUL_OVFCHK (hdr->n_sections, sizeof (RCoreSymCacheElementSection))) {
goto beach;
} else if (UT32_MUL_OVFCHK (hdr->n_symbols, sizeof (RCoreSymCacheElementSymbol))) {
goto beach;
} else if (UT32_MUL_OVFCHK (hdr->n_lined_symbols, sizeof (RCoreSymCacheElementLinedSymbol))) {
goto beach;
} else if (UT32_MUL_OVFCHK (hdr->n_line_info, sizeof (RCoreSymCacheElementLineInfo))) {
goto beach;
}
if (hdr->n_segments > 0) {
result->segments = R_NEWS0 (RCoreSymCacheElementSegment, hdr->n_segments);
if (!result->segments) {
goto beach;
}
size_t i;
ut8 *cursor = b + R_CS_EL_OFF_SEGS;
for (i = 0; i < hdr->n_segments && cursor + sizeof (RCoreSymCacheElementSegment) < end; i++) {
RCoreSymCacheElementSegment *seg = &result->segments[i];
seg->paddr = seg->vaddr = r_read_le64 (cursor);
cursor += 8;
if (cursor >= end) {
break;
}
seg->size = seg->vsize = r_read_le64 (cursor);
cursor += 8;
if (cursor >= end) {
break;
}
seg->name = str_dup_safe_fixed (b, cursor, 16, end);
cursor += 16;
if (!seg->name) {
continue;
}
if (!strcmp (seg->name, "__PAGEZERO")) {
page_zero_size = seg->size;
page_zero_idx = i;
seg->paddr = seg->vaddr = 0;
seg->size = 0;
}
}
for (i = 0; i < hdr->n_segments && page_zero_size > 0; i++) {
if (i == page_zero_idx) {
continue;
}
RCoreSymCacheElementSegment *seg = &result->segments[i];
if (seg->vaddr < page_zero_size) {
seg->vaddr += page_zero_size;
}
}
}
bool relative_to_strings = false;
ut8* string_origin;
if (hdr->n_sections > 0) {
result->sections = R_NEWS0 (RCoreSymCacheElementSection, hdr->n_sections);
if (!result->sections) {
goto beach;
}
size_t i;
ut8 *cursor = b + start_of_sections;
for (i = 0; i < hdr->n_sections && cursor < end; i++) {
ut8 *sect_start = cursor;
RCoreSymCacheElementSection *sect = &result->sections[i];
sect->vaddr = sect->paddr = r_read_ble (cursor, false, bits);
if (sect->vaddr < page_zero_size) {
sect->vaddr += page_zero_size;
}
cursor += word_size;
if (cursor + word_size >= end) {
break;
}
sect->size = r_read_ble (cursor, false, bits);
cursor += word_size;
if (cursor + word_size >= end) {
break;
}
ut64 sect_name_off = r_read_ble (cursor, false, bits);
if (!i && !sect_name_off) {
relative_to_strings = true;
}
cursor += word_size;
if (bits == 32) {
cursor += word_size;
}
string_origin = relative_to_strings? b + start_of_strings : sect_start;
if (sect_name_off < (ut64)(size_t)(end - string_origin)) {
sect->name = str_dup_safe (b, string_origin + sect_name_off, end);
} else {
sect->name = strdup ("");
}
}
}
if (hdr->n_symbols) {
result->symbols = R_NEWS0 (RCoreSymCacheElementSymbol, hdr->n_symbols);
if (!result->symbols) {
goto beach;
}
size_t i;
ut8 *cursor = b + start_of_symbols;
for (i = 0; i < hdr->n_symbols && cursor + R_CS_EL_SIZE_SYM <= end; i++) {
RCoreSymCacheElementSymbol *sym = &result->symbols[i];
sym->paddr = r_read_le32 (cursor);
sym->size = r_read_le32 (cursor + 0x4);
sym->unk1 = r_read_le32 (cursor + 0x8);
size_t name_off = r_read_le32 (cursor + 0xc);
size_t mangled_name_off = r_read_le32 (cursor + 0x10);
sym->unk2 = (st32)r_read_le32 (cursor + 0x14);
string_origin = relative_to_strings? b + start_of_strings : cursor;
sym->name = str_dup_safe (b, string_origin + name_off, end);
if (!sym->name) {
cursor += R_CS_EL_SIZE_SYM;
continue;
}
string_origin = relative_to_strings? b + start_of_strings : cursor;
sym->mangled_name = str_dup_safe (b, string_origin + mangled_name_off, end);
if (!sym->mangled_name) {
cursor += R_CS_EL_SIZE_SYM;
continue;
}
cursor += R_CS_EL_SIZE_SYM;
}
}
if (hdr->n_lined_symbols) {
result->lined_symbols = R_NEWS0 (RCoreSymCacheElementLinedSymbol, hdr->n_lined_symbols);
if (!result->lined_symbols) {
goto beach;
}
size_t i;
ut8 *cursor = b + start_of_lined_symbols;
for (i = 0; i < hdr->n_lined_symbols && cursor + R_CS_EL_SIZE_LSYM <= end; i++) {
RCoreSymCacheElementLinedSymbol *lsym = &result->lined_symbols[i];
lsym->sym.paddr = r_read_le32 (cursor);
lsym->sym.size = r_read_le32 (cursor + 0x4);
lsym->sym.unk1 = r_read_le32 (cursor + 0x8);
size_t name_off = r_read_le32 (cursor + 0xc);
size_t mangled_name_off = r_read_le32 (cursor + 0x10);
lsym->sym.unk2 = (st32)r_read_le32 (cursor + 0x14);
size_t file_name_off = r_read_le32 (cursor + 0x18);
lsym->flc.line = r_read_le32 (cursor + 0x1c);
lsym->flc.col = r_read_le32 (cursor + 0x20);
string_origin = relative_to_strings? b + start_of_strings : cursor;
lsym->sym.name = str_dup_safe (b, string_origin + name_off, end);
if (!lsym->sym.name) {
cursor += R_CS_EL_SIZE_LSYM;
continue;
}
string_origin = relative_to_strings? b + start_of_strings : cursor;
lsym->sym.mangled_name = str_dup_safe (b, string_origin + mangled_name_off, end);
if (!lsym->sym.mangled_name) {
cursor += R_CS_EL_SIZE_LSYM;
continue;
}
string_origin = relative_to_strings? b + start_of_strings : cursor;
lsym->flc.file = str_dup_safe (b, string_origin + file_name_off, end);
if (!lsym->flc.file) {
cursor += R_CS_EL_SIZE_LSYM;
continue;
}
cursor += R_CS_EL_SIZE_LSYM;
meta_add_fileline (bf, r_coresym_cache_element_pa2va (result, lsym->sym.paddr), lsym->sym.size, &lsym->flc);
}
}
if (hdr->n_line_info) {
result->line_info = R_NEWS0 (RCoreSymCacheElementLineInfo, hdr->n_line_info);
if (!result->line_info) {
goto beach;
}
size_t i;
ut8 *cursor = b + start_of_line_info;
for (i = 0; i < hdr->n_line_info && cursor + R_CS_EL_SIZE_LINFO <= end; i++) {
RCoreSymCacheElementLineInfo *info = &result->line_info[i];
info->paddr = r_read_le32 (cursor);
info->size = r_read_le32 (cursor + 4);
size_t file_name_off = r_read_le32 (cursor + 8);
info->flc.line = r_read_le32 (cursor + 0xc);
info->flc.col = r_read_le32 (cursor + 0x10);
string_origin = relative_to_strings? b + start_of_strings : cursor;
info->flc.file = str_dup_safe (b, string_origin + file_name_off, end);
if (!info->flc.file) {
break;
}
cursor += R_CS_EL_SIZE_LINFO;
meta_add_fileline (bf, r_coresym_cache_element_pa2va (result, info->paddr), info->size, &info->flc);
}
}
beach:
free (b);
return result;
} | 1 | null | -1 | https://github.com/radareorg/radare2/commit/669a404b6d98d5db409a5ebadae4e94b34ef5136 | 0CCPP |
fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset)
{
char * fru_area;
uint8_t * fru_data;
uint32_t fru_len, i;
uint8_t tmp[2];
fru_len = 0;
if (read_fru_area(intf, fru, id, offset, 2, tmp) == 0) {
fru_len = 8 * tmp[1];
}
if (fru_len == 0) {
return;
}
fru_data = malloc(fru_len);
if (!fru_data) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return;
}
memset(fru_data, 0, fru_len);
if (read_fru_area(intf, fru, id, offset, fru_len, fru_data) < 0) {
free_n(&fru_data);
return;
}
i = 3;
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
if (strlen(fru_area) > 0) {
printf(" Product Manufacturer : %s\n", fru_area);
}
free_n(&fru_area);
}
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
if (strlen(fru_area) > 0) {
printf(" Product Name : %s\n", fru_area);
}
free_n(&fru_area);
}
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
if (strlen(fru_area) > 0) {
printf(" Product Part Number : %s\n", fru_area);
}
free_n(&fru_area);
}
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
if (strlen(fru_area) > 0) {
printf(" Product Version : %s\n", fru_area);
}
free_n(&fru_area);
}
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
if (strlen(fru_area) > 0) {
printf(" Product Serial : %s\n", fru_area);
}
free_n(&fru_area);
}
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
if (strlen(fru_area) > 0) {
printf(" Product Asset Tag : %s\n", fru_area);
}
free_n(&fru_area);
}
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
if (strlen(fru_area) > 0 && verbose > 0) {
printf(" Product FRU ID : %s\n", fru_area);
}
free_n(&fru_area);
}
while ((i < fru_len) && (fru_data[i] != FRU_END_OF_FIELDS)) {
int j = i;
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
if (strlen(fru_area) > 0) {
printf(" Product Extra : %s\n", fru_area);
}
free_n(&fru_area);
}
if (i == j)
break;
}
free_n(&fru_data);
} | 0 | null | -1 | https://github.com/ipmitool/ipmitool/commit/e824c23316ae50beb7f7488f2055ac65e8b341f2 | 0CCPP |
SQLRETURN SQLSetDescFieldW( SQLHDESC descriptor_handle,
SQLSMALLINT rec_number,
SQLSMALLINT field_identifier,
SQLPOINTER value,
SQLINTEGER buffer_length )
{
DMHDESC descriptor = (DMHDESC) descriptor_handle;
SQLRETURN ret;
SQLCHAR s1[ 100 + LOG_MESSAGE_LEN ];
int isStrField = 0;
if ( !__validate_desc( descriptor ))
{
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
"Error: SQL_INVALID_HANDLE" );
#ifdef WITH_HANDLE_REDIRECT
{
DMHDESC parent_desc;
parent_desc = find_parent_handle( descriptor, SQL_HANDLE_DESC );
if ( parent_desc ) {
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
"Info: found parent handle" );
if ( CHECK_SQLSETDESCFIELDW( parent_desc -> connection ))
{
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
"Info: calling redirected driver function" );
return SQLSETDESCFIELDW( parent_desc -> connection,
descriptor,
rec_number,
field_identifier,
value,
buffer_length );
}
}
}
#endif
return SQL_INVALID_HANDLE;
}
function_entry( descriptor );
if ( log_info.log_flag )
{
sprintf( descriptor -> msg, "\n\t\tEntry:\
\n\t\t\tDescriptor = %p\
\n\t\t\tRec Number = %d\
\n\t\t\tField Ident = %s\
\n\t\t\tValue = %p\
\n\t\t\tBuffer Length = %d",
descriptor,
rec_number,
__desc_attr_as_string( s1, field_identifier ),
value,
(int)buffer_length );
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
descriptor -> msg );
}
thread_protect( SQL_HANDLE_DESC, descriptor );
if ( descriptor -> connection -> state < STATE_C4 )
{
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
"Error: HY010" );
__post_internal_error( &descriptor -> error,
ERROR_HY010, NULL,
descriptor -> connection -> environment -> requested_version );
return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
}
if( __check_stmt_from_desc( descriptor, STATE_S8 ) ||
__check_stmt_from_desc( descriptor, STATE_S9 ) ||
__check_stmt_from_desc( descriptor, STATE_S10 ) ||
__check_stmt_from_desc( descriptor, STATE_S11 ) ||
__check_stmt_from_desc( descriptor, STATE_S12 ) ||
__check_stmt_from_desc( descriptor, STATE_S13 ) ||
__check_stmt_from_desc( descriptor, STATE_S14 ) ||
__check_stmt_from_desc( descriptor, STATE_S15 )) {
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
"Error: HY010" );
__post_internal_error( &descriptor -> error,
ERROR_HY010, NULL,
descriptor -> connection -> environment -> requested_version );
return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
}
if ( rec_number < 0 )
{
__post_internal_error( &descriptor -> error,
ERROR_07009, NULL,
descriptor -> connection -> environment -> requested_version );
return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
}
switch ( field_identifier )
{
case SQL_DESC_ALLOC_TYPE:
case SQL_DESC_ARRAY_SIZE:
case SQL_DESC_ARRAY_STATUS_PTR:
case SQL_DESC_BIND_OFFSET_PTR:
case SQL_DESC_BIND_TYPE:
case SQL_DESC_COUNT:
case SQL_DESC_ROWS_PROCESSED_PTR:
case SQL_DESC_AUTO_UNIQUE_VALUE:
case SQL_DESC_CASE_SENSITIVE:
case SQL_DESC_CONCISE_TYPE:
case SQL_DESC_DATA_PTR:
case SQL_DESC_DATETIME_INTERVAL_CODE:
case SQL_DESC_DATETIME_INTERVAL_PRECISION:
case SQL_DESC_DISPLAY_SIZE:
case SQL_DESC_FIXED_PREC_SCALE:
case SQL_DESC_INDICATOR_PTR:
case SQL_DESC_LENGTH:
case SQL_DESC_NULLABLE:
case SQL_DESC_NUM_PREC_RADIX:
case SQL_DESC_OCTET_LENGTH:
case SQL_DESC_OCTET_LENGTH_PTR:
case SQL_DESC_PARAMETER_TYPE:
case SQL_DESC_PRECISION:
case SQL_DESC_ROWVER:
case SQL_DESC_SCALE:
case SQL_DESC_SEARCHABLE:
case SQL_DESC_TYPE:
case SQL_DESC_UNNAMED:
case SQL_DESC_UNSIGNED:
case SQL_DESC_UPDATABLE:
isStrField = 0;
break;
case SQL_DESC_BASE_COLUMN_NAME:
case SQL_DESC_BASE_TABLE_NAME:
case SQL_DESC_CATALOG_NAME:
case SQL_DESC_LABEL:
case SQL_DESC_LITERAL_PREFIX:
case SQL_DESC_LITERAL_SUFFIX:
case SQL_DESC_LOCAL_TYPE_NAME:
case SQL_DESC_NAME:
case SQL_DESC_SCHEMA_NAME:
case SQL_DESC_TABLE_NAME:
case SQL_DESC_TYPE_NAME:
isStrField = 1;
break;
default:
isStrField = buffer_length != SQL_IS_POINTER && buffer_length != SQL_IS_INTEGER
&& buffer_length != SQL_IS_UINTEGER && buffer_length != SQL_IS_SMALLINT &&
buffer_length != SQL_IS_USMALLINT;
}
if ( isStrField && buffer_length < 0 && buffer_length != SQL_NTS)
{
__post_internal_error( &descriptor -> error,
ERROR_HY090, NULL,
descriptor -> connection -> environment -> requested_version );
return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
}
if ( field_identifier == SQL_DESC_COUNT && (SQLINTEGER)value < 0 )
{
__post_internal_error( &descriptor -> error,
ERROR_07009, NULL,
descriptor -> connection -> environment -> requested_version );
return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
}
if ( field_identifier == SQL_DESC_PARAMETER_TYPE && value != SQL_PARAM_INPUT
&& value != SQL_PARAM_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT &&
value != SQL_PARAM_INPUT_OUTPUT_STREAM && value != SQL_PARAM_OUTPUT_STREAM )
{
__post_internal_error( &descriptor -> error,
ERROR_HY105, NULL,
descriptor -> connection -> environment -> requested_version );
return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
}
if ( descriptor -> connection -> unicode_driver ||
CHECK_SQLSETDESCFIELDW( descriptor -> connection ))
{
if ( !CHECK_SQLSETDESCFIELDW( descriptor -> connection ))
{
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
"Error: IM001" );
__post_internal_error( &descriptor -> error,
ERROR_IM001, NULL,
descriptor -> connection -> environment -> requested_version );
return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
}
ret = SQLSETDESCFIELDW( descriptor -> connection,
descriptor -> driver_desc,
rec_number,
field_identifier,
value,
buffer_length );
if ( log_info.log_flag )
{
sprintf( descriptor -> msg,
"\n\t\tExit:[%s]",
__get_return_status( ret, s1 ));
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
descriptor -> msg );
}
}
else
{
SQLCHAR *ascii_str = NULL;
if ( !CHECK_SQLSETDESCFIELD( descriptor -> connection ))
{
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
"Error: IM001" );
__post_internal_error( &descriptor -> error,
ERROR_IM001, NULL,
descriptor -> connection -> environment -> requested_version );
return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
}
switch ( field_identifier )
{
case SQL_DESC_NAME:
ascii_str = (SQLCHAR*) unicode_to_ansi_alloc( value, buffer_length, descriptor -> connection, NULL );
value = ascii_str;
buffer_length = strlen((char*) ascii_str );
break;
default:
break;
}
ret = SQLSETDESCFIELD( descriptor -> connection,
descriptor -> driver_desc,
rec_number,
field_identifier,
value,
buffer_length );
if ( log_info.log_flag )
{
sprintf( descriptor -> msg,
"\n\t\tExit:[%s]",
__get_return_status( ret, s1 ));
dm_log_write( __FILE__,
__LINE__,
LOG_INFO,
LOG_INFO,
descriptor -> msg );
}
if ( ascii_str )
{
free( ascii_str );
}
}
return function_return( SQL_HANDLE_DESC, descriptor, ret );
} | 1 | 163,170,171,172 | -1 | https://github.com/lurcher/unixODBC/commit/45ef78e037f578b15fc58938a3a3251655e71d6f | 0CCPP |
public AuthorizationCodeRequestUrl newAuthorizationUrl() {
return new AuthorizationCodeRequestUrl(authorizationServerEncodedUrl, clientId).setScopes(
scopes);
} | 1 | 1,2 | -1 | https://github.com/googleapis/google-oauth-java-client/commit/13433cd7dd06267fc261f0b1d4764f8e3432c824 | 2Java |
--S){this.spinner.stop();if(null!=x)x(U);else{var p=[];J.getModel().beginUpdate();try{for(V=0;V<U.length;V++){var C=U[V]();null!=C&&(p=p.concat(C))}}finally{J.getModel().endUpdate()}}q(p)}}),W=0;W<H;W++)mxUtils.bind(this,function(V){var X=c[V];if(null!=X){var p=new FileReader;p.onload=mxUtils.bind(this,function(C){if(null==v||v(X))if("image/"==X.type.substring(0,6))if("image/svg"==X.type.substring(0,9)){var I=Graph.clipSvgDataUri(C.target.result),T=I.indexOf(",");T=decodeURIComponent(escape(atob(I.substring(T+ | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.