Пример #1
0
int sys_pipe(void * scallStructPtr) {
  struct pipeSyscall s;
  int fd;
  char newPath[100];
  newPath[0] = 0;

  ugets(cProc, (size_t)scallStructPtr, 0, 14, sizeof(struct pipeSyscall), 0, (unsigned int *)&s);


  k_mkfifo(newPath);

  for (fd = 0; fd < MAX_FILES_PER_PROC; fd++) {
    if (!cProc->openFiles[fd]) {
      break;
    }
  }
  if (fd != MAX_FILES_PER_PROC) {
    cProc->openFiles[fd] = k_open(newPath, O_WRONLY);
    s.pipefd[1] = fd;
  }
  for (; fd < MAX_FILES_PER_PROC; fd++) {
    if (!cProc->openFiles[fd]) {
      break;
    }
  }
  if (fd != MAX_FILES_PER_PROC) {
    cProc->openFiles[fd] = k_open(newPath, O_RDONLY);
    s.pipefd[0] = fd;
  }

  uputs(cProc, (size_t)scallStructPtr, 0, 14, sizeof(struct pipeSyscall), 0, (unsigned int *)&s);

  return 0;
}
Пример #2
0
void gerar_Tela(){
	k_open(LARGURA*20, ALTURA*20+20, "Jogo Da Vida" );
    k_set_block(10);
    k_set_zoom(1,1);
	k_clear('K');
	//k_flush();
}
Пример #3
0
/*************************************************************
 *                      ReadRingName                         *
 * Read startstop's configfile as far as the first ring name *
 *************************************************************/
void ReadRingName( char *ringname, char *configFile )
{
	int        nfiles;
	char      *com, *str;
	char       configfile[20];

	strcpy( configfile, "" );

	nfiles = k_open( configFile );
	if ( nfiles == 0 )
	{
		printf( "status: Error opening file <%s>. Exiting.\n",
				configFile );
		exit( -1 );
	}

	/* Process Ring commands from startstop's command file
	 ***************************************************/
	while(nfiles > 0)          /* While there are command files open */
	{
		while(k_rd())         /* Read next line from active file  */
		{
			com = k_str();    /* Get the first token from line */

			/* Ignore blank lines & comments
			 *****************************/
			if( !com )           continue;
			if( com[0] == '#' )  continue;

			/* Process only 1st Ring command
			 *****************************/
			if( k_its( "Ring" ) )
			{
				str = k_str();
				strcpy( ringname, str );
				break;
			}

			/* See if there were any errors processing this command
			 ****************************************************/
			if( k_err() )
			{
				printf( "status: Bad <%s> command in <%s>. Exiting.\n",
						com, configfile );
				return;
			}
		}
		nfiles = k_close();
	}

	return;
}
Пример #4
0
int sys_open(void * scallStructPtr) {
  int fd;
  unsigned int fn_buf[1024];
  struct openSyscall s;
  ugets(cProc, (size_t)scallStructPtr, 0, 14, sizeof(struct openSyscall), 0, (unsigned int *)&s);
  ugets(cProc, (size_t)s.filename, 0, 14, 1024, 1, fn_buf);


  for (fd = 0; fd < MAX_FILES_PER_PROC; fd++) {
    if (!cProc->openFiles[fd]) {
      break;
    }
  }
  if (fd != MAX_FILES_PER_PROC) {
    cProc->openFiles[fd] = k_open(fn_buf, s.mode);
    s.mode = fd;
  } else {
    s.mode = -1;
  }
  uputs(cProc, (size_t)scallStructPtr, 0, 14, sizeof(struct openSyscall), 0, (unsigned int *)&s);

  return 0;
}
Пример #5
0
/******************************************************************************
 *  orb2eworm_config() processes command file(s) using kom.c functions;        *
 *                    exits if any errors are encountered.                    *
 ******************************************************************************/
void 
orb2eworm_config( char *configfile )
{
	int	ncommand; /* # of required commands you expect to process */
	char	init[10]; /* init flags, one byte for each required command */
	int	nmiss;	/* number of required commands that were missed */
	char	*com;
	char	*str;
	int	nfiles;
	int	success;
	int	i;

	/*
	 * Set to zero one init flag for each required command 
	 */
	ncommand = 7;
	for ( i = 0; i < ncommand; i++ )
		init[i] = 0;
	nLogo = 0;

	/*
	 * Open the main configuration file 
	 */
	nfiles = k_open( configfile );
	if ( nfiles == 0 ) 
	{
		fprintf( stderr,
		   "orb2eworm: Error opening command file <%s>; exiting!\n",
			configfile );
		exit( -1 );
	}
	/*
	 * Process all command files 
	 */
	while ( nfiles > 0 ) 
	{	/* While there are command files open */
		while ( k_rd() ) 
		{/* Read next line from active file  */
			com = k_str();	/* Get the first token from line */

			/*
			 * Ignore blank lines & comments 
			 */
			if ( !com )
				continue;
			if ( com[0] == '#' )
				continue;

			/*
			 * Open a nested configuration file 
			 */
			if ( com[0] == '@' ) 
			{
				success = nfiles + 1;
				nfiles = k_open( &com[1] );
				if ( nfiles != success ) 
				{
					fprintf( stderr,
					"orb2eworm: Error opening command " );
					fprintf( stderr,
					"file <%s>; exiting!\n", &com[1] );
					exit( -1 );
				}
				continue;
			}
			/*
			 * Process anything else as a command 
			 */
			 /* 0 */ if ( k_its( "LogFile" ) ) 
			 {
				LogSwitch = k_int();
				init[0] = 1;
			}
			 /* 1 */ 
			else if ( k_its( "MyModuleId" ) ) 
			{
				str = k_str();
				if ( str )
					strcpy( MyModName, str );
				init[1] = 1;
			}
			 /* 2 */ 
			else if ( k_its( "RingName" ) ) 
			{
				str = k_str();
				if ( str )
					strcpy( RingName, str );
				init[2] = 1;
			}
			 /* 3 */ 
			else if ( k_its( "HeartBeatInterval" ) ) 
			{
				HeartBeatInterval = k_long();
				init[3] = 1;
			}
			 /* 4 */ 
			else if ( k_its( "OrbName" ) ) 
			{
				str = k_str();
				if ( str )
					strcpy( OrbName, str );
				init[4] = 1;
			}
			 /* 5 */ 
			else if ( k_its( "ChannelSelect" ) ) 
			{
				str = k_str();
				if ( str )
					strcpy( ChannelSelect, str );
				init[5] = 1;
			}
			 /* 6 */ 
			else if ( k_its( "ChannelReject" ) ) 
			{
				str = k_str();
				if ( str )
					strcpy( ChannelReject, str );
				init[6] = 1;
			}
			/*
			 * Unknown command 
			 */
			else 
			{
				fprintf( stderr,
				   "orb2eworm: <%s> Unknown command in <%s>.\n",
				   com, configfile );
				continue;
			}

			/*
			 * See if there were any errors processing the
			 * command 
			 */
			if ( k_err() ) 
			{
				fprintf( stderr,
				"orb2eworm: Bad <%s> command in <%s>; exiting!\n",
					com, configfile );
				exit( -1 );
			}
		}
		nfiles = k_close();
	}

	/*
	 * After all files are closed, check init flags for missed commands 
	 */
	nmiss = 0;
	for ( i = 0; i < ncommand; i++ )
		if ( !init[i] )
			nmiss++;
	if ( nmiss ) 
	{
		fprintf( stderr, "orb2eworm: ERROR, no " );
		if ( !init[0] ) fprintf( stderr, "<LogFile> " );
		if ( !init[1] ) fprintf( stderr, "<MyModuleId> " );
		if ( !init[2] ) fprintf( stderr, "<RingName> " );
		if ( !init[3] ) fprintf( stderr, "<HeartBeatInterval> " );
		if ( !init[4] ) fprintf( stderr, "<OrbName> " );
		if ( !init[5] ) fprintf( stderr, "<ChannelSelect> " );
		if ( !init[6] ) fprintf( stderr, "<ChannelReject> " );
		fprintf( stderr, "command(s) in <%s>; exiting!\n", configfile );
		exit( -1 );
	}
	return;
}