rescue from bit-rot

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4802 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2001-06-26 06:38:11 +00:00
parent 86ee77bf02
commit 4e32ac79e3

View File

@ -14,9 +14,11 @@
#include <string.h>
#include "gnc-book.h"
#include "gnc-commodity.h"
#include "gnc-engine.h"
#include "Group.h"
#include "io-gncxml.h"
#include "io-gncxml-v2.h"
int
main (int argc, char *argv[])
@ -25,38 +27,46 @@ main (int argc, char *argv[])
char * fake_argv[] = {"hello", 0};
GNCBook *book;
AccountGroup *grp;
char *bufp;
int rc, sz;
char *bufp = NULL;
int rc, sz = 0;
/* intitialize the engine */
gnc_engine_init (fake_argc, fake_argv);
/* dirty little hack to work around commodity borkeness */
{
gnc_commodity_table *t = gnc_engine_commodities ();
gnc_commodity *cm = gnc_commodity_new ("US Dollar", "ISO4217", "USD", "840", 100);
gnc_commodity_table_insert (t, cm);
}
/* contact the database, which is a flat file for this demo */
book = gnc_book_new ();
rc = gnc_book_begin (book, "file:/tmp/demo.xac", FALSE);
rc = gnc_book_begin (book, "file:/tmp/demo.gml", FALSE, FALSE);
if (!rc) {
int err = gnc_book_get_error (book);
GNCBackendError err = gnc_book_get_error (book);
printf ("HTTP/1.1 500 Server Error\n");
printf ("\n");
printf ("%d %s\n", err, strerror (err));
printf ("err=%d \n", err);
goto bookerrexit;
}
rc = gnc_book_load (book);
if (!rc) {
int err = gnc_book_get_error (book);
GNCBackendError err = gnc_book_get_error (book);
printf ("HTTP/1.1 500 Server Error\n");
printf ("\n");
printf ("%d %s\n", err, strerror (err));
printf ("err=%d \n", err);
goto bookerrexit;
}
/* the grp pointer points to our local cache of the data */
grp = gnc_book_get_group (book);
gncxml_write_to_buf(grp, &bufp, &sz);
// gncxml_write_to_buf(grp, &bufp, &sz);
// write_pricedb_str (NULL, book);
/* print the HTTP header */
printf ("HTTP/1.1 200 OK\n");