static gchar* rb_disc_recorder_plugin_write_audio_project (const gchar *name, GtkTreeModel *model, GError **error) { GtkTreeIter iter; xmlTextWriter *project; xmlDocPtr doc = NULL; xmlSaveCtxt *save; gint success; gchar *path; int fd; int use_errno = 0; if (! gtk_tree_model_get_iter_first (model, &iter)) { g_set_error (error, RB_RECORDER_ERROR, RB_RECORDER_ERROR_GENERAL, _("Unable to build an audio track list")); return NULL; } /* get a temporary path */ path = g_build_filename (g_get_tmp_dir (), "brasero-tmp-project-XXXXXX", NULL); fd = g_mkstemp (path); if (fd == -1) { g_set_error (error, RB_RECORDER_ERROR, RB_RECORDER_ERROR_GENERAL, _("Unable to write audio project file %s: %s"), path, g_strerror (errno)); rb_debug ("g_mkstemp failed"); g_free (path); return NULL; } project = xmlNewTextWriterDoc (&doc, 0); if (!project) { g_remove (path); g_free (path); close (fd); g_set_error (error, RB_RECORDER_ERROR, RB_RECORDER_ERROR_GENERAL, _("Unable to write audio project")); return NULL; } xmlTextWriterSetIndent (project, 1); xmlTextWriterSetIndentString (project, (xmlChar *) "\t"); success = xmlTextWriterStartDocument (project, NULL, "UTF8", NULL); if (success < 0) goto error; success = xmlTextWriterStartElement (project, (xmlChar *) "braseroproject"); if (success < 0) goto error; /* write the name of the version */ success = xmlTextWriterWriteElement (project, (xmlChar *) "version", (xmlChar *) "0.2"); if (success < 0) goto error; if (name) { success = xmlTextWriterWriteElement (project, (xmlChar *) "label", (xmlChar *) name); if (success < 0) goto error; } success = xmlTextWriterStartElement (project, (xmlChar *) "track"); if (success < 0) goto error; do { RhythmDBEntry *entry; const char *str; xmlChar *escaped; success = xmlTextWriterStartElement (project, (xmlChar *) "audio"); if (success < 0) goto error; gtk_tree_model_get (model, &iter, 0, &entry, -1); str = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); escaped = (xmlChar *) g_uri_escape_string (str, NULL, FALSE); success = xmlTextWriterWriteElement (project, (xmlChar *) "uri", escaped); g_free (escaped); if (success == -1) goto error; /* start of the song always 0 */ success = xmlTextWriterWriteElement (project, (xmlChar *) "start", (xmlChar *) "0"); if (success == -1) goto error; /* end of the song = duration (in seconds while brasero likes it * in nanoseconds =( ) */ /* Disable this for the moment and let brasero check the size * itself. In case the user chooses on the fly burning we need * a more precise duration or we'd end up burning the track * incompletely or with a big padding */ /* end = g_strdup_printf ("%"G_GINT64_FORMAT, (gint64) (song->duration * 1000000000LL)); success = xmlTextWriterWriteElement (project, (xmlChar *) "end", (xmlChar *) end); g_free (end); if (success == -1) goto error; */ str = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE); if (str) { escaped = (xmlChar *) g_uri_escape_string (str, NULL, FALSE); success = xmlTextWriterWriteElement (project, (xmlChar *) "title", escaped); g_free (escaped); if (success == -1) goto error; } str = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST); if (str) { escaped = (xmlChar *) g_uri_escape_string (str, NULL, FALSE); success = xmlTextWriterWriteElement (project, (xmlChar *) "artist", escaped); g_free (escaped); if (success == -1) goto error; } /* if (song->composer) { escaped = (unsigned char *) g_uri_escape_string (song->composer, NULL, FALSE); success = xmlTextWriterWriteElement (project, (xmlChar *) "composer", escaped); g_free (escaped); if (success == -1) goto error; } */ success = xmlTextWriterEndElement (project); /* audio */ if (success < 0) goto error; } while (gtk_tree_model_iter_next (model, &iter)); success = xmlTextWriterEndElement (project); /* track */ if (success < 0) goto error; success = xmlTextWriterEndElement (project); /* braseroproject */ if (success < 0) goto error; success = xmlTextWriterEndDocument (project); if (success < 0) goto end_error; xmlFreeTextWriter (project); save = xmlSaveToFd (fd, "UTF8", XML_SAVE_FORMAT); if (save == NULL) goto save_error; if (xmlSaveDoc (save, doc) == -1) goto save_error; if (xmlSaveClose (save) == -1) { use_errno = errno; rb_debug ("xmlSaveClose failed"); goto save_error; } xmlFreeDoc (doc); if (close (fd) == -1) { use_errno = errno; rb_debug ("close() failed"); goto save_error; } return path; error: /* cleanup */ xmlTextWriterEndDocument (project); end_error: xmlFreeTextWriter (project); save_error: if (use_errno != 0) { g_set_error (error, RB_RECORDER_ERROR, RB_RECORDER_ERROR_GENERAL, _("Unable to write audio project file %s: %s"), path, g_strerror (use_errno)); } else { g_set_error (error, RB_RECORDER_ERROR, RB_RECORDER_ERROR_GENERAL, _("Unable to write audio project")); } g_remove (path); g_free (path); close (fd); return NULL; }
/** * glista_storage_save_all_items: * @all_items: A linked list of all items to save * * Save all items to the storage XML file */ void glista_storage_save_all_items(GList *all_items) { GlistaItem *item; xmlTextWriterPtr xml; int ret; gchar *storage_file; gchar done_str[2]; gchar *remind_at_str; remind_at_str = g_malloc0(sizeof(gchar) * 20); // Build storage file path storage_file = g_build_filename(gl_globs->configdir, GL_XML_FILENAME, NULL); // Start XML xml = xmlNewTextWriterFilename(storage_file, 0); g_free(storage_file); if (xml == NULL) { fprintf(stderr, "Unable to write data to storage XML file\n"); return; } xmlTextWriterSetIndent(xml, 1); xmlTextWriterSetIndentString(xml, BAD_CAST " "); ret = xmlTextWriterStartDocument(xml, NULL, GL_XML_ENCODING, "yes"); ret = xmlTextWriterStartElement(xml, BAD_CAST GL_XNODE_ROOT); // Iterate over items, writing them to the XML file while (all_items != NULL) { item = all_items->data; g_snprintf((gchar *) &done_str, 2, "%d", item->done); ret = xmlTextWriterStartElement(xml, BAD_CAST GL_XNODE_ITEM); ret = xmlTextWriterWriteElement(xml, BAD_CAST GL_XNODE_TEXT, BAD_CAST item->text); ret = xmlTextWriterWriteElement(xml, BAD_CAST GL_XNODE_DONE, BAD_CAST &done_str); if (item->parent != NULL) { ret = xmlTextWriterWriteElement(xml, BAD_CAST GL_XNODE_PRNT, BAD_CAST item->parent); } if (item->note != NULL) { ret = xmlTextWriterWriteElement(xml, BAD_CAST GL_XNODE_NOTE, BAD_CAST item->note); } if (item->remind_at != -1) { remind_at_str = g_strdup_printf("%d", (gint) item->remind_at); ret = xmlTextWriterWriteElement(xml, BAD_CAST GL_XNODE_RMDR, BAD_CAST remind_at_str); } ret = xmlTextWriterEndElement(xml); all_items = all_items->next; } g_free(remind_at_str); // End XML ret = xmlTextWriterEndElement(xml); ret = xmlTextWriterEndDocument(xml); xmlTextWriterFlush(xml); xmlFreeTextWriter(xml); }
static char* totem_disc_recorder_plugin_write_video_project (TotemDiscRecorderPlugin *pi, char **error) { xmlTextWriter *project; xmlDocPtr doc = NULL; xmlSaveCtxt *save; xmlChar *escaped; gint success; char *title, *path, *uri; int fd; /* get a temporary path */ path = g_build_filename (g_get_tmp_dir (), "brasero-tmp-project-XXXXXX", NULL); fd = g_mkstemp (path); if (!fd) { g_free (path); *error = g_strdup (_("Unable to write a project.")); return NULL; } project = xmlNewTextWriterDoc (&doc, 0); if (!project) { g_remove (path); g_free (path); close (fd); *error = g_strdup (_("Unable to write a project.")); return NULL; } xmlTextWriterSetIndent (project, 1); xmlTextWriterSetIndentString (project, (xmlChar *) "\t"); success = xmlTextWriterStartDocument (project, NULL, "UTF8", NULL); if (success < 0) goto error; success = xmlTextWriterStartElement (project, (xmlChar *) "braseroproject"); if (success < 0) goto error; /* write the name of the version */ success = xmlTextWriterWriteElement (project, (xmlChar *) "version", (xmlChar *) "0.2"); if (success < 0) goto error; title = totem_object_get_short_title (pi->priv->totem); if (title) { success = xmlTextWriterWriteElement (project, (xmlChar *) "label", (xmlChar *) title); g_free (title); if (success < 0) goto error; } success = xmlTextWriterStartElement (project, (xmlChar *) "track"); if (success < 0) goto error; success = xmlTextWriterStartElement (project, (xmlChar *) "video"); if (success < 0) goto error; uri = totem_object_get_current_mrl (pi->priv->totem); escaped = (unsigned char *) g_uri_escape_string (uri, NULL, FALSE); g_free (uri); success = xmlTextWriterWriteElement (project, (xmlChar *) "uri", escaped); g_free (escaped); if (success == -1) goto error; /* start of the song always 0 */ success = xmlTextWriterWriteElement (project, (xmlChar *) "start", (xmlChar *) "0"); if (success == -1) goto error; success = xmlTextWriterEndElement (project); /* video */ if (success < 0) goto error; success = xmlTextWriterEndElement (project); /* track */ if (success < 0) goto error; success = xmlTextWriterEndElement (project); /* braseroproject */ if (success < 0) goto error; xmlTextWriterEndDocument (project); xmlFreeTextWriter (project); save = xmlSaveToFd (fd, "UTF8", XML_SAVE_FORMAT); xmlSaveDoc (save, doc); xmlSaveClose (save); xmlFreeDoc (doc); close (fd); return path; error: /* cleanup */ xmlTextWriterEndDocument (project); xmlFreeTextWriter (project); g_remove (path); g_free (path); close (fd); *error = g_strdup (_("Unable to write a project.")); return NULL; }
static void createSBOLWriter() { INDENT = 0; WRITER = xmlNewTextWriterDoc(&OUTPUT, 0); xmlTextWriterSetIndentString(WRITER,xmlCharStrdup("\t")); xmlTextWriterSetIndent(WRITER, INDENT); }
/** * @brief Saves the current game. * * @return 0 on success. */ int save_all (void) { char file[PATH_MAX]; xmlDocPtr doc; xmlTextWriterPtr writer; /* Create the writer. */ writer = xmlNewTextWriterDoc(&doc, conf.save_compress); if (writer == NULL) { ERR("testXmlwriterDoc: Error creating the xml writer"); return -1; } /* Set the writer parameters. */ xmlTextWriterSetIndentString(writer, (const xmlChar*)" "); xmlTextWriterSetIndent(writer, 1); /* Start element. */ xmlw_start(writer); xmlw_startElem(writer,"naev_save"); /* Save the version and such. */ xmlw_startElem(writer,"version"); xmlw_elem( writer, "naev", "%d.%d.%d", VMAJOR, VMINOR, VREV ); xmlw_elem( writer, "data", "%s", ndata_name() ); xmlw_endElem(writer); /* "version" */ /* Save the data. */ if (save_data(writer) < 0) { ERR("Trying to save game data"); goto err_writer; } /* Finish element. */ xmlw_endElem(writer); /* "naev_save" */ xmlw_done(writer); /* Write to file. */ if (nfile_dirMakeExist("%ssaves", nfile_basePath()) < 0) { WARN("Aborting save..."); goto err_writer; } snprintf(file, PATH_MAX, "%ssaves/%s.ns", nfile_basePath(), player_name); /* Back up old savegame. */ if (nfile_backupIfExists(file) < 0) { WARN("Aborting save..."); goto err_writer; } /* Critical section, if crashes here player's game gets corrupted. * Luckily we have a copy just in case... */ xmlFreeTextWriter(writer); if (xmlSaveFileEnc(file, doc, "UTF-8") < 0) { WARN("Failed to write savegame! You'll most likely have to restore it by copying your backup savegame over your current savegame."); goto err; } xmlFreeDoc(doc); return 0; err_writer: xmlFreeTextWriter(writer); err: xmlFreeDoc(doc); return -1; }
void nrps::startXml(xmlTextWriterPtr writer) { xmlTextWriterSetIndent(writer, 1); xmlTextWriterSetIndentString(writer, BAD_CAST " "); xmlTextWriterStartDocument(writer, nullptr, "UTF-8", nullptr); }
gboolean rejilla_project_save_project_xml (RejillaBurnSession *session, const gchar *uri) { RejillaTrackType *track_type = NULL; xmlTextWriter *project; gboolean retval; GSList *tracks; GValue *value; gint success; gchar *path; path = g_filename_from_uri (uri, NULL, NULL); if (!path) return FALSE; project = xmlNewTextWriterFilename (path, 0); if (!project) { g_free (path); return FALSE; } xmlTextWriterSetIndent (project, 1); xmlTextWriterSetIndentString (project, (xmlChar *) "\t"); success = xmlTextWriterStartDocument (project, NULL, "UTF-8", NULL); if (success < 0) goto error; success = xmlTextWriterStartElement (project, (xmlChar *) "rejillaproject"); if (success < 0) goto error; /* write the name of the version */ success = xmlTextWriterWriteElement (project, (xmlChar *) "version", (xmlChar *) REJILLA_PROJECT_VERSION); if (success < 0) goto error; if (rejilla_burn_session_get_label (session)) { success = xmlTextWriterWriteElement (project, (xmlChar *) "label", (xmlChar *) rejilla_burn_session_get_label (session)); if (success < 0) goto error; } value = NULL; rejilla_burn_session_tag_lookup (session, REJILLA_COVER_URI, &value); if (value) { gchar *escaped; escaped = g_uri_escape_string (g_value_get_string (value), NULL, FALSE); success = xmlTextWriterWriteElement (project, (xmlChar *) "cover", (xmlChar *) escaped); g_free (escaped); if (success < 0) goto error; } success = xmlTextWriterStartElement (project, (xmlChar *) "track"); if (success < 0) goto error; track_type = rejilla_track_type_new (); tracks = rejilla_burn_session_get_tracks (session); for (; tracks; tracks = tracks->next) { RejillaTrack *track; track = tracks->data; rejilla_track_get_track_type (track, track_type); if (rejilla_track_type_get_has_stream (track_type)) { if (REJILLA_STREAM_FORMAT_HAS_VIDEO (rejilla_track_type_get_stream_format (track_type))) success = xmlTextWriterStartElement (project, (xmlChar *) "video"); else success = xmlTextWriterStartElement (project, (xmlChar *) "audio"); if (success < 0) goto error; retval = _save_audio_track_xml (project, REJILLA_TRACK_STREAM (track)); if (!retval) goto error; success = xmlTextWriterEndElement (project); /* audio/video */ if (success < 0) goto error; } else if (rejilla_track_type_get_has_data (track_type)) { success = xmlTextWriterStartElement (project, (xmlChar *) "data"); if (success < 0) goto error; retval = _save_data_track_xml (project, session); if (!retval) goto error; success = xmlTextWriterEndElement (project); /* data */ if (success < 0) goto error; } else retval = FALSE; } success = xmlTextWriterEndElement (project); /* track */ if (success < 0) goto error; rejilla_track_type_free (track_type); success = xmlTextWriterEndElement (project); /* rejillaproject */ if (success < 0) goto error; xmlTextWriterEndDocument (project); xmlFreeTextWriter (project); g_free (path); return TRUE; error: if (track_type) rejilla_track_type_free (track_type); xmlTextWriterEndDocument (project); xmlFreeTextWriter (project); g_remove (path); g_free (path); return FALSE; }
void write_preset_to_xml(Preset *preset, gchar *filename) { int rc; xmlTextWriterPtr writer; GList *iter_params = preset->params; guint last_id = 0; guint last_position = 0; printf("Creating a new xml doc\n"); /* Create a new XmlWriter for uri, with no compression. */ writer = xmlNewTextWriterFilename(filename, 0); if (writer == NULL) { printf("testXmlwriterFilename: Error creating the xml writer\n"); return; } /* * Start the document with the xml default for the version, * encoding and the default for the standalone declaration. */ rc = xmlTextWriterStartDocument(writer, NULL, GDIGI_ENCODING, NULL); if (rc < 0) { printf ("testXmlwriterFilename: Error at xmlTextWriterStartDocument\n"); return; } rc = xmlTextWriterSetIndent(writer, 1); rc = xmlTextWriterSetIndentString(writer, BAD_CAST " "); /* Write the tag identifying type of prefix, schema version and ns. */ rc = xmlTextWriterStartElement(writer, BAD_CAST get_preset_filename(product_id)); rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "SchemaVersion", BAD_CAST "1.2"); rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns", BAD_CAST "http://www.digitech.com/xml/preset"); /* Write the Name tag. */ rc = xmlTextWriterWriteElement(writer, BAD_CAST "Name", BAD_CAST preset->name); rc = xmlTextWriterStartElement(writer, BAD_CAST "Params"); while (iter_params) { XmlSettings *xml; SettingParam *param = (SettingParam *) iter_params->data; if (param->id == last_id && param->position == last_position) { g_warning("Skipping duplicate parameter id %d position %d", last_id, last_position); iter_params = iter_params->next; continue; } rc = xmlTextWriterStartElement(writer, BAD_CAST "Param"); rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ID", "%d", param->id); rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "Position", "%d", param->position); rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "Value", "%d", param->value); last_id = param->id; last_position = param->position; xml = get_xml_settings(param->id, param->position); if (!xml) { printf("Failed to get xml settings for id %d position %d\n", param->id, param->position); } else { ValueType type; gchar *suffix = ""; gdouble step = 1.0; gint offset = 0; gboolean decimal = FALSE; EffectValues *values = NULL; rc = xmlTextWriterWriteElement(writer, BAD_CAST "Name", BAD_CAST xml->label); values = xml->values; type = values->type; while ((type & VALUE_TYPE_EXTRA) && value_is_extra(values, param->value)) { values = values->extra; type = values->type; } type &= ~VALUE_TYPE_EXTRA; if (type & VALUE_TYPE_OFFSET) { offset = values->offset; type &= ~VALUE_TYPE_OFFSET; } if (type & VALUE_TYPE_STEP) { step = values->step; type &= ~VALUE_TYPE_STEP; } if (type & VALUE_TYPE_SUFFIX) { suffix = values->suffix; type &= ~VALUE_TYPE_SUFFIX; } if (type & VALUE_TYPE_DECIMAL) { decimal = TRUE; type &= ~VALUE_TYPE_DECIMAL; } switch (type) { case VALUE_TYPE_LABEL: { char *textp = map_xml_value(xml, param->value); if (!textp) { g_warning("Unable to map %s value %d for id %d position %d", xml->label, param->value, param->id, param->position); textp = ""; } rc = xmlTextWriterWriteElement(writer, BAD_CAST "Text", BAD_CAST textp); break; } case VALUE_TYPE_PLAIN: { if (decimal) { double value = (param->value + offset) * step; rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "Text", "%0.2f%s", value, suffix); } else { gint value = (param->value + offset) * step; rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "Text", "%d%s", value, suffix); } break; } case VALUE_TYPE_NONE: rc = xmlTextWriterStartElement(writer, BAD_CAST "Text"); rc = xmlTextWriterEndElement(writer); break; default: g_warning("Unhandled value type %d", type); break; } } rc = xmlTextWriterEndElement(writer); iter_params = iter_params->next; } rc = xmlTextWriterEndDocument(writer); if (rc < 0) { printf("testXmlwriterFilename: Error at xmlTextWriterEndDocument\n"); return; } xmlFreeTextWriter(writer); }
static int ephy_node_db_write_to_xml_valist (EphyNodeDb *db, const xmlChar *filename, const xmlChar *root, const xmlChar *version, const xmlChar *comment, EphyNode *first_node, va_list argptr) { xmlTextWriterPtr writer; EphyNode *node; int ret; LOG ("Saving node db to %s", filename); START_PROFILER ("Saving node db") /* FIXME: do we want to turn compression on ? */ writer = xmlNewTextWriterFilename ((const char *)filename, 0); if (writer == NULL) { return -1; } ret = xmlTextWriterSetIndent (writer, 1); if (ret < 0) goto out; ret = xmlTextWriterSetIndentString (writer, (const xmlChar *)" "); if (ret < 0) goto out; ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL); if (ret < 0) goto out; ret = xmlTextWriterStartElement (writer, root); if (ret < 0) goto out; ret = xmlTextWriterWriteAttribute (writer, (const xmlChar *)"version", version); if (ret < 0) goto out; if (comment != NULL) { ret = xmlTextWriterWriteComment (writer, comment); if (ret < 0) goto out; } node = first_node; while (node != NULL) { GPtrArray *children; EphyNodeFilterFunc filter; gpointer user_data; int i; filter = va_arg (argptr, EphyNodeFilterFunc); user_data = va_arg (argptr, gpointer); children = ephy_node_get_children (node); for (i = 0; i < children->len; i++) { EphyNode *kid; kid = g_ptr_array_index (children, i); if (!filter || filter (kid, user_data)) { ret = ephy_node_write_to_xml (kid, writer); if (ret < 0) break; } } if (ret < 0) break; node = va_arg (argptr, EphyNode *); } if (ret < 0) goto out; ret = xmlTextWriterEndElement (writer); /* root */ if (ret < 0) goto out; ret = xmlTextWriterEndDocument (writer); if (ret < 0) goto out; out: xmlFreeTextWriter (writer); STOP_PROFILER ("Saving node db") return ret >= 0 ? 0 : -1; }
static RejillaBurnResult rejilla_vcd_imager_generate_xml_file (RejillaProcess *process, const gchar *path, GError **error) { RejillaVcdImagerPrivate *priv; GSList *tracks = NULL; xmlTextWriter *xml; gchar buffer [64]; gint success; GSList *iter; gchar *name; gint i; REJILLA_JOB_LOG (process, "Creating (S)VCD layout xml file (%s)", path); xml = xmlNewTextWriterFilename (path, 0); if (!xml) return REJILLA_BURN_ERR; priv = REJILLA_VCD_IMAGER_PRIVATE (process); xmlTextWriterSetIndent (xml, 1); xmlTextWriterSetIndentString (xml, (xmlChar *) "\t"); success = xmlTextWriterStartDocument (xml, NULL, "UTF8", NULL); if (success < 0) goto error; success = xmlTextWriterWriteDTD (xml, (xmlChar *) "videocd", (xmlChar *) "-//GNU//DTD VideoCD//EN", (xmlChar *) "http://www.gnu.org/software/vcdimager/videocd.dtd", (xmlChar *) NULL); if (success < 0) goto error; /* let's start */ success = xmlTextWriterStartElement (xml, (xmlChar *) "videocd"); if (success < 0) goto error; success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "xmlns", (xmlChar *) "http://www.gnu.org/software/vcdimager/1.0/"); if (success < 0) goto error; if (priv->svcd) success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "class", (xmlChar *) "svcd"); else success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "class", (xmlChar *) "vcd"); if (success < 0) goto error; if (priv->svcd) success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "version", (xmlChar *) "1.0"); else success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "version", (xmlChar *) "2.0"); if (success < 0) goto error; /* info part */ success = xmlTextWriterStartElement (xml, (xmlChar *) "info"); if (success < 0) goto error; /* name of the volume */ name = NULL; rejilla_job_get_audio_title (REJILLA_JOB (process), &name); success = xmlTextWriterWriteElement (xml, (xmlChar *) "album-id", (xmlChar *) name); g_free (name); if (success < 0) goto error; /* number of CDs */ success = xmlTextWriterWriteElement (xml, (xmlChar *) "volume-count", (xmlChar *) "1"); if (success < 0) goto error; /* CD number */ success = xmlTextWriterWriteElement (xml, (xmlChar *) "volume-number", (xmlChar *) "1"); if (success < 0) goto error; /* close info part */ success = xmlTextWriterEndElement (xml); if (success < 0) goto error; /* Primary Volume descriptor */ success = xmlTextWriterStartElement (xml, (xmlChar *) "pvd"); if (success < 0) goto error; /* NOTE: no need to convert a possible non compliant name as this will * be done by vcdimager. */ name = NULL; rejilla_job_get_audio_title (REJILLA_JOB (process), &name); success = xmlTextWriterWriteElement (xml, (xmlChar *) "volume-id", (xmlChar *) name); g_free (name); if (success < 0) goto error; /* Makes it CD-i compatible */ success = xmlTextWriterWriteElement (xml, (xmlChar *) "system-id", (xmlChar *) "CD-RTOS CD-BRIDGE"); if (success < 0) goto error; /* Close Primary Volume descriptor */ success = xmlTextWriterEndElement (xml); if (success < 0) goto error; /* the tracks */ success = xmlTextWriterStartElement (xml, (xmlChar *) "sequence-items"); if (success < 0) goto error; /* get all tracks */ rejilla_job_get_tracks (REJILLA_JOB (process), &tracks); priv->num_tracks = g_slist_length (tracks); for (i = 0, iter = tracks; iter; iter = iter->next, i++) { RejillaTrack *track; gchar *video; track = iter->data; success = xmlTextWriterStartElement (xml, (xmlChar *) "sequence-item"); if (success < 0) goto error; video = rejilla_track_stream_get_source (REJILLA_TRACK_STREAM (track), FALSE); success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "src", (xmlChar *) video); g_free (video); if (success < 0) goto error; sprintf (buffer, "track-%i", i); success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "id", (xmlChar *) buffer); if (success < 0) goto error; /* close sequence-item */ success = xmlTextWriterEndElement (xml); if (success < 0) goto error; } /* sequence-items */ success = xmlTextWriterEndElement (xml); if (success < 0) goto error; /* the navigation */ success = xmlTextWriterStartElement (xml, (xmlChar *) "pbc"); if (success < 0) goto error; /* get all tracks */ rejilla_job_get_tracks (REJILLA_JOB (process), &tracks); for (i = 0, iter = tracks; iter; iter = iter->next, i++) { RejillaTrack *track; track = iter->data; sprintf (buffer, "playlist-%i", i); success = xmlTextWriterStartElement (xml, (xmlChar *) "playlist"); if (success < 0) goto error; success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "id", (xmlChar *) buffer); if (success < 0) goto error; success = xmlTextWriterWriteElement (xml, (xmlChar *) "wait", (xmlChar *) "0"); if (success < 0) goto error; success = xmlTextWriterStartElement (xml, (xmlChar *) "play-item"); if (success < 0) goto error; sprintf (buffer, "track-%i", i); success = xmlTextWriterWriteAttribute (xml, (xmlChar *) "ref", (xmlChar *) buffer); if (success < 0) goto error; /* play-item */ success = xmlTextWriterEndElement (xml); if (success < 0) goto error; /* playlist */ success = xmlTextWriterEndElement (xml); if (success < 0) goto error; } /* pbc */ success = xmlTextWriterEndElement (xml); if (success < 0) goto error; /* close videocd */ success = xmlTextWriterEndElement (xml); if (success < 0) goto error; xmlTextWriterEndDocument (xml); xmlFreeTextWriter (xml); return REJILLA_BURN_OK; error: REJILLA_JOB_LOG (process, "Error"); /* close everything */ xmlTextWriterEndDocument (xml); xmlFreeTextWriter (xml); /* FIXME: get the error */ return REJILLA_BURN_ERR; }