Beispiel #1
0
/****** write_xml ************************************************************
PROTO	int	write_xml(char *filename)
PURPOSE	Save meta-data to an XML file/stream.
INPUT	XML file name.
OUTPUT	RETURN_OK if everything went fine, RETURN_ERROR otherwise.
NOTES	-.
AUTHOR	E. Bertin (IAP)
VERSION	14/07/2006
 ***/
int	write_xml(char *filename)
  {
   FILE		*file;

  if (!(file = fopen(prefs.xml_name, "w")))
    return RETURN_ERROR;

  write_xml_header(file);
  write_vo_fields(file);

  fprintf(file, "   <DATA>\n");
  if (prefs.cat_type == FITS_LDAC || prefs.cat_type == FITS_TPX
	|| prefs.cat_type == FITS_10)
    fprintf(file,
	"   <FITS extnum=\"%d\"><STREAM href=\"%s%s\" /> </FITS>",
	prefs.cat_type == FITS_10? 1:2,
	prefs.cat_name[0] == '/'? "file://" : "file:",
	prefs.cat_name);
  fprintf(file, "   </DATA>\n");
  fprintf(file, "  </TABLE>\n");

  write_xml_meta(file, (char *)NULL);

  fprintf(file, "</RESOURCE>\n");
  fprintf(file, "</VOTABLE>\n");

  fclose(file);

  return RETURN_OK;
  }
Beispiel #2
0
/****** write_xmlerror ******************************************************
PROTO	int	write_xmlerror(char *error)
PURPOSE	Save meta-data to a simplified XML file in case of a catched error
INPUT	a character string.
OUTPUT	RETURN_OK if everything went fine, RETURN_ERROR otherwise.
NOTES	-.
AUTHOR	E. Bertin (IAP)
VERSION	14/07/2006
 ***/
void	write_xmlerror(char *filename, char *error)
  {
   FILE			*file;

  if (!(file = fopen(filename, "w")))
    return;

  write_xml_header(file);

  fprintf(file, " </TABLE>\n");

  write_xml_meta(file, error);

  fprintf(file, "</RESOURCE>\n");
  fprintf(file, "</VOTABLE>\n");

  fclose(file);

  return;
  }
// TimeSlice Interface
void
dmz::ArchivePluginAutoSave::update_time_slice (const Float64 TimeDelta) {

   if (_appStateDirty && _archiveMod && _archiveHandle && _saveFile) {

      _appStateDirty = False;

      FILE *file = open_file (_saveFile, "wb");

      if (file) {

         StreamFile out (file);

         Config config = _archiveMod->create_archive (_archiveHandle);

         write_xml_header (out);
         format_config_to_xml (config, out);

         close_file (file);
      }
   }
}
Beispiel #4
0
/*!

\brief Save session data.
\details Session data is saved to the session file.
\return Returns dmz::True if the session data is successfully saved.
\sa dmz::Application::load_session()

*/
dmz::Boolean
dmz::Application::save_session () {

   Boolean result (False);

   Config session;

   _state.rt.get_session_config (session);

   Config prevDirConfig;

   const String DefaultDir (_state.appState.get_default_directory ());

   if (DefaultDir) {

      if (session.lookup_config (ApplicationName, prevDirConfig)) {

         prevDirConfig.store_attribute (DirName, DefaultDir);
      }
      else if (DefaultDir != get_home_directory ()) {

         Config dirConfig (ApplicationName);
         dirConfig.store_attribute (DirName, DefaultDir);
         session.add_config (dirConfig);
      }
   }

   if (!session.is_empty () && _state.sessionDir && _state.sessionPath) {

      if (create_directory (_state.sessionDir)) {

         FILE *file = open_file (_state.sessionPath, "wb");

         if (file) {

            StreamFile fs (file);

            write_xml_header (fs);

            format_config_to_xml (session, fs);

            close_file (file); file = 0;

            result = True;

            if (!_state.quiet) {

               _state.log.info << "Saved session to file: " << _state.sessionPath << endl;
            }
         }
         else {

            _state.log.error << "Unable to create session file: "
               << _state.sessionPath << endl;
         }
      }
      else {

         _state.log.error << "Unable to create session directory: " << _state.sessionDir
            << endl;
      }
   }
   else if (session.is_empty ()) {

      if (!_state.quiet) { _state.log.info << "No session data to save." << endl; }
   }
   else if (!_state.sessionDir) {

      _state.log.error << "Session directory not found." << endl;
   }
   else if (!_state.sessionPath) {

      _state.log.error << "Session file not found." << endl;
   }

   return result;
}