Esempio n. 1
0
/* Export in the iwb format. */
void
export_iwb (gchar *iwb_location)
{
  const gchar *tmpdir = g_get_tmp_dir ();
  gchar *images = "images";
  gchar *background_image = get_background_image();
  gchar *project_name = get_project_name ();
  gchar *ardesia_tmp_dir = g_build_filename (tmpdir, PACKAGE_NAME, (gchar *) 0);
  gchar *project_tmp_dir = g_build_filename (ardesia_tmp_dir, project_name, (gchar *) 0);
  gchar *img_dir_path = g_build_filename (project_tmp_dir, images, (gchar *) 0);
  gchar *first_savepoint_file = g_strdup_printf ("%s%s%s_2_vellum.png", img_dir_path, G_DIR_SEPARATOR_S, PACKAGE_NAME);

  /* if exist the file I continue to save */
  if ((file_exists(first_savepoint_file)) || (background_image))
    {
      gchar *iwb_file = (gchar *) NULL;
      gchar *content_filename = "content.xml";
      gchar *content_filepath = g_build_filename (project_tmp_dir, content_filename, (gchar *) 0);
      
      /* If the iwb location is null means that it is a new project. */
      if (iwb_location == NULL)
        {
          /* It will be putted in the project dir. */
          gchar *extension = "iwb";
          gchar *iwb_name =  g_strdup_printf("%s.%s", get_project_name (), extension);

          /* The zip file is the iwb file located in the ardesia workspace. */
          iwb_file = g_build_filename (get_project_dir (), iwb_name, (gchar *) 0);
          g_free(iwb_name);
        }
      else
        {
          g_remove (iwb_location);
          iwb_file = g_strdup_printf ("%s", iwb_location);
        }

      g_remove (content_filepath);

      create_xml_content (content_filepath, img_dir_path, background_image);

      create_iwb (iwb_file, project_tmp_dir, "images", content_filename);

      /* Add to the list of the artefacts created in the session. */
      add_artifact (iwb_file);
      g_free (iwb_file);
      g_free (content_filepath);
    }

  g_free (first_savepoint_file);
  g_free (ardesia_tmp_dir);
  g_free (project_tmp_dir);
  g_free (img_dir_path);
}
Esempio n. 2
0
/*
 *  By clearing files, you simply just move them to another directory to avid unwanted deletes of data
 *  After clear_files have been called upon, deletion of Experiment should be done.
 *
 *  Notes:
 *  If removed files directory create succeded or it already exists,
 *  try to organise the removed files in corresponding project it
 *  was started in by creating a project folder in removed files folder
 *
 */
ProjectHandlerErrorCode Experiment::clear_files() {


  // do not attempt to clear nonexisting experiments
  if (open_mode_ == experiment_open_mode::not_initialized || open_mode_ == experiment_open_mode::deleted) {
    return ProjectHandlerErrorCode::IO_ERROR;
  }

  boost::system::error_code boost_err;
  //First try to create the default removed files path
  fs::create_directory(DEFAULT_REMOVE_PATH, boost_err);
  if (boost_err == boost::system::errc::success || boost_err == boost::system::errc::file_exists) {

    fs::create_directory(DEFAULT_REMOVE_PATH + get_project_name(), boost_err);
    std::string new_dir = DEFAULT_REMOVE_PATH + get_project_name() + name_ + "/";
    if (fs::exists(new_dir)) {
        return ProjectHandlerErrorCode::NAME_TAKEN;
    }
    fs::create_directory(new_dir, boost_err);
    if(boost_err !=  boost::system::errc::success){
      return ProjectHandlerErrorCode::IO_ERROR;
    }
    delete(data_file_input_stream_);
    delete(meta_file_input_stream_);
    std::fclose(meta_file_handler_);
    std::fclose(data_file_handler_);
    text_file_->close();
    delete(text_file_);
    open_mode_ = experiment_open_mode::deleted;

    boost::system::error_code err;
    fs::rename(experiment_dir_path_, new_dir, err);
    if (err == boost::system::errc::success) {
      return ProjectHandlerErrorCode::SUCCESS;
    }else{
      return ProjectHandlerErrorCode::IO_ERROR;
    }
  } else {
    return ProjectHandlerErrorCode::IO_ERROR;
  }
}
Esempio n. 3
0
void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) {


	const int UTF8_FLAG = 0x00000100;
	print_line("*******************GORRRGLE***********************");

	uint32_t header = decode_uint32(&p_manifest[0]);
	uint32_t filesize = decode_uint32(&p_manifest[4]);
	uint32_t string_block_len = decode_uint32(&p_manifest[16]);
	uint32_t string_count = decode_uint32(&p_manifest[20]);
	uint32_t string_flags = decode_uint32(&p_manifest[28]);
	const uint32_t string_table_begins = 40;

	Vector<String> string_table;

	printf("stirng block len: %i\n",string_block_len);
	printf("stirng count: %i\n",string_count);
	printf("flags: %x\n",string_flags);

	for(int i=0;i<string_count;i++) {

		uint32_t offset = decode_uint32(&p_manifest[string_table_begins+i*4]);
		offset+=string_table_begins+string_count*4;

		String str = _parse_string(&p_manifest[offset],string_flags&UTF8_FLAG);

		if (str.begins_with("godot-project-name")) {


			if (str=="godot-project-name") {
				//project name
				str = get_project_name();

			} else {

				String lang = str.substr(str.find_last("-")+1,str.length()).replace("-","_");
				String prop = "application/name_"+lang;
				if (Globals::get_singleton()->has(prop)) {
					str = Globals::get_singleton()->get(prop);
				} else {
					str = get_project_name();
				}
			}
		}

		string_table.push_back(str);

	}

	//write a new string table, but use 16 bits
	Vector<uint8_t> ret;
	ret.resize(string_table_begins+string_table.size()*4);

	for(int i=0;i<string_table_begins;i++) {

		ret[i]=p_manifest[i];
	}

	int ofs=0;
	for(int i=0;i<string_table.size();i++) {

		encode_uint32(ofs,&ret[string_table_begins+i*4]);
		ofs+=string_table[i].length()*2+2+2;
	}

	ret.resize(ret.size()+ofs);
	uint8_t *chars=&ret[ret.size()-ofs];
	for(int i=0;i<string_table.size();i++) {

		String s = string_table[i];
		encode_uint16(s.length(),chars);
		chars+=2;
		for(int j=0;j<s.length();j++) {
			encode_uint16(s[j],chars);
			chars+=2;
		}
		encode_uint16(0,chars);
		chars+=2;
	}

	//pad
	while(ret.size()%4)
		ret.push_back(0);

	//change flags to not use utf8
	encode_uint32(string_flags&~0x100,&ret[28]);
	//change length
	encode_uint32(ret.size()-12,&ret[16]);
	//append the rest...
	int rest_from = 12+string_block_len;
	int rest_to = ret.size();
	int rest_len = (p_manifest.size() - rest_from);
	ret.resize(ret.size() + (p_manifest.size() - rest_from) );
	for(int i=0;i<rest_len;i++) {
		ret[rest_to+i]=p_manifest[rest_from+i];
	}
	//finally update the size
	encode_uint32(ret.size(),&ret[4]);


	p_manifest=ret;
	printf("end\n");
}
Esempio n. 4
0
void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool p_give_internet) {


	const int CHUNK_AXML_FILE = 0x00080003;
	const int CHUNK_RESOURCEIDS = 0x00080180;
	const int CHUNK_STRINGS = 0x001C0001;
	const int CHUNK_XML_END_NAMESPACE = 0x00100101;
	const int CHUNK_XML_END_TAG = 0x00100103;
	const int CHUNK_XML_START_NAMESPACE = 0x00100100;
	const int CHUNK_XML_START_TAG = 0x00100102;
	const int CHUNK_XML_TEXT = 0x00100104;
	const int UTF8_FLAG = 0x00000100;

	Vector<String> string_table;

	uint32_t ofs=0;


	uint32_t header = decode_uint32(&p_manifest[ofs]);
	uint32_t filesize = decode_uint32(&p_manifest[ofs+4]);
	ofs+=8;

//	print_line("FILESIZE: "+itos(filesize)+" ACTUAL: "+itos(p_manifest.size()));

	uint32_t string_count;
	uint32_t styles_count;
	uint32_t string_flags;
	uint32_t string_data_offset;

	uint32_t styles_offset;
	uint32_t string_table_begins;
	uint32_t string_table_ends;
	Vector<uint8_t> stable_extra;

	while(ofs < p_manifest.size()) {

		uint32_t chunk = decode_uint32(&p_manifest[ofs]);
		uint32_t size = decode_uint32(&p_manifest[ofs+4]);


		switch(chunk) {

			case CHUNK_STRINGS: {


				int iofs=ofs+8;

				string_count=decode_uint32(&p_manifest[iofs]);
				styles_count=decode_uint32(&p_manifest[iofs+4]);
				uint32_t string_flags=decode_uint32(&p_manifest[iofs+8]);
				string_data_offset=decode_uint32(&p_manifest[iofs+12]);
				styles_offset=decode_uint32(&p_manifest[iofs+16]);
/*
				printf("string count: %i\n",string_count);
				printf("flags: %i\n",string_flags);
				printf("sdata ofs: %i\n",string_data_offset);
				printf("styles ofs: %i\n",styles_offset);
*/
				uint32_t st_offset=iofs+20;
				string_table.resize(string_count);
				uint32_t string_end=0;

				string_table_begins=st_offset;


				for(int i=0;i<string_count;i++) {

					uint32_t string_at = decode_uint32(&p_manifest[st_offset+i*4]);
					string_at+=st_offset+string_count*4;

					ERR_EXPLAIN("Unimplemented, can't read utf8 string table.");
					ERR_FAIL_COND(string_flags&UTF8_FLAG);

					if (string_flags&UTF8_FLAG) {



					} else {
						uint32_t len = decode_uint16(&p_manifest[string_at]);
						Vector<CharType> ucstring;
						ucstring.resize(len+1);
						for(int j=0;j<len;j++) {
							uint16_t c=decode_uint16(&p_manifest[string_at+2+2*j]);
							ucstring[j]=c;
						}
						string_end=MAX(string_at+2+2*len,string_end);
						ucstring[len]=0;
						string_table[i]=ucstring.ptr();
					}


//					print_line("String "+itos(i)+": "+string_table[i]);
				}

				for(int i=string_end;i<(ofs+size);i++) {
					stable_extra.push_back(p_manifest[i]);
				}

//				printf("stable extra: %i\n",int(stable_extra.size()));
				string_table_ends=ofs+size;

//				print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends));

			} break;
			case CHUNK_XML_START_TAG: {

				int iofs=ofs+8;
				uint32_t line=decode_uint32(&p_manifest[iofs]);
				uint32_t nspace=decode_uint32(&p_manifest[iofs+8]);
				uint32_t name=decode_uint32(&p_manifest[iofs+12]);
				uint32_t check=decode_uint32(&p_manifest[iofs+16]);

				String tname=string_table[name];

//				printf("NSPACE: %i\n",nspace);
				//printf("NAME: %i (%s)\n",name,tname.utf8().get_data());
				//printf("CHECK: %x\n",check);
				uint32_t attrcount=decode_uint32(&p_manifest[iofs+20]);
				iofs+=28;
				//printf("ATTRCOUNT: %x\n",attrcount);
				for(int i=0;i<attrcount;i++) {
					uint32_t attr_nspace=decode_uint32(&p_manifest[iofs]);
					uint32_t attr_name=decode_uint32(&p_manifest[iofs+4]);
					uint32_t attr_value=decode_uint32(&p_manifest[iofs+8]);
					uint32_t attr_flags=decode_uint32(&p_manifest[iofs+12]);
					uint32_t attr_resid=decode_uint32(&p_manifest[iofs+16]);


					String value;
					if (attr_value!=0xFFFFFFFF)
						value=string_table[attr_value];
					else
						value="Res #"+itos(attr_resid);
					String attrname = string_table[attr_name];
					String nspace;
					if (attr_nspace!=0xFFFFFFFF)
						nspace=string_table[attr_nspace];
					else
						nspace="";

					printf("ATTR %i NSPACE: %i\n",i,attr_nspace);
					printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data());
					printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data());
					printf("ATTR %i FLAGS: %x\n",i,attr_flags);
					printf("ATTR %i RESID: %x\n",i,attr_resid);

					//replace project information
					if (tname=="manifest" && attrname=="package") {

						print_line("FOUND PACKAGE");
						string_table[attr_value]=get_package_name();
					}

					//print_line("tname: "+tname);
					//print_line("nspace: "+nspace);
					//print_line("attrname: "+attrname);
					if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionCode") {

						print_line("FOUND versioncode");
						encode_uint32(version_code,&p_manifest[iofs+16]);
					}


					if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionName") {

						print_line("FOUND versionname");
						if (attr_value==0xFFFFFFFF) {
							WARN_PRINT("Version name in a resource, should be plaintext")
						} else
							string_table[attr_value]=version_name;
					}

					if (tname=="activity" && /*nspace=="android" &&*/ attrname=="screenOrientation") {

						encode_uint32(orientation==0?0:1,&p_manifest[iofs+16]);
						/*
						print_line("FOUND screen orientation");
						if (attr_value==0xFFFFFFFF) {
							WARN_PRINT("Version name in a resource, should be plaintext")
						} else {
							string_table[attr_value]=(orientation==0?"landscape":"portrait");
						}*/
					}

					if (tname=="application" && /*nspace=="android" &&*/ attrname=="label") {

						print_line("FOUND application");
						if (attr_value==0xFFFFFFFF) {
							WARN_PRINT("Application name in a resource, should be plaintext (but you can ignore this).")
						} else {

							String aname = get_project_name();
							string_table[attr_value]=aname;
						}
					}
					if (tname=="activity" && /*nspace=="android" &&*/ attrname=="label") {

						print_line("FOUND activity name");
						if (attr_value==0xFFFFFFFF) {
							WARN_PRINT("Activity name in a resource, should be plaintext (but you can ignore this)")
						} else {
							String aname;
							if (this->name!="") {
								aname=this->name;
							} else {
								aname = Globals::get_singleton()->get("application/name");

							}

							if (aname=="") {
								aname=_MKSTR(VERSION_NAME);
							}

							print_line("APP NAME IS..."+aname);
							string_table[attr_value]=aname;
						}
					}

					if (tname=="uses-permission" && /*nspace=="android" &&*/ attrname=="name") {

						if (value.begins_with("godot.custom")) {

							int which = value.get_slice(".",2).to_int();
							if (which>=0 && which<MAX_USER_PERMISSIONS && user_perms[which].strip_edges()!="") {

								string_table[attr_value]=user_perms[which].strip_edges();
							}

						} else if (value.begins_with("godot.")) {
							String perm = value.get_slice(".",1);
							print_line("PERM: "+perm+" HAS: "+itos(perms.has(perm)));

							if (perms.has(perm) || (p_give_internet && perm=="INTERNET")) {

								string_table[attr_value]="android.permission."+perm;
							}

						}
					}

					if (tname=="supports-screens" ) {

						if (attr_value==0xFFFFFFFF) {
							WARN_PRINT("Screen res name in a resource, should be plaintext")
						} else if (attrname=="smallScreens") {

							encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);

						} else if (attrname=="mediumScreens") {

							encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);

						} else if (attrname=="largeScreens") {

							encode_uint32(screen_support[SCREEN_LARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]);

						} else if (attrname=="xlargeScreens") {

							encode_uint32(screen_support[SCREEN_XLARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]);

						}
					}


					iofs+=20;
				}

			} break;
Esempio n. 5
0
void CSystemPage::ReloadVcproj(void)
{
  string root = "..\\utilities";
  string prefix = "UTIL_gm";
  string name;

  string theprojectname = get_project_name(EXEPROJECT, m_projectType, root, prefix, name);

  FILE *F = fopen(theprojectname.c_str(),"rb");
  if(F)
  {
      string line;
      bool is_release = false;
      bool is_debug = false;

      while(!feof(F))
      {
        ReadLine(F,line,1024);
        if(line.length()<=0) continue;
      
        const char *Pos;

        if(visualStudio7)
        {
          Pos = strstr(line.c_str(), "Name=\"Release|");
          if(Pos)
          {
            is_release = true;
            is_debug = false;
            continue;
          }
          Pos = strstr(line.c_str(), "Name=\"Debug|");
          if(Pos)
          {
            is_release = false;
            is_debug = true;
            continue;
          }

        
          const char *TMP_DIR = "IntermediateDirectory=\"";
          Pos = strstr(line.c_str(), TMP_DIR);
          if(Pos!=NULL)
          {
            const char *Pos2 = strstr(Pos+strlen(TMP_DIR), "\\UTIL_gm\"");
            if(Pos2!=NULL)
            {
              line[Pos2 - line.c_str() + 1] = 0;

              if(is_debug)
              {
                UpdateData(TRUE);
                m_tempDebug = Pos + strlen(TMP_DIR);
                UpdateData(FALSE);
              }
              if(is_release)
              {
                UpdateData(TRUE);
                m_tempRelease = Pos + strlen(TMP_DIR);
                UpdateData(FALSE);
              }
            }
            continue;
          }

          const char *OUT_DIR = "OutputDirectory=\"";
          Pos = strstr(line.c_str(), OUT_DIR);
          if(Pos!=NULL)
          {
            const char *Pos2 = strstr(Pos+strlen(OUT_DIR), "\"");
            if(Pos2!=NULL)
            {
              line[Pos2 - line.c_str()] = 0;

              UpdateData(TRUE);
              m_outputBin = Pos + strlen(OUT_DIR);
              UpdateData(FALSE);
            }
            continue;
          }

          const char *LIB_PATH = "AdditionalLibraryDirectories=\"";
          Pos = strstr(line.c_str(), LIB_PATH);
          if(Pos!=NULL)
          {
            const char *Pos2 = strstr(Pos+strlen(LIB_PATH), "\"");
            if(Pos2!=NULL)
            {
              line[Pos2 - line.c_str()] = 0;

              UpdateData(TRUE);
              m_outputLib = Pos + strlen(LIB_PATH);
              UpdateData(FALSE);
            }
            continue;
          }


        }
         
        else
        {
          Pos = strstr(line.c_str(), " - Win32 Release");
          if(Pos)
          {
            is_release = true;
            is_debug = false;
            continue;
          }
          Pos = strstr(line.c_str(), " - Win32 Debug");
          if(Pos)
          {
            is_release = false;
            is_debug = true;
            continue;
          }

          const char *OUT_DIR2 = "PROP Output_Dir \"";
          Pos = strstr(line.c_str(), OUT_DIR2);
          if(Pos!=NULL)
          {
            const char *Pos2 = strstr(Pos+strlen(OUT_DIR2), "\"");
            if(Pos2!=NULL)
            {
              line[Pos2 - line.c_str()] = 0;

              UpdateData(TRUE);
              m_outputBin = Pos + strlen(OUT_DIR2);
              UpdateData(FALSE);
            }
            continue;
          }


          const char *TMP_DIR6 = "PROP Intermediate_Dir \"";
          Pos = strstr(line.c_str(), TMP_DIR6);
          if(Pos!=NULL)
          {
            const char *Pos2 = strstr(Pos+strlen(TMP_DIR6), "\\UTIL_gm\"");
            if(Pos2!=NULL)
            {
              line[Pos2 - line.c_str() + 1] = 0;

              if(is_debug)
              {
                UpdateData(TRUE);
                m_tempDebug = Pos + strlen(TMP_DIR6);
                UpdateData(FALSE);
              }
              if(is_release)
              {
                UpdateData(TRUE);
                m_tempRelease = Pos + strlen(TMP_DIR6);
                UpdateData(FALSE);
              }
            }
            continue;          
          }


          const char *LIB_PATH6 = "ADD LINK32 /libpath:\"";
          Pos = strstr(line.c_str(), LIB_PATH6);
          if(Pos!=NULL)
          {
            const char *Pos2 = strstr(Pos+strlen(LIB_PATH6), "\" ");
            if(Pos2!=NULL)
            {
              line[Pos2 - line.c_str()] = 0;

              UpdateData(TRUE);
              m_outputLib = Pos + strlen(LIB_PATH6);
              UpdateData(FALSE);
            }
            continue;
          }
 
        }
 
      }
      fclose(F);
    }
}
Esempio n. 6
0
/*
 * Start the dialog that ask to the user where save the video
 * containing the screencast.
 * This function take as input the recorder tool button in ardesia bar
 * return true is the recorder is started.
 */
gboolean start_save_video_dialog (GtkToolButton *toolbutton,
                                  GtkWindow     *parent)
{
  gboolean status = FALSE;

  gchar *filename = g_strdup_printf ("%s", get_project_name ());

  GtkWidget *chooser = gtk_file_chooser_dialog_new (gettext ("Save video as ogv"),
                                                    parent,
                                                    GTK_FILE_CHOOSER_ACTION_SAVE,
                                                    GTK_STOCK_CANCEL,
                                                    GTK_RESPONSE_CANCEL,
                                                    GTK_STOCK_SAVE_AS,
                                                    GTK_RESPONSE_ACCEPT,
                                                    NULL);

  gtk_window_set_modal (GTK_WINDOW (chooser), TRUE);
  gtk_window_set_keep_above (GTK_WINDOW (chooser), TRUE);

  gtk_window_set_title (GTK_WINDOW (chooser), gettext ("Choose a file"));

  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), get_project_dir ());

  gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), filename);

  start_virtual_keyboard ();

  if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
    {
      gchar *supported_extension = ".ogv";
      gchar *filename_copy = (gchar *) NULL;
      g_free (filename);
      filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
      filename_copy = g_strdup_printf ("%s", filename); 

      if (!g_str_has_suffix (filename, supported_extension))
        {
          g_free (filename_copy);
          filename_copy = g_strdup_printf ("%s%s", filename, supported_extension);
        }

      g_free (filename);
      filename = filename_copy;

      if (file_exists (filename))
        {
          gint result = show_override_dialog (GTK_WINDOW (chooser));
          if ( result  == GTK_RESPONSE_NO)
            {
              g_free (filename);
              filename = NULL;
              gtk_widget_destroy (chooser);
              chooser = NULL;
              return status;
            }
        }
      else
        {
           FILE *stream = g_fopen (filename, "w");
           if (stream == NULL)
            {
              show_could_not_write_dialog (GTK_WINDOW (chooser));
            }
           else
            {
              fclose (stream);
            }
        }

      recorder_pid = call_recorder (filename, "start");
      status = (recorder_pid > 0);
    }
  stop_virtual_keyboard ();

  if (chooser)
    {
      gtk_widget_destroy (chooser);
      chooser = NULL;
    }

  g_free (filename);
  filename = NULL;
  return status;
}
Esempio n. 7
0
/* Load an iwb file and create the list of save-point. */
GSList *
load_iwb (gchar *iwbfile)
{
    const gchar *tmpdir = g_get_tmp_dir ();
    GSList *savepoint_list = (GSList *) NULL;
    gchar  *ardesia_tmp_dir = g_build_filename (tmpdir, PACKAGE_NAME, (gchar *) 0);
    gchar  *project_name = get_project_name ();
    gchar  *project_tmp_dir = g_build_filename (ardesia_tmp_dir, project_name, (gchar *) 0);
    gchar  *content_filename = "content.xml";
    gchar  *content_filepath = g_build_filename (project_tmp_dir, content_filename, (gchar *) 0);
    xmlDocPtr doc = (xmlDocPtr) NULL; // the resulting document tree
    xmlXPathContextPtr context = (xmlXPathContextPtr) NULL;

    decompress_iwb (iwbfile, project_tmp_dir);

    /* Initialize libxml. */
    xmlInitParser ();

    /*
     * This initialize the library and check potential ABI mismatches
     * between the version it was compiled for and the actual shared
     * library used.
     */
    LIBXML_TEST_VERSION

    /*
     * Build an XML tree from a the file.
     */
    doc = xmlParseFile (content_filepath);

    if (doc == NULL)
    {
        printf ("Failed to parse %s\n", content_filepath);
        exit (EXIT_FAILURE);
    }

    context = xmlXPathNewContext (doc);

    if (context == NULL)
    {
        xmlFreeDoc (doc);
        printf ("Error: unable to create new XPath context\n");
        exit (EXIT_FAILURE);
    }

    context = register_namespaces (context);

    savepoint_list = load_savepoints_by_iwb (savepoint_list, project_tmp_dir, context);

    g_remove (content_filepath);

    xmlXPathFreeContext (context);

    xmlFreeDoc (doc);
    doc = NULL;

    /*
     * Cleanup function for the XML library.
     */
    xmlCleanupParser ();

    g_free (ardesia_tmp_dir);
    ardesia_tmp_dir = NULL;

    g_free (project_tmp_dir);
    project_tmp_dir = NULL;

    g_free (content_filepath);
    content_filepath = NULL;

    return savepoint_list;
}