void glp_puts(const char *s) { #ifdef HAVE_ENV ENV *env = get_env_ptr(); /* if terminal output is disabled, do nothing */ if (!env->term_out) goto skip; /* pass the string to the hook routine, if defined */ if (env->term_hook != NULL) { if (env->term_hook(env->term_info, s) != 0) goto skip; } /* write the string on the terminal */ fputs(s, stdout); fflush(stdout); /* write the string on the tee file, if required */ if (env->tee_file != NULL) { fputs(s, env->tee_file); fflush(env->tee_file); } skip: return; #else /* write the string on the terminal */ if (_term_hook_) _term_hook_(s); #endif }
void glp_vprintf(const char *fmt, va_list arg) { ENV *env = get_env_ptr(); /* if terminal output is disabled, do nothing */ if (!env->term_out) goto skip; /* format the output */ vsprintf(env->term_buf, fmt, arg); /* pass the output to the user-defined routine */ if (env->term_hook != NULL) { if (env->term_hook(env->term_info, env->term_buf) != 0) goto skip; } /* send the output to the terminal */ fputs(env->term_buf, stdout); fflush(stdout); /* copy the output to the text file */ if (env->tee_file != NULL) { fputs(env->term_buf, env->tee_file); fflush(env->tee_file); } skip: return; }