/*\ ||| Written By Fredrik Hübinette ||| All rights reserved. No warrenties, use at your own risk. ||| This source is distributed under the GNU GENERAL PUBLIC LICENCE, ||| see the file "COPYING" for more information. \*/ /* #define DEBUG */ #define H_LOOP 1 #define H_MANY 2 #define H_STREAM 4 #define H_NOISY 8 #define H_REPEATCOUNT 16 #define H_PRELOAD 32 #define H_DAEMON 64 #define H_EXITS 128 #define H_IGNORE_ERRORS 256 #define H_NOKILL 0x100 #define H_SWALLOW 0x200 #define H_MAXASPECT 0x400 #define H_FILL 0x800 #define H_FILTER 0x1000 #define H_URL 0x2000 #define H_EMBED 0x4000 #define H_NOEMBED 0x8000 #define H_CONTROLS 0x10000 #define H_NOCHECK 0x20000 #define H_HIDDEN 0x40000 #define BUFSIZE (1024*128) #define CHUNK_SIZE 8192 #define PRELOAD 40000 #define PRELOAD_TIME 5 /* seconds */ #define my_timercmp(tvp, cmp, uvp) \ ( (tvp)->tv_sec == (uvp)->tv_sec ? \ (tvp)->tv_usec cmp (uvp)->tv_usec : \ (tvp)->tv_sec cmp (uvp)->tv_sec ) #define INC_TIME(tvp, sec, usec) do { \ (tvp)->tv_usec += (usec); \ (tvp)->tv_sec += (sec); \ if( (tvp)->tv_usec > 1000000 ) { \ (tvp)->tv_sec++ ; (tvp)->tv_usec -= 1000000 ; \ } \ }while(0) #define MAXIMUM(X,Y) ((X)>(Y)?(X):(Y)) #define MINIMUM(X,Y) ((X)<(Y)?(X):(Y)) #ifdef DEBUG static FILE *debug_output=0; static FILE *getout() { if(debug_output) return debug_output; debug_output=fopen("/tmp/ndebug","a+"); fprintf(debug_output,"------------\n"); return debug_output; } static int D(char *fmt, ...) { FILE *f; char buffer[9999]; va_list ap; va_start(ap,fmt); vsnprintf(buffer,sizeof(buffer),fmt,ap); va_end(ap); if((f=getout())) { fprintf(f,"PID%4d: %s",getpid(),buffer); fflush(f); } } #else /* OPTIMIZE ME! */ static int D(char *fmt, ...) { } #endif #ifndef MIN #define MIN(X,Y) ((X)<(Y)?(X):(Y)) #endif #ifndef MAXINT #define MAXINT 0x7fffffff #endif #ifndef USE_SETPGRP #define MY_SETPGRP() setpgid(0,0) #else #ifdef SETPGRP_TAKES_TWO_ARGS #define MY_SETPGRP() setpgrp(0,0) #else #define MY_SETPGRP() setpgrp() #endif #endif