Exemplo n.º 1
0
int main(int argc, char *argv[]) {

	FILE *fh;
	char msg[20];
	char *m;
	struct timespec tm, tm2;
	int sleep_ms;
	int i, count;

	sleep_ms = 100;
	if (argc>1) {
		sleep_ms = atoi(argv[1]);

	}else {
		printf("NOTE: no period specified, using %d ms as default\n", sleep_ms);
	}

   	tm.tv_sec = 0;
   	tm.tv_nsec = 1000000 * sleep_ms;

	fh = foread("/dev/mbcdd");
   	//fh = foread(argv[2]);
	i = 0;

	while(!feof(fh)) { // || !feof(fh)

		fread(msg, 1, sizeof(msg), fh);

		//printf("read %i: %s\n", i, msg);
		printf("%s", msg);

		nanosleep(&tm, &tm2);
		i++;
	}

	fclose(fh);

	return 0;
}
Exemplo n.º 2
0
/***********************************************************************
 **  PostScript mainline processor.				      **
 ***********************************************************************/
static void psmain(void)
{
    int color_done;			/* done doing colors */
	int i;
	
	ini_JOB();					/* init job stuff		*/
    ini_PAGE();					/* init %%Page: comment state */
	Fofd = 0;
    GraphicsPresentFlag = 0;
    NoFont = 0;
	width_open(); /* Open WIDTH for H&Js char-width round-off errors*/
	FontBase = 1000;
#ifdef TRACE
    if(debugger_trace)
		p_info(PI_TRACE, "Starting job:%s\n",JobName);
#endif
    cc_hit = 0;
	cc_mask = (1 & Plates); /* hit nothing, set all black */
	if ( !cc_mask) 
		m_fopen(tpname, "w+", 1); /* delete prev version of .tp */
    spot_pass = 1;				/* 1st pass */
    color_done = 0;				/* not done yet */
	PageRotationAngle = 0;
	frame_fg_attribute = 0;		/* default is opaque */
	prologue_output_flag = 0;
	PageNo1 = 1;
	underscore_min = 10;
	overflow_page_buff_count = 0;
	memset ( (char *)overflow_page_buff, 0, sizeof (overflow_page_buff) );
	ExitError = 0;
	HNJ_LockFailureFlag = 0;
    while(color_done != 1 )		/* until we get all colors */
    {
		FootnoteFrameFlag = 0;
		BlackPaint_cc_mask = cc_mask;
		PaintOnPage = 0;
		blend_flag = 0;
		BlendAngle = 0;
		BlendEndColor = 0;
		in_overflow = 0;
		was_overflow = 0;
		Linesub = -1;			/* clear text/escapement buffer	*/
		flagGlyph = 0;
		*GlyphName = 0;
		for(i=0; i<1999; i++)
		{
			Line[i] = 0;
			Kspace[i] = 0;
		}
		for(i=0; i<40; i++)
			bf_kmd80[i].active_flag = 0;
		fowrd =  256;
		Xmark =  0;
		y_max =  0;
		Oldfont = -1;
		Holdfont =  0;
		usw = 0;
		StrikeThruRuleStartFlag = 0;
		FlashOn = 1;
		CurrentFrame = 0;
		CurrentEle = 0;
		memset( (char *)&fo_line_def.FoStatusLength, 0, sizeof(LDEF) );
		DontPaintFlag = fo_line_def.MiscLineFlags & 0x10;
		not_lnum = 1;			/* Default: Put text font, not line-num font*/
		last_lnum = 0;
		jbl = 0;
		repeatno = 0;
		Obdegree = 0;
		Old_ob = 0;
		Hold_ob = 0;
		Holdss = 0;
		Holdps = 0;
		Oldss = 0;
		Oldps = 0;
		Ktabmode = 0;
		psend = 0;
		WidthOfNumeric = 0;
		memset ( page_number, 0, sizeof(page_number) );
		CurrentLineBcEc = 0;
		PrevLineBcEc = 0;
		BcEcExtraLeadNeeded = 0;
		BcEcExtraLead = 0;
		LastLinemaxErr = 0;
		cc_hit &= (Plates & ~1); /* only use plates to be output */
#ifdef TRACE
		if(debugger_trace)
		{
			p_info(PI_TRACE, "spot color pass %d, cc_mask: %lo , cc_hit: %lo\n",
				   spot_pass, cc_mask, cc_hit);
			p_info(PI_TRACE, "processing Tree: '%s', Dir: '%s',file: '%s', type= %d\n",
				   TreeName, SubDirName, JobName, FileType);
		}
#endif
		switch(FileType)
		{
		  case 0:				/* Galley output */
			if (spot_pass != 2)
				cc_hit = 0;
			if((err = dtext()) )
				error("processing FO file, err = ",JobName,err);
			if( (cc_hit < 2) ||	/* picked up no color(s) */
			   (spot_pass != 1) || /* or on second pass thru file */
				( !KeyOutputType) )	/* or composite */
				color_done = 1;	/* we are done */
			else
			{
				spot_pass = 2;	/* mark as 2nd pass thru file */
				cc_hit &= (Plates & ~1); /* mask off black */
				cc_mask = 0;	/* not the black we start with */
				galley_count = 0;
				MasterOutputSwitch = 1;
				if(Fofd)		/* if still open */
					foread(1);	/* rewind open FO file */
			}
			break;
			
		  case 1:				/* DesignMaster */
			if((err = dxy()) )
				p_info(PI_ELOG, "ERROR --processing Tree: '%s', Dir: '%s', Unit: %s\n",
					   TreeName,SubDirName,JobName);
			color_done = 1;		/* color loop inside dxy */
			break;
		}						/* end switch(FileType) */
		m_close(-1);			/* close all output */
    }							/* end while(color_done!=1) */
    if (wdfd)
    {
		p_close (wdfd);
		wdfd = 0;
    }
    if (Fofd)
    {
		p_close(Fofd);
		Fofd = 0;
		FoName[0] = 0;
    }
   if (TrailerName) {
		fclose(TrailerName);
		TrailerName = NULL;
    }
    if (PrologName)
    {
		fclose(PrologName);
		PrologName = NULL;

		if (EpsFlag)
		   strcpy (logname, p_path(TreeName, EPS_FILE, SubDirName, tpname));
		else if (BookPrint)
		   strcpy (logname, p_path(TreeName, OUTPUT_FILE, ParentDirName, tpname));
		else
		   strcpy (logname, p_path(TreeName, OUTPUT_FILE, SubDirName, tpname));

	  	sprintf(shell_msg,"cat %s >> %s \n mv %s %s \n cat %s >> %s \n mv %s %s",
			prologname, trailername,
			trailername, prologname,
			logname, prologname,
			prologname, logname);
		system(shell_msg);
    }
#ifdef TRACE
    if(debugger_trace)
		p_info(PI_TRACE, "Finished job, Tree: '%s', Dir: '%s', Name: '%s'.\n",
			   TreeName,SubDirName,JobName);
#endif
}