idx
int64
func
string
target
int64
96,956
void encode(ArgumentEncoder* encoder, CFDictionaryRef dictionary) { CFIndex size = CFDictionaryGetCount(dictionary); Vector<CFTypeRef, 32> keys(size); Vector<CFTypeRef, 32> values(size); CFDictionaryGetKeysAndValues(dictionary, keys.data(), values.data()); encoder->encodeUInt64(size); for (CFIndex i = 0; i < size; ++i) { ASSERT(keys[i]); ASSERT(CFGetTypeID(keys[i]) == CFStringGetTypeID()); ASSERT(values[i]); if (typeFromCFTypeRef(values[i]) == Unknown) continue; encode(encoder, static_cast<CFStringRef>(keys[i])); encode(encoder, values[i]); } }
0
398,513
RZ_API RzBinDwarfLineInfo *rz_bin_dwarf_parse_line(RzBinFile *binfile, RZ_NULLABLE RzBinDwarfDebugInfo *info, RzBinDwarfLineInfoMask mask) { rz_return_val_if_fail(binfile, NULL); RzBinSection *section = getsection(binfile, "debug_line"); if (!section) { return NULL; } ut64 len = section->size; if (len < 1) { return NULL; } ut8 *buf = RZ_NEWS0(ut8, len + 1); if (!buf) { return NULL; } int ret = rz_buf_read_at(binfile->buf, section->paddr, buf, len); if (ret != len) { free(buf); return NULL; } // Actually parse the section RzBinDwarfLineInfo *r = parse_line_raw(binfile, buf, len, mask, binfile->o && binfile->o->info && binfile->o->info->big_endian, info); free(buf); return r; }
0
387,645
static int read_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, unsigned int size) { struct user_element *ue = kctl->private_data; if (ue->tlv_data_size == 0 || ue->tlv_data == NULL) return -ENXIO; if (size < ue->tlv_data_size) return -ENOSPC; if (copy_to_user(buf, ue->tlv_data, ue->tlv_data_size)) return -EFAULT; return 0; }
0
227,025
IRC_PROTOCOL_CALLBACK(topic) { char *pos_topic, *old_topic_color, *topic_color; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; struct t_gui_buffer *ptr_buffer; IRC_PROTOCOL_MIN_ARGS(3); if (!irc_channel_is_channel (server, argv[2])) { weechat_printf (server->buffer, _("%s%s: \"%s\" command received without channel"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "topic"); return WEECHAT_RC_OK; } pos_topic = (argc > 3) ? ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; ptr_channel = irc_channel_search (server, argv[2]); ptr_nick = irc_nick_search (server, ptr_channel, nick); ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; /* * unmask a smart filtered join if it is in hashtable * "join_smart_filtered" of channel */ if (ptr_channel) irc_channel_join_smart_filtered_unmask (ptr_channel, nick); if (pos_topic && pos_topic[0]) { topic_color = irc_color_decode ( pos_topic, weechat_config_boolean (irc_config_network_colors_receive)); if (weechat_config_boolean (irc_config_look_display_old_topic) && ptr_channel && ptr_channel->topic && ptr_channel->topic[0]) { old_topic_color = irc_color_decode ( ptr_channel->topic, weechat_config_boolean (irc_config_network_colors_receive)); weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, NULL, ptr_buffer), date, irc_protocol_tags (command, NULL, NULL, address), _("%s%s%s%s has changed topic for %s%s%s from \"%s%s%s\" to " "\"%s%s%s\""), weechat_prefix ("network"), irc_nick_color_for_msg (server, 1, ptr_nick, nick), nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, argv[2], IRC_COLOR_RESET, IRC_COLOR_TOPIC_OLD, (old_topic_color) ? old_topic_color : ptr_channel->topic, IRC_COLOR_RESET, IRC_COLOR_TOPIC_NEW, (topic_color) ? topic_color : pos_topic, IRC_COLOR_RESET); if (old_topic_color) free (old_topic_color); } else { weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, NULL, ptr_buffer), date, irc_protocol_tags (command, NULL, NULL, address), _("%s%s%s%s has changed topic for %s%s%s to \"%s%s%s\""), weechat_prefix ("network"), irc_nick_color_for_msg (server, 1, ptr_nick, nick), nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, argv[2], IRC_COLOR_RESET, IRC_COLOR_TOPIC_NEW, (topic_color) ? topic_color : pos_topic, IRC_COLOR_RESET); } if (topic_color) free (topic_color); } else { if (weechat_config_boolean (irc_config_look_display_old_topic) && ptr_channel && ptr_channel->topic && ptr_channel->topic[0]) { old_topic_color = irc_color_decode ( ptr_channel->topic, weechat_config_boolean (irc_config_network_colors_receive)); weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, NULL, ptr_buffer), date, irc_protocol_tags (command, NULL, NULL, address), _("%s%s%s%s has unset topic for %s%s%s (old topic: " "\"%s%s%s\")"), weechat_prefix ("network"), irc_nick_color_for_msg (server, 1, ptr_nick, nick), nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, argv[2], IRC_COLOR_RESET, IRC_COLOR_TOPIC_OLD, (old_topic_color) ? old_topic_color : ptr_channel->topic, IRC_COLOR_RESET); if (old_topic_color) free (old_topic_color); } else { weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, NULL, ptr_buffer), date, irc_protocol_tags (command, NULL, NULL, address), _("%s%s%s%s has unset topic for %s%s%s"), weechat_prefix ("network"), irc_nick_color_for_msg (server, 1, ptr_nick, nick), nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, argv[2], IRC_COLOR_RESET); } } if (ptr_channel) irc_channel_set_topic (ptr_channel, pos_topic); return WEECHAT_RC_OK; }
0
247,699
TEST_P(SslReadBufferLimitTest, SmallReadsIntoSameSlice) { // write_size * num_writes must be large enough to cause buffer reserving fragmentation, // but smaller than one reservation so the expected slice to be 1. const uint32_t write_size = 1; const uint32_t num_writes = 12 * 1024; const uint32_t read_buffer_limit = write_size * num_writes; const uint32_t expected_chunk_size = write_size * num_writes; initialize(); EXPECT_CALL(listener_callbacks_, onAccept_(_)) .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void { server_connection_ = dispatcher_->createServerConnection( std::move(socket), server_ssl_socket_factory_->createTransportSocket(nullptr), stream_info_); server_connection_->setBufferLimits(read_buffer_limit); server_connection_->addConnectionCallbacks(server_callbacks_); server_connection_->addReadFilter(read_filter_); EXPECT_EQ("", server_connection_->nextProtocol()); EXPECT_EQ(read_buffer_limit, server_connection_->bufferLimit()); })); EXPECT_CALL(client_callbacks_, onEvent(Network::ConnectionEvent::Connected)) .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { dispatcher_->exit(); })); dispatcher_->run(Event::Dispatcher::RunType::Block); uint32_t filter_seen = 0; EXPECT_CALL(*read_filter_, onNewConnection()); EXPECT_CALL(*read_filter_, onData(_, _)) .WillRepeatedly(Invoke([&](Buffer::Instance& data, bool) -> Network::FilterStatus { EXPECT_GE(expected_chunk_size, data.length()); EXPECT_EQ(1, data.getRawSlices().size()); filter_seen += data.length(); data.drain(data.length()); if (filter_seen == (write_size * num_writes)) { server_connection_->close(Network::ConnectionCloseType::FlushWrite); } return Network::FilterStatus::StopIteration; })); EXPECT_CALL(client_callbacks_, onEvent(Network::ConnectionEvent::RemoteClose)) .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { EXPECT_EQ((write_size * num_writes), filter_seen); dispatcher_->exit(); })); for (uint32_t i = 0; i < num_writes; i++) { Buffer::OwnedImpl data(std::string(write_size, 'a')); client_connection_->write(data, false); } dispatcher_->run(Event::Dispatcher::RunType::Block); }
0
238,609
static void scalar32_min_max_xor(struct bpf_reg_state *dst_reg, struct bpf_reg_state *src_reg) { bool src_known = tnum_subreg_is_const(src_reg->var_off); bool dst_known = tnum_subreg_is_const(dst_reg->var_off); struct tnum var32_off = tnum_subreg(dst_reg->var_off); s32 smin_val = src_reg->s32_min_value; if (src_known && dst_known) { __mark_reg32_known(dst_reg, var32_off.value); return; } /* We get both minimum and maximum from the var32_off. */ dst_reg->u32_min_value = var32_off.value; dst_reg->u32_max_value = var32_off.value | var32_off.mask; if (dst_reg->s32_min_value >= 0 && smin_val >= 0) { /* XORing two positive sign numbers gives a positive, * so safe to cast u32 result into s32. */ dst_reg->s32_min_value = dst_reg->u32_min_value; dst_reg->s32_max_value = dst_reg->u32_max_value; } else { dst_reg->s32_min_value = S32_MIN; dst_reg->s32_max_value = S32_MAX; } }
0
195,296
void publish(Topic *iterator, size_t start, size_t stop, std::string_view topic, std::pair<std::string_view, std::string_view> message) { /* If we already have 64 triggered topics make sure to drain it here */ if (numTriggeredTopics == 64) { drain(); } /* Iterate over all segments in given topic */ for (; stop != std::string::npos; start = stop + 1) { stop = topic.find('/', start); std::string_view segment = topic.substr(start, stop - start); /* It is very important to disallow wildcards when publishing. * We will not catch EVERY misuse this lazy way, but enough to hinder * explosive recursion. * Terminating wildcards MAY still get triggered along the way, if for * instace the error is found late while iterating the topic segments. */ if (segment.length() == 1) { if (segment[0] == '+' || segment[0] == '#') { return; } } /* Do we have a terminating wildcard child? */ if (iterator->terminatingWildcardChild) { iterator->terminatingWildcardChild->messages[messageId] = message; /* Add this topic to triggered */ if (!iterator->terminatingWildcardChild->triggered) { triggeredTopics[numTriggeredTopics++] = iterator->terminatingWildcardChild; iterator->terminatingWildcardChild->triggered = true; } } /* Do we have a wildcard child? */ if (iterator->wildcardChild) { publish(iterator->wildcardChild, stop + 1, stop, topic, message); } std::map<std::string_view, Topic *>::iterator it = iterator->children.find(segment); if (it == iterator->children.end()) { /* Stop trying to match by exact string */ return; } iterator = it->second; } /* If we went all the way we matched exactly */ iterator->messages[messageId] = message; /* Add this topic to triggered */ if (!iterator->triggered) { triggeredTopics[numTriggeredTopics++] = iterator; iterator->triggered = true; } }
1
472,123
int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param) { struct cgroup_fs_context *ctx = cgroup_fc2context(fc); struct cgroup_subsys *ss; struct fs_parse_result result; int opt, i; opt = fs_parse(fc, cgroup1_fs_parameters, param, &result); if (opt == -ENOPARAM) { if (strcmp(param->key, "source") == 0) { if (param->type != fs_value_is_string) return invalf(fc, "Non-string source"); if (fc->source) return invalf(fc, "Multiple sources not supported"); fc->source = param->string; param->string = NULL; return 0; } for_each_subsys(ss, i) { if (strcmp(param->key, ss->legacy_name)) continue; if (!cgroup_ssid_enabled(i) || cgroup1_ssid_disabled(i)) return invalfc(fc, "Disabled controller '%s'", param->key); ctx->subsys_mask |= (1 << i); return 0; } return invalfc(fc, "Unknown subsys name '%s'", param->key); } if (opt < 0) return opt; switch (opt) { case Opt_none: /* Explicitly have no subsystems */ ctx->none = true; break; case Opt_all: ctx->all_ss = true; break; case Opt_noprefix: ctx->flags |= CGRP_ROOT_NOPREFIX; break; case Opt_clone_children: ctx->cpuset_clone_children = true; break; case Opt_cpuset_v2_mode: ctx->flags |= CGRP_ROOT_CPUSET_V2_MODE; break; case Opt_xattr: ctx->flags |= CGRP_ROOT_XATTR; break; case Opt_release_agent: /* Specifying two release agents is forbidden */ if (ctx->release_agent) return invalfc(fc, "release_agent respecified"); ctx->release_agent = param->string; param->string = NULL; break; case Opt_name: /* blocked by boot param? */ if (cgroup_no_v1_named) return -ENOENT; /* Can't specify an empty name */ if (!param->size) return invalfc(fc, "Empty name"); if (param->size > MAX_CGROUP_ROOT_NAMELEN - 1) return invalfc(fc, "Name too long"); /* Must match [\w.-]+ */ for (i = 0; i < param->size; i++) { char c = param->string[i]; if (isalnum(c)) continue; if ((c == '.') || (c == '-') || (c == '_')) continue; return invalfc(fc, "Invalid name"); } /* Specifying two names is forbidden */ if (ctx->name) return invalfc(fc, "name respecified"); ctx->name = param->string; param->string = NULL; break; } return 0; }
0
513,208
static void plugin_variables_deinit(struct st_plugin_int *plugin) { for (sys_var *var= plugin->system_vars; var; var= var->next) (*var->test_load)= FALSE; mysql_del_sys_var_chain(plugin->system_vars); }
0
292,234
inbound_foundip (session *sess, char *ip, const message_tags_data *tags_data) { struct hostent *HostAddr; HostAddr = gethostbyname (ip); if (HostAddr) { prefs.dcc_ip = ((struct in_addr *) HostAddr->h_addr)->s_addr; EMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session, inet_ntoa (*((struct in_addr *) HostAddr->h_addr)), NULL, NULL, NULL, 0, tags_data->timestamp); } }
0
442,796
convert_to_network(char *buffer, size_t length) { CURLcode rc; /* translate from the host encoding to the network encoding */ char *input_ptr, *output_ptr; size_t in_bytes, out_bytes; /* open an iconv conversion descriptor if necessary */ if(outbound_cd == (iconv_t)-1) { outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK, CURL_ICONV_CODESET_OF_HOST); if(outbound_cd == (iconv_t)-1) { return CURLE_CONV_FAILED; } } /* call iconv */ input_ptr = output_ptr = buffer; in_bytes = out_bytes = length; rc = iconv(outbound_cd, &input_ptr, &in_bytes, &output_ptr, &out_bytes); if ((rc == -1) || (in_bytes != 0)) { return CURLE_CONV_FAILED; } return CURLE_OK; }
0
215,400
int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *max) { struct page *page; struct address_space *mapping; __be32 *pptr, *curr, *end; u32 mask, start, len, n; __be32 val; int i; len = *max; if (!len) return size; dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len); mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex); mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); pptr = kmap(page); curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32; i = offset % 32; offset &= ~(PAGE_CACHE_BITS - 1); if ((size ^ offset) / PAGE_CACHE_BITS) end = pptr + PAGE_CACHE_BITS / 32; else end = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) / 32; /* scan the first partial u32 for zero bits */ val = *curr; if (~val) { n = be32_to_cpu(val); mask = (1U << 31) >> i; for (; i < 32; mask >>= 1, i++) { if (!(n & mask)) goto found; } } curr++; /* scan complete u32s for the first zero bit */ while (1) { while (curr < end) { val = *curr; if (~val) { n = be32_to_cpu(val); mask = 1 << 31; for (i = 0; i < 32; mask >>= 1, i++) { if (!(n & mask)) goto found; } } curr++; } kunmap(page); offset += PAGE_CACHE_BITS; if (offset >= size) break; page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); curr = pptr = kmap(page); if ((size ^ offset) / PAGE_CACHE_BITS) end = pptr + PAGE_CACHE_BITS / 32; else end = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) / 32; } dprint(DBG_BITMAP, "bitmap full\n"); start = size; goto out; found: start = offset + (curr - pptr) * 32 + i; if (start >= size) { dprint(DBG_BITMAP, "bitmap full\n"); goto out; } /* do any partial u32 at the start */ len = min(size - start, len); while (1) { n |= mask; if (++i >= 32) break; mask >>= 1; if (!--len || n & mask) goto done; } if (!--len) goto done; *curr++ = cpu_to_be32(n); /* do full u32s */ while (1) { while (curr < end) { n = be32_to_cpu(*curr); if (len < 32) goto last; if (n) { len = 32; goto last; } *curr++ = cpu_to_be32(0xffffffff); len -= 32; } set_page_dirty(page); kunmap(page); offset += PAGE_CACHE_BITS; page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); pptr = kmap(page); curr = pptr; end = pptr + PAGE_CACHE_BITS / 32; } last: /* do any partial u32 at end */ mask = 1U << 31; for (i = 0; i < len; i++) { if (n & mask) break; n |= mask; mask >>= 1; } done: *curr = cpu_to_be32(n); set_page_dirty(page); kunmap(page); *max = offset + (curr - pptr) * 32 + i - start; HFSPLUS_SB(sb).free_blocks -= *max; sb->s_dirt = 1; dprint(DBG_BITMAP, "-> %u,%u\n", start, *max); out: mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex); return start; }
1
230,973
eval_under(mrb_state *mrb, mrb_value self, mrb_value blk, struct RClass *c) { struct RProc *p; mrb_callinfo *ci; int nregs; check_block(mrb, blk); ci = mrb->c->ci; if (ci->cci == CINFO_DIRECT) { return mrb_yield_with_class(mrb, blk, 1, &self, self, c); } ci->u.target_class = c; p = mrb_proc_ptr(blk); mrb_vm_ci_proc_set(ci, p); ci->n = 1; ci->nk = 0; ci->mid = ci[-1].mid; if (MRB_PROC_CFUNC_P(p)) { mrb_stack_extend(mrb, 4); mrb->c->ci->stack[0] = self; mrb->c->ci->stack[1] = self; mrb->c->ci->stack[2] = mrb_nil_value(); return MRB_PROC_CFUNC(p)(mrb, self); } nregs = p->body.irep->nregs; if (nregs < 4) nregs = 4; mrb_stack_extend(mrb, nregs); mrb->c->ci->stack[0] = self; mrb->c->ci->stack[1] = self; stack_clear(mrb->c->ci->stack+2, nregs-2); ci = cipush(mrb, 0, 0, NULL, NULL, 0, 0); return self; }
0
318,773
drill_add_drill_hole (gerbv_image_t *image, drill_state_t *state, gerbv_drill_stats_t *stats, gerbv_net_t *curr_net) { gerbv_render_size_t *bbox; double r; /* Add one to drill stats for the current tool */ drill_stats_increment_drill_counter(image->drill_stats->drill_list, state->current_tool); curr_net->next = g_new0(gerbv_net_t, 1); if (curr_net->next == NULL) GERB_FATAL_ERROR("malloc curr_net->next failed in %s()", __FUNCTION__); curr_net = curr_net->next; curr_net->layer = image->layers; curr_net->state = image->states; curr_net->start_x = state->curr_x; curr_net->start_y = state->curr_y; /* KLUDGE. This function isn't allowed to return anything but inches */ if(state->unit == GERBV_UNIT_MM) { curr_net->start_x /= 25.4; curr_net->start_y /= 25.4; /* KLUDGE. All images, regardless of input format, are returned in INCH format */ curr_net->state->unit = GERBV_UNIT_INCH; } curr_net->stop_x = curr_net->start_x - state->origin_x; curr_net->stop_y = curr_net->start_y - state->origin_y; curr_net->aperture = state->current_tool; curr_net->aperture_state = GERBV_APERTURE_STATE_FLASH; /* Check if aperture is set. Ignore the below instead of causing SEGV... */ if(image->aperture[state->current_tool] == NULL) return curr_net; bbox = &curr_net->boundingBox; r = image->aperture[state->current_tool]->parameter[0] / 2; /* Set boundingBox */ bbox->left = curr_net->start_x - r; bbox->right = curr_net->start_x + r; bbox->bottom = curr_net->start_y - r; bbox->top = curr_net->start_y + r; drill_update_image_info_min_max_from_bbox(image->info, bbox); return curr_net; }
0
500,640
int sftp_dir_eof(sftp_dir dir) { return dir->eof; }
0
197,318
void Compute(OpKernelContext* ctx) override { const Tensor& handle = ctx->input(0); const string& name = handle.scalar<tstring>()(); auto session_state = ctx->session_state(); OP_REQUIRES(ctx, session_state != nullptr, errors::FailedPrecondition( "DeleteSessionTensor called on null session state")); OP_REQUIRES_OK(ctx, session_state->DeleteTensor(name)); }
1
369,301
static int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg, unsigned int nr_args, u64 __user *tags) { struct page *last_hpage = NULL; struct io_rsrc_data *data; int i, ret; struct iovec iov; if (ctx->user_bufs) return -EBUSY; if (!nr_args || nr_args > IORING_MAX_REG_BUFFERS) return -EINVAL; ret = io_rsrc_node_switch_start(ctx); if (ret) return ret; ret = io_rsrc_data_alloc(ctx, io_rsrc_buf_put, tags, nr_args, &data); if (ret) return ret; ret = io_buffers_map_alloc(ctx, nr_args); if (ret) { io_rsrc_data_free(data); return ret; } for (i = 0; i < nr_args; i++, ctx->nr_user_bufs++) { ret = io_copy_iov(ctx, &iov, arg, i); if (ret) break; ret = io_buffer_validate(&iov); if (ret) break; if (!iov.iov_base && *io_get_tag_slot(data, i)) { ret = -EINVAL; break; } ret = io_sqe_buffer_register(ctx, &iov, &ctx->user_bufs[i], &last_hpage); if (ret) break; } WARN_ON_ONCE(ctx->buf_data); ctx->buf_data = data; if (ret) __io_sqe_buffers_unregister(ctx); else io_rsrc_node_switch(ctx, NULL); return ret;
0
234,817
static void btrfs_report_missing_device(struct btrfs_fs_info *fs_info, u64 devid, u8 *uuid, bool error) { if (error) btrfs_err_rl(fs_info, "devid %llu uuid %pU is missing", devid, uuid); else btrfs_warn_rl(fs_info, "devid %llu uuid %pU is missing", devid, uuid); }
0
462,302
status_end_id_list(stream * s) { /* HACK: we know that there's at least one character in the buffer. */ if (*s->cursor.w.ptr != '\n') stputs(s, "\"\r\n"); }
0
509,478
bool ha_maria::is_changed() const { return file->state->changed; }
0
196,817
njs_array_convert_to_slow_array(njs_vm_t *vm, njs_array_t *array) { uint32_t i, length; njs_value_t index, value; njs_object_prop_t *prop; njs_set_array(&value, array); array->object.fast_array = 0; length = array->length; for (i = 0; i < length; i++) { if (njs_is_valid(&array->start[i])) { njs_uint32_to_string(&index, i); prop = njs_object_property_add(vm, &value, &index, 0); if (njs_slow_path(prop == NULL)) { return NJS_ERROR; } prop->value = array->start[i]; } } /* GC: release value. */ njs_mp_free(vm->mem_pool, array->start); array->start = NULL; return NJS_OK; }
1
261,988
static void free_bundle_hash_entry(void *freethis) { struct connectbundle *b = (struct connectbundle *) freethis; bundle_destroy(b); }
0
218,809
MagickExport void XProgressMonitorWidget(Display *display,XWindows *windows, const char *task,const MagickOffsetType offset,const MagickSizeType span) { unsigned int width; XEvent event; assert(display != (Display *) NULL); assert(windows != (XWindows *) NULL); assert(task != (const char *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",task); if (span == 0) return; /* Update image windows if there is a pending expose event. */ while (XCheckTypedWindowEvent(display,windows->command.id,Expose,&event)) (void) XCommandWidget(display,windows,(const char *const *) NULL,&event); while (XCheckTypedWindowEvent(display,windows->image.id,Expose,&event)) XRefreshWindow(display,&windows->image,&event); while (XCheckTypedWindowEvent(display,windows->info.id,Expose,&event)) if (monitor_info.text != (char *) NULL) XInfoWidget(display,windows,monitor_info.text); /* Draw progress monitor bar to represent percent completion of a task. */ if ((windows->info.mapped == MagickFalse) || (task != monitor_info.text)) XInfoWidget(display,windows,task); width=(unsigned int) (((offset+1)*(windows->info.width- (2*monitor_info.x)))/span); if (width < monitor_info.width) { monitor_info.raised=MagickTrue; XDrawWidgetText(display,&windows->info,&monitor_info); monitor_info.raised=MagickFalse; } monitor_info.width=width; XDrawWidgetText(display,&windows->info,&monitor_info); (void) XFlush(display); }
0
269,503
static MagickBooleanType DecodeLabImage(Image *image,ExceptionInfo *exception) { CacheView *image_view; MagickBooleanType status; ssize_t y; status=MagickTrue; image_view=AcquireAuthenticCacheView(image,exception); for (y=0; y < (ssize_t) image->rows; y++) { Quantum *magick_restrict q; ssize_t x; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (Quantum *) NULL) { status=MagickFalse; break; } for (x=0; x < (ssize_t) image->columns; x++) { double a, b; a=QuantumScale*GetPixela(image,q)+0.5; if (a > 1.0) a-=1.0; b=QuantumScale*GetPixelb(image,q)+0.5; if (b > 1.0) b-=1.0; SetPixela(image,QuantumRange*a,q); SetPixelb(image,QuantumRange*b,q); q+=GetPixelChannels(image); } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) { status=MagickFalse; break; } } image_view=DestroyCacheView(image_view); return(status); }
0
489,215
int hfsplus_find_cat(struct super_block *sb, u32 cnid, struct hfs_find_data *fd) { hfsplus_cat_entry tmp; int err; u16 type; hfsplus_cat_build_key(sb, fd->search_key, cnid, NULL); err = hfs_brec_read(fd, &tmp, sizeof(hfsplus_cat_entry)); if (err) return err; type = be16_to_cpu(tmp.type); if (type != HFSPLUS_FOLDER_THREAD && type != HFSPLUS_FILE_THREAD) { printk(KERN_ERR "hfs: found bad thread record in catalog\n"); return -EIO; } if (be16_to_cpu(tmp.thread.nodeName.length) > 255) { printk(KERN_ERR "hfs: catalog name length corrupted\n"); return -EIO; } hfsplus_cat_build_key_uni(fd->search_key, be32_to_cpu(tmp.thread.parentID), &tmp.thread.nodeName); return hfs_brec_find(fd); }
0
289,241
static int snd_pcm_oss_nonblock(struct file * file) { spin_lock(&file->f_lock); file->f_flags |= O_NONBLOCK; spin_unlock(&file->f_lock); return 0; }
0
231,694
void deliverDataWithoutErrorCheck( Buf data, bool writes = true, folly::SocketAddress* peer = nullptr) { data->coalesce(); server->onNetworkData( peer == nullptr ? clientAddr : *peer, NetworkData(std::move(data), Clock::now())); if (writes) { loopForWrites(); } }
0
231,650
TEST_P( QuicServerTransportPendingDataTest, TestNoCipherProcessPendingOneRttData) { server->getNonConstConn().qLogger = std::make_shared<quic::FileQLogger>(VantagePoint::Server); recvClientHello(); auto data = IOBuf::copyBuffer("bad data"); StreamId streamId = 2; // Write packet with zero rtt keys auto packetData = packetToBuf(createStreamPacket( *clientConnectionId, *server->getConn().serverConnectionId, clientNextAppDataPacketNum++, streamId, *data, 0 /* cipherOverhead */, 0 /* largestAcked */, folly::none, false)); deliverData(std::move(packetData)); EXPECT_EQ(server->getConn().streamManager->streamCount(), 0); EXPECT_EQ(server->getConn().pendingOneRttData->size(), 1); recvClientFinished(); EXPECT_EQ(server->getConn().streamManager->streamCount(), 1); EXPECT_EQ(server->getConn().pendingZeroRttData, nullptr); EXPECT_EQ(server->getConn().pendingOneRttData, nullptr); EXPECT_EQ( server->getConn().qLogger->scid, server->getConn().serverConnectionId); }
0
301,343
static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, uint32 share_mode, uint32 access_mask) { START_PROFILE(syscall_kernel_flock); kernel_flock(fsp->fh->fd, share_mode, access_mask); END_PROFILE(syscall_kernel_flock); return 0; }
0
402,669
long verbosity(void) { if (!verbose) return 0; return *verbose; }
0
500,671
static sftp_attributes sftp_xstat(sftp_session sftp, const char *path, int param) { sftp_status_message status = NULL; sftp_message msg = NULL; ssh_string pathstr; ssh_buffer buffer; uint32_t id; buffer = ssh_buffer_new(); if (buffer == NULL) { ssh_set_error_oom(sftp->session); return NULL; } pathstr = ssh_string_from_char(path); if (pathstr == NULL) { ssh_set_error_oom(sftp->session); ssh_buffer_free(buffer); return NULL; } id = sftp_get_new_id(sftp); if (buffer_add_u32(buffer, id) < 0 || buffer_add_ssh_string(buffer, pathstr) < 0) { ssh_set_error_oom(sftp->session); ssh_buffer_free(buffer); ssh_string_free(pathstr); return NULL; } if (sftp_packet_write(sftp, param, buffer) < 0) { ssh_buffer_free(buffer); ssh_string_free(pathstr); return NULL; } ssh_buffer_free(buffer); ssh_string_free(pathstr); while (msg == NULL) { if (sftp_read_and_dispatch(sftp) < 0) { return NULL; } msg = sftp_dequeue(sftp, id); } if (msg->packet_type == SSH_FXP_ATTRS) { sftp_attributes attr = sftp_parse_attr(sftp, msg->payload, 0); sftp_message_free(msg); return attr; } else if (msg->packet_type == SSH_FXP_STATUS) { status = parse_status_msg(msg); sftp_message_free(msg); if (status == NULL) { return NULL; } sftp_set_error(sftp, status->status); ssh_set_error(sftp->session, SSH_REQUEST_DENIED, "SFTP server: %s", status->errormsg); status_msg_free(status); return NULL; } ssh_set_error(sftp->session, SSH_FATAL, "Received mesg %d during stat()", msg->packet_type); sftp_message_free(msg); return NULL; }
0
508,383
Locked_tables_list::init_locked_tables(THD *thd) { DBUG_ASSERT(thd->locked_tables_mode == LTM_NONE); DBUG_ASSERT(m_locked_tables == NULL); DBUG_ASSERT(m_reopen_array == NULL); DBUG_ASSERT(m_locked_tables_count == 0); for (TABLE *table= thd->open_tables; table; table= table->next, m_locked_tables_count++) { TABLE_LIST *src_table_list= table->pos_in_table_list; char *db, *table_name, *alias; size_t db_len= table->s->db.length; size_t table_name_len= table->s->table_name.length; size_t alias_len= table->alias.length(); TABLE_LIST *dst_table_list; if (! multi_alloc_root(&m_locked_tables_root, &dst_table_list, sizeof(*dst_table_list), &db, db_len + 1, &table_name, table_name_len + 1, &alias, alias_len + 1, NullS)) { reset(); return TRUE; } memcpy(db, table->s->db.str, db_len + 1); memcpy(table_name, table->s->table_name.str, table_name_len + 1); strmake(alias, table->alias.ptr(), alias_len); dst_table_list->init_one_table(db, db_len, table_name, table_name_len, alias, table->reginfo.lock_type); dst_table_list->table= table; dst_table_list->mdl_request.ticket= src_table_list->mdl_request.ticket; /* Link last into the list of tables */ *(dst_table_list->prev_global= m_locked_tables_last)= dst_table_list; m_locked_tables_last= &dst_table_list->next_global; table->pos_in_locked_tables= dst_table_list; } if (m_locked_tables_count) { /** Allocate an auxiliary array to pass to mysql_lock_tables() in reopen_tables(). reopen_tables() is a critical path and we don't want to complicate it with extra allocations. */ m_reopen_array= (TABLE_LIST**)alloc_root(&m_locked_tables_root, sizeof(TABLE_LIST*) * (m_locked_tables_count+1)); if (m_reopen_array == NULL) { reset(); return TRUE; } } TRANSACT_TRACKER(add_trx_state(thd, TX_LOCKED_TABLES)); thd->enter_locked_tables_mode(LTM_LOCK_TABLES); return FALSE; }
0
267,864
void SingleFromSingle(const size_t xsize, const pixel_type* const JXL_RESTRICT row_in, const float factor, Image3F* decoded, size_t c, size_t y, Rect& rect) { JXL_DASSERT(xsize <= rect.xsize()); const HWY_FULL(float) df; const Rebind<pixel_type, HWY_FULL(float)> di; // assumes pixel_type <= float float* const JXL_RESTRICT row_out = rect.PlaneRow(decoded, c, y); const auto factor_v = Set(df, factor); for (size_t x = 0; x < xsize; x += Lanes(di)) { const auto in = Load(di, row_in + x); const auto out = ConvertTo(df, in) * factor_v; Store(out, df, row_out + x); } }
0
339,717
static double ratio (Bigint *a, Bigint *b) { _double da, db; int k, ka, kb; value(da) = b2d(a, &ka); value(db) = b2d(b, &kb); #ifdef Pack_32 k = ka - kb + 32*(a->wds - b->wds); #else k = ka - kb + 16*(a->wds - b->wds); #endif #ifdef IBM if (k > 0) { word0(da) += (k >> 2)*Exp_msk1; if (k &= 3) { da *= 1 << k; } } else { k = -k; word0(db) += (k >> 2)*Exp_msk1; if (k &= 3) db *= 1 << k; } #else if (k > 0) { word0(da) += k*Exp_msk1; } else { k = -k; word0(db) += k*Exp_msk1; } #endif return value(da) / value(db); }
0
267,867
void RgbFromSingle(const size_t xsize, const pixel_type* const JXL_RESTRICT row_in, const float factor, Image3F* decoded, size_t /*c*/, size_t y, Rect& rect) { JXL_DASSERT(xsize <= rect.xsize()); const HWY_FULL(float) df; const Rebind<pixel_type, HWY_FULL(float)> di; // assumes pixel_type <= float float* const JXL_RESTRICT row_out_r = rect.PlaneRow(decoded, 0, y); float* const JXL_RESTRICT row_out_g = rect.PlaneRow(decoded, 1, y); float* const JXL_RESTRICT row_out_b = rect.PlaneRow(decoded, 2, y); const auto factor_v = Set(df, factor); for (size_t x = 0; x < xsize; x += Lanes(di)) { const auto in = Load(di, row_in + x); const auto out = ConvertTo(df, in) * factor_v; Store(out, df, row_out_r + x); Store(out, df, row_out_g + x); Store(out, df, row_out_b + x); } }
0
244,078
GF_Err stvi_box_read(GF_Box *s, GF_BitStream *bs) { GF_StereoVideoBox *ptr = (GF_StereoVideoBox *)s; ISOM_DECREASE_SIZE(ptr, 12); gf_bs_read_int(bs, 30); ptr->single_view_allowed = gf_bs_read_int(bs, 2); ptr->stereo_scheme = gf_bs_read_u32(bs); ptr->sit_len = gf_bs_read_u32(bs); ISOM_DECREASE_SIZE(ptr, ptr->sit_len); ptr->stereo_indication_type = gf_malloc(sizeof(char)*ptr->sit_len); if (!ptr->stereo_indication_type) return GF_OUT_OF_MEM; gf_bs_read_data(bs, ptr->stereo_indication_type, ptr->sit_len); return GF_OK; }
0
512,251
bool Arg_comparator::set_cmp_func_real() { if ((((*a)->result_type() == DECIMAL_RESULT && !(*a)->const_item() && (*b)->result_type() == STRING_RESULT && (*b)->const_item()) || ((*b)->result_type() == DECIMAL_RESULT && !(*b)->const_item() && (*a)->result_type() == STRING_RESULT && (*a)->const_item()))) { /* <non-const decimal expression> <cmp> <const string expression> or <const string expression> <cmp> <non-const decimal expression> Do comparison as decimal rather than float, in order not to lose precision. */ m_compare_handler= &type_handler_newdecimal; return set_cmp_func_decimal(); } THD *thd= current_thd; func= is_owner_equal_func() ? &Arg_comparator::compare_e_real : &Arg_comparator::compare_real; if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC) { precision= 5 / log_10[MY_MAX((*a)->decimals, (*b)->decimals) + 1]; if (func == &Arg_comparator::compare_real) func= &Arg_comparator::compare_real_fixed; else if (func == &Arg_comparator::compare_e_real) func= &Arg_comparator::compare_e_real_fixed; } a= cache_converted_constant(thd, a, &a_cache, compare_type_handler()); b= cache_converted_constant(thd, b, &b_cache, compare_type_handler()); return false; }
0
502,712
int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx, unsigned int sid_ctx_len) { if (sid_ctx_len > SSL_MAX_SID_CTX_LENGTH) { SSLerr(SSL_F_SSL_SESSION_SET1_ID_CONTEXT, SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); return 0; } s->sid_ctx_length = sid_ctx_len; memcpy(s->sid_ctx, sid_ctx, sid_ctx_len); return 1; }
0
328,895
R_API RBinJavaField *r_bin_java_get_method_code_attribute_with_addr(RBinJavaObj *bin, ut64 addr) { RListIter *iter = NULL, *iter_tmp = NULL; RBinJavaField *fm_type, *res = NULL; if (!bin && R_BIN_JAVA_GLOBAL_BIN) { bin = R_BIN_JAVA_GLOBAL_BIN; } if (!bin) { eprintf ("Attempting to analyse function when the R_BIN_JAVA_GLOBAL_BIN has not been set.\n"); return NULL; } r_list_foreach_safe (bin->methods_list, iter, iter_tmp, fm_type) { ut64 offset = r_bin_java_get_method_code_offset (fm_type) + bin->loadaddr, size = r_bin_java_get_method_code_size (fm_type); if (addr >= offset && addr <= size + offset) { res = fm_type; } } return res; }
0
512,989
const my_decimal *const_ptr_my_decimal() const { return &decimal_value; }
0
211,845
static Image *ReadTIFFImage(const ImageInfo *image_info, ExceptionInfo *exception) { #define MaxPixelChannels 32 #define ThrowTIFFException(severity,message) \ { \ if (pixel_info != (MemoryInfo *) NULL) \ pixel_info=RelinquishVirtualMemory(pixel_info); \ if (quantum_info != (QuantumInfo *) NULL) \ quantum_info=DestroyQuantumInfo(quantum_info); \ TIFFClose(tiff); \ ThrowReaderException(severity,message); \ } const char *option; float *chromaticity = (float *) NULL, x_position, y_position, x_resolution, y_resolution; Image *image; int tiff_status = 0; MagickBooleanType more_frames; MagickStatusType status; MemoryInfo *pixel_info = (MemoryInfo *) NULL; QuantumInfo *quantum_info; QuantumType quantum_type; size_t number_pixels; ssize_t i, scanline_size, y; TIFF *tiff; TIFFMethodType method; uint16 compress_tag = 0, bits_per_sample = 0, endian = 0, extra_samples = 0, interlace = 0, max_sample_value = 0, min_sample_value = 0, orientation = 0, pages = 0, photometric = 0, *sample_info = NULL, sample_format = 0, samples_per_pixel = 0, units = 0, value = 0; uint32 height, rows_per_strip, width; unsigned char *pixels; void *sans[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /* Open image. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); if (IsEventLogging() != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } (void) SetMagickThreadValue(tiff_exception,exception); tiff=TIFFClientOpen(image->filename,"rb",(thandle_t) image,TIFFReadBlob, TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,TIFFGetBlobSize,TIFFMapBlob, TIFFUnmapBlob); if (tiff == (TIFF *) NULL) { if (exception->severity == UndefinedException) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); image=DestroyImageList(image); return((Image *) NULL); } if (exception->severity > ErrorException) { TIFFClose(tiff); image=DestroyImageList(image); return((Image *) NULL); } if (image_info->number_scenes != 0) { /* Generate blank images for subimage specification (e.g. image.tif[4]. We need to check the number of directores because it is possible that the subimage(s) are stored in the photoshop profile. */ if (image_info->scene < (size_t)TIFFNumberOfDirectories(tiff)) { for (i=0; i < (ssize_t) image_info->scene; i++) { status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse; if (status == MagickFalse) { TIFFClose(tiff); image=DestroyImageList(image); return((Image *) NULL); } AcquireNextImage(image_info,image); if (GetNextImageInList(image) == (Image *) NULL) { TIFFClose(tiff); image=DestroyImageList(image); return((Image *) NULL); } image=SyncNextImageInList(image); } } } more_frames=MagickTrue; do { /* TIFFPrintDirectory(tiff,stdout,MagickFalse); */ photometric=PHOTOMETRIC_RGB; if ((TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&width) != 1) || (TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&height) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric,sans) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag,sans) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&endian,sans) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_PLANARCONFIG,&interlace,sans) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,&samples_per_pixel,sans) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,&bits_per_sample,sans) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLEFORMAT,&sample_format,sans) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_MINSAMPLEVALUE,&min_sample_value,sans) != 1) || (TIFFGetFieldDefaulted(tiff,TIFFTAG_MAXSAMPLEVALUE,&max_sample_value,sans) != 1)) { TIFFClose(tiff); ThrowReaderException(CorruptImageError,"ImproperImageHeader"); } if (((sample_format != SAMPLEFORMAT_IEEEFP) || (bits_per_sample != 64)) && ((bits_per_sample <= 0) || (bits_per_sample > 32))) { TIFFClose(tiff); ThrowReaderException(CorruptImageError,"UnsupportedBitsPerPixel"); } if (samples_per_pixel > MaxPixelChannels) { TIFFClose(tiff); ThrowReaderException(CorruptImageError,"MaximumChannelsExceeded"); } if (sample_format == SAMPLEFORMAT_IEEEFP) (void) SetImageProperty(image,"quantum:format","floating-point"); switch (photometric) { case PHOTOMETRIC_MINISBLACK: { (void) SetImageProperty(image,"tiff:photometric","min-is-black"); break; } case PHOTOMETRIC_MINISWHITE: { (void) SetImageProperty(image,"tiff:photometric","min-is-white"); break; } case PHOTOMETRIC_PALETTE: { (void) SetImageProperty(image,"tiff:photometric","palette"); break; } case PHOTOMETRIC_RGB: { (void) SetImageProperty(image,"tiff:photometric","RGB"); break; } case PHOTOMETRIC_CIELAB: { (void) SetImageProperty(image,"tiff:photometric","CIELAB"); break; } case PHOTOMETRIC_LOGL: { (void) SetImageProperty(image,"tiff:photometric","CIE Log2(L)"); break; } case PHOTOMETRIC_LOGLUV: { (void) SetImageProperty(image,"tiff:photometric","LOGLUV"); break; } #if defined(PHOTOMETRIC_MASK) case PHOTOMETRIC_MASK: { (void) SetImageProperty(image,"tiff:photometric","MASK"); break; } #endif case PHOTOMETRIC_SEPARATED: { (void) SetImageProperty(image,"tiff:photometric","separated"); break; } case PHOTOMETRIC_YCBCR: { (void) SetImageProperty(image,"tiff:photometric","YCBCR"); break; } default: { (void) SetImageProperty(image,"tiff:photometric","unknown"); break; } } if (image->debug != MagickFalse) { (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Geometry: %ux%u", (unsigned int) width,(unsigned int) height); (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Interlace: %u", interlace); (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Bits per sample: %u",bits_per_sample); (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Min sample value: %u",min_sample_value); (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Max sample value: %u",max_sample_value); (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Photometric " "interpretation: %s",GetImageProperty(image,"tiff:photometric")); } image->columns=(size_t) width; image->rows=(size_t) height; image->depth=(size_t) bits_per_sample; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Image depth: %.20g", (double) image->depth); image->endian=MSBEndian; if (endian == FILLORDER_LSB2MSB) image->endian=LSBEndian; #if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN) if (TIFFIsBigEndian(tiff) == 0) { (void) SetImageProperty(image,"tiff:endian","lsb"); image->endian=LSBEndian; } else { (void) SetImageProperty(image,"tiff:endian","msb"); image->endian=MSBEndian; } #endif if ((photometric == PHOTOMETRIC_MINISBLACK) || (photometric == PHOTOMETRIC_MINISWHITE)) image->colorspace=GRAYColorspace; if (photometric == PHOTOMETRIC_SEPARATED) image->colorspace=CMYKColorspace; if (photometric == PHOTOMETRIC_CIELAB) image->colorspace=LabColorspace; if ((photometric == PHOTOMETRIC_YCBCR) && (compress_tag != COMPRESSION_OJPEG) && (compress_tag != COMPRESSION_JPEG)) image->colorspace=YCbCrColorspace; status=TIFFGetProfiles(tiff,image); if (status == MagickFalse) { TIFFClose(tiff); InheritException(exception,&image->exception); return(DestroyImageList(image)); } status=TIFFGetProperties(tiff,image); if (status == MagickFalse) { TIFFClose(tiff); InheritException(exception,&image->exception); return(DestroyImageList(image)); } option=GetImageOption(image_info,"tiff:exif-properties"); if ((option == (const char *) NULL) || (IsMagickTrue(option) != MagickFalse)) (void) TIFFGetEXIFProperties(tiff,image); option=GetImageOption(image_info,"tiff:gps-properties"); if ((option == (const char *) NULL) || (IsMagickTrue(option) != MagickFalse)) (void) TIFFGetGPSProperties(tiff,image); if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution,sans) == 1) && (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution,sans) == 1)) { image->x_resolution=x_resolution; image->y_resolution=y_resolution; } if (TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units,sans,sans) == 1) { if (units == RESUNIT_INCH) image->units=PixelsPerInchResolution; if (units == RESUNIT_CENTIMETER) image->units=PixelsPerCentimeterResolution; } if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position,sans) == 1) && (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position,sans) == 1)) { image->page.x=CastDoubleToLong(ceil(x_position* image->x_resolution-0.5)); image->page.y=CastDoubleToLong(ceil(y_position* image->y_resolution-0.5)); } if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation,sans) == 1) image->orientation=(OrientationType) orientation; if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1) { if ((chromaticity != (float *) NULL) && (*chromaticity != 0.0)) { image->chromaticity.white_point.x=chromaticity[0]; image->chromaticity.white_point.y=chromaticity[1]; } } if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1) { if ((chromaticity != (float *) NULL) && (*chromaticity != 0.0)) { image->chromaticity.red_primary.x=chromaticity[0]; image->chromaticity.red_primary.y=chromaticity[1]; image->chromaticity.green_primary.x=chromaticity[2]; image->chromaticity.green_primary.y=chromaticity[3]; image->chromaticity.blue_primary.x=chromaticity[4]; image->chromaticity.blue_primary.y=chromaticity[5]; } } #if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919) if ((compress_tag != COMPRESSION_NONE) && (TIFFIsCODECConfigured(compress_tag) == 0)) { TIFFClose(tiff); ThrowReaderException(CoderError,"CompressNotSupported"); } #endif switch (compress_tag) { case COMPRESSION_NONE: image->compression=NoCompression; break; case COMPRESSION_CCITTFAX3: image->compression=FaxCompression; break; case COMPRESSION_CCITTFAX4: image->compression=Group4Compression; break; case COMPRESSION_JPEG: { image->compression=JPEGCompression; #if defined(JPEG_SUPPORT) { char sampling_factor[MaxTextExtent]; int tiff_status; uint16 horizontal, vertical; tiff_status=TIFFGetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,&horizontal, &vertical); if (tiff_status == 1) { (void) FormatLocaleString(sampling_factor,MaxTextExtent,"%dx%d", horizontal,vertical); (void) SetImageProperty(image,"jpeg:sampling-factor", sampling_factor); (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Sampling Factors: %s",sampling_factor); } } #endif break; } case COMPRESSION_OJPEG: image->compression=JPEGCompression; break; #if defined(COMPRESSION_LZMA) case COMPRESSION_LZMA: image->compression=LZMACompression; break; #endif case COMPRESSION_LZW: image->compression=LZWCompression; break; case COMPRESSION_DEFLATE: image->compression=ZipCompression; break; case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break; #if defined(COMPRESSION_WEBP) case COMPRESSION_WEBP: image->compression=WebPCompression; break; #endif #if defined(COMPRESSION_ZSTD) case COMPRESSION_ZSTD: image->compression=ZstdCompression; break; #endif default: image->compression=RLECompression; break; } quantum_info=(QuantumInfo *) NULL; if ((photometric == PHOTOMETRIC_PALETTE) && (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize)) { size_t colors; colors=(size_t) GetQuantumRange(bits_per_sample)+1; if (AcquireImageColormap(image,colors) == MagickFalse) { TIFFClose(tiff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } } if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages,sans) == 1) image->scene=value; if (image->storage_class == PseudoClass) { int tiff_status; size_t range; uint16 *blue_colormap = (uint16 *) NULL, *green_colormap = (uint16 *) NULL, *red_colormap = (uint16 *) NULL; /* Initialize colormap. */ tiff_status=TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap, &green_colormap,&blue_colormap); if (tiff_status == 1) { if ((red_colormap != (uint16 *) NULL) && (green_colormap != (uint16 *) NULL) && (blue_colormap != (uint16 *) NULL)) { range=255; /* might be old style 8-bit colormap */ for (i=0; i < (ssize_t) image->colors; i++) if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) || (blue_colormap[i] >= 256)) { range=65535; break; } for (i=0; i < (ssize_t) image->colors; i++) { image->colormap[i].red=ClampToQuantum(((double) QuantumRange*red_colormap[i])/range); image->colormap[i].green=ClampToQuantum(((double) QuantumRange*green_colormap[i])/range); image->colormap[i].blue=ClampToQuantum(((double) QuantumRange*blue_colormap[i])/range); } } } } if (image_info->ping != MagickFalse) { if (image_info->number_scenes != 0) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; goto next_tiff_frame; } status=SetImageExtent(image,image->columns,image->rows); if (status == MagickFalse) { TIFFClose(tiff); InheritException(exception,&image->exception); return(DestroyImageList(image)); } status=SetImageColorspace(image,image->colorspace); status&=ResetImagePixels(image,exception); if (status == MagickFalse) { TIFFClose(tiff); InheritException(exception,&image->exception); return(DestroyImageList(image)); } /* Allocate memory for the image and pixel buffer. */ quantum_info=AcquireQuantumInfo(image_info,image); if (quantum_info == (QuantumInfo *) NULL) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); if (sample_format == SAMPLEFORMAT_UINT) status=SetQuantumFormat(image,quantum_info,UnsignedQuantumFormat); if (sample_format == SAMPLEFORMAT_INT) status=SetQuantumFormat(image,quantum_info,SignedQuantumFormat); if (sample_format == SAMPLEFORMAT_IEEEFP) status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat); if (status == MagickFalse) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); status=MagickTrue; switch (photometric) { case PHOTOMETRIC_MINISBLACK: { quantum_info->min_is_white=MagickFalse; break; } case PHOTOMETRIC_MINISWHITE: { quantum_info->min_is_white=MagickTrue; break; } default: break; } extra_samples=0; tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples, &sample_info,sans); if (tiff_status == 1) { (void) SetImageProperty(image,"tiff:alpha","unspecified"); if (extra_samples == 0) { if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB)) image->matte=MagickTrue; } else for (i=0; i < extra_samples; i++) { image->matte=MagickTrue; if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA) { SetQuantumAlphaType(quantum_info,AssociatedQuantumAlpha); (void) SetImageProperty(image,"tiff:alpha","associated"); } else if (sample_info[i] == EXTRASAMPLE_UNASSALPHA) { SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha); (void) SetImageProperty(image,"tiff:alpha","unassociated"); } } } if (image->matte != MagickFalse) (void) SetImageAlphaChannel(image,OpaqueAlphaChannel); method=ReadGenericMethod; rows_per_strip=(uint32) image->rows; if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1) { char value[MaxTextExtent]; (void) FormatLocaleString(value,MaxTextExtent,"%u",(unsigned int) rows_per_strip); (void) SetImageProperty(image,"tiff:rows-per-strip",value); method=ReadStripMethod; if (rows_per_strip > (uint32) image->rows) rows_per_strip=(uint32) image->rows; } if (TIFFIsTiled(tiff) != MagickFalse) { uint32 columns, rows; if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) || (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1)) ThrowTIFFException(CoderError,"ImageIsNotTiled"); if ((AcquireMagickResource(WidthResource,columns) == MagickFalse) || (AcquireMagickResource(HeightResource,rows) == MagickFalse)) ThrowTIFFException(ImageError,"WidthOrHeightExceedsLimit"); method=ReadTileMethod; } if ((photometric == PHOTOMETRIC_LOGLUV) || (compress_tag == COMPRESSION_CCITTFAX3)) method=ReadGenericMethod; if (image->compression == JPEGCompression) method=GetJPEGMethod(image,tiff,photometric,bits_per_sample, samples_per_pixel); quantum_info->endian=LSBEndian; scanline_size=TIFFScanlineSize(tiff); if (scanline_size <= 0) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); number_pixels=MagickMax((MagickSizeType) image->columns*samples_per_pixel* pow(2.0,ceil(log(bits_per_sample)/log(2.0))),image->columns* rows_per_strip); if ((double) scanline_size > 1.5*number_pixels) ThrowTIFFException(CorruptImageError,"CorruptImage"); number_pixels=MagickMax((MagickSizeType) scanline_size,number_pixels); pixel_info=AcquireVirtualMemory(number_pixels,sizeof(uint32)); if (pixel_info == (MemoryInfo *) NULL) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); (void) ResetMagickMemory(pixels,0,number_pixels*sizeof(uint32)); quantum_type=GrayQuantum; if (image->storage_class == PseudoClass) quantum_type=IndexQuantum; if (interlace != PLANARCONFIG_SEPARATE) { size_t pad; pad=(size_t) MagickMax((ssize_t) samples_per_pixel-1,0); if (image->matte != MagickFalse) { if (image->storage_class == PseudoClass) quantum_type=IndexAlphaQuantum; else quantum_type=samples_per_pixel == 1 ? AlphaQuantum : GrayAlphaQuantum; } if ((samples_per_pixel > 2) && (interlace != PLANARCONFIG_SEPARATE)) { quantum_type=RGBQuantum; pad=(size_t) MagickMax((ssize_t) samples_per_pixel+ extra_samples-3,0); if (image->matte != MagickFalse) { quantum_type=RGBAQuantum; pad=(size_t) MagickMax((ssize_t) samples_per_pixel+ extra_samples-4,0); } if (image->colorspace == CMYKColorspace) { quantum_type=CMYKQuantum; pad=(size_t) MagickMax((ssize_t) samples_per_pixel+ extra_samples-4,0); if (image->matte != MagickFalse) { quantum_type=CMYKAQuantum; pad=(size_t) MagickMax((ssize_t) samples_per_pixel+ extra_samples-5,0); } } status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3)); if (status == MagickFalse) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); } } switch (method) { case ReadYCCKMethod: { /* Convert YCC TIFF image. */ for (y=0; y < (ssize_t) image->rows; y++) { int status; IndexPacket *indexes; PixelPacket *magick_restrict q; ssize_t x; unsigned char *p; status=TIFFReadPixels(tiff,0,y,(char *) pixels); if (status == -1) break; q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; indexes=GetAuthenticIndexQueue(image); p=pixels; for (x=0; x < (ssize_t) image->columns; x++) { SetPixelCyan(q,ScaleCharToQuantum(ClampYCC((double) *p+ (1.402*(double) *(p+2))-179.456))); SetPixelMagenta(q,ScaleCharToQuantum(ClampYCC((double) *p- (0.34414*(double) *(p+1))-(0.71414*(double ) *(p+2))+ 135.45984))); SetPixelYellow(q,ScaleCharToQuantum(ClampYCC((double) *p+ (1.772*(double) *(p+1))-226.816))); SetPixelBlack(indexes+x,ScaleCharToQuantum((unsigned char)*(p+3))); q++; p+=4; } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } break; } case ReadStripMethod: { unsigned char *p; size_t extent; ssize_t stride, strip_id; tsize_t strip_size; unsigned char *strip_pixels; /* Convert stripped TIFF image. */ extent=4*(samples_per_pixel+1)*TIFFStripSize(tiff); strip_pixels=(unsigned char *) AcquireQuantumMemory(extent, sizeof(*strip_pixels)); if (strip_pixels == (unsigned char *) NULL) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); (void) memset(strip_pixels,0,extent*sizeof(*strip_pixels)); stride=TIFFVStripSize(tiff,1); strip_id=0; p=strip_pixels; for (i=0; i < (ssize_t) samples_per_pixel; i++) { size_t rows_remaining; switch (i) { case 0: break; case 1: quantum_type=GreenQuantum; break; case 2: quantum_type=BlueQuantum; break; case 3: { quantum_type=AlphaQuantum; if (image->colorspace == CMYKColorspace) quantum_type=BlackQuantum; break; } case 4: quantum_type=AlphaQuantum; break; default: break; } rows_remaining=0; for (y=0; y < (ssize_t) image->rows; y++) { PixelPacket *magick_restrict q; q=GetAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; if (rows_remaining == 0) { strip_size=TIFFReadEncodedStrip(tiff,strip_id,strip_pixels, TIFFStripSize(tiff)); if (strip_size == -1) break; rows_remaining=rows_per_strip; if ((y+rows_per_strip) > (ssize_t) image->rows) rows_remaining=(rows_per_strip-(y+rows_per_strip- image->rows)); p=strip_pixels; strip_id++; } (void) ImportQuantumPixels(image,(CacheView *) NULL, quantum_info,quantum_type,p,exception); p+=stride; rows_remaining--; if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } if ((samples_per_pixel > 1) && (interlace != PLANARCONFIG_SEPARATE)) break; } strip_pixels=(unsigned char *) RelinquishMagickMemory(strip_pixels); break; } case ReadTileMethod: { unsigned char *p; size_t extent; uint32 columns, rows; unsigned char *tile_pixels; /* Convert tiled TIFF image. */ if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) || (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1)) ThrowTIFFException(CoderError,"ImageIsNotTiled"); number_pixels=(MagickSizeType) columns*rows; if (HeapOverflowSanityCheck(rows,sizeof(*tile_pixels)) != MagickFalse) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); extent=4*(samples_per_pixel+1)*MagickMax(rows*TIFFTileRowSize(tiff), TIFFTileSize(tiff)); tile_pixels=(unsigned char *) AcquireQuantumMemory(extent, sizeof(*tile_pixels)); if (tile_pixels == (unsigned char *) NULL) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); (void) memset(tile_pixels,0,extent*sizeof(*tile_pixels)); for (i=0; i < (ssize_t) samples_per_pixel; i++) { switch (i) { case 0: break; case 1: quantum_type=GreenQuantum; break; case 2: quantum_type=BlueQuantum; break; case 3: { quantum_type=AlphaQuantum; if (image->colorspace == CMYKColorspace) quantum_type=BlackQuantum; break; } case 4: quantum_type=AlphaQuantum; break; default: break; } for (y=0; y < (ssize_t) image->rows; y+=rows) { ssize_t x; size_t rows_remaining; rows_remaining=image->rows-y; if ((ssize_t) (y+rows) < (ssize_t) image->rows) rows_remaining=rows; for (x=0; x < (ssize_t) image->columns; x+=columns) { size_t columns_remaining, row; columns_remaining=image->columns-x; if ((ssize_t) (x+columns) < (ssize_t) image->columns) columns_remaining=columns; tiff_status=TIFFReadTile(tiff,tile_pixels,(uint32) x,(uint32) y, 0,i); if (tiff_status == -1) break; p=tile_pixels; for (row=0; row < rows_remaining; row++) { PixelPacket *magick_restrict q; q=GetAuthenticPixels(image,x,y+row,columns_remaining,1, exception); if (q == (PixelPacket *) NULL) break; (void) ImportQuantumPixels(image,(CacheView *) NULL, quantum_info,quantum_type,p,exception); p+=TIFFTileRowSize(tiff); if (SyncAuthenticPixels(image,exception) == MagickFalse) break; } } } if ((samples_per_pixel > 1) && (interlace != PLANARCONFIG_SEPARATE)) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) i, samples_per_pixel); if (status == MagickFalse) break; } } tile_pixels=(unsigned char *) RelinquishMagickMemory(tile_pixels); break; } case ReadGenericMethod: default: { MemoryInfo *generic_info = (MemoryInfo *) NULL; uint32 *p; uint32 *pixels; /* Convert generic TIFF image. */ if (HeapOverflowSanityCheck(image->rows,sizeof(*pixels)) != MagickFalse) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); number_pixels=(MagickSizeType) image->columns*image->rows; generic_info=AcquireVirtualMemory(number_pixels,sizeof(*pixels)); if (generic_info == (MemoryInfo *) NULL) ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); pixels=(uint32 *) GetVirtualMemoryBlob(generic_info); tiff_status=TIFFReadRGBAImage(tiff,(uint32) image->columns,(uint32) image->rows,(uint32 *) pixels,0); if (tiff_status == -1) { generic_info=RelinquishVirtualMemory(generic_info); break; } p=pixels+(image->columns*image->rows)-1; for (y=0; y < (ssize_t) image->rows; y++) { ssize_t x; PixelPacket *magick_restrict q; q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; q+=image->columns-1; for (x=0; x < (ssize_t) image->columns; x++) { SetPixelRed(q,ScaleCharToQuantum((unsigned char) TIFFGetR(*p))); SetPixelGreen(q,ScaleCharToQuantum((unsigned char) TIFFGetG(*p))); SetPixelBlue(q,ScaleCharToQuantum((unsigned char) TIFFGetB(*p))); if (image->matte == MagickFalse) SetPixelOpacity(q,OpaqueOpacity); else SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) TIFFGetA(*p))); p--; q--; } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } generic_info=RelinquishVirtualMemory(generic_info); break; } } pixel_info=RelinquishVirtualMemory(pixel_info); SetQuantumImageType(image,quantum_type); next_tiff_frame: if (quantum_info != (QuantumInfo *) NULL) quantum_info=DestroyQuantumInfo(quantum_info); if (tiff_status == -1) { status=MagickFalse; break; } if (photometric == PHOTOMETRIC_CIELAB) DecodeLabImage(image,exception); if ((photometric == PHOTOMETRIC_LOGL) || (photometric == PHOTOMETRIC_MINISBLACK) || (photometric == PHOTOMETRIC_MINISWHITE)) { image->type=GrayscaleType; if (bits_per_sample == 1) image->type=BilevelType; } /* Proceed to next image. */ if (image_info->number_scenes != 0) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; more_frames=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse; if (more_frames != MagickFalse) { /* Allocate next image structure. */ AcquireNextImage(image_info,image); if (GetNextImageInList(image) == (Image *) NULL) { status=MagickFalse; break; } image=SyncNextImageInList(image); status=SetImageProgress(image,LoadImagesTag,image->scene-1, image->scene); if (status == MagickFalse) break; } } while ((status != MagickFalse) && (more_frames != MagickFalse)); TIFFClose(tiff); if ((image_info->number_scenes != 0) && (image_info->scene >= GetImageListLength(image))) status=MagickFalse; if (status == MagickFalse) return(DestroyImageList(image)); TIFFReadPhotoshopLayers(image_info,image,exception); return(GetFirstImageInList(image)); }
1
386,509
void DL_Dxf::addSolid(DL_CreationInterface* creationInterface) { DL_SolidData sd; for (int k = 0; k < 4; k++) { sd.x[k] = getRealValue(10 + k, 0.0); sd.y[k] = getRealValue(20 + k, 0.0); sd.z[k] = getRealValue(30 + k, 0.0); } creationInterface->addSolid(sd); }
0
445,894
file_list_drag_begin (GtkWidget *widget, GdkDragContext *context, gpointer data) { FrWindow *window = data; debug (DEBUG_INFO, "::DragBegin -->\n"); if (window->priv->activity_ref > 0) return FALSE; _g_clear_object (&window->priv->drag_destination_folder); g_free (window->priv->drag_base_dir); window->priv->drag_base_dir = NULL; gdk_property_change (gdk_drag_context_get_source_window (context), XDS_ATOM, TEXT_ATOM, 8, GDK_PROP_MODE_REPLACE, (guchar *) XDS_FILENAME, strlen (XDS_FILENAME)); return TRUE; }
0
246,719
static u32 do_import_sub() { /* We import the subtitle file, i.e. we parse it and store the content as samples of a 3GPP Timed Text track in an ISO file, possibly for later export (e.g. when converting SRT to TTXT, ...) */ #ifndef GPAC_DISABLE_MEDIA_IMPORT GF_Err e; GF_MediaImporter import; /* Prepare the importer */ file = gf_isom_open("ttxt_convert", GF_ISOM_OPEN_WRITE, NULL); if (timescale && file) gf_isom_set_timescale(file, timescale); memset(&import, 0, sizeof(GF_MediaImporter)); import.dest = file; import.in_name = inName; /* Start the import */ e = gf_media_import(&import); if (e) { M4_LOG(GF_LOG_ERROR, ("Error importing %s: %s\n", inName, gf_error_to_string(e))); gf_isom_delete(file); gf_file_delete("ttxt_convert"); return mp4box_cleanup(1); } /* Prepare the export */ strcpy(outfile, inName); if (strchr(outfile, '.')) { while (outfile[strlen(outfile)-1] != '.') outfile[strlen(outfile)-1] = 0; outfile[strlen(outfile)-1] = 0; } #ifndef GPAC_DISABLE_ISOM_DUMP /* Start the export of the track #1, in the appropriate dump type, indicating it's a conversion */ dump_isom_timed_text(file, gf_isom_get_track_id(file, 1), dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, GF_TRUE, (import_subtitle==2) ? GF_TEXTDUMPTYPE_SVG : (dump_srt ? GF_TEXTDUMPTYPE_SRT : GF_TEXTDUMPTYPE_TTXT)); #endif /* Clean the importer */ gf_isom_delete(file); gf_file_delete("ttxt_convert"); if (e) { M4_LOG(GF_LOG_ERROR, ("Error converting %s: %s\n", inName, gf_error_to_string(e))); return mp4box_cleanup(1); } return mp4box_cleanup(0); #else M4_LOG(GF_LOG_ERROR, ("Feature not supported\n")); return mp4box_cleanup(1); #endif }
0
232,329
static GF_Err gf_isom_parse_movie_boxes_internal(GF_ISOFile *mov, u32 *boxType, u64 *bytesMissing, Bool progressive_mode) { GF_Box *a; u64 totSize, mdat_end=0; GF_Err e = GF_OK; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (mov->single_moof_mode && mov->single_moof_state == 2) { return e; } /*restart from where we stopped last*/ totSize = mov->current_top_box_start; if (mov->bytes_removed) { assert(totSize >= mov->bytes_removed); totSize -= mov->bytes_removed; } gf_bs_seek(mov->movieFileMap->bs, totSize); #endif /*while we have some data, parse our boxes*/ while (gf_bs_available(mov->movieFileMap->bs)) { *bytesMissing = 0; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS mov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed; GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Parsing a top-level box at position %d\n", mov->current_top_box_start)); #endif e = gf_isom_parse_root_box(&a, mov->movieFileMap->bs, boxType, bytesMissing, progressive_mode); if (e >= 0) { //safety check, should never happen if (!a) return GF_ISOM_INVALID_FILE; } else if (e == GF_ISOM_INCOMPLETE_FILE) { /*our mdat is uncomplete, only valid for READ ONLY files...*/ if (mov->openMode != GF_ISOM_OPEN_READ) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Incomplete MDAT while file is not read-only\n")); return GF_ISOM_INVALID_FILE; } if ((mov->openMode == GF_ISOM_OPEN_READ) && !progressive_mode) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Incomplete file while reading for dump - aborting parsing\n")); break; } return e; } else { return e; } switch (a->type) { /*MOOV box*/ case GF_ISOM_BOX_TYPE_MOOV: if (mov->moov) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate MOOV detected!\n")); gf_isom_box_del(a); return GF_ISOM_INVALID_FILE; } mov->moov = (GF_MovieBox *)a; mov->original_moov_offset = mov->current_top_box_start; /*set our pointer to the movie*/ mov->moov->mov = mov; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (mov->moov->mvex) mov->moov->mvex->mov = mov; #ifdef GF_ENABLE_CTRN if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { gf_isom_setup_traf_inheritance(mov); } #endif #endif e = gf_list_add(mov->TopBoxes, a); if (e) return e; totSize += a->size; if (!mov->moov->mvhd) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing MovieHeaderBox\n")); return GF_ISOM_INVALID_FILE; } if (mov->meta) { gf_isom_meta_restore_items_ref(mov, mov->meta); } //dump senc info in dump mode if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { u32 k; for (k=0; k<gf_list_count(mov->moov->trackList); k++) { GF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k); if (trak->sample_encryption) { e = senc_Parse(mov->movieFileMap->bs, trak, NULL, trak->sample_encryption); if (e) return e; } } } else { u32 k; for (k=0; k<gf_list_count(mov->moov->trackList); k++) { GF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k); if (trak->Media->information->sampleTable->sampleGroups) { convert_compact_sample_groups(trak->Media->information->sampleTable->child_boxes, trak->Media->information->sampleTable->sampleGroups); } } } if (mdat_end && mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) { gf_isom_push_mdat_end(mov, mdat_end); mdat_end=0; } break; /*META box*/ case GF_ISOM_BOX_TYPE_META: if (mov->meta) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate META detected!\n")); gf_isom_box_del(a); return GF_ISOM_INVALID_FILE; } mov->meta = (GF_MetaBox *)a; mov->original_meta_offset = mov->current_top_box_start; e = gf_list_add(mov->TopBoxes, a); if (e) { return e; } totSize += a->size; gf_isom_meta_restore_items_ref(mov, mov->meta); break; /*we only keep the MDAT in READ for dump purposes*/ case GF_ISOM_BOX_TYPE_MDAT: if (!mov->first_data_toplevel_offset) { mov->first_data_toplevel_offset = mov->current_top_box_start; mov->first_data_toplevel_size = a->size; } totSize += a->size; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (mov->emsgs) { gf_isom_box_array_del(mov->emsgs); mov->emsgs = NULL; } #endif if (mov->openMode == GF_ISOM_OPEN_READ) { if (!mov->mdat) { mov->mdat = (GF_MediaDataBox *) a; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) { return e; } } #ifndef GPAC_DISABLE_ISOM_FRAGMENTS else if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) gf_list_add(mov->TopBoxes, a); #endif else gf_isom_box_del(a); //in other modes we don't care if (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) { mdat_end = gf_bs_get_position(mov->movieFileMap->bs); if (mov->moov) { gf_isom_push_mdat_end(mov, mdat_end); mdat_end=0; } } } /*if we don't have any MDAT yet, create one (edit-write mode) We only work with one mdat, but we're puting it at the place of the first mdat found when opening a file for editing*/ else if (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) { gf_isom_box_del(a); mov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT); if (!mov->mdat) return GF_OUT_OF_MEM; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) { return e; } } else { gf_isom_box_del(a); } break; case GF_ISOM_BOX_TYPE_FTYP: /*ONE AND ONLY ONE FTYP*/ if (mov->brand) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate 'ftyp' detected!\n")); return GF_ISOM_INVALID_FILE; } mov->brand = (GF_FileTypeBox *)a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; case GF_ISOM_BOX_TYPE_OTYP: /*ONE AND ONLY ONE FTYP*/ if (mov->otyp) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate 'otyp' detected!\n")); return GF_ISOM_INVALID_FILE; } if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { mov->otyp = (GF_Box *)a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; } else { GF_FileTypeBox *brand = (GF_FileTypeBox *) gf_isom_box_find_child(a->child_boxes, GF_ISOM_BOX_TYPE_FTYP); if (brand) { s32 pos; gf_list_del_item(a->child_boxes, brand); pos = gf_list_del_item(mov->TopBoxes, mov->brand); gf_isom_box_del((GF_Box *) mov->brand); mov->brand = brand; if (pos<0) pos=0; gf_list_insert(mov->TopBoxes, brand, pos); } gf_isom_box_del(a); } break; case GF_ISOM_BOX_TYPE_PDIN: /*ONE AND ONLY ONE PDIN*/ if (mov->pdin) { gf_isom_box_del(a); GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Duplicate 'pdin'' detected!\n")); return GF_ISOM_INVALID_FILE; } mov->pdin = (GF_ProgressiveDownloadBox *) a; totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS case GF_ISOM_BOX_TYPE_STYP: { u32 brand = ((GF_FileTypeBox *)a)->majorBrand; switch (brand) { case GF_ISOM_BRAND_SISX: case GF_ISOM_BRAND_RISX: case GF_ISOM_BRAND_SSSS: mov->is_index_segment = GF_TRUE; break; default: break; } } /*fall-through*/ case GF_ISOM_BOX_TYPE_SIDX: case GF_ISOM_BOX_TYPE_SSIX: if (mov->moov && !mov->first_data_toplevel_offset) { mov->first_data_toplevel_offset = mov->current_top_box_start; mov->first_data_toplevel_size = a->size; } totSize += a->size; if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { e = gf_list_add(mov->TopBoxes, a); if (e) return e; } else if (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) && (mov->openMode!=GF_ISOM_OPEN_KEEP_FRAGMENTS) ) { if (a->type==GF_ISOM_BOX_TYPE_SIDX) { if (mov->root_sidx) gf_isom_box_del( (GF_Box *) mov->root_sidx); mov->root_sidx = (GF_SegmentIndexBox *) a; mov->sidx_start_offset = mov->current_top_box_start; mov->sidx_end_offset = gf_bs_get_position(mov->movieFileMap->bs); } else if (a->type==GF_ISOM_BOX_TYPE_STYP) { mov->styp_start_offset = mov->current_top_box_start; if (mov->seg_styp) gf_isom_box_del(mov->seg_styp); mov->seg_styp = a; } else if (a->type==GF_ISOM_BOX_TYPE_SSIX) { if (mov->seg_ssix) gf_isom_box_del(mov->seg_ssix); mov->seg_ssix = a; } else { gf_isom_box_del(a); } gf_isom_push_mdat_end(mov, mov->current_top_box_start); } else if (!mov->NextMoofNumber && (a->type==GF_ISOM_BOX_TYPE_SIDX)) { if (mov->main_sidx) gf_isom_box_del( (GF_Box *) mov->main_sidx); mov->main_sidx = (GF_SegmentIndexBox *) a; mov->main_sidx_end_pos = mov->current_top_box_start + a->size; } else { gf_isom_box_del(a); } break; case GF_ISOM_BOX_TYPE_MOOF: //no support for inplace rewrite for fragmented files gf_isom_disable_inplace_rewrite(mov); if (!mov->moov) { GF_LOG(mov->moof ? GF_LOG_DEBUG : GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Movie fragment but no moov (yet) - possibly broken parsing!\n")); } if (mov->single_moof_mode) { mov->single_moof_state++; if (mov->single_moof_state > 1) { gf_isom_box_del(a); return GF_OK; } } ((GF_MovieFragmentBox *)a)->mov = mov; totSize += a->size; mov->moof = (GF_MovieFragmentBox *) a; /*some smooth streaming streams contain a SDTP under the TRAF: this is incorrect, convert it*/ FixTrackID(mov); if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { FixSDTPInTRAF(mov->moof); } else { u32 k; for (k=0; k<gf_list_count(mov->moof->TrackList); k++) { GF_TrackFragmentBox *traf = (GF_TrackFragmentBox *)gf_list_get(mov->moof->TrackList, k); if (traf->sampleGroups) { convert_compact_sample_groups(traf->child_boxes, traf->sampleGroups); } } } /*read & debug: store at root level*/ if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { u32 k; gf_list_add(mov->TopBoxes, a); /*also update pointers to trex for debug*/ if (mov->moov) { for (k=0; k<gf_list_count(mov->moof->TrackList); k++) { GF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k); if (traf->tfhd && mov->moov->mvex && mov->moov->mvex->TrackExList) { GF_TrackBox *trak = gf_isom_get_track_from_id(mov->moov, traf->tfhd->trackID); u32 j=0; while ((traf->trex = (GF_TrackExtendsBox*)gf_list_enum(mov->moov->mvex->TrackExList, &j))) { if (traf->trex->trackID == traf->tfhd->trackID) { if (!traf->trex->track) traf->trex->track = trak; break; } traf->trex = NULL; } } //we should only parse senc/psec when no saiz/saio is present, otherwise we fetch the info directly if (traf->trex && traf->tfhd && traf->trex->track && traf->sample_encryption) { GF_TrackBox *trak = GetTrackbyID(mov->moov, traf->tfhd->trackID); if (trak) { trak->current_traf_stsd_idx = traf->tfhd->sample_desc_index ? traf->tfhd->sample_desc_index : traf->trex->def_sample_desc_index; e = senc_Parse(mov->movieFileMap->bs, trak, traf, traf->sample_encryption); if (e) return e; trak->current_traf_stsd_idx = 0; } } } } else { for (k=0; k<gf_list_count(mov->moof->TrackList); k++) { GF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k); if (traf->sample_encryption) { e = senc_Parse(mov->movieFileMap->bs, NULL, traf, traf->sample_encryption); if (e) return e; } } } } else if (mov->openMode==GF_ISOM_OPEN_KEEP_FRAGMENTS) { mov->NextMoofNumber = mov->moof->mfhd->sequence_number+1; mov->moof = NULL; gf_isom_box_del(a); } else { /*merge all info*/ e = MergeFragment((GF_MovieFragmentBox *)a, mov); gf_isom_box_del(a); if (e) return e; } //done with moov if (mov->root_sidx) { gf_isom_box_del((GF_Box *) mov->root_sidx); mov->root_sidx = NULL; } if (mov->root_ssix) { gf_isom_box_del(mov->seg_ssix); mov->root_ssix = NULL; } if (mov->seg_styp) { gf_isom_box_del(mov->seg_styp); mov->seg_styp = NULL; } mov->sidx_start_offset = 0; mov->sidx_end_offset = 0; mov->styp_start_offset = 0; break; #endif case GF_ISOM_BOX_TYPE_UNKNOWN: { GF_UnknownBox *box = (GF_UnknownBox*)a; if (box->original_4cc == GF_ISOM_BOX_TYPE_JP) { u8 *c = (u8 *) box->data; if ((box->dataSize==4) && (GF_4CC(c[0],c[1],c[2],c[3])==(u32)0x0D0A870A)) mov->is_jp2 = 1; gf_isom_box_del(a); } else { e = gf_list_add(mov->TopBoxes, a); if (e) return e; } } break; case GF_ISOM_BOX_TYPE_PRFT: #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (!(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { //keep the last one read if (mov->last_producer_ref_time) gf_isom_box_del(a); else mov->last_producer_ref_time = (GF_ProducerReferenceTimeBox *)a; break; } #endif //fallthrough case GF_ISOM_BOX_TYPE_EMSG: #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { if (!mov->emsgs) mov->emsgs = gf_list_new(); gf_list_add(mov->emsgs, a); break; } #endif case GF_ISOM_BOX_TYPE_MFRA: case GF_ISOM_BOX_TYPE_MFRO: //only keep for dump mode, otherwise we ignore these boxes and we don't want to carry them over in non-fragmented file if (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { totSize += a->size; gf_isom_box_del(a); break; } default: totSize += a->size; e = gf_list_add(mov->TopBoxes, a); if (e) return e; break; } #ifndef GPAC_DISABLE_ISOM_FRAGMENTS /*remember where we left, in case we append an entire number of movie fragments*/ mov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed; #endif } /*we need at least moov or meta*/ if (!mov->moov && !mov->meta #ifndef GPAC_DISABLE_ISOM_FRAGMENTS && !mov->moof && !mov->is_index_segment #endif ) { return GF_ISOM_INCOMPLETE_FILE; } /*we MUST have movie header*/ if (!gf_opts_get_bool("core", "no-check")) { if (mov->moov && !mov->moov->mvhd) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing MVHD in MOOV!\n")); return GF_ISOM_INVALID_FILE; } /*we MUST have meta handler*/ if (mov->meta && !mov->meta->handler) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing handler in META!\n")); return GF_ISOM_INVALID_FILE; } } #ifndef GPAC_DISABLE_ISOM_WRITE if (mov->moov) { /*set the default interleaving time*/ mov->interleavingTime = mov->moov->mvhd->timeScale; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS /*in edit mode with successfully loaded fragments, delete all fragment signaling since file is no longer fragmented*/ if ((mov->openMode > GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS) && mov->moov->mvex) { gf_isom_box_del_parent(&mov->moov->child_boxes, (GF_Box *)mov->moov->mvex); mov->moov->mvex = NULL; } #endif } //create a default mdat if none was found if (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) { mov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT); if (!mov->mdat) return GF_OUT_OF_MEM; e = gf_list_add(mov->TopBoxes, mov->mdat); if (e) return e; } #endif /*GPAC_DISABLE_ISOM_WRITE*/ return GF_OK; }
0
263,483
static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb) { struct sock *sk; sco_conn_lock(conn); sk = conn->sk; sco_conn_unlock(conn); if (!sk) goto drop; BT_DBG("sk %p len %u", sk, skb->len); if (sk->sk_state != BT_CONNECTED) goto drop; if (!sock_queue_rcv_skb(sk, skb)) return; drop: kfree_skb(skb); }
0
386,513
void DL_Dxf::addLayer(DL_CreationInterface* creationInterface) { // correct some invalid attributes for layers: attrib = creationInterface->getAttributes(); if (attrib.getColor()==256 || attrib.getColor()==0) { attrib.setColor(7); } if (attrib.getWidth()<0) { attrib.setWidth(1); } std::string linetype = attrib.getLinetype(); std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper); if (linetype=="BYLAYER" || linetype=="BYBLOCK") { attrib.setLinetype("CONTINUOUS"); } // add layer std::string name = getStringValue(2, ""); if (name.length()==0) { return; } creationInterface->addLayer(DL_LayerData(name, getIntValue(70, 0))); }
0
398,493
static inline RzBinDwarfLocList *create_loc_list(ut64 offset) { RzBinDwarfLocList *list = RZ_NEW0(RzBinDwarfLocList); if (list) { list->list = rz_list_new(); list->offset = offset; } return list; }
0
226,249
void dfla_box_del(GF_Box *s) { GF_FLACConfigBox *ptr = (GF_FLACConfigBox *) s; if (ptr->data) gf_free(ptr->data); gf_free(ptr);
0
459,171
static void tcf_proto_destroy(struct tcf_proto *tp, bool rtnl_held, bool sig_destroy, struct netlink_ext_ack *extack) { tp->ops->destroy(tp, rtnl_held, extack); if (sig_destroy) tcf_proto_signal_destroyed(tp->chain, tp); tcf_chain_put(tp->chain); module_put(tp->ops->owner); kfree_rcu(tp, rcu); }
0
224,156
Status check_index_ordering(const Tensor& indices) { if (indices.NumElements() == 0) { return errors::InvalidArgument("Indices are empty"); } auto findices = indices.flat<int>(); for (std::size_t i = 0; i < findices.dimension(0) - 1; ++i) { if (findices(i) < findices(i + 1)) { continue; } return errors::InvalidArgument("Indices are not strictly ordered"); } return Status::OK(); }
0
210,278
void qemu_ram_free(struct uc_struct *uc, RAMBlock *block) { if (!block) { return; } //if (block->host) { // ram_block_notify_remove(block->host, block->max_length); //} QLIST_REMOVE(block, next); uc->ram_list.mru_block = NULL; /* Write list before version */ //smp_wmb(); // call_rcu(block, reclaim_ramblock, rcu); reclaim_ramblock(uc, block); }
1
500,679
int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr) { uint32_t flags = (attr ? attr->flags : 0); flags &= (SSH_FILEXFER_ATTR_SIZE | SSH_FILEXFER_ATTR_UIDGID | SSH_FILEXFER_ATTR_PERMISSIONS | SSH_FILEXFER_ATTR_ACMODTIME); if (buffer_add_u32(buffer, htonl(flags)) < 0) { return -1; } if (attr) { if (flags & SSH_FILEXFER_ATTR_SIZE) { if (buffer_add_u64(buffer, htonll(attr->size)) < 0) { return -1; } } if (flags & SSH_FILEXFER_ATTR_UIDGID) { if (buffer_add_u32(buffer,htonl(attr->uid)) < 0 || buffer_add_u32(buffer,htonl(attr->gid)) < 0) { return -1; } } if (flags & SSH_FILEXFER_ATTR_PERMISSIONS) { if (buffer_add_u32(buffer, htonl(attr->permissions)) < 0) { return -1; } } if (flags & SSH_FILEXFER_ATTR_ACMODTIME) { if (buffer_add_u32(buffer, htonl(attr->atime)) < 0 || buffer_add_u32(buffer, htonl(attr->mtime)) < 0) { return -1; } } } return 0; }
0
301,410
static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, off_t offset) { ssize_t result; #if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64) START_PROFILE_BYTES(syscall_pwrite, n); result = sys_pwrite(fsp->fh->fd, data, n, offset); END_PROFILE(syscall_pwrite); if (result == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be sought on. */ result = SMB_VFS_WRITE(fsp, data, n); } #else /* HAVE_PWRITE */ off_t curr; int lerrno; curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); if (curr == -1) { return -1; } if (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) { return -1; } result = SMB_VFS_WRITE(fsp, data, n); lerrno = errno; SMB_VFS_LSEEK(fsp, curr, SEEK_SET); errno = lerrno; #endif /* HAVE_PWRITE */ return result; }
0
301,359
static int vfswrap_chmod(vfs_handle_struct *handle, const char *path, mode_t mode) { int result; START_PROFILE(syscall_chmod); /* * We need to do this due to the fact that the default POSIX ACL * chmod modifies the ACL *mask* for the group owner, not the * group owner bits directly. JRA. */ { int saved_errno = errno; /* We might get ENOSYS */ if ((result = SMB_VFS_CHMOD_ACL(handle->conn, path, mode)) == 0) { END_PROFILE(syscall_chmod); return result; } /* Error - return the old errno. */ errno = saved_errno; } result = chmod(path, mode); END_PROFILE(syscall_chmod); return result; }
0
353,164
static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; #ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; src[i] = 255 - src[i]; } } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = src[i] < 0x80 ? (dest[i] * 2 * src[i]) / 255 : 255 - 2 * ((255 - dest[i]) * (255 - src[i])) / 255; } } #ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; src[i] = 255 - src[i]; blend[i] = 255 - blend[i]; } } #endif }
0
229,155
static void guest_reset(VirtIOSerial *vser) { VirtIOSerialPort *port; VirtIOSerialPortClass *vsc; QTAILQ_FOREACH(port, &vser->ports, next) { vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port); if (port->guest_connected) { port->guest_connected = false; if (vsc->set_guest_connected) { vsc->set_guest_connected(port, false); } } } }
0
316,999
static int selinux_bpf(int cmd, union bpf_attr *attr, unsigned int size) { u32 sid = current_sid(); int ret; switch (cmd) { case BPF_MAP_CREATE: ret = avc_has_perm(&selinux_state, sid, sid, SECCLASS_BPF, BPF__MAP_CREATE, NULL); break; case BPF_PROG_LOAD: ret = avc_has_perm(&selinux_state, sid, sid, SECCLASS_BPF, BPF__PROG_LOAD, NULL); break; default: ret = 0; break; } return ret; }
0
225,974
GF_Box *dOps_box_new() { ISOM_DECL_BOX_ALLOC(GF_OpusSpecificBox, GF_ISOM_BOX_TYPE_DOPS); return (GF_Box *)tmp;
0
226,388
void pmax_box_del(GF_Box *s) { gf_free((GF_PMAXBox *)s); }
0
369,215
static int io_rw_init_file(struct io_kiocb *req, fmode_t mode) { struct kiocb *kiocb = &req->rw.kiocb; struct io_ring_ctx *ctx = req->ctx; struct file *file = req->file; int ret; if (unlikely(!file || !(file->f_mode & mode))) return -EBADF; if (!io_req_ffs_set(req)) req->flags |= io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT; kiocb->ki_flags = iocb_flags(file); ret = kiocb_set_rw_flags(kiocb, req->rw.flags); if (unlikely(ret)) return ret; /* * If the file is marked O_NONBLOCK, still allow retry for it if it * supports async. Otherwise it's impossible to use O_NONBLOCK files * reliably. If not, or it IOCB_NOWAIT is set, don't retry. */ if ((kiocb->ki_flags & IOCB_NOWAIT) || ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req))) req->flags |= REQ_F_NOWAIT; if (ctx->flags & IORING_SETUP_IOPOLL) { if (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll) return -EOPNOTSUPP; kiocb->private = NULL; kiocb->ki_flags |= IOCB_HIPRI | IOCB_ALLOC_CACHE; kiocb->ki_complete = io_complete_rw_iopoll; req->iopoll_completed = 0; } else { if (kiocb->ki_flags & IOCB_HIPRI) return -EINVAL; kiocb->ki_complete = io_complete_rw; } return 0; }
0
247,566
TEST_P(SslSocketTest, RevokedCertificate) { const std::string server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem" crl: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.crl" )EOF"; // This should fail, since the certificate has been revoked. const std::string revoked_client_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns_key.pem" )EOF"; TestUtilOptions revoked_test_options(revoked_client_ctx_yaml, server_ctx_yaml, false, GetParam()); testUtil(revoked_test_options.setExpectedServerStats("ssl.fail_verify_error") .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED)); // This should succeed, since the cert isn't revoked. const std::string successful_client_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns2_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns2_key.pem" )EOF"; TestUtilOptions successful_test_options(successful_client_ctx_yaml, server_ctx_yaml, true, GetParam()); testUtil(successful_test_options.setExpectedSerialNumber(TEST_SAN_DNS2_CERT_SERIAL)); }
0
400,122
TerminalClient::TerminalClient(shared_ptr<SocketHandler> _socketHandler, shared_ptr<SocketHandler> _pipeSocketHandler, const SocketEndpoint& _socketEndpoint, const string& id, const string& passkey, shared_ptr<Console> _console, bool jumphost, const string& tunnels, const string& reverseTunnels, bool forwardSshAgent, const string& identityAgent) : console(_console), shuttingDown(false) { portForwardHandler = shared_ptr<PortForwardHandler>( new PortForwardHandler(_socketHandler, _pipeSocketHandler)); InitialPayload payload; payload.set_jumphost(jumphost); try { if (tunnels.length()) { auto pfsrs = parseRangesToRequests(tunnels); for (auto& pfsr : pfsrs) { #ifdef WIN32 STFATAL << "Source tunnel not supported on windows yet"; #else auto pfsresponse = portForwardHandler->createSource(pfsr, nullptr, -1, -1); if (pfsresponse.has_error()) { throw std::runtime_error(pfsresponse.error()); } #endif } } if (reverseTunnels.length()) { auto pfsrs = parseRangesToRequests(reverseTunnels); for (auto& pfsr : pfsrs) { *(payload.add_reversetunnels()) = pfsr; } } if (forwardSshAgent) { PortForwardSourceRequest pfsr; string authSock = ""; if (identityAgent.length()) { authSock.assign(identityAgent); } else { auto authSockEnv = getenv("SSH_AUTH_SOCK"); if (!authSockEnv) { CLOG(INFO, "stdout") << "Missing environment variable SSH_AUTH_SOCK. Are you sure " "you " "ran ssh-agent first?" << endl; exit(1); } authSock.assign(authSockEnv); } if (authSock.length()) { pfsr.mutable_destination()->set_name(authSock); pfsr.set_environmentvariable("SSH_AUTH_SOCK"); *(payload.add_reversetunnels()) = pfsr; } } } catch (const std::runtime_error& ex) { CLOG(INFO, "stdout") << "Error establishing port forward: " << ex.what() << endl; exit(1); } connection = shared_ptr<ClientConnection>( new ClientConnection(_socketHandler, _socketEndpoint, id, passkey)); int connectFailCount = 0; while (true) { try { bool fail = true; if (connection->connect()) { connection->writePacket( Packet(EtPacketType::INITIAL_PAYLOAD, protoToString(payload))); fd_set rfd; timeval tv; for (int a = 0; a < 3; a++) { FD_ZERO(&rfd); int clientFd = connection->getSocketFd(); if (clientFd < 0) { std::this_thread::sleep_for(std::chrono::seconds(1)); continue; } FD_SET(clientFd, &rfd); tv.tv_sec = 1; tv.tv_usec = 0; select(clientFd + 1, &rfd, NULL, NULL, &tv); if (FD_ISSET(clientFd, &rfd)) { Packet initialResponsePacket; if (connection->readPacket(&initialResponsePacket)) { if (initialResponsePacket.getHeader() != EtPacketType::INITIAL_RESPONSE) { CLOG(INFO, "stdout") << "Error: Missing initial response\n"; STFATAL << "Missing initial response!"; } auto initialResponse = stringToProto<InitialResponse>( initialResponsePacket.getPayload()); if (initialResponse.has_error()) { CLOG(INFO, "stdout") << "Error initializing connection: " << initialResponse.error() << endl; exit(1); } fail = false; break; } } } } if (fail) { LOG(WARNING) << "Connecting to server failed: Connect timeout"; connectFailCount++; if (connectFailCount == 3) { throw std::runtime_error("Connect Timeout"); } } } catch (const runtime_error& err) { LOG(INFO) << "Could not make initial connection to server"; CLOG(INFO, "stdout") << "Could not make initial connection to " << _socketEndpoint << ": " << err.what() << endl; exit(1); } TelemetryService::get()->logToDatadog("Connection Established", el::Level::Info, __FILE__, __LINE__); break; } VLOG(1) << "Client created with id: " << connection->getId(); };
0
317,297
static int selinux_shm_associate(struct kern_ipc_perm *shp, int shmflg) { struct ipc_security_struct *isec; struct common_audit_data ad; u32 sid = current_sid(); isec = selinux_ipc(shp); ad.type = LSM_AUDIT_DATA_IPC; ad.u.ipc_id = shp->key; return avc_has_perm(&selinux_state, sid, isec->sid, SECCLASS_SHM, SHM__ASSOCIATE, &ad); }
0
391,626
static ssize_t remove_slot_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "0\n"); }
0
241,059
static int create_lockfile(void) { int rv, fd; fd = -1; rv = _lockfile(O_CREAT | O_WRONLY, &fd, NULL); if (fd == -1) { log_error("lockfile %s open error %d: %s", cl.lockfile, rv, strerror(rv)); return -1; } if (rv < 0) { log_error("lockfile %s setlk error %d: %s", cl.lockfile, rv, strerror(rv)); goto fail; } rv = write_daemon_state(fd, BOOTHD_STARTING); if (rv != 0) { log_error("write daemon state %d to lockfile error %s: %s", BOOTHD_STARTING, cl.lockfile, strerror(errno)); goto fail; } if (is_root()) { if (fchown(fd, booth_conf->uid, booth_conf->gid) < 0) log_error("fchown() on lockfile said %d: %s", errno, strerror(errno)); } return fd; fail: close(fd); return -1; }
0
359,250
DEFUN (no_neighbor_route_reflector_client, no_neighbor_route_reflector_client_cmd, NO_NEIGHBOR_CMD2 "route-reflector-client", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Reflector client\n") { return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REFLECTOR_CLIENT); }
0
249,985
GF_Err DoFullInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emulation, u64 StartOffset) { u32 i, tracksDone; TrackWriter *tmp, *curWriter, *prevWriter; GF_Err e; u64 DTS, DTStmp, TStmp; s64 res; u32 descIndex, sampSize, chunkNumber; u16 curGroupID, curTrackPriority; Bool forceNewChunk, writeGroup; GF_StscEntry *stsc_ent; //this is used to emulate the write ... u64 offset, totSize, sampOffset; GF_ISOFile *movie = mw->movie; totSize = 0; curGroupID = 1; prevWriter = NULL; //we emulate a write from this offset... offset = StartOffset; tracksDone = 0; //browse each groups while (1) { writeGroup = 1; //proceed a group while (writeGroup) { u32 nb_samp = 1; Bool self_contained, chunked_forced=GF_FALSE; //first get the appropriated sample for the min time in this group curWriter = NULL; DTStmp = (u64) -1; TStmp = 0; curTrackPriority = (u16) -1; i=0; while ((tmp = (TrackWriter*)gf_list_enum(writers, &i))) { //is it done writing ? //is it in our group ?? if (tmp->isDone || tmp->stbl->groupID != curGroupID) continue; //OK, get the current sample in this track stbl_GetSampleDTS(tmp->stbl->TimeToSample, tmp->sampleNumber, &DTS); res = TStmp ? DTStmp * tmp->timeScale - DTS * TStmp : 0; if (res < 0) continue; if ((!res) && curTrackPriority <= tmp->stbl->trackPriority) continue; curWriter = tmp; curTrackPriority = tmp->stbl->trackPriority; DTStmp = DTS; TStmp = tmp->timeScale; } //no sample found, we're done with this group if (!curWriter) { //we're done with the group writeGroup = 0; continue; } //To Check: are empty sample tables allowed ??? if (curWriter->sampleNumber > curWriter->stbl->SampleSize->sampleCount) { curWriter->isDone = 1; tracksDone ++; continue; } e = stbl_GetSampleInfos(curWriter->stbl, curWriter->sampleNumber, &sampOffset, &chunkNumber, &descIndex, &stsc_ent); if (e) return e; e = stbl_GetSampleSize(curWriter->stbl->SampleSize, curWriter->sampleNumber, &sampSize); if (e) return e; update_writer_constant_dur(movie, curWriter, stsc_ent, &nb_samp, &sampSize, GF_FALSE); if (curWriter->stbl->MaxChunkSize && (curWriter->chunkSize + sampSize > curWriter->stbl->MaxChunkSize)) { curWriter->chunkSize = 0; chunked_forced = forceNewChunk = 1; } curWriter->chunkSize += sampSize; self_contained = ((curWriter->all_dref_mode==ISOM_DREF_SELF) || Media_IsSelfContained(curWriter->mdia, descIndex) ) ? GF_TRUE : GF_FALSE; //do we actually write, or do we emulate ? if (Emulation) { //are we in the same track ??? If not, force a new chunk when adding this sample if (!chunked_forced) { if (curWriter != prevWriter) { forceNewChunk = 1; } else { forceNewChunk = 0; } } //update our offsets... if (self_contained) { e = stbl_SetChunkAndOffset(curWriter->stbl, curWriter->sampleNumber, descIndex, curWriter->stsc, &curWriter->stco, offset, forceNewChunk, nb_samp); if (e) return e; offset += sampSize; totSize += sampSize; } else { // if (curWriter->prev_offset != sampOffset) forceNewChunk = 1; curWriter->prev_offset = sampOffset + sampSize; //we have a DataRef, so use the offset idicated in sampleToChunk //and ChunkOffset tables... e = stbl_SetChunkAndOffset(curWriter->stbl, curWriter->sampleNumber, descIndex, curWriter->stsc, &curWriter->stco, sampOffset, chunked_forced, nb_samp); if (e) return e; } } else { //this is no game, we're writing .... if (self_contained) { e = WriteSample(mw, sampSize, sampOffset, stsc_ent->isEdited, bs, 1); if (e) return e; } } //ok, the sample is done if (curWriter->sampleNumber == curWriter->stbl->SampleSize->sampleCount) { curWriter->isDone = 1; //one more track done... tracksDone ++; } else { curWriter->sampleNumber += nb_samp; } prevWriter = curWriter; } //if all our track are done, break if (tracksDone == gf_list_count(writers)) break; //go to next group curGroupID ++; } if (movie->mdat) movie->mdat->dataSize = totSize; return GF_OK; }
0
299,318
static MagickBooleanType WriteMATImage(const ImageInfo *image_info,Image *image, ExceptionInfo *exception) { char MATLAB_HDR[0x80]; MagickBooleanType status; MagickOffsetType scene; size_t imageListLength; struct tm local_time; time_t current_time; /* Open output image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); (void) LogMagickEvent(CoderEvent,GetMagickModule(),"enter MAT"); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); if (status == MagickFalse) return(MagickFalse); image->depth=8; current_time=time((time_t *) NULL); #if defined(MAGICKCORE_HAVE_LOCALTIME_R) (void) localtime_r(&current_time,&local_time); #else (void) memcpy(&local_time,localtime(&current_time),sizeof(local_time)); #endif (void) memset(MATLAB_HDR,' ',MagickMin(sizeof(MATLAB_HDR),124)); FormatLocaleString(MATLAB_HDR,sizeof(MATLAB_HDR), "MATLAB 5.0 MAT-file, Platform: %s, Created on: %s %s %2d %2d:%2d:%2d %d", OsDesc,DayOfWTab[local_time.tm_wday],MonthsTab[local_time.tm_mon], local_time.tm_mday,local_time.tm_hour,local_time.tm_min, local_time.tm_sec,local_time.tm_year+1900); MATLAB_HDR[0x7C]=0; MATLAB_HDR[0x7D]=1; MATLAB_HDR[0x7E]='I'; MATLAB_HDR[0x7F]='M'; (void) WriteBlob(image,sizeof(MATLAB_HDR),(unsigned char *) MATLAB_HDR); scene=0; imageListLength=GetImageListLength(image); do { char padding; MagickBooleanType is_gray; QuantumInfo *quantum_info; size_t data_size; unsigned char *pixels; unsigned int z; (void) TransformImageColorspace(image,sRGBColorspace,exception); is_gray=SetImageGray(image,exception); z=(is_gray != MagickFalse) ? 0 : 3; /* Store MAT header. */ data_size = image->rows * image->columns; if (is_gray == MagickFalse) data_size*=3; padding=((unsigned char)(data_size-1) & 0x7) ^ 0x7; (void) WriteBlobLSBLong(image,miMATRIX); (void) WriteBlobLSBLong(image,(unsigned int) data_size+padding+ ((is_gray != MagickFalse) ? 48 : 56)); (void) WriteBlobLSBLong(image,0x6); /* 0x88 */ (void) WriteBlobLSBLong(image,0x8); /* 0x8C */ (void) WriteBlobLSBLong(image,0x6); /* 0x90 */ (void) WriteBlobLSBLong(image,0); (void) WriteBlobLSBLong(image,0x5); /* 0x98 */ (void) WriteBlobLSBLong(image,(is_gray != MagickFalse) ? 0x8 : 0xC); /* 0x9C - DimFlag */ (void) WriteBlobLSBLong(image,(unsigned int) image->rows); /* x: 0xA0 */ (void) WriteBlobLSBLong(image,(unsigned int) image->columns); /* y: 0xA4 */ if (is_gray == MagickFalse) { (void) WriteBlobLSBLong(image,3); /* z: 0xA8 */ (void) WriteBlobLSBLong(image,0); } (void) WriteBlobLSBShort(image,1); /* 0xB0 */ (void) WriteBlobLSBShort(image,1); /* 0xB2 */ (void) WriteBlobLSBLong(image,'M'); /* 0xB4 */ (void) WriteBlobLSBLong(image,0x2); /* 0xB8 */ (void) WriteBlobLSBLong(image,(unsigned int) data_size); /* 0xBC */ /* Store image data. */ quantum_info=AcquireQuantumInfo(image_info,image); if (quantum_info == (QuantumInfo *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); pixels=(unsigned char *) GetQuantumPixels(quantum_info); do { const Quantum *p; ssize_t y; for (y=0; y < (ssize_t)image->columns; y++) { p=GetVirtualPixels(image,y,0,1,image->rows,exception); if (p == (const Quantum *) NULL) break; (void) ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, z2qtype[z],pixels,exception); (void) WriteBlob(image,image->rows,pixels); } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; } while (z-- >= 2); while (padding-- > 0) (void) WriteBlobByte(image,0); quantum_info=DestroyQuantumInfo(quantum_info); if (GetNextImageInList(image) == (Image *) NULL) break; image=SyncNextImageInList(image); status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); if (status == MagickFalse) break; } while (image_info->adjoin != MagickFalse); (void) CloseBlob(image); return(status); }
0
343,225
static void displayrate(const char *word, off_t size, const double started, const char * const name, int up) { double ended; double t; double speed; char speedstring[64]; ended = get_usec_time(); t = ended - started; if (t > 0.0 && size > (off_t) 0) { speed = size / t; } else { speed = 0.0; } if (speed > 524288.0) { addreply(0, MSG_TRANSFER_RATE_M, t, speed / 1048576.0); } else if (speed > 512.0) { addreply(0, MSG_TRANSFER_RATE_K, t, speed / 1024.0); } else if (speed > 0.1) { addreply(0, MSG_TRANSFER_RATE_B, t, speed); } if (!SNCHECK(snprintf(speedstring, sizeof speedstring, " (%llu bytes, %.2fKB/sec)", (unsigned long long) size, speed / 1024.0), sizeof speedstring)) { logfile(LOG_NOTICE, "%s%s%s%s %s %s", root_directory, *name == '/' ? "" : wd, (*name != '/' && (!*wd || wd[strlen(wd) - 1] != '/')) ? "/" : "", name, word, speedstring); } /* Tons of #ifdef here, but it avoids a pointless call to realpath() */ #if defined(WITH_UPLOAD_SCRIPT) || defined(WITH_ALTLOG) if ( # ifdef WITH_ALTLOG altlog_format != ALTLOG_NONE # endif # if defined(WITH_UPLOAD_SCRIPT) && defined(WITH_ALTLOG) || # endif # if (defined(WITH_UPLOAD_SCRIPT)) (do_upload_script != 0 && up != 0) # endif ) { char *alloca_filename_real; const size_t sizeof_filename_real = PATH_MAX + VHOST_PREFIX_MAX_LEN; char *resolved_path; const size_t sizeof_resolved_path = PATH_MAX + 1U; if ((resolved_path = malloc(sizeof_resolved_path)) == NULL) { return; } resolved_path[sizeof_resolved_path - 1U] = 0; if (realpath(name, resolved_path) == NULL) { if (up != 0) { (void) unlink(name); } free(resolved_path); logfile(LOG_ERR, "realpath() failure : [%s] => [%s]", name, strerror(errno)); return; } if (resolved_path[sizeof_resolved_path - 1U] != 0) { for (;;) { *resolved_path++ = 0; } } if ((alloca_filename_real = ALLOCA(sizeof_filename_real)) == NULL) { free(resolved_path); return; } # ifdef WITH_VIRTUAL_CHROOT if (SNCHECK(snprintf(alloca_filename_real, sizeof_filename_real, "\001%s", resolved_path), sizeof_filename_real)) { goto rp_failure; } # else if (SNCHECK(snprintf(alloca_filename_real, sizeof_filename_real, "\001%s%s", root_directory, (*resolved_path == '/' ? resolved_path + 1 : resolved_path)), sizeof_filename_real)) { goto rp_failure; } # endif # ifdef WITH_ALTLOG (void) altlog_writexfer(up, alloca_filename_real + 1, size, t); # endif # if defined(WITH_UPLOAD_SCRIPT) if (do_upload_script != 0 && up != 0) { upload_pipe_push(account, alloca_filename_real); } # endif rp_failure: free(resolved_path); ALLOCA_FREE(alloca_filename_real); } #else (void) up; #endif }
0
225,470
bool IsTensorIdPortValid(const TensorId& tensor_id) { return tensor_id.index() >= Graph::kControlSlot; }
0
230,978
mrb_protect_error(mrb_state *mrb, mrb_protect_error_func *body, void *userdata, mrb_bool *error) { struct mrb_jmpbuf *prev_jmp = mrb->jmp; struct mrb_jmpbuf c_jmp; mrb_value result = mrb_nil_value(); int ai = mrb_gc_arena_save(mrb); const struct mrb_context *c = mrb->c; ptrdiff_t ci_index = c->ci - c->cibase; if (error) { *error = FALSE; } MRB_TRY(&c_jmp) { mrb->jmp = &c_jmp; result = body(mrb, userdata); mrb->jmp = prev_jmp; } MRB_CATCH(&c_jmp) { mrb->jmp = prev_jmp; result = mrb_obj_value(mrb->exc); mrb->exc = NULL; if (error) { *error = TRUE; } if (mrb->c == c) { while (c->ci - c->cibase > ci_index) { cipop(mrb); } } else { // It was probably switched by mrb_fiber_resume(). // Simply destroy all successive CINFO_DIRECTs once the fiber has been switched. c = mrb->c; while (c->ci > c->cibase && c->ci->cci == CINFO_DIRECT) { cipop(mrb); } } } MRB_END_EXC(&c_jmp); mrb_gc_arena_restore(mrb, ai); mrb_gc_protect(mrb, result); return result; }
0
195,264
static void compile_xclass_matchingpath(compiler_common *common, PCRE2_SPTR cc, jump_list **backtracks) { DEFINE_COMPILER; jump_list *found = NULL; jump_list **list = (cc[0] & XCL_NOT) == 0 ? &found : backtracks; sljit_uw c, charoffset, max = 256, min = READ_CHAR_MAX; struct sljit_jump *jump = NULL; PCRE2_SPTR ccbegin; int compares, invertcmp, numberofcmps; #if defined SUPPORT_UNICODE && (PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16) BOOL utf = common->utf; #endif /* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == [8|16] */ #ifdef SUPPORT_UNICODE sljit_u32 unicode_status = 0; int typereg = TMP1; const sljit_u32 *other_cases; sljit_uw typeoffset; #endif /* SUPPORT_UNICODE */ /* Scanning the necessary info. */ cc++; ccbegin = cc; compares = 0; if (cc[-1] & XCL_MAP) { min = 0; cc += 32 / sizeof(PCRE2_UCHAR); } while (*cc != XCL_END) { compares++; if (*cc == XCL_SINGLE) { cc ++; GETCHARINCTEST(c, cc); if (c > max) max = c; if (c < min) min = c; #ifdef SUPPORT_UNICODE unicode_status |= XCLASS_SAVE_CHAR; #endif /* SUPPORT_UNICODE */ } else if (*cc == XCL_RANGE) { cc ++; GETCHARINCTEST(c, cc); if (c < min) min = c; GETCHARINCTEST(c, cc); if (c > max) max = c; #ifdef SUPPORT_UNICODE unicode_status |= XCLASS_SAVE_CHAR; #endif /* SUPPORT_UNICODE */ } #ifdef SUPPORT_UNICODE else { SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); cc++; if (*cc == PT_CLIST && *cc == XCL_PROP) { other_cases = PRIV(ucd_caseless_sets) + cc[1]; while (*other_cases != NOTACHAR) { if (*other_cases > max) max = *other_cases; if (*other_cases < min) min = *other_cases; other_cases++; } } else { max = READ_CHAR_MAX; min = 0; } switch(*cc) { case PT_ANY: /* Any either accepts everything or ignored. */ if (cc[-1] == XCL_PROP) { compile_char1_matchingpath(common, OP_ALLANY, cc, backtracks, FALSE); if (list == backtracks) add_jump(compiler, backtracks, JUMP(SLJIT_JUMP)); return; } break; case PT_LAMP: case PT_GC: case PT_PC: case PT_ALNUM: unicode_status |= XCLASS_HAS_TYPE; break; case PT_SCX: unicode_status |= XCLASS_HAS_SCRIPT_EXTENSION; if (cc[-1] == XCL_NOTPROP) { unicode_status |= XCLASS_SCRIPT_EXTENSION_NOTPROP; break; } compares++; /* Fall through */ case PT_SC: unicode_status |= XCLASS_HAS_SCRIPT; break; case PT_SPACE: case PT_PXSPACE: case PT_WORD: case PT_PXGRAPH: case PT_PXPRINT: case PT_PXPUNCT: unicode_status |= XCLASS_SAVE_CHAR | XCLASS_HAS_TYPE; break; case PT_CLIST: case PT_UCNC: unicode_status |= XCLASS_SAVE_CHAR; break; case PT_BOOL: unicode_status |= XCLASS_HAS_BOOL; break; case PT_BIDICL: unicode_status |= XCLASS_HAS_BIDICL; break; default: SLJIT_UNREACHABLE(); break; } cc += 2; } #endif /* SUPPORT_UNICODE */ } SLJIT_ASSERT(compares > 0); /* We are not necessary in utf mode even in 8 bit mode. */ cc = ccbegin; if ((cc[-1] & XCL_NOT) != 0) read_char(common, min, max, backtracks, READ_CHAR_UPDATE_STR_PTR); else { #ifdef SUPPORT_UNICODE read_char(common, min, max, (unicode_status & XCLASS_NEEDS_UCD) ? backtracks : NULL, 0); #else /* !SUPPORT_UNICODE */ read_char(common, min, max, NULL, 0); #endif /* SUPPORT_UNICODE */ } if ((cc[-1] & XCL_HASPROP) == 0) { if ((cc[-1] & XCL_MAP) != 0) { jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255); if (!optimize_class(common, (const sljit_u8 *)cc, (((const sljit_u8 *)cc)[31] & 0x80) != 0, TRUE, &found)) { 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)cc); OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0); add_jump(compiler, &found, JUMP(SLJIT_NOT_ZERO)); } add_jump(compiler, backtracks, JUMP(SLJIT_JUMP)); JUMPHERE(jump); cc += 32 / sizeof(PCRE2_UCHAR); } else { OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, min); add_jump(compiler, (cc[-1] & XCL_NOT) == 0 ? backtracks : &found, CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, max - min)); } } else if ((cc[-1] & XCL_MAP) != 0) { OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0); #ifdef SUPPORT_UNICODE unicode_status |= XCLASS_CHAR_SAVED; #endif /* SUPPORT_UNICODE */ if (!optimize_class(common, (const sljit_u8 *)cc, FALSE, TRUE, list)) { #if PCRE2_CODE_UNIT_WIDTH == 8 jump = NULL; if (common->utf) #endif /* PCRE2_CODE_UNIT_WIDTH == 8 */ jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255); 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)cc); OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0); add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO)); #if PCRE2_CODE_UNIT_WIDTH == 8 if (common->utf) #endif /* PCRE2_CODE_UNIT_WIDTH == 8 */ JUMPHERE(jump); } OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0); cc += 32 / sizeof(PCRE2_UCHAR); } #ifdef SUPPORT_UNICODE if (unicode_status & XCLASS_NEEDS_UCD) { if ((unicode_status & (XCLASS_SAVE_CHAR | XCLASS_CHAR_SAVED)) == XCLASS_SAVE_CHAR) OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0); #if PCRE2_CODE_UNIT_WIDTH == 32 if (!common->utf) { jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, MAX_UTF_CODE_POINT + 1); OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, UNASSIGNED_UTF_CHAR); JUMPHERE(jump); } #endif /* PCRE2_CODE_UNIT_WIDTH == 32 */ OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1); OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1)); OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT); OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2)); OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1); OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 3); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0); ccbegin = cc; if (unicode_status & XCLASS_HAS_BIDICL) { OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, scriptx_bidiclass)); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BIDICLASS_SHIFT); while (*cc != XCL_END) { if (*cc == XCL_SINGLE) { cc ++; GETCHARINCTEST(c, cc); } else if (*cc == XCL_RANGE) { cc ++; GETCHARINCTEST(c, cc); GETCHARINCTEST(c, cc); } else { SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); cc++; if (*cc == PT_BIDICL) { compares--; invertcmp = (compares == 0 && list != backtracks); if (cc[-1] == XCL_NOTPROP) invertcmp ^= 0x1; jump = CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (int)cc[1]); add_jump(compiler, compares > 0 ? list : backtracks, jump); } cc += 2; } } cc = ccbegin; } if (unicode_status & XCLASS_HAS_BOOL) { OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, bprops)); OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BPROPS_MASK); OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 2); while (*cc != XCL_END) { if (*cc == XCL_SINGLE) { cc ++; GETCHARINCTEST(c, cc); } else if (*cc == XCL_RANGE) { cc ++; GETCHARINCTEST(c, cc); GETCHARINCTEST(c, cc); } else { SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); cc++; if (*cc == PT_BOOL) { compares--; invertcmp = (compares == 0 && list != backtracks); if (cc[-1] == XCL_NOTPROP) invertcmp ^= 0x1; OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP1), (sljit_sw)(PRIV(ucd_boolprop_sets) + (cc[1] >> 5)), SLJIT_IMM, (sljit_sw)1 << (cc[1] & 0x1f)); add_jump(compiler, compares > 0 ? list : backtracks, JUMP(SLJIT_NOT_ZERO ^ invertcmp)); } cc += 2; } } cc = ccbegin; } if (unicode_status & XCLASS_HAS_SCRIPT) { OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script)); while (*cc != XCL_END) { if (*cc == XCL_SINGLE) { cc ++; GETCHARINCTEST(c, cc); } else if (*cc == XCL_RANGE) { cc ++; GETCHARINCTEST(c, cc); GETCHARINCTEST(c, cc); } else { SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); cc++; switch (*cc) { case PT_SCX: if (cc[-1] == XCL_NOTPROP) break; /* Fall through */ case PT_SC: compares--; invertcmp = (compares == 0 && list != backtracks); if (cc[-1] == XCL_NOTPROP) invertcmp ^= 0x1; add_jump(compiler, compares > 0 ? list : backtracks, CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (int)cc[1])); } cc += 2; } } cc = ccbegin; } if (unicode_status & XCLASS_HAS_SCRIPT_EXTENSION) { OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, scriptx_bidiclass)); OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_SCRIPTX_MASK); OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 2); if (unicode_status & XCLASS_SCRIPT_EXTENSION_NOTPROP) { if (unicode_status & XCLASS_HAS_TYPE) { if (unicode_status & XCLASS_SAVE_CHAR) { OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, TMP2, 0); unicode_status |= XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0; } else { OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP2, 0); unicode_status |= XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR; } } OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script)); } while (*cc != XCL_END) { if (*cc == XCL_SINGLE) { cc ++; GETCHARINCTEST(c, cc); } else if (*cc == XCL_RANGE) { cc ++; GETCHARINCTEST(c, cc); GETCHARINCTEST(c, cc); } else { SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); cc++; if (*cc == PT_SCX) { compares--; invertcmp = (compares == 0 && list != backtracks); jump = NULL; if (cc[-1] == XCL_NOTPROP) { jump = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, (int)cc[1]); if (invertcmp) { add_jump(compiler, backtracks, jump); jump = NULL; } invertcmp ^= 0x1; } OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP1), (sljit_sw)(PRIV(ucd_script_sets) + (cc[1] >> 5)), SLJIT_IMM, (sljit_sw)1 << (cc[1] & 0x1f)); add_jump(compiler, compares > 0 ? list : backtracks, JUMP(SLJIT_NOT_ZERO ^ invertcmp)); if (jump != NULL) JUMPHERE(jump); } cc += 2; } } if (unicode_status & XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0) OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); else if (unicode_status & XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR) OP1(SLJIT_MOV, TMP2, 0, RETURN_ADDR, 0); cc = ccbegin; } if (unicode_status & XCLASS_SAVE_CHAR) OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0); if (unicode_status & XCLASS_HAS_TYPE) { if (unicode_status & XCLASS_SAVE_CHAR) typereg = RETURN_ADDR; OP1(SLJIT_MOV_U8, typereg, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype)); } } #endif /* SUPPORT_UNICODE */ /* Generating code. */ charoffset = 0; numberofcmps = 0; #ifdef SUPPORT_UNICODE typeoffset = 0; #endif /* SUPPORT_UNICODE */ while (*cc != XCL_END) { compares--; invertcmp = (compares == 0 && list != backtracks); jump = NULL; if (*cc == XCL_SINGLE) { cc ++; GETCHARINCTEST(c, cc); if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE)) { OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_EQUAL); numberofcmps++; } else if (numberofcmps > 0) { OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_EQUAL); jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); numberofcmps = 0; } else { jump = CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); numberofcmps = 0; } } else if (*cc == XCL_RANGE) { cc ++; GETCHARINCTEST(c, cc); SET_CHAR_OFFSET(c); GETCHARINCTEST(c, cc); if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE)) { OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL); numberofcmps++; } else if (numberofcmps > 0) { OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL); jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); numberofcmps = 0; } else { jump = CMP(SLJIT_LESS_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); numberofcmps = 0; } } #ifdef SUPPORT_UNICODE else { SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); if (*cc == XCL_NOTPROP) invertcmp ^= 0x1; cc++; switch(*cc) { case PT_ANY: if (!invertcmp) jump = JUMP(SLJIT_JUMP); break; case PT_LAMP: OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Lu - typeoffset); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Ll - typeoffset); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Lt - typeoffset); OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_EQUAL); jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); break; case PT_GC: c = PRIV(ucp_typerange)[(int)cc[1] * 2]; SET_TYPE_OFFSET(c); jump = CMP(SLJIT_LESS_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, PRIV(ucp_typerange)[(int)cc[1] * 2 + 1] - c); break; case PT_PC: jump = CMP(SLJIT_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, (int)cc[1] - typeoffset); break; case PT_SC: case PT_SCX: case PT_BOOL: case PT_BIDICL: compares++; /* Do nothing. */ break; case PT_SPACE: case PT_PXSPACE: SET_CHAR_OFFSET(9); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0xd - 0x9); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x85 - 0x9); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x180e - 0x9); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); SET_TYPE_OFFSET(ucp_Zl); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Zl); OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL); jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); break; case PT_WORD: OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_UNDERSCORE - charoffset)); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL); /* Fall through. */ case PT_ALNUM: SET_TYPE_OFFSET(ucp_Ll); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Lu - ucp_Ll); OP_FLAGS((*cc == PT_ALNUM) ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL); SET_TYPE_OFFSET(ucp_Nd); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_No - ucp_Nd); OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL); jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); break; case PT_CLIST: other_cases = PRIV(ucd_caseless_sets) + cc[1]; /* At least three characters are required. Otherwise this case would be handled by the normal code path. */ SLJIT_ASSERT(other_cases[0] != NOTACHAR && other_cases[1] != NOTACHAR && other_cases[2] != NOTACHAR); SLJIT_ASSERT(other_cases[0] < other_cases[1] && other_cases[1] < other_cases[2]); /* Optimizing character pairs, if their difference is power of 2. */ if (is_powerof2(other_cases[1] ^ other_cases[0])) { if (charoffset == 0) OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]); else { OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset); OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]); } OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_IMM, other_cases[1]); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL); other_cases += 2; } else if (is_powerof2(other_cases[2] ^ other_cases[1])) { if (charoffset == 0) OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]); else { OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset); OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]); } OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_IMM, other_cases[2]); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(other_cases[0] - charoffset)); OP_FLAGS(SLJIT_OR | ((other_cases[3] == NOTACHAR) ? SLJIT_SET_Z : 0), TMP2, 0, SLJIT_EQUAL); other_cases += 3; } else { OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset)); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL); } while (*other_cases != NOTACHAR) { OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset)); OP_FLAGS(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_Z : 0), TMP2, 0, SLJIT_EQUAL); } jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); break; case PT_UCNC: OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_DOLLAR_SIGN - charoffset)); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_COMMERCIAL_AT - charoffset)); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_GRAVE_ACCENT - charoffset)); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); SET_CHAR_OFFSET(0xa0); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(0xd7ff - charoffset)); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL); SET_CHAR_OFFSET(0); OP2U(SLJIT_SUB | SLJIT_SET_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0xe000 - 0); OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_GREATER_EQUAL); jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); break; case PT_PXGRAPH: /* C and Z groups are the farthest two groups. */ SET_TYPE_OFFSET(ucp_Ll); OP2U(SLJIT_SUB | SLJIT_SET_GREATER, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_GREATER); jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll); /* In case of ucp_Cf, we overwrite the result. */ SET_CHAR_OFFSET(0x2066); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x180e - 0x2066); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); JUMPHERE(jump); jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0); break; case PT_PXPRINT: /* C and Z groups are the farthest two groups. */ SET_TYPE_OFFSET(ucp_Ll); OP2U(SLJIT_SUB | SLJIT_SET_GREATER, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_GREATER); OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Ll); OP_FLAGS(SLJIT_AND, TMP2, 0, SLJIT_NOT_EQUAL); jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll); /* In case of ucp_Cf, we overwrite the result. */ SET_CHAR_OFFSET(0x2066); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL); OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066); OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); JUMPHERE(jump); jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0); break; case PT_PXPUNCT: SET_TYPE_OFFSET(ucp_Sc); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_So - ucp_Sc); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL); SET_CHAR_OFFSET(0); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x7f); OP_FLAGS(SLJIT_AND, TMP2, 0, SLJIT_LESS_EQUAL); SET_TYPE_OFFSET(ucp_Pc); OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Ps - ucp_Pc); OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL); jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); break; default: SLJIT_UNREACHABLE(); break; } cc += 2; } #endif /* SUPPORT_UNICODE */ if (jump != NULL) add_jump(compiler, compares > 0 ? list : backtracks, jump); } if (found != NULL) set_jumps(found, LABEL()); }
1
226,224
GF_Box *mvcg_box_new() { ISOM_DECL_BOX_ALLOC(GF_MultiviewGroupBox, GF_ISOM_BOX_TYPE_MVCG); return (GF_Box *)tmp;
0
209,026
virNodeDeviceGetMdevTypesCaps(const char *sysfspath, virMediatedDeviceTypePtr **mdev_types, size_t *nmdev_types) { virMediatedDeviceTypePtr *types = NULL; size_t ntypes = 0; size_t i; /* this could be a refresh, so clear out the old data */ for (i = 0; i < *nmdev_types; i++) virMediatedDeviceTypeFree(*mdev_types[i]); VIR_FREE(*mdev_types); *nmdev_types = 0; if (virMediatedDeviceGetMdevTypes(sysfspath, &types, &ntypes) < 0) return -1; *mdev_types = g_steal_pointer(&types); *nmdev_types = ntypes; return 0; }
1
308,184
static int fastrpc_map_find(struct fastrpc_user *fl, int fd, struct fastrpc_map **ppmap) { struct fastrpc_map *map = NULL; mutex_lock(&fl->mutex); list_for_each_entry(map, &fl->maps, node) { if (map->fd == fd) { fastrpc_map_get(map); *ppmap = map; mutex_unlock(&fl->mutex); return 0; } } mutex_unlock(&fl->mutex); return -ENOENT; }
0
477,299
static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead, struct tipc_bearer *b, struct sk_buff **skb, int err) { struct tipc_skb_cb *skb_cb = TIPC_SKB_CB(*skb); struct tipc_crypto *rx = aead->crypto; struct tipc_aead *tmp = NULL; struct tipc_ehdr *ehdr; struct tipc_node *n; /* Is this completed by TX? */ if (unlikely(is_tx(aead->crypto))) { rx = skb_cb->tx_clone_ctx.rx; pr_debug("TX->RX(%s): err %d, aead %p, skb->next %p, flags %x\n", (rx) ? tipc_node_get_id_str(rx->node) : "-", err, aead, (*skb)->next, skb_cb->flags); pr_debug("skb_cb [recurs %d, last %p], tx->aead [%p %p %p]\n", skb_cb->tx_clone_ctx.recurs, skb_cb->tx_clone_ctx.last, aead->crypto->aead[1], aead->crypto->aead[2], aead->crypto->aead[3]); if (unlikely(err)) { if (err == -EBADMSG && (*skb)->next) tipc_rcv(net, (*skb)->next, b); goto free_skb; } if (likely((*skb)->next)) { kfree_skb((*skb)->next); (*skb)->next = NULL; } ehdr = (struct tipc_ehdr *)(*skb)->data; if (!rx) { WARN_ON(ehdr->user != LINK_CONFIG); n = tipc_node_create(net, 0, ehdr->id, 0xffffu, 0, true); rx = tipc_node_crypto_rx(n); if (unlikely(!rx)) goto free_skb; } /* Ignore cloning if it was TX master key */ if (ehdr->tx_key == KEY_MASTER) goto rcv; if (tipc_aead_clone(&tmp, aead) < 0) goto rcv; WARN_ON(!refcount_inc_not_zero(&tmp->refcnt)); if (tipc_crypto_key_attach(rx, tmp, ehdr->tx_key, false) < 0) { tipc_aead_free(&tmp->rcu); goto rcv; } tipc_aead_put(aead); aead = tmp; } if (unlikely(err)) { tipc_aead_users_dec((struct tipc_aead __force __rcu *)aead, INT_MIN); goto free_skb; } /* Set the RX key's user */ tipc_aead_users_set((struct tipc_aead __force __rcu *)aead, 1); /* Mark this point, RX works */ rx->timer1 = jiffies; rcv: /* Remove ehdr & auth. tag prior to tipc_rcv() */ ehdr = (struct tipc_ehdr *)(*skb)->data; /* Mark this point, RX passive still works */ if (rx->key.passive && ehdr->tx_key == rx->key.passive) rx->timer2 = jiffies; skb_reset_network_header(*skb); skb_pull(*skb, tipc_ehdr_size(ehdr)); pskb_trim(*skb, (*skb)->len - aead->authsize); /* Validate TIPCv2 message */ if (unlikely(!tipc_msg_validate(skb))) { pr_err_ratelimited("Packet dropped after decryption!\n"); goto free_skb; } /* Ok, everything's fine, try to synch own keys according to peers' */ tipc_crypto_key_synch(rx, *skb); /* Mark skb decrypted */ skb_cb->decrypted = 1; /* Clear clone cxt if any */ if (likely(!skb_cb->tx_clone_deferred)) goto exit; skb_cb->tx_clone_deferred = 0; memset(&skb_cb->tx_clone_ctx, 0, sizeof(skb_cb->tx_clone_ctx)); goto exit; free_skb: kfree_skb(*skb); *skb = NULL; exit: tipc_aead_put(aead); if (rx) tipc_node_put(rx->node); }
0
181,940
void OverlayWindowViews::ButtonPressed(views::Button* sender, const ui::Event& event) { if (sender == close_controls_view_.get()) controller_->Close(true /* should_pause_video */, true /* should_reset_pip_player */); if (sender == play_pause_controls_view_.get()) TogglePlayPause(); if (sender == first_custom_controls_view_.get()) controller_->CustomControlPressed(first_custom_controls_view_->id()); if (sender == second_custom_controls_view_.get()) controller_->CustomControlPressed(second_custom_controls_view_->id()); }
0
369,915
static struct dentry *proc_base_instantiate(struct inode *dir, struct dentry *dentry, struct task_struct *task, const void *ptr) { const struct pid_entry *p = ptr; struct inode *inode; struct proc_inode *ei; struct dentry *error; /* Allocate the inode */ error = ERR_PTR(-ENOMEM); inode = new_inode(dir->i_sb); if (!inode) goto out; /* Initialize the inode */ ei = PROC_I(inode); inode->i_ino = get_next_ino(); inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; /* * grab the reference to the task. */ ei->pid = get_task_pid(task, PIDTYPE_PID); if (!ei->pid) goto out_iput; inode->i_mode = p->mode; if (S_ISDIR(inode->i_mode)) set_nlink(inode, 2); if (S_ISLNK(inode->i_mode)) inode->i_size = 64; if (p->iop) inode->i_op = p->iop; if (p->fop) inode->i_fop = p->fop; ei->op = p->op; d_add(dentry, inode); error = NULL; out: return error; out_iput: iput(inode); goto out; }
0
230,968
stack_extend_alloc(mrb_state *mrb, mrb_int room) { mrb_value *oldbase = mrb->c->stbase; mrb_value *newstack; size_t oldsize = mrb->c->stend - mrb->c->stbase; size_t size = oldsize; size_t off = mrb->c->ci->stack ? mrb->c->stend - mrb->c->ci->stack : 0; if (off > size) size = off; #ifdef MRB_STACK_EXTEND_DOUBLING if ((size_t)room <= size) size *= 2; else size += room; #else /* Use linear stack growth. It is slightly slower than doubling the stack space, but it saves memory on small devices. */ if (room <= MRB_STACK_GROWTH) size += MRB_STACK_GROWTH; else size += room; #endif newstack = (mrb_value *)mrb_realloc_simple(mrb, mrb->c->stbase, sizeof(mrb_value) * size); if (newstack == NULL) { mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err)); } stack_clear(&(newstack[oldsize]), size - oldsize); envadjust(mrb, oldbase, newstack, oldsize); mrb->c->stbase = newstack; mrb->c->stend = mrb->c->stbase + size; /* Raise an exception if the new stack size will be too large, to prevent infinite recursion. However, do this only after resizing the stack, so mrb_raise has stack space to work with. */ if (size > MRB_STACK_MAX) { mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err)); } }
0
411,924
sort_version_list(smartlist_t *versions, int remove_duplicates) { smartlist_sort(versions, _compare_tor_version_str_ptr); if (remove_duplicates) smartlist_uniq(versions, _compare_tor_version_str_ptr, _tor_free); }
0
417,127
mp_sint32 PlayerGeneric::startPlaying(XModule* module, bool repeat/* = false*/, mp_uint32 startPosition/* = 0*/, mp_uint32 startRow/* = 0*/, mp_sint32 numChannels/* = -1*/, const mp_ubyte* customPanningTable/* = NULL*/, bool idle/* = false*/, mp_sint32 patternIndex/* = -1*/, bool playOneRowOnly/* = false*/) { this->idle = idle; this->repeat = repeat; this->playOneRowOnly = playOneRowOnly; if (mixer == NULL) { mixer = new MasterMixer(frequency, bufferSize, 1, audioDriver); mixer->setMasterMixerNotificationListener(listener); mixer->setSampleShift(sampleShift); if (audioDriver == NULL) mixer->setCurrentAudioDriverByName(audioDriverName); } if (!player || player->getType() != getPreferredPlayerType(module)) { if (player) { if (!mixer->isDeviceRemoved(player)) mixer->removeDevice(player); delete player; } player = getPreferredPlayer(module); if (player) { // apply our own "state" to the state of the newly allocated player player->resetMainVolumeOnStartPlay(resetMainVolumeOnStartPlayFlag); player->resetOnStop(resetOnStopFlag); player->setBufferSize(bufferSize); player->setResamplerType(resamplerType); player->setMasterVolume(masterVolume); player->setPanningSeparation(panningSeparation); player->setPlayMode(playMode); for (mp_sint32 i = PlayModeOptionFirst; i < PlayModeOptionLast; i++) player->enable((PlayModeOptions)i, options[i]); player->setDisableMixing(disableMixing); player->setAllowFilters(allowFilters); //if (paused) // player->pausePlaying(); // adjust number of virtual channels if necessary setNumMaxVirChannels(numMaxVirChannels); } } if (player && mixer) { if (!mixer->isDeviceRemoved(player)) mixer->removeDevice(player); player->startPlaying(module, repeat, startPosition, startRow, numChannels, customPanningTable, idle, patternIndex, playOneRowOnly); mixer->addDevice(player); if (!mixer->isPlaying()) return mixer->start(); } return MP_OK; }
0
224,489
static GF_Err txtin_setup_ttxt(GF_Filter *filter, GF_TXTIn *ctx) { GF_Err e; u32 j, k, ID, OCR_ES_ID; u64 file_size; GF_XMLNode *root, *ext; GF_PropertyValue *dcd; ctx->parser = gf_xml_dom_new(); e = gf_xml_dom_parse(ctx->parser, ctx->file_name, ttxt_dom_progress, ctx); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[TXTIn] Error parsing TTXT file: Line %d - %s\n", gf_xml_dom_get_line(ctx->parser), gf_xml_dom_get_error(ctx->parser))); return e; } root = gf_xml_dom_get_root(ctx->parser); if (strcmp(root->name, "TextStream")) { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[TXTIn] Invalid Timed Text file - expecting \"TextStream\" got %s", root->name)); return GF_NON_COMPLIANT_BITSTREAM; } file_size = ctx->end; ctx->end = 0; /*setup track in 3GP format directly (no ES desc)*/ if (!ctx->timescale) ctx->timescale = 1000; OCR_ES_ID = ID = 0; if (!ctx->opid) ctx->opid = gf_filter_pid_new(filter); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_TEXT) ); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CODECID, &PROP_UINT(GF_CODECID_TX3G) ); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TIMESCALE, &PROP_UINT(ctx->timescale) ); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DOWN_SIZE, &PROP_LONGUINT(file_size) ); if (!ID) ID = 1; gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ID, &PROP_UINT(ID) ); if (OCR_ES_ID) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CLOCK_ID, &PROP_UINT(OCR_ES_ID) ); ctx->nb_children = gf_list_count(root->content); ctx->cur_child_idx = 0; for (ctx->cur_child_idx=0; ctx->cur_child_idx < ctx->nb_children; ctx->cur_child_idx++) { GF_XMLNode *node = (GF_XMLNode*) gf_list_get(root->content, ctx->cur_child_idx); if (node->type) { continue; } if (!strcmp(node->name, "TextStreamHeader")) { GF_XMLNode *sdesc; s32 w, h, tx, ty, layer; u32 tref_id; GF_XMLAttribute *att; w = ctx->width; h = ctx->height; tx = ctx->txtx; ty = ctx->txty; layer = ctx->zorder; tref_id = 0; j=0; while ( (att=(GF_XMLAttribute *)gf_list_enum(node->attributes, &j))) { if (!strcmp(att->name, "width")) w = atoi(att->value); else if (!strcmp(att->name, "height")) h = atoi(att->value); else if (!strcmp(att->name, "layer")) layer = atoi(att->value); else if (!strcmp(att->name, "translation_x")) tx = atoi(att->value); else if (!strcmp(att->name, "translation_y")) ty = atoi(att->value); else if (!strcmp(att->name, "trefID")) tref_id = atoi(att->value); } if (tref_id) { gf_filter_pid_set_property_str(ctx->opid, "tref:chap", &PROP_UINT(tref_id) ); } if (w) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_WIDTH, &PROP_UINT(w) ); if (h) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_HEIGHT, &PROP_UINT(h) ); if (tx) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TRANS_X, &PROP_UINT(tx) ); if (ty) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TRANS_X, &PROP_UINT(ty) ); if (layer) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ZORDER, &PROP_SINT(ctx->zorder) ); if (ctx->lang) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_LANGUAGE, &PROP_STRING( ctx->lang) ); j=0; while ( (sdesc=(GF_XMLNode*)gf_list_enum(node->content, &j))) { if (sdesc->type) continue; if (!strcmp(sdesc->name, "TextSampleDescription")) { GF_TextSampleDescriptor td; memset(&td, 0, sizeof(GF_TextSampleDescriptor)); td.tag = GF_ODF_TEXT_CFG_TAG; td.vert_justif = (s8) -1; td.default_style.fontID = 1; td.default_style.font_size = ctx->fontsize; k=0; while ( (att=(GF_XMLAttribute *)gf_list_enum(sdesc->attributes, &k))) { if (!strcmp(att->name, "horizontalJustification")) { if (!stricmp(att->value, "center")) td.horiz_justif = 1; else if (!stricmp(att->value, "right")) td.horiz_justif = (s8) -1; else if (!stricmp(att->value, "left")) td.horiz_justif = 0; } else if (!strcmp(att->name, "verticalJustification")) { if (!stricmp(att->value, "center")) td.vert_justif = 1; else if (!stricmp(att->value, "bottom")) td.vert_justif = (s8) -1; else if (!stricmp(att->value, "top")) td.vert_justif = 0; } else if (!strcmp(att->name, "backColor")) td.back_color = ttxt_get_color(att->value); else if (!strcmp(att->name, "verticalText") && !stricmp(att->value, "yes") ) td.displayFlags |= GF_TXT_VERTICAL; else if (!strcmp(att->name, "fillTextRegion") && !stricmp(att->value, "yes") ) td.displayFlags |= GF_TXT_FILL_REGION; else if (!strcmp(att->name, "continuousKaraoke") && !stricmp(att->value, "yes") ) td.displayFlags |= GF_TXT_KARAOKE; else if (!strcmp(att->name, "scroll")) { if (!stricmp(att->value, "inout")) td.displayFlags |= GF_TXT_SCROLL_IN | GF_TXT_SCROLL_OUT; else if (!stricmp(att->value, "in")) td.displayFlags |= GF_TXT_SCROLL_IN; else if (!stricmp(att->value, "out")) td.displayFlags |= GF_TXT_SCROLL_OUT; } else if (!strcmp(att->name, "scrollMode")) { u32 scroll_mode = GF_TXT_SCROLL_CREDITS; if (!stricmp(att->value, "Credits")) scroll_mode = GF_TXT_SCROLL_CREDITS; else if (!stricmp(att->value, "Marquee")) scroll_mode = GF_TXT_SCROLL_MARQUEE; else if (!stricmp(att->value, "Right")) scroll_mode = GF_TXT_SCROLL_RIGHT; else if (!stricmp(att->value, "Down")) scroll_mode = GF_TXT_SCROLL_DOWN; td.displayFlags |= ((scroll_mode<<7) & GF_TXT_SCROLL_DIRECTION); } } k=0; while ( (ext=(GF_XMLNode*)gf_list_enum(sdesc->content, &k))) { if (ext->type) continue; if (!strcmp(ext->name, "TextBox")) ttxt_parse_text_box(ext, &td.default_pos); else if (!strcmp(ext->name, "Style")) ttxt_parse_text_style(ctx, ext, &td.default_style); else if (!strcmp(ext->name, "FontTable")) { GF_XMLNode *ftable; u32 z=0; while ( (ftable=(GF_XMLNode*)gf_list_enum(ext->content, &z))) { u32 m; if (ftable->type || strcmp(ftable->name, "FontTableEntry")) continue; td.font_count += 1; td.fonts = (GF_FontRecord*)gf_realloc(td.fonts, sizeof(GF_FontRecord)*td.font_count); m=0; while ( (att=(GF_XMLAttribute *)gf_list_enum(ftable->attributes, &m))) { if (!stricmp(att->name, "fontID")) td.fonts[td.font_count-1].fontID = atoi(att->value); else if (!stricmp(att->name, "fontName")) td.fonts[td.font_count-1].fontName = gf_strdup(att->value); } } } } if (ctx->nodefbox) { td.default_pos.top = td.default_pos.left = td.default_pos.right = td.default_pos.bottom = 0; } else { if ((td.default_pos.bottom==td.default_pos.top) || (td.default_pos.right==td.default_pos.left)) { td.default_pos.top = td.default_pos.left = 0; td.default_pos.right = w; td.default_pos.bottom = h; } } if (!td.fonts) { td.font_count = 1; td.fonts = (GF_FontRecord*)gf_malloc(sizeof(GF_FontRecord)); td.fonts[0].fontID = 1; td.fonts[0].fontName = gf_strdup("Serif"); } GF_SAFEALLOC(dcd, GF_PropertyValue); if (dcd) { dcd->type = GF_PROP_DATA; gf_odf_tx3g_write(&td, &dcd->value.data.ptr, &dcd->value.data.size); if (!ctx->text_descs) ctx->text_descs = gf_list_new(); gf_list_add(ctx->text_descs, dcd); } for (k=0; k<td.font_count; k++) gf_free(td.fonts[k].fontName); gf_free(td.fonts); } } } else { break; } } if (!ctx->text_descs) { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[TXTIn] Invalid Timed Text file - text stream header not found or empty\n")); return GF_NON_COMPLIANT_BITSTREAM; } dcd = gf_list_get(ctx->text_descs, 0); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DECODER_CONFIG, dcd); ctx->last_desc_idx = 1; ctx->first_samp = GF_TRUE; ctx->last_sample_empty = GF_FALSE; ctx->last_sample_duration = 0; txtin_probe_duration(ctx); return GF_OK; }
0
358,127
sonmp_decode(struct lldpd *cfg, char *frame, int s, struct lldpd_hardware *hardware, struct lldpd_chassis **newchassis, struct lldpd_port **newport) { const u_int8_t mcastaddr[] = SONMP_MULTICAST_ADDR; struct lldpd_chassis *chassis; struct lldpd_port *port; struct lldpd_mgmt *mgmt; int length, i; u_int8_t *pos; u_int8_t seg[3], rchassis; struct in_addr address; log_debug("sonmp", "decode SONMP PDU from %s", hardware->h_ifname); if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) { log_warn("sonmp", "failed to allocate remote chassis"); return -1; } TAILQ_INIT(&chassis->c_mgmt); if ((port = calloc(1, sizeof(struct lldpd_port))) == NULL) { log_warn("sonmp", "failed to allocate remote port"); free(chassis); return -1; } #ifdef ENABLE_DOT1 TAILQ_INIT(&port->p_vlans); #endif length = s; pos = (u_int8_t*)frame; if (length < SONMP_SIZE + 2*ETHER_ADDR_LEN + sizeof(u_int16_t)) { log_warnx("sonmp", "too short SONMP frame received on %s", hardware->h_ifname); goto malformed; } if (PEEK_CMP(mcastaddr, sizeof(mcastaddr)) != 0) /* There is two multicast address. We just handle only one of * them. */ goto malformed; /* We skip to LLC PID */ PEEK_DISCARD(ETHER_ADDR_LEN); PEEK_DISCARD_UINT16; PEEK_DISCARD(6); if (PEEK_UINT16 != LLC_PID_SONMP_HELLO) { log_debug("sonmp", "incorrect LLC protocol ID received for SONMP on %s", hardware->h_ifname); goto malformed; } chassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_ADDR; if ((chassis->c_id = calloc(1, sizeof(struct in_addr) + 1)) == NULL) { log_warn("sonmp", "unable to allocate memory for chassis id on %s", hardware->h_ifname); goto malformed; } chassis->c_id_len = sizeof(struct in_addr) + 1; chassis->c_id[0] = 1; PEEK_BYTES(&address, sizeof(struct in_addr)); memcpy(chassis->c_id + 1, &address, sizeof(struct in_addr)); if (asprintf(&chassis->c_name, "%s", inet_ntoa(address)) == -1) { log_warnx("sonmp", "unable to write chassis name for %s", hardware->h_ifname); goto malformed; } PEEK_BYTES(seg, sizeof(seg)); rchassis = PEEK_UINT8; for (i=0; sonmp_chassis_types[i].type != 0; i++) { if (sonmp_chassis_types[i].type == rchassis) break; } if (asprintf(&chassis->c_descr, "%s", sonmp_chassis_types[i].description) == -1) { log_warnx("sonmp", "unable to write chassis description for %s", hardware->h_ifname); goto malformed; } mgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4, &address, sizeof(struct in_addr), 0); if (mgmt == NULL) { if (errno == ENOMEM) log_warn("sonmp", "unable to allocate memory for management address"); else log_warn("sonmp", "too large management address received on %s", hardware->h_ifname); goto malformed; } TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries); port->p_ttl = cfg?(cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold): LLDPD_TTL; port->p_ttl = (port->p_ttl + 999) / 1000; port->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL; if (asprintf(&port->p_id, "%02x-%02x-%02x", seg[0], seg[1], seg[2]) == -1) { log_warn("sonmp", "unable to allocate memory for port id on %s", hardware->h_ifname); goto malformed; } port->p_id_len = strlen(port->p_id); /* Port description depend on the number of segments */ if ((seg[0] == 0) && (seg[1] == 0)) { if (asprintf(&port->p_descr, "port %d", seg[2]) == -1) { log_warnx("sonmp", "unable to write port description for %s", hardware->h_ifname); goto malformed; } } else if (seg[0] == 0) { if (asprintf(&port->p_descr, "port %d/%d", seg[1], seg[2]) == -1) { log_warnx("sonmp", "unable to write port description for %s", hardware->h_ifname); goto malformed; } } else { if (asprintf(&port->p_descr, "port %x:%x:%x", seg[0], seg[1], seg[2]) == -1) { log_warnx("sonmp", "unable to write port description for %s", hardware->h_ifname); goto malformed; } } *newchassis = chassis; *newport = port; return 1; malformed: lldpd_chassis_cleanup(chassis, 1); lldpd_port_cleanup(port, 1); free(port); return -1; }
0
450,363
static void zrle_choose_palette_rle(VncState *vs, int w, int h, VncPalette *palette, int bpp_out, int runs, int single_pixels, int zywrle_level, bool *use_rle, bool *use_palette) { size_t estimated_bytes; size_t plain_rle_bytes; *use_palette = *use_rle = false; estimated_bytes = w * h * (bpp_out / 8); /* start assuming raw */ if (bpp_out != 8) { if (zywrle_level > 0 && !(zywrle_level & 0x80)) estimated_bytes >>= zywrle_level; } plain_rle_bytes = ((bpp_out / 8) + 1) * (runs + single_pixels); if (plain_rle_bytes < estimated_bytes) { *use_rle = true; estimated_bytes = plain_rle_bytes; } if (palette_size(palette) < 128) { int palette_rle_bytes; palette_rle_bytes = (bpp_out / 8) * palette_size(palette); palette_rle_bytes += 2 * runs + single_pixels; if (palette_rle_bytes < estimated_bytes) { *use_rle = true; *use_palette = true; estimated_bytes = palette_rle_bytes; } if (palette_size(palette) < 17) { int packed_bytes; packed_bytes = (bpp_out / 8) * palette_size(palette); packed_bytes += w * h * bits_per_packed_pixel[palette_size(palette)-1] / 8; if (packed_bytes < estimated_bytes) { *use_rle = false; *use_palette = true; } } } }
0
198,169
TfLiteTensor* GetVariableInput(TfLiteContext* context, const TfLiteNode* node, int index) { TfLiteTensor* tensor = GetMutableInput(context, node, index); return tensor->is_variable ? tensor : nullptr; }
1
440,883
AuditPrefix(void) { time_t tm; char *autime, *s; char *tmpBuf; int len; time(&tm); autime = ctime(&tm); if ((s = strchr(autime, '\n'))) *s = '\0'; len = strlen(AUDIT_PREFIX) + strlen(autime) + 10 + 1; tmpBuf = malloc(len); if (!tmpBuf) return NULL; snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long) getpid()); return tmpBuf; }
0
237,828
static int acurite_986_decode(r_device *decoder, bitbuffer_t *bitbuffer) { int const browlen = 5; uint8_t *bb, sensor_num, status, crc, crcc; uint8_t br[8]; int8_t tempf; // Raw Temp is 8 bit signed Fahrenheit uint16_t sensor_id, valid_cnt = 0; char sensor_type; char *channel_str; int battery_low; data_t *data; int result = 0; for (uint16_t brow = 0; brow < bitbuffer->num_rows; ++brow) { decoder_logf(decoder, 2, __func__, "row %u bits %u, bytes %d", brow, bitbuffer->bits_per_row[brow], browlen); if (bitbuffer->bits_per_row[brow] < 39 || bitbuffer->bits_per_row[brow] > 43 ) { if (bitbuffer->bits_per_row[brow] > 16) decoder_log(decoder, 2, __func__,"skipping wrong len"); result = DECODE_ABORT_LENGTH; continue; // DECODE_ABORT_LENGTH } bb = bitbuffer->bb[brow]; // Reduce false positives // may eliminate these with a better PPM (precise?) demod. if ((bb[0] == 0xff && bb[1] == 0xff && bb[2] == 0xff) || (bb[0] == 0x00 && bb[1] == 0x00 && bb[2] == 0x00)) { result = DECODE_ABORT_EARLY; continue; // DECODE_ABORT_EARLY } // Reverse the bits, msg sent LSB first for (int i = 0; i < browlen; i++) br[i] = reverse8(bb[i]); decoder_log_bitrow(decoder, 1, __func__, br, browlen * 8, "reversed"); tempf = br[0]; sensor_id = (br[1] << 8) + br[2]; status = br[3]; sensor_num = (status & 0x01) + 1; status = status >> 1; battery_low = ((status & 1) == 1); // By default Sensor 1 is the Freezer, 2 Refrigerator sensor_type = sensor_num == 2 ? 'F' : 'R'; channel_str = sensor_num == 2 ? "2F" : "1R"; crc = br[4]; crcc = crc8le(br, 4, 0x07, 0); if (crcc != crc) { decoder_logf_bitrow(decoder, 2, __func__, br, browlen * 8, "bad CRC: %02x -", crc8le(br, 4, 0x07, 0)); // HACK: rct 2018-04-22 // the message is often missing the last 1 bit either due to a // problem with the device or demodulator // Add 1 (0x80 because message is LSB) and retry CRC. if (crcc == (crc | 0x80)) { decoder_logf(decoder, 2, __func__, "CRC fix %02x - %02x", crc, crcc); } else { continue; // DECODE_FAIL_MIC } } if (tempf & 0x80) { tempf = (tempf & 0x7f) * -1; } decoder_logf(decoder, 1, __func__, "sensor 0x%04x - %d%c: %d F", sensor_id, sensor_num, sensor_type, tempf); /* clang-format off */ data = data_make( "model", "", DATA_STRING, "Acurite-986", "id", NULL, DATA_INT, sensor_id, "channel", NULL, DATA_STRING, channel_str, "battery_ok", "Battery", DATA_INT, !battery_low, "temperature_F", "temperature", DATA_FORMAT, "%f F", DATA_DOUBLE, (float)tempf, "status", "status", DATA_INT, status, "mic", "Integrity", DATA_STRING, "CRC", NULL); /* clang-format on */ decoder_output_data(decoder, data); valid_cnt++; } if (valid_cnt) return 1; return result; }
0
294,631
date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass) { VALUE vy, vw, vd, vsg; VALUE argv2[4]; rb_scan_args(argc, argv, "31", &vy, &vw, &vd, &vsg); RETURN_FALSE_UNLESS_NUMERIC(vy); RETURN_FALSE_UNLESS_NUMERIC(vw); RETURN_FALSE_UNLESS_NUMERIC(vd); argv2[0] = vy; argv2[1] = vw; argv2[2] = vd; if (argc < 4) argv2[3] = INT2FIX(DEFAULT_SG); else argv2[3] = vsg; if (NIL_P(valid_commercial_sub(4, argv2, klass, 0))) return Qfalse; return Qtrue; }
0
297,211
PHP_MINIT_FUNCTION(exif) { REGISTER_INI_ENTRIES(); if (zend_hash_exists(&module_registry, "mbstring", sizeof("mbstring"))) { REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 1, CONST_CS | CONST_PERSISTENT); } else { REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 0, CONST_CS | CONST_PERSISTENT); } return SUCCESS; }
0
379,321
apply_cmdmod(cmdmod_T *cmod) { #ifdef HAVE_SANDBOX if ((cmod->cmod_flags & CMOD_SANDBOX) && !cmod->cmod_did_sandbox) { ++sandbox; cmod->cmod_did_sandbox = TRUE; } #endif if (cmod->cmod_verbose > 0) { if (cmod->cmod_verbose_save == 0) cmod->cmod_verbose_save = p_verbose + 1; p_verbose = cmod->cmod_verbose - 1; } if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT)) && cmod->cmod_save_msg_silent == 0) { cmod->cmod_save_msg_silent = msg_silent + 1; cmod->cmod_save_msg_scroll = msg_scroll; } if (cmod->cmod_flags & CMOD_SILENT) ++msg_silent; if (cmod->cmod_flags & CMOD_UNSILENT) msg_silent = 0; if (cmod->cmod_flags & CMOD_ERRSILENT) { ++emsg_silent; ++cmod->cmod_did_esilent; } if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmod->cmod_save_ei == NULL) { // Set 'eventignore' to "all". // First save the existing option value for restoring it later. cmod->cmod_save_ei = vim_strsave(p_ei); set_string_option_direct((char_u *)"ei", -1, (char_u *)"all", OPT_FREE, SID_NONE); } }
0
263,506
static void sco_sock_set_timer(struct sock *sk, long timeout) { if (!sco_pi(sk)->conn) return; BT_DBG("sock %p state %d timeout %ld", sk, sk->sk_state, timeout); cancel_delayed_work(&sco_pi(sk)->conn->timeout_work); schedule_delayed_work(&sco_pi(sk)->conn->timeout_work, timeout); }
0
333,074
nfa_regtry( nfa_regprog_T *prog, colnr_T col, proftime_T *tm UNUSED, // timeout limit or NULL int *timed_out UNUSED) // flag set on timeout or NULL { int i; regsubs_T subs, m; nfa_state_T *start = prog->start; int result; #ifdef ENABLE_LOG FILE *f; #endif rex.input = rex.line + col; #ifdef FEAT_RELTIME nfa_time_limit = tm; nfa_timed_out = timed_out; nfa_time_count = 0; #endif #ifdef ENABLE_LOG f = fopen(NFA_REGEXP_RUN_LOG, "a"); if (f != NULL) { fprintf(f, "\n\n\t=======================================================\n"); #ifdef DEBUG fprintf(f, "\tRegexp is \"%s\"\n", nfa_regengine.expr); #endif fprintf(f, "\tInput text is \"%s\" \n", rex.input); fprintf(f, "\t=======================================================\n\n"); nfa_print_state(f, start); fprintf(f, "\n\n"); fclose(f); } else emsg("Could not open temporary log file for writing"); #endif clear_sub(&subs.norm); clear_sub(&m.norm); #ifdef FEAT_SYN_HL clear_sub(&subs.synt); clear_sub(&m.synt); #endif result = nfa_regmatch(prog, start, &subs, &m); if (result == FALSE) return 0; else if (result == NFA_TOO_EXPENSIVE) return result; cleanup_subexpr(); if (REG_MULTI) { for (i = 0; i < subs.norm.in_use; i++) { rex.reg_startpos[i].lnum = subs.norm.list.multi[i].start_lnum; rex.reg_startpos[i].col = subs.norm.list.multi[i].start_col; rex.reg_endpos[i].lnum = subs.norm.list.multi[i].end_lnum; rex.reg_endpos[i].col = subs.norm.list.multi[i].end_col; } if (rex.reg_startpos[0].lnum < 0) { rex.reg_startpos[0].lnum = 0; rex.reg_startpos[0].col = col; } if (rex.reg_endpos[0].lnum < 0) { // pattern has a \ze but it didn't match, use current end rex.reg_endpos[0].lnum = rex.lnum; rex.reg_endpos[0].col = (int)(rex.input - rex.line); } else // Use line number of "\ze". rex.lnum = rex.reg_endpos[0].lnum; } else { for (i = 0; i < subs.norm.in_use; i++) { rex.reg_startp[i] = subs.norm.list.line[i].start; rex.reg_endp[i] = subs.norm.list.line[i].end; } if (rex.reg_startp[0] == NULL) rex.reg_startp[0] = rex.line + col; if (rex.reg_endp[0] == NULL) rex.reg_endp[0] = rex.input; } #ifdef FEAT_SYN_HL // Package any found \z(...\) matches for export. Default is none. unref_extmatch(re_extmatch_out); re_extmatch_out = NULL; if (prog->reghasz == REX_SET) { cleanup_zsubexpr(); re_extmatch_out = make_extmatch(); if (re_extmatch_out == NULL) return 0; // Loop over \z1, \z2, etc. There is no \z0. for (i = 1; i < subs.synt.in_use; i++) { if (REG_MULTI) { struct multipos *mpos = &subs.synt.list.multi[i]; // Only accept single line matches that are valid. if (mpos->start_lnum >= 0 && mpos->start_lnum == mpos->end_lnum && mpos->end_col >= mpos->start_col) re_extmatch_out->matches[i] = vim_strnsave(reg_getline(mpos->start_lnum) + mpos->start_col, mpos->end_col - mpos->start_col); } else { struct linepos *lpos = &subs.synt.list.line[i]; if (lpos->start != NULL && lpos->end != NULL) re_extmatch_out->matches[i] = vim_strnsave(lpos->start, lpos->end - lpos->start); } } } #endif return 1 + rex.lnum; }
0
482,643
static inline struct net *xt_net(const struct xt_action_param *par) { return par->state->net; }
0
326,091
regcomp_start( char_u *expr, int re_flags) // see vim_regcomp() { initchr(expr); if (re_flags & RE_MAGIC) reg_magic = MAGIC_ON; else reg_magic = MAGIC_OFF; reg_string = (re_flags & RE_STRING); reg_strict = (re_flags & RE_STRICT); get_cpo_flags(); num_complex_braces = 0; regnpar = 1; CLEAR_FIELD(had_endbrace); #ifdef FEAT_SYN_HL regnzpar = 1; re_has_z = 0; #endif regsize = 0L; reg_toolong = FALSE; regflags = 0; #if defined(FEAT_SYN_HL) || defined(PROTO) had_eol = FALSE; #endif }
0
312,393
qf_parse_fmt_e(regmatch_T *rmp, int midx, qffields_T *fields) { if (rmp->startp[midx] == NULL) return QF_FAIL; fields->end_lnum = atol((char *)rmp->startp[midx]); return QF_OK; }
0
293,539
PJ_DEF(void) pj_cis_add_range(pj_cis_t *cis, int cstart, int cend) { /* Can not set zero. This is the requirement of the parser. */ pj_assert(cstart > 0); while (cstart != cend) { PJ_CIS_SET(cis, cstart); ++cstart; } }
0
513,060
virtual ~Item_const() {}
0
254,901
DocumentSource::GetModPathsReturn GroupFromFirstDocumentTransformation::getModifiedPaths() const { // Replaces the entire root, so all paths are modified. return {DocumentSource::GetModPathsReturn::Type::kAllPaths, std::set<std::string>{}, {}}; }
0
252,311
inline void wenc14(unsigned short a, unsigned short b, unsigned short &l, unsigned short &h) { short as = static_cast<short>(a); short bs = static_cast<short>(b); short ms = (as + bs) >> 1; short ds = as - bs; l = static_cast<unsigned short>(ms); h = static_cast<unsigned short>(ds); }
0