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.4 by aga4096, Tue Dec 6 05:09:38 2005 UTC
# Line 22  Line 22 
22   *   *
23   * $Revision$   * $Revision$
24   * $Log$   * $Log$
25     * Revision 1.113.2.4  2005/12/06 05:09:38  aga4096
26     * ・開放忘れを修正.
27     *
28     * Revision 1.113.2.3  2005/11/01 10:36:14  tani
29     * _insertItem: dierctフラグによって書き込む日付情報の値を分岐する.
30     *
31     * Revision 1.113.2.2  2005/10/28 07:02:52  aga4096
32     * ・サブインデックスを含むインデックスの削除時にエラーが出ることがあるのを修正.
33     *
34     * Revision 1.113.2.1  2005/10/18 09:19:53  aga4096
35     * ・PubMed補完が正しくないことがあるのを修正.
36     *
37   * Revision 1.113  2005/10/11 16:20:22  orrisroot   * Revision 1.113  2005/10/11 16:20:22  orrisroot
38   * SQLRowCount の戻り値チェックを元にもどした.   * SQLRowCount の戻り値チェックを元にもどした.
39   *   *
# Line 497  static SQLHANDLE henv = NULL; Line 509  static SQLHANDLE henv = NULL;
509  static SQLHANDLE hdbc = NULL;  static SQLHANDLE hdbc = NULL;
510    
511    
512  static bool processEsummary(xmlTextReaderPtr reader, pubmed_t* p);  static void processEsummary(xmlTextReaderPtr reader, string &title, string &title_abbr);
513  static bool processEsearch(xmlTextReaderPtr reader, pubmed_t* p, int* DocID );  static bool processEsearch(xmlTextReaderPtr reader, pubmed_t* p, int* DocID );
514  static void processEfetch(xmlTextReaderPtr reader, pubmed_t* p);  static void processEfetch(xmlTextReaderPtr reader, pubmed_t* p);
515  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 558  static string getCsvStr( const itemid_t
558      return iids_str;      return iids_str;
559  }  }
560    
561    string urlencode( string str ){
562        int len = str.length();
563        char *buf = new char[len*3+1];
564        char *p = buf;
565        for ( int i = 0; i < len; i++ ){
566            char c = str[i];
567            if ( isalnum(c) || c =='$' || c == '*' || c == '_' || c =='.' )
568                *p++ = c;
569            else {
570                sprintf( p, "%%%02X", c & 0x00ff );
571                p += 3;
572            }
573        }
574        *p = '\0';
575        string encoded(buf);
576        delete[] buf;
577        return encoded;
578    }
579    
580  /**  /**
581   *   *
582   * public_item_target_userの設定値が'all'ならtrueをかえす   * public_item_target_userの設定値が'all'ならtrueをかえす
# Line 3755  static result_t _insertItem( sessionid_t Line 3786  static result_t _insertItem( sessionid_t
3786              strncpy2( (char*)lang, item -> getLang(), XNP_ITEM_LANG_LEN );              strncpy2( (char*)lang, item -> getLang(), XNP_ITEM_LANG_LEN );
3787              item_type_id = item -> getItemTypeID( );              item_type_id = item -> getItemTypeID( );
3788              uid = item -> getContributorUID( );              uid = item -> getContributorUID( );
3789              creation_date = time( NULL );              if( direct ){
3790              last_update_date = time( NULL );                  creation_date = item -> getCreationDate();
3791                    last_update_date = item -> getLastUpdateDate();
3792                }else{
3793                    creation_date = time( NULL );
3794                    last_update_date = time( NULL );
3795                }
3796              publication_year = item -> getPublicationYear();              publication_year = item -> getPublicationYear();
3797              publication_month = item -> getPublicationMonth();              publication_month = item -> getPublicationMonth();
3798              publication_mday = item -> getPublicationMday();              publication_mday = item -> getPublicationMday();
# Line 6435  result_t deleteIndexInternal( sessionid_ Line 6471  result_t deleteIndexInternal( sessionid_
6471                      result = querySimple( functionName, sql );                      result = querySimple( functionName, sql );
6472                  }                  }
6473              }              }
6474                
6475                // SQLFreeStmtについては  http://as400bks.rochester.ibm.com/pubs/html/as400/v4r5/ic2962/info/db2/rzadpmst62.htm#HDRFNFSTMT
6476                SQLFreeStmt( hstmt, SQL_CLOSE );
6477                SQLFreeStmt( hstmt, SQL_UNBIND );
6478          }          }
6479                    
6480          // 影響を受けたはずのアイテムを insertMetadataEventAutoする          // 影響を受けたはずのアイテムを insertMetadataEventAutoする
# Line 6895  void freeStringArray( char** strs, int l Line 6935  void freeStringArray( char** strs, int l
6935  void freeChangeLog( const changelog_t* ptr ){ delete[] ( changelog_t* )ptr; }  void freeChangeLog( const changelog_t* ptr ){ delete[] ( changelog_t* )ptr; }
6936  void freePubmed( const pubmed_t* ptr ){ delete[] ( pubmed_t* )ptr; }  void freePubmed( const pubmed_t* ptr ){ delete[] ( pubmed_t* )ptr; }
6937  void freeInt( const int* ptr ){ delete[] ( int* )ptr; }  void freeInt( const int* ptr ){ delete[] ( int* )ptr; }
6938    void freeAmazonbook( const amazonbook_t* ptr ){ delete[] ( amazonbook_t* )ptr; }
6939    
6940  static string errstr;  static string errstr;
6941  const char* getLastErrorString()  const char* getLastErrorString()
# Line 6944  static int streamPubmedFile(const char * Line 6985  static int streamPubmedFile(const char *
6985          return ret;          return ret;
6986      }      }
6987            
6988        // processEfetchで得たjournalは省略形なので、それを非省略形に変換する
6989      string url = PUBMED_ESEARCH_URL_BASE;      string url = PUBMED_ESEARCH_URL_BASE;
6990      const char* ptr = p -> getJournal( );      string journal( p -> getJournal() );
6991      while( *ptr != '\0' ){      url += urlencode("\""+journal+"\"[TA]"); // [TA] = [Title Abbreviation]
6992          char buf[ 4 ];      url = urlencode(url);  // libxmlのバグ(?)のため、2回urlencodeする
         sprintf( buf, "%%%02X", ( unsigned char )*( ptr++ ) );  
         url +=  buf;  
     }  
       
6993      reader = xmlNewTextReaderFilename(url.c_str());      reader = xmlNewTextReaderFilename(url.c_str());
6994      if( reader != NULL ){      if( reader != NULL ){
6995          ret = xmlTextReaderRead(reader);          ret = xmlTextReaderRead(reader);
6996          while( ret == 1 ){          while( ret == 1 ){
6997              if( processEsearch(reader, p, &DocID ) ) break;              if( processEsearch(reader, p, &DocID ) ) {
6998              ret = xmlTextReaderRead(reader);                  
6999          }                  string title, title_abbr;
7000          while( ret == 1 ){                  url = PUBMED_ESUMMARY_URL_BASE;
7001                    url += intToString( DocID );
7002                    xmlTextReaderPtr reader2 = xmlNewTextReaderFilename(url.c_str());
7003                    if( reader2 != NULL ){
7004                        ret = xmlTextReaderRead(reader2);
7005                        while( ret == 1 ){
7006                            processEsummary( reader2, title, title_abbr );
7007                            ret = xmlTextReaderRead( reader2 );
7008                        }
7009                        xmlFreeTextReader(reader2);
7010                    }
7011                    err = xmlGetLastError();
7012                    if( err != NULL ){
7013                        setLastErrorString( err -> message );
7014                        //return ret;
7015                    }
7016                    if ( title_abbr == journal )
7017                        p -> setJournal( title.c_str() );
7018                    
7019                }
7020              ret = xmlTextReaderRead(reader);              ret = xmlTextReaderRead(reader);
7021          }          }
         xmlFreeTextReader(reader);  
     }  
     err = xmlGetLastError();  
     if( err != NULL ){  
         setLastErrorString( err -> message );  
         return ret;  
     }  
       
     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 );  
         }  
7022          while( ret == 1 ){          while( ret == 1 ){
7023              ret = xmlTextReaderRead(reader);              ret = xmlTextReaderRead(reader);
7024          }          }
# Line 7093  static bool processEsearch(xmlTextReader Line 7133  static bool processEsearch(xmlTextReader
7133                      xmlChar* value = xmlTextReaderValue( reader );                      xmlChar* value = xmlTextReaderValue( reader );
7134                      *DocID = atoi( ( char* )value );                      *DocID = atoi( ( char* )value );
7135                      xmlFree( value );                      xmlFree( value );
7136                                          value = NULL;                      value = NULL;
7137                        xmlFree(name);
7138                      return true;                      return true;
7139                  }                  }
7140              }              }
# Line 7107  static bool processEsearch(xmlTextReader Line 7148  static bool processEsearch(xmlTextReader
7148    
7149  /**  /**
7150   *   *
7151   * @return true Journal Titleを取得した.   * Journal Title, Journal Title Abbreviation を取得する.
  * @return false Journal Titleを取得出来なかった.パースの継続を請う.  
7152   */   */
7153  static bool processEsummary(xmlTextReaderPtr reader, pubmed_t* p)  static void processEsummary(xmlTextReaderPtr reader, string &title, string &title_abbr )
7154  {  {
7155      xmlChar* name = NULL;      xmlChar* name = NULL;
7156      xmlChar* value = NULL;      xmlChar* value = NULL;
     bool ret = false;  
7157            
7158      name = xmlTextReaderName(reader);      name = xmlTextReaderName(reader);
7159      if( name == NULL)      if( name == NULL)
# Line 7129  static bool processEsummary(xmlTextReade Line 7168  static bool processEsummary(xmlTextReade
7168                      if( xmlTextReaderRead(reader) == 1 ){                      if( xmlTextReaderRead(reader) == 1 ){
7169                          if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){                          if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){
7170                              xmlChar* value = xmlTextReaderValue( reader );                              xmlChar* value = xmlTextReaderValue( reader );
7171                              p -> setJournal( ( char* )value );                              title = ( char* )value;
7172                                xmlFree( value );
7173                                value = NULL;
7174                            }
7175                        }
7176                    }
7177                    else if( strcmp( "MedAbbr", ( char* )attr_val ) == 0 ){
7178                        if( xmlTextReaderRead(reader) == 1 ){
7179                            if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){
7180                                xmlChar* value = xmlTextReaderValue( reader );
7181                                title_abbr = ( char* )value;
7182                              xmlFree( value );                              xmlFree( value );
7183                              value = NULL;                              value = NULL;
                             ret = true;  
7184                          }                          }
7185                      }                      }
7186                  }                  }
# Line 7143  static bool processEsummary(xmlTextReade Line 7191  static bool processEsummary(xmlTextReade
7191      xmlFree(name);      xmlFree(name);
7192            
7193      if( value != NULL) xmlFree(value);      if( value != NULL) xmlFree(value);
     return ret;  
7194  }  }
7195    
7196  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.4

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