Beispiel #1
0
void List ( void )
{
	int bookN = 0;

	puts ("List of available books:");
	while ( TRUE )
	{
		/* read line removing spaces */
		fgets (line, MaxLine, fin);
		NoSpaces ();

		/* if /BOOKSHELF or => break */
		if (!strcmp(line,"<!--/BOOKSHELF-->")) break;
		if (feof(fin)) CriticalError (SC_BooksCorrupted, "");

		bookN++;

		/* Line must start with <!--BOOK=bookname, and then print it */
		if ( !GetBookName() ) CriticalError (SC_BooksCorrupted, "");
		printf ("    %s\n",line);

		/* Strip until one gets to <!--/BOOK--> */
		do {
			fgets(line, MaxLine, fin);
			NoSpaces();
		} while ( strcmp(line,"<!--/BOOK-->") && !feof(fin) );

		if (feof(fin)) CriticalError (SC_BooksCorrupted, "");

	}
	printf ("Number of books found: %u\n", bookN);
}
Beispiel #2
0
/* Abort, retry or fail for character devices                   */
COUNT char_error(request * rq, struct dhdr FAR * lpDevice)
{
  return CriticalError(
                        EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE,
                        0,
                        rq->r_status & S_MASK,
                        lpDevice);
}
Beispiel #3
0
/* Abort, retry or fail for block devices                       */
COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice)
{
  return CriticalError(
                        EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE,
                        nDrive,
                        rq->r_status & S_MASK,
                        lpDevice);
}
Beispiel #4
0
int TCP_CLIENT_Config(void)
{ 
  if(ETH_BSP_Config() == ETH_ERROR) CriticalError(ERR_ETH_CONFIG);
  
  LwIP_Init();
  
  delay(500);
  
  if((ptcp_pcb = tcp_new()) == NULL) CriticalError(ERR_UDP_NEW);
   
  IP4_ADDR(&ip_addr_tx,192,9,206,251);
  
  if(tcp_connect(ptcp_pcb,&ip_addr_tx,TX_PORT,tcp_echoclient_connected) == ERR_OK) 
  {
    pbuf_free(ptcp_pcb->refused_data);
    return 0;
  }
  else return 1;
}
Beispiel #5
0
void UDP_Config(void)
{
  
  if(ETH_BSP_Config() == ETH_ERROR) CriticalError(ERR_ETH_CONFIG);
  
  LwIP_Init();
  
  delay(500);
  
  IP4_ADDR(&ip_addr_tx,192,9,206,251);
  
  if((pudp_pcb = udp_new()) == NULL) CriticalError(ERR_UDP_NEW);
 
  if((udp_bind(pudp_pcb,IP_ADDR_ANY,RX_PORT) != ERR_OK)) CriticalError(ERR_UDP_BIND);
 
  udp_recv(pudp_pcb,&udp_rx_handler,NULL);

  if(!(pOut = pbuf_alloc(PBUF_TRANSPORT,sizeof(tx_udp_msg),PBUF_RAM))) CriticalError(ERR_POUT_NEW);
}
Beispiel #6
0
void Del ( void )
{
	char tag[MaxLine]= "<!--BOOK=";
	char stout[255] = "";

	strcat (tag,BookName);
	strcat (tag,"-->");
	strupr (tag);

	fgets  (line, MaxLine, fin);
	strcpy (stout, line);
	NoSpaces();

	while (strcmp(line,tag))
	{
		if (!strcmp(line,"<!--/BOOKSHELF-->"))
			CriticalError (SC_BookNotFound, BookName);
		if (feof(fin)) CriticalError (SC_BooksCorrupted, "");

		fputs (stout, fout);
		do {
			fgets (line, MaxLine, fin);
			if (feof(fin)) CriticalError (SC_BooksCorrupted, "");
			fputs (line, fout);
			NoSpaces();
		} while (strcmp(line,"<!--/BOOK-->"));

		fgets  (line, MaxLine, fin);
		strcpy (stout, line);
		NoSpaces();

	}

	do {
		fgets (line, MaxLine, fin);
		NoSpaces();
		if (feof(fin)) CriticalError (SC_BooksCorrupted, "");
	} while (strcmp(line,"<!--/BOOK-->"));

}
Beispiel #7
0
	//__CALLOUT for radio transport
	void __CALLOUT OnRadioPacket(unsigned char* packet, int len)
	{
		if (len < sizeof(SRV_TO_ARMLET_HEADER)) {
			CriticalError("PROTOCOL: len < SRV_TO_ARMLET_HEADER");
			return;
		}
		SRV_TO_ARMLET_HEADER* header = (SRV_TO_ARMLET_HEADER*)packet;
		switch(header->msg_type) {
			case MSG_SHOW_MESSAGE:
				{
					SRV_STRING* pkt = (SRV_STRING*)packet;
					int size = len - sizeof(SRV_STRING);
					if (pkt->string[size]!=0)
						pkt->string[size]=0;
					_OnServerMessage(&pkt->string[0]);
				}
				break;
			case MSG_SET_PLAYER_NAME:
				{
					SRV_STRING* pkt = (SRV_STRING*)packet;
					int size = len - sizeof(SRV_STRING);
					if (pkt->string[size]!=0)
						pkt->string[size]=0;
					_OnSetPlayerName(&pkt->string[0]);
				}
				break;
			case MSG_SET_PLAYER_REGENERATION:
				{
					SRV_SET_PLAYER_REGENERATION* pkt = (SRV_SET_PLAYER_REGENERATION*)packet;
					_OnSetRegenerationRate(pkt->level);
				}
				break;
			case MSG_ROOM_HIT:
				{
					SRV_ROOM_HIT* pkt = (SRV_ROOM_HIT*)packet;
					_OnExplosion(pkt->room_id);
				}
				break;
			default:
				//TODO Log
				break;
		}
		//TODO cycle with
		//	MSG_TASK_COMPLETED = 64,
		//	MSG_TASK_COMPLETION_CONFIRMED = 65,
	}
Beispiel #8
0
	void CheckWinError(
		char const* file, char const* function, int line )
	{
		DWORD LastError = GetLastError();
		if( !LastError )
		{
			return;
		}
		Errored = true;
		char StrBuffer[ 1024 ];
		FormatMessage(
			FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,
			0,
			LastError,
			MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ),
			StrBuffer,
			sizeof( StrBuffer ) - 1,
			0 );
		CriticalError( file, function, line, StrBuffer );
	}
Beispiel #9
0
void set_fact_defaults(void)
{
		/* write defaults */
	memset((unsigned char*)&Clbr_E2pImage, 0 , sizeof(Clbr_E2pImage_t));
	zero_press1 = 1100;
	zero_press2 = 1110;
	set_press1 = 100;
	set_press2 = 100;
	scale_press1 = 100;
	scale_press2 = 100;
	vol_calibr = 1;
	calib_time = 0;
	/* put checksum to the last halfword */
  	((unsigned int*)&Clbr_E2pImage)[sizeof(Clbr_E2pImage)/2 - 1] = crc16(&Clbr_E2pImage, sizeof(Clbr_E2pImage) - 2);
		SST25SectorErase(CLBR_E2PIMG_BASE);
		if(!SST25WriteArray(CLBR_E2PIMG_BASE, &Clbr_E2pImage, sizeof(Clbr_E2pImage)))
			CriticalError("eeprom err");

//		if(eeprom_write(0, &E2pImage, sizeof(E2pImage_t)) == 0)
//			critical_error((uchar*)eeprom_msg);
}
Beispiel #10
0
void main ( BYTE argc, char *argv[] )
{
	int i=2 ;

  /*********** STARTUP AND PARAMETER PARSING **************/

	/* Opening strings */
	printf ("BOOKSHLF %s - FreeDOS Book Shelf manager\n", VerS);
	puts ("Copyright Aitor SANTAMARIA MERINO under the GNU GPL 2.0\n");

	/* Discard FastHelp */

	if ( (argc==1) ||
	     ( (argc==2) && (!strcmp(argv[1],"/?")) ) )
	     FastHelp ();

	/* Determine command (argv[1]) */

	if (!strcmp (strupr(argv[1]),"LIST") )
		curcommand = CM_List;
	else if (!strcmp (argv[1],"ADD"))
		curcommand = CM_Add;
	else if (!strcmp (argv[1],"DEL"))
		curcommand = CM_Del;
	else
		CriticalError (SC_UnknownCommand, "");

	/* Get the book name (ADD/DEL) */
	if ( (curcommand==CM_Add) || (curcommand==CM_Del) )
	{
		if (argc<3) CriticalError (SC_WrongNParams, "");
		strncpy (BookName, argv[i++], MaxLine);
	}

	/* More arguments? */
	if (argc > (i+1)) CriticalError (SC_WrongNParams, "");
	if (argc == (i+1))
		strncpy (finName, argv[i], 255);


  /*********** OPENING FILES **************/

	/*  Try to open the source HTML file */
	i=1;	/* Flag meaning: 2=no finName was specified, 1=was specified */
	if (!finName[0])
	{
		i++;
		strcpy (finName, "..\\HELP\\INDEX.HTM");
//		strcpy (finName, "INDEX.HTM");
// for easy testings
	}

	while (i--)
		if ((fin = fopen (finName,"rt"))!=NULL) i=0;
		else
		   if (i) {
			strcpy (foutName, getenv ("HELPPATH"));
			if (!foutName[0]) CriticalError (SC_CantOpenSource, finName);
			strcat (foutName, "\\INDEX.HTM");
			strcpy (finName, foutName);
		   }
		   else CriticalError (SC_CantOpenSource, finName);


	/* Add extension BI if not present */
	if ( curcommand==CM_Add )
	{
		for ( i = strlen(BookName)-1; (i>=0) && (BookName[i]!='\\') && (BookName[i]!='.'); i--);
		if (! ((i>=0) && (BookName[i]=='.')) )
			strcat (BookName, ".BI");

		/* Open book index */
		if ((fbook = fopen (BookName,"rt"))==NULL)
			CriticalError (SC_CantOpenBI, BookName);
	}

	/* Compose the target file name .$$$ and try to open it (ADD/DEL) */
	if ( (curcommand==CM_Add) || (curcommand==CM_Del) )
	{
		for ( i=strlen(finName)-1; (i>=0) && (finName[i]!='\\')
						   && (finName[i]!='.')         ; i--);
		if ( (i<0) || ( (i>=0) && (finName[i]=='\\') ) )
			i=strlen(finName);

		strncpy (foutName, finName, i);
		strcat  (foutName, ".$$$");

		if ((fout = fopen (foutName,"wt"))==NULL)
			CriticalError (SC_CantOpenTarget, foutName);
	}

  /*********** MAIN WORK **************/

	/* Find <!--BOOKSHELF-->*/
	do {
		fgets (line, MaxLine, fin);
		if ( (curcommand==CM_Add) || (curcommand==CM_Del) )
			fputs (line, fout);
		NoSpaces();
	} while ( strcmp(line,"<!--BOOKSHELF-->") &&
		    !feof (fin)	);
	if (feof(fin)) CriticalError (SC_NoBookhelpFile, finName);

	/* Main loop */
	switch ( curcommand )
	{
		case CM_List: List();
				  break;
		case CM_Add:  Add();
				  break;
		case CM_Del:  Del();
	}

  /*********** CLOSING TASKS **************/

	/* Close files */
	switch ( curcommand )
	{
	   case CM_Add:
		fclose (fbook);

	   case CM_Del:
		while (!feof(fin))
		{
			fgets (line, MaxLine, fin);
			if (feof(fin)) break;
			fputs (line, fout);
		}
		fclose (fout);

	   case CM_List:
		fclose (fin);
	}

	/* File renaming stuff */
	if ( (curcommand==CM_Add) || (curcommand==CM_Del) )
	{
		/* create the back name */
		strncpy (fbackName, finName, 255);
		if ( (strlen(fbackName)>4) &&
		     (fbackName[strlen(fbackName)-4]=='.') )
			fbackName[strlen(fbackName)-4]=0;
		strcat (fbackName,".BAK");

		/* File mangling */
		if (remove(fbackName)) CriticalError (SC_CantRemoveFin, finName);
		if (rename(finName,fbackName)) CriticalError (SC_CantRemoveFin, finName);
		if (rename(foutName,finName)) CriticalError (SC_CantRemoveFin, finName);

		if (curcommand==CM_Add) puts ("Book successfully added.");
		else		     	      puts ("Book successfully removed.");
	}

}
Beispiel #11
0
//*----------------------------------------------------------------------------
//* Function Name       : MemManage_Handler
//* Object              :
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//* Functions called    :
//*----------------------------------------------------------------------------
void MemManage_Handler(void)
{
	printf("MemManage_Handler called\n\r");
	CriticalError(3);
}
Beispiel #12
0
void Add ( void )
{
	char tag[MaxLine]= "<!--BOOK=";
	char stout[255] = "";
	BOOL Updates = FALSE;

	/* Set the book header */
	for (; (strlen(BookName)>0) && (BookName[strlen(BookName)-1]!='.');
		 BookName[strlen(BookName)-1]=0);
	BookName[strlen(BookName)-1]=0;

	/* Get the tag name */
	strcat (tag,BookName);
	strcat (tag,"-->");
	strupr (tag);

	/* Pass all earlier */
	while (TRUE) {
		fgets  (line, MaxLine, fin);

		if (feof(fin)) CriticalError (SC_BooksCorrupted, "");
		strcpy (stout, line);
		NoSpaces();

		if (!strcmp(line,"<!--/BOOKSHELF-->")) break;
		if (strcmp(line,tag)>=0) break;

		strcat (line,"\n");
		fputs (line, fout);
		do {
			fgets (line, MaxLine,fin);
			fputs (line, fout);
			NoSpaces();
		} while (strcmp(line,"<!--/BOOK-->"));

	}
	   /* In all exits of this loop through here, stout is pending to be put */

	/* if present, update, that is, ignore previous book */
	if (!strcmp(line,tag))  {
		Updates = TRUE;		/* flag to say that we don't have to */
						/* append the saved line */
		do {
			fgets (line, MaxLine,fin);
			NoSpaces();
		} while (strcmp(line,"<!--/BOOK-->"));
	}

	/* Insert the book */
	fprintf (fout, "%s\n", tag);

	/* Transfer contents */
	while (TRUE) {
		fgets (line, MaxLine, fbook);
		if feof(fbook) break;
		fputs (line, fout);
	}

	/* Set the book end */
	fputs ("<!--/BOOK-->\n", fout);

	if (!Updates) fputs (stout, fout);
}
Beispiel #13
0
//*----------------------------------------------------------------------------
//* Function Name       : BusFault_Handler
//* Object              :
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//* Functions called    :
//*----------------------------------------------------------------------------
void BusFault_Handler(void)
{
	printf("BusFault_Handler called\n\r");
	CriticalError(4);
}
Beispiel #14
0
//*----------------------------------------------------------------------------
//* Function Name       : UsageFault_Handler
//* Object              :
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//* Functions called    :
//*----------------------------------------------------------------------------
void UsageFault_Handler(void)
{
	printf("UsageFault_Handler called\n\r");
	CriticalError(5);
}
Beispiel #15
0
//*----------------------------------------------------------------------------
//* Function Name       : SVC_Handler
//* Object              :
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//* Functions called    :
//*----------------------------------------------------------------------------
void SVC_Handler(void)
{
	printf("SVC_Handler called\n\r");
	CriticalError(6);
}
Beispiel #16
0
//*----------------------------------------------------------------------------
//* Function Name       : HardFault_Handler
//* Object              :
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//* Functions called    :
//*----------------------------------------------------------------------------
void HardFault_Handler(void)
{
	printf("HardFault_Handler called\n\r");
	CriticalError(2);
}
Beispiel #17
0
int c_Shader::LoadShader(char *buffer)
{
	int pos = 0, brackets = 0;

	//Copy Shader Name
	pos = DQWordstrcpy( Filename, buffer, MAX_QPATH );
	DQStripGfxExtention(Filename, MAX_QPATH);	//Keep Shadername as extentionless

	//skip to first {
	pos += DQSkipWhitespace(&buffer[pos], 65535); //arbitrary length

	//Initialise Shader Load variables
	CurrentRenderPass = &RenderPassChain;
	CurrentStage = NULL;
	CurrentCommand = NULL;
	CurrentGlobalCommand = NULL;
	TextureStageNum = 0;

	while(buffer[pos]!='\0') {

		if(buffer[pos] == '{') {
			++brackets;
			if(brackets==2) {
				//New Stage
				NewStage();
			}
			if(brackets>2) {
				CriticalError(ERR_FS, "Invalid Shader Format : Too many {");
				return 1000; //skip over shader
			}
			//Skip to next command
			pos += DQNextLine(&buffer[pos], 65535); //arbitrary length
			pos += DQSkipWhitespace(&buffer[pos], 65535);
			continue;

		}

		if(buffer[pos] == '}') {
			--brackets;
			if(brackets==0) {
				//End of shader definition
				++pos;
				break;
			}

			pos += DQNextLine(&buffer[pos], 65535); //arbitrary length
			pos += DQSkipWhitespace(&buffer[pos], 65535);
			continue;
		}
		//else Found a Shader Command
		if(brackets==0) CriticalError(ERR_FS, "Invalid Shader Format");

		//If required, AddShaderFunc adds as new function onto the command list, and handles
		//new stages and new passes
		//AddShaderFunc returns true if a new command is added
		LoadShaderFunc( &buffer[pos] );

		pos += DQNextLine(&buffer[pos], 65535); //arbitrary length
		pos += DQSkipWhitespace(&buffer[pos], 65535);
	}

	return pos;
}
Beispiel #18
0
//*----------------------------------------------------------------------------
//* Function Name       : DebugMon_Handler
//* Object              :
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//* Functions called    :
//*----------------------------------------------------------------------------
void DebugMon_Handler(void)
{
	printf("DebugMon_Handler called\n\r");
	CriticalError(7);
}
Beispiel #19
0
void CArchonProcess::CollectGarbage (void)

//	CollectGarbage
//
//	Collects garbage

	{
	CString sTask;

	try 
		{
		int i;

		//	Compute how long it's been since we last collected garbage

		DWORD dwStart = sysGetTickCount();
		DWORD dwTimeSinceLastCollection = dwStart - m_dwLastGarbageCollect;

		//	If it has been less than a certain time, then only collect garbage if
		//	all engines are idle.

		if (dwTimeSinceLastCollection < MAX_GARBAGE_COLLECT_WAIT)
			{
			//	Check to see if engines are idle

			bool bEnginesIdle = true;
			for (i = 0; i < m_Engines.GetCount(); i++)
				if (!m_Engines[i].pEngine->IsIdle())
					{
					bEnginesIdle = false;
					break;
					}

			//	If the engines are busy, then check to see if we have enough
			//	memory to wait some more.

			if (!bEnginesIdle)
				{
				CProcess CurrentProc;
				CurrentProc.CreateCurrentProcess();
				CProcess::SMemoryInfo MemoryInfo;
				if (!CurrentProc.GetMemoryInfo(&MemoryInfo))
					{
					LogBlackBox(ERR_CANT_GET_MEMORY_INFO);
					return;
					}

				//	If we have enough memory, then wait to collect garbage

				if (MemoryInfo.dwCurrentAlloc < MAX_GARBAGE_COLLECT_MEMORY)
					return;

				//	Warning that we're running out of memory

				LogBlackBox(ERR_MEMORY_WARNING);
				}
			}

		//	Collect

	#ifdef DEBUG_GARBAGE_COLLECTION
		printf("[%s] Collecting garbage.\n", (LPSTR)m_sName);
	#endif

		m_dwLastGarbageCollect = dwStart;

		m_RunEvent.Reset();
		m_PauseEvent.Set();

		//	Keep track of how long each engine takes to pause (for diagnostic
		//	purposes).

		TArray<DWORD> PauseTime;
		PauseTime.InsertEmpty(m_Engines.GetCount());

		//	Some engines still need an explicit call (because they don't have
		//	their own main thread).

		for (i = 0; i < m_Engines.GetCount(); i++)
			m_Engines[i].pEngine->SignalPause();

		//	Wait for the engines to stop

		for (i = 0; i < m_Engines.GetCount(); i++)
			{
			DWORD dwStart = sysGetTickCount();

			m_Engines[i].pEngine->WaitForPause();

			PauseTime[i] = sysGetTicksElapsed(dwStart);
			}

		//	Wait for our threads to stop

		m_EventThread.WaitForPause();
		m_ImportThread.WaitForPause();

		//	Now we ask all engines to mark their data in use

		for (i = 0; i < m_Engines.GetCount(); i++)
			{
			sTask = strPattern("Marking data: %s engine.", m_Engines[i].pEngine->GetName());
			m_Engines[i].pEngine->Mark();
			}

		//	Now we mark our own structures

		sTask = STR_MARKING_MNEMOSYNTH;
		m_MnemosynthDb.Mark();

		sTask = STR_MARKING_EVENT_THREAD;
		m_EventThread.Mark();

		sTask = STR_MARKING_IMPORT_THREAD;
		m_ImportThread.Mark();

		//	Now we sweep all unused

		sTask = STR_MARK_AND_SWEEP;

		DWORD dwSweepStart = sysGetTickCount();
		CDatum::MarkAndSweep();
		DWORD dwSweepTime = sysGetTickCount() - dwSweepStart;

		sTask = NULL_STR;

		//	Now we start all engines up again

		m_PauseEvent.Reset();
		m_RunEvent.Set();

		//	If garbage collection took too long, then we need to log it.

		DWORD dwTime = sysGetTickCount() - dwStart;
		if (dwTime >= 500)
			{
			//	Log each engine that took too long

			for (i = 0; i < m_Engines.GetCount(); i++)
				if (PauseTime[i] >= 500)
					Log(MSG_LOG_INFO, strPattern(STR_ENGINE_PAUSE_TIME, m_Engines[i].pEngine->GetName(), PauseTime[i] / 1000, (PauseTime[i] % 1000) / 10));

			//	Log overall time

			Log(MSG_LOG_INFO, strPattern(STR_GARBAGE_COLLECTION, 
					dwTime / 1000, (dwTime % 1000) / 10,
					dwSweepTime / 1000, (dwSweepTime % 1000) / 10));
			}
		}
	catch (...)
		{
		if (sTask.IsEmpty())
			CriticalError(ERR_CRASH_IN_COLLECT_GARBAGE);
		else
			CriticalError(strPattern("CRASH: %s", sTask));
		}
	}
Beispiel #20
0
//*----------------------------------------------------------------------------
//* Function Name       : NMI_Handler
//* Object              :
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//* Functions called    :
//*----------------------------------------------------------------------------
void NMI_Handler(void)
{
	printf("NMI_Handler called\n\r");
	CriticalError(1);
}