Index: main/trunk/greenstone2/runtime-src/src/z3950/z3950server.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/z3950/z3950server.cpp	(revision 20999)
+++ main/trunk/greenstone2/runtime-src/src/z3950/z3950server.cpp	(revision 22400)
@@ -734,71 +734,71 @@
 	r->errcode = 13;
 	return 0;
-      } else {
-	list<metatag*>::iterator METATAG_here = Metatag_list.begin();
-	list<metatag*>::iterator METATAG_end = Metatag_list.end();
-	while (METATAG_here != METATAG_end) {
-	  usMARC(*METATAG_here, mrec);
-	  METATAG_here++;
-	}
-
-	// set the date in the marc record to the current date
-	char today[32];
-	time_t d;
-	struct tm *time_struct;
-	//putenv("TZ=NFT-1DFT");
-	d = time(NULL);
-	time_struct = localtime(&d);
-	strftime(today, 16, "%y%m%d", time_struct);
-	put008(mrec->s008, today, F008_DATE_ENTERED);
-	put008(mrec->s008, "s", F008_TYPE_OF_DATE);
-
-	// to do: make this safer + more efficient
-	cp = new char[1000000];
-	char *cp2 = new char[1000000];
+      }
+
+      // work out the d2m format number
+      int record_format;
+      switch(r->request_format) {
+      case VAL_DANMARC: 
+	record_format = DANMARC;
+	break;
+      case VAL_FINMARC:
+	record_format = FINMARC;
+	break;
+      case VAL_NORMARC:
+	record_format = NORMARC;
+	break;
+      case VAL_SWEMARC:
+	record_format = SWEMARC;
+	break;
+      case VAL_UNIMARC:
+	record_format = UNIMARC;
+	break;
+      default:
+	// we don;t know any other format, so assume usMARC
+	record_format = USMARC;
+	// set above to be request_format, but this may change it
+	r->output_format = VAL_USMARC;
+      }
+      
+      
+
+      list<metatag*>::iterator METATAG_here = Metatag_list.begin();
+      list<metatag*>::iterator METATAG_end = Metatag_list.end();
+      while (METATAG_here != METATAG_end) {
+	//usMARC(*METATAG_here, mrec);
+	MARCmake(*METATAG_here, mrec, record_format);
+	METATAG_here++;
+      }
+
+      // set the date in the marc record to the current date
+      char today[32];
+      time_t d;
+      struct tm *time_struct;
+      //putenv("TZ=NFT-1DFT");
+      d = time(NULL);
+      time_struct = localtime(&d);
+      strftime(today, 16, "%y%m%d", time_struct);
+      put008(mrec->s008, today, F008_DATE_ENTERED);
+      put008(mrec->s008, "s", F008_TYPE_OF_DATE);
+
+      // to do: make this safer + more efficient
+      cp = new char[1000000];
+      char *cp2 = new char[1000000];
 	
-	switch(r->request_format) {
-	case VAL_DANMARC: {
-	  MARCtidy(mrec, cp, DANMARC);
-	  r->output_format = VAL_DANMARC;
-	  break; }
-	case VAL_FINMARC: {
-	  MARCtidy(mrec, cp, FINMARC);
-	  r->output_format = VAL_FINMARC;
-	  break; }
-	// YAZ doesn't know about ISMARC
-	/*
-	case VAL_ISMARC: {
-	  put008(mrec->s008, "k", F008_FORM_OF_PUBLICATION);
-	  MARCtidy(mrec, cp, ISMARC);
-	  r->output_format = VAL_ISMARC;
-	  break; }
-	*/
-	case VAL_NORMARC: {
-	  MARCtidy(mrec, cp, NORMARC);
-	  r->output_format = VAL_NORMARC;
-	  break; }
-	case VAL_SWEMARC: {
-	  MARCtidy(mrec, cp, SWEMARC);
-	  r->output_format = VAL_SWEMARC;
-	  break; }
-	default: {
-	  MARCtidy(mrec, cp, USMARC);
-	  r->output_format = VAL_USMARC;
-	  break; }
-	}
+      MARCtidy(mrec, cp, record_format);
 	
-	sprintf(cp2, "%s", (char*) MARC2709(cp, 0, 6, 'n', 'm', ' '));
-	r->len = strlen(cp2);
-	r->record = (char*) odr_malloc(r->stream, r->len+1);
-	strcpy(r->record, cp2);     
-	r->basename = (char*) odr_malloc(r->stream, CollectionName.size()+1);
-	char *tmptxt;
-	tmptxt = CollectionName.getcstr();
-	strcpy(r->basename, tmptxt);
-	delete tmptxt;
-	delete cp2;      
-	cerr << "dumping record:`" << cp << "'" << endl;
-	delete cp;
-      }
+      sprintf(cp2, "%s", (char*) MARC2709(cp, 0, 6, 'n', 'm', ' '));
+      r->len = strlen(cp2);
+      r->record = (char*) odr_malloc(r->stream, r->len+1);
+      strcpy(r->record, cp2);     
+      r->basename = (char*) odr_malloc(r->stream, CollectionName.size()+1);
+      char *tmptxt;
+      tmptxt = CollectionName.getcstr();
+      strcpy(r->basename, tmptxt);
+      delete tmptxt;
+      delete cp2;      
+      cerr << "dumping record:`" << cp << "'" << endl;
+      delete cp;
+      
     }
 
