static int Set(openfile* p,int No,const void* Data,int Size) { int Result = ERR_INVALID_PARAM; switch (No) { case OPENFILE_MULTIPLE: SETVALUE(p->Multiple,bool_t,ERR_NONE); break; case OPENFILE_FLAGS: SETVALUE(p->Flags,int,ERR_NONE); break; case OPENFILE_CLASS: SETVALUE(p->Class,int,ERR_NONE); break; case OPENFILE_FILETYPE: SETVALUE(p->FileType,int,ERR_NONE); break; case OPENFILE_FILETYPE_SINGLE: SETVALUE(p->FileTypeSingle,int,ERR_NONE); break; case OPENFILE_FILETYPE_SAVE: SETVALUE(p->FileTypeSave,int,ERR_NONE); break; case OPENFILE_PATH: SETSTRING(p->Path); break; case OPENFILE_SORTCOL: SETVALUE(p->SortCol,int,ERR_NONE); break; case OPENFILE_SORTDIR: SETVALUE(p->SortDir,bool_t,ERR_NONE); break; case OPENFILE_WIDTH_NAME: SETVALUE(p->DlgWidth[0],int,ERR_NONE); break; case OPENFILE_WIDTH_TYPE: SETVALUE(p->DlgWidth[1],int,ERR_NONE); break; case OPENFILE_WIDTH_SIZE: SETVALUE(p->DlgWidth[2],int,ERR_NONE); break; case OPENFILE_ONLYNAME: SETVALUE(p->OnlyName,bool_t,UpdateOnlyName(p)); break; case OPENFILE_HISTORYCOUNT: SETVALUE(p->HistoryCount,int,ERR_NONE); break; case OPENFILE_SAVE_NAME: SETSTRING(p->SaveName); break; case OPENFILE_SAVE_TYPE: SETVALUE(p->FileTypeSave,int,ERR_NONE); break; } if (No >= OPENFILE_HISTORY && No < OPENFILE_HISTORY+p->HistoryCount) { free(p->History[No-OPENFILE_HISTORY]); p->History[No-OPENFILE_HISTORY] = tcsdup((tchar_t*)Data); Result = ERR_NONE; } return Result; }
escm_atom * escm_and_let_star(escm *e, escm_atom *args, void *data) { escm_atom *claws, *arg, *prevenv, *val; escm_cons *c; (void) data; claws = escm_cons_pop(e, &args); escm_assert(ESCM_ISCONS(claws), claws, e); /* we create the new environment and enter it */ prevenv = escm_env_enter(e, escm_env_new(e, e->env)); val = e->TRUE; /* the we parse each claw and bind each variable */ while ((arg = escm_cons_pop(e, &claws))) { if (ESCM_ISSYM(arg)) { val = escm_atom_eval(e, arg); if (!ESCM_ISTRUE(e, val)) goto falseret; } else { escm_assert1(ESCM_ISCONS(arg), arg, e, escm_env_leave(e, prevenv)); c = escm_cons_val(arg); escm_assert1(c->cdr == e->NIL || escm_cons_val(c->cdr)->cdr == e->NIL, arg, e, escm_env_leave(e, prevenv)); if (c->cdr == e->NIL) { val = escm_atom_eval(e, c->car); if (!ESCM_ISTRUE(e, val)) goto falseret; } else { escm_assert1(ESCM_ISSYM(c->car), c->car, e, escm_env_leave(e, prevenv)); val = escm_atom_eval(e, escm_cons_val(c->cdr)->car); if (ESCM_ISCLOSURE(val) && !escm_proc_val(val)->name) escm_proc_val(val)->name = tcsdup(escm_sym_name(c->car)); escm_env_set(e, e->env, c->car, val); } } } if (escm_cons_val(args) != NULL) val = escm_and(e, args, NULL); escm_env_leave(e, prevenv); return val; falseret: escm_env_leave(e, prevenv); return e->FALSE; }
/** * @brief set the string as input */ escm_input * escm_input_str(const tchar *str) { escm_input *f; assert(str != NULL); f = xcalloc(1, sizeof *f); f->type = INPUT_STR; f->d.str.str = tcsdup(str); f->d.str.cur = f->d.str.str; return f; }
/** * @brief get a string. Each character is passed to "fun" which must return 1 * if the character is valid, 0 else (cf ctype.h) */ tchar * escm_input_getstr_fun(escm_input *f, int (*fun)(tint), int casesens) { size_t len = 0; tint c; assert(f != NULL); do { c = escm_input_getc(f); if (!casesens) c = tolower(c); strbuf[len++] = c; } while (c != TEOF && fun(c)); if (!f->end) escm_input_ungetc(f, c); strbuf[len - 1] = T('\0'); return tcsdup(strbuf); }
/** * @brief return a text that end with one of the `end' chars */ tchar * escm_input_gettext(escm_input *f, const tchar *end) { size_t len = 0; tint c; assert(f != NULL); assert(end != NULL); c = escm_input_getc(f); while (c != TEOF && !tcschr(end, c)) { if (c == T('\\')) { c = escm_input_getc(f); switch (c) { case T('a'): c = T('\a'); break; case T('b'): c = T('\b'); break; case T('f'): c = T('\f'); break; case T('n'): c = T('\n'); break; case T('r'): c = T('\r'); break; case T('t'): c = T('\t'); break; case T('v'): c = T('\v'); break; case T('\\'): case T('"'): break; default: strbuf[len++] = T('\\'); break; /* keep the new character */ } strbuf[len++] = c; } else strbuf[len++] = c; c = escm_input_getc(f); } if (!f->end) escm_input_ungetc(f, c); strbuf[len] = T('\0'); return tcsdup(strbuf); }
static void AddHistory(openfile* p,const tchar_t* s) { int i; for (i=0;i<p->HistoryCount;++i) if (p->History[i] && tcsicmp(p->History[i],s)==0) { for (;i>0;--i) SwapPChar(&p->History[i],&p->History[i-1]); break; } if (i==p->HistoryCount) { if (i<MAXHISTORY) p->HistoryCount++; else free(p->History[--i]); for (;i>0;--i) p->History[i] = p->History[i-1]; p->History[0] = tcsdup(s); } if (!p->Win.Smartphone) { int i; SendMessage(p->WndURL,CB_RESETCONTENT,0,0); for (i=0;i<p->HistoryCount;++i) if (p->History[i]) SendMessage(p->WndURL,CB_ADDSTRING,0,(LPARAM)p->History[i]); } SetURLText(p,s); }