char * zt_progname(char *name, int opts) { if (name && *name != '\0') { memset(_progname, '\0', PATH_MAX); if (opts == STRIP_DIR) { zt_cstr_basename(_progname, PATH_MAX, name, NULL); } else { memcpy(_progname, name, MIN(PATH_MAX, strlen(name))); } } return _progname; }
void _zt_log_assertion(const char *s, const char *file, unsigned int line, const char *func) { char bname[PATH_MAX]; if (!s) { s = "no assertion given"; } (void)zt_cstr_basename(bname, PATH_MAX, file, NULL); if (func) { zt_log_printf(zt_log_err, "Assertion Failed: \"%s\": %s[%d:%s]", s, bname, line, func); } else { zt_log_printf(zt_log_err, "Assertion Failed: \"%s\": %s[%d]", s, bname, line); } }
int _zt_log_abort(const char *s, const char *file, unsigned int line, const char *func) { char bname[PATH_MAX]; if (!s) { s = "no message given"; } (void)zt_cstr_basename(bname, PATH_MAX, file, NULL); if (func) { zt_log_printf(zt_log_crit, "Exiting: \"%s\": %s[%d:%s]", s, bname, line, func); } else { zt_log_printf(zt_log_crit, "Exiting: \"%s\": %s[%d]", s, bname, line); } return 0; }