Diff

Differences From Artifact [cea18abe88]:

To Artifact [caede5b68d]:


149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
.TP
LC_CBRET_OKAY
Returning LC_CBRET_OKAY from a callback indicates that all went well and further processing may continue.
.TP
LC_CBRET_ERROR
Returnning LC_CBRET_ERROR from a callback indicates that the command failed for some reason, the error will be passed back down the chain back to the
.BR lc_process (3)
call that began processing the configuration data.  If LC_CBRET_ERROR is returned from a callback that begins a section, the entire section is ignored.


.SH "RETURN VALUE"
On success 0 is returned, otherwise -1 is returned.

.SH EXAMPLE
.nf
#include <libconfig.h>
#include <strings.h>
#include <stdlib.h>
#include <stdio.h>

int callback_ifmodule(const char *shortvar, const char *var,
                      const char *arguments, const char *value,
                      lc_flags_t flags, void *extra) {
	if (flags == LC_FLAGS_SECTIONEND) {
		return(LC_CBRET_OKAY);
	}

	if (flags != LC_FLAGS_SECTIONSTART) {
		fprintf(stderr, "IfModule can only be used as a \\
		        section.\\n");
		return(LC_CBRET_ERROR);
	}
	if (arguments == NULL) {
		fprintf(stderr, "You must specify an argument to \\
		        IfModule.\\n");
		return(LC_CBRET_ERROR);
	}

	printf("IfModule %s\\n", arguments);

	if (strcasecmp(arguments, "MyModule") == 0) {
		return(LC_CBRET_IGNORESECTION);







|




















|
|



|
|







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
.TP
LC_CBRET_OKAY
Returning LC_CBRET_OKAY from a callback indicates that all went well and further processing may continue.
.TP
LC_CBRET_ERROR
Returnning LC_CBRET_ERROR from a callback indicates that the command failed for some reason, the error will be passed back down the chain back to the
.BR lc_process (3)
call that began processing the configuration data.  If LC_CBRET_ERROR is returned from a callback that begins a section, the entire section is ignored.  If LC_CBRET_ERROR is returned from a callback that ends a section, the error is ignored.


.SH "RETURN VALUE"
On success 0 is returned, otherwise -1 is returned.

.SH EXAMPLE
.nf
#include <libconfig.h>
#include <strings.h>
#include <stdlib.h>
#include <stdio.h>

int callback_ifmodule(const char *shortvar, const char *var,
                      const char *arguments, const char *value,
                      lc_flags_t flags, void *extra) {
	if (flags == LC_FLAGS_SECTIONEND) {
		return(LC_CBRET_OKAY);
	}

	if (flags != LC_FLAGS_SECTIONSTART) {
		lc_seterrstr("IfModule can only be used as a \\
		              section.");
		return(LC_CBRET_ERROR);
	}
	if (arguments == NULL) {
		lc_seterrstr("You must specify an argument to \\
		              IfModule.");
		return(LC_CBRET_ERROR);
	}

	printf("IfModule %s\\n", arguments);

	if (strcasecmp(arguments, "MyModule") == 0) {
		return(LC_CBRET_IGNORESECTION);
221
222
223
224
225
226
227

228
229
230

231
232
233

.SH ERRORS
.TP
.B ENOMEM
Memory could not be allocated to create the needed internal structures.

.SH "SEE ALSO"

.BR lc_register_var (3),
.BR lc_geterrno (3),
.BR lc_geterrstr (3),

.BR lc_cleanup (3),
.BR lc_process_file (3),
.BR lc_process (3)







>



>



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235

.SH ERRORS
.TP
.B ENOMEM
Memory could not be allocated to create the needed internal structures.

.SH "SEE ALSO"
.BR libconfig (3),
.BR lc_register_var (3),
.BR lc_geterrno (3),
.BR lc_geterrstr (3),
.BR lc_seterrstr (3),
.BR lc_cleanup (3),
.BR lc_process_file (3),
.BR lc_process (3)