Develop and Download Open Source Software

Browse CVS Repository

Diff of /malonnote/mnModel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.19 by maloninc, Tue Sep 13 09:11:37 2005 UTC revision 1.22 by maloninc, Thu Sep 15 03:02:37 2005 UTC
# Line 118  WikiList* mnModel::search(const char* se Line 118  WikiList* mnModel::search(const char* se
118          return list;          return list;
119  }  }
120    
121    void mnModel::group()
122    {
123            wxCSConv    conv(wxT(CODE_SET_SYSTEM));
124        char        buf[MAX_BUF_SIZE];
125            wxDir*      dir;
126            FILE*       fp;
127        wxString*   fileName = new wxString();
128        wxString    fullPathName;
129            int         typeTagLen = strlen(TYPE_TAG);
130            char*       token;
131            char*           inbufPtr;
132            int         inbufSize;
133            char        outbuf[MAX_BUF_SIZE];
134            char*       outbufPtr = outbuf;
135            int         outbufSize;
136            wxString*   typeToken;
137            char*       ptr;
138            int         i;
139    
140            iconv_t codeSet = iconv_open(CODE_SET_SYSTEM, CODE_SET_EUC_JP);
141            if(codeSet == (iconv_t)-1) {
142                    MN_FATAL_ERROR(wxT("failed iconv_open"));
143            }
144    
145            dir = new wxDir(*wikiDataDir);
146        if ( !dir->IsOpened() )
147        {
148                    MN_FATAL_ERROR(wxT("wxDir has faild\n"));
149            return ;
150        }
151        bool cont = dir->GetFirst(fileName, wxT("*.txt"), wxDIR_FILES);
152            while(cont){
153            fullPathName = *wikiDataDir + wxT("/") + *fileName;
154                    fp = fopen((const char*)fullPathName.mb_str(), "r");
155                    if(fp == NULL) {
156                            MN_FATAL_ERROR(wxT("fopen faild"));
157                    }
158                    while(1) {
159                            memset(buf, 0, MAX_BUF_SIZE);
160                            fgets(buf, MAX_BUF_SIZE, fp);
161                            if(buf[0] == 0) break;
162                            if(strstr(buf, TYPE_TAG)){
163                                    ptr = &buf[typeTagLen];
164                                    while((token = strtok(ptr, " /\r\n:"))!= NULL) {
165                                            memset(outbuf, 0, MAX_BUF_SIZE);
166                                            snprintf(outbuf, MAX_BUF_SIZE, "%s", TYPESEARCH_TAG);
167                                            inbufPtr = token;
168                                            inbufSize = strlen(token);
169                                            outbufPtr = &outbuf[strlen(TYPESEARCH_TAG)];
170                                            outbufSize = sizeof(outbuf) - strlen(TYPESEARCH_TAG);
171                                            iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize);
172    
173                                            typeToken = new wxString(outbuf, conv);
174                                            addSearchStr(typeToken);
175                                            delete typeToken;
176                                            ptr = NULL;
177                                    }
178                            }
179                    }
180                    fclose(fp);
181            cont = dir->GetNext(fileName);
182            }
183            delete dir;
184            delete fileName;
185            iconv_close(codeSet);
186    }
187    
188  bool mnModel::normalSearch(char* tokenList[], FILE*fp, char* decodeFileNameBuf)  bool mnModel::normalSearch(char* tokenList[], FILE*fp, char* decodeFileNameBuf)
189  {  {
190      char        buf[MAX_BUF_SIZE];      char        buf[MAX_BUF_SIZE];
# Line 167  bool mnModel::typeSearch(char* typeStr, Line 234  bool mnModel::typeSearch(char* typeStr,
234                  if(strstr((const char*)buf, TYPE_TAG)){  /* search TYPE line */                  if(strstr((const char*)buf, TYPE_TAG)){  /* search TYPE line */
235                          typeToken = strtok(typeStrCopy, ":");                          typeToken = strtok(typeStrCopy, ":");
236                          typeToken = strtok(NULL, ":");    /* second field separated by colon(:) */                          typeToken = strtok(NULL, ":");    /* second field separated by colon(:) */
237                            if(typeToken == NULL) return false;
238                          toLower(typeToken);                          toLower(typeToken);
239                          toLower(buf);                          toLower(buf);
240                          if(strstr(buf, typeToken)) return true;                          if(strstr(buf, typeToken)) return true;
# Line 181  void mnModel::addSearchStr(wxString* sea Line 249  void mnModel::addSearchStr(wxString* sea
249    
250          if(searchStrList->Index(searchStr->c_str()) == wxNOT_FOUND){          if(searchStrList->Index(searchStr->c_str()) == wxNOT_FOUND){
251                  string = new wxString(searchStr->c_str());                  string = new wxString(searchStr->c_str());
252                  //searchStrList->Add(*string, 1);                  searchStrList->Add(*string, 1);
253                  searchStrList->Insert(*string, 0);                  //searchStrList->Insert(*string, 0);
254          }          }
255  }  }
256    

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.22

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26