1// 2// tool_errors.h 3// sec 4// 5// Created by Mitch Adler on 1/9/13. 6// 7// 8 9// 10// These functions should be deprectaed! 11// Try to find a better way instead of using them. 12// 13 14#ifndef _TOOL_ERRORS_H_ 15#define _TOOL_ERRORS_H_ 16 17#include <stdarg.h> 18#include <stdio.h> 19#include "SecurityTool/SecurityTool.h" 20 21static inline const char * 22sec_errstr(int err) 23{ 24 const char *errString; 25 static char buffer[12]; 26 27 sprintf(buffer, "%d", err); 28 errString = buffer; 29#if 0 30 if (IS_SEC_ERROR(err)) 31 errString = SECErrorString(err); 32 else 33 errString = cssmErrorString(err); 34#endif 35 return errString; 36} 37 38static inline void 39sec_error(const char *msg, ...) 40{ 41 va_list args; 42 43 fprintf(stderr, "%s: ", prog_name); 44 45 va_start(args, msg); 46 vfprintf(stderr, msg, args); 47 va_end(args); 48 49 fprintf(stderr, "\n"); 50} 51 52static inline void 53sec_perror(const char *msg, int err) 54{ 55 sec_error("%s: %s", msg, sec_errstr(err)); 56} 57 58 59 60#endif 61