Example #1
0
/*--------------------------------------------------------------------*/
void
RCGSplitter::printShowV2( const ShowInfoT & show )
{
    createOutputFile( show.time_ );

    if ( ! M_fout.is_open() )
    {
        return;
    }

    std::ostream & os = M_fout;

    showinfo_t new_show;

    convert( static_cast< char >( M_playmode ),
             M_team_l,
             M_team_r,
             show,
             new_show );

    Int16 mode = htons( SHOW_MODE );
    os.write( reinterpret_cast< const char * >( &mode ),
              sizeof( Int16 ) );
    os.write( reinterpret_cast< const char * >( &new_show ),
              sizeof( showinfo_t ) );
}
Example #2
0
/*--------------------------------------------------------------------*/
void
RCGSplitter::printShowOld( const ShowInfoT & show )
{
    createOutputFile( show.time_ );

    if ( ! M_fout.is_open() )
    {
        return;
    }

    std::ostream & os = M_fout;

    dispinfo_t disp;

    disp.mode = htons( SHOW_MODE );

    convert( static_cast< char >( M_playmode ),
             M_team_l,
             M_team_r,
             show,
             disp.body.show );

    os.write( reinterpret_cast< const char * >( &disp ),
              sizeof( dispinfo_t ) );
}
Example #3
0
/*--------------------------------------------------------------------*/
void
RCGSplitter::printShowV3( const ShowInfoT & show )
{
    static PlayMode s_playmode = PM_Null;
    static TeamT s_teams[2];

    bool new_file = createOutputFile( show.time_ );

    if ( ! M_fout.is_open() )
    {
        return;
    }

    std::ostream & os = M_fout;

    Int16 mode;

    if ( new_file
         || s_playmode != M_playmode )
    {
        char pm = static_cast< char >( M_playmode );
        s_playmode = M_playmode;

        mode = htons( PM_MODE );
        os.write( reinterpret_cast< const char * >( &mode ),
                  sizeof( Int16 ) );
        os.write( reinterpret_cast< const char * >( &pm ),
                  sizeof( char ) );
    }

    if  ( new_file
          || ! s_teams[0].equals( M_team_l )
          || ! s_teams[1].equals( M_team_r ) )
    {
        team_t teams[2];
        convert( M_team_l, teams[0] );
        convert( M_team_r, teams[1] );
        s_teams[0] = M_team_l;
        s_teams[1] = M_team_r;

        mode = htons( TEAM_MODE );
        os.write( reinterpret_cast< const char * >( &mode ),
                  sizeof( mode ) );
        os.write( reinterpret_cast< const char * >( teams ),
                  sizeof( team_t ) * 2 );
    }

    short_showinfo_t2 new_show;

    convert( show, new_show );

    mode = htons( SHOW_MODE );
    os.write( reinterpret_cast< const char * >( &mode ),
              sizeof( Int16 ) );
    os.write( reinterpret_cast< const char * >( &new_show ),
              sizeof( short_showinfo_t2 ) );

}
Example #4
0
/*--------------------------------------------------------------------*/
void
RCGSplitter::doHandleMsgInfo( const int time,
                              const int board,
                              const std::string & msg )
{
    M_time = time;
    createOutputFile( M_time );

    if ( ! M_fout.is_open() )
    {
        return;
    }

    if ( M_version == REC_VERSION_4 )
    {
        M_fout << "(msg " << M_time
               << " " << board
               << " \"" << msg << "\")\n";
    }
    else if ( M_version == REC_VERSION_3
              || M_version == REC_VERSION_2 )
    {
        Int16 mode = htons( MSG_MODE );
        Int16 tmp_board = htons( static_cast< Int16 >( board ) );

        M_fout.write( reinterpret_cast< const char * >( &mode ),
                      sizeof( mode ) );
        M_fout.write( reinterpret_cast< const char * >( &tmp_board ),
                      sizeof( Int16 ) );
        Int16 nlen = htons( static_cast< short >( msg.length() + 1 ) );
        M_fout.write( reinterpret_cast< const char * >( &nlen ),
                      sizeof( Int16 ) );
        M_fout.write( msg.c_str(), msg.length() + 1 );
    }
    else
    {
        dispinfo_t disp;

        disp.mode = htons( MSG_MODE );

        disp.body.msg.board = htons( static_cast< Int16 >( board ) );
        std::memset( disp.body.msg.message, 0,
                     sizeof( disp.body.msg.message ) );
        std::strncpy( disp.body.msg.message,
                      msg.c_str(),
                      std::min( sizeof( disp.body.msg.message ) - 1,
                                msg.length() ) );
        M_fout.write( reinterpret_cast< const char * >( &disp ),
                      sizeof( dispinfo_t ) );
    }
}
Example #5
0
  void ClangInternalState::store() {
    // Cannot use the stack (private copy ctor)
    llvm::OwningPtr<llvm::raw_fd_ostream> m_LookupTablesOS;
    llvm::OwningPtr<llvm::raw_fd_ostream> m_IncludedFilesOS;
    llvm::OwningPtr<llvm::raw_fd_ostream> m_ASTOS;
    llvm::OwningPtr<llvm::raw_fd_ostream> m_LLVMModuleOS;
    llvm::OwningPtr<llvm::raw_fd_ostream> m_MacrosOS;

    m_LookupTablesOS.reset(createOutputFile("lookup",
                                            &m_LookupTablesFile));
    m_IncludedFilesOS.reset(createOutputFile("included",
                                             &m_IncludedFilesFile));
    m_ASTOS.reset(createOutputFile("ast", &m_ASTFile));
    m_LLVMModuleOS.reset(createOutputFile("module", &m_LLVMModuleFile));
    m_MacrosOS.reset(createOutputFile("macros", &m_MacrosFile));

    printLookupTables(*m_LookupTablesOS.get(), m_ASTContext);
    printIncludedFiles(*m_IncludedFilesOS.get(), 
                       m_ASTContext.getSourceManager());
    printAST(*m_ASTOS.get(), m_ASTContext);
    printLLVMModule(*m_LLVMModuleOS.get(), m_Module);
    printMacroDefinitions(*m_MacrosOS.get(), m_Preprocessor);
  }
//main ()
int main (int argc, char *argv[]) {
//Call syntax check
    if (argc != 3) {
        printf ("Usage: %s Input_filename Minimum_length\n", argv[0]);
        exit (1);
    }
//Main varaibles
    int minLength = atoi (argv[2]), count = 0;
    FILE *inFile = NULL, *outFile = NULL;
    fastqEntry entry;
//minLength check
    if (minLength == 0) {
        printf ("Minimum_length must be a numerical value greater than 0.\n");
        exit (3);
    }
//File creation and checks
    printf ("Opening files...\n");
    createFile (&inFile, argv[1], 'r');
    createOutputFile (&outFile, argv[1], argv[2]);
//Check the sequence sizes
    printf ("Files opened.  Removing reads below threshold...\n");
    initializeFastqEntry (&entry);
//Automate the process
    while (1) {
//Load the data
        loadFastqEntry (&entry, inFile);
//Stop the loop if there are no entries left
        if (entry.title.str == NULL) {
            break;
        }
//Printf the data if it's big enough
        if (entry.sequence.len > minLength) {
            printFastqEntry (&entry, outFile);
        }
//Reset the entry
        reinitializeFastqEntry (&entry);
//A counter so the user has some idea of how long it will take
        if (++count % 1000000 == 0) {
            printf ("%d entries processed...\n", count);
        }
    }
//Close everything and free memory
    printf ("%d entries processed.  Closing files...\n", count);
    freeFastqEntry (&entry);
    fclose (inFile);
    fclose (outFile);
    printf ("Done.\n");
    return 0;
}
Example #7
0
int main(int argc, char* argv[]){
    FILE* input;
    FILE* output;
    input = fopen(argv[1], "r");
    output = fopen(argv[2], "w");
    MacroTable* table;
    table = createMacroTable();
    
    ReadFromFile(input, table);    
    rewind(input);
    createOutputFile(input, output, table);
    fclose(input);

    fclose (output);
    return 0;
}
//main ()
int main(int argc, char *argv[]) {
//Call syntax check
    if (argc != 3) {
        printf ("Usage: %s Input_filename Linker_sequence\n", argv[0]);
        exit(1);
    }
//Main variables
    int count = 0;
    FILE *inFile = NULL, *outFile = NULL;
    fastqEntry entry;
//File creation and checks
    printf ("Opening files...\n");
    createFile (&inFile, argv[1], 'r');
    createOutputFile (&outFile, argv[1], argv[2]);
//Remove the linker
    printf ("Files opened.  Trimming linker...\n");
//Prep the entry node
    initializeFastqEntry (&entry);
//Automate the process
    while (1) {
//Load the fastq entry
        loadFastqEntry (&entry, inFile);
//Stop the loop if the file is processed
        if (entry.title.str == NULL) {
            break;
        }
//Trim the entry if needed, print it, then reset it
        trimLinker (&entry, argv[2]);
        printFastqEntry (&entry, outFile);
        reinitializeFastqEntry (&entry);
//A counter so the user has some idea of how long it will take
        if (++count % 1000000 == 0) {
            printf ("%d entries processed...\n", count);
        }
    }
//Close everything and free memory
    printf ("%d entries processed.  Closing files and freeing memory...\n", count);
    freeFastqEntry (&entry);
    fclose (inFile);
    fclose (outFile);
    printf ("Done.\n");
    return 0;
}
Example #9
0
//main ()
int main (int argC, char *argV[]) {
//Call syntax check
    if (argC != 2) {
        printf ("Usage: %s Input_filename\n", argV[0]);
        exit(1);
    }
//Main variables
    node *curNode = NULL, *entryNode = NULL, *prevNode = NULL, *rootNode = NULL;
    FILE *inFile = NULL, *outFile = NULL;
    int count = 0;
//File creation and checks
    printf ("Opening files...\n");
    createFile (&inFile, argV[1], 'r');
    createOutputFile (&outFile, argV[1]);
//Load the list
    printf ("Files found and created.  Compiling entries...\n");
    while (1) {
//Stop conditions
        if (((ferror (inFile)) || (feof (inFile)))) {
            break;
        }
//Load the next entry from the file
        entryNode = malloc (sizeof (node));
        initializeNode (entryNode);
        loadEntryNode (entryNode, inFile);
//Add it to the tree
        curNode = insert (entryNode, curNode);
        if (++count % 1000000 == 0) {
            printf ("Entry %d sorted...\n", count);
        }
//Clear entry node for the next loop
        entryNode = NULL;
    }
//Print the now sorted list
    printf ("%d entries compiled.  Writing to file...\n", count);
    fclose (inFile);
    rootNode = curNode;
    while (write_ascending(curNode, rootNode, prevNode, outFile) != 1);
//Close everything and free memory
    printf ("Written.  Closing files...\n");
    fclose (outFile);
    return 0;}
Example #10
0
//main ()
int main (int argC, char *argV[]) {
//Call syntax check
    if (argC != 2) {
        printf ("Usage: %s Input_filename\n", argV[0]);
        exit (1);
    }
//Main variables
    FILE *inFile = NULL, *outFile = NULL;
    node *entry = NULL, *firstNode = NULL;
    int count = 0;
    char in;
//File creation and checks
    printf ("Opening files...\n");
    createFile (&inFile, argV[1], 'r');
    createOutputFile (&outFile, argV[1]);
//Load entries into DLL
    printf ("Files opened.  Loading entries...\n");
    while (1) {
//Stop conditions
        if (((ferror (inFile)) || (feof (inFile)))) {
            break;
        }
        entry = malloc (sizeof (node));
        initializeNode (entry);
        loadEntry (entry, inFile);
        firstNode = insertNode (entry, firstNode);
        entry = NULL;
//A counter so the user has some idea of how long it will take
        if (++count % 100000 == 0) {
            printf ("%d entries ordered...\n", count);
        }
    }
    fclose (inFile);
//Write ordered list to file
    printf ("%d entries ordered.  Writing to file...\n", count);
    printNodeList (firstNode, outFile);
//Close everything and free memory
    printf ("Writen.  Closing files and freeing memory...\n");
    fclose (outFile);
    return 0;
}
Example #11
0
//main()
int main (int argc, char *argv[]) {
//Call syntax check
    if (argc != 2) {
        printf ("Usage: %s Input_filename\n", argv[0]);
        exit (1);
    }
//Main variables
    int sequenceLength = 0, count = 0;
    long netSequenceLength = 0;
    FILE *inFile = NULL, *outFile = NULL;
    fastqEntry entry;
//File creation and checks
    printf ("Opening files..\n");
    createFile (&inFile, argv[1], 'r');
    createOutputFile (&outFile, argv[1]);
//Extract titles
    printf ("Files opened.  Parsing out titles...\n");
    initializeFastqEntry (&entry);
    while (1) {
//Load the entry, stop the loop if the list is done
        loadFastqEntry (&entry, inFile);
        if (entry.title.str == NULL) {
            break;
        }
//Adjsut the lengths and print the values
        sequenceLength = entry.sequence.len - 1;
        netSequenceLength += sequenceLength;
        fprintf (outFile, "%s\t%d\t%lu\n", entry.title.str, sequenceLength, netSequenceLength);
        reinitializeFastqEntry (&entry);
//A counter so the user has some idea of how long it will take
        if (++count % 1000000 == 0) {
            printf ("%d entries processed...\n", count);
        }
    }
    printf ("%d titles parsed.  Closing files and freeing memory...\n", count);
    freeFastqEntry (&entry);
    fclose (inFile);
    fclose (outFile);
    return 0;
}
Example #12
0
int main(int argc, char *argv[]){
    openSourceFile(argv[1]);
    createOutputFile(argv[1]);
    strcpy(sourceFileName, argv[1]);
    
    while(!sourceEOF){
	TokenType currentToken = getToken();
	if(strcmp(tokenTypeStr[currentToken], "OTHER") != 0 && strcmp(tokenTypeStr[currentToken], "ERROR") != 0){
	    if(currentToken == KEYWORD || currentToken == OPERATOR || currentToken == DELIMITER)
		fprintf(outputFile, "%d %s\n", lineNo, tokenString);
	    else
	        fprintf(outputFile, "%d %s %s\n", lineNo, tokenTypeStr[currentToken], tokenString);
	    //printf("%d %s %s\n", lineNo, tokenTypeStr[currentToken], tokenString);
	}
    }
    
    fclose(source);
    fclose(outputFile);
    diffTest(argv[1]);
    
    return 0;
}
void read10Files()
{
  int i;
  int totalNames = 0; //keeps track of the total number of names
  char names[NUM_NAME_BUFFER][NAME_LENGTH_BUFFER] = {"",""}; //array for names
  int yearNums[NUM_NAME_BUFFER][10] = {0}; //array for numbers of names in years
  char fileNames[12] = "yob1920.txt"; //file names
  int indexChange = 5; //controls the year we are accessing
  for (i = 0; i < 10; i++)
  {
    if(fileNames[indexChange] == ':') //ascii table incrementation
    {
      fileNames[indexChange] = '0';
      fileNames[indexChange - 1] = '0'; // change 9 to a 0
      fileNames[indexChange - 2]++; //change the 1 to a 2
    }
    totalNames += readSingleFile(names, yearNums, i, fileNames, totalNames); //returns 1 if a new name is added. 0 if only a new year is added.
    fileNames[indexChange]++; //ascii table incrementation
  }
  sortArray(names, yearNums, totalNames);
  createOutputFile(names, yearNums, totalNames);
}
bool
WsdlGeneratorHelper::generate(void)
{
    bool success = createOutputFile();
    return success;
}
OJInt32_t WindowsProcess::create(const OJString &cmd,
								const OJInt32_t timeLimit,
								const OJInt32_t memoryLimit,
								bool startImmediately)
{
    ILogger *logger = LoggerFactory::getLogger(LoggerId::AppInitLoggerId);

    {
        logger->logTraceX(OJStr("[process] - create - CMD='%s' T=%dms, M=%dbytes"),
            cmd.c_str(), timeLimit, memoryLimit);
    }

    if(!createInputFile())
    {
        logger->logError(OJStr("[process] - create - can't creat inputFile"));
        return -1;
    }

    if(!createOutputFile())
    {
        logger->logError(OJStr("[process] - create - can't creat outputFile"));
        return -1;
    }

    if (!jobHandle_.create(useToExcuter_))
    {
        logger->logError(OJStr("[process] - create - can't creat job"));
        return -1;
    }

    if (!jobHandle_.setLimit(timeLimit, memoryLimit))
    {
        logger->logError(OJStr("[process] - create - set job limit failed"));
        return -1;
    }
    
	OJChar_t cmdline[1024];
	wcscpy_s(cmdline, cmd.c_str());

	STARTUPINFO   si;
	PROCESS_INFORMATION   pi;
    ZeroMemory(&si, sizeof(si));
    ZeroMemory(&pi, sizeof(pi)); 
	
	si.cb = sizeof(si); 
	si.wShowWindow = SW_HIDE;//隐藏窗口
    si.hStdInput = inputFileHandle_;
    si.hStdOutput = si.hStdError = outputFileHandle_;
    si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; //使用handel项和wShowWindow项。

    DWORD createFlag = CREATE_SUSPENDED | CREATE_NO_WINDOW | CREATE_BREAKAWAY_FROM_JOB;

	bool res =  createProcess(
        NULL,    //   No module name (use command line).   
		cmdline, //   Command line.   
		NULL,    //   Process handle not inheritable.   
		NULL,    //   Thread handle not inheritable.   
		TRUE,   //   Set handle inheritance to ...
		createFlag, // creation  flags.  
		NULL,    //   Use parent 's environment block.   
		NULL,    //   Use parent 's starting  directory.   
		&si,     //   Pointer to STARTUPINFO structure. 
		&pi);    //   Pointer to PROCESS_INFORMAT\ION structure.

    
	if (!res)
    {
        logger->logErrorX(OJStr("[process] - can't creat process. last error: %u"), 
            GetLastError());
        return -1;
    }
		
    alive_ = true;
	processHandle_ = pi.hProcess;
	threadHandle_ = pi.hThread;

	if(startImmediately)
        return start();

	return 1;
}
Example #16
0
/*--------------------------------------------------------------------*/
void
RCGSplitter::printShowV4( const ShowInfoT & show )
{
    static const char * s_playmode_strings[] = PLAYMODE_STRINGS;

    static PlayMode s_playmode = PM_Null;
    static TeamT s_teams[2];

    bool new_file = createOutputFile( show.time_ );

    if ( ! M_fout.is_open() )
    {
        return;
    }

    std::ostream & os = M_fout;

    if ( new_file
         || s_playmode != M_playmode )
    {
        s_playmode = M_playmode;

        os << "(playmode " << M_time
           << " " << s_playmode_strings[s_playmode]
           << ")\n";
    }

    if  ( new_file
          || ! s_teams[0].equals( M_team_l )
          || ! s_teams[1].equals( M_team_r ) )
    {
        s_teams[0] = M_team_l;
        s_teams[1] = M_team_r;

        os << "(team " << M_time
           << ' ' << ( M_team_l.name_.empty() ? "null" : M_team_l.name_.c_str() )
           << ' ' << ( M_team_r.name_.empty() ? "null" : M_team_r.name_.c_str() )
           << ' ' << M_team_l.score_
           << ' ' << M_team_r.score_
           << ' ' << M_team_l.pen_score_
           << ' ' << M_team_r.pen_score_
           << ' ' << M_team_l.pen_miss_
           << ' ' << M_team_r.pen_miss_
           << ")\n";
    }


    os << "(show " << M_time;

    // ball
    os << "((b)"
       << ' ' << show.ball_.x_
       << ' ' << show.ball_.y_
       << ' ' << show.ball_.vx_
       << ' ' << show.ball_.vy_
       << ')';

    // players
    for ( int i = 0; i < MAX_PLAYER*2; ++i )
    {
        const PlayerT & p = show.player_[i];

        os << " ((" << p.side_ << ' ' << p.unum_ << ')';
        os << ' ' << p.type_;
        os << ' ' << std::hex << std::showbase << p.state_ << std::dec << std::noshowbase;

        os << ' ' << p.x_ << ' ' << p.y_
           << ' ' << p.vx_ << ' ' << p.vy_
           << ' ' << p.body_ << ' ' << p.neck_;
        if ( p.point_x_ != SHOWINFO_SCALE2F
             && p.point_y_ != SHOWINFO_SCALE2F )
        {
            os << ' ' << p.point_x_ << ' ' << p.point_y_;
        }


        os << " (v " << p.view_quality_ << ' ' << p.view_width_ << ')';

        os << " (s " << p.stamina_ << ' ' << p.effort_ << ' ' << p.recovery_ << ')';

        if ( p.focus_side_ != 'n' )
        {
            os << " (f" << p.focus_side_ << ' ' << p.focus_unum_ << ')';
        }

        os << " (c"
           << ' ' << p.kick_count_
           << ' ' << p.dash_count_
           << ' ' << p.turn_count_
           << ' ' << p.catch_count_
           << ' ' << p.move_count_
           << ' ' << p.turn_neck_count_
           << ' ' << p.change_view_count_
           << ' ' << p.say_count_
           << ' ' << p.tackle_count_
           << ' ' << p.pointto_count_
           << ' ' << p.attentionto_count_
           << ')';
        os << ')';
    }

    os << ")\n";
}