Ejemplo n.º 1
0
void ntScriptMgr::load()
{
    m_pLuaState= lua_open();
    luaL_openlibs(m_pLuaState);
    luaopen_gs(m_pLuaState);
    excute("dofile('../data/script/boot.lua')");
    ntLuaFunc<void>("ntInit")();
}
Ejemplo n.º 2
0
int main(const int argc, const char *argv[])
{
	int server_fd, client_fd;
	int read_size;
	short cmd_len;
	struct sockaddr addr;
	socklen_t alen;

	info_sys("backuprestore service start!");

	if ((server_fd = srv_create_sk()) < 0)
		err_sys("create socket server error");
	alen = sizeof(addr);

	info_sys("Server socket create successfully!");

	while(1){
		client_fd = accept(server_fd, (struct sockaddr*) &addr, &alen);
		if (client_fd < 0) {
			debug_sys("socket accept failed, please try again!");
			continue;
		}
		info_sys("before excute");
		while (1) {
			cmd_len = 0;
			if (readx(client_fd, &cmd_len, sizeof(cmd_len)) <= 0){
				debug_sys("cmd length read fail");
				break;
			}

			if (cmd_len < 1 || cmd_len > 2048){
				debug_sys("cmd length is not right");
				break;
			}

			if (readx(client_fd, &cmd, cmd_len) <= 0){
				debug_sys("read cmd fail");
				break;
			}
			cmd[cmd_len] = 0;
			if (excute(client_fd, cmd) < 0)
				break;
		}
		close(client_fd);
	}
	close(server_fd);
	info_sys("backuprestore service end!");
	return EXIT_SUCCESS;
}
Ejemplo n.º 3
0
void GamePlayScene::doErase() {
	if (!isOnPause() && getPuzzle()->isCellEditable(m_row, m_col)) {
		AbstractCommand *cmd;
		if (isOnNote()) {
			cmd = new CmdEditCellNote(this, m_time, m_row, m_col, 0,
					m_sudoku->getCellNotes(m_row, m_col));
		} else {
			cmd = new CmdEditCellValue(this, m_time, m_row, m_col, 0,
					m_sudoku->getCellValue(m_row, m_col));
//			doSetCellValue(m_row, m_col, 0);
		}
		excute(cmd);
	}
//	m_puzzleLayer->resetValues();
//	m_puzzleLayer->resetColors();
//	m_inputLayer->setUndoRedoButton();
}
Ejemplo n.º 4
0
main(int argc, char *argv[])
{
   //strcat(sucess, "Sucess");
   //strcat(failed, "Failed");
   char *hostname;
   char line[MAX];
   char temp[MAX];
   char *token;
   char* cmd;
   //char *myargv[32];
   int myargc;
   int i;
   bzero(cwd, MAX);
   hp = getenv("HOME");
   //strcpy(hd,getHomeDir(env));
   //uint16_t network_bytes_order_r, network_bytes_order_s;
   if (argc < 2)
      hostname = "localhost";
   else
      hostname = argv[1];
   if (argc < 3)
      cusPort = 3000;
   else
      cusPort = atoi(argv[2]);

   //cusPort = argv[2]; 
   server_init(hostname, cusPort); 
   //send(newsock, Welcom,MAX,MAX);
   // Try to accept a client request
   while(1){
     //int myargc = 0 ;
     char *myargv[32];
     int o = 0;
     printf("server: accepting new connection ....\n"); 

     // Try to accept a client connection as descriptor newsock
     length = sizeof(client_addr);
     newsock = accept(sock, (struct sockaddr *)&client_addr, &length);
     if (newsock < 0){
        printf("server: accept error\n");
        exit(1);
     }
     printf("server: accepted a client connection from\n");
     printf("-----------------------------------------------\n");
     printf("        IP=%s  port=%d\n", inet_ntoa(client_addr.sin_addr.s_addr),
                                        ntohs(client_addr.sin_port));
     printf("-----------------------------------------------\n");
     
     // Processing loop
     while(1){
       myargc = 0;
       n = read(newsock, line, MAX);
       if (n==0){
           printf("server: client died, server loops\n");
           close(newsock);
           break;
      }
      
      // show the line string
      printf("server: read  n=%d bytes; line=[%s]\n", n, line);
      printf("line + %s\n",line );
      strcpy(temp, line);
      token = strtok(temp," ");
      while(token != NULL){
        myargc++;
        myargv[o]=token;
        token = strtok(NULL, " ");
        o++;
      }
      
      cmd = myargv[0];
      excute(myargc, myargv);
      printf("\n");
      myargc = 0;
      o = 0;

      //bzero(myargv,MAX);
      // strcat(line, " ECHO");

      // // send the echo line to client 
      // n = write(newsock, line, MAX);

      // printf("server: wrote n=%d bytes; ECHO=[%s]\n", n, line);
      // printf("server: ready for next request\n");
    }
 }
}
Ejemplo n.º 5
0
bool ntScriptMgr::excute( const ntString& str )
{
    return excute(ntwtos(str));
}
Ejemplo n.º 6
0
int main () {
    FILE* iImage;
    FILE* dImage;
    FILE* snp;
    FILE* edp;
    unsigned int buffer;
    iImage = fopen ("iimage.bin","rb");
    dImage = fopen("dimage.bin","rb");
    snp = fopen("snapshot.rpt","w");
    edp = fopen("error_dump.rpt","w");
    int i=0;
    int j;

    while(fread(&buffer, 4, 1, dImage)){
        i++;
        if(i == 1){
            registers[sp] = rvs(buffer);
        }
        if(i == 2)Dnum = rvs(buffer);
        if(i > 2)Dm[i-3] = rvs(buffer);
    }
    i = 0;
    while(fread(&buffer, 4, 1, iImage)){
        i++;
        if(i > 256){
            error_ao = 1;
            break;
        }
        unsigned int db = rvs(buffer);
        if(i == 1){
            inPC = db;
            PC = db;
        }else if(i == 2){
            Inum = db;
        }else if(i > Inum+2){
            break;
        }else{
            Im[i-3] = db;
        }

    }
    int cycle = 0;
    IF = Im[0];
    fprintf(snp,"cycle %d\n",cycle);
    for(j = 0;j < 32;j++)fprintf(snp,"$%02d: 0x%08X\n",j,registers[j]);
    fprintf(snp,"PC: 0x%08X\n",PC);
    fprintf(snp,"IF: 0x%08X\n",IF);
    fprintf(snp,"ID: %s\n",ID);
    fprintf(snp,"EX: %s\n",EX);
    fprintf(snp,"DM: %s\n",DM);
    fprintf(snp,"WB: %s\n\n\n",WB);
    cycle++;
    char fwdedad = 0;
    int fwdedr = 0;
    int preIF = 0;
    for(i = 0;i < Inum;){

        if(fwded == 1)fwded = 0;
        if(for_id == 1){
            fwdedad = forad;
            fwdedr = fwdr;
            fwded = 1;
        }
        if(error() != 0 || error_w0 == 1 || error_no == 1){
            if(error_w0 == 1)fprintf(edp, "In cycle %d: Write $0 Error\n", cycle);
            if(error_ao == 1){
                fprintf(edp, "In cycle %d: Address Overflow\n", cycle);
                end = 1;
            }
            if(error_dm == 1){
                fprintf(edp, "In cycle %d: Misalignment Error\n", cycle);
                end = 1;
            }

            if(error_no == 1)fprintf(edp, "In cycle %d: Number Overflow\n", cycle);
            error_w0 = 0;
            error_ao = 0;
            error_no = 0;
            error_dm = 0;
        }
        if(end)break;
        if(IF == -1 && strcmp(EX,"HALT") == 0 && strcmp(ID,"HALT") == 0 && strcmp(DM,"HALT") == 0 && strcmp(WB,"HALT") == 0){
            break;
        }
        fprintf(snp,"cycle %d\n",cycle);
        for(j = 0;j < 32;j++){

            fprintf(snp,"$%02d: 0x%08X\n",j,registers[j]);
        }
        if(stall == 0)PC = PC+4;
        if(stall == 0)preIF = IF;
        IF = Im[(PC-inPC)/4];
        write();
        dm();
        excute();
        if(flush == 1){
            decode(0);
        }else{
            decode(preIF);
        }


        fprintf(snp,"PC: 0x%08X\n",PC);
        if(flush == 1){
            fprintf(snp,"IF: 0x%08X to_be_flushed\n",IF);
        }else if(stall == 1){
            fprintf(snp,"IF: 0x%08X to_be_stalled\n",IF);
        }else fprintf(snp,"IF: 0x%08X\n",IF);
        if(stall == 1){
            fprintf(snp,"ID: %s to_be_stalled\n",ID);
        }else if(for_Bie == 1){
            fprintf(snp,"ID: %s fwd_ID_EX_r%c_$%d\n",ID,forad,fwdr);
        }else if(for_B == 1){
            fprintf(snp,"ID: %s fwd_EX-DM_r%c_$%d\n",ID,forad,fwdr);
        }else fprintf(snp,"ID: %s\n",ID);
        if(fwded == 1){
            fprintf(snp,"EX: %s fwd_EX-DM_r%c_$%d\n",EX,fwdedad,fwdedr);
        }else fprintf(snp,"EX: %s\n",EX);
        fprintf(snp,"DM: %s\n",DM);
        fprintf(snp,"WB: %s\n\n\n",WB);
        if(PC%4 != 0)error_dm = 1;
        i = (PC-inPC)/4;
        cycle++;
    }
    return 0;
}
Ejemplo n.º 7
0
void JudgeTask::doRun()
{
    ILogger *logger = LoggerFactory::getLogger(LoggerId::AppInitLoggerId);

    OJString infoBuffer;

    FormatString(infoBuffer, OJStr("[JudgeTask] task %d"), Input.SolutionID);
    logger->logInfo(infoBuffer);

    //编译
    if(!compile())
    {
        return;
    }

    //搜索测试数据

    OJString path;
    FormatString(path, OJStr("%s/%d"), AppConfig::Path::TestDataPath.c_str(), Input.ProblemID);
    
    DebugMessage(OJStr("[JudgeTask] %d search path: %s"), Input.SolutionID, path.c_str());

    //TODO: 根据是否specialJudge,决定搜索.out还是.in文件。
    FileTool::FileNameList fileList;
    FileTool::GetSpecificExtFiles(fileList, path, OJStr(".out"), true);

    OJUInt32_t testCount = fileList.size();
    if(testCount <= 0)//没有测试数据
    {
        output_.Result = AppConfig::JudgeCode::SystemError;

        FormatString(infoBuffer, OJStr("[JudgeTask] not found test data for solution %d problem %d."),
            Input.SolutionID, Input.ProblemID);
        logger->logError(infoBuffer);
        return;
    }

    //测试多组数据
    OJUInt32_t accepted = 0;
    for(OJUInt32_t i=0; i<testCount; ++i)
    {
        answerOutputFile_ = fileList[i];
        answerInputFile_ = FileTool::RemoveFileExt(answerOutputFile_);
        answerInputFile_ += OJStr(".in");

        DebugMessage(OJStr("[JudgeTask] %d input file: %s"), 
            Input.SolutionID, answerInputFile_.c_str());
        DebugMessage(OJStr("[JudgeTask] %d output file: %s"), 
            Input.SolutionID, answerOutputFile_.c_str());

        if(!safeRemoveFile(userOutputFile_))
        {
            output_.Result = AppConfig::JudgeCode::SystemError;
            break;
        }

        if(!excute())
        {
            break;
        }
            
        if(!match())
        {
            break;
        }
        
        ++accepted;
    }

    output_.PassRate = float(accepted)/testCount;
}