plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

misc.h (1121B)


      1 #include	<stdio.h>
      2 #include	<stdlib.h>
      3 #include	<math.h>
      4 #include	<ctype.h>
      5 #include	<string.h>
      6 
      7 // XXX: Apparently necessary for g++
      8 #define	typename tyname
      9 
     10 extern char	errbuf[];
     11 extern char	*progname;
     12 extern int	linenum;
     13 extern int	wantwarn;
     14 
     15 // #define	ERROR	fflush(stdout), fprintf(stderr, "%s: ", progname), fprintf(stderr,
     16 // #define	FATAL	), exit(1)
     17 // #define	WARNING	)
     18 
     19 #define	ERROR	fprintf(stdout, "\n#MESSAGE TO USER:  "), sprintf(errbuf,
     20 #define	FATAL	), fputs(errbuf, stdout), \
     21 		fprintf(stderr, "%s: ", progname), \
     22 		fputs(errbuf, stderr), \
     23 		fflush(stdout), \
     24 		exit(1)
     25 #define	WARNING	), fputs(errbuf, stdout), \
     26 		wantwarn ? \
     27 			fprintf(stderr, "%s: ", progname), \
     28 			fputs(errbuf, stderr) : 0, \
     29 		fflush(stdout)
     30 
     31 #define	eq(s,t)	(strcmp(s,t) == 0)
     32 
     33 inline int	max(int x, int y)	{ return x > y ? x : y; }
     34 inline int	min(int x, int y)	{ return x > y ? y : x; }
     35 inline int	abs(int x)		{ return (x >= 0) ? x : -x; }
     36 
     37 extern int	dbg;
     38 
     39 extern int	pn, userpn;		// actual and user-defined page numbers
     40 extern int	pagetop, pagebot;	// printing margins
     41 extern int	physbot;		// physical bottom of the page