예제 #1
0
파일: ini.c 프로젝트: macosunity/rengine
/*
 *	Recursively prints a tree of ini_pairs
 */
static void write_pair(ini_pair *p, FILE *f) {
	if(!p) return;
	
	string_to_file(f, p->param);
	fputs(" = ", f);	
	string_to_file(f, p->value);
	fputc('\n', f);
	
	write_pair(p->left, f);
	write_pair(p->right, f);
}
예제 #2
0
파일: ini.c 프로젝트: macosunity/rengine
/*
 *	Recursively prints a tree of INI sections
 */
static void write_section(ini_section *s, FILE *f) {
	if(!s) return;
		
	fputs("\n[", f);
	string_to_file(f, s->name);
	fputs("]\n", f);
	
	write_pair(s->fields, f);
	
	/* The akward sequence is to ensure that values are not written sorted */
	
	write_section(s->left, f);
	write_section(s->right, f);
}
예제 #3
0
파일: biz.cpp 프로젝트: kesco/crowd
 void Blog::write_to(bf::path &to) {
   if (!bf::exists(to)) bf::create_directories(to);
   const string theme_style = _theme.post_template();
   for (auto &post:*_posts) {
     bf::path file_path = to;
     file_path.append(post.title() + ".html");
     mstch::map content{
         {"content", _parser->parse(post.content())}
     };
     string convert = mstch::render(theme_style, content);
     try {
       bool is_rewrite = bf::exists(file_path);
       string_to_file(file_path.string(), convert, is_rewrite);
       cout << post.title() << ":" <<
       bg::to_iso_extended_string(post.date()) << endl;
     } catch (IOException &ex) {
       cerr << ex.what() << endl;
     }
   }
 }
예제 #4
0
void CRASHREPORTER_send_message(const char *additional_information, const char **messages, int num_messages, Crash_Type crash_type){
  QString plugin_names = get_plugin_names();
  
  QString tosend = QString(additional_information) + "\n\n";

  tosend += VERSION "\n\n";

  tosend += "OpenGL vendor: " + QString((GE_vendor_string==NULL ? "(null)" : (const char*)GE_vendor_string )) + "\n";
  tosend += "OpenGL renderer: " + QString((GE_renderer_string==NULL ? "(null)" : (const char*)GE_renderer_string)) + "\n";
  tosend += "OpenGL version: " + QString((GE_version_string==NULL ? "(null)" : (const char*)GE_version_string)) + "\n";
  tosend += QString("OpenGL flags: %1").arg(GE_opengl_version_flags, 0, 16) + "\n\n";

  tosend += "Running plugins: " + plugin_names + "\n\n";

  tosend += "Running time: " + QString::number(running_time.elapsed()) + "\n\n";

  tosend += "\n\n";

    
  for(int i=0;i<num_messages;i++)
    tosend += QString::number(i) + ": "+messages[i] + "\n";

  tosend += "\n\n";

  int event_pos = g_event_pos;

  tosend += "start event_pos: " + QString::number(event_pos) + "\n";

  for(int i=event_pos-1; i>=0 ; i--)
    tosend += QString(g_event_log[i]) + "\n";

  for(int i=NUM_EVENTS-1; i>=event_pos ; i--)
    tosend += QString(g_event_log[i]) + "\n";

  tosend += "end event_pos: " + QString::number(g_event_pos) + "\n";
  
  tosend += "\n\n";

#if defined(FOR_LINUX)
  tosend += "LINUX\n\n";
  tosend += "/etc/os-release: "+file_to_string("/etc/os-release");
  tosend += "\n\n";
  tosend += "/proc/version: "+file_to_string("/proc/version");
  tosend += "\n\n";
  tosend += "/proc/cpuinfo: "+file_to_string("/proc/cpuinfo");
#endif

  // start process
  {
    QString program = QCoreApplication::applicationDirPath() + QDir::separator() + "crashreporter";
#if FOR_WINDOWS
    program += ".exe";
#endif

    QTemporaryFile *file;
    
    if (crash_type==CT_CRASH) {
      file = new QTemporaryFile;
    } else {
      if (g_crashreporter_file==NULL) {
        g_crashreporter_file = new QTemporaryFile;
        g_crashreporter_file->setAutoRemove(false); // We delete it in the sub process. This process is just going to exit as soon as possible.
      }
      file = g_crashreporter_file;
    }

    bool save_mixer_tree;
    
    if (crash_type==CT_CRASH)
      save_mixer_tree = false; // Don't want to risk crashing inside the crash handler.
    else
      save_mixer_tree = true;
    
    string_to_file(tosend, file, save_mixer_tree);

    /*
      Whether to block
      ================
                                    RELEASE      !RELEASE
                                -------------------------
      Crash in main thread      |     no [1]       yes [2]
      Crash in other thread     |     no [1]       yes [2]
      Assert in main thread     |     no [4]       yes [2]
      Assert in other thread    |     no [4]       yes [2,3]

      [1] When crashing in RELEASE mode, it doesn't matter wheter we block or not, because
          radium will exit immediately after finishing this function anyway, and it's
          probably better to do that as quickly as possible.

      [2] Ideally, this should happen though:
          1. All threads immediately freezes
          2. A dialog pops up asking whether to:
             a) Stop program (causing gdb to kick in)
             b) Ignore
             c) Run assert crashreporter

      [3] This can be annoying if the assert happens in the audio thread though.

      [4] Asserts are not really supposed to happen, but there are a lot of them, 
          and they might pop up unnecessarily (for instance a bug in the asserts themselves):
          * Blocking might cause the program to be non-functional unnecessarily.
          * Blocking could prevent the user from saving the current song,
            for instance if the assert window just pops up immediately after closing it.
     */

#ifdef RELEASE
    bool do_block = false;
#else
    bool do_block = true;
#endif

    QTemporaryFile emergency_save_file("radium_crash_save");

#if 0
    bool dosave = is_crash && Undo_num_undos_since_last_save()>0;
#else
    bool dosave = false; // saving inside a forked version of the program didn't really work that well. Maybe it works better in windows.
#endif
    
    if (dosave)
      emergency_save_file.open();
    
    run_program(program,
                toBase64(file->fileName()),
                toBase64(plugin_names),
                toBase64(dosave ? emergency_save_file.fileName() : NOEMERGENCYSAVE),
                crash_type==CT_CRASH ? "is_crash" : crash_type==CT_ERROR ? "is_error" : "is_warning",
                do_block
                );

    if (dosave)
      Save_Clean(STRING_create(emergency_save_file.fileName()),root,false);
  }
  
}