[RFC Patch] Invert the program entry point

Neil Williams linux at codehelp.co.uk
Tue Jan 3 03:06:00 EST 2006


On Tuesday 03 January 2006 6:18 am, Chris Shoemaker wrote:
> Folks,
>         I'm interested in comments on the attached patch.

I too have been working on a gnucash C executable - but with even less links 
into guile. I could get it to load gnucash as far as the splash screen, load 
all the modules but had problems at the main window stage. (Hence it hasn't 
been committed.) I think the problems are just down to some additional 
configure defines that have unwanted side effects.

I'm certainly in favour of working with you on this process.

My test routine is for the cashutil branch and creates gnucash2 - a typical 
binary executable from C source. I added some of the cashutil popt calls so 
that, in effect, gnucash2 implements a lot of the cashutil CLI.

(cashutil itself would retain the --shell interface that provides all the add, 
edit, delete, undo, redo support as well as implementing the gnucash2 CLI for 
users who don't have the --gui installed.)

I'll commit to the cashutil branch later - my error is probably obvious to 
others so please, don't be too critical of it! (I know it doesn't work 
properly.)

:-)

Unfortunately, it's not a small commit because I've had to merge a lot of 
trunk changes into the cashutil branch (e.g. merging the lib/libqof changes).

One comment on gnucash2 - as a 'standard' popt interface, I've currently 
implemented it so that if no commands are given, gnucash2 prints --usage and 
exits. I've done this because gnucash2 has lots of other CLI commands and 
options:

bin$ ./gnucash2
Usage: lt-gnucash2 [-g|--gui] [--no-file] [-?|--help] [--usage] [-l|--list]
        [--explain] [-x|--xml-file filename] [-t|--date string]
        [-d|--database string] [-e|--exclude string] [-s|--sql string]
        [-f|--sql-file filename] [-w|--write filename] [--compress=integer]
        [--debug] [--version] [-c|--category string]

   GnuCash: Open Source Accounting Software
   See http://www.gnucash.org/
   Use --help for more detailed help or
   -g to load the gnucash main window.
   Use exactly one of -x -l -g --explain;
   options are -c -t -w, -d or -e, -s or -f.

To load the gui, I've got a specific command:
$ gnucash2 --gui
or using short popt syntax:
$ gnucash2 -g

Is this a no-go ? I think it would be fine to specify --gui for the desktop 
icons etc. 

gnucash2 would allow arbitrary SQL-type queries to be run against gnucash data 
on the command line, allow users to list the supported objects and see an 
explanation of all their parameters. category is a red-herring - it's 
inherited from the Palm work that lies behind the gnucash2 popt CLI. 

gnucash2 sql-type queries result in QSF being output, either to stdout or to a 
file using --write.

>         This design has several disadvantages that I don't want to get
> into right now, but several of them can be avoided by a small change
> in the attached patch.  Basically, we can just provide a main()
> function in C, link to libguile, and build an executable that calls a
> guile module.  That's what this patch does.  It installs an alternate
> startup script 'gnucash-test' in the bin directory which calls the
> 'gnucash-bin' executable, which starts up Gnucash.  Tada! Gnucash is
> now a C program that happens to link to some libraries written in
> guile.

I can add CLI code to this C source to completely replace command-line.scm - 
as long as loading the main window can be sorted out.

>         BTW, I think that one consequence of this change would be that
> it would become much easier to move the entire start-up sequence from
> guile to C.

I've got 75% of that startup sequence in gnucash2.

>         WorksForMe(tm) but I'm especially interested to hear if I've
> missed anything.  I've delayed committing on the chance that there's
> some fundamental flaw in this design.  So speak up if so!

I'll commit to the cashutil branch, you can take a look at gnucash2 and we can 
work together - that may be the best solution.

-- 

Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20060103/d773632c/attachment.bin


More information about the gnucash-devel mailing list