pinentry-dmenu

a pinentry program based on dmenu
git clone anongit@rnpnr.xyz:pinentry-dmenu.git
Log | Files | Refs | Feed | README | LICENSE

util.c (517B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdarg.h>
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 #include <string.h>
      6 
      7 #include "util.h"
      8 
      9 void
     10 die(const char *fmt, ...)
     11 {
     12 	va_list ap;
     13 
     14 	va_start(ap, fmt);
     15 	vfprintf(stderr, fmt, ap);
     16 	va_end(ap);
     17 
     18 	if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
     19 		fputc(' ', stderr);
     20 		perror(NULL);
     21 	} else {
     22 		fputc('\n', stderr);
     23 	}
     24 
     25 	exit(1);
     26 }
     27 
     28 void *
     29 ecalloc(size_t nmemb, size_t size)
     30 {
     31 	void *p;
     32 
     33 	if (!(p = calloc(nmemb, size)))
     34 		die("calloc:");
     35 	return p;
     36 }