status

statusbar program for dwm
git clone anongit@rnpnr.xyz:status.git
Log | Files | Refs | Feed | README | LICENSE

util.c (448B)


      1 /* See LICENSE for license details. */
      2 #include <stdarg.h>
      3 
      4 static void
      5 die(const char *errstr, ...)
      6 {
      7 	va_list ap;
      8 
      9 	va_start(ap, errstr);
     10 	vfprintf(stderr, errstr, ap);
     11 	va_end(ap);
     12 	exit(1);
     13 }
     14 
     15 static int
     16 pscanf(const char *path, const char *fmt, ...)
     17 {
     18 	FILE *fp;
     19 	va_list ap;
     20 	int ret;
     21 
     22 	if (!(fp = fopen(path, "r")))
     23 		return -1;
     24 
     25 	va_start(ap, fmt);
     26 	ret = vfscanf(fp, fmt, ap);
     27 	va_end(ap);
     28 	fclose(fp);
     29 
     30 	return (ret == EOF) ? -1 : ret;
     31 }