void Compiler::generateMetaData() { // Add global metadata for (map<Tree, set<Tree> >::iterator i = gMetaDataSet.begin(); i != gMetaDataSet.end(); i++) { if (i->first != tree("author")) { stringstream str1, str2; str1 << *(i->first); str2 << **(i->second.begin()); fJSON.declare(str1.str().c_str(), unquote(str2.str()).c_str()); } else { for (set<Tree>::iterator j = i->second.begin(); j != i->second.end(); j++) { if (j == i->second.begin()) { stringstream str1, str2; str1 << *(i->first); str2 << **j; fJSON.declare(str1.str().c_str(), unquote(str2.str()).c_str()); } else { stringstream str2; str2 << **j; fJSON.declare("contributor", unquote(str2.str()).c_str()); } } } } }
void identify(treasure_type *item) { /*{ Something has been identified }*/ integer i1,x1,x2; treas_ptr curse; x1 = item->tval; x2 = item->subval; if (strstr(item->name,"|") != NULL) { for (i1 = 0; i1 < MAX_TALLOC; i1++) { //with t_list[i1] do; if ((t_list[i1].tval == x1) && (t_list[i1].subval == x2)) { unquote(t_list[i1].name); known1(t_list[i1].name); } } for (i1 = Equipment_min; i1 <= Equipment_secondary; i1++) { //with equipment[i1] do; if ((equipment[i1].tval == x1) && (equipment[i1].subval == x2)) { unquote(equipment[i1].name); known1(equipment[i1].name); } } for(curse = inventory_list; curse != nil; curse = curse->next) { //with curse^.data do; if ((curse->data.tval == x1) && (curse->data.subval == x2)) { unquote(curse->data.name); known1(curse->data.name); } } i1 = 0; do { i1++; //with object_list[i1] do; if ((object_list[i1].tval == x1) && (object_list[i1].subval == x2)) { if (strstr(object_list[i1].name,"%T") != NULL) { insert_str(object_list[i1].name," %T|",""); object_ident[i1] = true; } else { unquote(object_list[i1].name); known1(object_list[i1].name); object_ident[i1] = true; } } } while (i1 != MAX_OBJECTS); } /* end if | */ };
Joystick Joystick::deserialize(std::string input){ Joystick joy; joy.is_xbox = stob(pullObject("\"is_xbox\"", input)); joy.type = std::stoi(pullObject("\"type\"",input)); joy.name = unquote(pullObject("\"name\"", input)); joy.buttons = std::stoi(pullObject("\"buttons\"", input)); joy.button_count = std::stoi(pullObject("\"button_count\"", input)); std::vector<int8_t> axes_deserialized = deserializeList(pullObject("\"axes\"",input), std::function<int8_t(std::string)>([&](std::string input){ return std::stoi(input);}), true); if(axes_deserialized.size() == joy.axes.size()){ joy.axes = axes_deserialized; } else { throw std::out_of_range("Exception: deserialization resulted in array of " + std::to_string(axes_deserialized.size()) + " axes, expected " + std::to_string(joy.axes.size())); } joy.axis_count = std::stoi(pullObject("\"axis_count\"", input)); std::vector<uint8_t> axis_types_deserialized = deserializeList(pullObject("\"axis_types\"",input), std::function<uint8_t(std::string)>([&](std::string input){ return std::stoi(input);}), true); if(axis_types_deserialized.size() == joy.axis_types.size()){ joy.axis_types = axis_types_deserialized; } else { throw std::out_of_range("Exception: deserialization resulted in array of " + std::to_string(axis_types_deserialized.size()) + " axis types, expected " + std::to_string(joy.axis_types.size())); } std::vector<int16_t> povs_deserialized = deserializeList(pullObject("\"povs\"",input), std::function<int16_t(std::string)>([&](std::string input){ return std::stoi(input);}), true); if(povs_deserialized.size() == joy.povs.size()){ joy.povs = povs_deserialized; } else { throw std::out_of_range("Exception: deserialization resulted in array of " + std::to_string(povs_deserialized.size()) + " povs, expected " + std::to_string(joy.povs.size())); } joy.pov_count = std::stoi(pullObject("\"pov_count\"", input)); joy.outputs = std::stoi(pullObject("\"outputs\"", input)); joy.left_rumble = std::stoi(pullObject("\"left_rumble\"", input)); joy.right_rumble = std::stoi(pullObject("\"right_rumble\"", input)); return joy; }
/* * Scan all leading options */ int leadOptions(char **Xline, optScanner fct, void * arg) { int ec = E_None; char *p, *q, *line; assert(Xline && *Xline); p = *Xline; while(*(line = skipdm(p))) { q = unquote(line, p = skipwd(line)); if(!q) { error_out_of_memory(); return E_NoMem; } if(!isoption(q) || ((ec = scanOption(fct, arg, q)) != E_None && ec != E_Ignore)) { free(q); break; } free(q); } *Xline = line; return ec; }
static int addArg(char ***Xarg, int *argc, char *sBeg, char **sEnd) { char **arg; assert(Xarg); assert(argc); assert(sEnd); assert(sBeg); *sEnd = skip_word(sBeg); /* find end of argument */ /* Because *start != '\0' && !isargdelim(*start) ==> s != start */ assert(*sEnd > sBeg); /* add new entry for new argument */ if((arg = realloc(*Xarg, (*argc + 2) * sizeof(char *))) == 0) { freep(*Xarg); return 1; } /* create new entry */ if((arg[*argc] = unquote(sBeg, *sEnd)) == 0) { freep(arg); return 1; } arg[++*argc] = 0; /* keep it a correct argv[] array if a freep() is triggered above */ *Xarg = arg; return 0; }
std::basic_istream<CharT>& operator>>(std::basic_istream<CharT>& is, RLeaf<StrType>& param){ //TODO: seems useless. remove this function? (Remove in .hpp also) StrType str; is>>str; str = unquote(str); param = RLeaf<StrType>(str); }
static void get_env_args(gint seq, gchar ** list, gchar * resp) { gchar *args; gint i; gdbio_pop_seq(seq); for (i = 0; list[i]; i++) { if (strncmp(list[i], "~\"", 2) == 0) { args = unquote(list[i] + 1); if (args && *args) { gchar *quote = strchr(g_strstrip(args), '"'); if (quote) { memmove(args, quote + 1, strlen(quote)); quote = strrchr(args, '"'); if (quote && g_str_equal(quote, "\".")) { *quote = '\0'; break; } } } g_free(args); args = NULL; } } env_info.args = args; if (gdbio_environ_func) { gdbio_environ_func(&env_info); } }
int passwd_val(char const * str, int dflt) { if ((str = unquote(str)) != NULL) { int i; for (i = 0; booltrue[i]; i++) if (strcmp(str, booltrue[i]) == 0) return P_YES; for (i = 0; boolfalse[i]; i++) if (strcmp(str, boolfalse[i]) == 0) return P_NO; /* * Special cases for defaultpassword */ if (strcmp(str, "random") == 0) return P_RANDOM; if (strcmp(str, "none") == 0) return P_NONE; errx(1, "Invalid value for default password"); } return dflt; }
int addArg(char ***Xarg, int *argc, char *sBeg, char **sEnd) { char **arg; assert(Xarg); assert(argc); assert(sEnd); assert(sBeg); *sEnd = skipwd(sBeg); /* find end of argument */ /* Because *start != '\0' && !isargdelim(*start) ==> s != start */ assert(*sEnd > sBeg); /* add new entry for new argument */ if((arg = realloc(*Xarg, (*argc + 2) * sizeof(char *))) == NULL) { freep(*Xarg); return 1; } /* create new entry */ if((arg[(*argc)++] = unquote(sBeg, *sEnd)) == NULL) { freep(arg); return 1; } *Xarg = arg; return 0; }
int APIENTRY WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, char* lpCmdLine, int /*nCmdShow*/) { std::string filename = unquote(lpCmdLine); std::string snippetUrl = sendFile(filename.c_str()); copyToClipboard(snippetUrl); return 0; }
void PothosUtilBase::loadModule(const std::string &, const std::string &path) { std::cout << "Loading: " << path << std::endl; //this tests module load and unload -- could throw or cause abort { Pothos::PluginModule module(unquote(path)); } std::cout << "success!" << std::endl; }
static size_t gettok (struct imap4d_tokbuf *tok, size_t off) { char *buf = tok->buffer; while (off < tok->level && mu_isblank (buf[off])) off++; if (tok->argc == tok->argmax) { if (tok->argmax == 0) tok->argmax = 16; else tok->argmax *= 2; tok->argp = realloc (tok->argp, tok->argmax * sizeof (tok->argp[0])); if (!tok->argp) imap4d_bye (ERR_NO_MEM); } if (buf[off] == '"') { char *start = buf + off + 1; char *p = NULL; while (*start && (p = strchr (start, '"'))) { if (p == start || p[-1] != '\\') break; start = p + 1; } if (p) { size_t len; off++; len = unquote (buf + off, p - (buf + off)); buf[off + len] = 0; tok->argp[tok->argc++] = off; return p - buf + 1; } } tok->argp[tok->argc++] = off; if (ISDELIM (buf[off])) return insert_nul (tok, off + 1); while (off < tok->level && !mu_isblank (buf[off])) { if (ISDELIM (buf[off])) return insert_nul (tok, off); off++; } insert_nul (tok, off); return off + 1; }
void MenuItem::DrawIcon(HDC hDC) { int size, px, py, d; /* if (m_ItemID & MENUITEM_ID_FOLDER) return; */ if (NULL == m_hIcon) { // if no icon yet, try to load it, either from explicit string // or from pidl_list if (m_pszIcon) { char path[MAX_PATH]; const char *p; int index; p = Tokenize(m_pszIcon, path, ","); index = 0; if (p) { index = atoi(p); if (index) --index; } unquote(path); ExtractIconEx(path, index, NULL, &m_hIcon, 1); } else if (m_pidl_list) { m_hIcon = sh_geticon(first_pidl(m_pidl_list), (Settings_menu.iconSize>16)?(32):(16)); } if (NULL == m_hIcon) return; } size = MenuInfo.nIconSize; d = (m_nHeight - size) / 2; px = m_nLeft + d; py = m_nTop + d; /* DrawIconEx(hDC, px, py, m_hIcon, size, size, 0, NULL, DI_NORMAL ); */ DrawIconSatnHue(hDC, px, py, m_hIcon, //size, size, 0, Settings_menu.iconSize, Settings_menu.iconSize, 0, /* BlackboxZero 1.4.2012 */ NULL, DI_NORMAL, //false == m_bActive, 40, 0 false == m_bActive, Settings_menu.iconSaturation, Settings_menu.iconHue /* BlackboxZero 1.3.2012 */ ); }
void wwwauthenticate(HttpState *hs, char *line) { char cred[64], *user, *pass, *realm, *s, *spec, *name; Fmt fmt; UserPasswd *up; spec = nil; up = nil; cred[0] = 0; hs->autherror[0] = 0; if(cistrncmp(line, "basic ", 6) != 0){ werrstr("unknown auth: %s", line); goto error; } line += 6; if(cistrncmp(line, "realm=", 6) != 0){ werrstr("missing realm: %s", line); goto error; } line += 6; user = hs->c->url->user; pass = hs->c->url->passwd; if(user==nil || pass==nil){ realm = unquote(line, &line); fmtstrinit(&fmt); name = servername(hs->netaddr); fmtprint(&fmt, "proto=pass service=http server=%q realm=%q", name, realm); free(name); if(hs->c->url->user) fmtprint(&fmt, " user=%q", hs->c->url->user); spec = fmtstrflush(&fmt); if(spec == nil) goto error; if((up = auth_getuserpasswd(nil, "%s", spec)) == nil) goto error; user = up->user; pass = up->passwd; } if((s = smprint("%s:%s", user, pass)) == nil) goto error; free(up); enc64(cred, sizeof(cred), (uint8_t*)s, strlen(s)); memset(s, 0, strlen(s)); free(s); hs->credentials = smprint("Basic %s", cred); if(hs->credentials == nil) goto error; return; error: free(up); free(spec); snprint(hs->autherror, sizeof hs->autherror, "%r"); fprint(2, "%s: Authentication failed: %r\n", argv0); }
static void imap4d_tokbuf_unquote (struct imap4d_tokbuf *tok, size_t *poff, size_t *plen) { char *buf = tok->buffer + *poff; if (buf[0] == '"' && buf[*plen - 1] == '"') { ++*poff; *plen = unquote (buf + 1, *plen - 1); } }
LPITEMIDLIST get_folder_pidl (const char *rawpath) { if (NULL==rawpath) return NULL; char path [MAX_PATH]; char temp [MAX_PATH]; unquote(temp, rawpath); if (false == is_relative_path(temp)) { if (is_alpha(temp[0]) && temp[1] == ':' && temp[2] == 0) temp[2] = '\\', temp[3] = 0; return sh_getpidl(NULL, temp); } const char *p = temp; int id = get_csidl(&p); if (NO_CSIDL == id || CSIDL_BLACKBOX == id || CSIDL_CURTHEME == id) { GetBlackboxPath(path, MAX_PATH); if (NO_CSIDL != id) path[strlen(path)-1] = 0; if (p) strcat(path, p); return sh_getpidl(NULL, path); } // special folders, like CONTROLS LPITEMIDLIST pID1, pID; if (NOERROR != SHGetSpecialFolderLocation(NULL, id, &pID1)) return sh_getpidl(NULL, temp); if (NULL == p) { pID = duplicateIDlist(pID1); } else { pID = NULL; // a subdirectory is specified, like APPDATA\microsoft // so get its local pidl and append it IShellFolder* pThisFolder = sh_get_folder_interface(pID1); if (pThisFolder) { LPITEMIDLIST pID2 = sh_getpidl(pThisFolder, p+1); if (pID2) { pID = joinIDlists(pID1, pID2); m_free(pID2); } } } SHMalloc_Free(pID1); return pID; }
void compile_messages(const char *filename) /* I - Message filename */ { int i; /* Looping var */ char msgname[1024], /* Message filename */ orig[1024], /* Original message text */ text[1024], /* Message text */ *ptr; /* Pointer into filename */ int num_msgs; /* Number of messages */ espmsg_t *msgs; /* Messages */ message_t *temp; /* Current message */ num_msgs = 0; msgs = NULL; for (i = num_messages, temp = messages; i > 0; i --, temp ++) if (temp->str && temp->str[0]) { unquote(orig, temp->id); unquote(text, temp->str); if (strcmp(orig, text)) num_msgs = espAddMessage(orig, text, num_msgs, &msgs); } if (num_msgs == 0) { printf("espmsg: No messages in \"%s\" to compile!\n", filename); return; } strcpy(msgname, filename); if ((ptr = strrchr(msgname, '.')) != NULL) *ptr = '\0'; if (espSaveMessages(msgname, num_msgs, msgs)) printf("espmsg: Unable to save messages into \"%s\" - %s\n", msgname, strerror(errno)); else printf("espmsg: Compiled %d messages into \"%s\".\n", num_msgs, msgname); }
static void eval(char *line, Engine *engine) { line = unquote(line); scheduleMsg(&logger, "Parsing [%s]", line); evalPool.reset(); LEElement * e = evalPool.parseExpression(line); if (e == NULL) { scheduleMsg(&logger, "parsing failed"); } else { float result = evalCalc.getValue2(e, engine); scheduleMsg(&logger, "Eval result: %f", result); } }
char * newstr(char const * p) { char *q = NULL; if ((p = unquote(p)) != NULL) { int l = strlen(p) + 1; if ((q = malloc(l)) != NULL) memcpy(q, p, l); } return q; }
void Search::ProcessName(const string& Src) const { auto Buffer = unquote(m_FindEdit->GetString() + Src); for (; !Buffer.empty() && !m_Owner->FindPartName(Buffer, FALSE, 1); Buffer.pop_back()) ; if (!Buffer.empty()) { m_FindEdit->SetString(Buffer); m_FindEdit->Show(); } }
char * newstr(char const * p) { char *q; if ((p = unquote(p)) == NULL) return (NULL); if ((q = strdup(p)) == NULL) err(1, "strdup()"); return (q); }
int boolean_val(char const * str, int dflt) { if ((str = unquote(str)) != NULL) { int i; for (i = 0; booltrue[i]; i++) if (strcmp(str, booltrue[i]) == 0) return 1; for (i = 0; boolfalse[i]; i++) if (strcmp(str, boolfalse[i]) == 0) return 0; } return dflt; }
static char * get_arg(char *args, char **key, char **val) { int inquote; *key = args; *val = NULL; inquote = 0; while (*args && (inquote || !isspace(*args))) { if (*args == '"') inquote = !inquote; else if (*args == '=' && !*val) { *args = '\0'; *val = args + 1; } ++args; } unquote(key, args); unquote(val, args); if (*args) *args++ = '\0'; return skipws(args); }
static char *unquote_and_strip(char *line) { char *p = unquote(line); char *p2; char *cvtd_line; while (*p && isspace(*p)) ++p; cvtd_line = (char *)emalloc(strlen(p) + 1); strcpy(cvtd_line, p); p2 = cvtd_line + strlen(cvtd_line); if (p2 > cvtd_line && p2[-1] == '\n') *--p2 = 0; if (p2 > cvtd_line && *--p2 == '-') *p2 = 0; /* don't demand trailing '-' in searches; may have been unhyphenated */ return cvtd_line; }
char *replace_shellfolders(char *buffer, const char *path, bool search_path) { char temp [MAX_PATH]; const char *p = unquote(temp, path); if (false == is_relative_path(temp)) return strcpy(buffer, temp); int id = get_csidl(&p); if (CSIDL_BLACKBOX == id || CSIDL_CURTHEME == id) { GetBlackboxPath(buffer, MAX_PATH); buffer[strlen(buffer)-1] = 0; } else if (NO_CSIDL == id) { if (search_path) { if (SearchPath(NULL, temp, ".exe", MAX_PATH, buffer, NULL)) return buffer; else return strcpy(buffer, temp); } GetBlackboxPath(buffer, MAX_PATH); } else { // special folders, like CONTROLS LPITEMIDLIST pID; HRESULT hr = SHGetSpecialFolderLocation(NULL, id, &pID); if (NOERROR != hr) return strcpy(buffer, temp); // returns also things like "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" // (unlike SHGetPathFromIDList) BOOL result = sh_get_displayname(NULL, pID, SHGDN_FORPARSING, buffer); SHMalloc_Free(pID); if (FALSE == result) return strcpy(buffer, temp); } if (p) strcat(buffer, p); return buffer; }
char * extract_cmd_name(const char line[], int raw, size_t buf_len, char buf[]) { const char *result; #ifdef _WIN32 int left_quote, right_quote = 0; #endif line = skip_whitespace(line); #ifdef _WIN32 if((left_quote = (line[0] == '"'))) { result = strchr(line + 1, '"'); } else #endif { result = strchr(line, ' '); } if(result == NULL) { result = line + strlen(line); } #ifdef _WIN32 if(left_quote && (right_quote = (result[0] == '"'))) { result++; } #endif snprintf(buf, MIN(result - line + 1, buf_len), "%s", line); #ifdef _WIN32 if(!raw && left_quote && right_quote) { unquote(buf); } #endif if(!raw) { fuse_strip_mount_metadata(buf); } result = skip_whitespace(result); return (char *)result; }
int editor_type::cmd_j (command_type& ct) { std::wstring sep; unquote (ct.param, sep); std::wstring doc; for (std::size_t line = line1; line <= line2; ++line) { if (line > line1) doc.append (sep); std::wstring::const_iterator s, e; buffer.get (line, s, e); chomp_bang (s, e); doc.append (s, e); } doc.push_back ('\n'); buffer.change (line1, line2, doc); return ct.command; }
static void InitTemplateProfile(string &strTemplatePath) { if (strTemplatePath.empty()) { strTemplatePath = GetFarIniString(L"General"s, L"TemplateProfile"s, path::join(L"%FARHOME%"sv, L"Default.farconfig"sv)); } if (!strTemplatePath.empty()) { strTemplatePath = ConvertNameToFull(unquote(os::env::expand(strTemplatePath))); DeleteEndSlash(strTemplatePath); if (os::fs::is_directory(strTemplatePath)) path::append(strTemplatePath, L"Default.farconfig"sv); Global->Opt->TemplateProfilePath = strTemplatePath; } }
static bool try_arg(const string& cmd, const string& prefix_, string& arg) { if (prefix_.empty()) return false; // No such command string prefix( prefix_ ); if (!prefix.contains(" ", -1)) prefix += " "; if (cmd.contains(prefix, 0)) { arg = cmd.after(prefix); strip_space(arg); // Strip format stuff while (arg.contains('/', 0)) arg = arg.after(' '); if (arg.contains("'", 0)) { // Quoted arg -- add as unquoted arg = unquote(arg); return true; } else if (is_file_pos(arg)) { // FILE:LINE arg -- ignore return false; } else if (arg.matches(rxint)) { // LINE arg -- ignore return false; } else { // Other arg -- add unchanged return true; } } // Bad prefix -- ignore return false; }
bool String::unquote(const char *clist) { assert(clist != NULL); char *s; if(!str) return false; str->unfix(); s = unquote(str->text, clist); if(!s) { str->fix(); return false; } set(s); return true; }