| |
---|
| | #define textdomain(domain) |
---|
| | #define bind_textdomain_codeset(domain,codeset) |
---|
| | #endif |
---|
| | |
---|
| | #include <sys/types.h> |
---|
| | #include <sys/wait.h> |
---|
| | |
---|
| | |
---|
| | // プライグイン化のおまじないです。 |
---|
| | HonokaPluginRegister(PrimePrediction); |
---|
| | |
---|
| | |
---|
| |
---|
| | \fn PrimePrediction::getPredictionList(const WideString &str) |
---|
| | */ |
---|
| | ResultList PrimePrediction::getPredictionList(const WideString &str) |
---|
| | { |
---|
| | ResultList l; |
---|
| | if (!con) return l; |
---|
| | String s = lookup_method + "\t"; |
---|
| | String t; |
---|
| | m_iconv.convert(t,str); |
---|
| | s = s + t + String("\n"); |
---|
| |
---|
| | t = ""; |
---|
| | } else t += s[i]; |
---|
| | } |
---|
| | if (t.length()) sl.push_back(t); |
---|
| | ResultList l; |
---|
| | l.Title = utf8_mbstowcs(String(_("lookup result"))); |
---|
| | l.kType = PREDICTION; |
---|
| | for(unsigned int i = 1;i < sl.size();i ++) { |
---|
| | /*vector<String> rl; |
---|
| | String r; |
---|
| | for(unsigned int j = 0;j < sl[i].length();j ++) { |
---|
| | if ((sl[i][j] == '\t') || (sl[i][j] == ' ')) { |
---|
| | if (r.length()) { |
---|
| | rl.push_back(r); |
---|
| | r = ""; |
---|
| | } |
---|
| | } else r += sl[i][j]; |
---|
| | } |
---|
| | if (r.length()) rl.push_back(r); |
---|
| | if (rl.size() < 2) continue; |
---|
| | WideString w; |
---|
| | m_iconv.convert(w,rl[1]); |
---|
| | l.kouho.push_back(ResultEntry(w)); |
---|
| | */ |
---|
| | ResultEntry e = parser(sl[i]); |
---|
| | if (e.kanji.length()) l.kouho.push_back(e); |
---|
| | } |
---|
| | return l; |
---|
| |
---|
| | \fn PrimePrediction::disconnect() |
---|
| | */ |
---|
| | void PrimePrediction::disconnect() |
---|
| | { |
---|
| | if (!con) return; |
---|
| | String s = "close\n"; |
---|
| | write(ifd,s.c_str(),s.length()); |
---|
| | close(ifd); |
---|
| | close(ofd); |
---|
| | con = false; |
---|
| | } |
---|
| | |
---|
| | |
---|
| | /*! |
---|
| |
---|
| | int in_fd[2],out_fd[2],i; |
---|
| | if (con) return true; |
---|
| | if (pipe(in_fd) == -1) return false; |
---|
| | if (pipe(out_fd) == -1) return false; |
---|
| | con = true; |
---|
| | switch(fork()) { |
---|
| | switch(vfork()) { |
---|
| | case -1: { |
---|
| | close(in_fd[0]); |
---|
| | close(in_fd[1]); |
---|
| | close(out_fd[0]); |
---|
| |
---|
| | dup2(in_fd[0],0); |
---|
| | dup2(out_fd[1],1); |
---|
| | close(in_fd[0]); |
---|
| | close(out_fd[1]); |
---|
| | con = true; |
---|
| | execlp("prime",NULL); |
---|
| | con = false; |
---|
| | exit(1); |
---|
| | _exit(0); |
---|
| | } |
---|
| | } |
---|
| | close(in_fd[0]); |
---|
| | close(out_fd[1]); |
---|
| |
---|
| | |