REURLRequest::REURLRequest(const REURL & url) { REPtr<REURLRequestInternal> internal(new REURLRequestInternal()); if (internal.isNotEmpty()) { internal->url = url; _r = REPtr<REURLRequestInternal>(internal); } }
void breakpoint_Relocation::set_target(address x) { assert(settable(), "must be settable"); jint target_bits = (jint)internal() ? scaled_offset (x) : runtime_address_to_index(x); short* p = &live_bits() + 1; add_long(p, target_bits); assert(p == instrs(), "new target must fit"); _target = x; }
static toff_t __tiff_size(thandle_t data) { struct cached_image *cimg=(struct cached_image *)data; struct tiff_decoder *deco=(struct tiff_decoder*)cimg->decoder; if (!deco->tiff_open)internal("BUG IN LIBTIFF: sizeproc called on closed file. Contact the libtiff authors.\n"); return deco->tiff_size; }
void material::set_param(int idx,const param_proxy &p,const param_proxy &m) { if(idx<0 || idx>=(int)internal().m_params.size()) return; m_internal.m_params[idx].p=p; m_internal.m_params[idx].m=m; m_internal.m_params[idx].a.free(); }
static int __tiff_close(void *data) { struct cached_image *cimg=(struct cached_image *)data; struct tiff_decoder *deco=(struct tiff_decoder*)cimg->decoder; if (!deco->tiff_open)internal("BUG IN LIBTIFF: closeproc called on closed file. Contact the libtiff authors.\n"); if (deco->tiff_data)mem_free(deco->tiff_data),deco->tiff_data=NULL; deco->tiff_open=0; return 0; }
void kill_buffer_data(struct read_buffer *rb, int n) { if (n > rb->len || n < 0) { internal("called kill_buffer_data with bad value"); rb->len = 0; return; } memmove(rb->data, rb->data + n, rb->len - n); rb->len -= n; }
static int __tiff_mmap(thandle_t data, tdata_t *dest, toff_t *len) { struct cached_image *cimg=(struct cached_image *)data; struct tiff_decoder *deco=(struct tiff_decoder*)cimg->decoder; if (!deco->tiff_open)internal("BUG IN LIBTIFF: mapproc called on closed file. Contact the libtiff authors.\n"); *dest=deco->tiff_data; *len=deco->tiff_size; return 0; }
uint32_t RuleSetPrivate::appendRule(const Rule& rule, uint32_t parent_id, bool lock) { std::unique_lock<std::mutex> op_lock(_op_mutex, std::defer_lock); if (lock) { op_lock.lock(); } auto rule_ptr = makePointer<Rule>(rule); /* * If the rule doesn't already have a sequence number * assigned, do it now. Otherwise update the sequence * number counter so that we don't generate a duplicit * one if assignID() gets called in the future. */ if (rule_ptr->getRuleID() == Rule::DefaultID) { assignID(rule_ptr); } else { _id_next = std::max(_id_next.load(), rule_ptr->getRuleID() + 1); } /* Initialize conditions */ rule_ptr->internal()->initConditions(_interface_ptr); /* Append the rule to the main rule table */ if (parent_id == Rule::LastID) { _rules.push_back(rule_ptr); } else if (parent_id == 0) { _rules.insert(_rules.begin(), rule_ptr); } else { bool parent_found = false; for (auto it = _rules.begin(); it != _rules.end(); ++it) { const Rule& rule = **it; if (rule.getRuleID() == parent_id) { _rules.insert(it+1, rule_ptr); parent_found = true; break; } } if (!parent_found) { throw Exception("Rule set append", "rule", "Invalid parent ID"); } } /* If the rule is timed, put it into the priority queue */ if (rule_ptr->getTimeoutSeconds() > 0) { _rules_timed.push(rule_ptr); } return rule_ptr->getRuleID(); }
skeletonVisualization::skeletonVisualization(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { ui.setupUi(this); ui.centralWidget->setContentsMargins(6, 6, 6, 6); ui.centralWidget->setLayout(ui.horizontalLayout); connect(ui.buttonOpen, SIGNAL(clicked()), this, SLOT(openImage())); connect(ui.actionOpen, SIGNAL(activated()), this, SLOT(openImage())); connect(ui.buttonRefresh, SIGNAL(clicked()), this, SLOT(updateSkeleton())); connect(ui.actionRefresh, SIGNAL(activated()), this, SLOT(updateSkeleton())); connect(ui.buttonSave, SIGNAL(clicked()), this, SLOT(saveImage())); connect(ui.actionSave, SIGNAL(activated()), this, SLOT(saveImage())); connect(ui.buttonConnect, SIGNAL(clicked()), this, SLOT(breaksConnector())); connect(ui.actionConnect, SIGNAL(activated()), this, SLOT(breaksConnector())); connect(ui.buttonQuit, SIGNAL(clicked()), this, SLOT(exitMethod())); connect(ui.actionQuit, SIGNAL(activated()), this, SLOT(exitMethod())); connect(ui.sliderScale, SIGNAL(valueChanged(int)), this, SLOT(setScaleValue(int))); connect(ui.checkBoxCircles, SIGNAL(stateChanged(int)), this, SLOT(checkBoxesChanged(int))); connect(ui.checkBoxBones, SIGNAL(stateChanged(int)), this, SLOT(checkBoxesChanged(int))); connect(ui.checkBoxContours, SIGNAL(stateChanged(int)), this, SLOT(checkBoxesChanged(int))); connect(ui.checkBoxImage, SIGNAL(stateChanged(int)), this, SLOT(checkBoxesChanged(int))); connect(ui.actionOn, SIGNAL(activated()), this, SLOT(scaleOn())); connect(ui.actionOff, SIGNAL(activated()), this, SLOT(scaleOff())); connect(ui.actionOriginal, SIGNAL(activated()), this, SLOT(scaleOrig())); connect(ui.actionInternal, SIGNAL(activated()), this, SLOT(internal())); connect(ui.actionExternal, SIGNAL(activated()), this, SLOT(external())); scene = 0; drawCircles = ready = 0; drawBones = drawImage = drawContours = skeletonView = 1; scale = 1.0; }
static void fb_switch_shutdown(void) { int rs; if (in_gr_operation <= 0) internal("fb_switch_shutdown: in_gr_operation %d", in_gr_operation); if (!fb_active && in_gr_operation == 1) { EINTRLOOP(rs, ioctl(TTY,VT_RELDISP,1)); } EINTRLOOP(rs, ioctl(TTY,VT_SETMODE, &vt_omode)); install_signal_handler(SIG_REL, (void (*)(void *))NULL, (void*)SIG_REL, 1); install_signal_handler(SIG_ACQ, (void (*)(void *))NULL, (void*)SIG_ACQ, 0); in_gr_operation--; }
void scene::set_location(const char *name) { nya_render::texture::set_default_aniso(2); if (!m_curve.is_valid()) { m_curve.create(); load("postprocess.txt"); set_texture("color_curve", m_curve); set_shader_param("screen_radius", nya_math::vec4(1.185185, 0.5 * 4.0 / 3.0, 0.0, 0.0)); set_shader_param("damage_frame", nya_math::vec4(0.35, 0.5, 1.0, 0.1)); m_flare.init(get_texture("main_color"), get_texture("main_depth")); m_cockpit_black.load("shaders/cockpit_black.nsh"); m_cockpit_black_quad.init(); m_missile_trails_renderer.init(); m_particles_render.init(); } if (is_native_location(name)) { auto &zip = get_native_location_provider(name); auto tex = load_texture(zip, "tonecurve.tga"); if (tex.get_width() > 0) { auto rtex = tex.internal().get_shared_data()->tex; rtex.set_wrap(nya_render::texture::wrap_clamp, nya_render::texture::wrap_clamp); m_curve.set(tex); } else m_curve.set(load_tonecurve("Map/tonecurve_default.tcb")); } else { if (m_location_name == "def" || m_location_name.empty()) m_curve.set(load_tonecurve("Map/tonecurve_default.tcb")); else m_curve.set(load_tonecurve(("Map/tonecurve_" + m_location_name + ".tcb").c_str())); } world::set_location(name); for (auto &a: m_aircrafts) a->apply_location(m_location_name.c_str(), m_location.get_params()); m_flare.apply_location(m_location.get_params()); auto &p = m_location.get_params(); set_shader_param("bloom_param", nya_math::vec4(p.hdr.bloom_threshold, p.hdr.bloom_offset, p.hdr.bloom_scale, 1.0)); set_shader_param("saturation", nya_math::vec4(p.tone_saturation * 0.01, 0.0, 0.0, 0.0)); m_luminance_speed = p.hdr.luminance_speed; m_fade_time = m_fade_max_time = 2000; }
char no_internal_point(int i, int j, int k) { int t; double square = s(i, j, k); for (t = 0; t < n; ++t) { if (t==i || t==j || t==k) continue; if (internal(i, j, k, t)) return 0; } return 1; }
static tsize_t __tiff_read(thandle_t data, tdata_t dest, tsize_t count) { struct cached_image *cimg=(struct cached_image *)data; struct tiff_decoder *deco=(struct tiff_decoder*)cimg->decoder; int n; if (!deco->tiff_open)internal("BUG IN LIBTIFF: readproc called on closed file. Contact the libtiff authors.\n"); n=(deco->tiff_pos+count>deco->tiff_size)?deco->tiff_size-deco->tiff_pos:count; memcpy(dest,deco->tiff_data+deco->tiff_pos,n); deco->tiff_pos+=n; return n; }
void breakpoint_Relocation::unpack_data() { _bits = live_bits(); int targetlen = datalen() - 1 - instrlen(); jint target_bits = 0; if (targetlen == 0) target_bits = 0; else if (targetlen == 1) target_bits = binding()->short_data_at(1); else if (targetlen == 2) target_bits = binding()-> long_data_at(1); else { ShouldNotReachHere(); } _target = internal() ? address_from_scaled_offset(target_bits) : index_to_runtime_address ((intptr_t)target_bits); }
int init_virtual_devices(struct graphics_driver *drv, int n) { if (n_virtual_devices) { internal("init_virtual_devices: already initialized"); return -1; } if ((unsigned)n > MAXINT / sizeof(struct graphics_device *)) overalloc(); virtual_devices = mem_calloc(n * sizeof(struct graphics_device *)); n_virtual_devices = n; virtual_device_timer = NULL; current_virtual_device = NULL; return 0; }
void read_select(struct connection *c) { struct read_buffer *rb; int rd; if (!(rb = c->buffer)) { internal("read socket has no buffer"); setcstate(c, S_INTERNAL); abort_connection(c); return; } set_handlers(rb->sock, NULL, NULL, NULL, NULL); if ((unsigned)rb->len > MAXINT - sizeof(struct read_buffer) - READ_SIZE) overalloc(); rb = mem_realloc(rb, sizeof(struct read_buffer) + rb->len + READ_SIZE); c->buffer = rb; #ifdef HAVE_SSL if(c->ssl) { if ((rd = SSL_read(c->ssl, rb->data + rb->len, READ_SIZE)) <= 0) { int err; if ((err = SSL_get_error(c->ssl, rd)) == SSL_ERROR_WANT_READ) { read_from_socket(c, rb->sock, rb, rb->done); return; } if (rb->close && !rd) { rb->close = 2; rb->done(c, rb); return; } setcstate(c, rd ? (err == SSL_ERROR_SYSCALL ? get_error_from_errno(errno) : S_SSL_ERROR) : S_CANT_READ); /*mem_free(rb);*/ if (!rd || err == SSL_ERROR_SYSCALL) retry_connection(c); else abort_connection(c); return; } } else #endif if ((rd = read(rb->sock, rb->data + rb->len, READ_SIZE)) <= 0) { if (rb->close && !rd) { rb->close = 2; rb->done(c, rb); return; } setcstate(c, rd ? get_error_from_errno(errno) : S_CANT_READ); /*mem_free(rb);*/ retry_connection(c); return; } log_data(rb->data + rb->len, rd); rb->len += rd; rb->done(c, rb); }
int process(char **args) { int return_val = 0; if (args[0] == NULL) { return_val = 0; } else if (is_control(args[0])) { return_val = do_control(args); } else if (is_ok()) { if (!internal(args, &return_val)) { return_val = execute(args); } } return return_val; }
void write_select(struct connection *c) { struct write_buffer *wb; int wr; if (!(wb = c->buffer)) { internal("write socket has no buffer"); setcstate(c, S_INTERNAL); abort_connection(c); return; } set_timeout(c); /*printf("ws: %d\n",wb->len-wb->pos); for (wr = wb->pos; wr < wb->len; wr++) printf("%c", wb->data[wr]); printf("-\n");*/ #ifdef HAVE_SSL if(c->ssl) { if ((wr = SSL_write(c->ssl, wb->data + wb->pos, wb->len - wb->pos)) <= 0) { int err; if ((err = SSL_get_error(c->ssl, wr)) != SSL_ERROR_WANT_WRITE) { setcstate(c, wr ? (err == SSL_ERROR_SYSCALL ? get_error_from_errno(errno) : S_SSL_ERROR) : S_CANT_WRITE); if (!wr || err == SSL_ERROR_SYSCALL) retry_connection(c); else abort_connection(c); return; } else return; } } else #endif if ((wr = write(wb->sock, wb->data + wb->pos, wb->len - wb->pos)) <= 0) { #ifdef ATHEOS /* Workaround for a bug in Syllable */ if (wr && errno == EAGAIN) { return; } #endif setcstate(c, wr ? get_error_from_errno(errno) : S_CANT_WRITE); retry_connection(c); return; } /*printf("wr: %d\n", wr);*/ if ((wb->pos += wr) == wb->len) { void (*f)(struct connection *) = wb->done; c->buffer = NULL; set_handlers(wb->sock, NULL, NULL, NULL, NULL); mem_free(wb); f(c); } }
long select_info(int type) { int i = 0, j; struct cache_entry *ce; switch (type) { case CI_FILES: for (j = 0; j < FD_SETSIZE; j++) if (threads[j].read_func || threads[j].write_func || threads[j].error_func) i++; return i; case CI_TIMERS: foreach(ce, timers) i++; return i; default: internal("cache_info: bad request"); } return 0; }
bool material::load(const char *name) { if(!m_internal.load(name)) return false; if(!internal().m_shared.is_valid()) return false; m_internal.m_last_set_pass_idx= -1; m_internal.m_should_rebuild_passes_maps=true; m_internal.m_name=m_internal.m_shared->m_name; m_internal.m_passes=m_internal.m_shared->m_passes; m_internal.m_params=m_internal.m_shared->m_params; m_internal.m_textures=m_internal.m_shared->m_textures; return true; }
void *html_special(struct part *p, int c, ...) { va_list l; unsigned char *t; struct form_control *fc; struct frameset_param *fsp; struct frame_param *fp; va_start(l, c); switch (c) { case SP_TAG: t = va_arg(l, unsigned char *); va_end(l); html_tag(p->data, t, X(p->cx), Y(p->cy)); break; case SP_CONTROL: fc = va_arg(l, struct form_control *); va_end(l); html_form_control(p, fc); break; case SP_TABLE: va_end(l); return convert_table; case SP_USED: va_end(l); return (void *)!!p->data; case SP_FRAMESET: fsp = va_arg(l, struct frameset_param *); va_end(l); return create_frameset(p->data, fsp); case SP_FRAME: fp = va_arg(l, struct frame_param *); va_end(l); create_frame(fp); break; case SP_NOWRAP: nowrap = va_arg(l, int); va_end(l); break; default: internal("html_special: unknown code %d", c); va_end(l); } return NULL; }
void png_restart(struct cached_image *cimg, unsigned char *data, int length) { png_structp png_ptr; png_infop info_ptr; #ifdef DEBUG if (!cimg->decoder) internal("decoder NULL in png_restart\n"); #endif /* #ifdef DEBUG */ png_ptr=((struct png_decoder *)(cimg->decoder))->png_ptr; info_ptr=((struct png_decoder *)(cimg->decoder))->info_ptr; end_callback_hit=0; if (setjmp(png_ptr->jmpbuf)){ img_end(cimg); return; } png_process_data(png_ptr, info_ptr, data, length); if (end_callback_hit) img_end(cimg); }
static int do_queued_lookup(struct dnsquery *q) { #ifndef THREAD_SAFE_LOOKUP q->next_in_queue = NULL; if (!dns_queue) { dns_queue = q; /*debug("direct lookup");*/ #endif return do_lookup(q, 0); #ifndef THREAD_SAFE_LOOKUP } else { /*debug("queuing lookup for %s", q->name);*/ if (dns_queue->next_in_queue) internal("DNS queue corrupted"); dns_queue->next_in_queue = q; dns_queue = q; return 1; } #endif }
/* Frees all data allocated by cached_image including cached image itself */ void img_destruct_cached_image(struct cached_image *cimg) { switch (cimg->state){ case 0: case 1: case 2: case 3: case 9: case 11: break; case 12: case 14: if (cimg->gamma_table) mem_free(cimg->gamma_table); if (cimg->bmp.user){ drv->unregister_bitmap(&(cimg->bmp)); } if (cimg->strip_optimized){ if (cimg->dregs) mem_free(cimg->dregs); }else{ mem_free(cimg->buffer); } case 8: case 10: destroy_decoder(cimg); break; case 13: case 15: drv->unregister_bitmap(&(cimg->bmp)); break; #ifdef DEBUG default: fprintf(stderr,"img_destruct_cached_image: state=%d\n",cimg->state); internal("Invalid state in struct cached_image"); #endif /* #ifdef DEBUG */ } mem_free(cimg->url); mem_free(cimg); }
static toff_t __tiff_seek(thandle_t data, toff_t offset, int whence) { struct cached_image *cimg=(struct cached_image *)data; struct tiff_decoder *deco=(struct tiff_decoder*)cimg->decoder; if (!deco->tiff_open)internal("BUG IN LIBTIFF: seekproc called on closed file. Contact the libtiff authors.\n"); switch(whence) { case SEEK_SET: deco->tiff_pos=(offset>(toff_t)deco->tiff_size)?(toff_t)deco->tiff_size:offset; break; case SEEK_CUR: deco->tiff_pos+=((toff_t)deco->tiff_pos+offset>(toff_t)deco->tiff_size)?(toff_t)deco->tiff_size-(toff_t)deco->tiff_pos:offset; break; case SEEK_END: deco->tiff_pos=(offset>(toff_t)deco->tiff_size)?0:(toff_t)deco->tiff_size-offset; break; } return deco->tiff_pos; }
int breakpoint_Relocation::pack_data() { short* p = data(); assert(p == &live_bits(), "initializing live_bits"); *p++ = _bits; jint target_bits = (jint) internal() ? scaled_offset (_target) : runtime_address_to_index(_target); if (settable()) { // save space for set_target later add_long(p, target_bits); } else { add_int (p, target_bits); } for (int i = 0; i < instrlen(); i++) { add_short(p, (short)0x7777); // placeholder value until bytes can be saved } return p - data(); }
int is_in_area(struct map_area *a, int x, int y) { int i; int over; switch (a->shape) { case SHAPE_DEFAULT: return 1; case SHAPE_RECT: return a->ncoords >= 4 && x >= a->coords[0] && y >= a->coords[1] && x < a->coords[2] && y < a->coords[3]; case SHAPE_CIRCLE: return a->ncoords >= 3 && (a->coords[0]-x)*(a->coords[0]-x)+(a->coords[1]-y)*(a->coords[1]-y) <= a->coords[2]*a->coords[2]; case SHAPE_POLY: over = 0; if (a->ncoords >= 4) for (i = 0; i + 1 < a->ncoords; i += 2) { int x1, x2, y1, y2; x1 = a->coords[i]; y1 = a->coords[i + 1]; x2 = a->coords[0]; y2 = a->coords[1]; if (i + 3 < a->ncoords) { x2 = a->coords[i + 2]; y2 = a->coords[i + 3]; } if (y1 > y2) { int sw; sw = x1; x1 = x2; x2 = sw; sw = y1; y1 = y2; y2 = sw; } if (y >= y1 && y < y2) { int po = 10000 * (y - y1) / (y2 - y1); int xs = x1 + (x2 - x1) * po / 10000; if (xs >= x) over++; } } return over & 1; default: internal("is_in_area: bad shape: %d", a->shape); } return 0; }
int split_line(struct part *p) { int i; /*if (!p->data) goto r;*/ /*printf("split: %d,%d , %d,%d,%d\n",p->cx,p->cy,par_format.rightmargin,par_format.leftmargin,p->cx);*/ for (i = rm(par_format); i >= par_format.leftmargin; i--) if (i < p->spl && p->spaces[i]) goto split; /*for (i = p->cx - 1; i > rm(par_format) && i > par_format.leftmargin; i--)*/ for (i = par_format.leftmargin; i < p->cx ; i++) if (i < p->spl && p->spaces[i]) goto split; /*for (i = rm(par_format); i >= par_format.leftmargin; i--) if ((POS(i, p->cy) & 0xff) == ' ') goto split; for (i = p->cx - 1; i > rm(par_format) && i > par_format.leftmargin; i--) if ((POS(i, p->cy) & 0xff) == ' ') goto split;*/ if (p->cx + par_format.rightmargin > p->x) p->x = p->cx + par_format.rightmargin; /*if (p->y < p->cy + 1) p->y = p->cy + 1; p->cy++; p->cx = -1; memset(p->spaces, 0, p->spl); if (p->data) xpand_lines(p, p->cy + 1);*/ /*line_break(p);*/ return 0; split: if (i + par_format.rightmargin > p->x) p->x = i + par_format.rightmargin; if (p->data) { #ifdef DEBUG if ((POS(i, p->cy) & 0xff) != ' ') internal("bad split: %c", (char)POS(i, p->cy)); #endif move_chars(p, i+1, p->cy, par_format.leftmargin, p->cy+1); del_chars(p, i, p->cy); } memmove(p->spaces, p->spaces + i + 1, p->spl - i - 1); memset(p->spaces + p->spl - i - 1, 0, i + 1); memmove(p->spaces + par_format.leftmargin, p->spaces, p->spl - par_format.leftmargin); p->cy++; p->cx -= i - par_format.leftmargin + 1; /*return 1 + (p->cx == par_format.leftmargin);*/ if (p->cx == par_format.leftmargin) p->cx = -1; if (p->y < p->cy + (p->cx != -1)) p->y = p->cy + (p->cx != -1); return 1 + (p->cx == -1); }
/* Fixes returned data in case they are CMYK or grayscale. */ static inline void fix_data( struct jpg_decoder *deco, int lines_read) { int a; switch (global_cinfo->output_components){ case 1: for (a=0; a<lines_read; a++) gray_to_rgb(deco->scanlines[a], global_cinfo ->output_width); break; case 3: break; case 4: cmyk_to_rgb(deco->scanlines[0], global_cinfo ->output_width*lines_read); break; default: internal("Invalid output_components"); } }
// Executes a command, as a child process int child (char command []) { int count=0; // Execute internal commands if (isInternal(command)) { internal (command); exit (0); } element = strtok (command, sep); while (element != NULL) { com[count] = element; count++; com[count] = NULL; element = strtok (NULL, sep); } // Execute command execvp (com[0], com); perror("Command was not found"); return EXIT_FAILURE; }