int ft_while(t_data *d, struct termios *term, t_list *list) { while (42) { ft_bzero(d->read_char, 3); read(0, d->read_char, 3); if (is_rtn(d->read_char)) { ft_quit(term); final_print(list); return (1); } if (ft_while_help(d, term, list, d->read_char)) ; else if (is_arrow(d->read_char, d, list) == 0) ; else if (is_spc(d->read_char, list, d) == 0) ; else if (is_del(d->read_char)) list = ft_del_elem(list, d, term); if (list == NULL) return (0); } return (0); }
int read_user(t_list *head) { char read_char[4] = {0}; while (42) { tputs(tgetstr("cl", NULL), 1, ft_putschar); so_printed(head); print_cursor(head); ft_strclr(read_char); read(0, read_char, 3); head = is_key(head, read_char); head = is_spc(head, read_char); if (read_char[0] == 10 && read_char[1] == 0) return (0); else if ((KEYDEL) || (KEYSUP)) { head->slc = -1; head = head->next; if (head->next == head && head->slc == -1) return (-1); } else if (read_char[0] == 27 && read_char[1] == 0) return (-1); } return (0); }
/********************************************************************** * 文字列 *p をデリミタ文字 c あるいは空白で分割し * *args[] ポインタに入れる * 分割数 n を返す. ********************************************************************** */ static int split_str(char *p,int c,char **args) { int argc=0; int qq=0; splitchr=c; while(1) { while( is_spc(*p) ) p++; if(*p==0) break; if(*p != 0x22) { args[argc++]=p; /* 項目の先頭文字 */ while( *p ) { /* 区切り文字まで読み進める */ if(is_spc(*p))break; p++; } if(is_spc(*p)) { /* 区切り文字であれば */ *p=0;p++; /* NULLで切る */ } }else{ qq=*p++; args[argc++]=p; /* 項目の先頭文字 */ while( *p ) { /* 区切り文字まで読み進める */ if(*p==qq)break; p++; } if(*p==qq) { /* 区切り文字であれば */ *p=0;p++; /* NULLで切る */ } } } return argc; }
void GUI_Prefs_Read(const char *app_name) { sPrefs.clear(); string pref_dir; if (!GUI_GetPrefsDir(pref_dir)) return; pref_dir += DIR_STR; #if LIN pref_dir += "."; pref_dir += app_name; #else pref_dir += app_name; #endif pref_dir += ".prefs"; MFMemFile* f = MemFile_Open(pref_dir.c_str()); GUI_PrefSection_t * cur=NULL; if(f) { const char * p = MemFile_GetBegin(f); const char * e = MemFile_GetEnd(f); while(p<e) { skip_space(p,e); if(p<e && *p=='[') { ++p; const char * cs = p; while(p<e && !is_eol(*p) && *p != ']') ++p; string cur_name(cs,p); cur=&sPrefs[cur_name]; } else if(p<e && *p != '\r' && *p != '\n') { const char * ks = p; while(p<e && !is_spc(*p) && !is_eol(*p) && *p != '=') { if (*p=='\\') ++p; if(p<e) ++p; } const char * ke = p; skip_space(p,e); if(p<e && *p=='=') { ++p; skip_space(p,e); if(p<e) { const char * vs = p; while(p<e && !is_spc(*p) && !is_eol(*p) && *p != '=') { if (*p=='\\') ++p; if(p<e) ++p; } const char * ve = p; if(cur) { string key(ks,ke); string val(vs,ve); dequote(key); dequote(val); (*cur)[key] = val; } } } } skip_eol(p,e); } MemFile_Close(f); } #if DEBUG_PREFS for(GUI_Prefs_t::iterator s = sPrefs.begin(); s != sPrefs.end(); ++s) { printf("[%s]" CRLF, s->first.c_str()); for(GUI_PrefSection_t::iterator p = s->second.begin(); p != s->second.end(); ++p) printf("'%s'='%s'" CRLF, p->first.c_str(), p->second.c_str()); } #endif }
inline void skip_space(const char *&p, const char * e) { while(p<e && is_spc(*p)) ++p; }