0000: 2e 54 48 20 4c 43 5f 52 45 47 49 53 54 45 52 5f .TH LC_REGISTER_
0010: 43 41 4c 4c 42 41 43 4b 20 33 20 22 32 35 20 4f CALLBACK 3 "25 O
0020: 63 74 20 30 34 22 20 22 40 50 41 43 4b 41 47 45 ct 04" "@PACKAGE
0030: 5f 53 54 52 49 4e 47 40 22 0a 2e 53 48 20 4e 41 _STRING@"..SH NA
0040: 4d 45 0a 6c 63 5f 72 65 67 69 73 74 65 72 5f 63 ME.lc_register_c
0050: 61 6c 6c 62 61 63 6b 20 5c 2d 20 52 65 67 69 73 allback \- Regis
0060: 74 65 72 20 61 20 66 75 6e 63 74 69 6f 6e 20 66 ter a function f
0070: 6f 72 20 63 61 6c 6c 62 61 63 6b 20 69 6e 20 63 or callback in c
0080: 6f 6e 66 69 67 20 70 72 6f 63 65 73 73 69 6e 67 onfig processing
0090: 2e 0a 0a 2e 53 48 20 53 59 4e 4f 50 53 49 53 0a ....SH SYNOPSIS.
00a0: 2e 42 20 23 69 6e 63 6c 75 64 65 20 3c 6c 69 62 .B #include <lib
00b0: 63 6f 6e 66 69 67 2e 68 3e 0a 2e 73 70 0a 2e 42 config.h>..sp..B
00c0: 49 20 22 69 6e 74 20 6c 63 5f 72 65 67 69 73 74 I "int lc_regist
00d0: 65 72 5f 63 61 6c 6c 62 61 63 6b 28 63 6f 6e 73 er_callback(cons
00e0: 74 20 63 68 61 72 20 2a 22 20 76 61 72 20 22 2c t char *" var ",
00f0: 20 63 68 61 72 20 22 20 6f 70 74 20 22 2c 20 6c char " opt ", l
0100: 63 5f 76 61 72 5f 74 79 70 65 5f 74 20 22 20 74 c_var_type_t " t
0110: 79 70 65 20 22 2c 20 69 6e 74 20 28 2a 22 20 63 ype ", int (*" c
0120: 61 6c 6c 62 61 63 6b 20 22 29 28 63 6f 6e 73 74 allback ")(const
0130: 20 63 68 61 72 20 2a 2c 20 63 6f 6e 73 74 20 63 char *, const c
0140: 68 61 72 20 2a 2c 20 63 6f 6e 73 74 20 63 68 61 har *, const cha
0150: 72 20 2a 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 r *, const char
0160: 2a 2c 20 6c 63 5f 66 6c 61 67 73 5f 74 2c 20 76 *, lc_flags_t, v
0170: 6f 69 64 20 2a 29 2c 20 76 6f 69 64 20 2a 22 20 oid *), void *"
0180: 65 78 74 72 61 20 22 29 3b 22 0a 0a 2e 53 48 20 extra ");"...SH
0190: 44 45 53 43 52 49 50 54 49 4f 4e 0a 54 68 65 0a DESCRIPTION.The.
01a0: 2e 42 52 20 6c 63 5f 72 65 67 69 73 74 65 72 5f .BR lc_register_
01b0: 63 61 6c 6c 62 61 63 6b 20 28 33 29 0a 66 75 6e callback (3).fun
01c0: 63 74 69 6f 6e 20 72 65 67 69 73 74 65 72 73 20 ction registers
01d0: 61 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 62 65 a function to be
01e0: 20 63 61 6c 6c 65 64 20 77 68 65 6e 0a 2e 49 52 called when..IR
01f0: 20 76 61 72 0a 69 73 20 65 6e 63 6f 75 6e 74 65 var.is encounte
0200: 64 20 69 6e 20 61 20 63 6f 6e 66 69 67 75 72 61 d in a configura
0210: 74 69 6f 6e 20 66 69 6c 65 2c 20 63 6f 6d 6d 61 tion file, comma
0220: 6e 64 20 6c 69 6e 65 2c 20 6f 72 20 65 6e 76 69 nd line, or envi
0230: 72 6f 6e 6d 65 6e 74 20 76 61 72 69 61 62 6c 65 ronment variable
0240: 2e 0a 54 68 65 20 70 61 72 61 6d 65 74 65 72 73 ..The parameters
0250: 20 61 72 65 20 61 73 20 66 6f 6c 6c 6f 77 73 3a are as follows:
0260: 0a 2e 54 50 0a 2e 49 52 20 22 63 6f 6e 73 74 20 ..TP..IR "const
0270: 63 68 61 72 20 2a 76 61 72 22 0a 2e 52 53 0a 54 char *var"..RS.T
0280: 68 65 0a 2e 49 52 20 76 61 72 0a 70 61 72 61 6d he..IR var.param
0290: 65 74 65 72 20 69 6e 64 69 63 61 74 65 73 20 74 eter indicates t
02a0: 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 76 he name of the v
02b0: 61 72 69 61 62 6c 65 20 74 6f 20 72 65 67 69 73 ariable to regis
02c0: 74 65 72 20 66 6f 72 20 61 20 63 61 6c 6c 62 61 ter for a callba
02d0: 63 6b 20 77 68 65 6e 20 65 6e 63 6f 75 6e 74 65 ck when encounte
02e0: 72 65 64 20 69 6e 20 61 20 63 6f 6e 66 69 67 75 red in a configu
02f0: 72 61 74 69 6f 6e 20 66 69 6c 65 2c 20 74 68 65 ration file, the
0300: 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 2c 20 6f 72 environment, or
0310: 20 61 73 20 61 20 6c 6f 6e 67 20 6f 70 74 69 6f as a long optio
0320: 6e 2e 20 20 54 68 65 0a 2e 49 52 20 76 61 72 0a n. The..IR var.
0330: 6d 61 79 20 62 65 20 70 72 65 66 69 78 65 64 20 may be prefixed
0340: 77 69 74 68 20 22 2a 2e 22 20 74 6f 20 69 6e 64 with "*." to ind
0350: 69 63 61 74 65 20 74 68 61 74 20 74 68 65 20 6f icate that the o
0360: 62 6a 65 63 74 20 63 61 6e 20 6f 63 63 75 72 20 bject can occur
0370: 69 6e 20 61 6e 79 20 73 65 63 74 69 6f 6e 20 6f in any section o
0380: 72 20 73 75 62 73 65 63 74 69 6f 6e 2e 0a 2e 52 r subsection...R
0390: 45 0a 0a 2e 54 50 0a 2e 49 52 20 22 63 6f 6e 73 E...TP..IR "cons
03a0: 74 20 63 68 61 72 20 6f 70 74 22 0a 2e 52 53 0a t char opt"..RS.
03b0: 54 68 65 0a 2e 49 52 20 6f 70 74 0a 70 61 72 61 The..IR opt.para
03c0: 6d 65 74 65 72 20 69 6e 64 69 63 61 74 65 73 20 meter indicates
03d0: 74 68 65 20 73 69 6e 67 6c 65 20 63 68 61 72 65 the single chare
03e0: 63 74 61 72 20 73 68 6f 72 74 20 6f 70 74 69 6f ctar short optio
03f0: 6e 20 74 6f 20 75 73 65 20 66 72 6f 6d 20 74 68 n to use from th
0400: 65 20 63 6f 6d 6d 61 6e 64 20 6c 69 6e 65 20 74 e command line t
0410: 6f 20 69 6e 76 6f 6b 65 20 74 68 65 20 72 65 67 o invoke the reg
0420: 69 73 74 65 72 20 63 61 6c 6c 62 61 63 6b 2e 20 ister callback.
0430: 20 41 20 76 61 6c 75 65 20 6f 66 20 30 20 69 6e A value of 0 in
0440: 64 69 63 61 74 65 73 20 74 68 61 74 20 6e 6f 20 dicates that no
0450: 73 68 6f 72 74 20 6f 70 74 69 6f 6e 20 69 73 20 short option is
0460: 61 63 63 65 70 74 61 62 6c 65 2e 0a 2e 52 45 0a acceptable...RE.
0470: 0a 2e 54 50 0a 2e 49 52 20 22 6c 63 5f 76 61 72 ..TP..IR "lc_var
0480: 5f 74 79 70 65 5f 74 20 74 79 70 65 22 0a 2e 52 _type_t type"..R
0490: 53 0a 54 68 65 0a 2e 49 52 20 74 79 70 65 0a 70 S.The..IR type.p
04a0: 61 72 61 6d 65 74 65 72 20 69 6e 64 69 63 61 74 arameter indicat
04b0: 65 73 20 74 68 65 20 74 79 70 65 20 6f 66 20 76 es the type of v
04c0: 61 6c 75 65 73 20 74 68 61 74 20 61 72 65 20 61 alues that are a
04d0: 63 63 65 70 74 61 62 6c 65 20 66 6f 72 20 74 68 cceptable for th
04e0: 69 73 20 63 61 6c 6c 62 61 63 6b 2e 20 20 41 20 is callback. A
04f0: 76 61 6c 75 65 20 6f 66 20 4c 43 5f 56 41 52 5f value of LC_VAR_
0500: 4e 4f 4e 45 20 6d 65 61 6e 73 20 74 68 61 74 20 NONE means that
0510: 74 68 65 20 63 6f 6d 6d 61 6e 64 20 77 69 6c 6c the command will
0520: 20 61 63 63 65 70 74 20 6e 6f 20 61 72 67 75 6d accept no argum
0530: 65 6e 74 73 2c 20 77 68 69 6c 65 20 61 20 76 61 ents, while a va
0540: 6c 75 65 20 6f 66 20 4c 43 5f 56 41 52 5f 55 4e lue of LC_VAR_UN
0550: 4b 4e 4f 57 4e 20 69 6e 64 69 63 61 74 65 73 20 KNOWN indicates
0560: 74 68 61 74 20 69 74 27 73 20 6e 6f 74 20 6b 6e that it's not kn
0570: 6f 77 6e 20 77 68 65 74 68 65 72 20 6f 72 20 6e own whether or n
0580: 6f 74 20 61 6e 20 61 72 67 75 6d 65 6e 74 20 69 ot an argument i
0590: 73 20 61 70 70 6c 69 63 61 62 6c 65 2c 20 74 68 s applicable, th
05a0: 69 73 20 77 69 6c 6c 20 61 6c 73 6f 20 64 69 73 is will also dis
05b0: 61 62 6c 65 20 63 6f 6d 6d 61 6e 64 20 6c 69 6e able command lin
05c0: 65 20 70 72 6f 63 65 73 73 69 6e 67 2e 20 20 41 e processing. A
05d0: 6e 79 20 6f 74 68 65 72 20 76 61 6c 75 65 20 69 ny other value i
05e0: 73 20 63 75 72 72 65 6e 74 6c 79 20 69 67 6e 6f s currently igno
05f0: 72 65 64 2e 0a 2e 52 45 0a 0a 2e 54 50 0a 2e 49 red...RE...TP..I
0600: 52 20 22 69 6e 74 20 28 2a 63 61 6c 6c 62 61 63 R "int (*callbac
0610: 6b 29 28 2e 2e 2e 29 22 0a 2e 52 53 0a 54 68 65 k)(...)"..RS.The
0620: 0a 2e 49 52 20 63 61 6c 6c 62 61 63 6b 0a 70 61 ..IR callback.pa
0630: 72 61 6d 65 74 65 72 20 69 6e 64 69 63 61 74 65 rameter indicate
0640: 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 s the name of th
0650: 65 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 69 6e e function to in
0660: 76 6f 6b 65 20 77 68 65 6e 20 74 68 65 20 61 62 voke when the ab
0670: 6f 76 65 20 70 61 72 61 6d 65 74 65 72 73 20 61 ove parameters a
0680: 72 65 20 6d 65 74 2e 20 20 54 68 65 20 73 70 65 re met. The spe
0690: 63 69 66 69 65 64 20 66 75 6e 63 74 69 6f 6e 20 cified function
06a0: 73 68 6f 75 6c 64 20 74 61 6b 65 20 36 20 70 61 should take 6 pa
06b0: 72 61 6d 65 74 65 72 73 2c 20 73 65 65 20 62 65 rameters, see be
06c0: 6c 6f 77 20 66 6f 72 20 6d 6f 72 65 20 69 6e 66 low for more inf
06d0: 6f 72 6d 61 74 69 6f 6e 2e 20 20 54 68 69 73 20 ormation. This
06e0: 76 61 6c 75 65 20 6d 61 79 20 6e 6f 74 20 62 65 value may not be
06f0: 20 4e 55 4c 4c 2e 0a 2e 52 45 0a 0a 2e 54 50 0a NULL...RE...TP.
0700: 2e 49 52 20 22 76 6f 69 64 20 2a 65 78 74 72 61 .IR "void *extra
0710: 22 0a 2e 52 53 0a 54 68 65 0a 2e 49 52 20 65 78 "..RS.The..IR ex
0720: 74 72 61 0a 70 61 72 61 6d 65 74 65 72 20 69 73 tra.parameter is
0730: 20 61 20 70 6f 69 6e 74 65 72 20 74 68 61 74 20 a pointer that
0740: 63 61 6e 20 62 65 20 75 73 65 64 20 74 6f 20 70 can be used to p
0750: 61 73 73 20 64 61 74 61 20 74 6f 20 74 68 65 20 ass data to the
0760: 63 61 6c 6c 62 61 63 6b 20 75 70 6f 6e 20 69 6e callback upon in
0770: 76 6f 63 61 74 69 6f 6e 2c 20 69 74 20 77 69 6c vocation, it wil
0780: 6c 20 6e 6f 74 20 62 65 20 6d 61 6e 67 6c 65 64 l not be mangled
0790: 20 6f 72 20 65 78 61 6d 69 6e 65 64 20 62 79 20 or examined by
07a0: 61 6e 79 20 66 75 6e 63 74 69 6f 6e 2e 0a 2e 52 any function...R
07b0: 45 0a 0a 54 68 65 20 61 72 67 75 6d 65 6e 74 73 E..The arguments
07c0: 20 74 6f 20 74 68 65 20 66 75 6e 63 74 69 6f 6e to the function
07d0: 20 73 70 65 63 69 66 69 65 64 20 61 73 0a 2e 49 specified as..I
07e0: 52 20 63 61 6c 6c 62 61 63 6b 0a 61 72 65 20 61 R callback.are a
07f0: 73 20 66 6f 6c 6c 6f 77 73 3a 0a 2e 54 50 0a 2e s follows:..TP..
0800: 49 20 22 63 6f 6e 73 74 20 63 68 61 72 20 2a 73 I "const char *s
0810: 68 6f 72 74 76 61 72 22 0a 2e 52 53 0a 54 68 65 hortvar"..RS.The
0820: 0a 2e 49 20 73 68 6f 72 74 76 61 72 0a 70 61 72 ..I shortvar.par
0830: 61 6d 65 74 65 72 20 69 73 20 74 68 65 20 6c 6f ameter is the lo
0840: 63 61 6c 20 76 61 72 69 61 62 6c 65 20 6e 61 6d cal variable nam
0850: 65 2c 20 70 72 6f 76 69 64 65 64 20 61 73 20 61 e, provided as a
0860: 20 63 6f 6e 76 69 65 6e 63 65 2e 20 20 49 74 20 convience. It
0870: 69 73 20 74 68 65 20 70 6f 72 74 69 6f 6e 20 6f is the portion o
0880: 66 20 74 68 65 20 76 61 72 69 61 62 6c 65 20 6e f the variable n
0890: 61 6d 65 20 61 66 74 65 72 20 74 68 65 20 66 69 ame after the fi
08a0: 72 73 74 20 22 64 6f 74 22 20 28 2e 29 20 69 6e rst "dot" (.) in
08b0: 20 74 68 65 20 66 75 6c 6c 79 20 71 75 61 6c 69 the fully quali
08c0: 66 69 65 64 20 76 61 72 69 61 62 6c 65 20 6e 61 fied variable na
08d0: 6d 65 2e 20 20 54 68 65 20 22 64 6f 74 22 20 28 me. The "dot" (
08e0: 2e 29 20 76 61 6c 75 65 20 69 6e 20 74 68 65 20 .) value in the
08f0: 66 75 6c 6c 79 20 71 75 61 6c 69 66 69 65 64 20 fully qualified
0900: 76 61 72 69 61 62 6c 65 20 6e 61 6d 65 20 69 6e variable name in
0910: 64 69 63 61 74 65 73 20 61 20 73 65 63 74 69 6f dicates a sectio
0920: 6e 20 6f 72 20 73 75 62 73 65 63 74 69 6f 6e 20 n or subsection
0930: 74 68 61 74 20 74 68 65 20 76 61 72 69 61 62 6c that the variabl
0940: 65 20 62 65 6c 6f 6e 67 73 20 74 6f 2e 0a 54 68 e belongs to..Th
0950: 69 73 20 6d 61 79 20 62 65 0a 2e 42 20 4e 55 4c is may be..B NUL
0960: 4c 0a 69 66 20 74 68 65 0a 2e 49 52 20 76 61 72 L.if the..IR var
0970: 0a 70 61 72 61 6d 65 74 65 72 20 74 6f 0a 2e 42 .parameter to..B
0980: 52 20 6c 63 5f 72 65 67 69 73 74 65 72 5f 63 61 R lc_register_ca
0990: 6c 6c 62 61 63 6b 20 28 33 29 0a 77 61 73 0a 2e llback (3).was..
09a0: 42 20 4e 55 4c 4c 0a 74 6f 6f 2e 0a 2e 52 45 0a B NULL.too...RE.
09b0: 2e 54 50 0a 2e 49 20 22 63 6f 6e 73 74 20 63 68 .TP..I "const ch
09c0: 61 72 20 2a 76 61 72 22 0a 2e 52 53 0a 54 68 65 ar *var"..RS.The
09d0: 0a 2e 49 20 76 61 72 0a 70 61 72 61 6d 65 74 65 ..I var.paramete
09e0: 72 20 69 73 20 74 68 65 20 66 75 6c 6c 79 20 71 r is the fully q
09f0: 75 61 6c 69 66 69 65 64 20 76 61 72 69 61 62 6c ualified variabl
0a00: 65 20 6e 61 6d 65 2e 20 20 49 74 20 69 6e 63 6c e name. It incl
0a10: 75 64 65 73 20 69 6e 20 74 68 65 20 70 72 65 66 udes in the pref
0a20: 69 78 20 61 6e 79 20 73 65 63 74 69 6f 6e 73 20 ix any sections
0a30: 61 6e 64 20 73 75 62 73 65 63 74 69 6f 6e 73 20 and subsections
0a40: 74 68 61 74 20 63 6f 6e 74 61 69 6e 20 74 68 69 that contain thi
0a50: 73 20 76 61 72 69 61 62 6c 65 2e 0a 54 68 69 73 s variable..This
0a60: 20 6d 61 79 20 62 65 0a 2e 42 20 4e 55 4c 4c 0a may be..B NULL.
0a70: 69 66 20 74 68 65 0a 2e 49 52 20 76 61 72 0a 70 if the..IR var.p
0a80: 61 72 61 6d 65 74 65 72 20 74 6f 0a 2e 42 52 20 arameter to..BR
0a90: 6c 63 5f 72 65 67 69 73 74 65 72 5f 63 61 6c 6c lc_register_call
0aa0: 62 61 63 6b 20 28 33 29 0a 77 61 73 0a 2e 42 20 back (3).was..B
0ab0: 4e 55 4c 4c 0a 74 6f 6f 2e 0a 2e 52 45 0a 2e 54 NULL.too...RE..T
0ac0: 50 0a 2e 49 20 22 63 6f 6e 73 74 20 63 68 61 72 P..I "const char
0ad0: 20 2a 61 72 67 75 6d 65 6e 74 73 22 0a 2e 52 53 *arguments"..RS
0ae0: 0a 54 68 65 0a 2e 49 20 61 72 67 75 6d 65 6e 74 .The..I argument
0af0: 73 0a 70 61 72 61 6d 65 74 65 72 20 70 72 6f 76 s.parameter prov
0b00: 69 64 65 73 20 74 68 65 20 61 72 67 75 6d 65 6e ides the argumen
0b10: 74 73 20 70 61 73 73 65 64 20 74 6f 20 74 68 65 ts passed to the
0b20: 20 76 61 72 69 61 62 6c 65 2c 20 63 75 72 72 65 variable, curre
0b30: 6e 74 6c 79 20 6f 6e 6c 79 20 73 65 63 74 69 6f ntly only sectio
0b40: 6e 73 20 6d 61 79 20 68 61 76 65 20 61 72 67 75 ns may have argu
0b50: 6d 65 6e 74 73 2e 0a 54 68 69 73 20 6d 61 79 20 ments..This may
0b60: 62 65 0a 2e 42 20 4e 55 4c 4c 0a 69 66 20 74 68 be..B NULL.if th
0b70: 65 72 65 20 77 65 72 65 20 6e 6f 20 61 72 67 75 ere were no argu
0b80: 6d 65 6e 74 73 20 73 70 65 63 69 66 69 65 64 2c ments specified,
0b90: 20 6f 72 20 69 66 20 61 72 67 75 6d 65 6e 74 73 or if arguments
0ba0: 20 77 65 72 65 20 6e 6f 74 20 61 70 70 6c 69 63 were not applic
0bb0: 61 62 6c 65 2e 0a 2e 52 45 0a 2e 54 50 0a 2e 49 able...RE..TP..I
0bc0: 20 22 63 6f 6e 73 74 20 63 68 61 72 20 2a 76 61 "const char *va
0bd0: 6c 75 65 22 0a 2e 52 53 0a 54 68 65 0a 2e 49 20 lue"..RS.The..I
0be0: 76 61 6c 75 65 0a 70 61 72 61 6d 65 74 65 72 20 value.parameter
0bf0: 70 72 6f 76 69 64 65 73 20 74 68 65 20 76 61 6c provides the val
0c00: 75 65 20 6f 66 20 74 68 65 20 76 61 72 69 61 62 ue of the variab
0c10: 6c 65 20 73 70 65 63 69 66 69 65 64 2e 0a 54 68 le specified..Th
0c20: 69 73 20 6d 61 79 20 62 65 0a 2e 42 20 4e 55 4c is may be..B NUL
0c30: 4c 0a 69 66 20 6e 6f 20 76 61 6c 75 65 20 77 61 L.if no value wa
0c40: 73 20 73 70 65 63 69 66 69 65 64 2e 20 20 56 61 s specified. Va
0c50: 6c 75 65 73 20 61 72 65 20 72 65 71 75 69 72 65 lues are require
0c60: 64 20 69 66 20 74 68 65 0a 2e 49 52 20 74 79 70 d if the..IR typ
0c70: 65 0a 70 61 72 61 6d 65 74 65 72 20 74 6f 0a 2e e.parameter to..
0c80: 42 52 20 6c 63 5f 72 65 67 69 73 74 65 72 5f 63 BR lc_register_c
0c90: 61 6c 6c 62 61 63 6b 20 28 33 29 0a 77 61 73 20 allback (3).was
0ca0: 6e 6f 74 20 73 70 65 63 69 66 69 65 64 20 61 73 not specified as
0cb0: 20 6f 6e 65 20 6f 66 20 4c 43 5f 56 41 52 5f 4e one of LC_VAR_N
0cc0: 4f 4e 45 2c 20 4c 43 5f 56 41 52 5f 53 45 43 54 ONE, LC_VAR_SECT
0cd0: 49 4f 4e 2c 20 4c 43 5f 56 41 52 5f 53 45 43 54 ION, LC_VAR_SECT
0ce0: 49 4f 4e 53 54 41 52 54 2c 20 6f 72 20 4c 43 5f IONSTART, or LC_
0cf0: 56 41 52 5f 53 45 43 54 49 4f 4e 45 4e 44 2e 0a VAR_SECTIONEND..
0d00: 2e 52 45 0a 2e 54 50 0a 2e 49 20 22 6c 63 5f 66 .RE..TP..I "lc_f
0d10: 6c 61 67 73 5f 74 20 66 6c 61 67 73 22 0a 2e 52 lags_t flags"..R
0d20: 53 0a 54 68 65 20 66 6c 61 67 73 20 70 61 72 61 S.The flags para
0d30: 6d 65 74 65 72 20 70 72 6f 76 69 64 65 73 20 69 meter provides i
0d40: 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 nformation about
0d50: 20 74 68 65 20 74 79 70 65 20 6f 66 20 63 6f 6d the type of com
0d60: 6d 61 6e 64 20 62 65 69 6e 67 20 63 61 6c 6c 65 mand being calle
0d70: 64 2e 20 20 54 68 65 20 76 61 6c 69 64 20 76 61 d. The valid va
0d80: 6c 75 65 73 20 61 72 65 3a 0a 2e 49 50 20 4c 43 lues are:..IP LC
0d90: 5f 46 4c 41 47 53 5f 56 41 52 0a 54 6f 20 69 6e _FLAGS_VAR.To in
0da0: 64 69 63 61 74 65 20 61 20 72 65 67 75 6c 61 72 dicate a regular
0db0: 20 76 61 72 69 61 62 6c 65 20 69 6e 20 61 20 63 variable in a c
0dc0: 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 66 69 6c onfiguration fil
0dd0: 65 2e 0a 2e 49 50 20 4c 43 5f 46 4c 41 47 53 5f e...IP LC_FLAGS_
0de0: 43 4d 44 4c 49 4e 45 0a 54 6f 20 69 6e 64 69 63 CMDLINE.To indic
0df0: 61 74 65 20 61 20 63 6f 6d 6d 61 6e 64 20 6c 69 ate a command li
0e00: 6e 65 20 6f 70 74 69 6f 6e 20 68 61 73 20 62 65 ne option has be
0e10: 65 6e 20 75 73 65 64 20 74 6f 20 69 6e 76 6f 6b en used to invok
0e20: 65 20 74 68 69 73 20 6f 70 74 69 6f 6e 2e 0a 2e e this option...
0e30: 49 50 20 4c 43 5f 46 4c 41 47 53 5f 53 45 43 54 IP LC_FLAGS_SECT
0e40: 49 4f 4e 53 54 41 52 54 0a 54 6f 20 69 6e 64 69 IONSTART.To indi
0e50: 63 61 74 65 20 74 68 61 74 20 74 68 69 73 20 63 cate that this c
0e60: 6f 6d 6d 61 6e 64 20 72 65 70 72 65 73 65 6e 74 ommand represent
0e70: 73 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 s the beginning
0e80: 6f 66 20 61 20 73 65 63 74 69 6f 6e 2e 0a 2e 49 of a section...I
0e90: 50 20 4c 43 5f 46 4c 41 47 53 5f 53 45 43 54 49 P LC_FLAGS_SECTI
0ea0: 4f 4e 45 4e 44 0a 54 6f 20 69 6e 64 69 63 61 74 ONEND.To indicat
0eb0: 65 20 74 68 61 74 20 74 68 69 73 20 63 6f 6d 6d e that this comm
0ec0: 61 6e 64 20 72 65 70 72 65 73 65 6e 74 73 20 74 and represents t
0ed0: 68 65 20 65 6e 64 20 6f 66 20 61 20 73 65 63 74 he end of a sect
0ee0: 69 6f 6e 2e 0a 2e 52 45 0a 2e 54 50 0a 2e 49 20 ion...RE..TP..I
0ef0: 22 76 6f 69 64 20 2a 65 78 74 72 61 22 0a 2e 52 "void *extra"..R
0f00: 53 0a 54 68 65 0a 2e 49 20 65 78 74 72 61 0a 70 S.The..I extra.p
0f10: 61 72 61 6d 65 74 65 72 20 69 73 20 6a 75 73 74 arameter is just
0f20: 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65 0a 2e a copy of the..
0f30: 49 52 20 65 78 74 72 61 0a 70 61 72 61 6d 65 74 IR extra.paramet
0f40: 65 72 20 70 61 73 73 65 64 20 74 6f 0a 2e 42 52 er passed to..BR
0f50: 20 6c 63 5f 72 65 67 69 73 74 65 72 5f 63 61 6c lc_register_cal
0f60: 6c 62 61 63 6b 20 28 33 29 0a 77 68 65 6e 20 74 lback (3).when t
0f70: 68 65 20 63 61 6c 6c 62 61 63 6b 20 77 61 73 20 he callback was
0f80: 72 65 67 69 73 74 65 72 65 64 2e 0a 2e 52 45 0a registered...RE.
0f90: 0a 54 68 65 0a 2e 49 52 20 63 61 6c 6c 62 61 63 .The..IR callbac
0fa0: 6b 0a 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c k.function shoul
0fb0: 64 20 72 65 74 75 72 6e 20 6f 6e 65 20 6f 66 20 d return one of
0fc0: 74 68 72 65 65 20 76 61 6c 75 65 73 3a 0a 2e 54 three values:..T
0fd0: 50 0a 4c 43 5f 43 42 52 45 54 5f 49 47 4e 4f 52 P.LC_CBRET_IGNOR
0fe0: 45 53 45 43 54 49 4f 4e 0a 52 65 74 75 72 6e 69 ESECTION.Returni
0ff0: 6e 67 20 4c 43 5f 43 42 52 45 54 5f 49 47 4e 4f ng LC_CBRET_IGNO
1000: 52 45 53 45 43 54 49 4f 4e 20 66 72 6f 6d 20 61 RESECTION from a
1010: 20 63 61 6c 6c 62 61 63 6b 20 74 68 61 74 20 62 callback that b
1020: 65 67 69 6e 73 20 61 20 73 65 63 74 69 6f 6e 20 egins a section
1030: 63 61 75 73 65 73 20 74 68 65 20 65 6e 74 69 72 causes the entir
1040: 65 20 73 65 63 74 69 6f 6e 20 74 6f 20 62 65 20 e section to be
1050: 69 67 6e 6f 72 65 64 20 77 69 74 68 6f 75 74 20 ignored without
1060: 67 65 6e 65 72 61 74 69 6e 67 20 61 6e 20 65 72 generating an er
1070: 72 6f 72 2e 0a 2e 54 50 0a 4c 43 5f 43 42 52 45 ror...TP.LC_CBRE
1080: 54 5f 4f 4b 41 59 0a 52 65 74 75 72 6e 69 6e 67 T_OKAY.Returning
1090: 20 4c 43 5f 43 42 52 45 54 5f 4f 4b 41 59 20 66 LC_CBRET_OKAY f
10a0: 72 6f 6d 20 61 20 63 61 6c 6c 62 61 63 6b 20 69 rom a callback i
10b0: 6e 64 69 63 61 74 65 73 20 74 68 61 74 20 61 6c ndicates that al
10c0: 6c 20 77 65 6e 74 20 77 65 6c 6c 20 61 6e 64 20 l went well and
10d0: 66 75 72 74 68 65 72 20 70 72 6f 63 65 73 73 69 further processi
10e0: 6e 67 20 6d 61 79 20 63 6f 6e 74 69 6e 75 65 2e ng may continue.
10f0: 0a 2e 54 50 0a 4c 43 5f 43 42 52 45 54 5f 45 52 ..TP.LC_CBRET_ER
1100: 52 4f 52 0a 52 65 74 75 72 6e 6e 69 6e 67 20 4c ROR.Returnning L
1110: 43 5f 43 42 52 45 54 5f 45 52 52 4f 52 20 66 72 C_CBRET_ERROR fr
1120: 6f 6d 20 61 20 63 61 6c 6c 62 61 63 6b 20 69 6e om a callback in
1130: 64 69 63 61 74 65 73 20 74 68 61 74 20 74 68 65 dicates that the
1140: 20 63 6f 6d 6d 61 6e 64 20 66 61 69 6c 65 64 20 command failed
1150: 66 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e 2c for some reason,
1160: 20 74 68 65 20 65 72 72 6f 72 20 77 69 6c 6c 20 the error will
1170: 62 65 20 70 61 73 73 65 64 20 62 61 63 6b 20 64 be passed back d
1180: 6f 77 6e 20 74 68 65 20 63 68 61 69 6e 20 62 61 own the chain ba
1190: 63 6b 20 74 6f 20 74 68 65 0a 2e 42 52 20 6c 63 ck to the..BR lc
11a0: 5f 70 72 6f 63 65 73 73 20 28 33 29 0a 63 61 6c _process (3).cal
11b0: 6c 20 74 68 61 74 20 62 65 67 61 6e 20 70 72 6f l that began pro
11c0: 63 65 73 73 69 6e 67 20 74 68 65 20 63 6f 6e 66 cessing the conf
11d0: 69 67 75 72 61 74 69 6f 6e 20 64 61 74 61 2e 20 iguration data.
11e0: 20 49 66 20 4c 43 5f 43 42 52 45 54 5f 45 52 52 If LC_CBRET_ERR
11f0: 4f 52 20 69 73 20 72 65 74 75 72 6e 65 64 20 66 OR is returned f
1200: 72 6f 6d 20 61 20 63 61 6c 6c 62 61 63 6b 20 74 rom a callback t
1210: 68 61 74 20 62 65 67 69 6e 73 20 61 20 73 65 63 hat begins a sec
1220: 74 69 6f 6e 2c 20 74 68 65 20 65 6e 74 69 72 65 tion, the entire
1230: 20 73 65 63 74 69 6f 6e 20 69 73 20 69 67 6e 6f section is igno
1240: 72 65 64 2e 0a 0a 0a 2e 53 48 20 22 52 45 54 55 red.....SH "RETU
1250: 52 4e 20 56 41 4c 55 45 22 0a 4f 6e 20 73 75 63 RN VALUE".On suc
1260: 63 65 73 73 20 30 20 69 73 20 72 65 74 75 72 6e cess 0 is return
1270: 65 64 2c 20 6f 74 68 65 72 77 69 73 65 20 2d 31 ed, otherwise -1
1280: 20 69 73 20 72 65 74 75 72 6e 65 64 2e 0a 0a 2e is returned....
1290: 53 48 20 45 58 41 4d 50 4c 45 0a 2e 6e 66 0a 23 SH EXAMPLE..nf.#
12a0: 69 6e 63 6c 75 64 65 20 3c 6c 69 62 63 6f 6e 66 include <libconf
12b0: 69 67 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c ig.h>.#include <
12c0: 73 74 72 69 6e 67 73 2e 68 3e 0a 23 69 6e 63 6c strings.h>.#incl
12d0: 75 64 65 20 3c 73 74 64 6c 69 62 2e 68 3e 0a 23 ude <stdlib.h>.#
12e0: 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e 68 include <stdio.h
12f0: 3e 0a 0a 69 6e 74 20 63 61 6c 6c 62 61 63 6b 5f >..int callback_
1300: 69 66 6d 6f 64 75 6c 65 28 63 6f 6e 73 74 20 63 ifmodule(const c
1310: 68 61 72 20 2a 73 68 6f 72 74 76 61 72 2c 20 63 har *shortvar, c
1320: 6f 6e 73 74 20 63 68 61 72 20 2a 76 61 72 2c 0a onst char *var,.
1330: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1340: 20 20 20 20 20 20 63 6f 6e 73 74 20 63 68 61 72 const char
1350: 20 2a 61 72 67 75 6d 65 6e 74 73 2c 20 63 6f 6e *arguments, con
1360: 73 74 20 63 68 61 72 20 2a 76 61 6c 75 65 2c 0a st char *value,.
1370: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1380: 20 20 20 20 20 20 6c 63 5f 66 6c 61 67 73 5f 74 lc_flags_t
1390: 20 66 6c 61 67 73 2c 20 76 6f 69 64 20 2a 65 78 flags, void *ex
13a0: 74 72 61 29 20 7b 0a 09 69 66 20 28 66 6c 61 67 tra) {..if (flag
13b0: 73 20 3d 3d 20 4c 43 5f 46 4c 41 47 53 5f 53 45 s == LC_FLAGS_SE
13c0: 43 54 49 4f 4e 45 4e 44 29 20 7b 0a 09 09 72 65 CTIONEND) {...re
13d0: 74 75 72 6e 28 4c 43 5f 43 42 52 45 54 5f 4f 4b turn(LC_CBRET_OK
13e0: 41 59 29 3b 0a 09 7d 0a 0a 09 69 66 20 28 66 6c AY);..}...if (fl
13f0: 61 67 73 20 21 3d 20 4c 43 5f 46 4c 41 47 53 5f ags != LC_FLAGS_
1400: 53 45 43 54 49 4f 4e 53 54 41 52 54 29 20 7b 0a SECTIONSTART) {.
1410: 09 09 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 ..fprintf(stderr
1420: 2c 20 22 49 66 4d 6f 64 75 6c 65 20 63 61 6e 20 , "IfModule can
1430: 6f 6e 6c 79 20 62 65 20 75 73 65 64 20 61 73 20 only be used as
1440: 61 20 5c 5c 0a 09 09 20 20 20 20 20 20 20 20 73 a \\... s
1450: 65 63 74 69 6f 6e 2e 5c 5c 6e 22 29 3b 0a 09 09 ection.\\n");...
1460: 72 65 74 75 72 6e 28 4c 43 5f 43 42 52 45 54 5f return(LC_CBRET_
1470: 45 52 52 4f 52 29 3b 0a 09 7d 0a 09 69 66 20 28 ERROR);..}..if (
1480: 61 72 67 75 6d 65 6e 74 73 20 3d 3d 20 4e 55 4c arguments == NUL
1490: 4c 29 20 7b 0a 09 09 66 70 72 69 6e 74 66 28 73 L) {...fprintf(s
14a0: 74 64 65 72 72 2c 20 22 59 6f 75 20 6d 75 73 74 tderr, "You must
14b0: 20 73 70 65 63 69 66 79 20 61 6e 20 61 72 67 75 specify an argu
14c0: 6d 65 6e 74 20 74 6f 20 5c 5c 0a 09 09 20 20 20 ment to \\...
14d0: 20 20 20 20 20 49 66 4d 6f 64 75 6c 65 2e 5c 5c IfModule.\\
14e0: 6e 22 29 3b 0a 09 09 72 65 74 75 72 6e 28 4c 43 n");...return(LC
14f0: 5f 43 42 52 45 54 5f 45 52 52 4f 52 29 3b 0a 09 _CBRET_ERROR);..
1500: 7d 0a 0a 09 70 72 69 6e 74 66 28 22 49 66 4d 6f }...printf("IfMo
1510: 64 75 6c 65 20 25 73 5c 5c 6e 22 2c 20 61 72 67 dule %s\\n", arg
1520: 75 6d 65 6e 74 73 29 3b 0a 0a 09 69 66 20 28 73 uments);...if (s
1530: 74 72 63 61 73 65 63 6d 70 28 61 72 67 75 6d 65 trcasecmp(argume
1540: 6e 74 73 2c 20 22 4d 79 4d 6f 64 75 6c 65 22 29 nts, "MyModule")
1550: 20 3d 3d 20 30 29 20 7b 0a 09 09 72 65 74 75 72 == 0) {...retur
1560: 6e 28 4c 43 5f 43 42 52 45 54 5f 49 47 4e 4f 52 n(LC_CBRET_IGNOR
1570: 45 53 45 43 54 49 4f 4e 29 3b 0a 09 7d 0a 0a 09 ESECTION);..}...
1580: 72 65 74 75 72 6e 28 4c 43 5f 43 42 52 45 54 5f return(LC_CBRET_
1590: 4f 4b 41 59 29 3b 0a 7d 0a 0a 69 6e 74 20 6d 61 OKAY);.}..int ma
15a0: 69 6e 28 69 6e 74 20 61 72 67 63 2c 20 63 68 61 in(int argc, cha
15b0: 72 20 2a 2a 61 72 67 76 29 20 7b 0a 09 69 6e 74 r **argv) {..int
15c0: 20 6c 63 5f 72 63 5f 72 65 74 20 3d 20 30 2c 20 lc_rc_ret = 0,
15d0: 6c 63 5f 70 5f 72 65 74 3b 0a 0a 09 6c 63 5f 72 lc_p_ret;...lc_r
15e0: 63 5f 72 65 74 20 3d 20 6c 63 5f 72 65 67 69 73 c_ret = lc_regis
15f0: 74 65 72 5f 63 61 6c 6c 62 61 63 6b 28 22 2a 2e ter_callback("*.
1600: 49 66 4d 6f 64 75 6c 65 22 2c 20 30 2c 20 4c 43 IfModule", 0, LC
1610: 5f 56 41 52 5f 4e 4f 4e 45 2c 0a 09 20 20 20 20 _VAR_NONE,..
1620: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1630: 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 6c cal
1640: 6c 62 61 63 6b 5f 69 66 6d 6f 64 75 6c 65 2c 20 lback_ifmodule,
1650: 4e 55 4c 4c 29 3b 0a 0a 09 69 66 20 28 6c 63 5f NULL);...if (lc_
1660: 72 63 5f 72 65 74 20 21 3d 20 30 29 20 7b 0a 09 rc_ret != 0) {..
1670: 09 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c .fprintf(stderr,
1680: 20 22 45 72 72 6f 72 20 72 65 67 69 73 74 65 72 "Error register
1690: 69 6e 67 20 63 61 6c 6c 62 61 63 6b 2e 5c 5c 6e ing callback.\\n
16a0: 22 29 3b 0a 09 09 72 65 74 75 72 6e 28 45 58 49 ");...return(EXI
16b0: 54 5f 46 41 49 4c 55 52 45 29 3b 0a 09 7d 0a 0a T_FAILURE);..}..
16c0: 09 6c 63 5f 70 5f 72 65 74 20 3d 20 6c 63 5f 70 .lc_p_ret = lc_p
16d0: 72 6f 63 65 73 73 28 61 72 67 63 2c 20 61 72 67 rocess(argc, arg
16e0: 76 2c 20 22 65 78 61 6d 70 6c 65 22 2c 20 4c 43 v, "example", LC
16f0: 5f 43 4f 4e 46 5f 41 50 41 43 48 45 2c 0a 09 20 _CONF_APACHE,..
1700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1710: 20 20 20 20 20 4e 55 4c 4c 29 3b 0a 09 69 66 20 NULL);..if
1720: 28 6c 63 5f 70 5f 72 65 74 20 21 3d 20 30 29 20 (lc_p_ret != 0)
1730: 7b 0a 09 09 66 70 72 69 6e 74 66 28 73 74 64 65 {...fprintf(stde
1740: 72 72 2c 20 22 45 72 72 6f 72 20 70 72 6f 63 65 rr, "Error proce
1750: 73 73 69 6e 67 20 63 6f 6e 66 69 67 75 72 61 74 ssing configurat
1760: 69 6f 6e 3a 20 5c 5c 0a 09 09 20 20 20 20 20 20 ion: \\...
1770: 20 20 25 73 5c 5c 6e 22 2c 20 6c 63 5f 67 65 74 %s\\n", lc_get
1780: 65 72 72 73 74 72 28 29 29 3b 0a 09 09 72 65 74 errstr());...ret
1790: 75 72 6e 28 45 58 49 54 5f 46 41 49 4c 55 52 45 urn(EXIT_FAILURE
17a0: 29 3b 0a 09 7d 0a 0a 09 72 65 74 75 72 6e 28 45 );..}...return(E
17b0: 58 49 54 5f 53 55 43 43 45 53 53 29 3b 0a 7d 0a XIT_SUCCESS);.}.
17c0: 2e 66 69 0a 0a 2e 53 48 20 45 52 52 4f 52 53 0a .fi...SH ERRORS.
17d0: 2e 54 50 0a 2e 42 20 45 4e 4f 4d 45 4d 0a 4d 65 .TP..B ENOMEM.Me
17e0: 6d 6f 72 79 20 63 6f 75 6c 64 20 6e 6f 74 20 62 mory could not b
17f0: 65 20 61 6c 6c 6f 63 61 74 65 64 20 74 6f 20 63 e allocated to c
1800: 72 65 61 74 65 20 74 68 65 20 6e 65 65 64 65 64 reate the needed
1810: 20 69 6e 74 65 72 6e 61 6c 20 73 74 72 75 63 74 internal struct
1820: 75 72 65 73 2e 0a 0a 2e 53 48 20 22 53 45 45 20 ures....SH "SEE
1830: 41 4c 53 4f 22 0a 2e 42 52 20 6c 63 5f 72 65 67 ALSO"..BR lc_reg
1840: 69 73 74 65 72 5f 76 61 72 20 28 33 29 2c 0a 2e ister_var (3),..
1850: 42 52 20 6c 63 5f 67 65 74 65 72 72 6e 6f 20 28 BR lc_geterrno (
1860: 33 29 2c 0a 2e 42 52 20 6c 63 5f 67 65 74 65 72 3),..BR lc_geter
1870: 72 73 74 72 20 28 33 29 2c 0a 2e 42 52 20 6c 63 rstr (3),..BR lc
1880: 5f 70 72 6f 63 65 73 73 20 28 33 29 0a _process (3).