Node:Internal structure of kort program,
Next:Running kort,
Previous:Database structure,
Up:Top
Internal structure of kort program
Chaos reigns within.
Reflect, repent, and reboot.
Order shall return.1
Err..there is no solutions, there is only adaptation to current
situation.
Kort is written in the Objective C language with very little emphasis
in object orientation. The data structures of previous version of kort
were turned into objc classes with a few protocol classes thrown in. Internal
workings are very much the same as in previous version altough the syntax
is now very different. Most significant change is that because ncurses
form library could not be used for unicode input/output it has been replaced
with a non-forms ncurses implementation. Forms library is not linked in
any more. Replacement for ncurses forms resides for most parts in files
that begin with ciroucset_* and it is used in same manner as original
ncurses forms but again, syntax is very different. This form-code stuff is
also written in objective c.
Most important parts of the program are described here:
- Phile record_t.h contains the record_t class. This holds
about every valuable piece of data about interpreting data records.
- kortparser.y is yacc/bison source code that is used to parse
the Application definition file syntax and when finding something
valuable, this part usually calls something from
- record_t.m that is implementation of record_t class.
- kortelements.lex contains the lex interpretation rules for
static strings and language elements used in
Application definition file syntax.
- main.m is the part where execution begins. Initialization
stuff for most part. This constructs appbus_t and controller_t
and enters main loop, located inside controller_t class.
- db_t.m is where about all database interaction should be
done. Methods of most interest are of course save_record_to_db
and fetch_record_from_db but there is also a lot of stuff that
is used to make values for record identifiers and locking records.
- tcl_t.m contains parts needed for calling TCL interpreter.
- net_t.m contains UDP/IP -related stuff, but message-sending
functions are also found from db_t.m.
- static_strings.m contains initialization of (error)messages.
- controller_t.m contains much of the application logic.
- appbus_t.m acts a proxy and owner. It owns instances of
net and db and tcl and proxies method class between these and the
controller_t class intances.
Class record_t contains record definitions. For most
part naming in record_t is assumed self-explanatory, with the
following exceptions:
- There may be 255 fields in each record, definitely enough as there may
not be hidden fields so programmer must find space from terminal screen
for each field, if she finds she does not, should he consult
J. Preece et al.; HCI; ISBN 0-201-62769-82 for details about fitting many fields to one screenful.
- nfields and nlabels contain number of fields and labels present for
each record .. record_t is present once for each record. Many members
of the record_t structure are for each field, like field_x that is
defined as int field_x[256] and it means that in field_x[0] there
will be the x coordinate for first field that is given for a record
in application definition file.
- should tablename point to NULL would recordname be assumed
to be a record that will not be saved to DB.
- njoining_records is number of records that have this record
as their subrecords.
- allowed_values_table_for_field and allowed_values_column_for_field
are used to specify at runtime the ALLOWED_VALUES directive from
application definition file. Their NULL-pointage is checked at least
from file visualization.c when navigating out from field.
- func_key_actions specify the thing that is done when Fx is hit.
- func_key_recordnamepointers[x] should point to non-NULL when
func_key_actions[x]==act_selectrecord as it causes another record
to be selected.
- func_key_labels are the labels shown in the bottom of the screen.
curses has different modes for these labels, currently kort uses mode
that displays 8 labels. There is usually mode function keys, currently
kort has support for 12 function keys so F9-F12 will not have any
label displayed but they may have a function anyway.
- askfirst is indication whether function key action should be confirmed
by the user before action is taken.
- record_id is set at runtime. It is the given surrogate value for
record that is saved to associated data table column recid. This
number is used to tell which record is which record. As there is
one record_t in memory of kort at time, this number remains the
same when user saves record content and changes (i.e. a new surrogate
is invented) when user changes record as new.
- record_id_master is record_id of the record that is this parent of
this record.
- nsubkeys is the number of records that have this record as their
parent.
- subkeylist and subkeyindex are kind of historic relics, at some
point it might have been possible to do "next record" and "prev record"
operations for subrecord of a record and these variables might have
been used for that.
- Structure members named tclcode_XXX point to tcl code that may be
given to TCL interpreter at point or another. Some of them relate to
record, some to function key and some to record field.
- dateformat_of_field is pointer to structure that contains information
about parsing of date formats. In dateformatspec_t value of hh_pos
is -1 if hour-part is not present is date format in question and if it is,
then value of hh_pos is the position of number presenting hour
in the string that contains said date in human readable form. Example is
that if date format is "dd.mm.yyyy hh:mi" then hh_pos is 12 as hour
begins from character position 12 at this string.
Kort code is somewhat commented and there is a more-up-to-date
listing of kort structure available from
http://muikku.katiska.org/kort/documentation-0.03/doxygen_generated/index.html and it should documents details ; I'll try to explain those
parts not clearly visible from code in this page.
Compiling kort
Kort is for most part done in Objective C. "gcc -Wall" doesn't produce serious
complaints so in current incarnation the syntax of kort might conform
to objective c syntax somewhat. Parser is written in yacc+lex so you'll
need those; actually bison+flex was used but syntax should be the same.
Bison versions earlier than 1.75 do not work, at least 1.75 is required.
Of course thingies that kort tries to glue together must be present. At least
one version combination that is known to compile is this:
- gcc-2.96, the infamous redhat release :)
- glibc-2.2.4
- mysql-3.23.41
- tcl-8.3.3
- ncurses-5.4 (5.3 wont do, nor will earlier). You will need the version
of ncurses that has wide character support compiled in. Either compile
youself, there is a switch in configure script for this or if in debian
environment, grab the package libncursesw5 as it has required support.
- tre is available from http://laurikari.net/tre/ and it is a
regular expression matching library with wide character support.
Many linux distributions already have this, at least debian has
both libtre4 and libtre-dev packages that you'll need to compile kort.
- Objective C support for gcc must be installed. No objective C class
libraries need to be installed but the basic set that comes with
the compiler and includes implementation of the Object class itself
is required. Debian packages in question are objc and libobjc1.
Depending on your setup you may need to change libraries in Makefile.
You'll need to link at least -lncursesw -lmysqlclient -lfl -ltcl -lm -ldl -lz
-lobjc -ltre.
Basic stuff is ncursesw,mysqlclient and tcl. Flex needs -lfl.
Mysqlclient seems to require -lz. TCL seems to require -lm and -ldl,
at least in Linux. In some systems you'll propably need to include
-lgen -lnls -lc but that may have been at times long gone. These
libraries may be at perverse locations, as you know. Basically same
applies to #include-files so you'll may end up adding -I/dir/ectory -entries
to CFLAGS. Have phun :-)
Footnotes
-
Who would not love Suzie Wagner?
-
Kicks some
serious ass.