void web_page::set_base_url( const litehtml::tchar_t* base_url ) { #ifndef LITEHTML_UTF8 if(base_url) { if(PathIsRelative(base_url) && !PathIsURL(base_url)) { make_url(base_url, m_url.c_str(), m_base_path); } else { m_base_path = base_url; } } else { m_base_path = m_url; } #else LPWSTR bu = cairo_font::utf8_to_wchar(base_url); if(bu) { if(PathIsRelative(bu) && !PathIsURL(bu)) { make_url(bu, m_url.c_str(), m_base_path); } else { m_base_path = bu; } } else { m_base_path = m_url; } #endif }
static void start_push(HTTPCaller *caller, long i) { List *push_headers; Octstr *push_content; long *id; push_content = push_content_create(); push_headers = push_headers_create(octstr_len(push_content)); if (verbose) { debug("test.ppg", 0, "we have push content"); octstr_dump(push_content, 0); debug("test.ppg", 0, "and headers"); http_header_dump(push_headers); } id = gw_malloc(sizeof(long)); *id = i; make_url(&push_url); debug("test.ppg", 0, "TEST_PPG: starting to push job %ld", i); http_start_request(caller, HTTP_METHOD_POST, push_url, push_headers, push_content, 0, id, ssl_client_certkey_file); debug("test.ppg", 0, "push done"); octstr_destroy(push_content); http_destroy_headers(push_headers); }
static void remove_output_from_cache(t_session *session, char *request_uri, t_cot_type cot_type) { t_cached_object *object; char *url; int index; if ((url = make_url(session, request_uri)) == NULL) { return; } else if ((index = cache_index(url)) == -1) { free(url); return; } pthread_mutex_lock(&cache_mutex[index]); object = cache[index]; while (object != NULL) { if (object->type == cot_type) { if (strcmp(object->file, url) == 0) { if (object->in_use <= 0) { remove_from_cache(object, index); } else { object->deadline = 0; } break; } } object = object->next; } pthread_mutex_unlock(&cache_mutex[index]); free(url); }
void cairo_container::make_url_utf8( const char* url, const char* basepath, std::wstring& out ) { wchar_t* urlW = cairo_font::utf8_to_wchar(url); wchar_t* basepathW = cairo_font::utf8_to_wchar(basepath); make_url(urlW, basepathW, out); if(urlW) delete urlW; if(basepathW) delete basepathW; }
void perform(Action&& action, typename callback<Action>::type callback, long timeout) { const std::string url = make_url(action.path()); response_handler_t< Action, http_connection_t > handler(callback, endpoint_, log); ES_LOG(log, "requesting '%s' ...", url); perform(std::move(action), std::move(handler), url, timeout); }
SEXP make_handle_response(reference *ref){ CURL *handle = ref->handle; SEXP res = PROTECT(allocVector(VECSXP, 6)); SET_VECTOR_ELT(res, 0, make_url(handle)); SET_VECTOR_ELT(res, 1, make_status(handle)); SET_VECTOR_ELT(res, 2, make_rawvec(ref->resheaders.buf, ref->resheaders.size)); SET_VECTOR_ELT(res, 3, make_filetime(handle)); SET_VECTOR_ELT(res, 4, make_timevec(handle)); SET_VECTOR_ELT(res, 5, R_NilValue); setAttrib(res, R_NamesSymbol, make_namesvec()); UNPROTECT(1); return res; }
void RenderContext::get_image_size( const litehtml::tchar_t* src, const litehtml::tchar_t* baseurl, litehtml::size& sz ) { litehtml::tstring url; make_url(src, baseurl, url); ImagesMap::iterator img = m_images.find(url.c_str()); if(img != m_images.end()) { sz.width = img->second.width(); sz.height = img->second.height(); } else { sz.width = 0; sz.height = 0; } }
PROCESS_THREAD(sense_process, ev, data) { PROCESS_BEGIN(); etimer_set(&timer, CLOCK_SECOND*20); make_url(); while (1) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer)); process_start(&httpd_ws_process, NULL); post_json(); etimer_reset(&timer); } PROCESS_END(); }
void RenderContext::load_image( const litehtml::tchar_t* src, const litehtml::tchar_t* baseurl, bool redraw_on_ready ) { litehtml::tstring url; make_url(src, baseurl, url); if(m_images.find(url.c_str()) == m_images.end()) { try { Picture img = get_image(url.c_str(), true); if(img.isValid()) { m_images[url] = img; } } catch(...) { int iii=0; iii++; } } }
void do_configmenu() { int menu_no; int opts; menu_ent me[CONFIGOPT_LAST]; configinfo *ce[CONFIGOPT_LAST]; wrefresh(curscr); wmove(stdscr, 0, 0); wclear(stdscr); wrefresh(stdscr); /* if the target isn't mounted already, figure it out. */ if (target_mounted() == 0) { if (find_disks(msg_string(MSG_configure_prior)) < 0) return; if (mount_disks() != 0) return; } config_list_init(); make_url(pkgpath, &pkg, pkg_dir); opts = init_config_menu(config_list, me, ce); menu_no = new_menu(NULL, me, opts, 0, -4, 0, 70, MC_SCROLL | MC_NOBOX | MC_DFLTEXIT, configmenu_hdr, set_config, NULL, "XXX Help String", MSG_doneconfig); process_menu(menu_no, ce); free_menu(menu_no); sanity_check(); }
static int set_binpkg(struct menudesc *menu, void *arg) { configinfo **confp = arg; char pattern[STRSIZE]; /* binary pkg config requires network at this point, so if it's not already configured, do it. */ if (network_up == 0) { if (config_network()) mnt_net_config(); } process_menu(MENU_binpkg, NULL); make_url(pkgpath, &pkg, pkg_dir); if ( run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT, "pkg_add %s/pkgin", pkgpath) != 0) { msg_display(MSG_pkgin_failed); process_menu(MENU_ok, NULL); confp[menu->cursel]->setting = MSG_failed; return 0; } /* configure pkgin to use $pkgpath as a repository */ snprintf(pattern, STRSIZE, "s,^[^#].*$,%s,", pkgpath); replace("/usr/pkg/etc/pkgin/repositories.conf", pattern); run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT, "/usr/pkg/bin/pkgin -y update"); msg_display(MSG_binpkg_installed); process_menu(MENU_ok, NULL); confp[menu->cursel]->setting = MSG_DONE; return 0; }
static int do_ftp_fetch(const char *set_name, struct ftpinfo *f) { const char *ftp_opt; char url[STRSIZE]; int rval; /* * Invoke ftp to fetch the file. */ if (strcmp("ftp", f->user) == 0 && f->pass[0] == 0) { /* do anon ftp */ ftp_opt = "-a "; } else { ftp_opt = ""; } make_url(url, f, set_dir_for_set(set_name)); rval = run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_XFER_DIR, "/usr/bin/ftp %s%s/%s%s", ftp_opt, url, set_name, dist_postfix); return rval ? SET_RETRY : SET_OK; }
static t_cached_object *search_cache_for_output(t_session *session, t_cot_type cot_type) { t_cached_object *object, *result = NULL; char *url; int index; if ((url = make_url(session, NULL)) == NULL) { return NULL; } else if ((index = cache_index(url)) == -1) { free(url); return NULL; } pthread_mutex_lock(&cache_mutex[index]); object = cache[index]; while (object != NULL) { if (object->type == cot_type) { if (strcmp(object->file, url) == 0) { if (object->deadline > session->time) { object->in_use++; result = object; } else if (object->in_use <= 0) { remove_from_cache(object, index); } break; } } object = object->next; } pthread_mutex_unlock(&cache_mutex[index]); free(url); return result; }
/* Prepare an LDAP query to return certificates matching PATTERNS using the SERVER. This function returns an error code or 0 and a CONTEXT on success. */ gpg_error_t start_cert_fetch_ldap (ctrl_t ctrl, cert_fetch_context_t *context, strlist_t patterns, const ldap_server_t server) { gpg_error_t err; char *proxy = NULL; char *host = NULL; int port; char *user = NULL; char *pass = NULL; const char *base; char *argv[50]; int argc = 0; int argc_malloced = 0; char portbuf[30], timeoutbuf[30]; *context = NULL; if (opt.ldap_proxy && !(proxy = xtrystrdup (opt.ldap_proxy))) { err = gpg_error_from_syserror (); goto leave; } if (server) { if (server->host && !(host = xtrystrdup (server->host))) { err = gpg_error_from_syserror (); goto leave; } port = server->port; if (server->user && !(user = xtrystrdup (server->user))) { err = gpg_error_from_syserror (); goto leave; } if (server->pass && !(pass = xtrystrdup (server->pass))) { err = gpg_error_from_syserror (); goto leave; } base = server->base; } else /* Use a default server. */ return gpg_error (GPG_ERR_NOT_IMPLEMENTED); if (!base) base = ""; if (pass) /* Note: Must be the first item. */ { argv[argc++] = "--pass"; argv[argc++] = pass; } if (DBG_LOOKUP) argv[argc++] = "-vv"; else if (DBG_EXTPROG) argv[argc++] = "-v"; argv[argc++] = "--log-with-pid"; argv[argc++] = "--multi"; if (opt.ldaptimeout) { snprintf (timeoutbuf, sizeof timeoutbuf, "%u", opt.ldaptimeout); argv[argc++] = "--timeout"; argv[argc++] = timeoutbuf; } if (opt.ldap_proxy) { argv[argc++] = "--proxy"; argv[argc++] = proxy; } if (host) { argv[argc++] = "--host"; argv[argc++] = host; } if (port) { snprintf (portbuf, sizeof portbuf, "%d", port); argv[argc++] = "--port"; argv[argc++] = portbuf; } if (user) { argv[argc++] = "--user"; argv[argc++] = user; } /* All entries in argv from this index on are malloc'ed. */ argc_malloced = argc; for (; patterns; patterns = patterns->next) { strlist_t sl; char *url; if (argc >= DIM (argv) - 1) { /* Too many patterns. It does not make sense to allow an arbitrary number of patters because the length of the command line is limited anyway. */ /* fixme: cleanup. */ return gpg_error (GPG_ERR_RESOURCE_LIMIT); } sl = parse_one_pattern (patterns->d); if (!sl) { log_error (_("start_cert_fetch: invalid pattern '%s'\n"), patterns->d); err = gpg_error (GPG_ERR_INV_USER_ID); goto leave; } if ((sl->flags & 1)) err = make_url (&url, sl->d, "objectClass=*"); else err = make_url (&url, base, sl->d); free_strlist (sl); if (err) goto leave; argv[argc++] = url; } argv[argc] = NULL; *context = xtrycalloc (1, sizeof **context); if (!*context) { err = gpg_error_from_errno (errno); goto leave; } err = ldap_wrapper (ctrl, &(*context)->reader, (const char**)argv); if (err) { xfree (*context); *context = NULL; } leave: for (; argc_malloced < argc; argc_malloced++) xfree (argv[argc_malloced]); xfree (proxy); xfree (host); xfree (user); xfree (pass); return err; }
void RenderContext::draw_background( litehtml::uint_ptr hdc, const litehtml::background_paint& bg ) { /*cairo_save(cr); apply_clip(cr); rounded_rectangle(cr, bg.border_box, bg.border_radius); cairo_clip(cr); */ //cr->fill( NColor( bg.color.alpha, bg.color.red, bg.color.green, bg.color.blue ), // Rect( bg.clip_box.x, bg.clip_box.y, bg.clip_box.x+bg.clip_box.width, bg.clip_box.y+bg.clip_box.height) ); litehtml::tstring url; make_url(bg.image.c_str(), bg.baseurl.c_str(), url); //lock_images_cache(); ImagesMap::iterator img_i = m_images.find(url.c_str()); if(img_i != m_images.end() && img_i->second.isValid()) { Picture bgbmp = img_i->second; Picture new_img; if(bg.image_size.width != bgbmp.width() || bg.image_size.height != bgbmp.height()) { //new_img = bgbmp->scale_simple(bg.image_size.width, bg.image_size.height, Gdk::INTERP_BILINEAR); bgbmp = new_img; } /* cairo_surface_t* img = surface_from_pixbuf(bgbmp); cairo_pattern_t *pattern = cairo_pattern_create_for_surface(img); cairo_matrix_t flib_m; cairo_matrix_init_identity(&flib_m); cairo_matrix_translate(&flib_m, -bg.position_x, -bg.position_y); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); cairo_pattern_set_matrix (pattern, &flib_m); */ switch(bg.repeat) { case litehtml::background_repeat_no_repeat: //cr->draw( bgbmp, Point( bg.position_x, bg.position_y ), Size( bgbmp.width(), bgbmp.height() ) ); break; case litehtml::background_repeat_repeat_x: /*cairo_set_source(cr, pattern); cairo_rectangle(cr, bg.clip_box.left(), bg.position_y, bg.clip_box.width, bgbmp->get_height()); cairo_fill(cr);*/ break; case litehtml::background_repeat_repeat_y: /*cairo_set_source(cr, pattern); cairo_rectangle(cr, bg.position_x, bg.clip_box.top(), bgbmp->get_width(), bg.clip_box.height); cairo_fill(cr);*/ break; case litehtml::background_repeat_repeat: /*cairo_set_source(cr, pattern); cairo_rectangle(cr, bg.clip_box.left(), bg.clip_box.top(), bg.clip_box.width, bg.clip_box.height); cairo_fill(cr); */ break; } //cairo_pattern_destroy(pattern); //cairo_surface_destroy(img); } }
static t_cached_object *add_output_to_cache(t_session *session, char *output, int size, int time, t_cot_type cot_type) { t_cached_object *object; size_t len; char *pos, *loc, *data, str[50]; if ((pos = strstr(output, "\r\n\r\n")) == NULL) { return NULL; } *pos = '\0'; loc = strcasestr(output, hs_conlen); *pos = '\r'; if (loc == NULL) { /* Output has no Content-Length */ len = size - (pos + 4 - output); sprintf(str, "%s%ld\r\n", hs_conlen, (long)len); len = strlen(str); if ((data = (char*)malloc(len + size)) == NULL) { return NULL; } memcpy(data, str, len); memcpy(data + len, output, size); size += len; } else { /* Output has Content-Length */ if ((data = (char*)malloc(size)) == NULL) { return NULL; } memcpy(data, output, size); } secure_header(output); if ((object = (t_cached_object*)malloc(sizeof(t_cached_object))) == NULL) { clear_free(data, size); return NULL; } else if ((object->file = make_url(session, NULL)) == NULL) { clear_free(data, size); free(object); return NULL; } object->deadline = session->time + time; object->size = size; object->in_use = 0; object->type = cot_type; object->data = data; copy_ip(&(object->last_ip), &(session->ip_address)); if (add_object_to_cache(object) == false) { clear_free(object->data, size); free(object->file); free(object); return NULL; } return object; }