idx
int64 | func
string | target
int64 |
|---|---|---|
261,928
|
njs_string_prototype_iterator_obj(njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t kind)
{
njs_int_t ret;
njs_value_t *this;
this = njs_argument(args, 0);
ret = njs_string_object_validate(vm, this);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
return njs_array_iterator_create(vm, this, &vm->retval, kind);
}
| 0
|
488,344
|
void print_vma_addr(char *prefix, unsigned long ip)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
/*
* Do not print if we are in atomic
* contexts (in exception stacks, etc.):
*/
if (preempt_count())
return;
down_read(&mm->mmap_sem);
vma = find_vma(mm, ip);
if (vma && vma->vm_file) {
struct file *f = vma->vm_file;
char *buf = (char *)__get_free_page(GFP_KERNEL);
if (buf) {
char *p, *s;
p = d_path(&f->f_path, buf, PAGE_SIZE);
if (IS_ERR(p))
p = "?";
s = strrchr(p, '/');
if (s)
p = s+1;
printk("%s%s[%lx+%lx]", prefix, p,
vma->vm_start,
vma->vm_end - vma->vm_start);
free_page((unsigned long)buf);
}
}
up_read(¤t->mm->mmap_sem);
}
| 0
|
293,493
|
gif_result gif_initialise(gif_animation *gif, size_t size, unsigned char *data)
{
const unsigned char *gif_data;
unsigned int index;
gif_result return_value;
/* Initialize values */
gif->buffer_size = size;
gif->gif_data = data;
if (gif->lzw_ctx == NULL) {
lzw_result res = lzw_context_create(
(struct lzw_ctx **)&gif->lzw_ctx);
if (res != LZW_OK) {
return gif_error_from_lzw(res);
}
}
/* Check for sufficient data to be a GIF (6-byte header + 7-byte
* logical screen descriptor)
*/
if (gif->buffer_size < GIF_STANDARD_HEADER_SIZE) {
return GIF_INSUFFICIENT_DATA;
}
/* Get our current processing position */
gif_data = gif->gif_data + gif->buffer_position;
/* See if we should initialise the GIF */
if (gif->buffer_position == 0) {
/* We want everything to be NULL before we start so we've no
* chance of freeing bad pointers (paranoia)
*/
gif->frame_image = NULL;
gif->frames = NULL;
gif->local_colour_table = NULL;
gif->global_colour_table = NULL;
/* The caller may have been lazy and not reset any values */
gif->frame_count = 0;
gif->frame_count_partial = 0;
gif->decoded_frame = GIF_INVALID_FRAME;
/* 6-byte GIF file header is:
*
* +0 3CHARS Signature ('GIF')
* +3 3CHARS Version ('87a' or '89a')
*/
if (strncmp((const char *) gif_data, "GIF", 3) != 0) {
return GIF_DATA_ERROR;
}
gif_data += 3;
/* Ensure GIF reports version 87a or 89a */
/*
if ((strncmp(gif_data, "87a", 3) != 0) &&
(strncmp(gif_data, "89a", 3) != 0))
LOG(("Unknown GIF format - proceeding anyway"));
*/
gif_data += 3;
/* 7-byte Logical Screen Descriptor is:
*
* +0 SHORT Logical Screen Width
* +2 SHORT Logical Screen Height
* +4 CHAR __Packed Fields__
* 1BIT Global Colour Table Flag
* 3BITS Colour Resolution
* 1BIT Sort Flag
* 3BITS Size of Global Colour Table
* +5 CHAR Background Colour Index
* +6 CHAR Pixel Aspect Ratio
*/
gif->width = gif_data[0] | (gif_data[1] << 8);
gif->height = gif_data[2] | (gif_data[3] << 8);
gif->global_colours = (gif_data[4] & GIF_COLOUR_TABLE_MASK);
gif->colour_table_size = (2 << (gif_data[4] & GIF_COLOUR_TABLE_SIZE_MASK));
gif->background_index = gif_data[5];
gif->aspect_ratio = gif_data[6];
gif->loop_count = 1;
gif_data += 7;
/* Some broken GIFs report the size as the screen size they
* were created in. As such, we detect for the common cases and
* set the sizes as 0 if they are found which results in the
* GIF being the maximum size of the frames.
*/
if (((gif->width == 640) && (gif->height == 480)) ||
((gif->width == 640) && (gif->height == 512)) ||
((gif->width == 800) && (gif->height == 600)) ||
((gif->width == 1024) && (gif->height == 768)) ||
((gif->width == 1280) && (gif->height == 1024)) ||
((gif->width == 1600) && (gif->height == 1200)) ||
((gif->width == 0) || (gif->height == 0)) ||
((gif->width > 2048) || (gif->height > 2048))) {
gif->width = 1;
gif->height = 1;
}
/* Allocate some data irrespective of whether we've got any
* colour tables. We always get the maximum size in case a GIF
* is lying to us. It's far better to give the wrong colours
* than to trample over some memory somewhere.
*/
gif->global_colour_table = calloc(GIF_MAX_COLOURS, sizeof(unsigned int));
gif->local_colour_table = calloc(GIF_MAX_COLOURS, sizeof(unsigned int));
if ((gif->global_colour_table == NULL) ||
(gif->local_colour_table == NULL)) {
gif_finalise(gif);
return GIF_INSUFFICIENT_MEMORY;
}
/* Set the first colour to a value that will never occur in
* reality so we know if we've processed it
*/
gif->global_colour_table[0] = GIF_PROCESS_COLOURS;
/* Check if the GIF has no frame data (13-byte header + 1-byte
* termination block) Although generally useless, the GIF
* specification does not expressly prohibit this
*/
if (gif->buffer_size == (GIF_STANDARD_HEADER_SIZE + 1)) {
if (gif_data[0] == GIF_TRAILER) {
return GIF_OK;
} else {
return GIF_INSUFFICIENT_DATA;
}
}
/* Initialise enough workspace for a frame */
if ((gif->frames = (gif_frame *)malloc(sizeof(gif_frame))) == NULL) {
gif_finalise(gif);
return GIF_INSUFFICIENT_MEMORY;
}
gif->frame_holders = 1;
/* Initialise the bitmap header */
assert(gif->bitmap_callbacks.bitmap_create);
gif->frame_image = gif->bitmap_callbacks.bitmap_create(gif->width, gif->height);
if (gif->frame_image == NULL) {
gif_finalise(gif);
return GIF_INSUFFICIENT_MEMORY;
}
/* Remember we've done this now */
gif->buffer_position = gif_data - gif->gif_data;
}
/* Do the colour map if we haven't already. As the top byte is always
* 0xff or 0x00 depending on the transparency we know if it's been
* filled in.
*/
if (gif->global_colour_table[0] == GIF_PROCESS_COLOURS) {
/* Check for a global colour map signified by bit 7 */
if (gif->global_colours) {
if (gif->buffer_size < (gif->colour_table_size * 3 + GIF_STANDARD_HEADER_SIZE)) {
return GIF_INSUFFICIENT_DATA;
}
for (index = 0; index < gif->colour_table_size; index++) {
/* Gif colour map contents are r,g,b.
*
* We want to pack them bytewise into the
* colour table, such that the red component
* is in byte 0 and the alpha component is in
* byte 3.
*/
unsigned char *entry = (unsigned char *) &gif->
global_colour_table[index];
entry[0] = gif_data[0]; /* r */
entry[1] = gif_data[1]; /* g */
entry[2] = gif_data[2]; /* b */
entry[3] = 0xff; /* a */
gif_data += 3;
}
gif->buffer_position = (gif_data - gif->gif_data);
} else {
/* Create a default colour table with the first two
* colours as black and white
*/
unsigned int *entry = gif->global_colour_table;
entry[0] = 0x00000000;
/* Force Alpha channel to opaque */
((unsigned char *) entry)[3] = 0xff;
entry[1] = 0xffffffff;
}
}
/* Repeatedly try to initialise frames */
while ((return_value = gif_initialise_frame(gif)) == GIF_WORKING);
/* If there was a memory error tell the caller */
if ((return_value == GIF_INSUFFICIENT_MEMORY) ||
(return_value == GIF_DATA_ERROR)) {
return return_value;
}
/* If we didn't have some frames then a GIF_INSUFFICIENT_DATA becomes a
* GIF_INSUFFICIENT_FRAME_DATA
*/
if ((return_value == GIF_INSUFFICIENT_DATA) &&
(gif->frame_count_partial > 0)) {
return GIF_INSUFFICIENT_FRAME_DATA;
}
/* Return how many we got */
return return_value;
}
| 0
|
328,906
|
R_API void r_bin_java_get_import_json_definitions(RBinJavaObj *bin, PJ *pj) {
r_return_if_fail (pj);
RList *the_list;
RListIter *iter = NULL;
char *new_str;
pj_ka (pj, "imports");
if (!bin || !(the_list = r_bin_java_get_lib_names (bin))) {
pj_end (pj);
return;
}
r_list_foreach (the_list, iter, new_str) {
char *tmp = new_str;
while (*tmp) {
if (*tmp == '/') {
*tmp = '.';
}
tmp++;
}
pj_s (pj, new_str);
}
r_list_free (the_list);
pj_end (pj);
return;
}
| 0
|
413,683
|
static void analPaths(RCoreAnalPaths *p, PJ *pj) {
RAnalBlock *cur = p->cur;
if (!cur) {
// eprintf ("eof\n");
return;
}
/* handle ^C */
if (r_cons_is_breaked ()) {
return;
}
dict_set (&p->visited, cur->addr, 1, NULL);
r_list_append (p->path, cur);
if (p->followDepth && --p->followDepth == 0) {
return;
}
if (p->toBB && cur->addr == p->toBB->addr) {
if (!printAnalPaths (p, pj)) {
return;
}
} else {
RAnalBlock *c = cur;
ut64 j = cur->jump;
ut64 f = cur->fail;
analPathFollow (p, j, pj);
cur = c;
analPathFollow (p, f, pj);
if (p->followCalls) {
int i;
for (i = 0; i < cur->op_pos_size; i++) {
ut64 addr = cur->addr + cur->op_pos[i];
RAnalOp *op = r_core_anal_op (p->core, addr, R_ANAL_OP_MASK_BASIC);
if (op && op->type == R_ANAL_OP_TYPE_CALL) {
analPathFollow (p, op->jump, pj);
}
cur = c;
r_anal_op_free (op);
}
}
}
p->cur = r_list_pop (p->path);
dict_del (&p->visited, cur->addr);
if (p->followDepth) {
p->followDepth++;
}
}
| 0
|
508,309
|
static bool setup_natural_join_row_types(THD *thd,
List<TABLE_LIST> *from_clause,
Name_resolution_context *context)
{
DBUG_ENTER("setup_natural_join_row_types");
thd->where= "from clause";
if (from_clause->elements == 0)
DBUG_RETURN(false); /* We come here in the case of UNIONs. */
/*
Do not redo work if already done:
1) for stored procedures,
2) for multitable update after lock failure and table reopening.
*/
if (!context->select_lex->first_natural_join_processing)
{
context->first_name_resolution_table= context->natural_join_first_table;
DBUG_PRINT("info", ("using cached setup_natural_join_row_types"));
DBUG_RETURN(false);
}
List_iterator_fast<TABLE_LIST> table_ref_it(*from_clause);
TABLE_LIST *table_ref; /* Current table reference. */
/* Table reference to the left of the current. */
TABLE_LIST *left_neighbor;
/* Table reference to the right of the current. */
TABLE_LIST *right_neighbor= NULL;
/* Note that tables in the list are in reversed order */
for (left_neighbor= table_ref_it++; left_neighbor ; )
{
table_ref= left_neighbor;
do
{
left_neighbor= table_ref_it++;
}
while (left_neighbor && left_neighbor->sj_subq_pred);
if (store_top_level_join_columns(thd, table_ref,
left_neighbor, right_neighbor))
DBUG_RETURN(true);
if (left_neighbor)
{
TABLE_LIST *first_leaf_on_the_right;
first_leaf_on_the_right= table_ref->first_leaf_for_name_resolution();
left_neighbor->next_name_resolution_table= first_leaf_on_the_right;
}
right_neighbor= table_ref;
}
/*
Store the top-most, left-most NATURAL/USING join, so that we start
the search from that one instead of context->table_list. At this point
right_neighbor points to the left-most top-level table reference in the
FROM clause.
*/
DBUG_ASSERT(right_neighbor);
context->first_name_resolution_table=
right_neighbor->first_leaf_for_name_resolution();
/*
This is only to ensure that first_name_resolution_table doesn't
change on re-execution
*/
context->natural_join_first_table= context->first_name_resolution_table;
context->select_lex->first_natural_join_processing= false;
DBUG_RETURN (false);
}
| 0
|
204,069
|
do_window(
int nchar,
long Prenum,
int xchar) // extra char from ":wincmd gx" or NUL
{
long Prenum1;
win_T *wp;
#if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID)
char_u *ptr;
linenr_T lnum = -1;
#endif
#ifdef FEAT_FIND_ID
int type = FIND_DEFINE;
int len;
#endif
char_u cbuf[40];
if (ERROR_IF_ANY_POPUP_WINDOW)
return;
#ifdef FEAT_CMDWIN
# define CHECK_CMDWIN \
do { \
if (cmdwin_type != 0) \
{ \
emsg(_(e_invalid_in_cmdline_window)); \
return; \
} \
} while (0)
#else
# define CHECK_CMDWIN do { /**/ } while (0)
#endif
Prenum1 = Prenum == 0 ? 1 : Prenum;
switch (nchar)
{
// split current window in two parts, horizontally
case 'S':
case Ctrl_S:
case 's':
CHECK_CMDWIN;
reset_VIsual_and_resel(); // stop Visual mode
#ifdef FEAT_QUICKFIX
// When splitting the quickfix window open a new buffer in it,
// don't replicate the quickfix buffer.
if (bt_quickfix(curbuf))
goto newwindow;
#endif
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
(void)win_split((int)Prenum, 0);
break;
// split current window in two parts, vertically
case Ctrl_V:
case 'v':
CHECK_CMDWIN;
reset_VIsual_and_resel(); // stop Visual mode
#ifdef FEAT_QUICKFIX
// When splitting the quickfix window open a new buffer in it,
// don't replicate the quickfix buffer.
if (bt_quickfix(curbuf))
goto newwindow;
#endif
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
(void)win_split((int)Prenum, WSP_VERT);
break;
// split current window and edit alternate file
case Ctrl_HAT:
case '^':
CHECK_CMDWIN;
reset_VIsual_and_resel(); // stop Visual mode
if (buflist_findnr(Prenum == 0
? curwin->w_alt_fnum : Prenum) == NULL)
{
if (Prenum == 0)
emsg(_(e_no_alternate_file));
else
semsg(_(e_buffer_nr_not_found), Prenum);
break;
}
if (!curbuf_locked() && win_split(0, 0) == OK)
(void)buflist_getfile(
Prenum == 0 ? curwin->w_alt_fnum : Prenum,
(linenr_T)0, GETF_ALT, FALSE);
break;
// open new window
case Ctrl_N:
case 'n':
CHECK_CMDWIN;
reset_VIsual_and_resel(); // stop Visual mode
#ifdef FEAT_QUICKFIX
newwindow:
#endif
if (Prenum)
// window height
vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, "%ld", Prenum);
else
cbuf[0] = NUL;
#if defined(FEAT_QUICKFIX)
if (nchar == 'v' || nchar == Ctrl_V)
STRCAT(cbuf, "v");
#endif
STRCAT(cbuf, "new");
do_cmdline_cmd(cbuf);
break;
// quit current window
case Ctrl_Q:
case 'q':
reset_VIsual_and_resel(); // stop Visual mode
cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum);
do_cmdline_cmd(cbuf);
break;
// close current window
case Ctrl_C:
case 'c':
reset_VIsual_and_resel(); // stop Visual mode
cmd_with_count("close", cbuf, sizeof(cbuf), Prenum);
do_cmdline_cmd(cbuf);
break;
#if defined(FEAT_QUICKFIX)
// close preview window
case Ctrl_Z:
case 'z':
CHECK_CMDWIN;
reset_VIsual_and_resel(); // stop Visual mode
do_cmdline_cmd((char_u *)"pclose");
break;
// cursor to preview window
case 'P':
FOR_ALL_WINDOWS(wp)
if (wp->w_p_pvw)
break;
if (wp == NULL)
emsg(_(e_there_is_no_preview_window));
else
win_goto(wp);
break;
#endif
// close all but current window
case Ctrl_O:
case 'o':
CHECK_CMDWIN;
reset_VIsual_and_resel(); // stop Visual mode
cmd_with_count("only", cbuf, sizeof(cbuf), Prenum);
do_cmdline_cmd(cbuf);
break;
// cursor to next window with wrap around
case Ctrl_W:
case 'w':
// cursor to previous window with wrap around
case 'W':
CHECK_CMDWIN;
if (ONE_WINDOW && Prenum != 1) // just one window
beep_flush();
else
{
if (Prenum) // go to specified window
{
for (wp = firstwin; --Prenum > 0; )
{
if (wp->w_next == NULL)
break;
else
wp = wp->w_next;
}
}
else
{
if (nchar == 'W') // go to previous window
{
wp = curwin->w_prev;
if (wp == NULL)
wp = lastwin; // wrap around
}
else // go to next window
{
wp = curwin->w_next;
if (wp == NULL)
wp = firstwin; // wrap around
}
}
win_goto(wp);
}
break;
// cursor to window below
case 'j':
case K_DOWN:
case Ctrl_J:
CHECK_CMDWIN;
win_goto_ver(FALSE, Prenum1);
break;
// cursor to window above
case 'k':
case K_UP:
case Ctrl_K:
CHECK_CMDWIN;
win_goto_ver(TRUE, Prenum1);
break;
// cursor to left window
case 'h':
case K_LEFT:
case Ctrl_H:
case K_BS:
CHECK_CMDWIN;
win_goto_hor(TRUE, Prenum1);
break;
// cursor to right window
case 'l':
case K_RIGHT:
case Ctrl_L:
CHECK_CMDWIN;
win_goto_hor(FALSE, Prenum1);
break;
// move window to new tab page
case 'T':
CHECK_CMDWIN;
if (one_window())
msg(_(m_onlyone));
else
{
tabpage_T *oldtab = curtab;
tabpage_T *newtab;
// First create a new tab with the window, then go back to
// the old tab and close the window there.
wp = curwin;
if (win_new_tabpage((int)Prenum) == OK
&& valid_tabpage(oldtab))
{
newtab = curtab;
goto_tabpage_tp(oldtab, TRUE, TRUE);
if (curwin == wp)
win_close(curwin, FALSE);
if (valid_tabpage(newtab))
goto_tabpage_tp(newtab, TRUE, TRUE);
}
}
break;
// cursor to top-left window
case 't':
case Ctrl_T:
win_goto(firstwin);
break;
// cursor to bottom-right window
case 'b':
case Ctrl_B:
win_goto(lastwin);
break;
// cursor to last accessed (previous) window
case 'p':
case Ctrl_P:
if (!win_valid(prevwin))
beep_flush();
else
win_goto(prevwin);
break;
// exchange current and next window
case 'x':
case Ctrl_X:
CHECK_CMDWIN;
win_exchange(Prenum);
break;
// rotate windows downwards
case Ctrl_R:
case 'r':
CHECK_CMDWIN;
reset_VIsual_and_resel(); // stop Visual mode
win_rotate(FALSE, (int)Prenum1); // downwards
break;
// rotate windows upwards
case 'R':
CHECK_CMDWIN;
reset_VIsual_and_resel(); // stop Visual mode
win_rotate(TRUE, (int)Prenum1); // upwards
break;
// move window to the very top/bottom/left/right
case 'K':
case 'J':
case 'H':
case 'L':
CHECK_CMDWIN;
win_totop((int)Prenum,
((nchar == 'H' || nchar == 'L') ? WSP_VERT : 0)
| ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT));
break;
// make all windows the same height
case '=':
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_equal(NULL, FALSE, 'b');
break;
// increase current window height
case '+':
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_setheight(curwin->w_height + (int)Prenum1);
break;
// decrease current window height
case '-':
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_setheight(curwin->w_height - (int)Prenum1);
break;
// set current window height
case Ctrl__:
case '_':
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_setheight(Prenum ? (int)Prenum : 9999);
break;
// increase current window width
case '>':
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_setwidth(curwin->w_width + (int)Prenum1);
break;
// decrease current window width
case '<':
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_setwidth(curwin->w_width - (int)Prenum1);
break;
// set current window width
case '|':
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_setwidth(Prenum != 0 ? (int)Prenum : 9999);
break;
// jump to tag and split window if tag exists (in preview window)
#if defined(FEAT_QUICKFIX)
case '}':
CHECK_CMDWIN;
if (Prenum)
g_do_tagpreview = Prenum;
else
g_do_tagpreview = p_pvh;
#endif
// FALLTHROUGH
case ']':
case Ctrl_RSB:
CHECK_CMDWIN;
// keep Visual mode, can select words to use as a tag
if (Prenum)
postponed_split = Prenum;
else
postponed_split = -1;
#ifdef FEAT_QUICKFIX
if (nchar != '}')
g_do_tagpreview = 0;
#endif
// Execute the command right here, required when "wincmd ]"
// was used in a function.
do_nv_ident(Ctrl_RSB, NUL);
break;
#ifdef FEAT_SEARCHPATH
// edit file name under cursor in a new window
case 'f':
case 'F':
case Ctrl_F:
wingotofile:
CHECK_CMDWIN;
ptr = grab_file_name(Prenum1, &lnum);
if (ptr != NULL)
{
tabpage_T *oldtab = curtab;
win_T *oldwin = curwin;
# ifdef FEAT_GUI
need_mouse_correct = TRUE;
# endif
setpcmark();
if (win_split(0, 0) == OK)
{
RESET_BINDING(curwin);
if (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,
ECMD_HIDE, NULL) == FAIL)
{
// Failed to open the file, close the window
// opened for it.
win_close(curwin, FALSE);
goto_tabpage_win(oldtab, oldwin);
}
else if (nchar == 'F' && lnum >= 0)
{
curwin->w_cursor.lnum = lnum;
check_cursor_lnum();
beginline(BL_SOL | BL_FIX);
}
}
vim_free(ptr);
}
break;
#endif
#ifdef FEAT_FIND_ID
// Go to the first occurrence of the identifier under cursor along path in a
// new window -- webb
case 'i': // Go to any match
case Ctrl_I:
type = FIND_ANY;
// FALLTHROUGH
case 'd': // Go to definition, using 'define'
case Ctrl_D:
CHECK_CMDWIN;
if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0)
break;
find_pattern_in_path(ptr, 0, len, TRUE,
Prenum == 0 ? TRUE : FALSE, type,
Prenum1, ACTION_SPLIT, (linenr_T)1, (linenr_T)MAXLNUM);
curwin->w_set_curswant = TRUE;
break;
#endif
// Quickfix window only: view the result under the cursor in a new split.
#if defined(FEAT_QUICKFIX)
case K_KENTER:
case CAR:
if (bt_quickfix(curbuf))
qf_view_result(TRUE);
break;
#endif
// CTRL-W g extended commands
case 'g':
case Ctrl_G:
CHECK_CMDWIN;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; // disallow scrolling here
#endif
++no_mapping;
++allow_keys; // no mapping for xchar, but allow key codes
if (xchar == NUL)
xchar = plain_vgetc();
LANGMAP_ADJUST(xchar, TRUE);
--no_mapping;
--allow_keys;
#ifdef FEAT_CMDL_INFO
(void)add_to_showcmd(xchar);
#endif
switch (xchar)
{
#if defined(FEAT_QUICKFIX)
case '}':
xchar = Ctrl_RSB;
if (Prenum)
g_do_tagpreview = Prenum;
else
g_do_tagpreview = p_pvh;
#endif
// FALLTHROUGH
case ']':
case Ctrl_RSB:
// keep Visual mode, can select words to use as a tag
if (Prenum)
postponed_split = Prenum;
else
postponed_split = -1;
// Execute the command right here, required when
// "wincmd g}" was used in a function.
do_nv_ident('g', xchar);
break;
#ifdef FEAT_SEARCHPATH
case 'f': // CTRL-W gf: "gf" in a new tab page
case 'F': // CTRL-W gF: "gF" in a new tab page
cmdmod.cmod_tab = tabpage_index(curtab) + 1;
nchar = xchar;
goto wingotofile;
#endif
case 't': // CTRL-W gt: go to next tab page
goto_tabpage((int)Prenum);
break;
case 'T': // CTRL-W gT: go to previous tab page
goto_tabpage(-(int)Prenum1);
break;
case TAB: // CTRL-W g<Tab>: go to last used tab page
if (goto_tabpage_lastused() == FAIL)
beep_flush();
break;
default:
beep_flush();
break;
}
break;
default: beep_flush();
break;
}
}
| 1
|
223,479
|
static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common)
{
DEFINE_COMPILER;
const sljit_u8 *start_bits = common->re->start_bitmap;
struct sljit_label *start;
struct sljit_jump *partial_quit;
#if PCRE2_CODE_UNIT_WIDTH != 8
struct sljit_jump *found = NULL;
#endif
jump_list *matches = NULL;
if (common->match_end_ptr != 0)
{
OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);
OP1(SLJIT_MOV, RETURN_ADDR, 0, STR_END, 0);
OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1));
OP2U(SLJIT_SUB | SLJIT_SET_GREATER, STR_END, 0, TMP1, 0);
CMOV(SLJIT_GREATER, STR_END, TMP1, 0);
}
start = LABEL();
partial_quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
if (common->mode == PCRE2_JIT_COMPLETE)
add_jump(compiler, &common->failed_match, partial_quit);
OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
if (!optimize_class(common, start_bits, (start_bits[31] & 0x80) != 0, FALSE, &matches))
{
#if PCRE2_CODE_UNIT_WIDTH != 8
if ((start_bits[31] & 0x80) != 0)
found = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 255);
else
CMPTO(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 255, start);
#elif defined SUPPORT_UNICODE
if (common->utf && is_char7_bitset(start_bits, FALSE))
CMPTO(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 127, start);
#endif
OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)start_bits);
if (!HAS_VIRTUAL_REGISTERS)
{
OP2(SLJIT_SHL, TMP3, 0, SLJIT_IMM, 1, TMP2, 0);
OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP3, 0);
}
else
{
OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0);
}
JUMPTO(SLJIT_ZERO, start);
}
else
set_jumps(matches, start);
#if PCRE2_CODE_UNIT_WIDTH != 8
if (found != NULL)
JUMPHERE(found);
#endif
OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
if (common->mode != PCRE2_JIT_COMPLETE)
JUMPHERE(partial_quit);
if (common->match_end_ptr != 0)
OP1(SLJIT_MOV, STR_END, 0, RETURN_ADDR, 0);
}
| 0
|
335,998
|
static int sr9700_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
{
struct usbnet *dev = netdev_priv(netdev);
return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
}
| 0
|
450,357
|
void vnc_display_init(const char *id, Error **errp)
{
VncDisplay *vd;
if (vnc_display_find(id) != NULL) {
return;
}
vd = g_malloc0(sizeof(*vd));
vd->id = strdup(id);
QTAILQ_INSERT_TAIL(&vnc_displays, vd, next);
QTAILQ_INIT(&vd->clients);
vd->expires = TIME_MAX;
if (keyboard_layout) {
trace_vnc_key_map_init(keyboard_layout);
vd->kbd_layout = init_keyboard_layout(name2keysym,
keyboard_layout, errp);
} else {
vd->kbd_layout = init_keyboard_layout(name2keysym, "en-us", errp);
}
if (!vd->kbd_layout) {
return;
}
vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
vd->connections_limit = 32;
qemu_mutex_init(&vd->mutex);
vnc_start_worker_thread();
vd->dcl.ops = &dcl_ops;
register_displaychangelistener(&vd->dcl);
vd->kbd = qkbd_state_init(vd->dcl.con);
}
| 0
|
222,673
|
void get_in_jail(void)
{
struct passwd *pw;
uid_t uid;
gid_t gid;
pw = getpwnam(TMATE_JAIL_USER);
if (!pw) {
tmate_fatal("Cannot get the /etc/passwd entry for %s",
TMATE_JAIL_USER);
}
uid = pw->pw_uid;
gid = pw->pw_gid;
if (getuid() != 0)
tmate_fatal("Need root privileges to create the jail");
if (chroot(TMATE_WORKDIR "/jail") < 0)
tmate_fatal("Cannot chroot()");
if (chdir("/") < 0)
tmate_fatal("Cannot chdir()");
#ifdef IS_LINUX
if (unshare(CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNS | CLONE_NEWNET) < 0)
tmate_fatal("Cannot create new namespace");
#endif
if (setgroups(1, (gid_t[]){gid}) < 0)
tmate_fatal("Cannot setgroups()");
#if defined(HAVE_SETRESGID)
if (setresgid(gid, gid, gid) < 0)
tmate_fatal("Cannot setresgid() %d", gid);
#elif defined(HAVE_SETREGID)
if (setregid(gid, gid) < 0)
tmate_fatal("Cannot setregid()");
#else
if (setgid(gid) < 0)
tmate_fatal("Cannot setgid()");
#endif
#if defined(HAVE_SETRESUID)
if (setresuid(uid, uid, uid) < 0)
tmate_fatal("Cannot setresuid()");
#elif defined(HAVE_SETREUID)
if (setreuid(uid, uid) < 0)
tmate_fatal("Cannot setreuid()");
#else
if (setuid(uid) < 0)
tmate_fatal("Cannot setuid()");
#endif
nice(1);
tmate_debug("Dropped priviledges to %s (%d,%d), jailed in %s",
TMATE_JAIL_USER, uid, gid, TMATE_WORKDIR "/jail");
}
| 0
|
409,460
|
get_long_from_buf(char_u *buf, long_u *val)
{
int len;
char_u bytes[sizeof(long_u)];
int i;
int shift;
*val = 0;
len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u));
if (len != -1)
{
for (i = 0; i < (int)sizeof(long_u); i++)
{
shift = 8 * (sizeof(long_u) - 1 - i);
*val += (long_u)bytes[i] << shift;
}
}
return len;
}
| 0
|
90,231
|
virtual WifiNetwork* wifi_network() { return wifi_; }
| 0
|
387,825
|
void InstanceKlass::oop_print_on(oop obj, outputStream* st) {
Klass::oop_print_on(obj, st);
if (this == SystemDictionary::String_klass()) {
typeArrayOop value = java_lang_String::value(obj);
juint length = java_lang_String::length(obj);
if (value != NULL &&
value->is_typeArray() &&
length <= (juint) value->length()) {
st->print(BULLET"string: ");
java_lang_String::print(obj, st);
st->cr();
if (!WizardMode) return; // that is enough
}
}
st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj));
FieldPrinter print_field(st, obj);
do_nonstatic_fields(&print_field);
if (this == SystemDictionary::Class_klass()) {
st->print(BULLET"signature: ");
java_lang_Class::print_signature(obj, st);
st->cr();
Klass* mirrored_klass = java_lang_Class::as_Klass(obj);
st->print(BULLET"fake entry for mirror: ");
mirrored_klass->print_value_on_maybe_null(st);
st->cr();
Klass* array_klass = java_lang_Class::array_klass_acquire(obj);
st->print(BULLET"fake entry for array: ");
array_klass->print_value_on_maybe_null(st);
st->cr();
st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj));
st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj));
Klass* real_klass = java_lang_Class::as_Klass(obj);
if (real_klass != NULL && real_klass->is_instance_klass()) {
InstanceKlass::cast(real_klass)->do_local_static_fields(&print_field);
}
} else if (this == SystemDictionary::MethodType_klass()) {
st->print(BULLET"signature: ");
java_lang_invoke_MethodType::print_signature(obj, st);
st->cr();
}
}
| 0
|
247,630
|
TEST_P(SslSocketTest, TestConnectionSucceedsWhenRejectOnExpiredNoOcspResponse) {
const std::string server_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
- certificate_chain:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/good_cert.pem"
private_key:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/good_key.pem"
ocsp_staple_policy: strict_stapling
)EOF";
const std::string client_ctx_yaml = R"EOF(
common_tls_context:
tls_params:
cipher_suites:
- TLS_RSA_WITH_AES_128_GCM_SHA256
)EOF";
TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());
testUtil(test_options.setExpectedServerStats("ssl.ocsp_staple_omitted").enableOcspStapling());
}
| 0
|
243,012
|
static void ssl_free_buffered_record( mbedtls_ssl_context *ssl )
{
mbedtls_ssl_handshake_params * const hs = ssl->handshake;
if( hs == NULL )
return;
if( hs->buffering.future_record.data != NULL )
{
hs->buffering.total_bytes_buffered -=
hs->buffering.future_record.len;
mbedtls_free( hs->buffering.future_record.data );
hs->buffering.future_record.data = NULL;
}
}
| 0
|
455,419
|
xfs_inode_ag_iterator_tag(
struct xfs_mount *mp,
int (*execute)(struct xfs_inode *ip, int flags,
void *args),
int flags,
void *args,
int tag)
{
struct xfs_perag *pag;
int error = 0;
int last_error = 0;
xfs_agnumber_t ag;
ag = 0;
while ((pag = xfs_perag_get_tag(mp, ag, tag))) {
ag = pag->pag_agno + 1;
error = xfs_inode_ag_walk(mp, pag, execute, flags, args, tag,
0);
xfs_perag_put(pag);
if (error) {
last_error = error;
if (error == -EFSCORRUPTED)
break;
}
}
return last_error;
}
| 0
|
369,891
|
static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)
{
struct dentry *dentry, *leader, *dir;
char buf[PROC_NUMBUF];
struct qstr name;
name.name = buf;
name.len = snprintf(buf, sizeof(buf), "%d", pid);
dentry = d_hash_and_lookup(mnt->mnt_root, &name);
if (dentry) {
shrink_dcache_parent(dentry);
d_drop(dentry);
dput(dentry);
}
name.name = buf;
name.len = snprintf(buf, sizeof(buf), "%d", tgid);
leader = d_hash_and_lookup(mnt->mnt_root, &name);
if (!leader)
goto out;
name.name = "task";
name.len = strlen(name.name);
dir = d_hash_and_lookup(leader, &name);
if (!dir)
goto out_put_leader;
name.name = buf;
name.len = snprintf(buf, sizeof(buf), "%d", pid);
dentry = d_hash_and_lookup(dir, &name);
if (dentry) {
shrink_dcache_parent(dentry);
d_drop(dentry);
dput(dentry);
}
dput(dir);
out_put_leader:
dput(leader);
out:
return;
}
| 0
|
221,638
|
LogicalResult DynamicBroadcastInDimOpLowering::matchAndRewrite(
mhlo::DynamicBroadcastInDimOp op, mlir::PatternRewriter& rewriter) const {
MLIRContext* ctx = getContext();
auto in_type = op.operand().getType().dyn_cast<RankedTensorType>();
auto out_type = op.getResult().getType().dyn_cast<RankedTensorType>();
if (!in_type || !out_type) return failure();
// Check that broadcast is right-aligned (numpy style), so that operand
// dimensions broadcasted to match inner-most dimensions of the output.
auto bcast_dims = op.broadcast_dimensions().getValues<int64_t>();
auto expected_bcast_dims = llvm::seq<int64_t>(
out_type.getRank() - in_type.getRank(), out_type.getRank());
if (!llvm::equal(bcast_dims, expected_bcast_dims)) return failure();
ShapeComponentAnalysis shape_component_analysis;
auto input_map = isNonExpandingBroadcast(
shape_component_analysis, op.operand(), op.output_dimensions());
if (!input_map) return failure();
// Resolve dynamic output dimensions for the `linalg.init_tensor` operation.
SmallVector<Value> output_dyn_dimensions;
Location loc = op.getLoc();
int64_t rank = out_type.getRank();
for (size_t d = 0; d < rank; ++d) {
int64_t output_dim = out_type.getShape()[d];
// Skip static output dimensions, they will be resolved from the shape.
if (output_dim >= 0) continue;
// Resolve the dynamic size of the output dimension.
Value output_dyn_dim = rewriter.create<tensor::ExtractOp>(
loc, op.output_dimensions(),
ValueRange{rewriter.create<ConstantIndexOp>(loc, d)});
// Symbolic shape analysis might have given us an i32 or i64. Cast to index.
if (!output_dyn_dim.getType().isIndex())
output_dyn_dim = rewriter.create<IndexCastOp>(loc, output_dyn_dim,
rewriter.getIndexType());
output_dyn_dimensions.push_back(output_dyn_dim);
}
// Create a linalg.tensor_init operation to initialize output.
Value init = rewriter.create<linalg::InitTensorOp>(loc, output_dyn_dimensions,
out_type.getShape(),
out_type.getElementType());
// Output indexing map is an identity with `rank` number of loops.
AffineMap output_map = AffineMap::getMultiDimIdentityMap(rank, ctx);
// All iterators are parallel.
SmallVector<llvm::StringRef> iterator_types(rank, "parallel");
rewriter.replaceOpWithNewOp<linalg::GenericOp>(
op, /*resultTensorTypes=*/TypeRange{init.getType()},
/*inputs=*/ValueRange{op.operand()},
/*outputs=*/ValueRange{init},
/*indexingMaps=*/llvm::makeArrayRef({*input_map, output_map}),
/*iteratorTypes=*/iterator_types,
[&](OpBuilder& nested_builder, Location nested_loc, ValueRange args) {
nested_builder.create<linalg::YieldOp>(nested_loc, args[0]);
});
return success();
}
| 0
|
459,117
|
static struct tcf_block *tcf_block_create(struct net *net, struct Qdisc *q,
u32 block_index,
struct netlink_ext_ack *extack)
{
struct tcf_block *block;
block = kzalloc(sizeof(*block), GFP_KERNEL);
if (!block) {
NL_SET_ERR_MSG(extack, "Memory allocation for block failed");
return ERR_PTR(-ENOMEM);
}
mutex_init(&block->lock);
mutex_init(&block->proto_destroy_lock);
init_rwsem(&block->cb_lock);
flow_block_init(&block->flow_block);
INIT_LIST_HEAD(&block->chain_list);
INIT_LIST_HEAD(&block->owner_list);
INIT_LIST_HEAD(&block->chain0.filter_chain_list);
refcount_set(&block->refcnt, 1);
block->net = net;
block->index = block_index;
/* Don't store q pointer for blocks which are shared */
if (!tcf_block_shared(block))
block->q = q;
return block;
}
| 0
|
242,960
|
static int ssl_consume_current_message( mbedtls_ssl_context *ssl )
{
/*
* Consume last content-layer message and potentially
* update in_msglen which keeps track of the contents'
* consumption state.
*
* (1) Handshake messages:
* Remove last handshake message, move content
* and adapt in_msglen.
*
* (2) Alert messages:
* Consume whole record content, in_msglen = 0.
*
* (3) Change cipher spec:
* Consume whole record content, in_msglen = 0.
*
* (4) Application data:
* Don't do anything - the record layer provides
* the application data as a stream transport
* and consumes through mbedtls_ssl_read only.
*
*/
/* Case (1): Handshake messages */
if( ssl->in_hslen != 0 )
{
/* Hard assertion to be sure that no application data
* is in flight, as corrupting ssl->in_msglen during
* ssl->in_offt != NULL is fatal. */
if( ssl->in_offt != NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
}
/*
* Get next Handshake message in the current record
*/
/* Notes:
* (1) in_hslen is not necessarily the size of the
* current handshake content: If DTLS handshake
* fragmentation is used, that's the fragment
* size instead. Using the total handshake message
* size here is faulty and should be changed at
* some point.
* (2) While it doesn't seem to cause problems, one
* has to be very careful not to assume that in_hslen
* is always <= in_msglen in a sensible communication.
* Again, it's wrong for DTLS handshake fragmentation.
* The following check is therefore mandatory, and
* should not be treated as a silently corrected assertion.
* Additionally, ssl->in_hslen might be arbitrarily out of
* bounds after handling a DTLS message with an unexpected
* sequence number, see mbedtls_ssl_prepare_handshake_record.
*/
if( ssl->in_hslen < ssl->in_msglen )
{
ssl->in_msglen -= ssl->in_hslen;
memmove( ssl->in_msg, ssl->in_msg + ssl->in_hslen,
ssl->in_msglen );
MBEDTLS_SSL_DEBUG_BUF( 4, "remaining content in record",
ssl->in_msg, ssl->in_msglen );
}
else
{
ssl->in_msglen = 0;
}
ssl->in_hslen = 0;
}
/* Case (4): Application data */
else if( ssl->in_offt != NULL )
{
return( 0 );
}
/* Everything else (CCS & Alerts) */
else
{
ssl->in_msglen = 0;
}
return( 0 );
}
| 0
|
386,489
|
void DL_Dxf::writeView(DL_WriterA& dw) {
dw.dxfString( 0, "TABLE");
dw.dxfString( 2, "VIEW");
if (version==DL_VERSION_2000) {
dw.dxfHex(5, 6);
}
//dw.dxfHex(330, 0);
if (version==DL_VERSION_2000) {
dw.dxfString(100, "AcDbSymbolTable");
}
dw.dxfInt( 70, 0);
dw.dxfString( 0, "ENDTAB");
}
| 0
|
336,496
|
void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, const void *message,
size_t size)
{
RedCharDeviceVDIPort *dev = reds->agent_dev.get();
VDIChunkHeader *header;
AgentMsgFilterResult res;
res = agent_msg_filter_process_data(&dev->priv->write_filter,
(const uint8_t*) message, size);
switch (res) {
case AGENT_MSG_FILTER_OK:
break;
case AGENT_MSG_FILTER_DISCARD:
return;
case AGENT_MSG_FILTER_MONITORS_CONFIG:
reds_on_main_agent_monitors_config(reds, mcc, message, size);
return;
case AGENT_MSG_FILTER_PROTO_ERROR:
mcc->shutdown();
return;
}
spice_assert(dev->priv->recv_from_client_buf);
spice_assert(message == dev->priv->recv_from_client_buf->buf + sizeof(VDIChunkHeader));
// TODO - start tracking agent data per channel
header = (VDIChunkHeader *)dev->priv->recv_from_client_buf->buf;
header->port = VDP_CLIENT_PORT;
header->size = size;
dev->priv->recv_from_client_buf->buf_used = sizeof(VDIChunkHeader) + size;
dev->priv->recv_from_client_buf_pushed = TRUE;
dev->write_buffer_add(dev->priv->recv_from_client_buf);
}
| 0
|
512,975
|
Item_ref(THD *thd, Item_ref *item)
:Item_ident(thd, item), With_sum_func_cache(*item),
set_properties_only(0), ref(item->ref) {}
| 0
|
314,769
|
cdf_namecmp(const char *d, const uint16_t *s, size_t l)
{
for (; l--; d++, s++)
if (*d != CDF_TOLE2(*s))
return (unsigned char)*d - CDF_TOLE2(*s);
return 0;
}
| 0
|
366,239
|
static int do_loopback(struct path *path, const char *old_name,
int recurse)
{
struct path old_path;
struct mount *mnt = NULL, *parent;
struct mountpoint *mp;
int err;
if (!old_name || !*old_name)
return -EINVAL;
err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path);
if (err)
return err;
err = -EINVAL;
if (mnt_ns_loop(old_path.dentry))
goto out;
mp = lock_mount(path);
if (IS_ERR(mp)) {
err = PTR_ERR(mp);
goto out;
}
parent = real_mount(path->mnt);
if (!check_mnt(parent))
goto out2;
mnt = __do_loopback(&old_path, recurse);
if (IS_ERR(mnt)) {
err = PTR_ERR(mnt);
goto out2;
}
err = graft_tree(mnt, parent, mp);
if (err) {
lock_mount_hash();
umount_tree(mnt, UMOUNT_SYNC);
unlock_mount_hash();
}
out2:
unlock_mount(mp);
out:
path_put(&old_path);
return err;
}
| 0
|
389,740
|
tv_get_string_chk(typval_T *varp)
{
static char_u mybuf[NUMBUFLEN];
return tv_get_string_buf_chk(varp, mybuf);
}
| 0
|
437,277
|
compile_range_repeat_node(QuantNode* qn, int target_len, int empty_info,
regex_t* reg, ScanEnv* env)
{
int r;
int num_repeat = reg->num_repeat;
r = add_opcode(reg, qn->greedy ? OP_REPEAT : OP_REPEAT_NG);
if (r != 0) return r;
r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID */
reg->num_repeat++;
if (r != 0) return r;
r = add_rel_addr(reg, target_len + SIZE_OP_REPEAT_INC);
if (r != 0) return r;
r = entry_repeat_range(reg, num_repeat, qn->lower, qn->upper);
if (r != 0) return r;
r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env);
if (r != 0) return r;
if (
#ifdef USE_CALL
NODE_IS_IN_MULTI_ENTRY(qn) ||
#endif
NODE_IS_IN_REAL_REPEAT(qn)) {
r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC_SG : OP_REPEAT_INC_NG_SG);
}
else {
r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC : OP_REPEAT_INC_NG);
}
if (r != 0) return r;
r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID */
return r;
}
| 0
|
242,661
|
dissect_sysdig_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_)
{
proto_item *ti;
proto_tree *se_tree, *syscall_tree;
guint event_type = pinfo->rec->rec_header.syscall_header.event_type;
int encoding = pinfo->rec->rec_header.syscall_header.byte_order == G_BIG_ENDIAN ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN;
const struct _event_col_info *cur_col_info;
const struct _event_tree_info *cur_tree_info;
/*** HEURISTICS ***/
/* Check that the packet is long enough for it to belong to us. */
if (tvb_reported_length(tvb) < SYSDIG_EVENT_MIN_LENGTH)
return 0;
/*** COLUMN DATA ***/
/*
* Sysdig uses the term "event" internally. So far every event has been
* a syscall.
*/
col_set_str(pinfo->cinfo, COL_PROTOCOL, "System Call");
col_clear(pinfo->cinfo, COL_INFO);
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(event_type, event_type_vals, "Unknown syscall %u"));
/*
* XXX We can ditch this in favor of a simple index when event_col_info
* is contiguous and in the correct order.
*/
for (cur_col_info = event_col_info; cur_col_info->params; cur_col_info++) {
if (cur_col_info->event_type == event_type) {
const struct _event_col_info_param *cur_param = cur_col_info->params;
int param_offset = cur_col_info->num_len_fields * 2;
/* Find the data offset */
int cur_len_field;
for (cur_len_field = 0;
cur_len_field < cur_col_info->num_len_fields && cur_param->param_name;
cur_len_field++) {
unsigned param_len = tvb_get_guint16(tvb, cur_len_field * 2, encoding);
if (cur_param->param_num == cur_len_field) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s=", cur_param->param_name);
switch (cur_param->param_ftype) {
case FT_STRING:
col_append_str(pinfo->cinfo, COL_INFO, format_param_str(tvb, param_offset, param_len));
break;
case FT_UINT64:
col_append_fstr(pinfo->cinfo, COL_INFO, "%" G_GUINT64_FORMAT, tvb_get_guint64(tvb, param_offset, encoding));
default:
break;
}
cur_param++;
}
param_offset += param_len;
}
}
}
/*** PROTOCOL TREE ***/
/* create display subtree for the protocol */
ti = proto_tree_add_item(tree, proto_sysdig_event, tvb, 0, -1, ENC_NA);
se_tree = proto_item_add_subtree(ti, ett_sysdig_event);
proto_tree_add_uint(se_tree, hf_se_cpu_id, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.cpu_id);
proto_tree_add_uint64(se_tree, hf_se_thread_id, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.thread_id);
proto_tree_add_uint(se_tree, hf_se_event_length, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.event_len);
if (pinfo->rec->rec_header.syscall_header.nparams != 0) {
proto_tree_add_uint(se_tree, hf_se_nparams, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.nparams);
}
ti = proto_tree_add_uint(se_tree, hf_se_event_type, tvb, 0, 0, event_type);
syscall_tree = proto_item_add_subtree(ti, ett_sysdig_syscall);
for (cur_tree_info = event_tree_info; cur_tree_info->hf_indexes; cur_tree_info++) {
if (cur_tree_info->event_type == event_type) {
dissect_event_params(tvb, &pinfo->rec->rec_header.syscall_header, 0, syscall_tree, encoding, cur_tree_info->hf_indexes);
break;
}
}
/* XXX */
/* return offset; */
return pinfo->rec->rec_header.syscall_header.event_len;
}
| 0
|
273,105
|
timespec_add(struct timespec time1, struct timespec time2)
{
struct timespec result;
result.tv_sec = time1.tv_sec + time2.tv_sec;
result.tv_nsec = time1.tv_nsec + time2.tv_nsec;
if (result.tv_nsec >= 1000000000L)
{
result.tv_sec++;
result.tv_nsec -= 1000000000L;
}
return result;
}
| 0
|
384,117
|
raptor_xml_writer_comment(raptor_xml_writer* xml_writer,
const unsigned char *s)
{
XML_WRITER_FLUSH_CLOSE_BRACKET(xml_writer);
raptor_xml_writer_raw_counted(xml_writer, (const unsigned char*)"<!-- ", 5);
raptor_xml_writer_cdata(xml_writer, s);
raptor_xml_writer_raw_counted(xml_writer, (const unsigned char*)" -->", 4);
}
| 0
|
259,199
|
static int update_frag_index(MOVContext *c, int64_t offset)
{
int index, i;
MOVFragmentIndexItem * item;
MOVFragmentStreamInfo * frag_stream_info;
// If moof_offset already exists in frag_index, return index to it
index = search_frag_moof_offset(&c->frag_index, offset);
if (index < c->frag_index.nb_items &&
c->frag_index.item[index].moof_offset == offset)
return index;
// offset is not yet in frag index.
// Insert new item at index (sorted by moof offset)
item = av_fast_realloc(c->frag_index.item,
&c->frag_index.allocated_size,
(c->frag_index.nb_items + 1) *
sizeof(*c->frag_index.item));
if (!item)
return -1;
c->frag_index.item = item;
frag_stream_info = av_realloc_array(NULL, c->fc->nb_streams,
sizeof(*item->stream_info));
if (!frag_stream_info)
return -1;
for (i = 0; i < c->fc->nb_streams; i++) {
// Avoid building frag index if streams lack track id.
if (c->fc->streams[i]->id < 0) {
av_free(frag_stream_info);
return AVERROR_INVALIDDATA;
}
frag_stream_info[i].id = c->fc->streams[i]->id;
frag_stream_info[i].sidx_pts = AV_NOPTS_VALUE;
frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE;
frag_stream_info[i].next_trun_dts = AV_NOPTS_VALUE;
frag_stream_info[i].first_tfra_pts = AV_NOPTS_VALUE;
frag_stream_info[i].index_base = -1;
frag_stream_info[i].index_entry = -1;
frag_stream_info[i].encryption_index = NULL;
}
if (index < c->frag_index.nb_items)
memmove(c->frag_index.item + index + 1, c->frag_index.item + index,
(c->frag_index.nb_items - index) * sizeof(*c->frag_index.item));
item = &c->frag_index.item[index];
item->headers_read = 0;
item->current = 0;
item->nb_stream_info = c->fc->nb_streams;
item->moof_offset = offset;
item->stream_info = frag_stream_info;
c->frag_index.nb_items++;
return index;
}
| 0
|
513,039
|
void copy()
{
Timestamp_or_zero_datetime_native_null tmp(current_thd, item, false);
null_value= tmp.is_null();
m_value= tmp.is_null() ? Timestamp_or_zero_datetime() :
Timestamp_or_zero_datetime(tmp);
}
| 0
|
233,819
|
void fmtutil_atari_help_palbits(deark *c)
{
de_msg(c, "-opt atari:palbits=<9|12|15> : Numer of significant bits "
"per palette color");
}
| 0
|
233,943
|
Value DocumentSourceUnionWith::serialize(boost::optional<ExplainOptions::Verbosity> explain) const {
auto collectionless = _pipeline->getContext()->ns.isCollectionlessAggregateNS();
if (explain) {
// There are several different possible states depending on the explain verbosity as well as
// the other stages in the pipeline:
// * If verbosity is queryPlanner, then the sub-pipeline should be untouched and we can
// explain it directly.
// * If verbosity is execStats or allPlansExecution, then whether or not to explain the
// sub-pipeline depends on if we've started reading from it. For instance, there could be a
// $limit stage after the $unionWith which results in only reading from the base collection
// branch and not the sub-pipeline.
Pipeline* pipeCopy = nullptr;
if (*explain == ExplainOptions::Verbosity::kQueryPlanner) {
pipeCopy = Pipeline::create(_pipeline->getSources(), _pipeline->getContext()).release();
} else if (*explain >= ExplainOptions::Verbosity::kExecStats &&
_executionState > ExecutionProgress::kIteratingSource) {
// We've either exhausted the sub-pipeline or at least started iterating it. Use the
// cached pipeline to get the explain output since the '_pipeline' may have been
// modified for any optimizations or pushdowns into the initial $cursor stage.
pipeCopy = Pipeline::create(_cachedPipeline, _pipeline->getContext()).release();
} else {
// The plan does not require reading from the sub-pipeline, so just include the
// serialization in the explain output.
BSONArrayBuilder bab;
for (auto&& stage : _pipeline->serialize())
bab << stage;
auto spec = collectionless
? DOC("pipeline" << bab.arr())
: DOC("coll" << _pipeline->getContext()->ns.coll() << "pipeline" << bab.arr());
return Value(DOC(getSourceName() << spec));
}
invariant(pipeCopy);
BSONObj explainLocal =
pExpCtx->mongoProcessInterface->preparePipelineAndExplain(pipeCopy, *explain);
LOGV2_DEBUG(4553501, 3, "$unionWith attached cursor to pipeline for explain");
// We expect this to be an explanation of a pipeline -- there should only be one field.
invariant(explainLocal.nFields() == 1);
auto spec = collectionless ? DOC("pipeline" << explainLocal.firstElement())
: DOC("coll" << _pipeline->getContext()->ns.coll() << "pipeline"
<< explainLocal.firstElement());
return Value(DOC(getSourceName() << spec));
} else {
BSONArrayBuilder bab;
for (auto&& stage : _pipeline->serialize())
bab << stage;
auto spec = collectionless
? DOC("pipeline" << bab.arr())
: DOC("coll" << _pipeline->getContext()->ns.coll() << "pipeline" << bab.arr());
return Value(DOC(getSourceName() << spec));
}
}
| 0
|
249,987
|
u64 GetMoovAndMetaSize(GF_ISOFile *movie, GF_List *writers)
{
u32 i;
u64 size;
size = 0;
if (movie->moov) {
TrackWriter *writer;
gf_isom_box_size((GF_Box *)movie->moov);
size = movie->moov->size;
if (size > 0xFFFFFFFF) size += 8;
i=0;
while ((writer = (TrackWriter*)gf_list_enum(writers, &i))) {
size -= writer->stbl->ChunkOffset->size;
size -= writer->stbl->SampleToChunk->size;
gf_isom_box_size((GF_Box *)writer->stsc);
gf_isom_box_size(writer->stco);
size += writer->stsc->size;
size += writer->stco->size;
}
}
if (movie->meta) {
u64 msize;
gf_isom_box_size((GF_Box *)movie->meta);
msize = movie->meta->size;
if (msize > 0xFFFFFFFF) msize += 8;
size += msize;
}
return size;
}
| 0
|
466,160
|
static int em_pop_sreg(struct x86_emulate_ctxt *ctxt)
{
int seg = ctxt->src2.val;
unsigned long selector;
int rc;
rc = emulate_pop(ctxt, &selector, ctxt->op_bytes);
if (rc != X86EMUL_CONTINUE)
return rc;
rc = load_segment_descriptor(ctxt, (u16)selector, seg);
return rc;
}
| 0
|
387,781
|
InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) {
const int size = InstanceKlass::size(parser.vtable_size(),
parser.itable_size(),
nonstatic_oop_map_size(parser.total_oop_map_count()),
parser.is_interface(),
parser.is_anonymous(),
should_store_fingerprint(parser.is_anonymous()));
const Symbol* const class_name = parser.class_name();
assert(class_name != NULL, "invariant");
ClassLoaderData* loader_data = parser.loader_data();
assert(loader_data != NULL, "invariant");
InstanceKlass* ik;
// Allocation
if (REF_NONE == parser.reference_type()) {
if (class_name == vmSymbols::java_lang_Class()) {
// mirror
ik = new (loader_data, size, THREAD) InstanceMirrorKlass(parser);
}
else if (is_class_loader(class_name, parser)) {
// class loader
ik = new (loader_data, size, THREAD) InstanceClassLoaderKlass(parser);
} else {
// normal
ik = new (loader_data, size, THREAD) InstanceKlass(parser, InstanceKlass::_misc_kind_other);
}
} else {
// reference
ik = new (loader_data, size, THREAD) InstanceRefKlass(parser);
}
// Check for pending exception before adding to the loader data and incrementing
// class count. Can get OOM here.
if (HAS_PENDING_EXCEPTION) {
return NULL;
}
return ik;
}
| 0
|
353,011
|
printableStringValidate(
Syntax *syntax,
struct berval *val )
{
ber_len_t i;
if( BER_BVISEMPTY( val ) ) return LDAP_INVALID_SYNTAX;
for(i=0; i < val->bv_len; i++) {
if( !SLAP_PRINTABLE(val->bv_val[i]) ) {
return LDAP_INVALID_SYNTAX;
}
}
return LDAP_SUCCESS;
}
| 0
|
294,527
|
c_nth_kday_to_jd(int y, int m, int n, int k, double sg, int *rjd, int *ns)
{
int rjd2, ns2;
if (n > 0) {
c_find_fdom(y, m, sg, &rjd2, &ns2);
rjd2 -= 1;
}
else {
c_find_ldom(y, m, sg, &rjd2, &ns2);
rjd2 += 7;
}
*rjd = (rjd2 - MOD((rjd2 - k) + 1, 7)) + 7 * n;
*ns = (*rjd < sg) ? 0 : 1;
}
| 0
|
313,548
|
static int rose_del_node(struct rose_route_struct *rose_route,
struct net_device *dev)
{
struct rose_node *rose_node;
struct rose_neigh *rose_neigh;
int i, err = 0;
spin_lock_bh(&rose_node_list_lock);
spin_lock_bh(&rose_neigh_list_lock);
rose_node = rose_node_list;
while (rose_node != NULL) {
if ((rose_node->mask == rose_route->mask) &&
(rosecmpm(&rose_route->address, &rose_node->address,
rose_route->mask) == 0))
break;
rose_node = rose_node->next;
}
if (rose_node == NULL || rose_node->loopback) {
err = -EINVAL;
goto out;
}
rose_neigh = rose_neigh_list;
while (rose_neigh != NULL) {
if (ax25cmp(&rose_route->neighbour,
&rose_neigh->callsign) == 0 &&
rose_neigh->dev == dev)
break;
rose_neigh = rose_neigh->next;
}
if (rose_neigh == NULL) {
err = -EINVAL;
goto out;
}
for (i = 0; i < rose_node->count; i++) {
if (rose_node->neighbour[i] == rose_neigh) {
rose_neigh->count--;
if (rose_neigh->count == 0 && rose_neigh->use == 0)
rose_remove_neigh(rose_neigh);
rose_node->count--;
if (rose_node->count == 0) {
rose_remove_node(rose_node);
} else {
switch (i) {
case 0:
rose_node->neighbour[0] =
rose_node->neighbour[1];
fallthrough;
case 1:
rose_node->neighbour[1] =
rose_node->neighbour[2];
break;
case 2:
break;
}
}
goto out;
}
}
err = -EINVAL;
out:
spin_unlock_bh(&rose_neigh_list_lock);
spin_unlock_bh(&rose_node_list_lock);
return err;
}
| 0
|
427,164
|
static void check_match (LexState *ls, int what, int who, int where) {
if (l_unlikely(!testnext(ls, what))) {
if (where == ls->linenumber) /* all in the same line? */
error_expected(ls, what); /* do not need a complex message */
else {
luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
"%s expected (to close %s at line %d)",
luaX_token2str(ls, what), luaX_token2str(ls, who), where));
}
}
}
| 0
|
391,639
|
static NTSTATUS smbd_calculate_maximum_allowed_access(
connection_struct *conn,
const struct smb_filename *smb_fname,
bool use_privs,
uint32_t *p_access_mask)
{
struct security_descriptor *sd;
uint32_t access_granted;
NTSTATUS status;
if (!use_privs && (get_current_uid(conn) == (uid_t)0)) {
*p_access_mask |= FILE_GENERIC_ALL;
return NT_STATUS_OK;
}
status = SMB_VFS_GET_NT_ACL(conn, smb_fname->base_name,
(SECINFO_OWNER |
SECINFO_GROUP |
SECINFO_DACL),
talloc_tos(), &sd);
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
/*
* File did not exist
*/
*p_access_mask = FILE_GENERIC_ALL;
return NT_STATUS_OK;
}
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("Could not get acl on file %s: %s\n",
smb_fname_str_dbg(smb_fname),
nt_errstr(status)));
return NT_STATUS_ACCESS_DENIED;
}
/*
* If we can access the path to this file, by
* default we have FILE_READ_ATTRIBUTES from the
* containing directory. See the section:
* "Algorithm to Check Access to an Existing File"
* in MS-FSA.pdf.
*
* se_file_access_check()
* also takes care of owner WRITE_DAC and READ_CONTROL.
*/
status = se_file_access_check(sd,
get_current_nttok(conn),
use_privs,
(*p_access_mask & ~FILE_READ_ATTRIBUTES),
&access_granted);
TALLOC_FREE(sd);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("Access denied on file %s: "
"when calculating maximum access\n",
smb_fname_str_dbg(smb_fname)));
return NT_STATUS_ACCESS_DENIED;
}
*p_access_mask = (access_granted | FILE_READ_ATTRIBUTES);
if (!(access_granted & DELETE_ACCESS)) {
if (can_delete_file_in_directory(conn, smb_fname)) {
*p_access_mask |= DELETE_ACCESS;
}
}
return NT_STATUS_OK;
}
| 0
|
409,461
|
termrequest_any_pending()
{
int i;
time_t now = time(NULL);
for (i = 0; all_termrequests[i] != NULL; ++i)
{
if (all_termrequests[i]->tr_progress == STATUS_SENT)
{
if (all_termrequests[i]->tr_start > 0 && now > 0
&& all_termrequests[i]->tr_start + 2 < now)
// Sent the request more than 2 seconds ago and didn't get a
// response, assume it failed.
all_termrequests[i]->tr_progress = STATUS_FAIL;
else
return TRUE;
}
}
return FALSE;
}
| 0
|
432,182
|
MemTxResult memory_region_dispatch_read(struct uc_struct *uc, MemoryRegion *mr,
hwaddr addr,
uint64_t *pval,
MemOp op,
MemTxAttrs attrs)
{
unsigned size = memop_size(op);
MemTxResult r;
if (!memory_region_access_valid(uc, mr, addr, size, false, attrs)) {
*pval = unassigned_mem_read(mr, addr, size);
return MEMTX_DECODE_ERROR;
}
r = memory_region_dispatch_read1(uc, mr, addr, pval, size, attrs);
adjust_endianness(mr, pval, op);
return r;
}
| 0
|
238,584
|
static void __scalar64_min_max_lsh(struct bpf_reg_state *dst_reg,
u64 umin_val, u64 umax_val)
{
/* Special case <<32 because it is a common compiler pattern to sign
* extend subreg by doing <<32 s>>32. In this case if 32bit bounds are
* positive we know this shift will also be positive so we can track
* bounds correctly. Otherwise we lose all sign bit information except
* what we can pick up from var_off. Perhaps we can generalize this
* later to shifts of any length.
*/
if (umin_val == 32 && umax_val == 32 && dst_reg->s32_max_value >= 0)
dst_reg->smax_value = (s64)dst_reg->s32_max_value << 32;
else
dst_reg->smax_value = S64_MAX;
if (umin_val == 32 && umax_val == 32 && dst_reg->s32_min_value >= 0)
dst_reg->smin_value = (s64)dst_reg->s32_min_value << 32;
else
dst_reg->smin_value = S64_MIN;
/* If we might shift our top bit out, then we know nothing */
if (dst_reg->umax_value > 1ULL << (63 - umax_val)) {
dst_reg->umin_value = 0;
dst_reg->umax_value = U64_MAX;
} else {
dst_reg->umin_value <<= umin_val;
dst_reg->umax_value <<= umax_val;
}
}
| 0
|
406,212
|
static int mk_exit_code(struct libmnt_context *cxt, int rc)
{
int syserr;
struct stat st;
unsigned long uflags = 0, mflags = 0;
int restricted = mnt_context_is_restricted(cxt);
const char *tgt = mnt_context_get_target(cxt);
const char *src = mnt_context_get_source(cxt);
try_readonly:
if (mnt_context_helper_executed(cxt))
/*
* /sbin/mount.<type> called, return status
*/
return mnt_context_get_helper_status(cxt);
if (rc == 0 && mnt_context_get_status(cxt) == 1) {
/*
* Libmount success && syscall success.
*/
selinux_warning(cxt, tgt);
return MOUNT_EX_SUCCESS; /* mount(2) success */
}
mnt_context_get_mflags(cxt, &mflags); /* mount(2) flags */
mnt_context_get_user_mflags(cxt, &uflags); /* userspace flags */
if (!mnt_context_syscall_called(cxt)) {
/*
* libmount errors (extra library checks)
*/
switch (rc) {
case -EPERM:
warnx(_("only root can mount %s on %s"), src, tgt);
return MOUNT_EX_USAGE;
case -EBUSY:
warnx(_("%s is already mounted"), src);
return MOUNT_EX_USAGE;
case -MNT_ERR_NOFSTAB:
if (mnt_context_is_swapmatch(cxt)) {
warnx(_("can't find %s in %s"),
src ? src : tgt,
mnt_get_fstab_path());
return MOUNT_EX_USAGE;
}
/* source/target explicitly defined */
if (tgt)
warnx(_("can't find mountpoint %s in %s"),
tgt, mnt_get_fstab_path());
else
warnx(_("can't find mount source %s in %s"),
src, mnt_get_fstab_path());
return MOUNT_EX_USAGE;
case -MNT_ERR_NOFSTYPE:
if (restricted)
warnx(_("I could not determine the filesystem type, "
"and none was specified"));
else
warnx(_("you must specify the filesystem type"));
return MOUNT_EX_USAGE;
case -MNT_ERR_NOSOURCE:
if (src)
warnx(_("can't find %s"), src);
else
warnx(_("mount source not defined"));
return MOUNT_EX_USAGE;
case -MNT_ERR_MOUNTOPT:
if (errno)
warn(_("failed to parse mount options"));
else
warnx(_("failed to parse mount options"));
return MOUNT_EX_USAGE;
case -MNT_ERR_LOOPDEV:
warn(_("%s: failed to setup loop device"), src);
return MOUNT_EX_FAIL;
default:
return handle_generic_errors(rc, _("%s: mount failed"),
tgt ? tgt : src);
}
} else if (mnt_context_get_syscall_errno(cxt) == 0) {
/*
* mount(2) syscall success, but something else failed
* (probably error in mtab processing).
*/
if (rc < 0)
return handle_generic_errors(rc,
_("%s: filesystem mounted, but mount(8) failed"),
tgt ? tgt : src);
return MOUNT_EX_SOFTWARE; /* internal error */
}
/*
* mount(2) errors
*/
syserr = mnt_context_get_syscall_errno(cxt);
switch(syserr) {
case EPERM:
if (geteuid() == 0) {
if (stat(tgt, &st) || !S_ISDIR(st.st_mode))
warnx(_("mount point %s is not a directory"), tgt);
else
warnx(_("permission denied"));
} else
warnx(_("must be superuser to use mount"));
break;
case EBUSY:
{
struct libmnt_table *tb;
if (mflags & MS_REMOUNT) {
warnx(_("%s is busy"), tgt);
break;
}
warnx(_("%s is already mounted or %s busy"), src, tgt);
if (src && mnt_context_get_mtab(cxt, &tb) == 0) {
struct libmnt_iter *itr = mnt_new_iter(MNT_ITER_FORWARD);
struct libmnt_fs *fs;
while(mnt_table_next_fs(tb, itr, &fs) == 0) {
const char *s = mnt_fs_get_srcpath(fs),
*t = mnt_fs_get_target(fs);
if (t && s && mnt_fs_streq_srcpath(fs, src))
fprintf(stderr, _(
" %s is already mounted on %s\n"), s, t);
}
mnt_free_iter(itr);
}
break;
}
case ENOENT:
if (lstat(tgt, &st))
warnx(_("mount point %s does not exist"), tgt);
else if (stat(tgt, &st))
warnx(_("mount point %s is a symbolic link to nowhere"), tgt);
else if (stat(src, &st)) {
if (uflags & MNT_MS_NOFAIL)
return MOUNT_EX_SUCCESS;
warnx(_("special device %s does not exist"), src);
} else {
errno = syserr;
warn(_("mount(2) failed")); /* print errno */
}
break;
case ENOTDIR:
if (stat(tgt, &st) || ! S_ISDIR(st.st_mode))
warnx(_("mount point %s is not a directory"), tgt);
else if (stat(src, &st) && errno == ENOTDIR) {
if (uflags & MNT_MS_NOFAIL)
return MOUNT_EX_SUCCESS;
warnx(_("special device %s does not exist "
"(a path prefix is not a directory)"), src);
} else {
errno = syserr;
warn(_("mount(2) failed")); /* print errno */
}
break;
case EINVAL:
if (mflags & MS_REMOUNT)
warnx(_("%s not mounted or bad option"), tgt);
else if (mflags & MS_PROPAGATION)
warnx(_("%s is not mountpoint or bad option"), tgt);
else
warnx(_("wrong fs type, bad option, bad superblock on %s,\n"
" missing codepage or helper program, or other error"),
src);
if (mnt_fs_is_netfs(mnt_context_get_fs(cxt)))
fprintf(stderr, _(
" (for several filesystems (e.g. nfs, cifs) you might\n"
" need a /sbin/mount.<type> helper program)\n"));
fprintf(stderr, _(
" In some cases useful info is found in syslog - try\n"
" dmesg | tail or so\n"));
break;
case EMFILE:
warnx(_("mount table full"));
break;
case EIO:
warnx(_("%s: can't read superblock"), src);
break;
case ENODEV:
warnx(_("unknown filesystem type '%s'"), mnt_context_get_fstype(cxt));
break;
case ENOTBLK:
if (uflags & MNT_MS_NOFAIL)
return MOUNT_EX_SUCCESS;
if (stat(src, &st))
warnx(_("%s is not a block device, and stat(2) fails?"), src);
else if (S_ISBLK(st.st_mode))
warnx(_("the kernel does not recognize %s as a block device\n"
" (maybe `modprobe driver'?)"), src);
else if (S_ISREG(st.st_mode))
warnx(_("%s is not a block device (maybe try `-o loop'?)"), src);
else
warnx(_(" %s is not a block device"), src);
break;
case ENXIO:
if (uflags & MNT_MS_NOFAIL)
return MOUNT_EX_SUCCESS;
warnx(_("%s is not a valid block device"), src);
break;
case EACCES:
case EROFS:
if (mflags & MS_RDONLY)
warnx(_("cannot mount %s read-only"), src);
else if (readwrite)
warnx(_("%s is write-protected but explicit `-w' flag given"), src);
else if (mflags & MS_REMOUNT)
warnx(_("cannot remount %s read-write, is write-protected"), src);
else {
warnx(_("%s is write-protected, mounting read-only"), src);
mnt_context_reset_status(cxt);
mnt_context_set_mflags(cxt, mflags | MS_RDONLY);
rc = mnt_context_do_mount(cxt);
if (!rc)
rc = mnt_context_finalize_mount(cxt);
goto try_readonly;
}
break;
case ENOMEDIUM:
warnx(_("no medium found on %s"), src);
break;
default:
warn(_("mount %s on %s failed"), src, tgt);
break;
}
return MOUNT_EX_FAIL;
}
| 0
|
244,267
|
GF_Err stsz_box_size(GF_Box *s)
{
u32 i, fieldSize, size;
GF_SampleSizeBox *ptr = (GF_SampleSizeBox *)s;
ptr->size += 8;
if (!ptr->sampleCount) return GF_OK;
//regular table
if (ptr->type == GF_ISOM_BOX_TYPE_STSZ) {
if (ptr->sampleSize) return GF_OK;
ptr->size += (4 * ptr->sampleCount);
return GF_OK;
}
if (!ptr->sizes) return GF_ISOM_INVALID_FILE;
//compact size table
fieldSize = 4;
size = ptr->sizes[0];
for (i=0; i < ptr->sampleCount; i++) {
if (ptr->sizes[i] <= 0xF) {
}
//switch to 8-bit table
else if (ptr->sizes[i] <= 0xFF) {
fieldSize = 8;
}
//switch to 16-bit table
else if (ptr->sizes[i] <= 0xFFFF) {
fieldSize = 16;
}
//switch to 32-bit table
else {
fieldSize = 32;
}
//check the size
if (size != ptr->sizes[i]) size = 0;
}
//if all samples are of the same size, switch to regular (more compact)
if (size) {
ptr->type = GF_ISOM_BOX_TYPE_STSZ;
ptr->sampleSize = size;
gf_free(ptr->sizes);
ptr->sizes = NULL;
return GF_OK;
}
if (fieldSize == 32) {
//oops, doesn't fit in a compact table
ptr->type = GF_ISOM_BOX_TYPE_STSZ;
ptr->size += (4 * ptr->sampleCount);
return GF_OK;
}
//make sure we are a compact table (no need to change the mem representation)
ptr->type = GF_ISOM_BOX_TYPE_STZ2;
ptr->sampleSize = fieldSize;
if (fieldSize == 4) {
//do not forget the 0 padding field for odd count
ptr->size += (ptr->sampleCount + 1) / 2;
} else {
ptr->size += (ptr->sampleCount) * (fieldSize/8);
}
return GF_OK;
}
| 0
|
90,833
|
virtual ~UsageAndQuotaDispatcherTask() {
STLDeleteContainerPointers(callbacks_.begin(), callbacks_.end());
STLDeleteContainerPointers(unlimited_callbacks_.begin(),
unlimited_callbacks_.end());
}
| 0
|
382,798
|
static int dynamicSeek (struct gdIOCtx *ctx, const int pos)
{
int bytesNeeded;
dynamicPtr *dp;
dpIOCtx *dctx;
dctx = (dpIOCtx *) ctx;
dp = dctx->dp;
if (!dp->dataGood) {
return FALSE;
}
bytesNeeded = pos;
if (bytesNeeded > dp->realSize) {
/* 2.0.21 */
if (!dp->freeOK) {
return FALSE;
}
gdReallocDynamic (dp, dp->realSize * 2);
}
/* if we get here, we can be sure that we have enough bytes to copy safely */
/* Extend the logical size if we seek beyond EOF. */
if (pos > dp->logicalSize) {
dp->logicalSize = pos;
}
dp->pos = pos;
return TRUE;
}
| 0
|
225,815
|
GF_Err trgt_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_TrackGroupTypeBox *ptr = (GF_TrackGroupTypeBox *)s;
ISOM_DECREASE_SIZE(ptr, 4);
ptr->track_group_id = gf_bs_read_u32(bs);
return GF_OK;
| 0
|
229,291
|
sstring to_string(const event::schema_change::target_type t) {
switch (t) {
case event::schema_change::target_type::KEYSPACE: return "KEYSPACE";
case event::schema_change::target_type::TABLE: return "TABLE";
case event::schema_change::target_type::TYPE: return "TYPE";
case event::schema_change::target_type::FUNCTION: return "FUNCTION";
case event::schema_change::target_type::AGGREGATE:return "AGGREGATE";
}
assert(false && "unreachable");
}
| 0
|
275,942
|
uECC_RNG_Function uECC_get_rng(void) {
return g_rng_function;
}
| 0
|
513,290
|
join_read_next(READ_RECORD *info)
{
int error;
if ((error= info->table->file->ha_index_next(info->record)))
return report_error(info->table, error);
return 0;
}
| 0
|
417,120
|
mp_sint32 PlayerGeneric::getRow() const
{
if (player)
{
mp_uint32 index = player->getBeatIndexFromSamplePos(getCurrentSamplePosition());
return player->getRow(index);
}
return 0;
}
| 0
|
219,926
|
Bool CheckHintFormat(GF_TrackBox *trak, u32 HintType)
{
if (!IsHintTrack(trak)) return GF_FALSE;
if (GetHintFormat(trak) != HintType) return GF_FALSE;
return GF_TRUE;
}
| 0
|
309,941
|
extended_color_content(int color, int *r, int *g, int *b)
{
return NCURSES_SP_NAME(extended_color_content) (CURRENT_SCREEN,
color,
r, g, b);
}
| 0
|
442,779
|
operate(struct Configurable *config, int argc, argv_item_t argv[])
{
char errorbuffer[CURL_ERROR_SIZE];
char useragent[128]; /* buah, we don't want a larger default user agent */
struct ProgressData progressbar;
struct getout *urlnode;
struct getout *nextnode;
struct OutStruct outs;
struct OutStruct heads;
struct InStruct input;
URLGlob *urls=NULL;
URLGlob *inglob=NULL;
int urlnum;
int infilenum;
char *uploadfile=NULL; /* a single file, never a glob */
FILE *infd = stdin;
bool infdfopen;
FILE *headerfilep = NULL;
curl_off_t uploadfilesize; /* -1 means unknown */
bool stillflags=TRUE;
bool allocuseragent=FALSE;
char *httpgetfields=NULL;
CURL *curl;
int res = 0;
int i;
long retry_sleep_default;
long retry_sleep;
char *env;
#ifdef CURLDEBUG
/* this sends all memory debug messages to a logfile named memdump */
env = curlx_getenv("CURL_MEMDEBUG");
if(env) {
/* use the value as file name */
char *s = strdup(env);
curl_free(env);
curl_memdebug(s);
free(s);
/* this weird strdup() and stuff here is to make the curl_free() get
called before the memdebug() as otherwise the memdebug tracing will
with tracing a free() without an alloc! */
}
env = curlx_getenv("CURL_MEMLIMIT");
if(env) {
curl_memlimit(atoi(env));
curl_free(env);
}
#endif
memset(&outs,0,sizeof(outs));
config->outs = &outs;
/* we get libcurl info right away */
curlinfo = curl_version_info(CURLVERSION_NOW);
errorbuffer[0]=0; /* prevent junk from being output */
/* setup proper locale from environment */
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
/* inits */
if (main_init() != CURLE_OK) {
helpf("error initializing curl library\n");
return CURLE_FAILED_INIT;
}
config->postfieldsize = -1;
config->showerror=TRUE;
config->conf=CONF_DEFAULT;
config->use_httpget=FALSE;
config->create_dirs=FALSE;
config->lastrecvtime = cutil_tvnow();
config->lastsendtime = cutil_tvnow();
config->maxredirs = DEFAULT_MAXREDIRS;
if(argc>1 &&
(!curlx_strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
strchr(argv[1], 'q')) {
/*
* The first flag, that is not a verbose name, but a shortname
* and it includes the 'q' flag!
*/
;
}
else {
parseconfig(NULL, config); /* ignore possible failure */
}
if ((argc < 2) && !config->url_list) {
helpf(NULL);
return CURLE_FAILED_INIT;
}
/* Parse options */
for (i = 1; i < argc; i++) {
if(stillflags &&
('-' == argv[i][0])) {
char *nextarg;
bool passarg;
char *origopt=argv[i];
char *flag = argv[i];
if(curlx_strequal("--", argv[i]))
/* this indicates the end of the flags and thus enables the
following (URL) argument to start with -. */
stillflags=FALSE;
else {
nextarg= (i < argc - 1)? argv[i+1]: NULL;
res = getparameter(flag, nextarg, &passarg, config);
if(res) {
const char *reason = param2text(res);
if(res != PARAM_HELP_REQUESTED)
helpf("option %s: %s\n", origopt, reason);
clean_getout(config);
return CURLE_FAILED_INIT;
}
if(passarg) /* we're supposed to skip this */
i++;
}
}
else {
bool used;
/* just add the URL please */
res = getparameter((char *)"--url", argv[i], &used, config);
if(res)
return res;
}
}
retry_sleep_default = config->retry_delay?
config->retry_delay*1000:RETRY_SLEEP_DEFAULT; /* ms */
retry_sleep = retry_sleep_default;
if((!config->url_list || !config->url_list->url) && !config->list_engines) {
clean_getout(config);
helpf("no URL specified!\n");
return CURLE_FAILED_INIT;
}
if(NULL == config->useragent) {
/* set non-zero default values: */
snprintf(useragent, sizeof(useragent),
CURL_NAME "/" CURL_VERSION " (" OS ") " "%s", curl_version());
config->useragent= useragent;
}
else
allocuseragent = TRUE;
/* On WIN32 we can't set the path to curl-ca-bundle.crt
* at compile time. So we look here for the file in two ways:
* 1: look at the environment variable CURL_CA_BUNDLE for a path
* 2: if #1 isn't found, use the windows API function SearchPath()
* to find it along the app's path (includes app's dir and CWD)
*
* We support the environment variable thing for non-Windows platforms
* too. Just for the sake of it.
*/
if (!config->cacert &&
!config->capath &&
!config->insecure_ok) {
env = curlx_getenv("CURL_CA_BUNDLE");
if(env)
GetStr(&config->cacert, env);
else {
env = curlx_getenv("SSL_CERT_DIR");
if(env)
GetStr(&config->capath, env);
else {
env = curlx_getenv("SSL_CERT_FILE");
if(env)
GetStr(&config->cacert, env);
}
}
if(env)
curl_free(env);
#ifdef WIN32
else
FindWin32CACert(config, "curl-ca-bundle.crt");
#endif
}
if (config->postfields) {
if (config->use_httpget) {
/* Use the postfields data for a http get */
httpgetfields = strdup(config->postfields);
free(config->postfields);
config->postfields = NULL;
if(SetHTTPrequest(config,
(config->conf&CONF_NOBODY?HTTPREQ_HEAD:HTTPREQ_GET),
&config->httpreq)) {
free(httpgetfields);
return PARAM_BAD_USE;
}
}
else {
if(SetHTTPrequest(config, HTTPREQ_SIMPLEPOST, &config->httpreq))
return PARAM_BAD_USE;
}
}
/*
* Get a curl handle to use for all forthcoming curl transfers. Cleanup
* when all transfers are done.
*/
curl = curl_easy_init();
if(!curl) {
clean_getout(config);
return CURLE_FAILED_INIT;
}
/* This is the first entry added to easycode and it initializes the slist */
easycode = curl_slist_append(easycode, "CURL *hnd = curl_easy_init();");
if(!easycode) {
clean_getout(config);
res = CURLE_OUT_OF_MEMORY;
goto quit_curl;
}
if (config->list_engines) {
struct curl_slist *engines = NULL;
curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
list_engines(engines);
curl_slist_free_all(engines);
res = CURLE_OK;
goto quit_curl;
}
/* After this point, we should call curl_easy_cleanup() if we decide to bail
* out from this function! */
urlnode = config->url_list;
if(config->headerfile) {
/* open file for output: */
if(strcmp(config->headerfile,"-")) {
heads.filename = config->headerfile;
headerfilep=NULL;
}
else
headerfilep=stdout;
heads.stream = headerfilep;
heads.config = config;
}
/* loop through the list of given URLs */
while(urlnode) {
int up; /* upload file counter within a single upload glob */
char *dourl;
char *url;
char *infiles; /* might be a glob pattern */
char *outfiles=NULL;
/* get the full URL (it might be NULL) */
dourl=urlnode->url;
url = dourl;
if(NULL == url) {
/* This node had no URL, skip it and continue to the next */
if(urlnode->outfile)
free(urlnode->outfile);
/* move on to the next URL */
nextnode=urlnode->next;
free(urlnode); /* free the node */
urlnode = nextnode;
continue; /* next please */
}
/* default output stream is stdout */
outs.stream = stdout;
outs.config = config;
outs.bytes = 0; /* nothing written yet */
/* save outfile pattern before expansion */
if (urlnode->outfile) {
outfiles = strdup(urlnode->outfile);
if (!outfiles) {
clean_getout(config);
break;
}
}
infiles = urlnode->infile;
if(!config->globoff && infiles) {
/* Unless explicitly shut off */
res = glob_url(&inglob, infiles, &infilenum,
config->showerror?
(config->errors?config->errors:stderr):NULL);
if(res != CURLE_OK) {
clean_getout(config);
if(outfiles)
free(outfiles);
break;
}
}
/* Here's the loop for uploading multiple files within the same
single globbed string. If no upload, we enter the loop once anyway. */
for(up = 0;
(!up && !infiles) ||
(uploadfile = inglob?
glob_next_url(inglob):
(!up?strdup(infiles):NULL));
up++) {
int separator = 0;
long retry_numretries;
uploadfilesize=-1;
if(!config->globoff) {
/* Unless explicitly shut off, we expand '{...}' and '[...]'
expressions and return total number of URLs in pattern set */
res = glob_url(&urls, dourl, &urlnum,
config->showerror?
(config->errors?config->errors:stderr):NULL);
if(res != CURLE_OK) {
break;
}
}
else
urlnum = 1; /* without globbing, this is a single URL */
/* if multiple files extracted to stdout, insert separators! */
separator= ((!outfiles || curlx_strequal(outfiles, "-")) && urlnum > 1);
/* Here's looping around each globbed URL */
for(i = 0;
(url = urls?glob_next_url(urls):(i?NULL:strdup(url)));
i++) {
char *outfile;
struct timeval retrystart;
outfile = outfiles?strdup(outfiles):NULL;
if((urlnode->flags&GETOUT_USEREMOTE) ||
(outfile && !curlx_strequal("-", outfile)) ) {
/*
* We have specified a file name to store the result in, or we have
* decided we want to use the remote file name.
*/
if(!outfile) {
/* Find and get the remote file name */
char * pc =strstr(url, "://");
if(pc)
pc+=3;
else
pc=url;
pc = strrchr(pc, '/');
if(pc) {
/* duplicate the string beyond the slash */
pc++;
outfile = *pc ? strdup(pc): NULL;
}
if(!outfile || !*outfile) {
helpf("Remote file name has no length!\n");
res = CURLE_WRITE_ERROR;
free(url);
break;
}
#if defined(MSDOS)
{
/* This is for DOS, and then we do some major replacing of
bad characters in the file name before using it */
char file1 [PATH_MAX];
strcpy(file1, msdosify(outfile));
free (outfile);
outfile = strdup (rename_if_dos_device_name(file1));
}
#endif /* MSDOS */
}
else if(urls) {
/* fill '#1' ... '#9' terms from URL pattern */
char *storefile = outfile;
outfile = glob_match_url(storefile, urls);
free(storefile);
if(!outfile) {
/* bad globbing */
warnf(config, "bad output glob!\n");
free(url);
res = CURLE_FAILED_INIT;
break;
}
}
/* Create the directory hierarchy, if not pre-existant to a multiple
file output call */
if(config->create_dirs &&
(-1 == create_dir_hierarchy(outfile)))
return CURLE_WRITE_ERROR;
if(config->resume_from_current) {
/* We're told to continue from where we are now. Get the
size of the file as it is now and open it for append instead */
struct_stat fileinfo;
/* VMS -- Danger, the filesize is only valid for stream files */
if(0 == stat(outfile, &fileinfo))
/* set offset to current file size: */
config->resume_from = fileinfo.st_size;
else
/* let offset be 0 */
config->resume_from = 0;
}
outs.filename = outfile;
if(config->resume_from) {
outs.init = config->resume_from;
/* open file for output: */
outs.stream=(FILE *) fopen(outfile, config->resume_from?"ab":"wb");
if (!outs.stream) {
helpf("Can't open '%s'!\n", outfile);
return CURLE_WRITE_ERROR;
}
}
else {
outs.stream = NULL; /* open when needed */
}
}
infdfopen=FALSE;
if(uploadfile && !curlx_strequal(uploadfile, "-")) {
/*
* We have specified a file to upload and it isn't "-".
*/
struct_stat fileinfo;
/* If no file name part is given in the URL, we add this file name */
char *ptr=strstr(url, "://");
if(ptr)
ptr+=3;
else
ptr=url;
ptr = strrchr(ptr, '/');
if(!ptr || !strlen(++ptr)) {
/* The URL has no file name part, add the local file name. In order
to be able to do so, we have to create a new URL in another
buffer.*/
/* We only want the part of the local path that is on the right
side of the rightmost slash and backslash. */
char *filep = strrchr(uploadfile, '/');
char *file2 = strrchr(filep?filep:uploadfile, '\\');
if(file2)
filep = file2+1;
else if(filep)
filep++;
else
filep = uploadfile;
/* URL encode the file name */
filep = curl_easy_escape(curl, filep, 0 /* use strlen */);
if(filep) {
char *urlbuffer=(char *)malloc(strlen(url) + strlen(filep) + 3);
if(!urlbuffer) {
helpf("out of memory\n");
return CURLE_OUT_OF_MEMORY;
}
if(ptr)
/* there is a trailing slash on the URL */
sprintf(urlbuffer, "%s%s", url, filep);
else
/* thers is no trailing slash on the URL */
sprintf(urlbuffer, "%s/%s", url, filep);
curl_free(filep);
free(url);
url = urlbuffer; /* use our new URL instead! */
}
}
/* VMS Note:
*
* Reading binary from files can be a problem... Only FIXED, VAR
* etc WITHOUT implied CC will work Others need a \n appended to a
* line
*
* - Stat gives a size but this is UNRELIABLE in VMS As a f.e. a
* fixed file with implied CC needs to have a byte added for every
* record processed, this can by derived from Filesize & recordsize
* for VARiable record files the records need to be counted! for
* every record add 1 for linefeed and subtract 2 for the record
* header for VARIABLE header files only the bare record data needs
* to be considered with one appended if implied CC
*/
infd=(FILE *) fopen(uploadfile, "rb");
if (!infd || stat(uploadfile, &fileinfo)) {
helpf("Can't open '%s'!\n", uploadfile);
if(infd)
fclose(infd);
return CURLE_READ_ERROR;
}
infdfopen=TRUE;
uploadfilesize=fileinfo.st_size;
}
else if(uploadfile && curlx_strequal(uploadfile, "-")) {
SET_BINMODE(stdin);
infd = stdin;
}
if(uploadfile && config->resume_from_current)
config->resume_from = -1; /* -1 will then force get-it-yourself */
if(output_expected(url, uploadfile)
&& outs.stream && isatty(fileno(outs.stream)))
/* we send the output to a tty, therefore we switch off the progress
meter */
config->conf |= CONF_NOPROGRESS|CONF_ISATTY;
if (urlnum > 1 && !(config->conf&CONF_MUTE)) {
fprintf(stderr, "\n[%d/%d]: %s --> %s\n",
i+1, urlnum, url, outfile ? outfile : "<stdout>");
if (separator)
printf("%s%s\n", CURLseparator, url);
}
if (httpgetfields) {
char *urlbuffer;
/* Find out whether the url contains a file name */
const char *pc =strstr(url, "://");
char sep='?';
if(pc)
pc+=3;
else
pc=url;
pc = strrchr(pc, '/'); /* check for a slash */
if(pc) {
/* there is a slash present in the URL */
if(strchr(pc, '?'))
/* Ouch, there's already a question mark in the URL string, we
then append the data with an ampersand separator instead! */
sep='&';
}
/*
* Then append ? followed by the get fields to the url.
*/
urlbuffer=(char *)malloc(strlen(url) + strlen(httpgetfields) + 3);
if(!urlbuffer) {
helpf("out of memory\n");
return CURLE_OUT_OF_MEMORY;
}
if (pc)
sprintf(urlbuffer, "%s%c%s", url, sep, httpgetfields);
else
/* Append / before the ? to create a well-formed url
if the url contains a hostname only
*/
sprintf(urlbuffer, "%s/?%s", url, httpgetfields);
free(url); /* free previous URL */
url = urlbuffer; /* use our new URL instead! */
}
if(!config->errors)
config->errors = stderr;
if(!outfile && !(config->conf & CONF_GETTEXT)) {
/* We get the output to stdout and we have not got the ASCII/text flag,
then set stdout to be binary */
SET_BINMODE(stdout);
}
if(1 == config->tcp_nodelay)
my_setopt(curl, CURLOPT_TCP_NODELAY, 1);
/* where to store */
my_setopt(curl, CURLOPT_WRITEDATA, (FILE *)&outs);
/* what call to write */
my_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
/* for uploads */
input.stream = infd;
input.config = config;
my_setopt(curl, CURLOPT_READDATA, &input);
/* what call to read */
my_setopt(curl, CURLOPT_READFUNCTION, my_fread);
/* libcurl 7.12.3 business: */
my_setopt(curl, CURLOPT_IOCTLDATA, &input);
my_setopt(curl, CURLOPT_IOCTLFUNCTION, my_ioctl);
if(config->recvpersecond)
/* tell libcurl to use a smaller sized buffer as it allows us to
make better sleeps! 7.9.9 stuff! */
my_setopt(curl, CURLOPT_BUFFERSIZE, config->recvpersecond);
/* size of uploaded file: */
my_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadfilesize);
my_setopt(curl, CURLOPT_URL, url); /* what to fetch */
my_setopt(curl, CURLOPT_PROXY, config->proxy); /* proxy to use */
my_setopt(curl, CURLOPT_HEADER, config->conf&CONF_HEADER);
my_setopt(curl, CURLOPT_NOPROGRESS, config->conf&CONF_NOPROGRESS);
my_setopt(curl, CURLOPT_NOBODY, config->conf&CONF_NOBODY);
my_setopt(curl, CURLOPT_FAILONERROR,
config->conf&CONF_FAILONERROR);
my_setopt(curl, CURLOPT_UPLOAD, uploadfile?TRUE:FALSE);
my_setopt(curl, CURLOPT_FTPLISTONLY,
config->conf&CONF_FTPLISTONLY);
my_setopt(curl, CURLOPT_FTPAPPEND, config->conf&CONF_FTPAPPEND);
if (config->conf&CONF_NETRC_OPT)
my_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
else if (config->conf&CONF_NETRC)
my_setopt(curl, CURLOPT_NETRC, CURL_NETRC_REQUIRED);
else
my_setopt(curl, CURLOPT_NETRC, CURL_NETRC_IGNORED);
my_setopt(curl, CURLOPT_FOLLOWLOCATION,
config->conf&CONF_FOLLOWLOCATION);
my_setopt(curl, CURLOPT_UNRESTRICTED_AUTH,
config->conf&CONF_UNRESTRICTED_AUTH);
my_setopt(curl, CURLOPT_TRANSFERTEXT, config->conf&CONF_GETTEXT);
my_setopt(curl, CURLOPT_USERPWD, config->userpwd);
my_setopt(curl, CURLOPT_PROXYUSERPWD, config->proxyuserpwd);
my_setopt(curl, CURLOPT_RANGE, config->range);
my_setopt(curl, CURLOPT_ERRORBUFFER, errorbuffer);
my_setopt(curl, CURLOPT_TIMEOUT, config->timeout);
switch(config->httpreq) {
case HTTPREQ_SIMPLEPOST:
my_setopt(curl, CURLOPT_POSTFIELDS, config->postfields);
my_setopt(curl, CURLOPT_POSTFIELDSIZE, config->postfieldsize);
break;
case HTTPREQ_POST:
my_setopt(curl, CURLOPT_HTTPPOST, config->httppost);
break;
default:
break;
}
my_setopt(curl, CURLOPT_REFERER, config->referer);
my_setopt(curl, CURLOPT_AUTOREFERER,
config->conf&CONF_AUTO_REFERER);
my_setopt(curl, CURLOPT_USERAGENT, config->useragent);
my_setopt(curl, CURLOPT_FTPPORT, config->ftpport);
my_setopt(curl, CURLOPT_LOW_SPEED_LIMIT,
config->low_speed_limit);
my_setopt(curl, CURLOPT_LOW_SPEED_TIME, config->low_speed_time);
my_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE,
config->sendpersecond);
my_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE,
config->recvpersecond);
my_setopt(curl, CURLOPT_RESUME_FROM_LARGE,
config->use_resume?config->resume_from:0);
my_setopt(curl, CURLOPT_COOKIE, config->cookie);
my_setopt(curl, CURLOPT_HTTPHEADER, config->headers);
my_setopt(curl, CURLOPT_SSLCERT, config->cert);
my_setopt(curl, CURLOPT_SSLCERTTYPE, config->cert_type);
my_setopt(curl, CURLOPT_SSLKEY, config->key);
my_setopt(curl, CURLOPT_SSLKEYTYPE, config->key_type);
my_setopt(curl, CURLOPT_SSLKEYPASSWD, config->key_passwd);
/* SSH private key uses the same command-line option as SSL private key */
my_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, config->key);
my_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, config->pubkey);
/* default to strict verifyhost */
my_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);
if(config->cacert || config->capath) {
if (config->cacert)
my_setopt(curl, CURLOPT_CAINFO, config->cacert);
if (config->capath)
my_setopt(curl, CURLOPT_CAPATH, config->capath);
my_setopt(curl, CURLOPT_SSL_VERIFYPEER, TRUE);
}
if(config->insecure_ok) {
/* new stuff needed for libcurl 7.10 */
my_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
my_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1);
}
if((config->conf&CONF_NOBODY) ||
config->remote_time) {
/* no body or use remote time */
my_setopt(curl, CURLOPT_FILETIME, TRUE);
}
my_setopt(curl, CURLOPT_MAXREDIRS, config->maxredirs);
my_setopt(curl, CURLOPT_CRLF, config->crlf);
my_setopt(curl, CURLOPT_QUOTE, config->quote);
my_setopt(curl, CURLOPT_POSTQUOTE, config->postquote);
my_setopt(curl, CURLOPT_PREQUOTE, config->prequote);
my_setopt(curl, CURLOPT_WRITEHEADER,
config->headerfile?&heads:NULL);
my_setopt(curl, CURLOPT_COOKIEFILE, config->cookiefile);
/* cookie jar was added in 7.9 */
if(config->cookiejar)
my_setopt(curl, CURLOPT_COOKIEJAR, config->cookiejar);
/* cookie session added in 7.9.7 */
my_setopt(curl, CURLOPT_COOKIESESSION, config->cookiesession);
my_setopt(curl, CURLOPT_SSLVERSION, config->ssl_version);
my_setopt(curl, CURLOPT_TIMECONDITION, config->timecond);
my_setopt(curl, CURLOPT_TIMEVALUE, config->condtime);
my_setopt(curl, CURLOPT_CUSTOMREQUEST, config->customrequest);
my_setopt(curl, CURLOPT_STDERR, config->errors);
/* three new ones in libcurl 7.3: */
my_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config->proxytunnel);
my_setopt(curl, CURLOPT_INTERFACE, config->iface);
my_setopt(curl, CURLOPT_KRB4LEVEL, config->krb4level);
progressbarinit(&progressbar, config);
if((config->progressmode == CURL_PROGRESS_BAR) &&
!(config->conf&(CONF_NOPROGRESS|CONF_MUTE))) {
/* we want the alternative style, then we have to implement it
ourselves! */
my_setopt(curl, CURLOPT_PROGRESSFUNCTION, myprogress);
my_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);
}
/* new in libcurl 7.6.2: */
my_setopt(curl, CURLOPT_TELNETOPTIONS, config->telnet_options);
/* new in libcurl 7.7: */
my_setopt(curl, CURLOPT_RANDOM_FILE, config->random_file);
my_setopt(curl, CURLOPT_EGDSOCKET, config->egd_file);
my_setopt(curl, CURLOPT_CONNECTTIMEOUT, config->connecttimeout);
if(config->cipher_list)
my_setopt(curl, CURLOPT_SSL_CIPHER_LIST, config->cipher_list);
if(config->httpversion)
my_setopt(curl, CURLOPT_HTTP_VERSION, config->httpversion);
/* new in libcurl 7.9.2: */
if(config->disable_epsv)
/* disable it */
my_setopt(curl, CURLOPT_FTP_USE_EPSV, FALSE);
/* new in libcurl 7.10.5 */
if(config->disable_eprt)
/* disable it */
my_setopt(curl, CURLOPT_FTP_USE_EPRT, FALSE);
/* new in libcurl 7.10.6 (default is Basic) */
if(config->authtype)
my_setopt(curl, CURLOPT_HTTPAUTH, config->authtype);
/* new in curl 7.9.7 */
if(config->trace_dump) {
my_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
my_setopt(curl, CURLOPT_DEBUGDATA, config);
my_setopt(curl, CURLOPT_VERBOSE, TRUE);
}
res = CURLE_OK;
/* new in curl ?? */
if (config->engine) {
res = my_setopt(curl, CURLOPT_SSLENGINE, config->engine);
my_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1);
}
if (res != CURLE_OK)
goto show_error;
/* new in curl 7.10 */
my_setopt(curl, CURLOPT_ENCODING,
(config->encoding) ? "" : NULL);
/* new in curl 7.10.7 */
my_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS,
config->ftp_create_dirs);
if(config->proxyanyauth)
my_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
else if(config->proxyntlm)
my_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
else if(config->proxydigest)
my_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
else if(config->proxybasic)
my_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
/* new in curl 7.10.8 */
if(config->max_filesize)
my_setopt(curl, CURLOPT_MAXFILESIZE_LARGE,
config->max_filesize);
if(4 == config->ip_version)
my_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
else if(6 == config->ip_version)
my_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
else
my_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
/* new in curl 7.15.5 */
if(config->ftp_ssl_reqd)
my_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_ALL);
/* new in curl 7.11.0 */
else if(config->ftp_ssl)
my_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_TRY);
/* new in curl 7.16.0 */
else if(config->ftp_ssl_control)
my_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_CONTROL);
/* new in curl 7.16.1 */
if(config->ftp_ssl_ccc)
my_setopt(curl, CURLOPT_FTP_SSL_CCC, config->ftp_ssl_ccc_mode);
/* new in curl 7.11.1, modified in 7.15.2 */
if(config->socksproxy) {
my_setopt(curl, CURLOPT_PROXY, config->socksproxy);
my_setopt(curl, CURLOPT_PROXYTYPE, config->socksver);
}
/* curl 7.13.0 */
my_setopt(curl, CURLOPT_FTP_ACCOUNT, config->ftp_account);
my_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, config->ignorecl);
/* curl 7.14.2 */
my_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, config->ftp_skip_ip);
/* curl 7.15.1 */
my_setopt(curl, CURLOPT_FTP_FILEMETHOD, config->ftp_filemethod);
/* curl 7.15.2 */
if(config->localport) {
my_setopt(curl, CURLOPT_LOCALPORT, config->localport);
my_setopt(curl, CURLOPT_LOCALPORTRANGE,
config->localportrange);
}
/* curl 7.15.5 */
my_setopt(curl, CURLOPT_FTP_ALTERNATIVE_TO_USER,
config->ftp_alternative_to_user);
/* curl 7.16.0 */
my_setopt(curl, CURLOPT_SSL_SESSIONID_CACHE,
!config->disable_sessionid);
/* curl 7.16.2 */
if(config->raw) {
my_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, FALSE);
my_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, FALSE);
}
retry_numretries = config->req_retry;
retrystart = cutil_tvnow();
do {
res = curl_easy_perform(curl);
if (!curl_slist_append(easycode, "ret = curl_easy_perform(hnd);")) {
res = CURLE_OUT_OF_MEMORY;
break;
}
/* if retry-max-time is non-zero, make sure we haven't exceeded the
time */
if(retry_numretries &&
(!config->retry_maxtime ||
(cutil_tvdiff(cutil_tvnow(), retrystart)<
config->retry_maxtime*1000)) ) {
enum {
RETRY_NO,
RETRY_TIMEOUT,
RETRY_HTTP,
RETRY_FTP,
RETRY_LAST /* not used */
} retry = RETRY_NO;
long response;
if(CURLE_OPERATION_TIMEDOUT == res)
/* retry timeout always */
retry = RETRY_TIMEOUT;
else if(CURLE_OK == res) {
/* Check for HTTP transient errors */
char *this_url=NULL;
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &this_url);
if(this_url &&
curlx_strnequal(this_url, "http", 4)) {
/* This was HTTP(S) */
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
switch(response) {
case 500: /* Internal Server Error */
case 502: /* Bad Gateway */
case 503: /* Service Unavailable */
case 504: /* Gateway Timeout */
retry = RETRY_HTTP;
/*
* At this point, we have already written data to the output
* file (or terminal). If we write to a file, we must rewind
* or close/re-open the file so that the next attempt starts
* over from the beginning.
*
* TODO: similar action for the upload case. We might need
* to start over reading from a previous point if we have
* uploaded something when this was returned.
*/
break;
}
}
} /* if CURLE_OK */
else if(CURLE_LOGIN_DENIED == res) {
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
if(response/100 == 5)
/*
* This is typically when the FTP server only allows a certain
* amount of users and we are not one of them. It mostly
* returns 530 in this case, but all 5xx codes are transient.
*/
retry = RETRY_FTP;
}
if(retry) {
static const char * const m[]={NULL,
"timeout",
"HTTP error",
"FTP error"
};
warnf(config, "Transient problem: %s "
"Will retry in %ld seconds. "
"%ld retries left.\n",
m[retry],
retry_sleep/1000,
retry_numretries);
go_sleep(retry_sleep);
retry_numretries--;
if(!config->retry_delay) {
retry_sleep *= 2;
if(retry_sleep > RETRY_SLEEP_MAX)
retry_sleep = RETRY_SLEEP_MAX;
}
if(outs.bytes && outs.filename) {
/* We have written data to a output file, we truncate file
*/
if(!(config->conf&CONF_MUTE))
fprintf(stderr, "Throwing away %Od bytes\n", outs.bytes);
fflush(outs.stream);
/* truncate file at the position where we started appending */
#ifdef HAVE_FTRUNCATE
ftruncate( fileno(outs.stream), outs.init);
/* now seek to the end of the file, the position where we
just truncated the file in a large file-safe way */
fseek(outs.stream, 0, SEEK_END);
#else
/* ftruncate is not available, so just reposition the file
to the location we would have truncated it. This won't
work properly with large files on 32-bit systems, but
most of those will have ftruncate. */
fseek(outs.stream, (long)outs.init, SEEK_SET);
#endif
outs.bytes = 0; /* clear for next round */
}
continue;
}
} /* if retry_numretries */
/* In all ordinary cases, just break out of loop here */
retry_sleep = retry_sleep_default;
break;
} while(1);
if((config->progressmode == CURL_PROGRESS_BAR) &&
progressbar.calls) {
/* if the custom progress bar has been displayed, we output a
newline here */
fputs("\n", progressbar.out);
}
if(config->writeout) {
ourWriteOut(curl, config->writeout);
}
#ifdef USE_ENVIRONMENT
if (config->writeenv)
ourWriteEnv(curl);
#endif
show_error:
#ifdef VMS
if (!config->showerror) {
vms_show = VMSSTS_HIDE;
}
#else
if((res!=CURLE_OK) && config->showerror) {
fprintf(config->errors, "curl: (%d) %s\n", (int)res,
errorbuffer[0]? errorbuffer:
curl_easy_strerror((CURLcode)res));
if(CURLE_SSL_CACERT == res) {
#define CURL_CA_CERT_ERRORMSG1 \
"More details here: http://curl.haxx.se/docs/sslcerts.html\n\n" \
"curl performs SSL certificate verification by default, using a \"bundle\"\n" \
" of Certificate Authority (CA) public keys (CA certs). The default\n" \
" bundle is named curl-ca-bundle.crt; you can specify an alternate file\n" \
" using the --cacert option.\n"
#define CURL_CA_CERT_ERRORMSG2 \
"If this HTTPS server uses a certificate signed by a CA represented in\n" \
" the bundle, the certificate verification probably failed due to a\n" \
" problem with the certificate (it might be expired, or the name might\n" \
" not match the domain name in the URL).\n" \
"If you'd like to turn off curl's verification of the certificate, use\n" \
" the -k (or --insecure) option.\n"
fprintf(config->errors, "%s%s",
CURL_CA_CERT_ERRORMSG1,
CURL_CA_CERT_ERRORMSG2 );
}
}
#endif
if (outfile && !curlx_strequal(outfile, "-") && outs.stream)
fclose(outs.stream);
#ifdef HAVE_UTIME
/* Important that we set the time _after_ the file has been
closed, as is done above here */
if(config->remote_time && outs.filename) {
/* ask libcurl if we got a time. Pretty please */
long filetime;
curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
if(filetime >= 0) {
struct utimbuf times;
times.actime = (time_t)filetime;
times.modtime = (time_t)filetime;
utime(outs.filename, ×); /* set the time we got */
}
}
#endif
#ifdef __AMIGA__
/* Set the url as comment for the file. (up to 80 chars are allowed)
*/
if( strlen(url) > 78 )
url[79] = '\0';
SetComment( outs.filename, url);
#endif
if(headerfilep)
fclose(headerfilep);
if(url)
free(url);
if(outfile)
free(outfile);
if(infdfopen)
fclose(infd);
} /* loop to the next URL */
if(urls)
/* cleanup memory used for URL globbing patterns */
glob_cleanup(urls);
if(uploadfile)
free(uploadfile);
} /* loop to the next globbed upload file */
if(inglob) {
glob_cleanup(inglob);
inglob = NULL;
}
if(outfiles)
free(outfiles);
/* empty this urlnode struct */
if(urlnode->url)
free(urlnode->url);
if(urlnode->outfile)
free(urlnode->outfile);
if(urlnode->infile)
free(urlnode->infile);
/* move on to the next URL */
nextnode=urlnode->next;
free(urlnode); /* free the node */
urlnode = nextnode;
} /* while-loop through all URLs */
quit_curl:
if (httpgetfields)
free(httpgetfields);
if (config->engine)
free(config->engine);
/* cleanup the curl handle! */
curl_easy_cleanup(curl);
if (easycode)
curl_slist_append(easycode, "curl_easy_cleanup(hnd);");
if(config->headerfile && !headerfilep && heads.stream)
fclose(heads.stream);
if(allocuseragent)
free(config->useragent);
if(config->trace_fopened && config->trace_stream)
fclose(config->trace_stream);
if(config->errors_fopened)
fclose(config->errors);
main_free(); /* cleanup */
dumpeasycode(config);
return res;
}
| 0
|
242,981
|
static size_t ssl_compute_padding_length( size_t len,
size_t granularity )
{
return( ( granularity - ( len + 1 ) % granularity ) % granularity );
}
| 0
|
221,390
|
int nested_svm_exit_handled(struct vcpu_svm *svm)
{
int vmexit;
vmexit = nested_svm_intercept(svm);
if (vmexit == NESTED_EXIT_DONE)
nested_svm_vmexit(svm);
return vmexit;
}
| 0
|
459,025
|
http_EstimateWS(const struct http *fm, unsigned how)
{
unsigned u, l;
l = 4;
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
for (u = 0; u < fm->nhd; u++) {
if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL)
continue;
Tcheck(fm->hd[u]);
if (http_isfiltered(fm, u, how))
continue;
l += Tlen(fm->hd[u]) + 1L;
}
return (PRNDUP(l + 1L));
}
| 0
|
258,079
|
void Compute(OpKernelContext* context) override {
const Tensor& input = context->input(0);
const Tensor& sparse_dims = context->input(1);
if (TensorShapeUtils::IsScalar(input.shape()) || input.NumElements() == 0) {
context->set_output(0, input);
} else {
const int input_dims = input.dims();
const TensorShape& sparse_dims_shape = sparse_dims.shape();
const auto& axes_sparse_flat = sparse_dims.flat<Tidx>();
OP_REQUIRES(context, TensorShapeUtils::IsVector(sparse_dims_shape),
errors::InvalidArgument("'dims' must be 1-dimension, not ",
sparse_dims.dims()));
gtl::InlinedVector<bool, 8> axes_dense(input_dims, false);
for (int dummy = 0; dummy < axes_sparse_flat.size(); dummy++) {
Tidx axis = internal::SubtleMustCopy<Tidx>(axes_sparse_flat(dummy));
Tidx canonical_axis = axis < 0 ? input_dims + axis : axis;
OP_REQUIRES(context, canonical_axis >= 0 && canonical_axis < input_dims,
errors::InvalidArgument("'axis'[", dummy, "] = ", axis,
" is out of valid range [", 0, ", ",
input_dims - 1));
OP_REQUIRES(context, !axes_dense[canonical_axis],
errors::InvalidArgument("axis ", canonical_axis,
" specified more than once."));
axes_dense[canonical_axis] = true;
}
OP_REQUIRES(context, input_dims <= 8,
errors::Unimplemented(
"reverse is not implemented for tensors of rank > 8."));
Tensor* output = nullptr;
OP_REQUIRES_OK(context,
context->allocate_output(0, input.shape(), &output));
// TODO(cwhipkey): we can do dimension folding to reduce, e.g., a reverse
// of a single dimension to the dims=3 or dims=2 case, regardless of the
// number of dimensions in the tensor. This would let some ops use faster
// lower-dimension code (and use optimized versions).
#define HANDLE_REVERSE(NDIMS) \
case NDIMS: \
HandleReverseV2Case<Device, T, NDIMS>(context, axes_dense, output); \
return;
switch (input_dims) {
HANDLE_REVERSE(0);
HANDLE_REVERSE(1);
HANDLE_REVERSE(2);
HANDLE_REVERSE(3);
HANDLE_REVERSE(4);
HANDLE_REVERSE(5);
HANDLE_REVERSE(6);
HANDLE_REVERSE(7);
HANDLE_REVERSE(8);
}
#undef HANDLE_REVERSE
}
}
| 0
|
197,395
|
void Compute(OpKernelContext* context) override {
const Tensor& input = context->input(0);
const Tensor& dims = context->input(1);
if (TensorShapeUtils::IsScalar(input.shape())) {
context->set_output(0, input);
} else {
const int input_dims = input.dims();
OP_REQUIRES(context, TensorShapeUtils::IsVector(dims.shape()),
errors::InvalidArgument("'dims' must be 1-dimension, not ",
dims.dims()));
OP_REQUIRES(
context, input_dims == dims.dim_size(0),
errors::InvalidArgument(
"'dims' must have the same number of values as 'input' has "
"dimensions. 'input' has ",
input_dims, "'dims' has ", dims.dim_size(0), " values"));
OP_REQUIRES(context, input_dims <= 8,
errors::Unimplemented(
"reverse is not implemented for tensors of rank > 8."));
Tensor* output = nullptr;
OP_REQUIRES_OK(context,
context->allocate_output(0, input.shape(), &output));
#define HANDLE_REVERSE(NDIMS) \
case NDIMS: \
HandleReverseCase<Device, T, NDIMS>(context, dims.vec<bool>(), output); \
return;
switch (input_dims) {
HANDLE_REVERSE(0);
HANDLE_REVERSE(1);
HANDLE_REVERSE(2);
HANDLE_REVERSE(3);
HANDLE_REVERSE(4);
HANDLE_REVERSE(5);
HANDLE_REVERSE(6);
HANDLE_REVERSE(7);
HANDLE_REVERSE(8);
}
#undef HANDLE_REVERSE
}
}
| 1
|
229,234
|
void cql_server::response::compress_snappy()
{
using namespace compression_buffers;
auto view = input_buffer.get_linearized_view(_body);
const char* input = reinterpret_cast<const char*>(view.data());
size_t input_len = view.size();
size_t output_len = snappy_max_compressed_length(input_len);
_body = output_buffer.make_buffer(output_len, [&] (bytes_mutable_view output_view) {
char* output = reinterpret_cast<char*>(output_view.data());
if (snappy_compress(input, input_len, output, &output_len) != SNAPPY_OK) {
throw std::runtime_error("CQL frame Snappy compression failure");
}
return output_len;
});
on_compression_buffer_use();
}
| 0
|
445,920
|
pref_list_mode_changed (GSettings *settings,
const char *key,
gpointer user_data)
{
FrWindow *window = user_data;
fr_window_set_list_mode (window, g_settings_get_enum (settings, key));
}
| 0
|
230,306
|
njs_array_indices(njs_vm_t *vm, njs_value_t *object)
{
double idx;
uint32_t i;
njs_array_t *keys;
keys = njs_array_keys(vm, object, 1);
if (njs_slow_path(keys == NULL)) {
return NULL;
}
for (i = 0; i < keys->length; i++) {
idx = njs_string_to_index(&keys->start[i]);
if (isnan(idx)) {
keys->length = i;
break;
}
}
return keys;
}
| 0
|
430,429
|
static void ovs_nla_free_check_pkt_len_action(const struct nlattr *action)
{
const struct nlattr *a;
int rem;
nla_for_each_nested(a, action, rem) {
switch (nla_type(a)) {
case OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL:
case OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER:
ovs_nla_free_nested_actions(nla_data(a), nla_len(a));
break;
}
}
}
| 0
|
237,821
|
static char const *acurite_getChannelAndType(uint8_t byte, uint8_t mtype)
{
static char const *channel_strs[] = {"CR", "ER", "BR", "AR", "CF", "EF", "BF", "AF"}; // 'E' stands for error
int channel = ((mtype & 0x01) << 2) | ((byte & 0xC0) >> 6);
return channel_strs[channel];
}
| 0
|
412,336
|
static RzBinInfo *info(RzBinFile *bf) {
rz_return_val_if_fail(bf && bf->o && bf->o->bin_obj, NULL);
RzBinInfo *ret = RZ_NEW0(RzBinInfo);
if (!ret) {
return NULL;
}
ret->file = bf->file ? strdup(bf->file) : NULL;
ret->type = strdup("QNX Executable");
ret->bclass = strdup("qnx");
ret->machine = strdup("i386");
ret->rclass = strdup("QNX");
ret->arch = strdup("x86");
ret->os = strdup("any");
ret->subsystem = strdup("any");
ret->lang = "C/C++";
ret->signature = true;
return ret;
}
| 0
|
214,358
|
int qtm_decompress(struct qtm_stream *qtm, off_t out_bytes) {
unsigned int frame_start, frame_end, window_posn, match_offset, range;
unsigned char *window, *i_ptr, *i_end, *runsrc, *rundest;
int i, j, selector, extra, sym, match_length, ret;
unsigned short H, L, C, symf;
register unsigned int bit_buffer;
register unsigned char bits_left;
unsigned char bits_needed, bit_run;
/* easy answers */
if (!qtm || (out_bytes < 0)) return CL_ENULLARG;
if (qtm->error) return qtm->error;
/* flush out any stored-up bytes before we begin */
i = qtm->o_end - qtm->o_ptr;
if ((off_t) i > out_bytes) i = (int) out_bytes;
if (i) {
if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {
return qtm->error = ret;
}
qtm->o_ptr += i;
out_bytes -= i;
}
if (out_bytes == 0) return CL_SUCCESS;
/* restore local state */
QTM_RESTORE_BITS;
window = qtm->window;
window_posn = qtm->window_posn;
frame_start = qtm->frame_start;
H = qtm->H;
L = qtm->L;
C = qtm->C;
/* while we do not have enough decoded bytes in reserve: */
while ((qtm->o_end - qtm->o_ptr) < out_bytes) {
/* read header if necessary. Initialises H, L and C */
if (!qtm->header_read) {
H = 0xFFFF; L = 0; QTM_READ_BITS(C, 16);
qtm->header_read = 1;
}
/* decode more, at most up to to frame boundary */
frame_end = window_posn + (out_bytes - (qtm->o_end - qtm->o_ptr));
if ((frame_start + QTM_FRAME_SIZE) < frame_end) {
frame_end = frame_start + QTM_FRAME_SIZE;
}
while (window_posn < frame_end) {
QTM_GET_SYMBOL(qtm->model7, selector);
if (selector < 4) {
struct qtm_model *mdl = (selector == 0) ? &qtm->model0 :
((selector == 1) ? &qtm->model1 :
((selector == 2) ? &qtm->model2 :
&qtm->model3));
QTM_GET_SYMBOL((*mdl), sym);
window[window_posn++] = sym;
}
else {
switch (selector) {
case 4: /* selector 4 = fixed length match (3 bytes) */
QTM_GET_SYMBOL(qtm->model4, sym);
QTM_READ_BITS(extra, qtm->extra_bits[sym]);
match_offset = qtm->position_base[sym] + extra + 1;
match_length = 3;
break;
case 5: /* selector 5 = fixed length match (4 bytes) */
QTM_GET_SYMBOL(qtm->model5, sym);
QTM_READ_BITS(extra, qtm->extra_bits[sym]);
match_offset = qtm->position_base[sym] + extra + 1;
match_length = 4;
break;
case 6: /* selector 6 = variable length match */
QTM_GET_SYMBOL(qtm->model6len, sym);
QTM_READ_BITS(extra, qtm->length_extra[sym]);
match_length = qtm->length_base[sym] + extra + 5;
QTM_GET_SYMBOL(qtm->model6, sym);
QTM_READ_BITS(extra, qtm->extra_bits[sym]);
match_offset = qtm->position_base[sym] + extra + 1;
break;
default:
/* should be impossible, model7 can only return 0-6 */
return qtm->error = CL_EFORMAT;
}
rundest = &window[window_posn];
i = match_length;
/* does match offset wrap the window? */
if (match_offset > window_posn) {
/* j = length from match offset to end of window */
j = match_offset - window_posn;
if (j > (int) qtm->window_size) {
cli_dbgmsg("qtm_decompress: match offset beyond window boundaries\n");
return qtm->error = CL_EFORMAT;
}
runsrc = &window[qtm->window_size - j];
if (j < i) {
/* if match goes over the window edge, do two copy runs */
i -= j; while (j-- > 0) *rundest++ = *runsrc++;
runsrc = window;
}
while (i-- > 0) *rundest++ = *runsrc++;
}
else {
runsrc = rundest - match_offset;
if(i > (int) (qtm->window_size - window_posn))
i = qtm->window_size - window_posn;
while (i-- > 0) *rundest++ = *runsrc++;
}
window_posn += match_length;
}
} /* while (window_posn < frame_end) */
qtm->o_end = &window[window_posn];
/* another frame completed? */
if ((window_posn - frame_start) >= QTM_FRAME_SIZE) {
if ((window_posn - frame_start) != QTM_FRAME_SIZE) {
cli_dbgmsg("qtm_decompress: overshot frame alignment\n");
return qtm->error = CL_EFORMAT;
}
/* re-align input */
if (bits_left & 7) QTM_REMOVE_BITS(bits_left & 7);
do { QTM_READ_BITS(i, 8); } while (i != 0xFF);
qtm->header_read = 0;
/* window wrap? */
if (window_posn == qtm->window_size) {
/* flush all currently stored data */
i = (qtm->o_end - qtm->o_ptr);
if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {
return qtm->error = ret;
}
out_bytes -= i;
qtm->o_ptr = &window[0];
qtm->o_end = &window[0];
window_posn = 0;
}
frame_start = window_posn;
}
} /* while (more bytes needed) */
if (out_bytes) {
i = (int) out_bytes;
if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {
return qtm->error = ret;
}
qtm->o_ptr += i;
}
/* store local state */
QTM_STORE_BITS;
qtm->window_posn = window_posn;
qtm->frame_start = frame_start;
qtm->H = H;
qtm->L = L;
qtm->C = C;
return CL_SUCCESS;
}
| 1
|
90,166
|
static NetworkTechnology ParseNetworkTechnology(
const std::string& technology) {
if (technology == kNetworkTechnology1Xrtt)
return NETWORK_TECHNOLOGY_1XRTT;
if (technology == kNetworkTechnologyEvdo)
return NETWORK_TECHNOLOGY_EVDO;
if (technology == kNetworkTechnologyGprs)
return NETWORK_TECHNOLOGY_GPRS;
if (technology == kNetworkTechnologyEdge)
return NETWORK_TECHNOLOGY_EDGE;
if (technology == kNetworkTechnologyUmts)
return NETWORK_TECHNOLOGY_UMTS;
if (technology == kNetworkTechnologyHspa)
return NETWORK_TECHNOLOGY_HSPA;
if (technology == kNetworkTechnologyHspaPlus)
return NETWORK_TECHNOLOGY_HSPA_PLUS;
if (technology == kNetworkTechnologyLte)
return NETWORK_TECHNOLOGY_LTE;
if (technology == kNetworkTechnologyLteAdvanced)
return NETWORK_TECHNOLOGY_LTE_ADVANCED;
return NETWORK_TECHNOLOGY_UNKNOWN;
}
| 0
|
512,464
|
Item_basic_constant(THD *thd): Item_basic_value(thd) {};
| 0
|
489,145
|
static void *sctp_addto_param(struct sctp_chunk *chunk, int len,
const void *data)
{
void *target;
int chunklen = ntohs(chunk->chunk_hdr->length);
target = skb_put(chunk->skb, len);
memcpy(target, data, len);
/* Adjust the chunk length field. */
chunk->chunk_hdr->length = htons(chunklen + len);
chunk->chunk_end = skb_tail_pointer(chunk->skb);
return target;
}
| 0
|
233,866
|
static void fourcc_clear(struct de_fourcc *fourcc)
{
de_zeromem(fourcc, sizeof(struct de_fourcc));
}
| 0
|
427,798
|
int svm_mem_enc_op(struct kvm *kvm, void __user *argp)
{
struct kvm_sev_cmd sev_cmd;
int r;
if (!sev_enabled)
return -ENOTTY;
if (!argp)
return 0;
if (copy_from_user(&sev_cmd, argp, sizeof(struct kvm_sev_cmd)))
return -EFAULT;
mutex_lock(&kvm->lock);
/* Only the enc_context_owner handles some memory enc operations. */
if (is_mirroring_enc_context(kvm) &&
!cmd_allowed_from_miror(sev_cmd.id)) {
r = -EINVAL;
goto out;
}
switch (sev_cmd.id) {
case KVM_SEV_ES_INIT:
if (!sev_es_enabled) {
r = -ENOTTY;
goto out;
}
fallthrough;
case KVM_SEV_INIT:
r = sev_guest_init(kvm, &sev_cmd);
break;
case KVM_SEV_LAUNCH_START:
r = sev_launch_start(kvm, &sev_cmd);
break;
case KVM_SEV_LAUNCH_UPDATE_DATA:
r = sev_launch_update_data(kvm, &sev_cmd);
break;
case KVM_SEV_LAUNCH_UPDATE_VMSA:
r = sev_launch_update_vmsa(kvm, &sev_cmd);
break;
case KVM_SEV_LAUNCH_MEASURE:
r = sev_launch_measure(kvm, &sev_cmd);
break;
case KVM_SEV_LAUNCH_FINISH:
r = sev_launch_finish(kvm, &sev_cmd);
break;
case KVM_SEV_GUEST_STATUS:
r = sev_guest_status(kvm, &sev_cmd);
break;
case KVM_SEV_DBG_DECRYPT:
r = sev_dbg_crypt(kvm, &sev_cmd, true);
break;
case KVM_SEV_DBG_ENCRYPT:
r = sev_dbg_crypt(kvm, &sev_cmd, false);
break;
case KVM_SEV_LAUNCH_SECRET:
r = sev_launch_secret(kvm, &sev_cmd);
break;
case KVM_SEV_GET_ATTESTATION_REPORT:
r = sev_get_attestation_report(kvm, &sev_cmd);
break;
case KVM_SEV_SEND_START:
r = sev_send_start(kvm, &sev_cmd);
break;
case KVM_SEV_SEND_UPDATE_DATA:
r = sev_send_update_data(kvm, &sev_cmd);
break;
case KVM_SEV_SEND_FINISH:
r = sev_send_finish(kvm, &sev_cmd);
break;
case KVM_SEV_SEND_CANCEL:
r = sev_send_cancel(kvm, &sev_cmd);
break;
case KVM_SEV_RECEIVE_START:
r = sev_receive_start(kvm, &sev_cmd);
break;
case KVM_SEV_RECEIVE_UPDATE_DATA:
r = sev_receive_update_data(kvm, &sev_cmd);
break;
case KVM_SEV_RECEIVE_FINISH:
r = sev_receive_finish(kvm, &sev_cmd);
break;
default:
r = -EINVAL;
goto out;
}
if (copy_to_user(argp, &sev_cmd, sizeof(struct kvm_sev_cmd)))
r = -EFAULT;
out:
mutex_unlock(&kvm->lock);
return r;
}
| 0
|
262,790
|
static void mctp_serial_tty_write_wakeup(struct tty_struct *tty)
{
struct mctp_serial *dev = tty->disc_data;
schedule_work(&dev->tx_work);
}
| 0
|
90,768
|
DumpQuotaTableTask(
QuotaManager* manager,
Callback* callback)
: DatabaseTaskBase(manager),
callback_(callback) {
}
| 0
|
481,257
|
static void mlx5_fpga_conn_cq_tasklet(unsigned long data)
{
struct mlx5_fpga_conn *conn = (void *)data;
if (unlikely(!conn->qp.active))
return;
mlx5_fpga_conn_cqes(conn, MLX5_FPGA_CQ_BUDGET);
}
| 0
|
313,851
|
check_scrollbind(linenr_T topline_diff, long leftcol_diff)
{
int want_ver;
int want_hor;
win_T *old_curwin = curwin;
buf_T *old_curbuf = curbuf;
int old_VIsual_select = VIsual_select;
int old_VIsual_active = VIsual_active;
colnr_T tgt_leftcol = curwin->w_leftcol;
long topline;
long y;
// check 'scrollopt' string for vertical and horizontal scroll options
want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0);
#ifdef FEAT_DIFF
want_ver |= old_curwin->w_p_diff;
#endif
want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0));
// loop through the scrollbound windows and scroll accordingly
VIsual_select = VIsual_active = 0;
FOR_ALL_WINDOWS(curwin)
{
curbuf = curwin->w_buffer;
// skip original window and windows with 'noscrollbind'
if (curwin != old_curwin && curwin->w_p_scb)
{
// do the vertical scroll
if (want_ver)
{
#ifdef FEAT_DIFF
if (old_curwin->w_p_diff && curwin->w_p_diff)
{
diff_set_topline(old_curwin, curwin);
}
else
#endif
{
curwin->w_scbind_pos += topline_diff;
topline = curwin->w_scbind_pos;
if (topline > curbuf->b_ml.ml_line_count)
topline = curbuf->b_ml.ml_line_count;
if (topline < 1)
topline = 1;
y = topline - curwin->w_topline;
if (y > 0)
scrollup(y, FALSE);
else
scrolldown(-y, FALSE);
}
redraw_later(VALID);
cursor_correct();
curwin->w_redr_status = TRUE;
}
// do the horizontal scroll
if (want_hor && curwin->w_leftcol != tgt_leftcol)
{
curwin->w_leftcol = tgt_leftcol;
leftcol_changed();
}
}
}
// reset current-window
VIsual_select = old_VIsual_select;
VIsual_active = old_VIsual_active;
curwin = old_curwin;
curbuf = old_curbuf;
}
| 0
|
512,933
|
Item_copy(THD *thd, Item *i): Item(thd)
{
DBUG_ASSERT(i->is_fixed());
item= i;
null_value=maybe_null=item->maybe_null;
Type_std_attributes::set(item);
name= item->name;
set_handler(item->type_handler());
}
| 0
|
512,662
|
int Arg_comparator::compare_native()
{
THD *thd= current_thd;
if (!(*a)->val_native_with_conversion(thd, &m_native1,
compare_type_handler()))
{
if (!(*b)->val_native_with_conversion(thd, &m_native2,
compare_type_handler()))
{
if (set_null)
owner->null_value= 0;
return compare_type_handler()->cmp_native(m_native1, m_native2);
}
}
if (set_null)
owner->null_value= 1;
return -1;
}
| 0
|
384,206
|
static int nft_value_init(const struct nft_ctx *ctx,
struct nft_data *data, struct nft_data_desc *desc,
const struct nlattr *nla)
{
unsigned int len;
len = nla_len(nla);
if (len == 0)
return -EINVAL;
if (len > desc->size)
return -EOVERFLOW;
if (desc->len) {
if (len != desc->len)
return -EINVAL;
} else {
desc->len = len;
}
nla_memcpy(data->data, nla, len);
return 0;
}
| 0
|
267,870
|
void ModularFrameDecoder::MaybeDropFullImage() {
if (full_image.transform.empty() && !have_something) {
use_full_image = false;
for (auto& ch : full_image.channel) {
// keep metadata on channels around, but dealloc their planes
ch.plane = Plane<pixel_type>();
}
}
}
| 0
|
300,798
|
static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk)
{
u32 peer_node, peer_port;
u32 conn_type, conn_instance;
struct nlattr *nest;
peer_node = tsk_peer_node(tsk);
peer_port = tsk_peer_port(tsk);
conn_type = msg_nametype(&tsk->phdr);
conn_instance = msg_nameinst(&tsk->phdr);
nest = nla_nest_start_noflag(skb, TIPC_NLA_SOCK_CON);
if (!nest)
return -EMSGSIZE;
if (nla_put_u32(skb, TIPC_NLA_CON_NODE, peer_node))
goto msg_full;
if (nla_put_u32(skb, TIPC_NLA_CON_SOCK, peer_port))
goto msg_full;
if (tsk->conn_addrtype != 0) {
if (nla_put_flag(skb, TIPC_NLA_CON_FLAG))
goto msg_full;
if (nla_put_u32(skb, TIPC_NLA_CON_TYPE, conn_type))
goto msg_full;
if (nla_put_u32(skb, TIPC_NLA_CON_INST, conn_instance))
goto msg_full;
}
nla_nest_end(skb, nest);
return 0;
msg_full:
nla_nest_cancel(skb, nest);
return -EMSGSIZE;
}
| 0
|
436,139
|
*/
static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
const sigset_t __user *sig, size_t sigsz,
struct __kernel_timespec __user *uts)
{
struct io_wait_queue iowq = {
.wq = {
.private = current,
.func = io_wake_function,
.entry = LIST_HEAD_INIT(iowq.wq.entry),
},
.ctx = ctx,
.to_wait = min_events,
};
struct io_rings *rings = ctx->rings;
signed long timeout = MAX_SCHEDULE_TIMEOUT;
int ret;
do {
io_cqring_overflow_flush(ctx, false);
if (io_cqring_events(ctx) >= min_events)
return 0;
if (!io_run_task_work())
break;
} while (1);
if (sig) {
#ifdef CONFIG_COMPAT
if (in_compat_syscall())
ret = set_compat_user_sigmask((const compat_sigset_t __user *)sig,
sigsz);
else
#endif
ret = set_user_sigmask(sig, sigsz);
if (ret)
return ret;
}
if (uts) {
struct timespec64 ts;
if (get_timespec64(&ts, uts))
return -EFAULT;
timeout = timespec64_to_jiffies(&ts);
}
iowq.nr_timeouts = atomic_read(&ctx->cq_timeouts);
trace_io_uring_cqring_wait(ctx, min_events);
do {
/* if we can't even flush overflow, don't wait for more */
if (!io_cqring_overflow_flush(ctx, false)) {
ret = -EBUSY;
break;
}
prepare_to_wait_exclusive(&ctx->cq_wait, &iowq.wq,
TASK_INTERRUPTIBLE);
ret = io_cqring_wait_schedule(ctx, &iowq, &timeout);
finish_wait(&ctx->cq_wait, &iowq.wq);
cond_resched();
} while (ret > 0);
restore_saved_sigmask_unless(ret == -EINTR);
return READ_ONCE(rings->cq.head) == READ_ONCE(rings->cq.tail) ? ret : 0;
| 0
|
139,220
|
gfx::Rect OverlayWindowViews::GetFirstCustomControlsBounds() {
if (!first_custom_controls_view_)
return gfx::Rect();
return first_custom_controls_view_->GetMirroredBounds();
}
| 0
|
206,639
|
static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
struct nft_data_desc *desc, const struct nlattr *nla)
{
u8 genmask = nft_genmask_next(ctx->net);
struct nlattr *tb[NFTA_VERDICT_MAX + 1];
struct nft_chain *chain;
int err;
err = nla_parse_nested_deprecated(tb, NFTA_VERDICT_MAX, nla,
nft_verdict_policy, NULL);
if (err < 0)
return err;
if (!tb[NFTA_VERDICT_CODE])
return -EINVAL;
data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));
switch (data->verdict.code) {
default:
switch (data->verdict.code & NF_VERDICT_MASK) {
case NF_ACCEPT:
case NF_DROP:
case NF_QUEUE:
break;
default:
return -EINVAL;
}
fallthrough;
case NFT_CONTINUE:
case NFT_BREAK:
case NFT_RETURN:
break;
case NFT_JUMP:
case NFT_GOTO:
if (tb[NFTA_VERDICT_CHAIN]) {
chain = nft_chain_lookup(ctx->net, ctx->table,
tb[NFTA_VERDICT_CHAIN],
genmask);
} else if (tb[NFTA_VERDICT_CHAIN_ID]) {
chain = nft_chain_lookup_byid(ctx->net, ctx->table,
tb[NFTA_VERDICT_CHAIN_ID]);
if (IS_ERR(chain))
return PTR_ERR(chain);
} else {
return -EINVAL;
}
if (IS_ERR(chain))
return PTR_ERR(chain);
if (nft_is_base_chain(chain))
return -EOPNOTSUPP;
if (desc->flags & NFT_DATA_DESC_SETELEM &&
chain->flags & NFT_CHAIN_BINDING)
return -EINVAL;
chain->use++;
data->verdict.chain = chain;
break;
}
desc->len = sizeof(data->verdict);
return 0;
}
| 1
|
452,248
|
PHP_FUNCTION(xsl_xsltprocessor_transform_to_xml)
{
zval *id, *docp = NULL;
xmlDoc *newdocp;
xsltStylesheetPtr sheetp;
int ret;
xmlChar *doc_txt_ptr;
int doc_txt_len;
xsl_object *intern;
id = getThis();
intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
sheetp = (xsltStylesheetPtr) intern->ptr;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &docp) == FAILURE) {
RETURN_FALSE;
}
newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);
ret = -1;
if (newdocp) {
ret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, newdocp, sheetp);
if (doc_txt_ptr && doc_txt_len) {
RETVAL_STRINGL(doc_txt_ptr, doc_txt_len, 1);
xmlFree(doc_txt_ptr);
}
xmlFreeDoc(newdocp);
}
if (ret < 0) {
RETURN_FALSE;
}
}
| 0
|
206,989
|
apply_extra_data (FlatpakDir *self,
GFile *checkoutdir,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GFile) metadata = NULL;
g_autofree char *metadata_contents = NULL;
gsize metadata_size;
g_autoptr(GKeyFile) metakey = NULL;
g_autofree char *id = NULL;
g_autofree char *runtime_pref = NULL;
g_autoptr(FlatpakDecomposed) runtime_ref = NULL;
g_autoptr(FlatpakDeploy) runtime_deploy = NULL;
g_autoptr(FlatpakBwrap) bwrap = NULL;
g_autoptr(GFile) app_files = NULL;
g_autoptr(GFile) apply_extra_file = NULL;
g_autoptr(GFile) app_export_file = NULL;
g_autoptr(GFile) extra_export_file = NULL;
g_autoptr(GFile) extra_files = NULL;
g_autoptr(GFile) runtime_files = NULL;
g_autoptr(FlatpakContext) app_context = NULL;
g_auto(GStrv) minimal_envp = NULL;
g_autofree char *runtime_arch = NULL;
int exit_status;
const char *group = FLATPAK_METADATA_GROUP_APPLICATION;
g_autoptr(GError) local_error = NULL;
apply_extra_file = g_file_resolve_relative_path (checkoutdir, "files/bin/apply_extra");
if (!g_file_query_exists (apply_extra_file, cancellable))
return TRUE;
metadata = g_file_get_child (checkoutdir, "metadata");
if (!g_file_load_contents (metadata, cancellable, &metadata_contents, &metadata_size, NULL, error))
return FALSE;
metakey = g_key_file_new ();
if (!g_key_file_load_from_data (metakey, metadata_contents, metadata_size, 0, error))
return FALSE;
id = g_key_file_get_string (metakey, group, FLATPAK_METADATA_KEY_NAME,
&local_error);
if (id == NULL)
{
group = FLATPAK_METADATA_GROUP_RUNTIME;
id = g_key_file_get_string (metakey, group, FLATPAK_METADATA_KEY_NAME,
NULL);
if (id == NULL)
{
g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE;
}
g_clear_error (&local_error);
}
runtime_pref = g_key_file_get_string (metakey, group,
FLATPAK_METADATA_KEY_RUNTIME, error);
if (runtime_pref == NULL)
runtime_pref = g_key_file_get_string (metakey, FLATPAK_METADATA_GROUP_EXTENSION_OF,
FLATPAK_METADATA_KEY_RUNTIME, NULL);
if (runtime_pref == NULL)
return FALSE;
runtime_ref = flatpak_decomposed_new_from_pref (FLATPAK_KINDS_RUNTIME, runtime_pref, error);
if (runtime_ref == NULL)
return FALSE;
runtime_arch = flatpak_decomposed_dup_arch (runtime_ref);
if (!g_key_file_get_boolean (metakey, FLATPAK_METADATA_GROUP_EXTRA_DATA,
FLATPAK_METADATA_KEY_NO_RUNTIME, NULL))
{
/* We pass in self here so that we ensure that we find the runtime in case it only
exists in this installation (which might be custom) */
runtime_deploy = flatpak_find_deploy_for_ref (flatpak_decomposed_get_ref (runtime_ref), NULL, self, cancellable, error);
if (runtime_deploy == NULL)
return FALSE;
runtime_files = flatpak_deploy_get_files (runtime_deploy);
}
app_files = g_file_get_child (checkoutdir, "files");
app_export_file = g_file_get_child (checkoutdir, "export");
extra_files = g_file_get_child (app_files, "extra");
extra_export_file = g_file_get_child (extra_files, "export");
minimal_envp = flatpak_run_get_minimal_env (FALSE, FALSE);
bwrap = flatpak_bwrap_new (minimal_envp);
flatpak_bwrap_add_args (bwrap, flatpak_get_bwrap (), NULL);
if (runtime_files)
flatpak_bwrap_add_args (bwrap,
"--ro-bind", flatpak_file_get_path_cached (runtime_files), "/usr",
"--lock-file", "/usr/.ref",
NULL);
flatpak_bwrap_add_args (bwrap,
"--ro-bind", flatpak_file_get_path_cached (app_files), "/app",
"--bind", flatpak_file_get_path_cached (extra_files), "/app/extra",
"--chdir", "/app/extra",
/* We run as root in the system-helper case, so drop all caps */
"--cap-drop", "ALL",
NULL);
if (!flatpak_run_setup_base_argv (bwrap, runtime_files, NULL, runtime_arch,
/* Might need multiarch in apply_extra (see e.g. #3742). Should be pretty safe in this limited context */
FLATPAK_RUN_FLAG_MULTIARCH |
FLATPAK_RUN_FLAG_NO_SESSION_HELPER | FLATPAK_RUN_FLAG_NO_PROC,
error))
return FALSE;
app_context = flatpak_context_new ();
if (!flatpak_run_add_environment_args (bwrap, NULL,
FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY |
FLATPAK_RUN_FLAG_NO_SYSTEM_BUS_PROXY |
FLATPAK_RUN_FLAG_NO_A11Y_BUS_PROXY,
id,
app_context, NULL, NULL, NULL, cancellable, error))
return FALSE;
flatpak_bwrap_add_arg (bwrap, "/app/bin/apply_extra");
flatpak_bwrap_finish (bwrap);
g_debug ("Running /app/bin/apply_extra ");
/* We run the sandbox without caps, but it can still create files owned by itself with
* arbitrary permissions, including setuid myself. This is extra risky in the case where
* this runs as root in the system helper case. We canonicalize the permissions at the
* end, but to avoid non-canonical permissions leaking out before then we make the
* toplevel dir only accessible to the user */
if (chmod (flatpak_file_get_path_cached (extra_files), 0700) != 0)
{
glnx_set_error_from_errno (error);
return FALSE;
}
if (!g_spawn_sync (NULL,
(char **) bwrap->argv->pdata,
bwrap->envp,
G_SPAWN_SEARCH_PATH,
child_setup, bwrap->fds,
NULL, NULL,
&exit_status,
error))
return FALSE;
if (!flatpak_canonicalize_permissions (AT_FDCWD, flatpak_file_get_path_cached (extra_files),
getuid () == 0 ? 0 : -1,
getuid () == 0 ? 0 : -1,
error))
return FALSE;
if (exit_status != 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("apply_extra script failed, exit status %d"), exit_status);
return FALSE;
}
if (g_file_query_exists (extra_export_file, cancellable))
{
if (!flatpak_mkdir_p (app_export_file, cancellable, error))
return FALSE;
if (!flatpak_cp_a (extra_export_file,
app_export_file,
FLATPAK_CP_FLAGS_MERGE,
cancellable, error))
return FALSE;
}
return TRUE;
}
| 1
|
489,168
|
struct sctp_chunk *sctp_make_op_error(const struct sctp_association *asoc,
const struct sctp_chunk *chunk,
__be16 cause_code, const void *payload,
size_t paylen)
{
struct sctp_chunk *retval;
retval = sctp_make_op_error_space(asoc, chunk, paylen);
if (!retval)
goto nodata;
sctp_init_cause(retval, cause_code, paylen);
sctp_addto_chunk(retval, paylen, payload);
nodata:
return retval;
}
| 0
|
310,304
|
dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,
cached_dir_t *auth_src,
time_t dirty, cached_dir_t *(*regenerate)(void),
const char *name,
authority_type_t auth_type)
{
or_options_t *options = get_options();
int authority = (auth_type == V1_AUTHORITY && authdir_mode_v1(options)) ||
(auth_type == V2_AUTHORITY && authdir_mode_v2(options));
if (!authority || authdir_mode_bridge(options)) {
return cache_src;
} else {
/* We're authoritative. */
if (regenerate != NULL) {
if (dirty && dirty + DIR_REGEN_SLACK_TIME < time(NULL)) {
if (!(auth_src = regenerate())) {
log_err(LD_BUG, "Couldn't generate %s?", name);
exit(1);
}
} else {
log_info(LD_DIRSERV, "The %s is still clean; reusing.", name);
}
}
return auth_src ? auth_src : cache_src;
}
}
| 0
|
220,839
|
void optimized_ops_prefetch_write_l1_keep(const T* ptr) {
#ifdef __GNUC__
// builtin offered by GCC-compatible compilers including clang
__builtin_prefetch(ptr, /* 1 means write */ 1, /* 3 means high locality */ 3);
#else
(void)ptr;
#endif
}
| 0
|
349,873
|
int hw_atl_utils_update_stats(struct aq_hw_s *self)
{
struct aq_stats_s *cs = &self->curr_stats;
struct hw_atl_utils_mbox mbox;
hw_atl_utils_mpi_read_stats(self, &mbox);
#define AQ_SDELTA(_N_) (self->curr_stats._N_ += \
mbox.stats._N_ - self->last_stats._N_)
if (self->aq_link_status.mbps) {
AQ_SDELTA(uprc);
AQ_SDELTA(mprc);
AQ_SDELTA(bprc);
AQ_SDELTA(erpt);
AQ_SDELTA(uptc);
AQ_SDELTA(mptc);
AQ_SDELTA(bptc);
AQ_SDELTA(erpr);
AQ_SDELTA(ubrc);
AQ_SDELTA(ubtc);
AQ_SDELTA(mbrc);
AQ_SDELTA(mbtc);
AQ_SDELTA(bbrc);
AQ_SDELTA(bbtc);
AQ_SDELTA(dpc);
}
#undef AQ_SDELTA
cs->dma_pkt_rc = hw_atl_stats_rx_dma_good_pkt_counter_get(self);
cs->dma_pkt_tc = hw_atl_stats_tx_dma_good_pkt_counter_get(self);
cs->dma_oct_rc = hw_atl_stats_rx_dma_good_octet_counter_get(self);
cs->dma_oct_tc = hw_atl_stats_tx_dma_good_octet_counter_get(self);
memcpy(&self->last_stats, &mbox.stats, sizeof(mbox.stats));
return 0;
}
| 0
|
463,058
|
static uint16_t sungem_mii_read(SunGEMState *s, uint8_t phy_addr,
uint8_t reg_addr)
{
uint16_t val;
val = __sungem_mii_read(s, phy_addr, reg_addr);
trace_sungem_mii_read(phy_addr, reg_addr, val);
return val;
}
| 0
|
220,017
|
int callback_glewlwyd_get_api_key_list (const struct _u_request * request, struct _u_response * response, void * user_data) {
struct config_elements * config = (struct config_elements *)user_data;
json_t * j_api_key_list;
size_t offset = 0, limit = GLEWLWYD_DEFAULT_LIMIT_SIZE;
long int l_converted = 0;
char * endptr = NULL;
if (u_map_get(request->map_url, "offset") != NULL) {
l_converted = strtol(u_map_get(request->map_url, "offset"), &endptr, 10);
if (!(*endptr) && l_converted > 0) {
offset = (size_t)l_converted;
}
}
if (u_map_get(request->map_url, "limit") != NULL) {
l_converted = strtol(u_map_get(request->map_url, "limit"), &endptr, 10);
if (!(*endptr) && l_converted >= 0) {
limit = (size_t)l_converted;
}
}
j_api_key_list = get_api_key_list(config, u_map_get(request->map_url, "pattern"), offset, limit);
if (check_result_value(j_api_key_list, G_OK)) {
ulfius_set_json_body_response(response, 200, json_object_get(j_api_key_list, "api_key"));
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_api_key_list - Error get_api_key_list");
response->status = 500;
}
json_decref(j_api_key_list);
return U_CALLBACK_CONTINUE;
}
| 0
|
413,339
|
PHP_MINIT_FUNCTION(snmp)
{
netsnmp_log_handler *logh;
zend_class_entry ce, cex;
le_snmp_session = zend_register_list_destructors_ex(php_snmp_session_destructor, NULL, PHP_SNMP_SESSION_RES_NAME, module_number);
init_snmp("snmpapp");
#ifdef NETSNMP_DS_LIB_DONT_PERSIST_STATE
/* Prevent update of the snmpapp.conf file */
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);
#endif
/* Disable logging, use exit status'es and related variabled to detect errors */
shutdown_snmp_logging();
logh = netsnmp_register_loghandler(NETSNMP_LOGHANDLER_NONE, LOG_ERR);
if (logh) {
logh->pri_max = LOG_ERR;
}
memcpy(&php_snmp_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_snmp_object_handlers.read_property = php_snmp_read_property;
php_snmp_object_handlers.write_property = php_snmp_write_property;
php_snmp_object_handlers.has_property = php_snmp_has_property;
php_snmp_object_handlers.get_properties = php_snmp_get_properties;
php_snmp_object_handlers.get_gc = php_snmp_get_gc;
/* Register SNMP Class */
INIT_CLASS_ENTRY(ce, "SNMP", php_snmp_class_methods);
ce.create_object = php_snmp_object_new;
php_snmp_object_handlers.clone_obj = NULL;
php_snmp_ce = zend_register_internal_class(&ce TSRMLS_CC);
/* Register SNMP Class properties */
zend_hash_init(&php_snmp_properties, 0, NULL, NULL, 1);
PHP_SNMP_ADD_PROPERTIES(&php_snmp_properties, php_snmp_property_entries);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_SUFFIX", NETSNMP_OID_OUTPUT_SUFFIX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_MODULE", NETSNMP_OID_OUTPUT_MODULE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_FULL", NETSNMP_OID_OUTPUT_FULL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NUMERIC", NETSNMP_OID_OUTPUT_NUMERIC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_UCD", NETSNMP_OID_OUTPUT_UCD, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NONE", NETSNMP_OID_OUTPUT_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", SNMP_VALUE_LIBRARY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", SNMP_VALUE_PLAIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", SNMP_VALUE_OBJECT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_BIT_STR", ASN_BIT_STR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", ASN_OCTET_STR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OPAQUE", ASN_OPAQUE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_NULL", ASN_NULL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", ASN_OBJECT_ID, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_IPADDRESS", ASN_IPADDRESS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_COUNTER", ASN_GAUGE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_UNSIGNED", ASN_UNSIGNED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_TIMETICKS", ASN_TIMETICKS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_UINTEGER", ASN_UINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_1", SNMP_VERSION_1);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2c", SNMP_VERSION_2c);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2C", SNMP_VERSION_2c);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_3", SNMP_VERSION_3);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_NOERROR", PHP_SNMP_ERRNO_NOERROR);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ANY", PHP_SNMP_ERRNO_ANY);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_GENERIC", PHP_SNMP_ERRNO_GENERIC);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_TIMEOUT", PHP_SNMP_ERRNO_TIMEOUT);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ERROR_IN_REPLY", PHP_SNMP_ERRNO_ERROR_IN_REPLY);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_NOT_INCREASING", PHP_SNMP_ERRNO_OID_NOT_INCREASING);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_PARSING_ERROR", PHP_SNMP_ERRNO_OID_PARSING_ERROR);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_MULTIPLE_SET_QUERIES", PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES);
/* Register SNMPException class */
INIT_CLASS_ENTRY(cex, "SNMPException", NULL);
#ifdef HAVE_SPL
php_snmp_exception_ce = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException, NULL TSRMLS_CC);
#else
php_snmp_exception_ce = zend_register_internal_class_ex(&cex, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
#endif
return SUCCESS;
}
| 0
|
512,300
|
void set_geometry_type(uint type)
{ Type_geometry_attributes::set_geometry_type(type); }
| 0
|
437,302
|
select_opt_exact(OnigEncoding enc, OptExact* now, OptExact* alt)
{
int vn, va;
vn = now->len;
va = alt->len;
if (va == 0) {
return ;
}
else if (vn == 0) {
copy_opt_exact(now, alt);
return ;
}
else if (vn <= 2 && va <= 2) {
/* ByteValTable[x] is big value --> low price */
va = map_position_value(enc, now->s[0]);
vn = map_position_value(enc, alt->s[0]);
if (now->len > 1) vn += 5;
if (alt->len > 1) va += 5;
}
if (now->ignore_case == 0) vn *= 2;
if (alt->ignore_case == 0) va *= 2;
if (comp_distance_value(&now->mmd, &alt->mmd, vn, va) > 0)
copy_opt_exact(now, alt);
}
| 0
|
207,703
|
set<int> PipeSocketHandler::listen(const SocketEndpoint& endpoint) {
lock_guard<std::recursive_mutex> guard(globalMutex);
string pipePath = endpoint.name();
if (pipeServerSockets.find(pipePath) != pipeServerSockets.end()) {
throw runtime_error("Tried to listen twice on the same path");
}
sockaddr_un local;
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
FATAL_FAIL(fd);
initServerSocket(fd);
local.sun_family = AF_UNIX; /* local is declared before socket() ^ */
strcpy(local.sun_path, pipePath.c_str());
unlink(local.sun_path);
FATAL_FAIL(::bind(fd, (struct sockaddr*)&local, sizeof(sockaddr_un)));
::listen(fd, 5);
#ifndef WIN32
FATAL_FAIL(::chmod(local.sun_path, S_IRUSR | S_IWUSR | S_IXUSR));
#endif
pipeServerSockets[pipePath] = set<int>({fd});
return pipeServerSockets[pipePath];
}
| 1
|
517,458
|
static void do_foot(HttpResponse res) {
StringBuffer_append(res->outputbuffer,
"</center></div></div>"
"<div id='footer'>"
"Copyright © 2001-2018 <a href=\"http://tildeslash.com/\">Tildeslash</a>. All rights reserved. "
"<span style='margin-left:5px;'></span>"
"<a href=\"http://mmonit.com/monit/\">Monit web site</a> | "
"<a href=\"http://mmonit.com/wiki/\">Monit Wiki</a> | "
"<a href=\"http://mmonit.com/\">M/Monit</a>"
"</div></body></html>");
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.