/* xlog - GTK+ logging program for amateur radio operators Copyright (C) 2001 - 2007 Joop Stakenborg This file is part of xlog. Xlog is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Xlog is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with xlog. If not, see . */ /* * preferences.c - load and save program settings in xml format */ #include #include #include #include #include #include "preferences.h" #include "utils.h" #include "support.h" preferencestype preferences; extern gchar *xlogdir; static gint make_default_preferences (void) { preferences.x = 10; preferences.y = 30; preferences.width = 750; preferences.height = 540; preferences.latitude = 0.0; preferences.NS = 1; preferences.longitude = 0.0; preferences.EW = 1; preferences.units = 1; preferences.bands = g_strdup ("0.136,1.8,3.5,5.2,7,10,14,18,21,24,28,50,70,144,222,420,902,1240,2300,3300,5650,10000,24000,47000,75500,120000,142000,241000,300000"); preferences.modes = g_strdup ("SSB,CW,FM,AM,ASCI,ATV,CLO,FAX,GTOR,HELL,HFSK,JT44,JT6M,MFSK8,MFSK16,MTTY,MT63,OLIVIA,PAC,PAC2,PAC3,PCW,PKT,PSK31,PSK63,PSK125,Q15,RTTY,SSTV,THRB,TOR"); preferences.bandseditbox = 0; preferences.modeseditbox = 0; preferences.bandoptionmenu = 0; preferences.modeoptionmenu = 0; preferences.printall = 0; preferences.printsize = 0; preferences.printpoint = 0; preferences.printorientation = 0; preferences.printdestination = 0; preferences.hamlib = 0; preferences.rigid = 1; preferences.device = g_strdup ("/dev/ttyS1"); preferences.rigconf = g_strdup ("?"); preferences.round = 3; preferences.polltime = 0; preferences.clock = 0; preferences.logfont = g_strdup ("Sans 10"); preferences.autosave = 5; preferences.savedir = g_strdup_printf ("%s%s.%s", g_get_home_dir (), G_DIR_SEPARATOR_S, PACKAGE); preferences.saving = 1; preferences.logstoload = g_strdup ("*"); preferences.locator = g_strdup ("AA00AA"); preferences.freefield1 = g_strdup ("UNKNOWN"); preferences.freefield2 = g_strdup ("UNKNOWN"); preferences.callsign = g_strdup ("N0CALL"); preferences.defaultmhz = g_strdup ("?"); preferences.defaultmode = g_strdup ("?"); preferences.defaulttxrst = g_strdup ("?"); preferences.defaultrxrst = g_strdup ("?"); preferences.defaultawards = g_strdup ("?"); preferences.defaultpower = g_strdup ("?"); preferences.defaultfreefield1 = g_strdup ("?"); preferences.defaultfreefield2 = g_strdup ("?"); preferences.defaultremarks = g_strdup ("?"); preferences.b4columns2 = g_strdup ("1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0"); preferences.logcwidths2 = g_strdup ("50,100,50,50,100,50,50,50,50,100,50,50,50,100,100,100,100,100,200"); preferences.typeaheadfind = 1; preferences.remoteadding = 1; preferences.viewtoolbar = 1; preferences.viewb4 = 0; preferences.b4x = 10; preferences.b4y = 30; preferences.b4width = 500; preferences.b4height = 300; preferences.saveasadif = 0; preferences.saveastsv2 = g_strdup ("1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0"); preferences.handlebarpos = 300; preferences.cwf1 = g_strdup ("cq de % % test"); preferences.cwf2 = g_strdup ("@ de %"); preferences.cwf3 = g_strdup ("@ ++5nn--#"); preferences.cwf4 = g_strdup ("tu 73"); preferences.cwf5 = g_strdup ("@"); preferences.cwf6 = g_strdup ("%"); preferences.cwf7 = g_strdup ("@ sri qso b4 gl"); preferences.cwf8 = g_strdup ("agn"); preferences.cwf9 = g_strdup ("?"); preferences.cwf10 = g_strdup ("qrz?"); preferences.cwf11 = g_strdup ("pse k"); preferences.cwf12 = g_strdup ("++++test---- % %"); preferences.cwcq = g_strdup ("tu %"); preferences.cwsp = g_strdup ("tu 5nn#"); preferences.cwspeed = 24; preferences.backupdir = g_strdup_printf ("%s%s.%s", g_get_home_dir (), G_DIR_SEPARATOR_S, PACKAGE); preferences.backup = 1; preferences.fcc = 0; preferences.tsvcalc = 0; preferences.viewscoring = 1; preferences.scorex = 10; preferences.scorey = 300; preferences.scorewidth = 500; preferences.scoreheight = 300; preferences.scoringbands = g_strdup ("01101111111000000000000000000"); preferences.distqrb = 0; preferences.awardswac = 0; return 0; } void parseloadpreferences (xmlDocPtr p, xmlNodePtr cur) { xmlChar *key; cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"x"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.x = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"y"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.y = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"width"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.width = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"height"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.height = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"latitude"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.latitude = atof ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"NS"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.NS = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"longitude"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.longitude = atof ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"EW"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.EW = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"units"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.units = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"bands"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.bands = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"modes"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.modes = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"modeseditbox"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.modeseditbox = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"bandseditbox"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.bandseditbox = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"bandoptionmenu"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.bandoptionmenu = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"modeoptionmenu"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.modeoptionmenu = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"printall"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.printall = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"printsize"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.printsize = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"printpoint"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.printpoint = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"printdestination"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.printdestination = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"printorientation"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.printorientation = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"hamlib"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.hamlib = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"rigid"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.rigid = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"device"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.device = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"rigconf"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.rigconf = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"round"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.round = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"polltime"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.polltime = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"clock"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.clock = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"logfont"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.logfont = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"autosave"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.autosave = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"savedir"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.savedir = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"saving"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.saving = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"logstoload"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.logstoload = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"locator"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.locator = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"freefield1"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.freefield1 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"freefield2"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.freefield2 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"callsign"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.callsign = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaultmhz"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaultmhz = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaultmode"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaultmode = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaulttxrst"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaulttxrst = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaultrxrst"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaultrxrst = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaultawards"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaultawards = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaultpower"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaultpower = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaultfreefield1"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaultfreefield1 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaultfreefield2"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaultfreefield2 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"defaultremarks"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.defaultremarks = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"b4columns2"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.b4columns2 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"logcwidths2"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.logcwidths2 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"typeaheadfind"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.typeaheadfind = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"remoteadding"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.remoteadding = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"viewtoolbar"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.viewtoolbar = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"viewb4"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.viewb4 = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"b4x"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.b4x = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"b4y"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.b4y = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"b4width"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.b4width = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"b4height"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.b4height = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"saveasadif"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.saveasadif = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"saveastsv2"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.saveastsv2 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"handlebarpos"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.handlebarpos = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf1"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf1 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf2"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf2 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf3"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf3 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf4"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf4 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf5"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf5 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf6"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf6 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf7"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf7 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf8"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf8 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf9"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf9 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf10"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf10 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf11"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf11 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwf12"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwf12 = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwcq"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwcq = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwsp"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwsp = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"cwspeed"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.cwspeed = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"backupdir"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.backupdir = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"backup"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.backup = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"fcc"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.fcc = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"tsvcalc"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.tsvcalc = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"viewscoring"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.viewscoring = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"scorex"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.scorex = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"scorey"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.scorey = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"scorewidth"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.scorewidth = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"scoreheight"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.scoreheight = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"scoringbands"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.scoringbands = g_strdup ((gchar *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"distqrb"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.distqrb = atoi ((const char *)key); free (key); } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"awardswac"))) { key = xmlNodeListGetString (p, cur->xmlChildrenNode, 1); preferences.awardswac = atoi ((const char *)key); free (key); } cur = cur->next; } return; } void parsesavepreferences (xmlNodePtr cur) { gchar *key; xmlNodePtr node; for (node = cur->children; node != NULL; node = node->next) { if (!g_ascii_strcasecmp ((gchar *)node->name, "x")) { key = g_strdup_printf ("%d", preferences.x); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "y")) { key = g_strdup_printf ("%d", preferences.y); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "width")) { key = g_strdup_printf ("%d", preferences.width); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "height")) { key = g_strdup_printf ("%d", preferences.height); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "latitude")) { key = g_strdup_printf ("%3.2f", preferences.latitude); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "NS")) { key = g_strdup_printf ("%d", preferences.NS); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "longitude")) { key = g_strdup_printf ("%3.2f", preferences.longitude); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "EW")) { key = g_strdup_printf ("%d", preferences.EW); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "units")) { key = g_strdup_printf ("%d", preferences.units); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "bands")) { key = g_strdup (preferences.bands); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "modes")) { key = g_strdup (preferences.modes); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "modeseditbox")) { key = g_strdup_printf ("%d", preferences.modeseditbox); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "bandseditbox")) { key = g_strdup_printf ("%d", preferences.bandseditbox); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "modeoptionmenu")) { key = g_strdup_printf ("%d", preferences.modeoptionmenu); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "bandoptionmenu")) { key = g_strdup_printf ("%d", preferences.bandoptionmenu); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "printall")) { key = g_strdup_printf ("%d", preferences.printall); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "printsize")) { key = g_strdup_printf ("%d", preferences.printsize); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "printpoint")) { key = g_strdup_printf ("%d", preferences.printpoint); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "printorientation")) { key = g_strdup_printf ("%d", preferences.printorientation); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "printdestination")) { key = g_strdup_printf ("%d", preferences.printdestination); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "hamlib")) { key = g_strdup_printf ("%d", preferences.hamlib); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "rigid")) { key = g_strdup_printf ("%d", preferences.rigid); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "device")) { key = g_strdup (preferences.device); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "rigconf")) { key = g_strdup (preferences.rigconf); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "round")) { key = g_strdup_printf ("%d", preferences.round); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "polltime")) { key = g_strdup_printf ("%d", preferences.polltime); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "clock")) { key = g_strdup_printf ("%d", preferences.clock); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "logfont")) { key = g_strdup (preferences.logfont); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "autosave")) { key = g_strdup_printf ("%d", preferences.autosave); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "savedir")) { key = g_strdup (preferences.savedir); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "saving")) { key = g_strdup_printf ("%d", preferences.saving); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "logstoload")) { key = g_strdup (preferences.logstoload); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "locator")) { key = g_strdup (preferences.locator); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "freefield1")) { key = g_strdup (preferences.freefield1); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "freefield2")) { key = g_strdup (preferences.freefield2); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "callsign")) { key = g_strdup (preferences.callsign); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaultmhz")) { key = g_strdup (preferences.defaultmhz); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaultmode")) { key = g_strdup (preferences.defaultmode); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaulttxrst")) { key = g_strdup (preferences.defaulttxrst); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaultrxrst")) { key = g_strdup (preferences.defaultrxrst); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaultawards")) { key = g_strdup (preferences.defaultawards); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaultpower")) { key = g_strdup (preferences.defaultpower); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaultfreefield1")) { key = g_strdup (preferences.defaultfreefield1); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaultfreefield2")) { key = g_strdup (preferences.defaultfreefield2); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "defaultremarks")) { key = g_strdup (preferences.defaultremarks); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "b4columns2")) { key = g_strdup (preferences.b4columns2); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "logcwidths2")) { key = g_strdup (preferences.logcwidths2); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "typeaheadfind")) { key = g_strdup_printf ("%d", preferences.typeaheadfind); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "remoteadding")) { key = g_strdup_printf ("%d", preferences.remoteadding); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "viewtoolbar")) { key = g_strdup_printf ("%d", preferences.viewtoolbar); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "viewb4")) { key = g_strdup_printf ("%d", preferences.viewb4); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "b4x")) { key = g_strdup_printf ("%d", preferences.b4x); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "b4y")) { key = g_strdup_printf ("%d", preferences.b4y); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "b4width")) { key = g_strdup_printf ("%d", preferences.b4width); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "b4height")) { key = g_strdup_printf ("%d", preferences.b4height); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "saveasadif")) { key = g_strdup_printf ("%d", preferences.saveasadif); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "saveastsv2")) { key = g_strdup_printf ("%s", preferences.saveastsv2); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "handlebarpos")) { key = g_strdup_printf ("%d", preferences.handlebarpos); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf1")) { key = g_strdup_printf ("%s", preferences.cwf1); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf2")) { key = g_strdup_printf ("%s", preferences.cwf2); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf3")) { key = g_strdup_printf ("%s", preferences.cwf3); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf4")) { key = g_strdup_printf ("%s", preferences.cwf4); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf5")) { key = g_strdup_printf ("%s", preferences.cwf5); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf6")) { key = g_strdup_printf ("%s", preferences.cwf6); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf7")) { key = g_strdup_printf ("%s", preferences.cwf7); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf8")) { key = g_strdup_printf ("%s", preferences.cwf8); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf9")) { key = g_strdup_printf ("%s", preferences.cwf9); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf10")) { key = g_strdup_printf ("%s", preferences.cwf10); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf11")) { key = g_strdup_printf ("%s", preferences.cwf11); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwf12")) { key = g_strdup_printf ("%s", preferences.cwf12); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwcq")) { key = g_strdup_printf ("%s", preferences.cwcq); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwsp")) { key = g_strdup_printf ("%s", preferences.cwsp); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "cwspeed")) { key = g_strdup_printf ("%d", preferences.cwspeed); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "backupdir")) { key = g_strdup (preferences.backupdir); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "backup")) { key = g_strdup_printf ("%d", preferences.backup); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "fcc")) { key = g_strdup_printf ("%d", preferences.fcc); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "tsvcalc")) { key = g_strdup_printf ("%d", preferences.tsvcalc); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "viewscoring")) { key = g_strdup_printf ("%d", preferences.viewscoring); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "scorex")) { key = g_strdup_printf ("%d", preferences.scorex); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "scorey")) { key = g_strdup_printf ("%d", preferences.scorey); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "scorewidth")) { key = g_strdup_printf ("%d", preferences.scorewidth); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "scoreheight")) { key = g_strdup_printf ("%d", preferences.scoreheight); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "scoringbands")) { key = g_strdup (preferences.scoringbands); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "distqrb")) { key = g_strdup_printf ("%d", preferences.distqrb); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } else if (!g_ascii_strcasecmp ((gchar *)node->name, "awardswac")) { key = g_strdup_printf ("%d", preferences.awardswac); xmlNodeSetContent (node, (const xmlChar *)key); g_free (key); } } } static void newsavepreferences (xmlNodePtr cur) { gchar *homedir = g_strdup_printf ("%s%s.%s", g_get_home_dir (), G_DIR_SEPARATOR_S, PACKAGE); xmlNewTextChild (cur, NULL, (const xmlChar *)"x", (const xmlChar *)"10"); xmlNewTextChild (cur, NULL, (const xmlChar *)"y", (const xmlChar *)"30"); xmlNewTextChild (cur, NULL, (const xmlChar *)"width", (const xmlChar *)"750"); xmlNewTextChild (cur, NULL, (const xmlChar *)"height", (const xmlChar *)"540"); xmlNewTextChild (cur, NULL, (const xmlChar *)"latitude", (const xmlChar *)"0.0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"NS", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"longitude", (const xmlChar *)"0.0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"EW", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"units", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"bands", (const xmlChar *) "0.136,1.8,3.5,5.2,7,10,14,18,21,24,28,50,70,144,222,420,902,1240,2300,3300,5650,10000,24000,47000,75500,120000,142000,241000,300000"); xmlNewTextChild (cur, NULL, (const xmlChar *)"modes", (const xmlChar *) "SSB,CW,FM,AM,ASCI,ATV,CLO,FAX,GTOR,HELL,HFSK,JT44,JT6M,MFSK8,MFSK16,MTTY,MT63,OLIVIA,PAC,PAC2,PAC3,PCW,PKT,PSK31,PSK63,PSK125,Q15,RTTY,SSTV,THRB,TOR"); xmlNewTextChild (cur, NULL, (const xmlChar *)"bandseditbox", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"modeseditbox", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"bandoptionmenu", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"modeoptionmenu", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"printall", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"printsize", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"printpoint", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"printorientation", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"printdestination", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"hamlib", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"rigid", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"device", (const xmlChar *)"/dev/ttyS1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"rigconf", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"round", (const xmlChar *)"3"); xmlNewTextChild (cur, NULL, (const xmlChar *)"polltime", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"clock", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"logfont", (const xmlChar *)"Sans 10"); xmlNewTextChild (cur, NULL, (const xmlChar *)"autosave", (const xmlChar *)"5"); xmlNewTextChild (cur, NULL, (const xmlChar *)"savedir", (const xmlChar *)homedir); xmlNewTextChild (cur, NULL, (const xmlChar *)"saving", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"logstoload", (const xmlChar *)"*"); xmlNewTextChild (cur, NULL, (const xmlChar *)"locator", (const xmlChar *)"AA00AA"); xmlNewTextChild (cur, NULL, (const xmlChar *)"freefield1", (const xmlChar *)"UNKNOWN"); xmlNewTextChild (cur, NULL, (const xmlChar *)"freefield2", (const xmlChar *)"UNKNOWN"); xmlNewTextChild (cur, NULL, (const xmlChar *)"callsign", (const xmlChar *)"N0CALL"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaultmhz", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaultmode", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaulttxrst", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaultrxrst", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaultawards", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaultpower", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaultfreefield1", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaultfreefield2", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"defaultremarks", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"b4columns2", (const xmlChar *)"1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"logcwidths2", (const xmlChar *)"50,100,50,50,100,50,50,50,50,100,50,50,50,100,100,100,100,100,200"); xmlNewTextChild (cur, NULL, (const xmlChar *)"typeaheadfind", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"remoteadding", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"viewtoolbar", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"viewb4", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"b4x", (const xmlChar *)"10"); xmlNewTextChild (cur, NULL, (const xmlChar *)"b4y", (const xmlChar *)"30"); xmlNewTextChild (cur, NULL, (const xmlChar *)"b4width", (const xmlChar *)"500"); xmlNewTextChild (cur, NULL, (const xmlChar *)"b4height", (const xmlChar *)"300"); xmlNewTextChild (cur, NULL, (const xmlChar *)"saveasadif", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"saveastsv2", (const xmlChar *)"1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"handlebarpos", (const xmlChar *)"300"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf1", (const xmlChar *)"cq de % % test"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf2", (const xmlChar *)"@ de %"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf3", (const xmlChar *)"@ ++5nn--#"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf4", (const xmlChar *)"tu 73"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf5", (const xmlChar *)"@"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf6", (const xmlChar *)"%"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf7", (const xmlChar *)"@ sri qso b4 gl"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf8", (const xmlChar *)"agn"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf9", (const xmlChar *)"?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf10", (const xmlChar *)"qrz?"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf11", (const xmlChar *)"pse k"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwf12", (const xmlChar *)"++++test---- % %"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwcq", (const xmlChar *)"tu %"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwsp", (const xmlChar *)"tu 5nn#"); xmlNewTextChild (cur, NULL, (const xmlChar *)"cwspeed", (const xmlChar *)"24"); xmlNewTextChild (cur, NULL, (const xmlChar *)"backupdir", (const xmlChar *)homedir); xmlNewTextChild (cur, NULL, (const xmlChar *)"backup", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"fcc", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"tsvcalc", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"viewscoring", (const xmlChar *)"1"); xmlNewTextChild (cur, NULL, (const xmlChar *)"scorex", (const xmlChar *)"10"); xmlNewTextChild (cur, NULL, (const xmlChar *)"scorey", (const xmlChar *)"300"); xmlNewTextChild (cur, NULL, (const xmlChar *)"scorewidth", (const xmlChar *)"500"); xmlNewTextChild (cur, NULL, (const xmlChar *)"scoreheight", (const xmlChar *)"300"); xmlNewTextChild (cur, NULL, (const xmlChar *)"scoringbands", (const xmlChar *)"01101111111000000000000000000"); xmlNewTextChild (cur, NULL, (const xmlChar *)"distqrb", (const xmlChar *)"0"); xmlNewTextChild (cur, NULL, (const xmlChar *)"awardswac", (const xmlChar *)"0"); g_free (homedir); } void loadpreferences (void) { gchar *preferencesfile; xmlDocPtr prefs; xmlNodePtr cur; gint result; FILE *fp; result = make_default_preferences (); /* open preferences file */ preferencesfile = g_strconcat (xlogdir, G_DIR_SEPARATOR_S, "preferences.xml", NULL); if (!(fp = fopen (preferencesfile, "r"))) { g_free (preferencesfile); return; } fclose (fp); prefs = xmlParseFile (preferencesfile); if (prefs != NULL) { cur = xmlDocGetRootElement (prefs); if (cur == NULL) { g_warning (_("empty preferences file")); xmlFreeDoc (prefs); return; } if (xmlStrcmp(cur->name, (const xmlChar *) "xlog")) { g_warning (_("document of the wrong type, root node is not xlog")); xmlFreeDoc (prefs); return; } cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *) "xlog_preferences"))) /* read preferences file */ parseloadpreferences (prefs, cur); cur = cur->next; } xmlFreeDoc (prefs); } g_free (preferencesfile); } void savepreferences (void) { gchar *preferencesfile; xmlDocPtr prefs; xmlNodePtr root, cur, node; gint result; /* save defaults first, so we can parse the file later */ prefs = xmlNewDoc ((const xmlChar *)"1.0"); cur = xmlNewDocRawNode (prefs, NULL, (const xmlChar *)"xlog", NULL); xmlDocSetRootElement (prefs, cur); node = xmlNewChild (cur, NULL, (const xmlChar *)"xlog_preferences", NULL); newsavepreferences (node); preferencesfile = g_strconcat (xlogdir, G_DIR_SEPARATOR_S, "preferences.xml", NULL); result = xmlSaveFormatFile (preferencesfile, prefs, 1); root = xmlDocGetRootElement (prefs); if (root == NULL) { g_warning (_("empty preferences file")); xmlFreeDoc (prefs); return; } if (xmlStrcmp(root->name, (const xmlChar *) "xlog")) { g_warning (_("document of the wrong type, root node is not xlog")); xmlFreeDoc (prefs); return; } root = xmlDocGetRootElement (prefs); cur = root->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"xlog_preferences"))) parsesavepreferences (cur); cur = cur->next; } result = xmlSaveFormatFile (preferencesfile, prefs, 1); xmlFreeDoc (prefs); g_free (preferencesfile); }