Exemplo n.º 1
0
void
TourneyReadIni (void)
{
  parse_t parse;
  int clevel;
  char *mytok;
  qboolean inevent;

  t_eventcount = 0;
  clevel = 0;
  inevent = false;
  if (ParseStartFile (GAMEVERSION "/" TOURNEYINI, &parse) == true)
    {
      while ((mytok = ParseNextToken (&parse, STDSEPERATOR)))
	{
	  switch (clevel)
	    {
	    case 0:		//we're not in any section

	      clevel = _istourneysection (mytok);
	      if (!clevel)
		_tourneyparseerror (parse, "unknown command %s", mytok);
	      break;

	    default:		// we're are in any other section


	      if (Q_stricmp (mytok, "set") == 0)
		{
		  if (_tourneyset (parse, clevel, t_eventcount) == true)
		    t_eventcount++;
		}
	      else if (Q_stricmp (mytok, "play") == 0)
		{
		  if (_tourneyplay (parse, clevel, t_eventcount) == true)
		    t_eventcount++;
		}
	      else if (Q_stricmp (mytok, "print") == 0)
		{
		  if (_tourneyprint (parse, clevel, t_eventcount) == true)
		    t_eventcount++;
		}
	      else if (_istourneysection (mytok))
		clevel = _istourneysection (mytok);
	      else
		_tourneyparseerror (parse, "unknown command %s", mytok);
	    }
	}
      ParseEndFile (&parse);
    }
  gi.dprintf ("%i tourney events...\n", t_eventcount);
}
Exemplo n.º 2
0
int main()
{
  //int createChild = 1;
  char cwd[1024];
  int status;

  printf("Flooder program starting\n");

  while(1)
  {
    // Check the listen directory for a file
    printf("Checking for files...\n");
    int isEmpty =  IsDirectoryEmpty(LISTEN_DIR);
    if (isEmpty)
      printf("Directory 'listen' is empty\n");
    else
      printf("Directory 'listen' is not empty\n");

    // Process any files found in 'listen' directory
    if (!isEmpty)
    {
      // Change to the listen directory
      if (strcmp(getcwd(cwd, sizeof(cwd)), LISTEN_DIR) != 0)
      {
        if (chdir(LISTEN_DIR) != 0)
          perror("Error changing to listening directory\n");
      }

      switch(GetFile())
      {
        case 1:
          printf("...found 'start' file...\n");
          // Parse the file
          flooder f = ParseStartFile(); 

          // Delete the file 
          if (remove(START_FILE) != 0)
            perror("Error deleting 'start' file\n");

          //CreateChild();
          CreateChild(f);
          waitpid(-1, &status, WNOHANG);
          break;

        case 2:
          printf("...found 'stop' file...\n");
          // Delete the file 
          if (remove(STOP_FILE) != 0)
            perror("Error deleting 'stop' file\n");
          break;
          printf("Killing child pid %d\n", getpid());
          if (KillChildPid(getpid()) == 0)
            printf("Child pid successfully killed\n");
          else
            printf("Error killing child pid\n");
          break;

        default:
          printf("...found unknown file...\n");
          // Delete the file 
          if (remove(UNKNOWN_FILE) != 0)
            perror("Error deleting unknown file\n");
          break;
      }
    }

    sleep(5); 

  }

  exit(0);
}