Changeset 22400

Show
Ignore:
Timestamp:
14.07.2010 14:00:28 (9 years ago)
Author:
kjdon
Message:

some code formatting changes, major change is the call to MARCtidy instead of usMARC, allowing for different output formats, including the new uniMARC

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/z3950/z3950server.cpp

    r19591 r22400  
    734734    r->errcode = 13; 
    735735    return 0; 
    736       } else { 
    737     list<metatag*>::iterator METATAG_here = Metatag_list.begin(); 
    738     list<metatag*>::iterator METATAG_end = Metatag_list.end(); 
    739     while (METATAG_here != METATAG_end) { 
    740       usMARC(*METATAG_here, mrec); 
    741       METATAG_here++; 
    742     } 
    743  
    744     // set the date in the marc record to the current date 
    745     char today[32]; 
    746     time_t d; 
    747     struct tm *time_struct; 
    748     //putenv("TZ=NFT-1DFT"); 
    749     d = time(NULL); 
    750     time_struct = localtime(&d); 
    751     strftime(today, 16, "%y%m%d", time_struct); 
    752     put008(mrec->s008, today, F008_DATE_ENTERED); 
    753     put008(mrec->s008, "s", F008_TYPE_OF_DATE); 
    754  
    755     // to do: make this safer + more efficient 
    756     cp = new char[1000000]; 
    757     char *cp2 = new char[1000000]; 
     736      } 
     737 
     738      // work out the d2m format number 
     739      int record_format; 
     740      switch(r->request_format) { 
     741      case VAL_DANMARC:  
     742    record_format = DANMARC; 
     743    break; 
     744      case VAL_FINMARC: 
     745    record_format = FINMARC; 
     746    break; 
     747      case VAL_NORMARC: 
     748    record_format = NORMARC; 
     749    break; 
     750      case VAL_SWEMARC: 
     751    record_format = SWEMARC; 
     752    break; 
     753      case VAL_UNIMARC: 
     754    record_format = UNIMARC; 
     755    break; 
     756      default: 
     757    // we don;t know any other format, so assume usMARC 
     758    record_format = USMARC; 
     759    // set above to be request_format, but this may change it 
     760    r->output_format = VAL_USMARC; 
     761      } 
     762       
     763       
     764 
     765      list<metatag*>::iterator METATAG_here = Metatag_list.begin(); 
     766      list<metatag*>::iterator METATAG_end = Metatag_list.end(); 
     767      while (METATAG_here != METATAG_end) { 
     768    //usMARC(*METATAG_here, mrec); 
     769    MARCmake(*METATAG_here, mrec, record_format); 
     770    METATAG_here++; 
     771      } 
     772 
     773      // set the date in the marc record to the current date 
     774      char today[32]; 
     775      time_t d; 
     776      struct tm *time_struct; 
     777      //putenv("TZ=NFT-1DFT"); 
     778      d = time(NULL); 
     779      time_struct = localtime(&d); 
     780      strftime(today, 16, "%y%m%d", time_struct); 
     781      put008(mrec->s008, today, F008_DATE_ENTERED); 
     782      put008(mrec->s008, "s", F008_TYPE_OF_DATE); 
     783 
     784      // to do: make this safer + more efficient 
     785      cp = new char[1000000]; 
     786      char *cp2 = new char[1000000]; 
    758787     
    759     switch(r->request_format) { 
    760     case VAL_DANMARC: { 
    761       MARCtidy(mrec, cp, DANMARC); 
    762       r->output_format = VAL_DANMARC; 
    763       break; } 
    764     case VAL_FINMARC: { 
    765       MARCtidy(mrec, cp, FINMARC); 
    766       r->output_format = VAL_FINMARC; 
    767       break; } 
    768     // YAZ doesn't know about ISMARC 
    769     /* 
    770     case VAL_ISMARC: { 
    771       put008(mrec->s008, "k", F008_FORM_OF_PUBLICATION); 
    772       MARCtidy(mrec, cp, ISMARC); 
    773       r->output_format = VAL_ISMARC; 
    774       break; } 
    775     */ 
    776     case VAL_NORMARC: { 
    777       MARCtidy(mrec, cp, NORMARC); 
    778       r->output_format = VAL_NORMARC; 
    779       break; } 
    780     case VAL_SWEMARC: { 
    781       MARCtidy(mrec, cp, SWEMARC); 
    782       r->output_format = VAL_SWEMARC; 
    783       break; } 
    784     default: { 
    785       MARCtidy(mrec, cp, USMARC); 
    786       r->output_format = VAL_USMARC; 
    787       break; } 
    788     } 
     788      MARCtidy(mrec, cp, record_format); 
    789789     
    790     sprintf(cp2, "%s", (char*) MARC2709(cp, 0, 6, 'n', 'm', ' ')); 
    791     r->len = strlen(cp2); 
    792     r->record = (char*) odr_malloc(r->stream, r->len+1); 
    793     strcpy(r->record, cp2);      
    794     r->basename = (char*) odr_malloc(r->stream, CollectionName.size()+1); 
    795     char *tmptxt; 
    796     tmptxt = CollectionName.getcstr(); 
    797     strcpy(r->basename, tmptxt); 
    798     delete tmptxt; 
    799     delete cp2;       
    800     cerr << "dumping record:`" << cp << "'" << endl; 
    801     delete cp; 
    802       } 
     790      sprintf(cp2, "%s", (char*) MARC2709(cp, 0, 6, 'n', 'm', ' ')); 
     791      r->len = strlen(cp2); 
     792      r->record = (char*) odr_malloc(r->stream, r->len+1); 
     793      strcpy(r->record, cp2);      
     794      r->basename = (char*) odr_malloc(r->stream, CollectionName.size()+1); 
     795      char *tmptxt; 
     796      tmptxt = CollectionName.getcstr(); 
     797      strcpy(r->basename, tmptxt); 
     798      delete tmptxt; 
     799      delete cp2;       
     800      cerr << "dumping record:`" << cp << "'" << endl; 
     801      delete cp; 
     802       
    803803    } 
    804804