ptr scheme_entry(context* ctxt, char* stack_base, memory* mem) { char* heap = mem->heap_next; if (global_fun == 0) { global_fun = ((ptr) &inc) | closure_tag; } stack_base[-1] = 110 + global_foo; heap[0] = 'a'; heap[1] = fancy(heap[0]); heap[2] = global_fun; ptr p = 0 | (heap[0] << char_shift) | char_tag; return p; }
int main(int argc, char **argv) { struct Cell_head window; struct Categories cats; struct GModule *module; struct Option *opt1, *opt2, *opt3; struct Flag *fancy_mode, *simple_mode, *draw; char *tmpfile; FILE *fp; /* Initialize the GIS calls */ G_gisinit(argv[0]); module = G_define_module(); G_add_keyword(_("display")); G_add_keyword(_("cartography")); module->description = _("Create a TITLE for a raster map in a form suitable " "for display with d.text."); opt1 = G_define_standard_option(G_OPT_R_MAP); opt2 = G_define_option(); opt2->key = "color"; opt2->type = TYPE_STRING; opt2->answer = DEFAULT_FG_COLOR; opt2->required = NO; opt2->gisprompt = "old_color,color,color"; opt2->description = _("Sets the text color"); opt3 = G_define_option(); opt3->key = "size"; opt3->type = TYPE_DOUBLE; opt3->answer = "4.0"; opt3->options = "0-100"; opt3->description = _("Sets the text size as percentage of the frame's height"); draw = G_define_flag(); draw->key = 'd'; draw->description = _("Draw title on current display"); fancy_mode = G_define_flag(); fancy_mode->key = 'f'; fancy_mode->description = _("Do a fancier title"); /* currently just title, but it doesn't have to be /that/ simple */ simple_mode = G_define_flag(); simple_mode->key = 's'; simple_mode->description = _("Do a simple title"); /* Check command line */ if (G_parser(argc, argv)) exit(EXIT_FAILURE); map_name = opt1->answer; color = opt2->answer; if (opt3->answer != NULL) sscanf(opt3->answer, "%f", &size); type = fancy_mode->answer ? FANCY : NORMAL; if (fancy_mode->answer && simple_mode->answer) G_fatal_error(_("Title can be fancy or simple, not both")); if (!strlen(map_name)) G_fatal_error(_("No map name given")); Rast_get_cellhd(map_name, "", &window); if (Rast_read_cats(map_name, "", &cats) == -1) G_fatal_error(_("Unable to read category file of raster map <%s>"), map_name); if (draw->answer) { tmpfile = G_convert_dirseps_to_host(G_tempfile()); if (!(fp = fopen(tmpfile, "w"))) G_fatal_error(_("Unable to open temporary file <%s>"), tmpfile); } else fp = stdout; if (type == NORMAL) normal(&window, &cats, simple_mode->answer, fp); else fancy(&window, &cats, fp); if (draw->answer) { char inarg[GPATH_MAX]; fclose(fp); sprintf(inarg, "input=%s", tmpfile); G_spawn("d.text", "d.text", inarg, NULL); unlink(tmpfile); /* note a tmp file will remain, created by d.text so it can survive d.redraw */ } exit(EXIT_SUCCESS); }
bool request_handler::url_parse(const std::string& url, std::string& request_path, hash_map< std::string, std::vector<std::string> >& query_params) { std::string::size_type path_len; try { path_len = url.find_first_of("?"); } catch (std::exception& e) { path_len = url.size(); } try { request_path = libtorrent::unescape_string(url.substr(0, path_len)); } catch (std::runtime_error& exc) { return false; } std::string query_string = url.substr(path_len + 1, url.size() - (path_len + 1)); str query_copy = strdup(query_string.c_str()); boost::shared_ptr<char> fancy(query_copy, free); str query = query_copy; str kvpairs = strsep(&query, '&'); for (; kvpairs != NULL; kvpairs = strsep(&query, '&')) { if (*kvpairs == 0) continue; str kvpairs2 = strdup(kvpairs); boost::shared_ptr<char> fancy(kvpairs2, free); str skey = strsep(&kvpairs2, '='); if (skey == NULL || *skey == 0) continue; str sval = strsep(&kvpairs2, '='); if (sval == NULL || *sval == 0) continue; std::string key; std::string val; try { key = libtorrent::unescape_string(skey); } catch (std::runtime_error& exc) { return false; } try { val = libtorrent::unescape_string(sval); } catch (std::runtime_error& exc) { return false; } //logger << key << " = " << val << std::endl; if (query_params.count(key)) { std::vector<std::string>& vals = query_params[key]; vals.push_back(val); } else { std::vector<std::string> vals; vals.push_back(val); query_params[key] = vals; } } return true; }