mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add demo files
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3395 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
3
src/experimental/cgi-bin/.cvsignore
Normal file
3
src/experimental/cgi-bin/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
mbox.out
|
||||
29
src/experimental/cgi-bin/Makefile.am
Normal file
29
src/experimental/cgi-bin/Makefile.am
Normal file
@@ -0,0 +1,29 @@
|
||||
# cgi-bin Makefile.am file.
|
||||
|
||||
|
||||
bin_PROGRAMS = hello
|
||||
|
||||
CFLAGS = @CFLAGS@ ${GLIB_CFLAGS}
|
||||
|
||||
LDADD = \
|
||||
../../engine/libgncengine.la \
|
||||
-lxml -lglib
|
||||
|
||||
INCLUDES =
|
||||
|
||||
hello_SOURCES = \
|
||||
hello.c
|
||||
|
||||
noinst_HEADERS =
|
||||
|
||||
|
||||
EXTRA_DIST = \
|
||||
.cvsignore \
|
||||
README
|
||||
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# glib puts its header files in a bizarre place ...
|
||||
INCLUDES = \
|
||||
-I/usr/lib/glib/include \
|
||||
-I../../engine
|
||||
1
src/experimental/cgi-bin/README
Normal file
1
src/experimental/cgi-bin/README
Normal file
@@ -0,0 +1 @@
|
||||
this is some cgi-bin testing
|
||||
96
src/experimental/cgi-bin/hello.c
Normal file
96
src/experimental/cgi-bin/hello.c
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* FILE:
|
||||
* hello.c
|
||||
*
|
||||
* FUNCTION:
|
||||
* A simple libgnc_engine hello-world demo
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gnc-book.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "Group.h"
|
||||
#include "Query.h"
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int fake_argc =1;
|
||||
char * fake_argv[] = {"hello", 0};
|
||||
GNCBook *book;
|
||||
AccountGroup *grp;
|
||||
Query *q;
|
||||
GList *split_list, *node;
|
||||
Split *s;
|
||||
int i, rc;
|
||||
|
||||
|
||||
/* intitialize the engine */
|
||||
gnc_engine_init (fake_argc, fake_argv);
|
||||
|
||||
/* contact the database, which is a flat file for this demo */
|
||||
book = gnc_book_new ();
|
||||
|
||||
rc = gnc_book_begin (book, "file:/tmp/demo.xac");
|
||||
if (!rc) {
|
||||
int err = gnc_book_get_error (book);
|
||||
printf ("HTTP/1.1 500 Server Error\n");
|
||||
printf ("\n");
|
||||
printf ("%d %s\n", err, strerror (err));
|
||||
goto bookerrexit;
|
||||
}
|
||||
|
||||
rc = gnc_book_load (book);
|
||||
if (!rc) {
|
||||
int err = gnc_book_get_error (book);
|
||||
printf ("HTTP/1.1 500 Server Error\n");
|
||||
printf ("\n");
|
||||
printf ("%d %s\n", err, strerror (err));
|
||||
goto bookerrexit;
|
||||
}
|
||||
|
||||
/* the grp pointer points to our local cache of the data */
|
||||
grp = gnc_book_get_group (book);
|
||||
|
||||
/* build a query */
|
||||
q = xaccMallocQuery ();
|
||||
xaccQuerySetGroup (q, grp);
|
||||
xaccQuerySetMaxSplits (q, 30);
|
||||
|
||||
/* Get everything between some random dates */
|
||||
/* In real life, we would use a query as specified by the user */
|
||||
xaccQueryAddDateMatch (q, TRUE, 1982, 2, 28,
|
||||
FALSE, 2010, 10, 16,
|
||||
QUERY_OR);
|
||||
|
||||
split_list = xaccQueryGetSplits (q);
|
||||
|
||||
/* count number of splits */
|
||||
i = 0;
|
||||
for (node = split_list; node; node = node->next)
|
||||
{
|
||||
s = node->data;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/* print the HTTP header */
|
||||
printf ("HTTP/1.1 200 OK\n");
|
||||
printf ("Content-Type: text/xml\n");
|
||||
printf ("\n");
|
||||
printf ("found %d splits %d %d \n", i, xaccQueryHasTerms (q),
|
||||
xaccGroupGetNumSubAccounts(grp));
|
||||
|
||||
xaccFreeQuery (q);
|
||||
|
||||
bookerrexit:
|
||||
/* close the book */
|
||||
gnc_book_destroy (book);
|
||||
|
||||
/* shut down the engine */
|
||||
gnc_engine_shutdown ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user