claws-mail/src/exporthtml.c
Paul Mangan 283412fa01 2005-09-21 [paul] 1.9.14cvs47
* README
	* README.jp
	* configure.ac
	* config/config.rpath
	* doc/manual/en/sylpheed-20.html
	* doc/manual/es/sylpheed-20.html
	* po/bg.po
	* po/ca.po
	* po/de.po
	* po/es.po
	* po/fr.po
	* po/it.po
	* po/pt_BR.po
	* po/sk.po
	* po/zh_TW.po
	* src/account.c
	* src/account.h
	* src/action.c
	* src/action.h
	* src/adbookbase.h
	* src/addr_compl.c
	* src/addr_compl.h
	* src/addrbook.c
	* src/addrbook.h
	* src/addrcache.c
	* src/addrcache.h
	* src/addrcindex.c
	* src/addrcindex.h
	* src/addrclip.c
	* src/addrclip.h
	* src/addrdefs.h
	* src/addressadd.c
	* src/addressadd.h
	* src/addressbook.c
	* src/addressbook.h
	* src/addressitem.h
	* src/addrgather.c
	* src/addrgather.h
	* src/addrharvest.c
	* src/addrharvest.h
	* src/addrindex.c
	* src/addrindex.h
	* src/addritem.c
	* src/addritem.h
	* src/addrquery.c
	* src/addrquery.h
	* src/addrselect.c
	* src/addrselect.h
	* src/alertpanel.c
	* src/alertpanel.h
	* src/browseldap.c
	* src/browseldap.h
	* src/codeconv.c
	* src/codeconv.h
	* src/compose.c
	* src/compose.h
	* src/crash.c
	* src/crash.h
	* src/customheader.c
	* src/customheader.h
	* src/displayheader.c
	* src/displayheader.h
	* src/editaddress.c
	* src/editaddress.h
	* src/editbook.c
	* src/editbook.h
	* src/editgroup.c
	* src/editgroup.h
	* src/editjpilot.c
	* src/editjpilot.h
	* src/editldap.c
	* src/editldap.h
	* src/editldap_basedn.c
	* src/editldap_basedn.h
	* src/editvcard.c
	* src/editvcard.h
	* src/enriched.c
	* src/enriched.h
	* src/exphtmldlg.c
	* src/exphtmldlg.h
	* src/expldifdlg.c
	* src/expldifdlg.h
	* src/export.c
	* src/export.h
	* src/exporthtml.c
	* src/exporthtml.h
	* src/exportldif.c
	* src/exportldif.h
	* src/filtering.c
	* src/filtering.h
	* src/folder.c
	* src/folder.h
	* src/folder_item_prefs.c
	* src/folder_item_prefs.h
	* src/foldersel.c
	* src/foldersel.h
	* src/folderutils.c
	* src/folderutils.h
	* src/folderview.c
	* src/folderview.h
	* src/grouplistdialog.c
	* src/grouplistdialog.h
	* src/headerview.c
	* src/headerview.h
	* src/html.c
	* src/html.h
	* src/image_viewer.c
	* src/image_viewer.h
	* src/imap.c
	* src/imap.h
	* src/imap_gtk.c
	* src/imap_gtk.h
	* src/import.c
	* src/import.h
	* src/importldif.c
	* src/importldif.h
	* src/importmutt.c
	* src/importmutt.h
	* src/importpine.c
	* src/importpine.h
	* src/inc.c
	* src/inc.h
	* src/jpilot.c
	* src/jpilot.h
	* src/ldapctrl.c
	* src/ldapctrl.h
	* src/ldaplocate.c
	* src/ldaplocate.h
	* src/ldapquery.c
	* src/ldapquery.h
	* src/ldapserver.c
	* src/ldapserver.h
	* src/ldaputil.c
	* src/ldaputil.h
	* src/ldif.c
	* src/ldif.h
	* src/localfolder.c
	* src/localfolder.h
	* src/main.c
	* src/main.h
	* src/mainwindow.c
	* src/mainwindow.h
	* src/manual.c
	* src/manual.h
	* src/matcher.c
	* src/matcher.h
	* src/matcher_parser.h
	* src/matcher_parser_lex.l
	* src/matcher_parser_parse.y
	* src/mbox.c
	* src/mbox.h
	* src/message_search.c
	* src/message_search.h
	* src/messageview.c
	* src/messageview.h
	* src/mh.c
	* src/mh.h
	* src/mh_gtk.c
	* src/mh_gtk.h
	* src/mimeview.c
	* src/mimeview.h
	* src/msgcache.c
	* src/msgcache.h
	* src/mutt.c
	* src/mutt.h
	* src/news.c
	* src/news.h
	* src/news_gtk.c
	* src/news_gtk.h
	* src/noticeview.c
	* src/noticeview.h
	* src/partial_download.c
	* src/partial_download.h
	* src/pine.c
	* src/pine.h
	* src/pop.c
	* src/pop.h
	* src/prefs_account.c
	* src/prefs_account.h
	* src/prefs_actions.c
	* src/prefs_actions.h
	* src/prefs_common.c
	* src/prefs_common.h
	* src/prefs_compose_writing.c
	* src/prefs_compose_writing.h
	* src/prefs_customheader.c
	* src/prefs_customheader.h
	* src/prefs_display_header.c
	* src/prefs_display_header.h
	* src/prefs_ext_prog.c
	* src/prefs_ext_prog.h
	* src/prefs_filtering.c
	* src/prefs_filtering.h
	* src/prefs_filtering_action.c
	* src/prefs_filtering_action.h
	* src/prefs_folder_column.c
	* src/prefs_folder_column.h
	* src/prefs_folder_item.c
	* src/prefs_folder_item.h
	* src/prefs_fonts.c
	* src/prefs_fonts.h
	* src/prefs_gtk.c
	* src/prefs_gtk.h
	* src/prefs_image_viewer.c
	* src/prefs_image_viewer.h
	* src/prefs_matcher.c
	* src/prefs_matcher.h
	* src/prefs_message.c
	* src/prefs_message.h
	* src/prefs_msg_colors.c
	* src/prefs_msg_colors.h
	* src/prefs_other.c
	* src/prefs_other.h
	* src/prefs_quote.c
	* src/prefs_quote.h
	* src/prefs_receive.c
	* src/prefs_receive.h
	* src/prefs_send.c
	* src/prefs_send.h
	* src/prefs_spelling.c
	* src/prefs_spelling.h
	* src/prefs_summaries.c
	* src/prefs_summaries.h
	* src/prefs_summary_column.c
	* src/prefs_summary_column.h
	* src/prefs_template.c
	* src/prefs_template.h
	* src/prefs_themes.c
	* src/prefs_themes.h
	* src/prefs_toolbar.c
	* src/prefs_toolbar.h
	* src/prefs_wrapping.c
	* src/prefs_wrapping.h
	* src/privacy.c
	* src/privacy.h
	* src/procheader.c
	* src/procheader.h
	* src/procmime.c
	* src/procmime.h
	* src/procmsg.c
	* src/procmsg.h
	* src/quote_fmt.c
	* src/quote_fmt_parse.y
	* src/recv.c
	* src/recv.h
	* src/remotefolder.c
	* src/remotefolder.h
	* src/send_message.c
	* src/send_message.h
	* src/setup.c
	* src/setup.h
	* src/simple-gettext.c
	* src/sourcewindow.c
	* src/sourcewindow.h
	* src/ssl_manager.c
	* src/ssl_manager.h
	* src/statusbar.c
	* src/statusbar.h
	* src/stock_pixmap.c
	* src/stock_pixmap.h
	* src/summary_search.c
	* src/summary_search.h
	* src/summaryview.c
	* src/summaryview.h
	* src/syldap.c
	* src/syldap.h
	* src/textview.c
	* src/textview.h
	* src/toolbar.c
	* src/toolbar.h
	* src/undo.c
	* src/undo.h
	* src/unmime.c
	* src/unmime.h
	* src/vcard.c
	* src/vcard.h
	* src/wizard.c
	* src/wizard.h
	* src/common/base64.c
	* src/common/base64.h
	* src/common/defs.h
	* src/common/hooks.c
	* src/common/hooks.h
	* src/common/log.c
	* src/common/log.h
	* src/common/md5.c
	* src/common/md5.h
	* src/common/mgutils.c
	* src/common/mgutils.h
	* src/common/nntp.c
	* src/common/nntp.h
	* src/common/passcrypt.c
	* src/common/passcrypt.h.in
	* src/common/plugin.c
	* src/common/plugin.h
	* src/common/prefs.c
	* src/common/prefs.h
	* src/common/progressindicator.c
	* src/common/progressindicator.h
	* src/common/quoted-printable.c
	* src/common/quoted-printable.h
	* src/common/session.c
	* src/common/session.h
	* src/common/smtp.c
	* src/common/smtp.h
	* src/common/socket.c
	* src/common/socket.h
	* src/common/ssl.c
	* src/common/ssl.h
	* src/common/ssl_certificate.c
	* src/common/ssl_certificate.h
	* src/common/string_match.c
	* src/common/string_match.h
	* src/common/stringtable.c
	* src/common/sylpheed.c
	* src/common/sylpheed.h
	* src/common/template.c
	* src/common/template.h
	* src/common/timing.h
	* src/common/utils.c
	* src/common/utils.h
	* src/common/uuencode.c
	* src/common/uuencode.h
	* src/common/version.h.in
	* src/common/xml.c
	* src/common/xml.h
	* src/common/xmlprops.c
	* src/common/xmlprops.h
	* src/gtk/about.c
	* src/gtk/about.h
	* src/gtk/colorlabel.c
	* src/gtk/colorlabel.h
	* src/gtk/colorsel.c
	* src/gtk/colorsel.h
	* src/gtk/description_window.c
	* src/gtk/description_window.h
	* src/gtk/filesel.c
	* src/gtk/filesel.h
	* src/gtk/foldersort.c
	* src/gtk/foldersort.h
	* src/gtk/gtkutils.c
	* src/gtk/gtkutils.h
	* src/gtk/inputdialog.c
	* src/gtk/inputdialog.h
	* src/gtk/logwindow.c
	* src/gtk/logwindow.h
	* src/gtk/manage_window.c
	* src/gtk/manage_window.h
	* src/gtk/menu.c
	* src/gtk/menu.h
	* src/gtk/pluginwindow.c
	* src/gtk/pluginwindow.h
	* src/gtk/prefswindow.c
	* src/gtk/prefswindow.h
	* src/gtk/progressdialog.c
	* src/gtk/progressdialog.h
	* src/gtk/quicksearch.c
	* src/gtk/quicksearch.h
	* src/gtk/sslcertwindow.c
	* src/gtk/sslcertwindow.h
	* src/plugins/clamav/clamav_plugin.c
	* src/plugins/clamav/clamav_plugin.h
	* src/plugins/clamav/clamav_plugin_gtk.c
	* src/plugins/demo/demo.c
	* src/plugins/dillo_viewer/dillo_prefs.c
	* src/plugins/dillo_viewer/dillo_prefs.h
	* src/plugins/dillo_viewer/dillo_viewer.c
	* src/plugins/mathml_viewer/mathml_viewer.c
	* src/plugins/pgpcore/passphrase.c
	* src/plugins/pgpcore/passphrase.h
	* src/plugins/pgpcore/plugin.c
	* src/plugins/pgpcore/prefs_gpg.c
	* src/plugins/pgpcore/prefs_gpg.h
	* src/plugins/pgpcore/select-keys.c
	* src/plugins/pgpcore/select-keys.h
	* src/plugins/pgpcore/sgpgme.c
	* src/plugins/pgpcore/sgpgme.h
	* src/plugins/pgpinline/pgpinline.c
	* src/plugins/pgpinline/pgpinline.h
	* src/plugins/pgpinline/plugin.c
	* src/plugins/pgpmime/pgpmime.c
	* src/plugins/pgpmime/pgpmime.h
	* src/plugins/pgpmime/plugin.c
	* src/plugins/spamassassin/spamassassin.c
	* src/plugins/spamassassin/spamassassin.h
	* src/plugins/spamassassin/spamassassin_gtk.c
	* src/plugins/trayicon/trayicon.c
	* tools/OOo2sylpheed.pl
	* tools/acroread2sylpheed.pl
	* tools/asus_mailled.sh
	* tools/filter_conv.pl
	* tools/freshmeat_search.pl
	* tools/google_search.pl
	* tools/kmail2sylpheed.pl
	* tools/kmail2sylpheed_v2.pl
	* tools/maildir2sylpheed.pl
	* tools/multiwebsearch.pl
	* tools/newscache_clean.pl
	* tools/outlook2sylpheed.pl
	* tools/sylpheed-switcher
	* tools/update-po
	* tools/vcard2xml.py
	* tools/kdeservicemenu/sylpheed-kdeservicemenu.pl
		update FSF address
2005-09-21 18:22:51 +00:00

1227 lines
32 KiB
C

/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
* Copyright (C) 2002 Match Grun
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* Export address book to HTML file.
*/
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n.h>
#include "mgutils.h"
#include "utils.h"
#include "exporthtml.h"
#include "xmlprops.h"
#define DFL_DIR_SYLPHEED_OUT "sylpheed-out"
#define DFL_FILE_SYLPHEED_OUT "addressbook.html"
#define FMT_BUFSIZE 2048
#define HTML_SPACE "&nbsp;"
#define BORDER_SIZE 2
#define CELL_PADDING 2
#define CELL_SPACING 2
#define CHAR_ENCODING "ISO-8859-1"
/* Stylesheet names */
#define FILENAME_NONE ""
#define FILENAME_DEFAULT "sylpheed.css"
#define FILENAME_FULL "full.css"
#define FILENAME_CUSTOM "custom.css"
#define FILENAME_CUSTOM2 "custom2.css"
#define FILENAME_CUSTOM3 "custom3.css"
#define FILENAME_CUSTOM4 "custom4.css"
/* Settings - properties */
#define EXML_PROPFILE_NAME "exporthtml.xml"
#define EXMLPROP_DIRECTORY "directory"
#define EXMLPROP_FILE "file"
#define EXMLPROP_STYLESHEET "stylesheet"
#define EXMLPROP_FMT_NAME "format-full-name"
#define EXMLPROP_FMT_EMAIL "format-email-links"
#define EXMLPROP_FMT_ATTRIB "format-attributes"
#define EXMLPROP_BANDING "color-banding"
#define EXMLPROP_VALUE_YES "y"
#define EXMLPROP_VALUE_NO "n"
static gchar *_idTagRowEven_ = "tab-row0";
static gchar *_idTagRowOdd_ = "tab-row1";
/*
* Header entry.
*/
typedef struct _StylesheetEntry StylesheetEntry;
struct _StylesheetEntry {
gchar *fileName;
gint id;
gboolean dflValue;
};
/*
* Build stylesheet entry.
* Enter: ctl Export control data.
* file Filename.
* id File id.
* dfl Default flag.
*/
static void exporthtml_build_entry(
ExportHtmlCtl *ctl, const gchar *file, const gint id,
const gboolean dfl )
{
StylesheetEntry *entry;
entry = g_new0( StylesheetEntry, 1 );
entry->fileName = g_strdup( file );
entry->id = id;
entry->dflValue = dfl;
ctl->listStyle = g_list_append( ctl->listStyle, entry );
}
/*
* Free up object by releasing internal memory.
* Enter: ctl Export control data.
*/
ExportHtmlCtl *exporthtml_create( void ) {
ExportHtmlCtl *ctl = g_new0( ExportHtmlCtl, 1 );
ctl->path = NULL;
ctl->dirOutput = NULL;
ctl->fileHtml = NULL;
ctl->encoding = NULL;
ctl->stylesheet = EXPORT_HTML_ID_NONE;
ctl->nameFormat = EXPORT_HTML_FIRST_LAST;
ctl->banding = FALSE;
ctl->linkEMail = FALSE;
ctl->showAttribs = FALSE;
ctl->retVal = MGU_SUCCESS;
ctl->listStyle = NULL;
ctl->rcCreate = 0;
ctl->settingsFile = g_strconcat(
get_rc_dir(), G_DIR_SEPARATOR_S, EXML_PROPFILE_NAME, NULL );
/* Build stylesheet list */
exporthtml_build_entry(
ctl, FILENAME_NONE, EXPORT_HTML_ID_NONE, FALSE );
exporthtml_build_entry(
ctl, FILENAME_DEFAULT, EXPORT_HTML_ID_DEFAULT, TRUE );
exporthtml_build_entry(
ctl, FILENAME_FULL, EXPORT_HTML_ID_FULL, FALSE );
exporthtml_build_entry(
ctl, FILENAME_CUSTOM, EXPORT_HTML_ID_CUSTOM, FALSE );
exporthtml_build_entry(
ctl, FILENAME_CUSTOM2, EXPORT_HTML_ID_CUSTOM2, FALSE );
exporthtml_build_entry(
ctl, FILENAME_CUSTOM3, EXPORT_HTML_ID_CUSTOM3, FALSE );
exporthtml_build_entry(
ctl, FILENAME_CUSTOM4, EXPORT_HTML_ID_CUSTOM4, FALSE );
return ctl;
}
/*
* Free up object by releasing internal memory.
* Enter: ctl Export control data.
*/
void exporthtml_free( ExportHtmlCtl *ctl ) {
GList *node;
StylesheetEntry *entry;
g_return_if_fail( ctl != NULL );
/* Free stylesheet list */
node = ctl->listStyle;
while( node ) {
entry = ( StylesheetEntry * ) node->data;
g_free( entry->fileName );
entry->fileName = NULL;
entry->id = 0;
entry->dflValue = FALSE;
g_free( entry );
node->data = NULL;
node = g_list_next( node );
}
g_list_free( ctl->listStyle );
ctl->listStyle = NULL;
g_free( ctl->path );
g_free( ctl->fileHtml );
g_free( ctl->encoding );
g_free( ctl->dirOutput );
g_free( ctl->settingsFile );
/* Clear pointers */
ctl->path = NULL;
ctl->dirOutput = NULL;
ctl->fileHtml = NULL;
ctl->encoding = NULL;
ctl->stylesheet = EXPORT_HTML_ID_NONE;
ctl->nameFormat = EXPORT_HTML_FIRST_LAST;
ctl->banding = FALSE;
ctl->linkEMail = FALSE;
ctl->showAttribs = FALSE;
ctl->retVal = MGU_SUCCESS;
ctl->rcCreate = 0;
/* Now release object */
g_free( ctl );
}
/*
* Print control object.
* Enter: ctl Export control data.
* stream Output stream.
*/
void exporthtml_print( ExportHtmlCtl *ctl, FILE *stream ) {
fprintf( stream, "ExportHtmlCtl:\n" );
fprintf( stream, " path: %s\n", ctl->path );
fprintf( stream, "directory: %s\n", ctl->dirOutput );
fprintf( stream, " file: %s\n", ctl->fileHtml );
fprintf( stream, " settings: %s\n", ctl->settingsFile );
fprintf( stream, " encoding: %s\n", ctl->encoding );
fprintf( stream, " css file: %d\n", ctl->stylesheet );
fprintf( stream, " name fmt: %d\n", ctl->nameFormat );
fprintf( stream, " banding: %d\n", ctl->banding );
fprintf( stream, "link mail: %d\n", ctl->linkEMail );
fprintf( stream, "show attr: %d\n", ctl->showAttribs );
}
/*
* Find style entry.
* Enter: ctl Export control data.
* Return: Stylesheet object, or NULL if nothing found. If a default entry is
* found in list, it will be returned.
*/
static StylesheetEntry *exporthtml_find_stylesheet( ExportHtmlCtl *ctl ) {
StylesheetEntry *retVal = NULL;
StylesheetEntry *entry;
GList *node;
node = ctl->listStyle;
while( node ) {
entry = ( StylesheetEntry * ) node->data;
if( entry->id == ctl->stylesheet ) return entry;
if( entry->dflValue ) retVal = entry;
node = g_list_next( node );
}
return retVal;
}
/*
* Properties...
*/
/*
* Specify path to folder where files are created.
* Enter: ctl Export control data.
* value Full directory path.
*/
void exporthtml_set_output_dir( ExportHtmlCtl *ctl, const gchar *value ) {
g_return_if_fail( ctl != NULL );
ctl->dirOutput = mgu_replace_string( ctl->dirOutput, value );
g_strstrip( ctl->dirOutput );
}
void exporthtml_set_path( ExportHtmlCtl *ctl, const gchar *value ) {
g_return_if_fail( ctl != NULL );
ctl->path = mgu_replace_string( ctl->path, value );
g_strstrip( ctl->path );
}
void exporthtml_set_file_html( ExportHtmlCtl *ctl, const gchar *value ) {
g_return_if_fail( ctl != NULL );
ctl->fileHtml = mgu_replace_string( ctl->fileHtml, value );
g_strstrip( ctl->fileHtml );
}
void exporthtml_set_encoding( ExportHtmlCtl *ctl, const gchar *value ) {
g_return_if_fail( ctl != NULL );
ctl->encoding = mgu_replace_string( ctl->encoding, value );
g_strstrip( ctl->encoding );
}
void exporthtml_set_stylesheet( ExportHtmlCtl *ctl, const gint value ) {
g_return_if_fail( ctl != NULL );
ctl->stylesheet = value;
}
void exporthtml_set_name_format( ExportHtmlCtl *ctl, const gint value ) {
g_return_if_fail( ctl != NULL );
ctl->nameFormat = value;
}
void exporthtml_set_banding( ExportHtmlCtl *ctl, const gboolean value ) {
g_return_if_fail( ctl != NULL );
ctl->banding = value;
}
void exporthtml_set_link_email( ExportHtmlCtl *ctl, const gboolean value ) {
g_return_if_fail( ctl != NULL );
ctl->linkEMail = value;
}
void exporthtml_set_attributes( ExportHtmlCtl *ctl, const gboolean value ) {
g_return_if_fail( ctl != NULL );
ctl->showAttribs = value;
}
/*
* Create default CSS file.
* Enter: fileSpec File to create.
* Return: Status code.
*/
static gint exporthtml_create_css_dfl( const gchar *fileSpec ) {
FILE *cssFile;
cssFile = g_fopen( fileSpec, "rb" );
if( cssFile ) {
fclose( cssFile );
return MGU_SUCCESS;
}
cssFile = g_fopen( fileSpec, "wb" );
if( ! cssFile ) {
return MGU_OPEN_FILE;
}
fprintf( cssFile, "body {\n\tbackground: #ffffe0;\n" );
fprintf( cssFile, "\tfont-family: lucida, helvetica, sans-serif;\n" );
fprintf( cssFile, "\tfont-size: 10pt;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, "h1 {\n" );
fprintf( cssFile, "\tcolor: #000000;\n" );
fprintf( cssFile, "\ttext-align: center;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, "th {\n" );
fprintf( cssFile, "\tfont-size: 10pt;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, "td {\n" );
fprintf( cssFile, "\tfont-size: 10pt;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".fmt-folder {\n" );
fprintf( cssFile, "\tcolor: #0000ff;\n" );
fprintf( cssFile, "\tfont-size: 18pt;\n" );
fprintf( cssFile, "\tfont-weight: bold;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-head {\n" );
fprintf( cssFile, "\tbackground: #80c0f0;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-dn {\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-addr {\n" );
fprintf( cssFile, "\tfont-style: italic;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-email {\n" );
fprintf( cssFile, "\tfont-weight: bold;\n" );
fprintf( cssFile, "\tfont-style: italic;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-fn {\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-attr {\n" );
fprintf( cssFile, "}\n" );
fclose( cssFile );
return MGU_SUCCESS;
}
/*
* Create full CSS file.
* Enter: fileSpec File to create.
* Return: Status code.
*/
static gint exporthtml_create_css_full( const gchar *fileSpec ) {
FILE *cssFile;
cssFile = g_fopen( fileSpec, "rb" );
if( cssFile ) {
fclose( cssFile );
return MGU_SUCCESS;
}
cssFile = g_fopen( fileSpec, "wb" );
if( ! cssFile ) {
return MGU_OPEN_FILE;
}
fprintf( cssFile, "body {\n\tbackground: #ffffe0;\n" );
fprintf( cssFile, "\tfont-family: lucida, helvetica, sans-serif;\n" );
fprintf( cssFile, "\tfont-size: 10pt;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, "h1 {\n" );
fprintf( cssFile, "\tcolor: #000000;\n" );
fprintf( cssFile, "\ttext-align: center;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, "th {\n" );
fprintf( cssFile, "\tfont-size: 10pt;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, "td {\n" );
fprintf( cssFile, "\tfont-size: 10pt;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".fmt-folder {\n" );
fprintf( cssFile, "\tcolor: #0000ff;\n" );
fprintf( cssFile, "\tfont-size: 18pt;\n" );
fprintf( cssFile, "\tfont-weight: bold;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-head {\n" );
fprintf( cssFile, "\tbackground: #80c0f0;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-row0 {\n" );
fprintf( cssFile, "\tbackground: #f0f0f0;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-row1 {\n" );
fprintf( cssFile, "\tbackground: #d0d0d0;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-dn {\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-addr {\n" );
fprintf( cssFile, "\tfont-style: italic;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-email {\n" );
fprintf( cssFile, "\tfont-weight: bold;\n" );
fprintf( cssFile, "\tfont-style: italic;\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-fn {\n" );
fprintf( cssFile, "}\n" );
fprintf( cssFile, ".tab-attr {\n" );
fprintf( cssFile, "}\n" );
fclose( cssFile );
return MGU_SUCCESS;
}
/*
* Create stylesheet files.
* Enter: ctl Export control data.
*/
static void exporthtml_create_css_files( ExportHtmlCtl *ctl ) {
gchar *fileSpec;
GList *node;
node = ctl->listStyle;
while( node ) {
StylesheetEntry *entry = node->data;
node = g_list_next( node );
if( strlen( entry->fileName ) ) {
fileSpec = g_strconcat(
ctl->dirOutput, G_DIR_SEPARATOR_S,
entry->fileName, NULL );
if( entry->id == EXPORT_HTML_ID_DEFAULT ) {
exporthtml_create_css_dfl( fileSpec );
}
else if( entry->id != EXPORT_HTML_ID_NONE ) {
exporthtml_create_css_full( fileSpec );
}
g_free( fileSpec );
}
}
}
/*
* Comparison using linked list elements.
*/
static gint exporthtml_compare_name(
gconstpointer ptr1, gconstpointer ptr2 )
{
const AddrItemObject *item1 = ptr1;
const AddrItemObject *item2 = ptr2;
const gchar *name1 = NULL, *name2 = NULL;
if( item1 ) name1 = ADDRITEM_NAME( item1 );
if( item2 ) name2 = ADDRITEM_NAME( item2 );
if( ! name1 ) return ( name2 != NULL );
if( ! name2 ) return -1;
return g_utf8_collate( name1, name2 );
}
/*
* Comparison using linked list elements.
*/
static gint exporthtml_compare_email(
gconstpointer ptr1, gconstpointer ptr2 )
{
const ItemEMail *email1 = ptr1;
const ItemEMail *email2 = ptr2;
const gchar *name1 = NULL, *name2 = NULL;
if( email1 ) name1 = email1->address;
if( email2 ) name2 = email2->address;
if( ! name1 ) return ( name2 != NULL );
if( ! name2 ) return -1;
return g_utf8_collate( name1, name2 );
}
/*
* Comparison using linked list elements.
*/
static gint exporthtml_compare_attrib(
gconstpointer ptr1, gconstpointer ptr2 )
{
const UserAttribute *attr1 = ptr1;
const UserAttribute *attr2 = ptr2;
const gchar *name1 = NULL, *name2 = NULL;
if( attr1 ) name1 = attr1->name;
if( attr2 ) name2 = attr2->name;
if( ! name1 ) return ( name2 != NULL );
if( ! name2 ) return -1;
return g_utf8_collate( name1, name2 );
}
/*
* Build sorted list of named items.
* Enter: list List of items to sorted.
* Return: Sorted list.
* Note: List should freed after use. Items referenced by list should not be
* freed since they are managed by the address cache.
*/
static GList *exporthtml_sort_name( const GList *list ) {
const GList *node;
GList *sorted = NULL;
node = list;
while( node ) {
sorted = g_list_insert_sorted(
sorted, node->data, exporthtml_compare_name );
node = g_list_next( node );
}
return sorted;
}
/*
* Build sorted list of email items.
* Enter: list List of E-Mail items to sorted.
* Return: Sorted list.
* Note: List should freed after use. Items referenced by list should not be
* freed since they are managed by the address cache.
*/
static GList *exporthtml_sort_email( const GList *list ) {
const GList *node;
GList *sorted = NULL;
node = list;
while( node ) {
sorted = g_list_insert_sorted(
sorted, node->data, exporthtml_compare_email );
node = g_list_next( node );
}
return sorted;
}
/*
* Build sorted list of attributes.
* Enter: list List of items to sorted.
* Return: Sorted list.
* Note: List should freed after use. Items referenced by list should not be
* freed since they are managed by the address cache.
*/
static GList *exporthtml_sort_attrib( const GList *list ) {
const GList *node;
GList *sorted = NULL;
sorted = NULL;
node = list;
while( node ) {
sorted = g_list_insert_sorted(
sorted, node->data, exporthtml_compare_attrib );
node = g_list_next( node );
}
return sorted;
}
/*
* Format a list of E-Mail addresses.
* Enter: ctl Export control data.
* stream Output stream.
* listEMail List of addresses.
* sortFlag Set to TRUE if address list should be sorted.
*/
static void exporthtml_fmt_email(
ExportHtmlCtl *ctl, FILE *stream, const GList *listEMail,
gboolean sortFlag )
{
const GList *node;
GList *list;
gchar *name;
if( listEMail == NULL ) {
fprintf( stream, HTML_SPACE );
return;
}
list = NULL;
if( sortFlag ) {
node = list = exporthtml_sort_email( listEMail );
}
else {
node = listEMail;
}
while( node ) {
ItemEMail *email = ( ItemEMail * ) node->data;
node = g_list_next( node );
name = ADDRITEM_NAME( email );
if( name ) {
fprintf( stream, "%s ", name );
}
if( ctl->linkEMail ) {
fprintf( stream, "<a href=\"mailto:%s\">",
email->address );
}
fprintf( stream, "<span class=\"tab-email\">" );
fprintf( stream, "%s", email->address );
fprintf( stream, "</span>" );
if( ctl->linkEMail ) {
fprintf( stream, "</a>" );
}
if( email->remarks ) {
if( strlen( email->remarks ) ) {
fprintf( stream, " (%s)", email->remarks );
}
}
fprintf( stream, "<br>\n" );
}
g_list_free( list );
}
/*
* Format groups in an address book folder.
* Enter: ctl Export control data.
* stream Output stream.
* folder Folder.
* prevFlag If FALSE, list of persons were output.
* Return: TRUE if no groups were formatted.
*/
static gboolean exporthtml_fmt_group(
ExportHtmlCtl *ctl, FILE *stream, const ItemFolder *folder,
gboolean prevFlag )
{
gboolean retVal, band;
GList *node, *list;
const gchar *tagName;
retVal = TRUE;
if( folder->listGroup == NULL ) return retVal;
/* Write separator */
if( ! prevFlag ) {
fprintf( stream, "<br>\n" );
}
/* Write table headers */
fprintf( stream, "<table" );
fprintf( stream, " border=\"%d\"", BORDER_SIZE );
fprintf( stream, " cellpadding=\"%d\"", CELL_PADDING );
fprintf( stream, " cellspacing=\"%d\"", CELL_SPACING );
fprintf( stream, ">\n" );
fprintf( stream, "<tr class=\"tab-head\">\n" );
fprintf( stream, " <th width=\"200\">" );
fprintf( stream, "%s", _( "Group Name" ) );
fprintf( stream, "</th>\n" );
fprintf( stream, " <th width=\"300\">" );
fprintf( stream, "%s", _( "E-Mail Address" ) );
fprintf( stream, "</th>\n" );
fprintf( stream, "</tr>\n" );
list = exporthtml_sort_name( folder->listGroup );
band = FALSE;
node = list;
while( node ) {
AddrItemObject *aio = node->data;
if( aio && aio->type == ITEMTYPE_GROUP ) {
ItemGroup *group = ( ItemGroup * ) aio;
fprintf( stream, "<tr valign=\"top\"" );
if( ctl->banding ) {
if( band ) {
tagName = _idTagRowOdd_;
}
else {
tagName = _idTagRowEven_;
}
fprintf( stream, " class=\"%s\"", tagName );
band = ! band;
}
fprintf( stream, "\">\n" );
fprintf( stream, " <td class=\"tab-dn\">" );
fprintf( stream, "%s", ADDRITEM_NAME( group ) );
fprintf( stream, "</td>\n" );
fprintf( stream, " <td class=\"tab-addr\">" );
exporthtml_fmt_email( ctl, stream, group->listEMail, TRUE );
fprintf( stream, "</td>\n" );
fprintf( stream, "</tr>\n" );
retVal = FALSE;
}
node = g_list_next( node );
}
g_list_free( list );
fprintf( stream, "</table>\n" );
return retVal;
}
/*
* Format a list of E-Mail addresses.
* Enter: ctl Export control data.
* stream Output stream.
* listAttr List of attributes.
*/
static void exporthtml_fmt_attribs(
ExportHtmlCtl *ctl, FILE *stream, const GList *listAttr )
{
const GList *node;
GList *list;
if( listAttr == NULL ) {
fprintf( stream, HTML_SPACE );
return;
}
fprintf( stream, "<table border=\"0\">\n" );
node = list = exporthtml_sort_attrib( listAttr );
while( node ) {
UserAttribute *attr = ( UserAttribute * ) node->data;
node = g_list_next( node );
fprintf( stream, "<tr valign=\"top\">" );
fprintf( stream, "<td align=\"right\">%s:</td>", attr->name );
fprintf( stream, "<td>%s</td>", attr->value );
fprintf( stream, "</tr>\n" );
}
g_list_free( list );
fprintf( stream, "</table>" );
}
/*
* Format full name.
* Enter: ctl Export control data.
* buf Output buffer.
* person Person to format.
*/
static void exporthtml_fmt_fullname(
ExportHtmlCtl *ctl, gchar *buf, const ItemPerson *person )
{
gboolean flag;
if( ctl->nameFormat == EXPORT_HTML_LAST_FIRST ) {
flag = FALSE;
if( person->lastName ) {
if( *person->lastName ) {
strcat( buf, " " );
strcat( buf, person->lastName );
flag = TRUE;
}
}
if( person->firstName ) {
if( *person->firstName ) {
if( flag ) {
strcat( buf, ", " );
}
strcat( buf, person->firstName );
}
}
}
else {
if( person->firstName ) {
if( *person->firstName ) {
strcat( buf, person->firstName );
}
}
if( person->lastName ) {
if( *person->lastName ) {
strcat( buf, " " );
strcat( buf, person->lastName );
}
}
}
g_strstrip( buf );
flag = FALSE;
if( *buf ) flag = TRUE;
if( person->nickName ) {
if( strlen( person->nickName ) ) {
if( flag ) {
strcat( buf, " (" );
}
strcat( buf, person->nickName );
if( flag ) {
strcat( buf, ")" );
}
}
}
g_strstrip( buf );
}
/*
* Format persons in an address book folder.
* Enter: ctl Export control data.
* stream Output stream.
* folder Folder.
* Return: TRUE if no persons were formatted.
*/
static gboolean exporthtml_fmt_person(
ExportHtmlCtl *ctl, FILE *stream, const ItemFolder *folder )
{
gboolean retVal, band;
GList *node, *list;
gchar buf[ FMT_BUFSIZE ];
const gchar *tagName;
retVal = TRUE;
if( folder->listPerson == NULL ) return retVal;
/* Write table headers */
fprintf( stream, "<table" );
fprintf( stream, " border=\"%d\"", BORDER_SIZE );
fprintf( stream, " cellpadding=\"%d\"", CELL_PADDING );
fprintf( stream, " cellspacing=\"%d\"", CELL_SPACING );
fprintf( stream, ">\n" );
fprintf( stream, "<tr class=\"tab-head\">\n" );
fprintf( stream, " <th width=\"200\">" );
fprintf( stream, "%s", _( "Display Name" ) );
fprintf( stream, "</th>\n" );
fprintf( stream, " <th width=\"300\">" );
fprintf( stream, "%s", _( "E-Mail Address" ) );
fprintf( stream, "</th>\n" );
fprintf( stream, " <th width=\"200\">" );
fprintf( stream, "%s", _( "Full Name" ) );
fprintf( stream, "</th>\n" );
if( ctl->showAttribs ) {
fprintf( stream, " <th width=\"250\">" );
fprintf( stream, "%s", _( "Attributes" ) );
fprintf( stream, "</th>\n" );
}
fprintf( stream, "</tr>\n" );
band = FALSE;
node = list = exporthtml_sort_name( folder->listPerson );
while( node ) {
AddrItemObject *aio = node->data;
if( aio && aio->type == ITEMTYPE_PERSON ) {
ItemPerson *person = ( ItemPerson * ) aio;
/* Format first/last/nick name */
*buf = '\0';
exporthtml_fmt_fullname( ctl, buf,person );
fprintf( stream, "<tr valign=\"top\"" );
if( ctl->banding ) {
if( band ) {
tagName = _idTagRowOdd_;
}
else {
tagName = _idTagRowEven_;
}
fprintf( stream, " class=\"%s\"", tagName );
band = ! band;
}
fprintf( stream, ">\n" );
fprintf( stream, " <td class=\"tab-dn\">" );
fprintf( stream, "%s", ADDRITEM_NAME( person ) );
fprintf( stream, "</td>\n" );
fprintf( stream, " <td class=\"tab-addr\">" );
exporthtml_fmt_email( ctl, stream, person->listEMail, FALSE );
fprintf( stream, "</td>\n" );
fprintf( stream, " <td class=\"tab-fn\">" );
if( *buf ) {
fprintf( stream, "%s", buf );
}
else {
fprintf( stream, "%s", HTML_SPACE );
}
fprintf( stream, "</td>\n" );
if( ctl->showAttribs ) {
fprintf( stream, " <td class=\"tab-attr\">" );
exporthtml_fmt_attribs(
ctl, stream, person->listAttrib );
fprintf( stream, "</td>\n" );
}
fprintf( stream, "</tr>\n" );
retVal = FALSE;
}
node = g_list_next( node );
}
g_list_free( list );
fprintf( stream, "</table>\n" );
return retVal;
}
/*
* Format folder heirarchy.
* Enter: stream Output stream.
* list Heirarchy list.
*/
static void exporthtml_fmt_folderhead( FILE *stream, const GList *list ) {
const GList *node;
gboolean flag;
gchar *name;
flag = FALSE;
node = list;
while( node ) {
AddrItemObject *aio = node->data;
if( aio && aio->type == ITEMTYPE_FOLDER ) {
ItemFolder *folder = ( ItemFolder * ) aio;
name = ADDRITEM_NAME( folder );
if( name ) {
if( flag ) {
fprintf( stream, "&nbsp;&gt;&nbsp;" );
}
fprintf( stream, "%s", name );
flag = TRUE;
}
}
node = g_list_next( node );
}
}
/*
* Format an address book folder.
* Enter: ctl Export control data.
* stream Output stream.
* folder Folder.
*/
static void exporthtml_fmt_folder(
ExportHtmlCtl *ctl, FILE *stream, const ItemFolder *folder )
{
const GList *node;
GList *listHeir, *list;
const gchar *name;
gboolean ret1, ret2;
name = ADDRITEM_NAME( folder );
if( name ) {
listHeir = addritem_folder_path( folder, TRUE );
if( listHeir ) {
fprintf( stream, "<p class=\"fmt-folder\">" );
fprintf( stream, "%s: ", _( "Folder" ) );
exporthtml_fmt_folderhead( stream, listHeir );
fprintf( stream, "</p>\n" );
g_list_free( listHeir );
}
}
ret1 = exporthtml_fmt_person( ctl, stream, folder );
ret2 = exporthtml_fmt_group( ctl, stream, folder, ret1 );
node = list = exporthtml_sort_name( folder->listFolder );
while( node ) {
AddrItemObject *aio = node->data;
if( aio && aio->type == ITEMTYPE_FOLDER ) {
ItemFolder *subFolder = ( ItemFolder * ) aio;
exporthtml_fmt_folder( ctl, stream, subFolder );
}
node = g_list_next( node );
}
if( list ) {
g_list_free( list );
}
}
/*
* Format header block.
* Enter: ctl Export control data.
* stream Output stream.
* title Page title.
*/
static void exporthtml_fmt_header(
ExportHtmlCtl *ctl, FILE *stream, gchar *title )
{
StylesheetEntry *entry;
entry = exporthtml_find_stylesheet( ctl );
fprintf( stream,
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n" );
fprintf( stream, "<html>\n" );
fprintf( stream, "<head>\n" );
if( ctl->encoding && strlen( ctl->encoding ) > 0 ) {
fprintf( stream, "<meta " );
fprintf( stream, "http-equiv=\"Content-Type\" " );
fprintf( stream, "content=\"text/html; charset=%s\">\n",
ctl->encoding );
}
fprintf( stream, "<title>%s</title>\n", title );
if( entry != NULL ) {
if( entry->fileName && strlen( entry->fileName ) > 0 ) {
fprintf( stream, "<link " );
fprintf( stream, "rel=\"stylesheet\" " );
fprintf( stream, "type=\"text/css\" " );
fprintf( stream, "href=\"%s\" >\n", entry->fileName );
}
}
fprintf( stream, "<body>\n" );
fprintf( stream, "</head>\n" );
}
/*
* ============================================================================
* Export address book to HTML file.
* Enter: ctl Export control data.
* cache Address book/data source cache.
* Return: Status.
* ============================================================================
*/
void exporthtml_process(
ExportHtmlCtl *ctl, AddressCache *cache )
{
ItemFolder *rootFolder;
FILE *htmlFile;
time_t tt;
gchar *dsName;
static gchar *title;
htmlFile = g_fopen( ctl->path, "wb" );
if( ! htmlFile ) {
/* Cannot open file */
printf( "Cannot open file for write\n" );
ctl->retVal = MGU_OPEN_FILE;
return;
}
title = _( "Sylpheed Address Book" );
rootFolder = cache->rootFolder;
dsName = cache->name;
exporthtml_fmt_header( ctl, htmlFile, title );
fprintf( htmlFile, "<body>\n" );
fprintf( htmlFile, "<h1>%s</h1>\n", title );
fprintf( htmlFile, "<p class=\"fmt-folder\">" );
fprintf( htmlFile, "%s: ", _( "Address Book" ) );
fprintf( htmlFile, "%s", dsName );
fprintf( htmlFile, "</p>\n" );
exporthtml_fmt_folder( ctl, htmlFile, rootFolder );
tt = time( NULL );
fprintf( htmlFile, "<p>%s</p>\n", ctime( &tt ) );
fprintf( htmlFile, "<hr width=\"100%%\"></hr>\n" );
fprintf( htmlFile, "</body>\n" );
fprintf( htmlFile, "</html>\n" );
fclose( htmlFile );
ctl->retVal = MGU_SUCCESS;
/* Create stylesheet files */
exporthtml_create_css_files( ctl );
}
/*
* Build full export file specification.
* Enter: ctl Export control data.
*/
static void exporthtml_build_filespec( ExportHtmlCtl *ctl ) {
gchar *fileSpec;
fileSpec = g_strconcat(
ctl->dirOutput, G_DIR_SEPARATOR_S, ctl->fileHtml, NULL );
ctl->path = mgu_replace_string( ctl->path, fileSpec );
g_free( fileSpec );
}
/*
* ============================================================================
* Parse directory and filename from full export file specification.
* Enter: ctl Export control data.
* fileSpec File spec.
* ============================================================================
*/
void exporthtml_parse_filespec( ExportHtmlCtl *ctl, gchar *fileSpec ) {
gchar *t;
gchar *base = g_path_get_basename(fileSpec);
ctl->fileHtml =
mgu_replace_string( ctl->fileHtml, base );
g_free(base);
t = g_path_get_dirname( fileSpec );
ctl->dirOutput = mgu_replace_string( ctl->dirOutput, t );
g_free( t );
ctl->path = mgu_replace_string( ctl->path, fileSpec );
}
/*
* ============================================================================
* Test whether directory exists.
* Enter: ctl Export control data.
* Return: TRUE if exists.
* ============================================================================
*/
gboolean exporthtml_test_dir( ExportHtmlCtl *ctl ) {
gboolean retVal;
DIR *dp;
retVal = FALSE;
if((dp = opendir( ctl->dirOutput )) != NULL) {
retVal = TRUE;
closedir( dp );
}
return retVal;
}
/*
* ============================================================================
* Create output directory.
* Enter: ctl Export control data.
* Return: TRUE if directory created.
* ============================================================================
*/
gboolean exporthtml_create_dir( ExportHtmlCtl *ctl ) {
gboolean retVal = FALSE;
ctl->rcCreate = 0;
if( mkdir( ctl->dirOutput, S_IRWXU ) == 0 ) {
retVal = TRUE;
}
else {
ctl->rcCreate = errno;
}
return retVal;
}
/*
* ============================================================================
* Retrieve create directory error message.
* Enter: ctl Export control data.
* Return: Message.
* ============================================================================
*/
gchar *exporthtml_get_create_msg( ExportHtmlCtl *ctl ) {
gchar *msg;
if( ctl->rcCreate == EEXIST ) {
msg = _( "Name already exists but is not a directory." );
}
else if( ctl->rcCreate == EACCES ) {
msg = _( "No permissions to create directory." );
}
else if( ctl->rcCreate == ENAMETOOLONG ) {
msg = _( "Name is too long." );
}
else {
msg = _( "Not specified." );
}
return msg;
}
/*
* Set default values.
* Enter: ctl Export control data.
*/
static void exporthtml_default_values( ExportHtmlCtl *ctl ) {
gchar *str;
str = g_strconcat(
g_get_home_dir(), G_DIR_SEPARATOR_S,
DFL_DIR_SYLPHEED_OUT, NULL );
ctl->dirOutput = mgu_replace_string( ctl->dirOutput, str );
g_free( str );
ctl->fileHtml =
mgu_replace_string( ctl->fileHtml, DFL_FILE_SYLPHEED_OUT );
ctl->encoding = NULL;
ctl->stylesheet = EXPORT_HTML_ID_DEFAULT;
ctl->nameFormat = EXPORT_HTML_FIRST_LAST;
ctl->banding = TRUE;
ctl->linkEMail = TRUE;
ctl->showAttribs = TRUE;
ctl->retVal = MGU_SUCCESS;
}
/*
* ============================================================================
* Load settings from XML properties file.
* Enter: ctl Export control data.
* ============================================================================
*/
void exporthtml_load_settings( ExportHtmlCtl *ctl ) {
XmlProperty *props;
gint rc;
gchar buf[256];
*buf = '\0';
props = xmlprops_create();
xmlprops_set_path( props, ctl->settingsFile );
rc = xmlprops_load_file( props );
if( rc == 0 ) {
/* Read settings */
xmlprops_get_property_s( props, EXMLPROP_DIRECTORY, buf );
ctl->dirOutput = mgu_replace_string( ctl->dirOutput, buf );
xmlprops_get_property_s( props, EXMLPROP_FILE, buf );
ctl->fileHtml = mgu_replace_string( ctl->fileHtml, buf );
ctl->stylesheet =
xmlprops_get_property_i( props, EXMLPROP_STYLESHEET );
ctl->nameFormat =
xmlprops_get_property_i( props, EXMLPROP_FMT_NAME );
ctl->banding =
xmlprops_get_property_b( props, EXMLPROP_BANDING );
ctl->linkEMail =
xmlprops_get_property_b( props, EXMLPROP_FMT_EMAIL );
ctl->showAttribs =
xmlprops_get_property_b( props, EXMLPROP_FMT_ATTRIB );
}
else {
/* Set default values */
exporthtml_default_values( ctl );
}
exporthtml_build_filespec( ctl );
/* exporthtml_print( ctl, stdout ); */
xmlprops_free( props );
}
/*
* ============================================================================
* Save settings to XML properties file.
* Enter: ctl Export control data.
* ============================================================================
*/
void exporthtml_save_settings( ExportHtmlCtl *ctl ) {
XmlProperty *props;
props = xmlprops_create();
xmlprops_set_path( props, ctl->settingsFile );
xmlprops_set_property( props, EXMLPROP_DIRECTORY, ctl->dirOutput );
xmlprops_set_property( props, EXMLPROP_FILE, ctl->fileHtml );
xmlprops_set_property_i( props, EXMLPROP_STYLESHEET, ctl->stylesheet );
xmlprops_set_property_i( props, EXMLPROP_FMT_NAME, ctl->nameFormat );
xmlprops_set_property_b( props, EXMLPROP_BANDING, ctl->banding );
xmlprops_set_property_b( props, EXMLPROP_FMT_EMAIL, ctl->linkEMail );
xmlprops_set_property_b( props, EXMLPROP_FMT_ATTRIB, ctl->showAttribs );
xmlprops_save_file( props );
xmlprops_free( props );
}
/*
* ============================================================================
* End of Source.
* ============================================================================
*/