/** * CUnit error handler * Log message in a global var instead of printing in stderr * * CAUTION: Not stop execution on rterror case !!! */ static void cu_error_reporter(const char *fmt, va_list ap) { char *msg; /** This is a GNU extension. * Dunno how to handle errors here. */ if (!lw_vasprintf (&msg, fmt, ap)) { va_end (ap); return; } strncpy(cu_error_msg, msg, MAX_CUNIT_MSG_LENGTH); rtdealloc(msg); }
void default_noticereporter(const char *fmt, va_list ap) { char *msg; /* * This is a GNU extension. * Dunno how to handle errors here. */ if (!lw_vasprintf (&msg, fmt, ap)) { va_end (ap); return; } printf("%s\n", msg); free(msg); }
void pg_notice(const char *fmt, va_list ap) { char *msg; /* * This is a GNU extension. * Dunno how to handle errors here. */ if (!lw_vasprintf (&msg, fmt, ap)) { va_end (ap); return; } ereport(NOTICE, (errmsg_internal("%s", msg))); free(msg); }
/* Append variadic formatted string to a stringbuffer */ void vasbappend(stringbuffer_t *sb, char *fmt, ... ) { va_list ap; char *msg; va_start(ap, fmt); if (!lw_vasprintf (&msg, fmt, ap)) { va_end (ap); return; } /* Append to the stringbuffer */ stringbuffer_append(sb, msg); free(msg); va_end(ap); }