#if, #ifdef Nesting

You can nest #ifdef's within #if's, and vice-versa, throughout the config files.

For example, you might do this in your alerts.cfg:

Debug

#ifndef holiday
#  if piktmaster
        timing          55 *   * * * 5
#  else
        timing          55 */6 * * * 5
#  endif
#elsedef
        timing          =piktnever
#endifdef
When nesting in this way, per-machine #if directives take precedence over logical #ifdef directives.  So, for example,
#if linux
      [ aaa ... ]
#ifdef paranoid
      [ bbb ... ]
#endifdef
      [ ccc ... ]
#endif
would have the aaa, bbb & ccc content appear only on linux machines, and the bbb content only if paranoid is set (defined).  On the other hand, with
#ifdef paranoid
     [ aaa ... ]
#if linux
     [ bbb ... ]
#endif
     [ ccc ... ]
#endifdef
the aaa and ccc content would appear on all machines, if paranoid is set, while the bbb content would appear only on linux machines with paranoid defined.

This, however, would lead to error on non-linux systems:

#ifdef paranoid
     [ aaa ... ]
#if linux
     [ bbb ... ]
#endifdef
     [ ccc ... ]
#endif
because there would be no concluding #endifdef on those machines.  In other words, be careful about intertwining #if-#endif's with #ifdef-#endifdef's.

Observe that you can set/unset defines on a per-machine basis in the defines.cfg file, for example

#if dbserver
paranoid     TRUE
#else
paranoid     FALSE
#endif
Or, alternatively and equivalently,
paranoid
#if dbserver
             TRUE
#else
             FALSE
#endif
Refer to the Samples section for more examples.

prev page 1st page next page
 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
piktd.conf
config file