+ * in a static variable (real_*). Any function called in these macros must
+ * make sure to restore the errno if it changes it.
+ *
+ * "Pseudo code" for the following macros. <name> is the name of the hooked
+ * function, <fd> is either a file descriptor or a FILE pointer.
+ *
+ * if (!real_<name>) {
+ * real_<name> = dlsym_function(<name>);
+ * if (!initialized) {
+ * init_from_environment();
+ * }
+ * }
+ * if (tracked_fds_find(<fd>)) {
+ * if (force_write_to_non_tty) {
+ * handle = 1;
+ * } else {
+ * handle = isatty(<fd>);
+ * }
+ * } else {
+ * handle = 0;
+ * }
+ *
+ * if (handle) {
+ * handle_<fd>_pre(<fd>);
+ * }
+ * <type> result = real_<name>(<args>);
+ * if (handle) {
+ * handle_<fd>_post(<fd>);
+ * }
+ * return result;
+ */