int slprintf (char *str, int n, const char *format, ...) { #else int slprintf (va_alist) va_dcl { char *str, *format; int n; #endif va_list ap; int ret; #ifdef HAVE_STDARG_H va_start (ap, format); #else va_start (ap); str = va_arg (ap, char *); n = va_arg (ap, int); format = va_arg (ap, char *); #endif ret = vslprintf (str, n, format, ap); va_end (ap); return ret; }
int slprintf(char *str, int n, char *format, ...) { va_list ap; int ret; va_start(ap, format); ret = vslprintf(str,n,format,ap); va_end(ap); return ret; }
int slprintf_nocheck(char *dst, size_t size, const char *fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vslprintf(dst, size, fmt, ap); va_end(ap); return ret; }
/* ************************************************************************** ** * Add text to the body of the "current" debug message via the format buffer. * * Input: format_str - Format string, as used in printf(), et. al. * ... - Variable argument list. * * ..or.. va_alist - Old style variable parameter list starting point. * * Output: Always True. See dbghdr() for more info, though this is not * likely to be used in the same way. * * ************************************************************************** ** */ BOOL dbgtext( const char *format_str, ... ) { va_list ap; pstring msgbuf; va_start( ap, format_str ); vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap ); va_end( ap ); format_debug_text( msgbuf ); return( True ); } /* dbgtext */
void psi_error_wrapper(struct psi_data *context, struct psi_token *t, int type, const char *msg, ...) { va_list argv; const char *fn = NULL; unsigned ln = 0; if (context) { if (context->flags & PSI_SILENT) { /* context->last_error may be an argument to print */ char error[sizeof(context->last_error)]; va_start(argv, msg); vslprintf(error, sizeof(error), msg, argv); va_end(argv); memcpy(context->last_error, error, sizeof(context->last_error)); return; } } if (t) { fn = t->file->val; ln = t->line; } else if (zend_is_executing()) { fn = zend_get_executed_filename(); ln = zend_get_executed_lineno(); } else if (zend_is_compiling()) { fn = zend_get_compiled_filename()->val; ln = zend_get_compiled_lineno(); } else { fn = "PSI module startup"; } va_start(argv, msg); psi_verror(type, fn, ln, msg, argv); va_end(argv); va_start(argv, msg); PSI_DEBUG_LOCK(context, PSI_DEBUG_PRINTV(context, msg, argv); PSI_DEBUG_PRINT(context, "\n"); );
/* ************************************************************************** ** * Write an debug message on the debugfile. * This is called by dbghdr() and format_debug_text(). * ************************************************************************** ** */ int Debug1( const char *format_str, ... ) { va_list ap; int old_errno = errno; if( stdout_logging ) { va_start( ap, format_str ); if(dbf) (void)vfprintf( dbf, format_str, ap ); va_end( ap ); errno = old_errno; return( 0 ); } #ifdef WITH_SYSLOG if( !lp_syslog_only() ) #endif { if( !dbf ) { mode_t oldumask = umask( 022 ); if( append_log ) dbf = sys_fopen( debugf, "a" ); else dbf = sys_fopen( debugf, "w" ); (void)umask( oldumask ); if( dbf ) { setbuf( dbf, NULL ); } else { errno = old_errno; return(0); } } } #ifdef WITH_SYSLOG if( syslog_level < lp_syslog() ) { /* map debug levels to syslog() priorities * note that not all DEBUG(0, ...) calls are * necessarily errors */ static int priority_map[] = { LOG_ERR, /* 0 */ LOG_WARNING, /* 1 */ LOG_NOTICE, /* 2 */ LOG_INFO, /* 3 */ }; int priority; pstring msgbuf; if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0) priority = LOG_DEBUG; else priority = priority_map[syslog_level]; va_start( ap, format_str ); vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap ); va_end( ap ); msgbuf[255] = '\0'; syslog( priority, "%s", msgbuf ); } #endif check_log_size(); #ifdef WITH_SYSLOG if( !lp_syslog_only() ) #endif { va_start( ap, format_str ); if(dbf) (void)vfprintf( dbf, format_str, ap ); va_end( ap ); if(dbf) (void)fflush( dbf ); } errno = old_errno; return( 0 ); } /* Debug1 */