static void _xprintf(char *fmt,...){ va_list arp; va_start(arp, fmt); xvprintf(fmt, arp); va_end(arp); }
void glp_printf(const char *fmt, ...) { va_list arg; va_start(arg, fmt); xvprintf(fmt, arg); va_end(arg); return; }
void gt_file_xprintf(GtFile *file, const char *format, ...) { va_list va; int rval; va_start(va, format); if ((rval = xvprintf(file, format, va, 0))) { gt_assert(rval > 0); /* negative return is not possible, rval should denote the necessary buffer length -> try again with it */ /* reset variable arguments */ va_end(va); va_start(va, format); /* try again */ rval = xvprintf(file, format, va, rval); gt_assert(!rval); /* xvprintf() should not fail with given buffer length */ } va_end(va); }
void xprintf(char *format, ...) { va_list args; va_start(args, format); xvprintf(format, args); va_end(args); }
void DbgOut( char * msg, ... ) { #ifdef ALLOW_DEBUG_OUTPUT char *buff, *obuff; SYSTEMTIME SystemTime; va_list mylist; GetSystemTime( &SystemTime ); va_start( mylist, msg ); buff = xvprintf(msg, mylist); obuff = xprintf( "%02d:%02d:%02d %03d, Thrd:%05x, %s\r\n", SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds, GetCurrentThreadId(), buff ); #if DBG_OUT == DBG_STRINGS // debug output into debug strings OutputDebugStringA( obuff ); #elif DBG_OUT == DBG_FILE // debug output into file log HANDLE hDbgFile; DWORD dwWritten; if (!dbg_section_initialized) { InitializeCriticalSection( &dbg_logfile ); dbg_section_initialized = true; } EnterCriticalSection ( &dbg_logfile ); hDbgFile = CreateFile( DEBUG_FILE_LOG, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); SetFilePointer( hDbgFile, 0, 0, FILE_END ); WriteFile( hDbgFile, obuff, lstrlen(obuff), &dwWritten, 0 ); CloseHandle( hDbgFile ); LeaveCriticalSection( &dbg_logfile ); #elif DBG_OUT == DBG_BUFF // debug output into global buffer DWORD dwMsgLen = lstrlen(obuff); if ( !dbg_log_buff ) dbg_log_buff = (PCHAR) xalloc ( dwMsgLen + 1 ); else dbg_log_buff = (PCHAR) xrealloc( dbg_log_buff, lstrlen(dbg_log_buff) + dwMsgLen + 1 ); lstrcat( dbg_log_buff, obuff); #endif xfree( buff ); xfree( obuff ); #endif }
void weprintf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); xvprintf(fmt, ap); va_end(ap); }
static void warning(struct csa *csa, const char *fmt, ...) { /* print warning message and continue processing */ va_list arg; xprintf("%s:%d: warning: ", csa->fname, csa->count); va_start(arg, fmt); xvprintf(fmt, arg); va_end(arg); return; }
void glp_sdf_warning(glp_data *data, const char *fmt, ...) { /* print warning message */ va_list arg; xprintf("%s:%d: warning: ", data->fname, data->count); va_start(arg, fmt); xvprintf(fmt, arg); va_end(arg); return; }
static void error(struct csa *csa, const char *fmt, ...) { /* print error message and terminate processing */ va_list arg; xprintf("%s:%d: ", csa->fname, csa->count); va_start(arg, fmt); xvprintf(fmt, arg); va_end(arg); longjmp(csa->jump, 1); /* no return */ }
void __stubprintf (char *file, int line, const char *func, char *format, ...) { va_list args; xfflush (NULL); xprintf ("%s: %s[%d] %s: ", execname, file, line, func); va_start (args, format); xvprintf (format, args); va_end (args); xfflush (NULL); }
/* * Print the error with the given id. * * Special ids: * ERR_SILENT: Print nothing. * ERR_OLD: Print the previously set error * ERR_NAME: If this bit is set, print the name of the function * in bname * * This routine always resets or exits. The flag haderr * is set so the routine who catches the unwind can propogate * it if they want. * * Note that any open files at the point of error will eventually * be closed in the routine process in sh.c which is the only * place error unwinds are ever caught. */ void /*VARARGS*/ stderror(unsigned int id, ...) { va_list va; int flags; va_start(va, id); /* * Reset don't free flag for buggy os's */ dont_free = 0; flags = (int) id & ERR_FLAGS; id &= ~ERR_FLAGS; /* Pyramid's OS/x has a subtle bug in <varargs.h> which prevents calling * va_end more than once in the same function. -- [email protected] */ assert(!((flags & ERR_OLD) && seterr == NULL)); if (id >= sizeof(elst) / sizeof(elst[0])) id = ERR_INVALID; if (!(flags & ERR_SILENT)) { /* * Must flush before we print as we wish output before the error * to go on (some form of) standard output, while output after * goes on (some form of) diagnostic output. If didfds then output * will go to 1/2 else to FSHOUT/FSHDIAG. See flush in sh.print.c. */ flush();/*FIXRESET*/ haderr = 1; /* Now to diagnostic output */ if (flags & ERR_NAME) xprintf("%s: ", bname);/*FIXRESET*/ if ((flags & ERR_OLD)) { /* Old error. */ xprintf("%s.\n", seterr);/*FIXRESET*/ } else { xvprintf(elst[id], va);/*FIXRESET*/ xprintf(".\n");/*FIXRESET*/ } } va_end(va); if (seterr) { xfree(seterr); seterr = NULL; } fixerror(); reset(); /* Unwind */ }
void enprintf(int status, const char *fmt, ...) { va_list ap; va_start(ap, fmt); xvprintf(fmt, ap); va_end(ap); exit(status); }
void glp_sdf_error(glp_data *data, const char *fmt, ...) { /* print error message */ va_list arg; xprintf("%s:%d: ", data->fname, data->count); va_start(arg, fmt); xvprintf(fmt, arg); va_end(arg); if (data->jump == NULL) xerror(""); else longjmp(data->jump, 1); /* no return */ }
void debug_printf(const char *format, ...) { if (debug) { va_list ap; va_start(ap, format); xvprintf(format, ap); va_end(ap); xprintf("\n"); } }
static void error(const char *fmt, ...) { ENV *env = get_env_ptr(); va_list arg; env->term_out = GLP_ON; va_start(arg, fmt); xvprintf(fmt, arg); va_end(arg); xprintf("Error detected in file %s at line %d\n", env->err_file, env->err_line); if (env->err_hook != NULL) env->err_hook(env->err_info); abort(); exit(EXIT_FAILURE); /* no return */ }
void _msg(const char* type, const char* file, const char* func, int line, const char* fmt, ...){ _xprintf("%-10s %-10s %-3d %-8s ",file,func,line,type); { va_list arp; va_start(arp, fmt); xvprintf(fmt, arp); va_end(arp); } _xprintf("\n"); }
/* dprintf(): * Print to $DEBUGTTY, so that we can test editing on one pty, and * print debugging stuff on another. Don't interrupt the shell while * debugging cause you'll mangle up the file descriptors! */ static void dprintf(char *fmt, ...) { static int fd = -1; char *dtty; if ((dtty = getenv("DEBUGTTY"))) { int o; va_list va; va_start(va, fmt); if (fd == -1) fd = xopen(dtty, O_RDWR); o = SHOUT; flush(); SHOUT = fd; xvprintf(fmt, va); va_end(va); flush(); SHOUT = o; } }
#include "error.h" #include "exitfail.h" #include "gettext.h" /* written by Jim Meyering */ /* Just like printf, but call error if it fails without setting the stream's error indicator. */ int xprintf (char const *restrict format, ...) { va_list args; int retval; va_start (args, format); retval = xvprintf (format, args); va_end (args); return retval; } /* Just like vprintf, but call error if it fails without setting the stream's error indicator. */ int xvprintf (char const *restrict format, va_list args) { int retval = vprintf (format, args); if (retval < 0 && ! ferror (stdout)) error (exit_failure, errno, gettext ("cannot perform formatted output")); return retval;
void MW_printf(const char* fmt,...){ va_list arp; va_start(arp, fmt); xvprintf(fmt, arp); va_end(arp); }