/* CROND & CRONTAB: (c) Kees Lemmens, Netherlands; June 1993.

	Programs for ATARI ST (running under MINT) to make it possible
	to run background jobs at regular intervals.

	This file was in fact only needed to test cron during development.
	When compiling without the DEBUG option, none of the functions in
	this file will be called.
	  
	Any questions or suggestions about this program can be send to:
	lemmens@dv.twi.tudelft.nl
*/

#include <stdio.h>
#include <stdarg.h>
#include "cron.h"

void Debug(char *str, ...)
{
	va_list ptr;
	va_start(ptr,str);
	vfprintf(stderr,str,ptr);
	va_end(ptr);
}

void PrintBin(int max,long val)
{	int x;
	for(x=max;x>=0;x--)
		putchar( (val & (1L<<x)) ? '1' : '0');
}

void DebugPrintTimes(entry *line)
{
	puts("\nMinutes :    xxxxxxxxx5xxxxxxxxx4xxxxxxxxx3"
		 "xxxxxxxxx2xxxxxxxxx1xxxxxxxxx0");
	printf("             ");
	PrintBin(27,line->MinH);
	PrintBin(31,line->MinL);

	puts("\nHours :      xxx2xxxxxxxxx1xxxxxxxxx0");
	printf("             ");
	PrintBin(23,line->Hour);

	puts("\nDayofMonth : x3xxxxxxxxx2xxxxxxxxx1xxxxxxxx1");
	printf("             ");
	PrintBin(31,line->DayOfM);

	puts("\nMonth :      xx1xxxxxxxx1");
	printf("             ");
	PrintBin(12,line->Month);

	puts("\nDayOfWeek :  xxxxxx0");
	printf("             ");
	PrintBin(6,line->DayOfW);
	putchar('\n');
}
