/*
Copyright (c) 2000-2010, Dirk Krause
All rights reserved.

Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.
* Redistributions in binary form must reproduce the above 
  opyright notice, this list of conditions and the following
  disclaimer in the documentation and/or other materials
  provided with the distribution.
* Neither the name of the Dirk Krause nor the names of
  contributors may be used to endorse or promote
  products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*/

/*
  1.3.4
  2003/07/21
  - dkof module added
  - tracecc complains about too long "$!" or "$(...)" lines
    default line length for these lines increased to 512
    instead of 128.
*/

/*
  1.2.3
  2002/09/19
  - added dkapp_set_source_filename() / dkapp_set_source_lineno()
  - log levels now abbreviated
    n$one

*/

/*
  2002/07/04
  version 1.0.5
  - Generation of DLLs on W32.
  - The dkapp_open_ext1() function allows to specify
    - the application group name (package name)
    - the system configuration directory (configured via
      ./configure ... --sysconfdir=...
      where applicable)
    - a flag for working silently
    - a flag for not using stdout and stderr for logging
      (usefull for GUI based applications which have no console attached).
    It is recommended to use dkapp_open_ext1() instead of
    dkapp_open() and dkapp_set_groupname() and/or dkapp_set_silent().
    When using dkapp_open_ext1() the information can be used during
    application startup. 
  - Help texts by dkapp_help() are translated via codepages
    where applicable.
  - Help texts are written to the logfile too.
*/

/*
  2002/06/07
  int dkapp_set_groupname(dk_app_t *a, char *n);
  This function assigns an a package or program group name to an
  application. This can be used to search for configuration files
  in subdirectories below /etc, i.e. in /etc/yalc for
  klpr, klpq, klprq, klpc and snmpyalc which belong to the program
  group yalc.
  In dkapp.c the my_find_file() function was changed to search
  for files in subdirectories below /etc or WINDIR. I.e. klpr
  searches for configuration files also in
  WINDIR/klpr, WINDIR/yalc, WINDIR, /etc/klpr, /etc/yalc and /etc.
*/

/*
  2002/06/07
  added:   dkapp_set_silent(), dkapp_get_appname()
  void dkapp_set_silent(dk_app_t *a, int v) sets the application
  to be silent.
  char *dkapp_get_appname(dk_app_t *a) returns the application name.
*/

/*
  2002/06/04
  added:   dkapp_stream_open...(), dkapp_fopen()
  The functions call the appropriate dkstream_open...() or
  dksf_msfo() functions, security settings are retrieved from
  command line preferences, automated logging if security checks
  fail.
*/

/*
  2002/06/03
  removed: dksf_nowrite()
  changed: dksf_fopen()
  added:   dksf_msfo(), dksf_allowed_to_write()
*/

/*
  2002/05/30
  Functions dksf_nowrite() and dksf_fopen() added.
*/

/*
  2002/05/22
  Functions dkstr_is_abbr() and dkstr_find_multi_part_abbr() added.
*/

/*
  2002/02/15
  size_t dkstr_explode(char **array, size_t arraysize, char *str, char *wh);
  divides the string str, the array contains pointers to the substring.
  arraysize is the size of the array (number of pointers), wh a set
  of whitespaces (or a NULL pointer).
  char test_string[] = { "This is a test string." };
  char *p[4];
  dkstr_explode(p, 4, test_string, NULL);
  will create
  p[0] = "This" , p[1] = "is", p[2] = "a", p[3] = NULL.
  The NULL pointer is the finalizer.
*/

/*
  2002/02/05
  Changes to dkstr.c,
  char *dkstr_get_suffix(char *fn);
  added to get file type. A pointer to the dot is returned or NULL.
*/

/*
  2002/01/15
  Changes to dksf.c, we first try GetComputerNameA if available
  before checking registry and environment for a computer name.
*/

/*

  2001/12/04
  Registry-access changed to force ANSI versions of functions.

*/

