Develop and Download Open Source Software

Browse CVS Repository

Diff of /xoonips/AL/commonal.cc

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

revision 1.113 by orrisroot, Tue Oct 11 16:20:22 2005 UTC revision 1.113.2.2 by aga4096, Fri Oct 28 07:02:52 2005 UTC
# Line 22  Line 22 
22   *   *
23   * $Revision$   * $Revision$
24   * $Log$   * $Log$
25     * Revision 1.113.2.2  2005/10/28 07:02:52  aga4096
26     * ・サブインデックスを含むインデックスの削除時にエラーが出ることがあるのを修正.
27     *
28     * Revision 1.113.2.1  2005/10/18 09:19:53  aga4096
29     * ・PubMed補完が正しくないことがあるのを修正.
30     *
31   * Revision 1.113  2005/10/11 16:20:22  orrisroot   * Revision 1.113  2005/10/11 16:20:22  orrisroot
32   * SQLRowCount の戻り値チェックを元にもどした.   * SQLRowCount の戻り値チェックを元にもどした.
33   *   *
# Line 497  static SQLHANDLE henv = NULL; Line 503  static SQLHANDLE henv = NULL;
503  static SQLHANDLE hdbc = NULL;  static SQLHANDLE hdbc = NULL;
504    
505    
506  static bool processEsummary(xmlTextReaderPtr reader, pubmed_t* p);  static void processEsummary(xmlTextReaderPtr reader, string &title, string &title_abbr);
507  static bool processEsearch(xmlTextReaderPtr reader, pubmed_t* p, int* DocID );  static bool processEsearch(xmlTextReaderPtr reader, pubmed_t* p, int* DocID );
508  static void processEfetch(xmlTextReaderPtr reader, pubmed_t* p);  static void processEfetch(xmlTextReaderPtr reader, pubmed_t* p);
509  static int streamPubmedFile(const char *filename, pubmed_t* p);  static int streamPubmedFile(const char *filename, pubmed_t* p);
# Line 546  static string getCsvStr( const itemid_t Line 552  static string getCsvStr( const itemid_t
552      return iids_str;      return iids_str;
553  }  }
554    
555    string urlencode( string str ){
556        int len = str.length();
557        char *buf = new char[len*3+1];
558        char *p = buf;
559        for ( int i = 0; i < len; i++ ){
560            char c = str[i];
561            if ( isalnum(c) || c =='$' || c == '*' || c == '_' || c =='.' )
562                *p++ = c;
563            else {
564                sprintf( p, "%%%02X", c & 0x00ff );
565                p += 3;
566            }
567        }
568        *p = '\0';
569        string encoded(buf);
570        delete[] buf;
571        return encoded;
572    }
573    
574  /**  /**
575   *   *
576   * public_item_target_userの設定値が'all'ならtrueをかえす   * public_item_target_userの設定値が'all'ならtrueをかえす
# Line 6435  result_t deleteIndexInternal( sessionid_ Line 6460  result_t deleteIndexInternal( sessionid_
6460                      result = querySimple( functionName, sql );                      result = querySimple( functionName, sql );
6461                  }                  }
6462              }              }
6463                
6464                // SQLFreeStmtについては  http://as400bks.rochester.ibm.com/pubs/html/as400/v4r5/ic2962/info/db2/rzadpmst62.htm#HDRFNFSTMT
6465                SQLFreeStmt( hstmt, SQL_CLOSE );
6466                SQLFreeStmt( hstmt, SQL_UNBIND );
6467          }          }
6468                    
6469          // 影響を受けたはずのアイテムを insertMetadataEventAutoする          // 影響を受けたはずのアイテムを insertMetadataEventAutoする
# Line 6944  static int streamPubmedFile(const char * Line 6973  static int streamPubmedFile(const char *
6973          return ret;          return ret;
6974      }      }
6975            
6976        // processEfetchで得たjournalは省略形なので、それを非省略形に変換する
6977      string url = PUBMED_ESEARCH_URL_BASE;      string url = PUBMED_ESEARCH_URL_BASE;
6978      const char* ptr = p -> getJournal( );      string journal( p -> getJournal() );
6979      while( *ptr != '\0' ){      url += urlencode("\""+journal+"\"[TA]"); // [TA] = [Title Abbreviation]
6980          char buf[ 4 ];      url = urlencode(url);  // libxmlのバグ(?)のため、2回urlencodeする
         sprintf( buf, "%%%02X", ( unsigned char )*( ptr++ ) );  
         url +=  buf;  
     }  
       
6981      reader = xmlNewTextReaderFilename(url.c_str());      reader = xmlNewTextReaderFilename(url.c_str());
6982      if( reader != NULL ){      if( reader != NULL ){
6983          ret = xmlTextReaderRead(reader);          ret = xmlTextReaderRead(reader);
6984          while( ret == 1 ){          while( ret == 1 ){
6985              if( processEsearch(reader, p, &DocID ) ) break;              if( processEsearch(reader, p, &DocID ) ) {
6986                    
6987                    string title, title_abbr;
6988                    url = PUBMED_ESUMMARY_URL_BASE;
6989                    url += intToString( DocID );
6990                    xmlTextReaderPtr reader2 = xmlNewTextReaderFilename(url.c_str());
6991                    if( reader2 != NULL ){
6992                        ret = xmlTextReaderRead(reader2);
6993                        while( ret == 1 ){
6994                            processEsummary( reader2, title, title_abbr );
6995                            ret = xmlTextReaderRead( reader2 );
6996                        }
6997                        xmlFreeTextReader(reader2);
6998                    }
6999                    err = xmlGetLastError();
7000                    if( err != NULL ){
7001                        setLastErrorString( err -> message );
7002                        //return ret;
7003                    }
7004                    if ( title_abbr == journal )
7005                        p -> setJournal( title.c_str() );
7006                    
7007                }
7008              ret = xmlTextReaderRead(reader);              ret = xmlTextReaderRead(reader);
7009          }          }
7010          while( ret == 1 ){          while( ret == 1 ){
# Line 6970  static int streamPubmedFile(const char * Line 7018  static int streamPubmedFile(const char *
7018          return ret;          return ret;
7019      }      }
7020            
     url = PUBMED_ESUMMARY_URL_BASE;  
     url += intToString( DocID );  
     reader = xmlNewTextReaderFilename(url.c_str());  
     if( reader != NULL ){  
         ret = xmlTextReaderRead(reader);  
         while( ret == 1 ){  
             if( processEsummary( reader, p ) ) break;  
             ret = xmlTextReaderRead( reader );  
         }  
         while( ret == 1 ){  
             ret = xmlTextReaderRead(reader);  
         }  
         xmlFreeTextReader(reader);  
     }  
     err = xmlGetLastError();  
     if( err != NULL ){  
         setLastErrorString( err -> message );  
         return ret;  
     }  
       
7021      return ret;      return ret;
7022  }  }
7023    
# Line 7093  static bool processEsearch(xmlTextReader Line 7121  static bool processEsearch(xmlTextReader
7121                      xmlChar* value = xmlTextReaderValue( reader );                      xmlChar* value = xmlTextReaderValue( reader );
7122                      *DocID = atoi( ( char* )value );                      *DocID = atoi( ( char* )value );
7123                      xmlFree( value );                      xmlFree( value );
7124                                          value = NULL;                      value = NULL;
7125                      return true;                      return true;
7126                  }                  }
7127              }              }
# Line 7107  static bool processEsearch(xmlTextReader Line 7135  static bool processEsearch(xmlTextReader
7135    
7136  /**  /**
7137   *   *
7138   * @return true Journal Titleを取得した.   * Journal Title, Journal Title Abbreviation を取得する.
  * @return false Journal Titleを取得出来なかった.パースの継続を請う.  
7139   */   */
7140  static bool processEsummary(xmlTextReaderPtr reader, pubmed_t* p)  static void processEsummary(xmlTextReaderPtr reader, string &title, string &title_abbr )
7141  {  {
7142      xmlChar* name = NULL;      xmlChar* name = NULL;
7143      xmlChar* value = NULL;      xmlChar* value = NULL;
     bool ret = false;  
7144            
7145      name = xmlTextReaderName(reader);      name = xmlTextReaderName(reader);
7146      if( name == NULL)      if( name == NULL)
# Line 7129  static bool processEsummary(xmlTextReade Line 7155  static bool processEsummary(xmlTextReade
7155                      if( xmlTextReaderRead(reader) == 1 ){                      if( xmlTextReaderRead(reader) == 1 ){
7156                          if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){                          if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){
7157                              xmlChar* value = xmlTextReaderValue( reader );                              xmlChar* value = xmlTextReaderValue( reader );
7158                              p -> setJournal( ( char* )value );                              title = ( char* )value;
7159                                xmlFree( value );
7160                                value = NULL;
7161                            }
7162                        }
7163                    }
7164                    else if( strcmp( "MedAbbr", ( char* )attr_val ) == 0 ){
7165                        if( xmlTextReaderRead(reader) == 1 ){
7166                            if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){
7167                                xmlChar* value = xmlTextReaderValue( reader );
7168                                title_abbr = ( char* )value;
7169                              xmlFree( value );                              xmlFree( value );
7170                              value = NULL;                              value = NULL;
                             ret = true;  
7171                          }                          }
7172                      }                      }
7173                  }                  }
# Line 7143  static bool processEsummary(xmlTextReade Line 7178  static bool processEsummary(xmlTextReade
7178      xmlFree(name);      xmlFree(name);
7179            
7180      if( value != NULL) xmlFree(value);      if( value != NULL) xmlFree(value);
     return ret;  
7181  }  }
7182    
7183  static void processAsinSearch(xmlTextReaderPtr reader, amazonbook_t* p )  static void processAsinSearch(xmlTextReaderPtr reader, amazonbook_t* p )

Legend:
Removed from v.1.113  
changed lines
  Added in v.1.113.2.2

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