payredu

Cross-platform ledger GUI written in c99
git clone git@getsh.org:payredu.git
Log | Files | Refs | README

HACKING (2302B)


      1 HACKING
      2 =======
      3 
      4 yyyy/mm/dd <till \n>
      5   <till double space>  <sign|commodity|quantity>\n
      6   ...\n
      7   ...\n\n // mark posting on \n\n
      8 
      9 
     10 payredu can be bulit as a standalone library(libpayredu) or can be
     11 built as
     12 an executable.
     13 
     14 	make libpayredu.a
     15 	make libpayredu.so
     16 	make payredu
     17 
     18 You can control what you want to build by invoking it separately. By
     19 default
     20 builds everything.
     21 
     22 Makefile
     23 --------
     24 This project strives to use the same Makefile to work on both gmake
     25 and bmake.
     26 
     27 If you want to add any ${CC} specific flags, check the part under
     28 "#if ${CC}"
     29 in Makefile.
     30 
     31 commit.c
     32 --------
     33 The original ledger-cli does not do edits, to make the runtime simple
     34 but since
     35 the database is completely ASCII and unorganized, consequent and
     36 programmatic
     37 writes creates a stress on the CPU and RAM, making it unsuitable for
     38 building
     39 touch friendly GUIs or general clients on top of it without comprosing UX.
     40 
     41 To prevent this, payredu exposes a commit API which can be used by
     42 text editors
     43 and other frontends to validate added content before saving it to
     44 the file.
     45 
     46 Once you are done with the changes in the text editor or other GUI,
     47 you can
     48 commit the data to payredu using the APIs
     49 
     50 	int ledger_commit_text(new_text, new_text_len)
     51 	int ledger_commit_post(timestamp, comment, comment_len, entries**)
     52 
     53 The first variant can be used by text editors where the structure of the
     54 parsed text is not understood.
     55 
     56 The second variant can be used when frontend is a GUI or other UI
     57 where the
     58 user input is controlled.
     59 
     60 RETURN VALUE
     61 ------------
     62 Both variants return PARSE_OK if suceeded, and -1 on failure.
     63 
     64 payredu.c
     65 ---------
     66 Similar to ledger-cli
     67 payredu follows the UNIX style option arguments to make the parsing easy
     68 and to combine multiple options
     69 
     70 
     71 parse.c
     72 -------
     73 There are two parsers written for the
     74 * main ledger file
     75 * price history file
     76 
     77 
     78 The parser is written entirely by hand to reduce dependencies.
     79 
     80 The `state` variable at any given time holds the information 'what we are
     81 trying to parse'. If the `state` has the value `DATE`, it means we are in
     82 a condition where we expect DATE to occur such as when starting the parser
     83 or when a posting is parsed.
     84 
     85 There aren't as many states as the ledger format itself is quite minimal.
     86 These are currently the states,
     87 
     88 DATE
     89 COMMENT
     90 ENTRY_WHO
     91 ENTRY_AMOUNT
     92 ENTRY_END
     93