コード例 #1
0
ファイル: gcode-canon.c プロジェクト: csdexter/gcode-canon
int main(int argc, char *argv[]) {
  FILE *parFile = fopen(GCODE_PARAMETER_STORE, "r");
  FILE *inputFile = (argc > 1 ? fopen(argv[1], "r") : stdin);
  char line[0xFF];

  init_parameters(parFile);
  init_machine(NULL);
  init_stacks(NULL);
  init_tools(NULL);
  init_input(inputFile);
  //TODO: align API, add done_gcode_state().
  init_gcode_state(NULL);
  init_cycles(NULL);
  //TODO: align API, make it take a pointer to init data.
  init_queue();
  init_checker(NULL);

  while(machine_running() && gcode_running() && fetch_line_input(line)) {
    if(gcode_check(line)) update_gcode_state(line);
    move_machine_queue();
  }
  /* Flush movement queue */
  while(move_machine_queue());

  done_checker();
  done_queue();
  done_cycles();
  done_input();
  done_tools();
  done_stacks();
  done_machine();
  done_parameters();

  return 0;
}
コード例 #2
0
ファイル: checker.c プロジェクト: jamjr/Helios-NG
/*************************************************************************
 * MAIN ENTRY POINT FOR THE FILE-SYSTEM CHECKER
 *
 * - The different passes of the checking process ...
 *
 * Parameter  : full	= TRUE : Full check incl. directory tree scan
 *                        FALSE: only check_unique() then full check if
 *			         any errors occurred
 * Return     : FALSE, if a fatal error-condition occurred
 *
 *************************************************************************/
word
fscheck ( word full )
{
 struct buf *bpar, *bp;			/* used for check_inodes()	*/
 struct dir_elem root_de;

			/* For fatal error handling. This longjmp -	*/
			/* location is used, if bread() to fixed block- */
			/* numbers (like 1,2,3) fails or memory alloca- */
			/* operations do not succeed.			*/ 
			
 if ( setjmp ( term_jmp ) != 0 )
 {
 	IOdebug ("%sCHECKER INTERRUPTED DUE TO A FATAL ERROR CONDITION!", S_FATAL);
 	IOdebug ("%s(Especially block-read and memory allocation operations)", S_FATAL);
 	finish_checker ();
 	return FALSE;
 }

 if ( ! init_checker () )		/* Basic initialization		*/
 	return FALSE;

/*---------------  The four steps of the checking process ---------------*/

 IOdebug ( "%sSTEP 1   : CHECKING BASIC DATA STRUCTURES", S_INFO );
 unique_err = 0;
 if ( ! check_unique () )		/* Basic tests on superblock	*/
 {					/* and other unique structures	*/
 	IOdebug ("%sDURING BASIC DATA STRUCTURE CHECK", S_FATAL);
 	finish_checker ();
 	return FALSE;
 }	
 
 if ( !full && !unique_err ) {
	 finish_checker ();		/* Finish checking, tidy up and	*/
 					/* unlock the server's ports	*/
	 return TRUE;			/* Terminate checker process	*/
 }
 				
 IOdebug ( "%sSTEP 2   : TRAVERSING THE DIRECTORY TREE (INODE-CHECK)", S_INFO);
 bpar = bread ( 0, 1, 1, SAVEA );	/* Get sum-block with root-dir	*/
					/* if read fails jmp to term_jmp */
 					/* Start from the file-server's	*/
 					/* root position		*/
 memcpy ( &root_de, &bpar->b_un.b_sum->root_dir, sizeof (struct dir_elem) );
 brelse ( bpar->b_tbp, TAIL );		/* Release summary block	*/
 					/* Up from this point, we get a	*/
 					
 					/* Work on the directory tree	*/
 if ( ! check_inodes ( &root_de , 1, 0 ) )
 {
 	IOdebug ("%sDURING SIMPLE OBJECT (INODE) CHECK", S_FATAL);
	finish_checker ();
	return FALSE;
 }
 					/* Work on the bit-maps		*/
 IOdebug ( "%sSTEP 3   : MAKE BLOCK-BASED CONNECTIVITY CHECKS", S_INFO);
 if ( ! check_blocks () )
 {
 	IOdebug ("%sDURING BIT-MAP AND CONNECTIVITY CHECK", S_FATAL);
	finish_checker ();
	return FALSE;
 }
 actual_path[0] = '\0';
					/* Perform some final tidy-up	*/
					/* operations			*/
 IOdebug ("%sSTEP 4   : TIDYUP EVERYTHING AND CORRECT SUMMARY INFORMATIONS", S_INFO);
 if ( ! tidy_update () )
 {
	IOdebug ("%sDURING TIDY UP OPERATION", S_FATAL);
 	finish_checker ();
 	return FALSE;
 }
 finish_checker ();			/* Finish checking, tidy up and	*/
 					/* unlock the server's ports	*/
 return TRUE;				/* Terminate checker process	*/
}