blind

suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log | Files | Refs | README | LICENSE

util.h (1061B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "arg.h"
      3 
      4 #if defined(__GNUC__) || defined(__clang__)
      5 # define ATTRIBUTE_NORETURN __attribute__((noreturn))
      6 #else
      7 # define ATTRIBUTE_NORETURN
      8 #endif
      9 
     10 #define ELEMENTSOF(ARRAY) (sizeof(ARRAY) / sizeof(*(ARRAY)))
     11 #define MIN(A, B)         ((A) < (B) ? (A) : (B))
     12 #define MAX(A, B)         ((A) > (B) ? (A) : (B))
     13 #define CLIP(A, B, C)     ((B) < (A) ? (A) : (B) > (C) ? (C) : (B))
     14 #define STRLEN(STR)       (sizeof(STR) - 1)
     15 #define INTSTRLEN(TYPE)   ((sizeof(TYPE) == 1 ? 3 : (5 * sizeof(TYPE) / 2)) + ((TYPE)-1 < 1))
     16 
     17 #define USAGE(SYNOPSIS)\
     18 	NUSAGE(1, SYNOPSIS)
     19 
     20 #define NUSAGE(STATUS, SYNOPSIS)\
     21 	ATTRIBUTE_NORETURN\
     22 	static void usage(void)\
     23 	{ enprintf((STATUS), "usage: %s%s%s\n", argv0, *SYNOPSIS ? " " : "", SYNOPSIS); }
     24 
     25 #include "util/eprintf.h"
     26 #include "util/efflush.h"
     27 #include "util/fshut.h"
     28 #include "util/eopen.h"
     29 #include "util/emalloc.h"
     30 #include "util/to.h"
     31 #include "util/colour.h"
     32 #include "util/io.h"
     33 #include "util/jobs.h"
     34 #include "util/endian.h"
     35 #include "util/efunc.h"