示例#1
0
文件: main.c 项目: abashkirtsev/Shell
int RunPipe (struct data * d)
{
	int status = COMMAND_OK;
	int fd[2], prev, x;
	if (pipe (fd))
	{
		FreeBranch (d);
		FreeBranch (d);
		return COMMAND_FAIL;
	}
	PutPipeBuf (fd, &(d->pfd));
	x = d->pp;
	d->pp = 1;
	prev = d->out;
	d->out = fd[1];
	status = ProcessList (d);
	d->out = prev;
	if (status != COMMAND_OK)
	{
		d->pp = x;
		return status;
	}
	prev = d->in;
	d->in = fd[0];
	status = ProcessList (d);
	d->in = prev;
	d->pp = x;
	PopPipeBuf (&(d->pfd));
	status = WaitAllProcess (d);
	return status;
}
示例#2
0
文件: main.c 项目: abashkirtsev/Shell
int RunSerial (struct data * d)
{
	int status = COMMAND_OK;
	status = ProcessList (d);
	switch (status)
	{
		case COMMAND_OK:
		case COMMAND_FAIL:
			status = ProcessList (d);
	}
	return status;
}
示例#3
0
文件: main.c 项目: abashkirtsev/Shell
int RunOr (struct data * d)
{
	int status;
	status = ProcessList (d);
	switch (status)
	{
		case COMMAND_OK:
			FreeBranch (d);
			break;
		case COMMAND_FAIL:
			status = ProcessList (d);
	}
	return status;
}
示例#4
0
DWORD WINAPI Watch( void *p)
{
	TDATA *pData	= (TDATA*)p;
	DWORD	pid		= pData->pid;	// process의 ID
	//------------------------------
	HANDLE	hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
	if( hProcess == 0 )
	{
		MessageBox(0, "프로세스의 핸들을 얻을 수 없다.", "", MB_OK);
		return 0;
	}
	ListView_SetCheckState(hMainList, pData->idx, TRUE);

	//----- Event 관련 구현 추가 ---------------------------------
	HANDLE	hEvent		= CreateEvent(0, TRUE, 0, "Exit");	//-> Open.(동일한 객체의 핸들)
	HANDLE	h[2]		= { hProcess, hEvent };
	char    temp[50];
	DWORD ret = WaitForMultipleObjects( 2, h, FALSE, INFINITE);	// 부분 시그널

	if( ret		== WAIT_OBJECT_0)	// 프로세스가 시그널
	{
		wsprintf(temp, "[ %s ] 프로세스가 종료하였습니다.", pData->exename);
		SetWindowText(hStaticLog, temp);
		Sleep(1000);
	}

	CloseHandle( hEvent);
	CloseHandle(hProcess);
	delete pData;

	ProcessList();
	return 0;
}
示例#5
0
文件: main.c 项目: abashkirtsev/Shell
int RunBackground (struct data * d)
{
	int bg,
	    status = COMMAND_OK;
	bg = d->bg;
	d->bg = 1;
	status = ProcessList (d);
	d->bg = bg;
	return status;
}
示例#6
0
int main(int argc, char *argv[])
{
   int listenfd, connfd;
	char buf[N];
   struct sockaddr_in server_addr;

  // XXX:step 1  int socket(int domain, int type, int protocol);
   if ((listenfd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
   {
      fprintf(stderr, "fail to socket : %s\n", strerror(errno));
      exit(-1);
   }
#ifdef _DEBUG_
   printf("socket is %d\n", listenfd);
#endif  

  // XXX:step 2  int bind(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
   memset(&server_addr, 0, sizeof(server_addr));
   server_addr.sin_family = PF_INET;
   server_addr.sin_port = htons(8888);
   server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
	if (bind(listenfd, (SA *)&server_addr, sizeof(server_addr)) < 0)
	{
		perror("fail to bind");
		exit(-1);
	}

	listen(listenfd, 5);
  
   while ( 1 )
	{
		if ((connfd = accept(listenfd, NULL, NULL)) < 0)
		{
			perror("fail to accept");
			break;
		}
		recv(connfd, buf, N, 0);
		switch (buf[0])
		{
			case 'L' :
							ProcessList(connfd);
							break;
			case 'G' :
							ProcessGet(connfd, buf);
							break;
			case 'P' :
							ProcessPut(connfd, buf);
							break;
		}
		close(connfd);
	}

   return 0;
}
示例#7
0
void NewProcess(HWND hwnd)
{   

	UINT ret = DialogBoxParam( GetModuleHandle(0),
			MAKEINTRESOURCE(IDD_CREATEPROCESS),hwnd,
					NewProcessProc, // 메세지 함수.
					(LPARAM)0); 
	if ( ret == IDOK ) 
	{
		ProcessList();	
		SetWindowText(hStaticLog, "프로세스가 생성되었습니다");

	}
}
示例#8
0
文件: main.c 项目: abashkirtsev/Shell
void RunProgram (struct data * d)
{
	int status = COMMAND_OK;
	while (ScanTop (d->list) >= 0)
	{
		status = ProcessList (d);
		if (status == RUN_ERROR)
		{
			ClearComandsList (d->list);
			d->run = 0;
			break;
		}
	}
}
示例#9
0
void    IOList( void ) {
//================

// Process the input/output list.

    GStartIO();
    if( CITNode->link != NULL ) {
        if( RecNOpn() && RecNextOpr( OPR_TRM ) ) {
            AdvanceITPtr();                   // WRITE(6,3)
        } else if( Already( IO_NAMELIST ) ) {
            Error( IL_NO_IOLIST );
        }
        for(;;) {
            if( CITNode->link == NULL ) break;
            ProcessList();
        }
    }
    GStopIO();
}
void GOSoundGroupWorkItem::Run()
{
	if (m_Done == 3)
		return;
	{
		GOMutexLocker locker(m_Mutex);
		if (m_Done == 0)
		{
			m_Active.Move();
			m_Release.Move();
			m_Done = 1;
		}
		else
		{ 
			if (!m_Active.Peek() && !m_Release.Peek())
				return;
		}
		m_ActiveCount++;
	}
	float buffer[m_SamplesPerBuffer * 2];
	memset(buffer, 0, m_SamplesPerBuffer * 2 * sizeof(float));
	ProcessList(m_Active, buffer);
	ProcessReleaseList(m_Release, buffer);
	{
		GOMutexLocker locker(m_Mutex);
		if (m_Done == 1)
		{
			memcpy(m_Buffer, buffer, m_SamplesPerBuffer * 2 * sizeof(float));
			m_Done = 2;
		}
		else
		{
			for(unsigned i = 0; i < m_SamplesPerBuffer * 2; i++)
				m_Buffer[i] += buffer[i];
		}
		m_ActiveCount--;
		if (!m_ActiveCount)
		{
			m_Done = 3;
			m_Condition.Broadcast();
		}
	}
}
示例#11
0
void ProcessExit(HWND hwnd)
{
	char temp[10];
	DWORD pid;

	int idx  = ListView_GetNextItem(hMainList, -1, LVNI_ALL|LVNI_SELECTED);
	ListView_GetItemText(hMainList, idx, 1, temp, 10);
	pid = atoi(temp);
	HANDLE	hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
	if( hProcess)
	{
		TerminateProcess(hProcess, 1000);

		WaitForSingleObject(hProcess, INFINITE);

		ProcessList();

		SetWindowText(hStaticLog, "프로세스를 종료했습니다.");
	}
}
void MiniConstantPropagationPass::do_procedure_definition(ProcedureDefinition* p)
{
    procDef = p ;
    assert(procDef != NULL) ;
    OutputInformation("Mini Constant Propagation Pass begins") ;

    StatementList* innermostList = InnermostList(procDef) ;
    assert(innermostList != NULL) ;

    list<StatementList*>* allStatementLists =
        collect_objects<StatementList>(innermostList) ;

    list<StatementList*>::iterator listIter = allStatementLists->begin() ;
    while (listIter != allStatementLists->end())
    {
        ProcessList(*listIter) ;
        ++listIter ;
    }

    delete allStatementLists ;

    OutputInformation("Mini Constant Propagation Pass ends") ;
}
示例#13
0
文件: main.c 项目: abashkirtsev/Shell
int ProcessList (struct data * d)
{
	int status = COMMAND_OK;
	struct lexem * l;
	l = PopCom (d->list);
	if (l == NULL)
		return RUN_ERROR;
	switch (l->grp)
	{
		case CONDITIONS_AND:
			status = RunAnd (d);
			break;
		case CONDITIONS_OR:
			status = RunOr (d);
			break;
		case SEPARATOR:
			status = RunSerial (d);
			break;
		case AMPERSAND:
			status = RunBackground (d);
			break;
		case SEMICOLON:
			status = ProcessList (d);
			break;
		case PIPE:
			status = RunPipe (d);
			break;
		case COMMAND:
			d->l = l;
			status = RunCommand (d);
			break;
		default:
			status = RUN_ERROR;
	}
	DelLexem (l);
	return status;
}
示例#14
0
int main(int argc, char *argv[])
{
   int sockfd, fd, nbyte;
   char command[32];
   struct sockaddr_in server_addr;

   if (argc < 3)
	{
		printf("Usage : %s <server_ip> : <port>\n", argv[0]);
		exit(-1);
	}	
  
  // XXX:step 1  int socket(int domain, int type, int protocol);
   if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
   {
      fprintf(stderr, "fail to socket : %s\n", strerror(errno));
      exit(-1);
   }
#ifdef _DEBUG_
   printf("socket is %d\n", sockfd);
#endif  

  // XXX:step 2  int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
   memset(&server_addr, 0, sizeof(server_addr));
   server_addr.sin_family = PF_INET;
   server_addr.sin_port = htons(atoi(argv[2]));
   server_addr.sin_addr.s_addr = inet_addr(argv[1]);
   //server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  
	
  
   while ( 1 )
	{
      printf("<client> ");
		fgets(command, 32, stdin);
		command[strlen(command)-1] = '\0';  // overwrite the '\n' 
		if (strcmp(command, "help") == 0)
		{
		   PrintHelp();
		}
		else if (strcmp(command, "list") == 0)
		{
			ProcessList(server_addr);
		}
		else if (strncmp(command, "get ", 4) == 0)
		{
			ProcessGet(server_addr, command);
		}
		else if (strncmp(command, "put ", 4) == 0)
		{
			ProcessPut(server_addr, command);
		}
		else if (strcmp(command, "quit") == 0)
		{
			printf("Bye\n");
			break;
		}
		else
		{
			printf("wrong command, 'help' for command list\n");
		}
	}

   return 0;
}