Imported Upstream version 1.8.0
[platform/upstream/augeas.git] / src / internal.h
1 /*
2  * internal.h: Useful definitions
3  *
4  * Copyright (C) 2007-2017 David Lutterkort
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
19  *
20  * Author: David Lutterkort <dlutter@redhat.com>
21  */
22
23 #ifndef INTERNAL_H_
24 #define INTERNAL_H_
25
26 #include "list.h"
27 #include "datadir.h"
28 #include "augeas.h"
29
30 #include <stdio.h>
31 #include <string.h>
32 #include <strings.h>
33 #include <stdlib.h>
34 #include <stdbool.h>
35 #include <unistd.h>
36 #include <errno.h>
37 #include <assert.h>
38 #include <locale.h>
39 #include <stdint.h>
40
41 /*
42  * Various parameters about env vars, special tree nodes etc.
43  */
44
45 /* Define: AUGEAS_LENS_DIR
46  * The default location for lens definitions */
47 #define AUGEAS_LENS_DIR DATADIR "/augeas/lenses"
48
49 /* The directory where we install lenses distribute with Augeas */
50 #define AUGEAS_LENS_DIST_DIR DATADIR "/augeas/lenses/dist"
51
52 /* Define: AUGEAS_ROOT_ENV
53  * The env var that points to the chroot holding files we may modify.
54  * Mostly useful for testing */
55 #define AUGEAS_ROOT_ENV "AUGEAS_ROOT"
56
57 /* Define: AUGEAS_FILES_TREE
58  * The root for actual file contents */
59 #define AUGEAS_FILES_TREE "/files"
60
61 /* Define: AUGEAS_META_TREE
62  * Augeas reports some information in this subtree */
63 #define AUGEAS_META_TREE "/augeas"
64
65 /* Define: AUGEAS_META_FILES
66  * Information about files */
67 #define AUGEAS_META_FILES AUGEAS_META_TREE AUGEAS_FILES_TREE
68
69 /* Define: AUGEAS_META_TEXT
70  * Information about text (see aug_text_store and aug_text_retrieve) */
71 #define AUGEAS_META_TEXT AUGEAS_META_TREE "/text"
72
73 /* Define: AUGEAS_META_ROOT
74  * The root directory */
75 #define AUGEAS_META_ROOT AUGEAS_META_TREE "/root"
76
77 /* Define: AUGEAS_META_SAVE_MODE
78  * How we save files. One of 'backup', 'overwrite' or 'newfile' */
79 #define AUGEAS_META_SAVE_MODE AUGEAS_META_TREE "/save"
80
81 /* Define: AUGEAS_CLONE_IF_RENAME_FAILS
82  * Control what save does when renaming the temporary file to its final
83  * destination fails with EXDEV or EBUSY: when this tree node exists, copy
84  * the file contents. If it is not present, simply give up and report an
85  * error.  */
86 #define AUGEAS_COPY_IF_RENAME_FAILS \
87     AUGEAS_META_SAVE_MODE "/copy_if_rename_fails"
88
89 /* Define: AUGEAS_CONTEXT
90  * Context prepended to all non-absolute paths */
91 #define AUGEAS_CONTEXT AUGEAS_META_TREE "/context"
92
93 /* A hierarchy where we record certain 'events', e.g. which tree
94  * nodes actually gotsaved into files */
95 #define AUGEAS_EVENTS AUGEAS_META_TREE "/events"
96
97 #define AUGEAS_EVENTS_SAVED AUGEAS_EVENTS "/saved"
98
99 /* Where to put information about parsing of path expressions */
100 #define AUGEAS_META_PATHX AUGEAS_META_TREE "/pathx"
101
102 /* Define: AUGEAS_SPAN_OPTION
103  * Enable or disable node indexes */
104 #define AUGEAS_SPAN_OPTION AUGEAS_META_TREE "/span"
105
106 /* Define: AUGEAS_LENS_ENV
107  * Name of env var that contains list of paths to search for additional
108    spec files */
109 #define AUGEAS_LENS_ENV "AUGEAS_LENS_LIB"
110
111 /* Define: MAX_ENV_SIZE
112  * Fairly arbitrary bound on the length of the path we
113  *  accept from AUGEAS_SPEC_ENV */
114 #define MAX_ENV_SIZE 4096
115
116 /* Define: PATH_SEP_CHAR
117  * Character separating paths in a list of paths */
118 #define PATH_SEP_CHAR ':'
119
120 /* Constants for setting the save mode via the augeas path at
121  * AUGEAS_META_SAVE_MODE */
122 #define AUG_SAVE_BACKUP_TEXT "backup"
123 #define AUG_SAVE_NEWFILE_TEXT "newfile"
124 #define AUG_SAVE_NOOP_TEXT "noop"
125 #define AUG_SAVE_OVERWRITE_TEXT "overwrite"
126
127 /* constants for options in the tree */
128 #define AUG_ENABLE "enable"
129 #define AUG_DISABLE "disable"
130
131 /* default value for the relative path context */
132 #define AUG_CONTEXT_DEFAULT "/files"
133
134 #ifdef __GNUC__
135
136 #ifndef __GNUC_PREREQ
137 #define __GNUC_PREREQ(maj,min) 0
138 #endif
139
140 /**
141  * ATTRIBUTE_UNUSED:
142  *
143  * Macro to flag conciously unused parameters to functions
144  */
145 #ifndef ATTRIBUTE_UNUSED
146 #define ATTRIBUTE_UNUSED __attribute__((__unused__))
147 #endif
148
149 /**
150  * ATTRIBUTE_FORMAT
151  *
152  * Macro used to check printf/scanf-like functions, if compiling
153  * with gcc.
154  */
155 #ifndef ATTRIBUTE_FORMAT
156 #define ATTRIBUTE_FORMAT(args...) __attribute__((__format__ (args)))
157 #endif
158
159 #ifndef ATTRIBUTE_PURE
160 #define ATTRIBUTE_PURE __attribute__((pure))
161 #endif
162
163 #ifndef ATTRIBUTE_RETURN_CHECK
164 #if __GNUC_PREREQ (3, 4)
165 #define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
166 #else
167 #define ATTRIBUTE_RETURN_CHECK
168 #endif
169 #endif
170
171 /* A poor man's macro to get some move semantics: return the value of P but
172    set P itself to NULL. This has the effect that if you say 'x = move(y)'
173    that there is still only one pointer pointing to the memory Y pointed to
174    initially.
175  */
176 #define move(p) ({ typeof(p) _tmp = (p); (p) = NULL; _tmp; })
177
178 #else
179 #define ATTRIBUTE_UNUSED
180 #define ATTRIBUTE_FORMAT(...)
181 #define ATTRIBUTE_PURE
182 #define ATTRIBUTE_RETURN_CHECK
183 #define move(p) p
184 #endif                                   /* __GNUC__ */
185
186 #define ARRAY_CARDINALITY(array) (sizeof (array) / sizeof *(array))
187
188 /* String equality tests, suggested by Jim Meyering. */
189 #define STREQ(a,b) (strcmp((a),(b)) == 0)
190 #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
191 #define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
192 #define STRNEQ(a,b) (strcmp((a),(b)) != 0)
193 #define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
194 #define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
195 #define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
196
197 ATTRIBUTE_PURE
198 static inline int streqv(const char *a, const char *b) {
199     if (a == NULL || b == NULL)
200         return a == b;
201     return STREQ(a,b);
202 }
203
204 /* Path length and comparison */
205
206 #define SEP '/'
207
208 /* Length of PATH without any trailing '/' */
209 ATTRIBUTE_PURE
210 static inline int pathlen(const char *path) {
211     int len = strlen(path);
212
213     if (len > 0 && path[len-1] == SEP)
214         len--;
215
216     return len;
217 }
218
219 /* Return 1 if P1 is a prefix of P2. P1 as a string must have length <= P2 */
220 ATTRIBUTE_PURE
221 static inline int pathprefix(const char *p1, const char *p2) {
222     if (p1 == NULL || p2 == NULL)
223         return 0;
224     int l1 = pathlen(p1);
225
226     return STREQLEN(p1, p2, l1) && (p2[l1] == '\0' || p2[l1] == SEP);
227 }
228
229 static inline int pathendswith(const char *path, const char *basenam) {
230     const char *p = strrchr(path, SEP);
231     if (p == NULL)
232         return 0;
233     return streqv(p+1, basenam);
234 }
235
236 /* Join NSEG path components (passed as const char *) into one PATH.
237    Allocate as needed. Return 0 on success, -1 on failure */
238 int pathjoin(char **path, int nseg, ...);
239
240 /* Call calloc to allocate an array of N instances of *VAR */
241 #define CALLOC(Var,N) do { (Var) = calloc ((N), sizeof (*(Var))); } while (0)
242
243 #define MEMZERO(ptr, n) memset((ptr), 0, (n) * sizeof(*(ptr)));
244
245 #define MEMCPY(dest, src, n) memcpy((dest), (src), (n) * sizeof(*(src)))
246
247 #define MEMMOVE(dest, src, n) memmove((dest), (src), (n) * sizeof(*(src)))
248
249 /**
250  * TODO:
251  *
252  * macro to flag unimplemented blocks
253  */
254 #define TODO                                                            \
255     fprintf(stderr, "%s:%d Unimplemented block\n",                      \
256             __FILE__, __LINE__);
257
258 #define FIXME(msg, args ...)                            \
259     do {                                                \
260         fprintf(stderr, "%s:%d Fixme: ",                \
261                 __FILE__, __LINE__);                    \
262       fprintf(stderr, msg, ## args);                    \
263       fputc('\n', stderr);                              \
264     } while(0)
265
266 /*
267  * Internal data structures
268  */
269
270 // internal.c
271
272 /* Function: escape
273  * Escape nonprintable characters within TEXT, similar to how it's done in
274  * C string literals. Caller must free the returned string.
275  */
276 char *escape(const char *text, int cnt, const char *extra);
277
278 /* Function: unescape */
279 char *unescape(const char *s, int len, const char *extra);
280
281 /* Extra characters to be escaped in strings and regexps respectively */
282 #define STR_ESCAPES "\"\\"
283 #define RX_ESCAPES  "/\\"
284
285 /* Function: print_chars */
286 int print_chars(FILE *out, const char *text, int cnt);
287
288 /* Function: print_pos
289  * Print a pretty representation of being at position POS within TEXT */
290 void print_pos(FILE *out, const char *text, int pos);
291 char *format_pos(const char *text, int pos);
292
293 /* Function: xread_file
294  * Read the contents of file PATH and return them as one long string. The
295  * caller must free the result. Return NULL if any error occurs.
296  */
297 char* xread_file(const char *path);
298
299 /* Like xread_file, but caller supplies a file pointer */
300 char* xfread_file(FILE *fp);
301
302 /* Get the error message for ERRNUM in a threadsafe way. Based on libvirt's
303  * virStrError
304  */
305 const char *xstrerror(int errnum, char *buf, size_t len);
306
307 /* Like asprintf, but set *STRP to NULL on error */
308 int xasprintf(char **strp, const char *format, ...);
309
310 /* Convert S to RESULT with error checking */
311 int xstrtoint64(char const *s, int base, int64_t *result);
312
313 /* Calculate line and column number of character POS in TEXT */
314 void calc_line_ofs(const char *text, size_t pos, size_t *line, size_t *ofs);
315
316 /* Cleans path from user, removing trailing slashes and whitespace */
317 char *cleanpath(char *path);
318
319 /* Take the first LEN characters from the regexp *U and expand any
320  * character ranges in it. The expanded regexp, if expansion is necessary,
321  * is in U, and the old string is freed. If expansion is not needed or an
322  * error happens, U will be unchanged.
323  *
324  * Return 0 if expansion is not necessary, -1 if an error occurs, and 1 if
325  * expansion was needed.
326  */
327 int regexp_c_locale(char **u, size_t *len);
328
329 /* Struct: augeas
330  * The data structure representing a connection to Augeas. */
331 struct augeas {
332     struct tree      *origin;     /* Actual tree root is origin->children */
333     const char       *root;       /* Filesystem root for all files */
334                                   /* always ends with '/' */
335     unsigned int      flags;      /* Flags passed to AUG_INIT */
336     struct module    *modules;    /* Loaded modules */
337     size_t            nmodpath;
338     char             *modpathz;   /* The search path for modules as a
339                                      glibc argz vector */
340     struct pathx_symtab *symtab;
341     struct error        *error;
342     uint                api_entries;  /* Number of entries through a public
343                                        * API, 0 when called from outside */
344 #if HAVE_USELOCALE
345     /* On systems that have a uselocale call, we switch to the C locale
346      * on entry into API functions, and back to the old user locale
347      * on exit.
348      * FIXME: We need some solution for systems without uselocale, like
349      * setlocale + critical section, though that is very heavy-handed
350      */
351     locale_t            c_locale;
352     locale_t            user_locale;
353 #endif
354 };
355
356 static inline struct error *err_of_aug(const struct augeas *aug) {
357     return ((struct augeas *) aug)->error;
358 }
359
360 /* Used by augparse for loading tests */
361 int __aug_load_module_file(struct augeas *aug, const char *filename);
362
363 /* Called at beginning and end of every _public_ API function */
364 void api_entry(const struct augeas *aug);
365 void api_exit(const struct augeas *aug);
366
367 /* Struct: tree
368  * An entry in the global config tree. The data structure allows associating
369  * values with interior nodes, but the API currently marks that as an error.
370  *
371  * To make dealing with parents uniform, even for the root, we create
372  * standalone trees with a fake root, called origin. That root is generally
373  * not referenced from anywhere. Standalone trees should be created with
374  * MAKE_TREE_ORIGIN.
375  *
376  * The DIRTY flag is used to track which parts of the tree might need to be
377  * saved. For any node that is marked dirty, all of its ancestors must be
378  * marked dirty, too. Instead of setting this flag directly, the function
379  * TREE_MARK_DIRTY in augeas.c should be used (and only functions in that
380  * file should have a need to mark nodes as dirty)
381  *
382  * The FILE flag is set for entries underneath /augeas/files that hold the
383  * metadata for a file by ADD_FILE_INFO. The FILE flag is set for entries
384  * underneath /files for the toplevel node corresponding to a file by
385  * TREE_FREPLACE and is used by AUG_SOURCE to find the file to which a node
386  * belongs.
387  */
388 struct tree {
389     struct tree *next;
390     struct tree *parent;     /* Points to self for root */
391     char        *label;      /* Last component of PATH */
392     struct tree *children;   /* List of children through NEXT */
393     char        *value;
394     struct span *span;
395
396     /* Flags */
397     bool         dirty;
398     bool         file;
399     bool         added;      /* only used by ns_add and tree_rm to dedupe
400                                 nodesets */
401 };
402
403 /* The opaque structure used to represent path expressions. API's
404  * using STRUCT PATHX are declared farther below
405  */
406 struct pathx;
407
408 #define ROOT_P(t) ((t) != NULL && (t)->parent == (t)->parent->parent)
409
410 #define TREE_HIDDEN(tree) ((tree)->label == NULL)
411
412 /* Function: make_tree
413  * Allocate a new tree node with the given LABEL, VALUE, and CHILDREN,
414  * which are not copied. The new tree is marked as dirty
415  */
416 struct tree *make_tree(char *label, char *value,
417                        struct tree *parent, struct tree *children);
418
419 /* Mark a tree as a standalone tree; this creates a fake parent for ROOT,
420  * so that even ROOT has a parent. A new node with only child ROOT is
421  * returned on success, and NULL on failure.
422  */
423 struct tree  *make_tree_origin(struct tree *root);
424
425 /* Make a new tree node and append it to parent's children */
426 struct tree *tree_append(struct tree *parent, char *label, char *value);
427
428 int tree_rm(struct pathx *p);
429 int tree_unlink(struct augeas *aug, struct tree *tree);
430 struct tree *tree_set(struct pathx *p, const char *value);
431 int tree_insert(struct pathx *p, const char *label, int before);
432 int free_tree(struct tree *tree);
433 int dump_tree(FILE *out, struct tree *tree);
434 int tree_equal(const struct tree *t1, const struct tree *t2);
435 char *path_expand(struct tree *tree, const char *ppath);
436 char *path_of_tree(struct tree *tree);
437 /* Clear the dirty flag in the whole TREE */
438 void tree_clean(struct tree *tree);
439 /* Return first child with label LABEL or NULL */
440 struct tree *tree_child(struct tree *tree, const char *label);
441 /* Return first existing child with label LABEL or create one. Return NULL
442  * when allocation fails */
443 struct tree *tree_child_cr(struct tree *tree, const char *label);
444 /* Create a path in the tree; nodes along the path are looked up with
445  * tree_child_cr */
446 struct tree *tree_path_cr(struct tree *tree, int n, ...);
447 /* Store VALUE directly as the value of TREE and set VALUE to NULL.
448  * Update dirty flags */
449 void tree_store_value(struct tree *tree, char **value);
450 /* Set the value of TREE to a copy of VALUE and update dirty flags */
451 int tree_set_value(struct tree *tree, const char *value);
452 /* Cleanly remove all children of TREE, but leave TREE itself unchanged */
453 void tree_unlink_children(struct augeas *aug, struct tree *tree);
454 /* Find a node in the tree at path FPATH; FPATH is a file path, i.e.
455  * not interpreted as a path expression. If no such node exists, return NULL
456  */
457 struct tree *tree_fpath(struct augeas *aug, const char *fpath);
458 /* Find a node in the tree at path FPATH; FPATH is a file path, i.e.
459  * not interpreted as a path expression. If no such node exists, create
460  * it and all its missing ancestors.
461  */
462 struct tree *tree_fpath_cr(struct augeas *aug, const char *fpath);
463 /* Find the node matching PATH.
464  * Returns the node or NULL on error
465  * Errors: EMMATCH - more than one node matches PATH
466  *         ENOMEM  - allocation error
467  */
468 struct tree *tree_find(struct augeas *aug, const char *path);
469 /* Find the node matching PATH. Expand the tree to contain such a node if
470  * none exists.
471  * Returns the node or NULL on error
472  */
473 struct tree *tree_find_cr(struct augeas *aug, const char *path);
474 /* Find the node at the path stored in AUGEAS_CONTEXT, i.e. the root context
475  * node for relative paths.
476  * Errors: EMMATCH - more than one node matches PATH
477  *         ENOMEM  - allocation error
478  */
479 struct tree *tree_root_ctx(const struct augeas *aug);
480
481 /* Struct: memstream
482  * Wrappers to simulate OPEN_MEMSTREAM where that's not available. The
483  * STREAM member is opened by INIT_MEMSTREAM and closed by
484  * CLOSE_MEMSTREAM. The BUF is allocated automatically, but can not be used
485  * until after CLOSE_MEMSTREAM has been called. It is the callers
486  * responsibility to free up BUF.
487  */
488 struct memstream {
489     FILE   *stream;
490     char   *buf;
491     size_t size;
492 };
493
494 /* Function: init_memstream
495  * Initialize a memstream. On systems that have OPEN_MEMSTREAM, it is used
496  * to open MS->STREAM. On systems without OPEN_MEMSTREAM, MS->STREAM is
497  * backed by a temporary file.
498  *
499  * MS must be allocated in advance; INIT_MEMSTREAM initializes it.
500  */
501 int __aug_init_memstream(struct memstream *ms);
502 #define init_memstream(ms) __aug_init_memstream(ms);
503
504 /* Function: close_memstream
505  * Close a memstream. After calling this, MS->STREAM can not be used
506  * anymore and a string representing whatever was written to it is
507  * available in MS->BUF. The caller must free MS->BUF.
508  *
509  * The caller must free the MEMSTREAM structure.
510  */
511 int __aug_close_memstream(struct memstream *ms);
512 #define close_memstream(ms) __aug_close_memstream(ms)
513
514 /*
515  * Path expressions
516  */
517
518 typedef enum {
519     PATHX_NOERROR = 0,
520     PATHX_ENAME,
521     PATHX_ESTRING,
522     PATHX_ENUMBER,
523     PATHX_EDELIM,
524     PATHX_ENOEQUAL,
525     PATHX_ENOMEM,
526     PATHX_EPRED,
527     PATHX_EPAREN,
528     PATHX_ESLASH,
529     PATHX_EINTERNAL,
530     PATHX_ETYPE,
531     PATHX_ENOVAR,
532     PATHX_EEND,
533     PATHX_ENOMATCH,
534     PATHX_EARITY,
535     PATHX_EREGEXP,
536     PATHX_EMMATCH,
537     PATHX_EREGEXPFLAG
538 } pathx_errcode_t;
539
540 struct pathx;
541 struct pathx_symtab;
542
543 const char *pathx_error(struct pathx *pathx, const char **txt, int *pos);
544
545 /* Parse a path expression PATH rooted at TREE, which is a node somewhere
546  * in AUG->ORIGIN. If TREE is NULL, AUG->ORIGIN is used. If ROOT_CTX is not
547  * NULL and the PATH isn't absolute then it will be rooted at ROOT_CTX.
548  *
549  * Use this function rather than PATHX_PARSE for path expressions inside
550  * the tree in AUG->ORIGIN.
551  *
552  * If NEED_NODESET is true, the resulting path expression must evaluate toa
553  * nodeset, otherwise it can evaluate to a value of any type.
554  *
555  * Return the resulting path expression, or NULL on error. If an error
556  * occurs, the error struct in AUG contains details.
557  */
558 struct pathx *pathx_aug_parse(const struct augeas *aug,
559                               struct tree *tree,
560                               struct tree *root_ctx,
561                               const char *path, bool need_nodeset);
562
563 /* Parse the string PATH into a path expression PX that will be evaluated
564  * against the tree ORIGIN.
565  *
566  * If NEED_NODESET is true, the resulting path expression must evaluate toa
567  * nodeset, otherwise it can evaluate to a value of any type.
568  *
569  * Returns 0 on success, and -1 on error
570  */
571 int pathx_parse(const struct tree *origin,
572                 struct error *err,
573                 const char *path,
574                 bool need_nodeset,
575                 struct pathx_symtab *symtab,
576                 struct tree *root_ctx,
577                 struct pathx **px);
578 /* Return the error struct that was passed into pathx_parse */
579 struct error *err_of_pathx(struct pathx *px);
580 struct tree *pathx_first(struct pathx *path);
581 struct tree *pathx_next(struct pathx *path);
582 /* Return -1 if evalutating PATH runs into trouble, otherwise return the
583  * number of nodes matching PATH and set MATCH to the first matching
584  * node */
585 int pathx_find_one(struct pathx *path, struct tree **match);
586 int pathx_expand_tree(struct pathx *path, struct tree **tree);
587 void free_pathx(struct pathx *path);
588
589 struct pathx_symtab *pathx_get_symtab(struct pathx *pathx);
590 int pathx_symtab_define(struct pathx_symtab **symtab,
591                         const char *name, struct pathx *px);
592 /* Returns 1 on success, and -1 when out of memory */
593 int pathx_symtab_assign_tree(struct pathx_symtab **symtab, const char *name,
594                              struct tree *tree);
595 int pathx_symtab_undefine(struct pathx_symtab **symtab, const char *name);
596 void pathx_symtab_remove_descendants(struct pathx_symtab *symtab,
597                                      const struct tree *tree);
598 void free_symtab(struct pathx_symtab *symtab);
599
600 /* Escape a name so that it is safe to pass to parse_name and have it
601  * interpreted as the literal name of a path component.
602  *
603  * On return, *OUT will be NULL if IN does not need escaping, otherwise it
604  * will contain an escaped copy of IN which the caller must free.
605  *
606  * Returns -1 if it failed to allocate memory for *OUT, 0 on success
607  */
608 int pathx_escape_name(const char *in, char **out);
609
610 /* Debug helpers, all defined in internal.c. When ENABLE_DEBUG is not
611  * set, they compile to nothing.
612  */
613 #  if ENABLE_DEBUG
614   /* Return true if debugging for CATEGORY is turned on */
615   bool debugging(const char *category);
616   /* Format the arguments into a file name, prepend it with the directory
617    * from the environment variable AUGEAS_DEBUG_DIR, and open the file for
618    * writing.
619   */
620   FILE *debug_fopen(const char *format, ...)
621     ATTRIBUTE_FORMAT(printf, 1, 2);
622 #  else
623 #    define debugging(facility) (0)
624 #    define debug_fopen(format ...) (NULL)
625 #  endif
626 #endif
627
628
629 /*
630  * Local variables:
631  *  indent-tabs-mode: nil
632  *  c-indent-level: 4
633  *  c-basic-offset: 4
634  *  tab-width: 4
635  * End:
636  */